| 1 |
/* SPDX-License-Identifier: LGPL-2.1-or-later */ |
| 2 |
#pragma once |
| 3 |
|
| 4 |
#include <linux/l2tp.h> |
| 5 |
|
| 6 |
#include "in-addr-util.h" |
| 7 |
#include "shared-forward.h" |
| 8 |
#include "netdev.h" |
| 9 |
|
| 10 |
typedef enum L2tpL2specType { |
| 11 |
NETDEV_L2TP_L2SPECTYPE_NONE = L2TP_L2SPECTYPE_NONE, |
| 12 |
NETDEV_L2TP_L2SPECTYPE_DEFAULT = L2TP_L2SPECTYPE_DEFAULT, |
| 13 |
_NETDEV_L2TP_L2SPECTYPE_MAX, |
| 14 |
_NETDEV_L2TP_L2SPECTYPE_INVALID = -EINVAL, |
| 15 |
} L2tpL2specType; |
| 16 |
|
| 17 |
typedef enum L2tpEncapType { |
| 18 |
NETDEV_L2TP_ENCAPTYPE_UDP = L2TP_ENCAPTYPE_UDP, |
| 19 |
NETDEV_L2TP_ENCAPTYPE_IP = L2TP_ENCAPTYPE_IP, |
| 20 |
_NETDEV_L2TP_ENCAPTYPE_MAX, |
| 21 |
_NETDEV_L2TP_ENCAPTYPE_INVALID = -EINVAL, |
| 22 |
} L2tpEncapType; |
| 23 |
|
| 24 |
typedef enum L2tpLocalAddressType { |
| 25 |
NETDEV_L2TP_LOCAL_ADDRESS_AUTO, |
| 26 |
NETDEV_L2TP_LOCAL_ADDRESS_STATIC, |
| 27 |
NETDEV_L2TP_LOCAL_ADDRESS_DYNAMIC, |
| 28 |
_NETDEV_L2TP_LOCAL_ADDRESS_MAX, |
| 29 |
_NETDEV_L2TP_LOCAL_ADDRESS_INVALID = -EINVAL, |
| 30 |
} L2tpLocalAddressType; |
| 31 |
|
| 32 |
typedef struct L2tpTunnel L2tpTunnel; |
| 33 |
|
| 34 |
typedef struct L2tpSession { |
| 35 |
L2tpTunnel *tunnel; |
| 36 |
ConfigSection *section; |
| 37 |
|
| 38 |
char *name; |
| 39 |
int ifindex; |
| 40 |
|
| 41 |
uint32_t session_id; |
| 42 |
uint32_t peer_session_id; |
| 43 |
L2tpL2specType l2tp_l2spec_type; |
| 44 |
} L2tpSession; |
| 45 |
|
| 46 |
struct L2tpTunnel { |
| 47 |
NetDev meta; |
| 48 |
|
| 49 |
uint16_t l2tp_udp_sport; |
| 50 |
uint16_t l2tp_udp_dport; |
| 51 |
|
| 52 |
uint32_t tunnel_id; |
| 53 |
uint32_t peer_tunnel_id; |
| 54 |
|
| 55 |
int family; |
| 56 |
|
| 57 |
bool udp_csum; |
| 58 |
bool udp6_csum_rx; |
| 59 |
bool udp6_csum_tx; |
| 60 |
|
| 61 |
char *local_ifname; |
| 62 |
L2tpLocalAddressType local_address_type; |
| 63 |
union in_addr_union local; |
| 64 |
union in_addr_union remote; |
| 65 |
|
| 66 |
L2tpEncapType l2tp_encap_type; |
| 67 |
|
| 68 |
OrderedHashmap *sessions_by_section; |
| 69 |
}; |
| 70 |
|
| 71 |
DEFINE_NETDEV_CAST(L2TP, L2tpTunnel); |
| 72 |
extern const NetDevVTable l2tptnl_vtable; |
| 73 |
|
| 74 |
CONFIG_PARSER_PROTOTYPE(config_parse_l2tp_tunnel_local_address); |
| 75 |
CONFIG_PARSER_PROTOTYPE(config_parse_l2tp_tunnel_remote_address); |
| 76 |
CONFIG_PARSER_PROTOTYPE(config_parse_l2tp_tunnel_id); |
| 77 |
CONFIG_PARSER_PROTOTYPE(config_parse_l2tp_encap_type); |
| 78 |
CONFIG_PARSER_PROTOTYPE(config_parse_l2tp_session_l2spec); |
| 79 |
CONFIG_PARSER_PROTOTYPE(config_parse_l2tp_session_id); |
| 80 |
CONFIG_PARSER_PROTOTYPE(config_parse_l2tp_session_name); |