1 /* SPDX-License-Identifier: GPL-2.0+ WITH Linu 1 /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */ 2 /********************************************* 2 /*************************************************************************** 3 * Linux PPP over X - Generic PPP transport la 3 * Linux PPP over X - Generic PPP transport layer sockets 4 * Linux PPP over Ethernet (PPPoE) Socket Impl 4 * Linux PPP over Ethernet (PPPoE) Socket Implementation (RFC 2516) 5 * 5 * 6 * This file supplies definitions required by 6 * This file supplies definitions required by the PPP over Ethernet driver 7 * (pppox.c). All version information wrt thi 7 * (pppox.c). All version information wrt this file is located in pppox.c 8 * 8 * 9 * License: 9 * License: 10 * This program is free software; 10 * This program is free software; you can redistribute it and/or 11 * modify it under the terms of t 11 * modify it under the terms of the GNU General Public License 12 * as published by the Free Softw 12 * as published by the Free Software Foundation; either version 13 * 2 of the License, or (at your 13 * 2 of the License, or (at your option) any later version. 14 * 14 * 15 */ 15 */ 16 16 17 #ifndef _UAPI__LINUX_IF_PPPOX_H 17 #ifndef _UAPI__LINUX_IF_PPPOX_H 18 #define _UAPI__LINUX_IF_PPPOX_H 18 #define _UAPI__LINUX_IF_PPPOX_H 19 19 20 20 21 #include <linux/types.h> 21 #include <linux/types.h> 22 #include <asm/byteorder.h> 22 #include <asm/byteorder.h> 23 23 24 #include <linux/socket.h> 24 #include <linux/socket.h> 25 #include <linux/if.h> 25 #include <linux/if.h> 26 #include <linux/if_ether.h> 26 #include <linux/if_ether.h> 27 #include <linux/if_pppol2tp.h> 27 #include <linux/if_pppol2tp.h> 28 #include <linux/in.h> 28 #include <linux/in.h> 29 #include <linux/in6.h> 29 #include <linux/in6.h> 30 30 31 /* For user-space programs to pick up these de 31 /* For user-space programs to pick up these definitions 32 * which they wouldn't get otherwise without d 32 * which they wouldn't get otherwise without defining __KERNEL__ 33 */ 33 */ 34 #ifndef AF_PPPOX 34 #ifndef AF_PPPOX 35 #define AF_PPPOX 24 35 #define AF_PPPOX 24 36 #define PF_PPPOX AF_PPPOX 36 #define PF_PPPOX AF_PPPOX 37 #endif /* !(AF_PPPOX) */ 37 #endif /* !(AF_PPPOX) */ 38 38 39 /********************************************* 39 /************************************************************************ 40 * PPPoE addressing definition 40 * PPPoE addressing definition 41 */ 41 */ 42 typedef __be16 sid_t; 42 typedef __be16 sid_t; 43 struct pppoe_addr { 43 struct pppoe_addr { 44 sid_t sid; 44 sid_t sid; /* Session identifier */ 45 unsigned char remote[ETH_ALEN]; 45 unsigned char remote[ETH_ALEN]; /* Remote address */ 46 char dev[IFNAMSIZ]; 46 char dev[IFNAMSIZ]; /* Local device to use */ 47 }; 47 }; 48 48 49 /********************************************* 49 /************************************************************************ 50 * PPTP addressing definition 50 * PPTP addressing definition 51 */ 51 */ 52 struct pptp_addr { 52 struct pptp_addr { 53 __u16 call_id; 53 __u16 call_id; 54 struct in_addr sin_addr; 54 struct in_addr sin_addr; 55 }; 55 }; 56 56 57 /********************************************* 57 /************************************************************************ 58 * Protocols supported by AF_PPPOX 58 * Protocols supported by AF_PPPOX 59 */ 59 */ 60 #define PX_PROTO_OE 0 /* Currently just PPP 60 #define PX_PROTO_OE 0 /* Currently just PPPoE */ 61 #define PX_PROTO_OL2TP 1 /* Now L2TP also */ 61 #define PX_PROTO_OL2TP 1 /* Now L2TP also */ 62 #define PX_PROTO_PPTP 2 62 #define PX_PROTO_PPTP 2 63 #define PX_MAX_PROTO 3 63 #define PX_MAX_PROTO 3 64 64 65 struct sockaddr_pppox { 65 struct sockaddr_pppox { 66 __kernel_sa_family_t sa_family; 66 __kernel_sa_family_t sa_family; /* address family, AF_PPPOX */ 67 unsigned int sa_protocol; 67 unsigned int sa_protocol; /* protocol identifier */ 68 union { 68 union { 69 struct pppoe_addr pppoe; 69 struct pppoe_addr pppoe; 70 struct pptp_addr pptp; 70 struct pptp_addr pptp; 71 } sa_addr; 71 } sa_addr; 72 } __packed; 72 } __packed; 73 73 74 /* The use of the above union isn't viable bec 74 /* The use of the above union isn't viable because the size of this 75 * struct must stay fixed over time -- applica 75 * struct must stay fixed over time -- applications use sizeof(struct 76 * sockaddr_pppox) to fill it. We use a protoc 76 * sockaddr_pppox) to fill it. We use a protocol specific sockaddr 77 * type instead. 77 * type instead. 78 */ 78 */ 79 struct sockaddr_pppol2tp { 79 struct sockaddr_pppol2tp { 80 __kernel_sa_family_t sa_family; /* add 80 __kernel_sa_family_t sa_family; /* address family, AF_PPPOX */ 81 unsigned int sa_protocol; /* pro 81 unsigned int sa_protocol; /* protocol identifier */ 82 struct pppol2tp_addr pppol2tp; 82 struct pppol2tp_addr pppol2tp; 83 } __packed; 83 } __packed; 84 84 85 struct sockaddr_pppol2tpin6 { 85 struct sockaddr_pppol2tpin6 { 86 __kernel_sa_family_t sa_family; /* add 86 __kernel_sa_family_t sa_family; /* address family, AF_PPPOX */ 87 unsigned int sa_protocol; /* pro 87 unsigned int sa_protocol; /* protocol identifier */ 88 struct pppol2tpin6_addr pppol2tp; 88 struct pppol2tpin6_addr pppol2tp; 89 } __packed; 89 } __packed; 90 90 91 /* The L2TPv3 protocol changes tunnel and sess 91 /* The L2TPv3 protocol changes tunnel and session ids from 16 to 32 92 * bits. So we need a different sockaddr struc 92 * bits. So we need a different sockaddr structure. 93 */ 93 */ 94 struct sockaddr_pppol2tpv3 { 94 struct sockaddr_pppol2tpv3 { 95 __kernel_sa_family_t sa_family; /* add 95 __kernel_sa_family_t sa_family; /* address family, AF_PPPOX */ 96 unsigned int sa_protocol; /* pro 96 unsigned int sa_protocol; /* protocol identifier */ 97 struct pppol2tpv3_addr pppol2tp; 97 struct pppol2tpv3_addr pppol2tp; 98 } __packed; 98 } __packed; 99 99 100 struct sockaddr_pppol2tpv3in6 { 100 struct sockaddr_pppol2tpv3in6 { 101 __kernel_sa_family_t sa_family; /* add 101 __kernel_sa_family_t sa_family; /* address family, AF_PPPOX */ 102 unsigned int sa_protocol; /* pro 102 unsigned int sa_protocol; /* protocol identifier */ 103 struct pppol2tpv3in6_addr pppol2tp; 103 struct pppol2tpv3in6_addr pppol2tp; 104 } __packed; 104 } __packed; 105 105 106 /********************************************* 106 /********************************************************************* 107 * 107 * 108 * ioctl interface for defining forwarding of 108 * ioctl interface for defining forwarding of connections 109 * 109 * 110 ********************************************* 110 ********************************************************************/ 111 111 112 #define PPPOEIOCSFWD _IOW(0xB1 ,0, size_t) 112 #define PPPOEIOCSFWD _IOW(0xB1 ,0, size_t) 113 #define PPPOEIOCDFWD _IO(0xB1 ,1) 113 #define PPPOEIOCDFWD _IO(0xB1 ,1) 114 /*#define PPPOEIOCGFWD _IOWR(0xB1,2, size_t)* 114 /*#define PPPOEIOCGFWD _IOWR(0xB1,2, size_t)*/ 115 115 116 /* Codes to identify message types */ 116 /* Codes to identify message types */ 117 #define PADI_CODE 0x09 117 #define PADI_CODE 0x09 118 #define PADO_CODE 0x07 118 #define PADO_CODE 0x07 119 #define PADR_CODE 0x19 119 #define PADR_CODE 0x19 120 #define PADS_CODE 0x65 120 #define PADS_CODE 0x65 121 #define PADT_CODE 0xa7 121 #define PADT_CODE 0xa7 122 struct pppoe_tag { 122 struct pppoe_tag { 123 __be16 tag_type; 123 __be16 tag_type; 124 __be16 tag_len; 124 __be16 tag_len; 125 char tag_data[]; 125 char tag_data[]; 126 } __attribute__ ((packed)); 126 } __attribute__ ((packed)); 127 127 128 /* Tag identifiers */ 128 /* Tag identifiers */ 129 #define PTT_EOL __cpu_to_be16(0x0000) 129 #define PTT_EOL __cpu_to_be16(0x0000) 130 #define PTT_SRV_NAME __cpu_to_be16(0x0101) 130 #define PTT_SRV_NAME __cpu_to_be16(0x0101) 131 #define PTT_AC_NAME __cpu_to_be16(0x0102) 131 #define PTT_AC_NAME __cpu_to_be16(0x0102) 132 #define PTT_HOST_UNIQ __cpu_to_be16(0x0103) 132 #define PTT_HOST_UNIQ __cpu_to_be16(0x0103) 133 #define PTT_AC_COOKIE __cpu_to_be16(0x0104) 133 #define PTT_AC_COOKIE __cpu_to_be16(0x0104) 134 #define PTT_VENDOR __cpu_to_be16(0x0105) 134 #define PTT_VENDOR __cpu_to_be16(0x0105) 135 #define PTT_RELAY_SID __cpu_to_be16(0x0110) 135 #define PTT_RELAY_SID __cpu_to_be16(0x0110) 136 #define PTT_SRV_ERR __cpu_to_be16(0x0201) 136 #define PTT_SRV_ERR __cpu_to_be16(0x0201) 137 #define PTT_SYS_ERR __cpu_to_be16(0x0202) 137 #define PTT_SYS_ERR __cpu_to_be16(0x0202) 138 #define PTT_GEN_ERR __cpu_to_be16(0x0203) 138 #define PTT_GEN_ERR __cpu_to_be16(0x0203) 139 139 140 struct pppoe_hdr { 140 struct pppoe_hdr { 141 #if defined(__LITTLE_ENDIAN_BITFIELD) 141 #if defined(__LITTLE_ENDIAN_BITFIELD) 142 __u8 type : 4; 142 __u8 type : 4; 143 __u8 ver : 4; 143 __u8 ver : 4; 144 #elif defined(__BIG_ENDIAN_BITFIELD) 144 #elif defined(__BIG_ENDIAN_BITFIELD) 145 __u8 ver : 4; 145 __u8 ver : 4; 146 __u8 type : 4; 146 __u8 type : 4; 147 #else 147 #else 148 #error "Please fix <asm/byteorder.h>" 148 #error "Please fix <asm/byteorder.h>" 149 #endif 149 #endif 150 __u8 code; 150 __u8 code; 151 __be16 sid; 151 __be16 sid; 152 __be16 length; 152 __be16 length; 153 struct pppoe_tag tag[]; 153 struct pppoe_tag tag[]; 154 } __packed; 154 } __packed; 155 155 156 /* Length of entire PPPoE + PPP header */ 156 /* Length of entire PPPoE + PPP header */ 157 #define PPPOE_SES_HLEN 8 157 #define PPPOE_SES_HLEN 8 158 158 159 159 160 #endif /* _UAPI__LINUX_IF_PPPOX_H */ 160 #endif /* _UAPI__LINUX_IF_PPPOX_H */ 161 161
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.