if_pppox.h 4.6 KB

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