if_pppox.h 4.6 KB

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