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