xref: /linux/include/uapi/linux/if_pppox.h (revision ebd8b934e23f45ad3fc8a5a28bc5a96741a6a106)
1607ca46eSDavid Howells /***************************************************************************
2607ca46eSDavid Howells  * Linux PPP over X - Generic PPP transport layer sockets
3607ca46eSDavid Howells  * Linux PPP over Ethernet (PPPoE) Socket Implementation (RFC 2516)
4607ca46eSDavid Howells  *
5607ca46eSDavid Howells  * This file supplies definitions required by the PPP over Ethernet driver
6607ca46eSDavid Howells  * (pppox.c).  All version information wrt this file is located in pppox.c
7607ca46eSDavid Howells  *
8607ca46eSDavid Howells  * License:
9607ca46eSDavid Howells  *		This program is free software; you can redistribute it and/or
10607ca46eSDavid Howells  *		modify it under the terms of the GNU General Public License
11607ca46eSDavid Howells  *		as published by the Free Software Foundation; either version
12607ca46eSDavid Howells  *		2 of the License, or (at your option) any later version.
13607ca46eSDavid Howells  *
14607ca46eSDavid Howells  */
15607ca46eSDavid Howells 
16607ca46eSDavid Howells #ifndef _UAPI__LINUX_IF_PPPOX_H
17607ca46eSDavid Howells #define _UAPI__LINUX_IF_PPPOX_H
18607ca46eSDavid Howells 
19607ca46eSDavid Howells 
20607ca46eSDavid Howells #include <linux/types.h>
21607ca46eSDavid Howells #include <asm/byteorder.h>
22607ca46eSDavid Howells 
23607ca46eSDavid Howells #include <linux/socket.h>
24607ca46eSDavid Howells #include <linux/if_ether.h>
25607ca46eSDavid Howells #include <linux/if_pppol2tp.h>
26607ca46eSDavid Howells 
27607ca46eSDavid Howells /* For user-space programs to pick up these definitions
28607ca46eSDavid Howells  * which they wouldn't get otherwise without defining __KERNEL__
29607ca46eSDavid Howells  */
30607ca46eSDavid Howells #ifndef AF_PPPOX
31607ca46eSDavid Howells #define AF_PPPOX	24
32607ca46eSDavid Howells #define PF_PPPOX	AF_PPPOX
33607ca46eSDavid Howells #endif /* !(AF_PPPOX) */
34607ca46eSDavid Howells 
35607ca46eSDavid Howells /************************************************************************
36607ca46eSDavid Howells  * PPPoE addressing definition
37607ca46eSDavid Howells  */
38607ca46eSDavid Howells typedef __be16 sid_t;
39607ca46eSDavid Howells struct pppoe_addr {
40607ca46eSDavid Howells 	sid_t         sid;                    /* Session identifier */
41607ca46eSDavid Howells 	unsigned char remote[ETH_ALEN];       /* Remote address */
42607ca46eSDavid Howells 	char          dev[IFNAMSIZ];          /* Local device to use */
43607ca46eSDavid Howells };
44607ca46eSDavid Howells 
45607ca46eSDavid Howells /************************************************************************
46607ca46eSDavid Howells  * PPTP addressing definition
47607ca46eSDavid Howells  */
48607ca46eSDavid Howells struct pptp_addr {
49*ebd8b934Sstephen hemminger 	__u16		call_id;
50607ca46eSDavid Howells 	struct in_addr	sin_addr;
51607ca46eSDavid Howells };
52607ca46eSDavid Howells 
53607ca46eSDavid Howells /************************************************************************
54607ca46eSDavid Howells  * Protocols supported by AF_PPPOX
55607ca46eSDavid Howells  */
56607ca46eSDavid Howells #define PX_PROTO_OE    0 /* Currently just PPPoE */
57607ca46eSDavid Howells #define PX_PROTO_OL2TP 1 /* Now L2TP also */
58607ca46eSDavid Howells #define PX_PROTO_PPTP  2
59607ca46eSDavid Howells #define PX_MAX_PROTO   3
60607ca46eSDavid Howells 
61607ca46eSDavid Howells struct sockaddr_pppox {
62607ca46eSDavid Howells 	__kernel_sa_family_t sa_family;       /* address family, AF_PPPOX */
63607ca46eSDavid Howells 	unsigned int    sa_protocol;          /* protocol identifier */
64607ca46eSDavid Howells 	union {
65607ca46eSDavid Howells 		struct pppoe_addr  pppoe;
66607ca46eSDavid Howells 		struct pptp_addr   pptp;
67607ca46eSDavid Howells 	} sa_addr;
68607ca46eSDavid Howells } __packed;
69607ca46eSDavid Howells 
70607ca46eSDavid Howells /* The use of the above union isn't viable because the size of this
71607ca46eSDavid Howells  * struct must stay fixed over time -- applications use sizeof(struct
72607ca46eSDavid Howells  * sockaddr_pppox) to fill it. We use a protocol specific sockaddr
73607ca46eSDavid Howells  * type instead.
74607ca46eSDavid Howells  */
75607ca46eSDavid Howells struct sockaddr_pppol2tp {
76607ca46eSDavid Howells 	__kernel_sa_family_t sa_family; /* address family, AF_PPPOX */
77607ca46eSDavid Howells 	unsigned int    sa_protocol;    /* protocol identifier */
78607ca46eSDavid Howells 	struct pppol2tp_addr pppol2tp;
79607ca46eSDavid Howells } __packed;
80607ca46eSDavid Howells 
81607ca46eSDavid Howells struct sockaddr_pppol2tpin6 {
82607ca46eSDavid Howells 	__kernel_sa_family_t sa_family; /* address family, AF_PPPOX */
83607ca46eSDavid Howells 	unsigned int    sa_protocol;    /* protocol identifier */
84607ca46eSDavid Howells 	struct pppol2tpin6_addr pppol2tp;
85607ca46eSDavid Howells } __packed;
86607ca46eSDavid Howells 
87607ca46eSDavid Howells /* The L2TPv3 protocol changes tunnel and session ids from 16 to 32
88607ca46eSDavid Howells  * bits. So we need a different sockaddr structure.
89607ca46eSDavid Howells  */
90607ca46eSDavid Howells struct sockaddr_pppol2tpv3 {
91607ca46eSDavid Howells 	__kernel_sa_family_t sa_family; /* address family, AF_PPPOX */
92607ca46eSDavid Howells 	unsigned int    sa_protocol;    /* protocol identifier */
93607ca46eSDavid Howells 	struct pppol2tpv3_addr pppol2tp;
94607ca46eSDavid Howells } __packed;
95607ca46eSDavid Howells 
96607ca46eSDavid Howells struct sockaddr_pppol2tpv3in6 {
97607ca46eSDavid Howells 	__kernel_sa_family_t sa_family; /* address family, AF_PPPOX */
98607ca46eSDavid Howells 	unsigned int    sa_protocol;    /* protocol identifier */
99607ca46eSDavid Howells 	struct pppol2tpv3in6_addr pppol2tp;
100607ca46eSDavid Howells } __packed;
101607ca46eSDavid Howells 
102607ca46eSDavid Howells /*********************************************************************
103607ca46eSDavid Howells  *
104607ca46eSDavid Howells  * ioctl interface for defining forwarding of connections
105607ca46eSDavid Howells  *
106607ca46eSDavid Howells  ********************************************************************/
107607ca46eSDavid Howells 
108607ca46eSDavid Howells #define PPPOEIOCSFWD	_IOW(0xB1 ,0, size_t)
109607ca46eSDavid Howells #define PPPOEIOCDFWD	_IO(0xB1 ,1)
110607ca46eSDavid Howells /*#define PPPOEIOCGFWD	_IOWR(0xB1,2, size_t)*/
111607ca46eSDavid Howells 
112607ca46eSDavid Howells /* Codes to identify message types */
113607ca46eSDavid Howells #define PADI_CODE	0x09
114607ca46eSDavid Howells #define PADO_CODE	0x07
115607ca46eSDavid Howells #define PADR_CODE	0x19
116607ca46eSDavid Howells #define PADS_CODE	0x65
117607ca46eSDavid Howells #define PADT_CODE	0xa7
118607ca46eSDavid Howells struct pppoe_tag {
119607ca46eSDavid Howells 	__be16 tag_type;
120607ca46eSDavid Howells 	__be16 tag_len;
121607ca46eSDavid Howells 	char tag_data[0];
122607ca46eSDavid Howells } __attribute__ ((packed));
123607ca46eSDavid Howells 
124607ca46eSDavid Howells /* Tag identifiers */
125607ca46eSDavid Howells #define PTT_EOL		__cpu_to_be16(0x0000)
126607ca46eSDavid Howells #define PTT_SRV_NAME	__cpu_to_be16(0x0101)
127607ca46eSDavid Howells #define PTT_AC_NAME	__cpu_to_be16(0x0102)
128607ca46eSDavid Howells #define PTT_HOST_UNIQ	__cpu_to_be16(0x0103)
129607ca46eSDavid Howells #define PTT_AC_COOKIE	__cpu_to_be16(0x0104)
130607ca46eSDavid Howells #define PTT_VENDOR 	__cpu_to_be16(0x0105)
131607ca46eSDavid Howells #define PTT_RELAY_SID	__cpu_to_be16(0x0110)
132607ca46eSDavid Howells #define PTT_SRV_ERR     __cpu_to_be16(0x0201)
133607ca46eSDavid Howells #define PTT_SYS_ERR  	__cpu_to_be16(0x0202)
134607ca46eSDavid Howells #define PTT_GEN_ERR  	__cpu_to_be16(0x0203)
135607ca46eSDavid Howells 
136607ca46eSDavid Howells struct pppoe_hdr {
137607ca46eSDavid Howells #if defined(__LITTLE_ENDIAN_BITFIELD)
138607ca46eSDavid Howells 	__u8 type : 4;
139b1a5a34bSChangli Gao 	__u8 ver : 4;
140607ca46eSDavid Howells #elif defined(__BIG_ENDIAN_BITFIELD)
141607ca46eSDavid Howells 	__u8 ver : 4;
142b1a5a34bSChangli Gao 	__u8 type : 4;
143607ca46eSDavid Howells #else
144607ca46eSDavid Howells #error	"Please fix <asm/byteorder.h>"
145607ca46eSDavid Howells #endif
146607ca46eSDavid Howells 	__u8 code;
147607ca46eSDavid Howells 	__be16 sid;
148607ca46eSDavid Howells 	__be16 length;
149607ca46eSDavid Howells 	struct pppoe_tag tag[0];
150607ca46eSDavid Howells } __packed;
151607ca46eSDavid Howells 
152607ca46eSDavid Howells /* Length of entire PPPoE + PPP header */
153607ca46eSDavid Howells #define PPPOE_SES_HLEN	8
154607ca46eSDavid Howells 
155607ca46eSDavid Howells 
156607ca46eSDavid Howells #endif /* _UAPI__LINUX_IF_PPPOX_H */
157