Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /*************************************************************************** |
| 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 Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | #ifndef __LINUX_IF_PPPOX_H |
| 16 | #define __LINUX_IF_PPPOX_H |
| 17 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | #include <linux/if.h> |
| 19 | #include <linux/netdevice.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | #include <linux/ppp_channel.h> |
Arnaldo Carvalho de Melo | 797659f | 2007-03-10 15:56:08 -0300 | [diff] [blame] | 21 | #include <linux/skbuff.h> |
Simon Farnsworth | 287f3a9 | 2015-03-01 10:54:39 +0000 | [diff] [blame^] | 22 | #include <linux/workqueue.h> |
David Howells | 607ca46 | 2012-10-13 10:46:48 +0100 | [diff] [blame] | 23 | #include <uapi/linux/if_pppox.h> |
Arnaldo Carvalho de Melo | 797659f | 2007-03-10 15:56:08 -0300 | [diff] [blame] | 24 | |
| 25 | static inline struct pppoe_hdr *pppoe_hdr(const struct sk_buff *skb) |
| 26 | { |
Arnaldo Carvalho de Melo | d56f90a | 2007-04-10 20:50:43 -0700 | [diff] [blame] | 27 | return (struct pppoe_hdr *)skb_network_header(skb); |
Arnaldo Carvalho de Melo | 797659f | 2007-03-10 15:56:08 -0300 | [diff] [blame] | 28 | } |
| 29 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | struct pppoe_opt { |
| 31 | struct net_device *dev; /* device associated with socket*/ |
Florian Zumbiehl | 6f30e18 | 2007-03-04 16:03:22 -0800 | [diff] [blame] | 32 | int ifindex; /* ifindex of device associated with socket */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | 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 Farnsworth | 287f3a9 | 2015-03-01 10:54:39 +0000 | [diff] [blame^] | 36 | struct work_struct padt_work;/* Work item for handling PADT */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | }; |
| 38 | |
Dmitry Kozlov | 00959ad | 2010-08-21 23:05:39 -0700 | [diff] [blame] | 39 | struct 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 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | #include <net/sock.h> |
| 47 | |
| 48 | struct pppox_sock { |
| 49 | /* struct sock must be the first member of pppox_sock */ |
Dmitry Kozlov | 00959ad | 2010-08-21 23:05:39 -0700 | [diff] [blame] | 50 | struct sock sk; |
| 51 | struct ppp_channel chan; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | struct pppox_sock *next; /* for hash table */ |
| 53 | union { |
| 54 | struct pppoe_opt pppoe; |
Dmitry Kozlov | 00959ad | 2010-08-21 23:05:39 -0700 | [diff] [blame] | 55 | struct pptp_opt pptp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 56 | } proto; |
Al Viro | b963dc1 | 2007-08-23 02:55:33 -0400 | [diff] [blame] | 57 | __be16 num; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | }; |
| 59 | #define pppoe_dev proto.pppoe.dev |
Florian Zumbiehl | 6f30e18 | 2007-03-04 16:03:22 -0800 | [diff] [blame] | 60 | #define pppoe_ifindex proto.pppoe.ifindex |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | #define pppoe_pa proto.pppoe.pa |
| 62 | #define pppoe_relay proto.pppoe.relay |
| 63 | |
| 64 | static inline struct pppox_sock *pppox_sk(struct sock *sk) |
| 65 | { |
| 66 | return (struct pppox_sock *)sk; |
| 67 | } |
| 68 | |
| 69 | static inline struct sock *sk_pppox(struct pppox_sock *po) |
| 70 | { |
| 71 | return (struct sock *)po; |
| 72 | } |
| 73 | |
| 74 | struct module; |
| 75 | |
| 76 | struct pppox_proto { |
Eric W. Biederman | 1b8d7ae | 2007-10-08 23:24:22 -0700 | [diff] [blame] | 77 | int (*create)(struct net *net, struct socket *sock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 78 | int (*ioctl)(struct socket *sock, unsigned int cmd, |
| 79 | unsigned long arg); |
| 80 | struct module *owner; |
| 81 | }; |
| 82 | |
Eric Dumazet | 756e64a | 2010-09-21 06:43:54 +0000 | [diff] [blame] | 83 | extern int register_pppox_proto(int proto_num, const struct pppox_proto *pp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | extern void unregister_pppox_proto(int proto_num); |
| 85 | extern void pppox_unbind_sock(struct sock *sk);/* delete ppp-channel binding */ |
David S. Miller | 17ba15f | 2005-12-27 20:57:40 -0800 | [diff] [blame] | 86 | extern int pppox_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 87 | |
| 88 | /* PPPoX socket states */ |
| 89 | enum { |
| 90 | PPPOX_NONE = 0, /* initial state */ |
| 91 | PPPOX_CONNECTED = 1, /* connection established ==TCP_ESTABLISHED */ |
| 92 | PPPOX_BOUND = 2, /* bound to ppp device */ |
| 93 | PPPOX_RELAY = 4, /* forwarding is enabled */ |
| 94 | PPPOX_ZOMBIE = 8, /* dead, but still bound to ppp device */ |
| 95 | PPPOX_DEAD = 16 /* dead, useless, please clean me up!*/ |
| 96 | }; |
| 97 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 98 | #endif /* !(__LINUX_IF_PPPOX_H) */ |