blob: 69e813bcb947ef59c1fc23e541a938d5c179d197 [file] [log] [blame]
Thomas Gleixner2874c5f2019-05-27 08:55:01 +02001/* SPDX-License-Identifier: GPL-2.0-or-later */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/***************************************************************************
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:
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070011#ifndef __LINUX_IF_PPPOX_H
12#define __LINUX_IF_PPPOX_H
13
Linus Torvalds1da177e2005-04-16 15:20:36 -070014#include <linux/if.h>
15#include <linux/netdevice.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070016#include <linux/ppp_channel.h>
Arnaldo Carvalho de Melo797659f2007-03-10 15:56:08 -030017#include <linux/skbuff.h>
Simon Farnsworth287f3a92015-03-01 10:54:39 +000018#include <linux/workqueue.h>
David Howells607ca462012-10-13 10:46:48 +010019#include <uapi/linux/if_pppox.h>
Arnaldo Carvalho de Melo797659f2007-03-10 15:56:08 -030020
21static inline struct pppoe_hdr *pppoe_hdr(const struct sk_buff *skb)
22{
Arnaldo Carvalho de Melod56f90a2007-04-10 20:50:43 -070023 return (struct pppoe_hdr *)skb_network_header(skb);
Arnaldo Carvalho de Melo797659f2007-03-10 15:56:08 -030024}
25
Linus Torvalds1da177e2005-04-16 15:20:36 -070026struct pppoe_opt {
27 struct net_device *dev; /* device associated with socket*/
Florian Zumbiehl6f30e182007-03-04 16:03:22 -080028 int ifindex; /* ifindex of device associated with socket */
Linus Torvalds1da177e2005-04-16 15:20:36 -070029 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) */
Simon Farnsworth287f3a92015-03-01 10:54:39 +000032 struct work_struct padt_work;/* Work item for handling PADT */
Linus Torvalds1da177e2005-04-16 15:20:36 -070033};
34
Dmitry Kozlov00959ad2010-08-21 23:05:39 -070035struct 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};
Linus Torvalds1da177e2005-04-16 15:20:36 -070042#include <net/sock.h>
43
44struct pppox_sock {
45 /* struct sock must be the first member of pppox_sock */
Dmitry Kozlov00959ad2010-08-21 23:05:39 -070046 struct sock sk;
47 struct ppp_channel chan;
Linus Torvalds1da177e2005-04-16 15:20:36 -070048 struct pppox_sock *next; /* for hash table */
49 union {
50 struct pppoe_opt pppoe;
Dmitry Kozlov00959ad2010-08-21 23:05:39 -070051 struct pptp_opt pptp;
Linus Torvalds1da177e2005-04-16 15:20:36 -070052 } proto;
Al Virob963dc12007-08-23 02:55:33 -040053 __be16 num;
Linus Torvalds1da177e2005-04-16 15:20:36 -070054};
55#define pppoe_dev proto.pppoe.dev
Florian Zumbiehl6f30e182007-03-04 16:03:22 -080056#define pppoe_ifindex proto.pppoe.ifindex
Linus Torvalds1da177e2005-04-16 15:20:36 -070057#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 {
Eric W. Biederman11aa9c22015-05-08 21:09:13 -050073 int (*create)(struct net *net, struct socket *sock, int kern);
Linus Torvalds1da177e2005-04-16 15:20:36 -070074 int (*ioctl)(struct socket *sock, unsigned int cmd,
75 unsigned long arg);
76 struct module *owner;
77};
78
Eric Dumazet756e64a2010-09-21 06:43:54 +000079extern int register_pppox_proto(int proto_num, const struct pppox_proto *pp);
Linus Torvalds1da177e2005-04-16 15:20:36 -070080extern void unregister_pppox_proto(int proto_num);
81extern void pppox_unbind_sock(struct sock *sk);/* delete ppp-channel binding */
David S. Miller17ba15f2005-12-27 20:57:40 -080082extern int pppox_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg);
Arnd Bergmann055d8822019-07-30 21:25:20 +020083extern int pppox_compat_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg);
84
85#define PPPOEIOCSFWD32 _IOW(0xB1 ,0, compat_size_t)
Linus Torvalds1da177e2005-04-16 15:20:36 -070086
87/* PPPoX socket states */
88enum {
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 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070093 PPPOX_DEAD = 16 /* dead, useless, please clean me up!*/
94};
95
Linus Torvalds1da177e2005-04-16 15:20:36 -070096#endif /* !(__LINUX_IF_PPPOX_H) */