1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /***************************************************************************
3 * Linux PPP over X - Generic PPP transport layer sockets
4 * Linux PPP over Ethernet (PPPoE) Socket Implementation (RFC 2516)
6 * This file supplies definitions required by the PPP over Ethernet driver
7 * (pppox.c). All version information wrt this file is located in pppox.c
11 #ifndef __LINUX_IF_PPPOX_H
12 #define __LINUX_IF_PPPOX_H
15 #include <linux/netdevice.h>
16 #include <linux/ppp_channel.h>
17 #include <linux/skbuff.h>
18 #include <linux/workqueue.h>
19 #include <uapi/linux/if_pppox.h>
21 static inline struct pppoe_hdr *pppoe_hdr(const struct sk_buff *skb)
23 return (struct pppoe_hdr *)skb_network_header(skb);
27 struct net_device *dev; /* device associated with socket*/
28 int ifindex; /* ifindex of device associated with socket */
29 struct pppoe_addr pa; /* what this socket is bound to*/
30 struct sockaddr_pppox relay; /* what socket data will be
31 relayed to (PPPoE relaying) */
32 struct work_struct padt_work;/* Work item for handling PADT */
36 struct pptp_addr src_addr;
37 struct pptp_addr dst_addr;
38 u32 ack_sent, ack_recv;
39 u32 seq_sent, seq_recv;
45 /* struct sock must be the first member of pppox_sock */
47 struct ppp_channel chan;
48 struct pppox_sock *next; /* for hash table */
50 struct pppoe_opt pppoe;
55 #define pppoe_dev proto.pppoe.dev
56 #define pppoe_ifindex proto.pppoe.ifindex
57 #define pppoe_pa proto.pppoe.pa
58 #define pppoe_relay proto.pppoe.relay
60 static inline struct pppox_sock *pppox_sk(struct sock *sk)
62 return (struct pppox_sock *)sk;
65 static inline struct sock *sk_pppox(struct pppox_sock *po)
67 return (struct sock *)po;
73 int (*create)(struct net *net, struct socket *sock, int kern);
74 int (*ioctl)(struct socket *sock, unsigned int cmd,
79 extern int register_pppox_proto(int proto_num, const struct pppox_proto *pp);
80 extern void unregister_pppox_proto(int proto_num);
81 extern void pppox_unbind_sock(struct sock *sk);/* delete ppp-channel binding */
82 extern int pppox_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg);
83 extern int pppox_compat_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg);
85 #define PPPOEIOCSFWD32 _IOW(0xB1 ,0, compat_size_t)
87 /* PPPoX socket states */
89 PPPOX_NONE = 0, /* initial state */
90 PPPOX_CONNECTED = 1, /* connection established ==TCP_ESTABLISHED */
91 PPPOX_BOUND = 2, /* bound to ppp device */
92 PPPOX_RELAY = 4, /* forwarding is enabled */
93 PPPOX_DEAD = 16 /* dead, useless, please clean me up!*/
96 #endif /* !(__LINUX_IF_PPPOX_H) */