if_pppox.h 3.7 KB

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