BCM WL 6.30.102.9 (r366174)
[tomato.git] / release / src-rt / linux / linux-2.6 / include / linux / if_pppox.h
blobf92682c976dcc36b2a809243e557e90654b763df
1 /***************************************************************************
2 * Linux PPP over X - Generic PPP transport layer sockets
3 * Linux PPP over Ethernet (PPPoE) Socket Implementation (RFC 2516)
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
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.
16 #ifndef __LINUX_IF_PPPOX_H
17 #define __LINUX_IF_PPPOX_H
20 #include <asm/types.h>
21 #ifdef __KERNEL__
22 #include <asm/byteorder.h>
23 #else
24 #include <endian.h>
25 #include <byteswap.h>
26 #if __BYTE_ORDER == __LITTLE_ENDIAN
27 #define __LITTLE_ENDIAN_BITFIELD
28 #elif __BYTE_ORDER == __BIG_ENDIAN
29 #define __BIG_ENDIAN_BITFIELD
30 #else
31 #error "Adjust your <endian.h> defines."
32 #endif
33 #endif
35 #ifdef __KERNEL__
36 #include <linux/if_ether.h>
37 #include <linux/if.h>
38 #include <linux/netdevice.h>
39 #include <linux/in.h>
40 #include <asm/semaphore.h>
41 #include <linux/ppp_channel.h>
42 #endif /* __KERNEL__ */
43 #include <linux/if_pppol2tp.h>
45 /* For user-space programs to pick up these definitions
46 * which they wouldn't get otherwise without defining __KERNEL__
48 #ifndef AF_PPPOX
49 #define AF_PPPOX 24
50 #define PF_PPPOX AF_PPPOX
51 #endif /* !(AF_PPPOX) */
53 /************************************************************************
54 * PPPoE addressing definition
55 */
56 typedef __be16 sid_t;
57 struct pppoe_addr{
58 sid_t sid; /* Session identifier */
59 unsigned char remote[ETH_ALEN]; /* Remote address */
60 char dev[IFNAMSIZ]; /* Local device to use */
61 };
63 struct pptp_addr {
64 __u16 call_id;
65 struct in_addr sin_addr;
68 /************************************************************************
69 * Protocols supported by AF_PPPOX
70 */
71 #define PX_PROTO_OE 0 /* Currently just PPPoE */
72 #define PX_PROTO_OL2TP 1 /* Now L2TP also */
73 #define PX_PROTO_PPTP 2
74 #define PX_MAX_PROTO 3
76 struct sockaddr_pppox {
77 sa_family_t sa_family; /* address family, AF_PPPOX */
78 unsigned int sa_protocol; /* protocol identifier */
79 union{
80 struct pppoe_addr pppoe;
81 struct pptp_addr pptp;
82 }sa_addr;
83 }__attribute__ ((packed)); /* deprecated */
85 /* The use of the above union isn't viable because the size of this
86 * struct must stay fixed over time -- applications use sizeof(struct
87 * sockaddr_pppox) to fill it. We use a protocol specific sockaddr
88 * type instead.
90 struct sockaddr_pppoe {
91 sa_family_t sa_family; /* address family, AF_PPPOX */
92 unsigned int sa_protocol; /* protocol identifier */
93 struct pppoe_addr pppoe;
94 }__attribute__ ((packed));
96 struct sockaddr_pppol2tp {
97 sa_family_t sa_family; /* address family, AF_PPPOX */
98 unsigned int sa_protocol; /* protocol identifier */
99 struct pppol2tp_addr pppol2tp;
100 }__attribute__ ((packed));
102 /* Socket options */
103 #define PPTP_SO_TIMEOUT 1
104 #define PPTP_SO_WINDOW 2
106 /*********************************************************************
108 * ioctl interface for defining forwarding of connections
110 ********************************************************************/
112 #define PPPOEIOCSFWD _IOW(0xB1 ,0, size_t)
113 #define PPPOEIOCDFWD _IO(0xB1 ,1)
114 /*#define PPPOEIOCGFWD _IOWR(0xB1, 2, size_t)*/
115 #define PPPTPIOWFP _IOWR(0xB1 ,2, size_t)*/
117 /* Codes to identify message types */
118 #define PADI_CODE 0x09
119 #define PADO_CODE 0x07
120 #define PADR_CODE 0x19
121 #define PADS_CODE 0x65
122 #define PADT_CODE 0xa7
123 struct pppoe_tag {
124 __be16 tag_type;
125 __be16 tag_len;
126 char tag_data[0];
127 } __attribute ((packed));
129 /* Tag identifiers */
130 #define PTT_EOL __constant_htons(0x0000)
131 #define PTT_SRV_NAME __constant_htons(0x0101)
132 #define PTT_AC_NAME __constant_htons(0x0102)
133 #define PTT_HOST_UNIQ __constant_htons(0x0103)
134 #define PTT_AC_COOKIE __constant_htons(0x0104)
135 #define PTT_VENDOR __constant_htons(0x0105)
136 #define PTT_RELAY_SID __constant_htons(0x0110)
137 #define PTT_SRV_ERR __constant_htons(0x0201)
138 #define PTT_SYS_ERR __constant_htons(0x0202)
139 #define PTT_GEN_ERR __constant_htons(0x0203)
141 struct pppoe_hdr {
142 #if defined(__LITTLE_ENDIAN_BITFIELD)
143 __u8 ver : 4;
144 __u8 type : 4;
145 #elif defined(__BIG_ENDIAN_BITFIELD)
146 __u8 type : 4;
147 __u8 ver : 4;
148 #else
149 #error "Please fix <asm/byteorder.h>"
150 #endif
151 __u8 code;
152 __be16 sid;
153 __be16 length;
154 struct pppoe_tag tag[0];
155 } __attribute__ ((packed));
157 /* Length of entire PPPoE + PPP header */
158 #define PPPOE_SES_HLEN 8
160 #ifdef __KERNEL__
161 #include <linux/skbuff.h>
163 static inline struct pppoe_hdr *pppoe_hdr(const struct sk_buff *skb)
165 return (struct pppoe_hdr *)skb_network_header(skb);
168 struct pppoe_opt {
169 struct net_device *dev; /* device associated with socket*/
170 int ifindex; /* ifindex of device associated with socket */
171 struct pppoe_addr pa; /* what this socket is bound to*/
172 struct sockaddr_pppox relay; /* what socket data will be
173 relayed to (PPPoE relaying) */
176 struct pptp_opt {
177 struct pptp_addr src_addr;
178 struct pptp_addr dst_addr;
179 __u32 ack_sent, ack_recv;
180 __u32 seq_sent, seq_recv;
181 int ppp_flags;
184 #define PPTP_FLAG_PAUSE 0
185 #define PPTP_FLAG_PROC 1
187 #include <net/sock.h>
189 struct pppox_sock {
190 /* struct sock must be the first member of pppox_sock */
191 struct sock sk;
192 struct ppp_channel chan;
193 struct pppox_sock *next; /* for hash table */
194 union {
195 struct pppoe_opt pppoe;
196 struct pptp_opt pptp;
197 } proto;
198 __be16 num;
200 #define pppoe_dev proto.pppoe.dev
201 #define pppoe_ifindex proto.pppoe.ifindex
202 #define pppoe_pa proto.pppoe.pa
203 #define pppoe_relay proto.pppoe.relay
205 static inline struct pppox_sock *pppox_sk(struct sock *sk)
207 return (struct pppox_sock *)sk;
210 static inline struct sock *sk_pppox(struct pppox_sock *po)
212 return (struct sock *)po;
215 struct module;
217 struct pppox_proto {
218 int (*create)(struct socket *sock);
219 int (*ioctl)(struct socket *sock, unsigned int cmd,
220 unsigned long arg);
221 struct module *owner;
224 extern int register_pppox_proto(int proto_num, struct pppox_proto *pp);
225 extern void unregister_pppox_proto(int proto_num);
226 extern void pppox_unbind_sock(struct sock *sk);/* delete ppp-channel binding */
227 extern int pppox_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg);
229 /* PPPoX socket states */
230 enum {
231 PPPOX_NONE = 0, /* initial state */
232 PPPOX_CONNECTED = 1, /* connection established ==TCP_ESTABLISHED */
233 PPPOX_BOUND = 2, /* bound to ppp device */
234 PPPOX_RELAY = 4, /* forwarding is enabled */
235 PPPOX_ZOMBIE = 8, /* dead, but still bound to ppp device */
236 PPPOX_DEAD = 16 /* dead, useless, please clean me up!*/
239 #endif /* __KERNEL__ */
241 #endif /* !(__LINUX_IF_PPPOX_H) */