]> git.ipfire.org Git - thirdparty/kernel/stable.git/blame - include/linux/if_pppox.h
treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 503
[thirdparty/kernel/stable.git] / include / linux / if_pppox.h
CommitLineData
2874c5fd 1/* SPDX-License-Identifier: GPL-2.0-or-later */
1da177e4
LT
2/***************************************************************************
3 * Linux PPP over X - Generic PPP transport layer sockets
4 * Linux PPP over Ethernet (PPPoE) Socket Implementation (RFC 2516)
5 *
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
8 *
9 * License:
1da177e4 10 */
1da177e4
LT
11#ifndef __LINUX_IF_PPPOX_H
12#define __LINUX_IF_PPPOX_H
13
1da177e4
LT
14#include <linux/if.h>
15#include <linux/netdevice.h>
1da177e4 16#include <linux/ppp_channel.h>
797659fb 17#include <linux/skbuff.h>
287f3a94 18#include <linux/workqueue.h>
607ca46e 19#include <uapi/linux/if_pppox.h>
797659fb
ACM
20
21static inline struct pppoe_hdr *pppoe_hdr(const struct sk_buff *skb)
22{
d56f90a7 23 return (struct pppoe_hdr *)skb_network_header(skb);
797659fb
ACM
24}
25
1da177e4
LT
26struct pppoe_opt {
27 struct net_device *dev; /* device associated with socket*/
6f30e186 28 int ifindex; /* ifindex of device associated with socket */
1da177e4
LT
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) */
287f3a94 32 struct work_struct padt_work;/* Work item for handling PADT */
1da177e4
LT
33};
34
00959ade
DK
35struct pptp_opt {
36 struct pptp_addr src_addr;
37 struct pptp_addr dst_addr;
38 u32 ack_sent, ack_recv;
39 u32 seq_sent, seq_recv;
40 int ppp_flags;
41};
1da177e4
LT
42#include <net/sock.h>
43
44struct pppox_sock {
45 /* struct sock must be the first member of pppox_sock */
00959ade
DK
46 struct sock sk;
47 struct ppp_channel chan;
1da177e4
LT
48 struct pppox_sock *next; /* for hash table */
49 union {
50 struct pppoe_opt pppoe;
00959ade 51 struct pptp_opt pptp;
1da177e4 52 } proto;
b963dc1d 53 __be16 num;
1da177e4
LT
54};
55#define pppoe_dev proto.pppoe.dev
6f30e186 56#define pppoe_ifindex proto.pppoe.ifindex
1da177e4
LT
57#define pppoe_pa proto.pppoe.pa
58#define pppoe_relay proto.pppoe.relay
59
60static inline struct pppox_sock *pppox_sk(struct sock *sk)
61{
62 return (struct pppox_sock *)sk;
63}
64
65static inline struct sock *sk_pppox(struct pppox_sock *po)
66{
67 return (struct sock *)po;
68}
69
70struct module;
71
72struct pppox_proto {
11aa9c28 73 int (*create)(struct net *net, struct socket *sock, int kern);
1da177e4
LT
74 int (*ioctl)(struct socket *sock, unsigned int cmd,
75 unsigned long arg);
76 struct module *owner;
77};
78
756e64a0 79extern int register_pppox_proto(int proto_num, const struct pppox_proto *pp);
1da177e4
LT
80extern void unregister_pppox_proto(int proto_num);
81extern void pppox_unbind_sock(struct sock *sk);/* delete ppp-channel binding */
17ba15fb 82extern int pppox_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg);
1da177e4
LT
83
84/* PPPoX socket states */
85enum {
86 PPPOX_NONE = 0, /* initial state */
87 PPPOX_CONNECTED = 1, /* connection established ==TCP_ESTABLISHED */
88 PPPOX_BOUND = 2, /* bound to ppp device */
89 PPPOX_RELAY = 4, /* forwarding is enabled */
1da177e4
LT
90 PPPOX_DEAD = 16 /* dead, useless, please clean me up!*/
91};
92
1da177e4 93#endif /* !(__LINUX_IF_PPPOX_H) */