Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
0002 /***************************************************************************
0003  * Linux PPP over X - Generic PPP transport layer sockets
0004  * Linux PPP over Ethernet (PPPoE) Socket Implementation (RFC 2516) 
0005  *
0006  * This file supplies definitions required by the PPP over Ethernet driver
0007  * (pppox.c).  All version information wrt this file is located in pppox.c
0008  *
0009  * License:
0010  *      This program is free software; you can redistribute it and/or
0011  *      modify it under the terms of the GNU General Public License
0012  *      as published by the Free Software Foundation; either version
0013  *      2 of the License, or (at your option) any later version.
0014  *
0015  */
0016 
0017 #ifndef _UAPI__LINUX_IF_PPPOX_H
0018 #define _UAPI__LINUX_IF_PPPOX_H
0019 
0020 
0021 #include <linux/types.h>
0022 #include <asm/byteorder.h>
0023 
0024 #include <linux/socket.h>
0025 #include <linux/if.h>
0026 #include <linux/if_ether.h>
0027 #include <linux/if_pppol2tp.h>
0028 #include <linux/in.h>
0029 #include <linux/in6.h>
0030 
0031 /* For user-space programs to pick up these definitions
0032  * which they wouldn't get otherwise without defining __KERNEL__
0033  */
0034 #ifndef AF_PPPOX
0035 #define AF_PPPOX    24
0036 #define PF_PPPOX    AF_PPPOX
0037 #endif /* !(AF_PPPOX) */
0038 
0039 /************************************************************************ 
0040  * PPPoE addressing definition 
0041  */ 
0042 typedef __be16 sid_t;
0043 struct pppoe_addr {
0044     sid_t         sid;                    /* Session identifier */
0045     unsigned char remote[ETH_ALEN];       /* Remote address */
0046     char          dev[IFNAMSIZ];          /* Local device to use */
0047 }; 
0048  
0049 /************************************************************************ 
0050  * PPTP addressing definition
0051  */
0052 struct pptp_addr {
0053     __u16       call_id;
0054     struct in_addr  sin_addr;
0055 };
0056 
0057 /************************************************************************
0058  * Protocols supported by AF_PPPOX
0059  */
0060 #define PX_PROTO_OE    0 /* Currently just PPPoE */
0061 #define PX_PROTO_OL2TP 1 /* Now L2TP also */
0062 #define PX_PROTO_PPTP  2
0063 #define PX_MAX_PROTO   3
0064 
0065 struct sockaddr_pppox {
0066     __kernel_sa_family_t sa_family;       /* address family, AF_PPPOX */
0067     unsigned int    sa_protocol;          /* protocol identifier */
0068     union {
0069         struct pppoe_addr  pppoe;
0070         struct pptp_addr   pptp;
0071     } sa_addr;
0072 } __packed;
0073 
0074 /* The use of the above union isn't viable because the size of this
0075  * struct must stay fixed over time -- applications use sizeof(struct
0076  * sockaddr_pppox) to fill it. We use a protocol specific sockaddr
0077  * type instead.
0078  */
0079 struct sockaddr_pppol2tp {
0080     __kernel_sa_family_t sa_family; /* address family, AF_PPPOX */
0081     unsigned int    sa_protocol;    /* protocol identifier */
0082     struct pppol2tp_addr pppol2tp;
0083 } __packed;
0084 
0085 struct sockaddr_pppol2tpin6 {
0086     __kernel_sa_family_t sa_family; /* address family, AF_PPPOX */
0087     unsigned int    sa_protocol;    /* protocol identifier */
0088     struct pppol2tpin6_addr pppol2tp;
0089 } __packed;
0090 
0091 /* The L2TPv3 protocol changes tunnel and session ids from 16 to 32
0092  * bits. So we need a different sockaddr structure.
0093  */
0094 struct sockaddr_pppol2tpv3 {
0095     __kernel_sa_family_t sa_family; /* address family, AF_PPPOX */
0096     unsigned int    sa_protocol;    /* protocol identifier */
0097     struct pppol2tpv3_addr pppol2tp;
0098 } __packed;
0099 
0100 struct sockaddr_pppol2tpv3in6 {
0101     __kernel_sa_family_t sa_family; /* address family, AF_PPPOX */
0102     unsigned int    sa_protocol;    /* protocol identifier */
0103     struct pppol2tpv3in6_addr pppol2tp;
0104 } __packed;
0105 
0106 /*********************************************************************
0107  *
0108  * ioctl interface for defining forwarding of connections
0109  *
0110  ********************************************************************/
0111 
0112 #define PPPOEIOCSFWD    _IOW(0xB1 ,0, size_t)
0113 #define PPPOEIOCDFWD    _IO(0xB1 ,1)
0114 /*#define PPPOEIOCGFWD  _IOWR(0xB1,2, size_t)*/
0115 
0116 /* Codes to identify message types */
0117 #define PADI_CODE   0x09
0118 #define PADO_CODE   0x07
0119 #define PADR_CODE   0x19
0120 #define PADS_CODE   0x65
0121 #define PADT_CODE   0xa7
0122 struct pppoe_tag {
0123     __be16 tag_type;
0124     __be16 tag_len;
0125     char tag_data[];
0126 } __attribute__ ((packed));
0127 
0128 /* Tag identifiers */
0129 #define PTT_EOL     __cpu_to_be16(0x0000)
0130 #define PTT_SRV_NAME    __cpu_to_be16(0x0101)
0131 #define PTT_AC_NAME __cpu_to_be16(0x0102)
0132 #define PTT_HOST_UNIQ   __cpu_to_be16(0x0103)
0133 #define PTT_AC_COOKIE   __cpu_to_be16(0x0104)
0134 #define PTT_VENDOR  __cpu_to_be16(0x0105)
0135 #define PTT_RELAY_SID   __cpu_to_be16(0x0110)
0136 #define PTT_SRV_ERR     __cpu_to_be16(0x0201)
0137 #define PTT_SYS_ERR     __cpu_to_be16(0x0202)
0138 #define PTT_GEN_ERR     __cpu_to_be16(0x0203)
0139 
0140 struct pppoe_hdr {
0141 #if defined(__LITTLE_ENDIAN_BITFIELD)
0142     __u8 type : 4;
0143     __u8 ver : 4;
0144 #elif defined(__BIG_ENDIAN_BITFIELD)
0145     __u8 ver : 4;
0146     __u8 type : 4;
0147 #else
0148 #error  "Please fix <asm/byteorder.h>"
0149 #endif
0150     __u8 code;
0151     __be16 sid;
0152     __be16 length;
0153     struct pppoe_tag tag[];
0154 } __packed;
0155 
0156 /* Length of entire PPPoE + PPP header */
0157 #define PPPOE_SES_HLEN  8
0158 
0159 
0160 #endif /* _UAPI__LINUX_IF_PPPOX_H */