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