Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /***************************************************************************
0003  * Linux PPP over X - Generic PPP transport layer sockets
0004  * Linux PPP over Ethernet (PPPoE) Socket Implementation (RFC 2516) 
0005  *
0006  * This file supplies definitions required by the PPP over Ethernet driver
0007  * (pppox.c).  All version information wrt this file is located in pppox.c
0008  *
0009  * License:
0010  */
0011 #ifndef __LINUX_IF_PPPOX_H
0012 #define __LINUX_IF_PPPOX_H
0013 
0014 #include <linux/if.h>
0015 #include <linux/netdevice.h>
0016 #include <linux/ppp_channel.h>
0017 #include <linux/skbuff.h>
0018 #include <linux/workqueue.h>
0019 #include <uapi/linux/if_pppox.h>
0020 
0021 static inline struct pppoe_hdr *pppoe_hdr(const struct sk_buff *skb)
0022 {
0023     return (struct pppoe_hdr *)skb_network_header(skb);
0024 }
0025 
0026 struct pppoe_opt {
0027     struct net_device      *dev;      /* device associated with socket*/
0028     int         ifindex;  /* ifindex of device associated with socket */
0029     struct pppoe_addr   pa;   /* what this socket is bound to*/
0030     struct sockaddr_pppox   relay;    /* what socket data will be
0031                          relayed to (PPPoE relaying) */
0032     struct work_struct      padt_work;/* Work item for handling PADT */
0033 };
0034 
0035 struct pptp_opt {
0036     struct pptp_addr src_addr;
0037     struct pptp_addr dst_addr;
0038     u32 ack_sent, ack_recv;
0039     u32 seq_sent, seq_recv;
0040     int ppp_flags;
0041 };
0042 #include <net/sock.h>
0043 
0044 struct pppox_sock {
0045     /* struct sock must be the first member of pppox_sock */
0046     struct sock sk;
0047     struct ppp_channel chan;
0048     struct pppox_sock   *next;    /* for hash table */
0049     union {
0050         struct pppoe_opt pppoe;
0051         struct pptp_opt  pptp;
0052     } proto;
0053     __be16          num;
0054 };
0055 #define pppoe_dev   proto.pppoe.dev
0056 #define pppoe_ifindex   proto.pppoe.ifindex
0057 #define pppoe_pa    proto.pppoe.pa
0058 #define pppoe_relay proto.pppoe.relay
0059 
0060 static inline struct pppox_sock *pppox_sk(struct sock *sk)
0061 {
0062     return (struct pppox_sock *)sk;
0063 }
0064 
0065 static inline struct sock *sk_pppox(struct pppox_sock *po)
0066 {
0067     return (struct sock *)po;
0068 }
0069 
0070 struct module;
0071 
0072 struct pppox_proto {
0073     int     (*create)(struct net *net, struct socket *sock, int kern);
0074     int     (*ioctl)(struct socket *sock, unsigned int cmd,
0075                  unsigned long arg);
0076     struct module   *owner;
0077 };
0078 
0079 extern int register_pppox_proto(int proto_num, const struct pppox_proto *pp);
0080 extern void unregister_pppox_proto(int proto_num);
0081 extern void pppox_unbind_sock(struct sock *sk);/* delete ppp-channel binding */
0082 extern int pppox_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg);
0083 extern int pppox_compat_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg);
0084 
0085 #define PPPOEIOCSFWD32    _IOW(0xB1 ,0, compat_size_t)
0086 
0087 /* PPPoX socket states */
0088 enum {
0089     PPPOX_NONE      = 0,  /* initial state */
0090     PPPOX_CONNECTED = 1,  /* connection established ==TCP_ESTABLISHED */
0091     PPPOX_BOUND     = 2,  /* bound to ppp device */
0092     PPPOX_RELAY     = 4,  /* forwarding is enabled */
0093     PPPOX_DEAD      = 16  /* dead, useless, please clean me up!*/
0094 };
0095 
0096 #endif /* !(__LINUX_IF_PPPOX_H) */