Merge remote-tracking branch 'lsk/linux-linaro-lsk-v4.4-android' into linux-linaro...
[firefly-linux-kernel-4.4.55.git] / include / linux / if_pppox.h
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  */
15 #ifndef __LINUX_IF_PPPOX_H
16 #define __LINUX_IF_PPPOX_H
17
18 #include <linux/if.h>
19 #include <linux/netdevice.h>
20 #include <linux/ppp_channel.h>
21 #include <linux/skbuff.h>
22 #include <linux/workqueue.h>
23 #include <uapi/linux/if_pppox.h>
24
25 static inline struct pppoe_hdr *pppoe_hdr(const struct sk_buff *skb)
26 {
27         return (struct pppoe_hdr *)skb_network_header(skb);
28 }
29
30 struct pppoe_opt {
31         struct net_device      *dev;      /* device associated with socket*/
32         int                     ifindex;  /* ifindex of device associated with socket */
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) */
36         struct work_struct      padt_work;/* Work item for handling PADT */
37 };
38
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 };
46
47 struct pppolac_opt {
48         __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);
54 };
55
56 struct pppopns_opt {
57         __u16           local;
58         __u16           remote;
59         __u32           recv_sequence;
60         __u32           xmit_sequence;
61         void            (*data_ready)(struct sock *sk_raw);
62         int             (*backlog_rcv)(struct sock *sk_raw, struct sk_buff *skb);
63 };
64
65 #include <net/sock.h>
66
67 struct pppox_sock {
68         /* struct sock must be the first member of pppox_sock */
69         struct sock sk;
70         struct ppp_channel chan;
71         struct pppox_sock       *next;    /* for hash table */
72         union {
73                 struct pppoe_opt pppoe;
74                 struct pptp_opt  pptp;
75                 struct pppolac_opt lac;
76                 struct pppopns_opt pns;
77         } proto;
78         __be16                  num;
79 };
80 #define pppoe_dev       proto.pppoe.dev
81 #define pppoe_ifindex   proto.pppoe.ifindex
82 #define pppoe_pa        proto.pppoe.pa
83 #define pppoe_relay     proto.pppoe.relay
84
85 static inline struct pppox_sock *pppox_sk(struct sock *sk)
86 {
87         return (struct pppox_sock *)sk;
88 }
89
90 static inline struct sock *sk_pppox(struct pppox_sock *po)
91 {
92         return (struct sock *)po;
93 }
94
95 struct module;
96
97 struct pppox_proto {
98         int             (*create)(struct net *net, struct socket *sock, int kern);
99         int             (*ioctl)(struct socket *sock, unsigned int cmd,
100                                  unsigned long arg);
101         struct module   *owner;
102 };
103
104 extern int register_pppox_proto(int proto_num, const struct pppox_proto *pp);
105 extern void unregister_pppox_proto(int proto_num);
106 extern void pppox_unbind_sock(struct sock *sk);/* delete ppp-channel binding */
107 extern int pppox_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg);
108
109 /* PPPoX socket states */
110 enum {
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 */
115     PPPOX_ZOMBIE        = 8,  /* dead, but still bound to ppp device */
116     PPPOX_DEAD          = 16  /* dead, useless, please clean me up!*/
117 };
118
119 #endif /* !(__LINUX_IF_PPPOX_H) */