xref: /OK3568_Linux_fs/kernel/include/linux/if_pppox.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0-or-later */
2*4882a593Smuzhiyun /***************************************************************************
3*4882a593Smuzhiyun  * Linux PPP over X - Generic PPP transport layer sockets
4*4882a593Smuzhiyun  * Linux PPP over Ethernet (PPPoE) Socket Implementation (RFC 2516)
5*4882a593Smuzhiyun  *
6*4882a593Smuzhiyun  * This file supplies definitions required by the PPP over Ethernet driver
7*4882a593Smuzhiyun  * (pppox.c).  All version information wrt this file is located in pppox.c
8*4882a593Smuzhiyun  *
9*4882a593Smuzhiyun  * License:
10*4882a593Smuzhiyun  */
11*4882a593Smuzhiyun #ifndef __LINUX_IF_PPPOX_H
12*4882a593Smuzhiyun #define __LINUX_IF_PPPOX_H
13*4882a593Smuzhiyun 
14*4882a593Smuzhiyun #include <linux/if.h>
15*4882a593Smuzhiyun #include <linux/netdevice.h>
16*4882a593Smuzhiyun #include <linux/ppp_channel.h>
17*4882a593Smuzhiyun #include <linux/skbuff.h>
18*4882a593Smuzhiyun #include <linux/workqueue.h>
19*4882a593Smuzhiyun #include <uapi/linux/if_pppox.h>
20*4882a593Smuzhiyun 
pppoe_hdr(const struct sk_buff * skb)21*4882a593Smuzhiyun static inline struct pppoe_hdr *pppoe_hdr(const struct sk_buff *skb)
22*4882a593Smuzhiyun {
23*4882a593Smuzhiyun 	return (struct pppoe_hdr *)skb_network_header(skb);
24*4882a593Smuzhiyun }
25*4882a593Smuzhiyun 
26*4882a593Smuzhiyun struct pppoe_opt {
27*4882a593Smuzhiyun 	struct net_device      *dev;	  /* device associated with socket*/
28*4882a593Smuzhiyun 	int			ifindex;  /* ifindex of device associated with socket */
29*4882a593Smuzhiyun 	struct pppoe_addr	pa;	  /* what this socket is bound to*/
30*4882a593Smuzhiyun 	struct sockaddr_pppox	relay;	  /* what socket data will be
31*4882a593Smuzhiyun 					     relayed to (PPPoE relaying) */
32*4882a593Smuzhiyun 	struct work_struct      padt_work;/* Work item for handling PADT */
33*4882a593Smuzhiyun };
34*4882a593Smuzhiyun 
35*4882a593Smuzhiyun struct pptp_opt {
36*4882a593Smuzhiyun 	struct pptp_addr src_addr;
37*4882a593Smuzhiyun 	struct pptp_addr dst_addr;
38*4882a593Smuzhiyun 	u32 ack_sent, ack_recv;
39*4882a593Smuzhiyun 	u32 seq_sent, seq_recv;
40*4882a593Smuzhiyun 	int ppp_flags;
41*4882a593Smuzhiyun };
42*4882a593Smuzhiyun #include <net/sock.h>
43*4882a593Smuzhiyun 
44*4882a593Smuzhiyun struct pppox_sock {
45*4882a593Smuzhiyun 	/* struct sock must be the first member of pppox_sock */
46*4882a593Smuzhiyun 	struct sock sk;
47*4882a593Smuzhiyun 	struct ppp_channel chan;
48*4882a593Smuzhiyun 	struct pppox_sock	*next;	  /* for hash table */
49*4882a593Smuzhiyun 	union {
50*4882a593Smuzhiyun 		struct pppoe_opt pppoe;
51*4882a593Smuzhiyun 		struct pptp_opt  pptp;
52*4882a593Smuzhiyun 	} proto;
53*4882a593Smuzhiyun 	__be16			num;
54*4882a593Smuzhiyun };
55*4882a593Smuzhiyun #define pppoe_dev	proto.pppoe.dev
56*4882a593Smuzhiyun #define pppoe_ifindex	proto.pppoe.ifindex
57*4882a593Smuzhiyun #define pppoe_pa	proto.pppoe.pa
58*4882a593Smuzhiyun #define pppoe_relay	proto.pppoe.relay
59*4882a593Smuzhiyun 
pppox_sk(struct sock * sk)60*4882a593Smuzhiyun static inline struct pppox_sock *pppox_sk(struct sock *sk)
61*4882a593Smuzhiyun {
62*4882a593Smuzhiyun 	return (struct pppox_sock *)sk;
63*4882a593Smuzhiyun }
64*4882a593Smuzhiyun 
sk_pppox(struct pppox_sock * po)65*4882a593Smuzhiyun static inline struct sock *sk_pppox(struct pppox_sock *po)
66*4882a593Smuzhiyun {
67*4882a593Smuzhiyun 	return (struct sock *)po;
68*4882a593Smuzhiyun }
69*4882a593Smuzhiyun 
70*4882a593Smuzhiyun struct module;
71*4882a593Smuzhiyun 
72*4882a593Smuzhiyun struct pppox_proto {
73*4882a593Smuzhiyun 	int		(*create)(struct net *net, struct socket *sock, int kern);
74*4882a593Smuzhiyun 	int		(*ioctl)(struct socket *sock, unsigned int cmd,
75*4882a593Smuzhiyun 				 unsigned long arg);
76*4882a593Smuzhiyun 	struct module	*owner;
77*4882a593Smuzhiyun };
78*4882a593Smuzhiyun 
79*4882a593Smuzhiyun extern int register_pppox_proto(int proto_num, const struct pppox_proto *pp);
80*4882a593Smuzhiyun extern void unregister_pppox_proto(int proto_num);
81*4882a593Smuzhiyun extern void pppox_unbind_sock(struct sock *sk);/* delete ppp-channel binding */
82*4882a593Smuzhiyun extern int pppox_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg);
83*4882a593Smuzhiyun extern int pppox_compat_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg);
84*4882a593Smuzhiyun 
85*4882a593Smuzhiyun #define PPPOEIOCSFWD32    _IOW(0xB1 ,0, compat_size_t)
86*4882a593Smuzhiyun 
87*4882a593Smuzhiyun /* PPPoX socket states */
88*4882a593Smuzhiyun enum {
89*4882a593Smuzhiyun     PPPOX_NONE		= 0,  /* initial state */
90*4882a593Smuzhiyun     PPPOX_CONNECTED	= 1,  /* connection established ==TCP_ESTABLISHED */
91*4882a593Smuzhiyun     PPPOX_BOUND		= 2,  /* bound to ppp device */
92*4882a593Smuzhiyun     PPPOX_RELAY		= 4,  /* forwarding is enabled */
93*4882a593Smuzhiyun     PPPOX_DEAD		= 16  /* dead, useless, please clean me up!*/
94*4882a593Smuzhiyun };
95*4882a593Smuzhiyun 
96*4882a593Smuzhiyun #endif /* !(__LINUX_IF_PPPOX_H) */
97