Merge branch 'pm-domains'
[cascardo/linux.git] / include / uapi / 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
16 #ifndef _UAPI__LINUX_IF_PPPOX_H
17 #define _UAPI__LINUX_IF_PPPOX_H
18
19
20 #include <linux/types.h>
21 #include <asm/byteorder.h>
22
23 #include <linux/socket.h>
24 #include <linux/if.h>
25 #include <linux/if_ether.h>
26 #include <linux/if_pppol2tp.h>
27 #include <linux/in.h>
28 #include <linux/in6.h>
29
30 /* For user-space programs to pick up these definitions
31  * which they wouldn't get otherwise without defining __KERNEL__
32  */
33 #ifndef AF_PPPOX
34 #define AF_PPPOX        24
35 #define PF_PPPOX        AF_PPPOX
36 #endif /* !(AF_PPPOX) */
37
38 /************************************************************************ 
39  * PPPoE addressing definition 
40  */ 
41 typedef __be16 sid_t;
42 struct pppoe_addr {
43         sid_t         sid;                    /* Session identifier */
44         unsigned char remote[ETH_ALEN];       /* Remote address */
45         char          dev[IFNAMSIZ];          /* Local device to use */
46 }; 
47  
48 /************************************************************************ 
49  * PPTP addressing definition
50  */
51 struct pptp_addr {
52         __u16           call_id;
53         struct in_addr  sin_addr;
54 };
55
56 /************************************************************************
57  * Protocols supported by AF_PPPOX
58  */
59 #define PX_PROTO_OE    0 /* Currently just PPPoE */
60 #define PX_PROTO_OL2TP 1 /* Now L2TP also */
61 #define PX_PROTO_PPTP  2
62 #define PX_MAX_PROTO   3
63
64 struct sockaddr_pppox {
65         __kernel_sa_family_t sa_family;       /* address family, AF_PPPOX */
66         unsigned int    sa_protocol;          /* protocol identifier */
67         union {
68                 struct pppoe_addr  pppoe;
69                 struct pptp_addr   pptp;
70         } sa_addr;
71 } __packed;
72
73 /* The use of the above union isn't viable because the size of this
74  * struct must stay fixed over time -- applications use sizeof(struct
75  * sockaddr_pppox) to fill it. We use a protocol specific sockaddr
76  * type instead.
77  */
78 struct sockaddr_pppol2tp {
79         __kernel_sa_family_t sa_family; /* address family, AF_PPPOX */
80         unsigned int    sa_protocol;    /* protocol identifier */
81         struct pppol2tp_addr pppol2tp;
82 } __packed;
83
84 struct sockaddr_pppol2tpin6 {
85         __kernel_sa_family_t sa_family; /* address family, AF_PPPOX */
86         unsigned int    sa_protocol;    /* protocol identifier */
87         struct pppol2tpin6_addr pppol2tp;
88 } __packed;
89
90 /* The L2TPv3 protocol changes tunnel and session ids from 16 to 32
91  * bits. So we need a different sockaddr structure.
92  */
93 struct sockaddr_pppol2tpv3 {
94         __kernel_sa_family_t sa_family; /* address family, AF_PPPOX */
95         unsigned int    sa_protocol;    /* protocol identifier */
96         struct pppol2tpv3_addr pppol2tp;
97 } __packed;
98
99 struct sockaddr_pppol2tpv3in6 {
100         __kernel_sa_family_t sa_family; /* address family, AF_PPPOX */
101         unsigned int    sa_protocol;    /* protocol identifier */
102         struct pppol2tpv3in6_addr pppol2tp;
103 } __packed;
104
105 /*********************************************************************
106  *
107  * ioctl interface for defining forwarding of connections
108  *
109  ********************************************************************/
110
111 #define PPPOEIOCSFWD    _IOW(0xB1 ,0, size_t)
112 #define PPPOEIOCDFWD    _IO(0xB1 ,1)
113 /*#define PPPOEIOCGFWD  _IOWR(0xB1,2, size_t)*/
114
115 /* Codes to identify message types */
116 #define PADI_CODE       0x09
117 #define PADO_CODE       0x07
118 #define PADR_CODE       0x19
119 #define PADS_CODE       0x65
120 #define PADT_CODE       0xa7
121 struct pppoe_tag {
122         __be16 tag_type;
123         __be16 tag_len;
124         char tag_data[0];
125 } __attribute__ ((packed));
126
127 /* Tag identifiers */
128 #define PTT_EOL         __cpu_to_be16(0x0000)
129 #define PTT_SRV_NAME    __cpu_to_be16(0x0101)
130 #define PTT_AC_NAME     __cpu_to_be16(0x0102)
131 #define PTT_HOST_UNIQ   __cpu_to_be16(0x0103)
132 #define PTT_AC_COOKIE   __cpu_to_be16(0x0104)
133 #define PTT_VENDOR      __cpu_to_be16(0x0105)
134 #define PTT_RELAY_SID   __cpu_to_be16(0x0110)
135 #define PTT_SRV_ERR     __cpu_to_be16(0x0201)
136 #define PTT_SYS_ERR     __cpu_to_be16(0x0202)
137 #define PTT_GEN_ERR     __cpu_to_be16(0x0203)
138
139 struct pppoe_hdr {
140 #if defined(__LITTLE_ENDIAN_BITFIELD)
141         __u8 type : 4;
142         __u8 ver : 4;
143 #elif defined(__BIG_ENDIAN_BITFIELD)
144         __u8 ver : 4;
145         __u8 type : 4;
146 #else
147 #error  "Please fix <asm/byteorder.h>"
148 #endif
149         __u8 code;
150         __be16 sid;
151         __be16 length;
152         struct pppoe_tag tag[0];
153 } __packed;
154
155 /* Length of entire PPPoE + PPP header */
156 #define PPPOE_SES_HLEN  8
157
158
159 #endif /* _UAPI__LINUX_IF_PPPOX_H */