blob: 325727a7096ae0525babccc76ce6a263738d224e [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/***************************************************************************
2 * Linux PPP over X - Generic PPP transport layer sockets
3 * Linux PPP over Ethernet (PPPoE) Socket Implementation (RFC 2516)
4 *
5 * This file supplies definitions required by the PPP over Ethernet driver
6 * (pppox.c). All version information wrt this file is located in pppox.c
7 *
8 * License:
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version
12 * 2 of the License, or (at your option) any later version.
13 *
14 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070015#ifndef __LINUX_IF_PPPOX_H
16#define __LINUX_IF_PPPOX_H
17
Linus Torvalds1da177e2005-04-16 15:20:36 -070018#include <linux/if.h>
19#include <linux/netdevice.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070020#include <linux/ppp_channel.h>
Arnaldo Carvalho de Melo797659f2007-03-10 15:56:08 -030021#include <linux/skbuff.h>
Simon Farnsworth287f3a92015-03-01 10:54:39 +000022#include <linux/workqueue.h>
David Howells607ca462012-10-13 10:46:48 +010023#include <uapi/linux/if_pppox.h>
Arnaldo Carvalho de Melo797659f2007-03-10 15:56:08 -030024
25static inline struct pppoe_hdr *pppoe_hdr(const struct sk_buff *skb)
26{
Arnaldo Carvalho de Melod56f90a2007-04-10 20:50:43 -070027 return (struct pppoe_hdr *)skb_network_header(skb);
Arnaldo Carvalho de Melo797659f2007-03-10 15:56:08 -030028}
29
Linus Torvalds1da177e2005-04-16 15:20:36 -070030struct pppoe_opt {
31 struct net_device *dev; /* device associated with socket*/
Florian Zumbiehl6f30e182007-03-04 16:03:22 -080032 int ifindex; /* ifindex of device associated with socket */
Linus Torvalds1da177e2005-04-16 15:20:36 -070033 struct pppoe_addr pa; /* what this socket is bound to*/
34 struct sockaddr_pppox relay; /* what socket data will be
35 relayed to (PPPoE relaying) */
Simon Farnsworth287f3a92015-03-01 10:54:39 +000036 struct work_struct padt_work;/* Work item for handling PADT */
Linus Torvalds1da177e2005-04-16 15:20:36 -070037};
38
Dmitry Kozlov00959ad2010-08-21 23:05:39 -070039struct pptp_opt {
40 struct pptp_addr src_addr;
41 struct pptp_addr dst_addr;
42 u32 ack_sent, ack_recv;
43 u32 seq_sent, seq_recv;
44 int ppp_flags;
45};
Chia-chi Yeheffa5132009-05-08 04:02:40 +080046
47struct pppolac_opt {
Chia-chi Yeh8d755902011-04-15 15:22:09 -070048 __u32 local;
49 __u32 remote;
50 __u32 recv_sequence;
51 __u32 xmit_sequence;
52 atomic_t sequencing;
53 int (*backlog_rcv)(struct sock *sk_udp, struct sk_buff *skb);
Chia-chi Yeheffa5132009-05-08 04:02:40 +080054};
55
Chia-chi Yeh69e8c022009-06-12 01:09:30 +080056struct pppopns_opt {
Chia-chi Yeh8d755902011-04-15 15:22:09 -070057 __u16 local;
58 __u16 remote;
59 __u32 recv_sequence;
60 __u32 xmit_sequence;
Jon Medhurst07597f42015-08-19 13:43:16 +010061 void (*data_ready)(struct sock *sk_raw);
Chia-chi Yeh8d755902011-04-15 15:22:09 -070062 int (*backlog_rcv)(struct sock *sk_raw, struct sk_buff *skb);
Chia-chi Yeh69e8c022009-06-12 01:09:30 +080063};
64
Linus Torvalds1da177e2005-04-16 15:20:36 -070065#include <net/sock.h>
66
67struct pppox_sock {
68 /* struct sock must be the first member of pppox_sock */
Dmitry Kozlov00959ad2010-08-21 23:05:39 -070069 struct sock sk;
70 struct ppp_channel chan;
Linus Torvalds1da177e2005-04-16 15:20:36 -070071 struct pppox_sock *next; /* for hash table */
72 union {
73 struct pppoe_opt pppoe;
Dmitry Kozlov00959ad2010-08-21 23:05:39 -070074 struct pptp_opt pptp;
Chia-chi Yeheffa5132009-05-08 04:02:40 +080075 struct pppolac_opt lac;
Chia-chi Yeh69e8c022009-06-12 01:09:30 +080076 struct pppopns_opt pns;
Linus Torvalds1da177e2005-04-16 15:20:36 -070077 } proto;
Al Virob963dc12007-08-23 02:55:33 -040078 __be16 num;
Linus Torvalds1da177e2005-04-16 15:20:36 -070079};
80#define pppoe_dev proto.pppoe.dev
Florian Zumbiehl6f30e182007-03-04 16:03:22 -080081#define pppoe_ifindex proto.pppoe.ifindex
Linus Torvalds1da177e2005-04-16 15:20:36 -070082#define pppoe_pa proto.pppoe.pa
83#define pppoe_relay proto.pppoe.relay
84
85static inline struct pppox_sock *pppox_sk(struct sock *sk)
86{
87 return (struct pppox_sock *)sk;
88}
89
90static inline struct sock *sk_pppox(struct pppox_sock *po)
91{
92 return (struct sock *)po;
93}
94
95struct module;
96
97struct pppox_proto {
Eric W. Biederman11aa9c22015-05-08 21:09:13 -050098 int (*create)(struct net *net, struct socket *sock, int kern);
Linus Torvalds1da177e2005-04-16 15:20:36 -070099 int (*ioctl)(struct socket *sock, unsigned int cmd,
100 unsigned long arg);
101 struct module *owner;
102};
103
Eric Dumazet756e64a2010-09-21 06:43:54 +0000104extern int register_pppox_proto(int proto_num, const struct pppox_proto *pp);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105extern void unregister_pppox_proto(int proto_num);
106extern void pppox_unbind_sock(struct sock *sk);/* delete ppp-channel binding */
David S. Miller17ba15f2005-12-27 20:57:40 -0800107extern int pppox_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108
109/* PPPoX socket states */
110enum {
111 PPPOX_NONE = 0, /* initial state */
112 PPPOX_CONNECTED = 1, /* connection established ==TCP_ESTABLISHED */
113 PPPOX_BOUND = 2, /* bound to ppp device */
114 PPPOX_RELAY = 4, /* forwarding is enabled */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115 PPPOX_DEAD = 16 /* dead, useless, please clean me up!*/
116};
117
Linus Torvalds1da177e2005-04-16 15:20:36 -0700118#endif /* !(__LINUX_IF_PPPOX_H) */