l2tp.h 4.2 KB

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