blob: aff7ad8a4ea3cdea45daca2049a7b83dc8151cc3 [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>
David Howells607ca462012-10-13 10:46:48 +010022#include <uapi/linux/if_pppox.h>
Arnaldo Carvalho de Melo797659f2007-03-10 15:56:08 -030023
24static inline struct pppoe_hdr *pppoe_hdr(const struct sk_buff *skb)
25{
Arnaldo Carvalho de Melod56f90a2007-04-10 20:50:43 -070026 return (struct pppoe_hdr *)skb_network_header(skb);
Arnaldo Carvalho de Melo797659f2007-03-10 15:56:08 -030027}
28
Linus Torvalds1da177e2005-04-16 15:20:36 -070029struct pppoe_opt {
30 struct net_device *dev; /* device associated with socket*/
Florian Zumbiehl6f30e182007-03-04 16:03:22 -080031 int ifindex; /* ifindex of device associated with socket */
Linus Torvalds1da177e2005-04-16 15:20:36 -070032 struct pppoe_addr pa; /* what this socket is bound to*/
33 struct sockaddr_pppox relay; /* what socket data will be
34 relayed to (PPPoE relaying) */
35};
36
Dmitry Kozlov00959ad2010-08-21 23:05:39 -070037struct pptp_opt {
38 struct pptp_addr src_addr;
39 struct pptp_addr dst_addr;
40 u32 ack_sent, ack_recv;
41 u32 seq_sent, seq_recv;
42 int ppp_flags;
43};
Linus Torvalds1da177e2005-04-16 15:20:36 -070044#include <net/sock.h>
45
46struct pppox_sock {
47 /* struct sock must be the first member of pppox_sock */
Dmitry Kozlov00959ad2010-08-21 23:05:39 -070048 struct sock sk;
49 struct ppp_channel chan;
Linus Torvalds1da177e2005-04-16 15:20:36 -070050 struct pppox_sock *next; /* for hash table */
51 union {
52 struct pppoe_opt pppoe;
Dmitry Kozlov00959ad2010-08-21 23:05:39 -070053 struct pptp_opt pptp;
Linus Torvalds1da177e2005-04-16 15:20:36 -070054 } proto;
Al Virob963dc12007-08-23 02:55:33 -040055 __be16 num;
Linus Torvalds1da177e2005-04-16 15:20:36 -070056};
57#define pppoe_dev proto.pppoe.dev
Florian Zumbiehl6f30e182007-03-04 16:03:22 -080058#define pppoe_ifindex proto.pppoe.ifindex
Linus Torvalds1da177e2005-04-16 15:20:36 -070059#define pppoe_pa proto.pppoe.pa
60#define pppoe_relay proto.pppoe.relay
61
62static inline struct pppox_sock *pppox_sk(struct sock *sk)
63{
64 return (struct pppox_sock *)sk;
65}
66
67static inline struct sock *sk_pppox(struct pppox_sock *po)
68{
69 return (struct sock *)po;
70}
71
72struct module;
73
74struct pppox_proto {
Eric W. Biederman1b8d7ae2007-10-08 23:24:22 -070075 int (*create)(struct net *net, struct socket *sock);
Linus Torvalds1da177e2005-04-16 15:20:36 -070076 int (*ioctl)(struct socket *sock, unsigned int cmd,
77 unsigned long arg);
78 struct module *owner;
79};
80
Eric Dumazet756e64a2010-09-21 06:43:54 +000081extern int register_pppox_proto(int proto_num, const struct pppox_proto *pp);
Linus Torvalds1da177e2005-04-16 15:20:36 -070082extern void unregister_pppox_proto(int proto_num);
83extern void pppox_unbind_sock(struct sock *sk);/* delete ppp-channel binding */
David S. Miller17ba15f2005-12-27 20:57:40 -080084extern int pppox_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg);
Linus Torvalds1da177e2005-04-16 15:20:36 -070085
86/* PPPoX socket states */
87enum {
88 PPPOX_NONE = 0, /* initial state */
89 PPPOX_CONNECTED = 1, /* connection established ==TCP_ESTABLISHED */
90 PPPOX_BOUND = 2, /* bound to ppp device */
91 PPPOX_RELAY = 4, /* forwarding is enabled */
92 PPPOX_ZOMBIE = 8, /* dead, but still bound to ppp device */
93 PPPOX_DEAD = 16 /* dead, useless, please clean me up!*/
94};
95
Linus Torvalds1da177e2005-04-16 15:20:36 -070096#endif /* !(__LINUX_IF_PPPOX_H) */