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