if_pppox.h 4.7 KB

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