l2tp.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. /*
  2. * L2TP-over-IP socket for L2TPv3.
  3. *
  4. * Author: James Chapman <jchapman@katalix.com>
  5. */
  6. #ifndef _UAPI_LINUX_L2TP_H_
  7. #define _UAPI_LINUX_L2TP_H_
  8. #include <linux/types.h>
  9. #include <linux/socket.h>
  10. #ifndef __KERNEL__
  11. #include <netinet/in.h>
  12. #endif
  13. #define IPPROTO_L2TP 115
  14. /**
  15. * struct sockaddr_l2tpip - the sockaddr structure for L2TP-over-IP sockets
  16. * @l2tp_family: address family number AF_L2TPIP.
  17. * @l2tp_addr: protocol specific address information
  18. * @l2tp_conn_id: connection id of tunnel
  19. */
  20. #define __SOCK_SIZE__ 16 /* sizeof(struct sockaddr) */
  21. struct sockaddr_l2tpip {
  22. /* The first fields must match struct sockaddr_in */
  23. __kernel_sa_family_t l2tp_family; /* AF_INET */
  24. __be16 l2tp_unused; /* INET port number (unused) */
  25. struct in_addr l2tp_addr; /* Internet address */
  26. __u32 l2tp_conn_id; /* Connection ID of tunnel */
  27. /* Pad to size of `struct sockaddr'. */
  28. unsigned char __pad[sizeof(struct sockaddr) -
  29. sizeof(__kernel_sa_family_t) -
  30. sizeof(__be16) - sizeof(struct in_addr) -
  31. sizeof(__u32)];
  32. };
  33. /**
  34. * struct sockaddr_l2tpip6 - the sockaddr structure for L2TP-over-IPv6 sockets
  35. * @l2tp_family: address family number AF_L2TPIP.
  36. * @l2tp_addr: protocol specific address information
  37. * @l2tp_conn_id: connection id of tunnel
  38. */
  39. struct sockaddr_l2tpip6 {
  40. /* The first fields must match struct sockaddr_in6 */
  41. __kernel_sa_family_t l2tp_family; /* AF_INET6 */
  42. __be16 l2tp_unused; /* INET port number (unused) */
  43. __be32 l2tp_flowinfo; /* IPv6 flow information */
  44. struct in6_addr l2tp_addr; /* IPv6 address */
  45. __u32 l2tp_scope_id; /* scope id (new in RFC2553) */
  46. __u32 l2tp_conn_id; /* Connection ID of tunnel */
  47. };
  48. /*****************************************************************************
  49. * NETLINK_GENERIC netlink family.
  50. *****************************************************************************/
  51. /*
  52. * Commands.
  53. * Valid TLVs of each command are:-
  54. * TUNNEL_CREATE - CONN_ID, pw_type, netns, ifname, ipinfo, udpinfo, udpcsum, vlanid
  55. * TUNNEL_DELETE - CONN_ID
  56. * TUNNEL_MODIFY - CONN_ID, udpcsum
  57. * TUNNEL_GETSTATS - CONN_ID, (stats)
  58. * TUNNEL_GET - CONN_ID, (...)
  59. * SESSION_CREATE - SESSION_ID, PW_TYPE, offset, data_seq, cookie, peer_cookie, offset, l2spec
  60. * SESSION_DELETE - SESSION_ID
  61. * SESSION_MODIFY - SESSION_ID, data_seq
  62. * SESSION_GET - SESSION_ID, (...)
  63. * SESSION_GETSTATS - SESSION_ID, (stats)
  64. *
  65. */
  66. enum {
  67. L2TP_CMD_NOOP,
  68. L2TP_CMD_TUNNEL_CREATE,
  69. L2TP_CMD_TUNNEL_DELETE,
  70. L2TP_CMD_TUNNEL_MODIFY,
  71. L2TP_CMD_TUNNEL_GET,
  72. L2TP_CMD_SESSION_CREATE,
  73. L2TP_CMD_SESSION_DELETE,
  74. L2TP_CMD_SESSION_MODIFY,
  75. L2TP_CMD_SESSION_GET,
  76. __L2TP_CMD_MAX,
  77. };
  78. #define L2TP_CMD_MAX (__L2TP_CMD_MAX - 1)
  79. /*
  80. * ATTR types defined for L2TP
  81. */
  82. enum {
  83. L2TP_ATTR_NONE, /* no data */
  84. L2TP_ATTR_PW_TYPE, /* u16, enum l2tp_pwtype */
  85. L2TP_ATTR_ENCAP_TYPE, /* u16, enum l2tp_encap_type */
  86. L2TP_ATTR_OFFSET, /* u16 */
  87. L2TP_ATTR_DATA_SEQ, /* u16 */
  88. L2TP_ATTR_L2SPEC_TYPE, /* u8, enum l2tp_l2spec_type */
  89. L2TP_ATTR_L2SPEC_LEN, /* u8, enum l2tp_l2spec_type */
  90. L2TP_ATTR_PROTO_VERSION, /* u8 */
  91. L2TP_ATTR_IFNAME, /* string */
  92. L2TP_ATTR_CONN_ID, /* u32 */
  93. L2TP_ATTR_PEER_CONN_ID, /* u32 */
  94. L2TP_ATTR_SESSION_ID, /* u32 */
  95. L2TP_ATTR_PEER_SESSION_ID, /* u32 */
  96. L2TP_ATTR_UDP_CSUM, /* u8 */
  97. L2TP_ATTR_VLAN_ID, /* u16 */
  98. L2TP_ATTR_COOKIE, /* 0, 4 or 8 bytes */
  99. L2TP_ATTR_PEER_COOKIE, /* 0, 4 or 8 bytes */
  100. L2TP_ATTR_DEBUG, /* u32 */
  101. L2TP_ATTR_RECV_SEQ, /* u8 */
  102. L2TP_ATTR_SEND_SEQ, /* u8 */
  103. L2TP_ATTR_LNS_MODE, /* u8 */
  104. L2TP_ATTR_USING_IPSEC, /* u8 */
  105. L2TP_ATTR_RECV_TIMEOUT, /* msec */
  106. L2TP_ATTR_FD, /* int */
  107. L2TP_ATTR_IP_SADDR, /* u32 */
  108. L2TP_ATTR_IP_DADDR, /* u32 */
  109. L2TP_ATTR_UDP_SPORT, /* u16 */
  110. L2TP_ATTR_UDP_DPORT, /* u16 */
  111. L2TP_ATTR_MTU, /* u16 */
  112. L2TP_ATTR_MRU, /* u16 */
  113. L2TP_ATTR_STATS, /* nested */
  114. L2TP_ATTR_IP6_SADDR, /* struct in6_addr */
  115. L2TP_ATTR_IP6_DADDR, /* struct in6_addr */
  116. L2TP_ATTR_UDP_ZERO_CSUM6_TX, /* u8 */
  117. L2TP_ATTR_UDP_ZERO_CSUM6_RX, /* u8 */
  118. __L2TP_ATTR_MAX,
  119. };
  120. #define L2TP_ATTR_MAX (__L2TP_ATTR_MAX - 1)
  121. /* Nested in L2TP_ATTR_STATS */
  122. enum {
  123. L2TP_ATTR_STATS_NONE, /* no data */
  124. L2TP_ATTR_TX_PACKETS, /* u64 */
  125. L2TP_ATTR_TX_BYTES, /* u64 */
  126. L2TP_ATTR_TX_ERRORS, /* u64 */
  127. L2TP_ATTR_RX_PACKETS, /* u64 */
  128. L2TP_ATTR_RX_BYTES, /* u64 */
  129. L2TP_ATTR_RX_SEQ_DISCARDS, /* u64 */
  130. L2TP_ATTR_RX_OOS_PACKETS, /* u64 */
  131. L2TP_ATTR_RX_ERRORS, /* u64 */
  132. __L2TP_ATTR_STATS_MAX,
  133. };
  134. #define L2TP_ATTR_STATS_MAX (__L2TP_ATTR_STATS_MAX - 1)
  135. enum l2tp_pwtype {
  136. L2TP_PWTYPE_NONE = 0x0000,
  137. L2TP_PWTYPE_ETH_VLAN = 0x0004,
  138. L2TP_PWTYPE_ETH = 0x0005,
  139. L2TP_PWTYPE_PPP = 0x0007,
  140. L2TP_PWTYPE_PPP_AC = 0x0008,
  141. L2TP_PWTYPE_IP = 0x000b,
  142. __L2TP_PWTYPE_MAX
  143. };
  144. enum l2tp_l2spec_type {
  145. L2TP_L2SPECTYPE_NONE,
  146. L2TP_L2SPECTYPE_DEFAULT,
  147. };
  148. enum l2tp_encap_type {
  149. L2TP_ENCAPTYPE_UDP,
  150. L2TP_ENCAPTYPE_IP,
  151. };
  152. enum l2tp_seqmode {
  153. L2TP_SEQ_NONE = 0,
  154. L2TP_SEQ_IP = 1,
  155. L2TP_SEQ_ALL = 2,
  156. };
  157. /*
  158. * NETLINK_GENERIC related info
  159. */
  160. #define L2TP_GENL_NAME "l2tp"
  161. #define L2TP_GENL_VERSION 0x1
  162. #define L2TP_GENL_MCGROUP "l2tp"
  163. #endif /* _UAPI_LINUX_L2TP_H_ */