l2tp.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
  2. /*
  3. * L2TP-over-IP socket for L2TPv3.
  4. *
  5. * Author: James Chapman <jchapman@katalix.com>
  6. */
  7. #ifndef _UAPI_LINUX_L2TP_H_
  8. #define _UAPI_LINUX_L2TP_H_
  9. #include <linux/types.h>
  10. #include <linux/socket.h>
  11. #include <linux/in.h>
  12. #include <linux/in6.h>
  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[__SOCK_SIZE__ -
  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
  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, cookie, peer_cookie, l2spec
  60. * SESSION_DELETE - SESSION_ID
  61. * SESSION_MODIFY - SESSION_ID
  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 (not used) */
  87. L2TP_ATTR_DATA_SEQ, /* u16 (not used) */
  88. L2TP_ATTR_L2SPEC_TYPE, /* u8, enum l2tp_l2spec_type */
  89. L2TP_ATTR_L2SPEC_LEN, /* u8 (not used) */
  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 (not used) */
  98. L2TP_ATTR_COOKIE, /* 0, 4 or 8 bytes */
  99. L2TP_ATTR_PEER_COOKIE, /* 0, 4 or 8 bytes */
  100. L2TP_ATTR_DEBUG, /* u32, enum l2tp_debug_flags */
  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 (not used) */
  112. L2TP_ATTR_MRU, /* u16 (not used) */
  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, /* flag */
  117. L2TP_ATTR_UDP_ZERO_CSUM6_RX, /* flag */
  118. L2TP_ATTR_PAD,
  119. __L2TP_ATTR_MAX,
  120. };
  121. #define L2TP_ATTR_MAX (__L2TP_ATTR_MAX - 1)
  122. /* Nested in L2TP_ATTR_STATS */
  123. enum {
  124. L2TP_ATTR_STATS_NONE, /* no data */
  125. L2TP_ATTR_TX_PACKETS, /* u64 */
  126. L2TP_ATTR_TX_BYTES, /* u64 */
  127. L2TP_ATTR_TX_ERRORS, /* u64 */
  128. L2TP_ATTR_RX_PACKETS, /* u64 */
  129. L2TP_ATTR_RX_BYTES, /* u64 */
  130. L2TP_ATTR_RX_SEQ_DISCARDS, /* u64 */
  131. L2TP_ATTR_RX_OOS_PACKETS, /* u64 */
  132. L2TP_ATTR_RX_ERRORS, /* u64 */
  133. L2TP_ATTR_STATS_PAD,
  134. __L2TP_ATTR_STATS_MAX,
  135. };
  136. #define L2TP_ATTR_STATS_MAX (__L2TP_ATTR_STATS_MAX - 1)
  137. enum l2tp_pwtype {
  138. L2TP_PWTYPE_NONE = 0x0000,
  139. L2TP_PWTYPE_ETH_VLAN = 0x0004,
  140. L2TP_PWTYPE_ETH = 0x0005,
  141. L2TP_PWTYPE_PPP = 0x0007,
  142. L2TP_PWTYPE_PPP_AC = 0x0008,
  143. L2TP_PWTYPE_IP = 0x000b,
  144. __L2TP_PWTYPE_MAX
  145. };
  146. enum l2tp_l2spec_type {
  147. L2TP_L2SPECTYPE_NONE,
  148. L2TP_L2SPECTYPE_DEFAULT,
  149. };
  150. enum l2tp_encap_type {
  151. L2TP_ENCAPTYPE_UDP,
  152. L2TP_ENCAPTYPE_IP,
  153. };
  154. /* For L2TP_ATTR_DATA_SEQ. Unused. */
  155. enum l2tp_seqmode {
  156. L2TP_SEQ_NONE = 0,
  157. L2TP_SEQ_IP = 1,
  158. L2TP_SEQ_ALL = 2,
  159. };
  160. /**
  161. * enum l2tp_debug_flags - debug message categories for L2TP tunnels/sessions
  162. *
  163. * @L2TP_MSG_DEBUG: verbose debug (if compiled in)
  164. * @L2TP_MSG_CONTROL: userspace - kernel interface
  165. * @L2TP_MSG_SEQ: sequence numbers
  166. * @L2TP_MSG_DATA: data packets
  167. */
  168. enum l2tp_debug_flags {
  169. L2TP_MSG_DEBUG = (1 << 0),
  170. L2TP_MSG_CONTROL = (1 << 1),
  171. L2TP_MSG_SEQ = (1 << 2),
  172. L2TP_MSG_DATA = (1 << 3),
  173. };
  174. /*
  175. * NETLINK_GENERIC related info
  176. */
  177. #define L2TP_GENL_NAME "l2tp"
  178. #define L2TP_GENL_VERSION 0x1
  179. #define L2TP_GENL_MCGROUP "l2tp"
  180. #endif /* _UAPI_LINUX_L2TP_H_ */