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