if_pppox.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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 <asm/types.h>
  18. #include <asm/byteorder.h>
  19. #ifdef __KERNEL__
  20. #include <linux/if_ether.h>
  21. #include <linux/if.h>
  22. #include <linux/netdevice.h>
  23. #include <asm/semaphore.h>
  24. #include <linux/ppp_channel.h>
  25. #endif /* __KERNEL__ */
  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 __u16 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. * Protocols supported by AF_PPPOX
  44. */
  45. #define PX_PROTO_OE 0 /* Currently just PPPoE */
  46. #define PX_MAX_PROTO 1
  47. struct sockaddr_pppox {
  48. sa_family_t sa_family; /* address family, AF_PPPOX */
  49. unsigned int sa_protocol; /* protocol identifier */
  50. union{
  51. struct pppoe_addr pppoe;
  52. }sa_addr;
  53. }__attribute__ ((packed));
  54. /*********************************************************************
  55. *
  56. * ioctl interface for defining forwarding of connections
  57. *
  58. ********************************************************************/
  59. #define PPPOEIOCSFWD _IOW(0xB1 ,0, size_t)
  60. #define PPPOEIOCDFWD _IO(0xB1 ,1)
  61. /*#define PPPOEIOCGFWD _IOWR(0xB1,2, size_t)*/
  62. /* Codes to identify message types */
  63. #define PADI_CODE 0x09
  64. #define PADO_CODE 0x07
  65. #define PADR_CODE 0x19
  66. #define PADS_CODE 0x65
  67. #define PADT_CODE 0xa7
  68. struct pppoe_tag {
  69. __u16 tag_type;
  70. __u16 tag_len;
  71. char tag_data[0];
  72. } __attribute ((packed));
  73. /* Tag identifiers */
  74. #define PTT_EOL __constant_htons(0x0000)
  75. #define PTT_SRV_NAME __constant_htons(0x0101)
  76. #define PTT_AC_NAME __constant_htons(0x0102)
  77. #define PTT_HOST_UNIQ __constant_htons(0x0103)
  78. #define PTT_AC_COOKIE __constant_htons(0x0104)
  79. #define PTT_VENDOR __constant_htons(0x0105)
  80. #define PTT_RELAY_SID __constant_htons(0x0110)
  81. #define PTT_SRV_ERR __constant_htons(0x0201)
  82. #define PTT_SYS_ERR __constant_htons(0x0202)
  83. #define PTT_GEN_ERR __constant_htons(0x0203)
  84. struct pppoe_hdr {
  85. #if defined(__LITTLE_ENDIAN_BITFIELD)
  86. __u8 ver : 4;
  87. __u8 type : 4;
  88. #elif defined(__BIG_ENDIAN_BITFIELD)
  89. __u8 type : 4;
  90. __u8 ver : 4;
  91. #else
  92. #error "Please fix <asm/byteorder.h>"
  93. #endif
  94. __u8 code;
  95. __u16 sid;
  96. __u16 length;
  97. struct pppoe_tag tag[0];
  98. } __attribute__ ((packed));
  99. #ifdef __KERNEL__
  100. struct pppoe_opt {
  101. struct net_device *dev; /* device associated with socket*/
  102. int ifindex; /* ifindex of device associated with socket */
  103. struct pppoe_addr pa; /* what this socket is bound to*/
  104. struct sockaddr_pppox relay; /* what socket data will be
  105. relayed to (PPPoE relaying) */
  106. };
  107. #include <net/sock.h>
  108. struct pppox_sock {
  109. /* struct sock must be the first member of pppox_sock */
  110. struct sock sk;
  111. struct ppp_channel chan;
  112. struct pppox_sock *next; /* for hash table */
  113. union {
  114. struct pppoe_opt pppoe;
  115. } proto;
  116. unsigned short num;
  117. };
  118. #define pppoe_dev proto.pppoe.dev
  119. #define pppoe_ifindex proto.pppoe.ifindex
  120. #define pppoe_pa proto.pppoe.pa
  121. #define pppoe_relay proto.pppoe.relay
  122. static inline struct pppox_sock *pppox_sk(struct sock *sk)
  123. {
  124. return (struct pppox_sock *)sk;
  125. }
  126. static inline struct sock *sk_pppox(struct pppox_sock *po)
  127. {
  128. return (struct sock *)po;
  129. }
  130. struct module;
  131. struct pppox_proto {
  132. int (*create)(struct socket *sock);
  133. int (*ioctl)(struct socket *sock, unsigned int cmd,
  134. unsigned long arg);
  135. struct module *owner;
  136. };
  137. extern int register_pppox_proto(int proto_num, struct pppox_proto *pp);
  138. extern void unregister_pppox_proto(int proto_num);
  139. extern void pppox_unbind_sock(struct sock *sk);/* delete ppp-channel binding */
  140. extern int pppox_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg);
  141. /* PPPoX socket states */
  142. enum {
  143. PPPOX_NONE = 0, /* initial state */
  144. PPPOX_CONNECTED = 1, /* connection established ==TCP_ESTABLISHED */
  145. PPPOX_BOUND = 2, /* bound to ppp device */
  146. PPPOX_RELAY = 4, /* forwarding is enabled */
  147. PPPOX_ZOMBIE = 8, /* dead, but still bound to ppp device */
  148. PPPOX_DEAD = 16 /* dead, useless, please clean me up!*/
  149. };
  150. #endif /* __KERNEL__ */
  151. #endif /* !(__LINUX_IF_PPPOX_H) */