Line data Source code
1 : /* SPDX-License-Identifier: LGPL-2.1+ */ 2 : #pragma once 3 : 4 : #include <netinet/in.h> 5 : #include <linux/l2tp.h> 6 : 7 : #include "in-addr-util.h" 8 : #include "netdev.h" 9 : #include "networkd-util.h" 10 : 11 : typedef enum L2tpL2specType { 12 : NETDEV_L2TP_L2SPECTYPE_NONE = L2TP_L2SPECTYPE_NONE, 13 : NETDEV_L2TP_L2SPECTYPE_DEFAULT = L2TP_L2SPECTYPE_DEFAULT, 14 : _NETDEV_L2TP_L2SPECTYPE_MAX, 15 : _NETDEV_L2TP_L2SPECTYPE_INVALID = -1, 16 : } L2tpL2specType; 17 : 18 : typedef enum L2tpEncapType { 19 : NETDEV_L2TP_ENCAPTYPE_UDP = L2TP_ENCAPTYPE_UDP, 20 : NETDEV_L2TP_ENCAPTYPE_IP = L2TP_ENCAPTYPE_IP, 21 : _NETDEV_L2TP_ENCAPTYPE_MAX, 22 : _NETDEV_L2TP_ENCAPTYPE_INVALID = -1, 23 : } L2tpEncapType; 24 : 25 : typedef enum L2tpLocalAddressType { 26 : NETDEV_L2TP_LOCAL_ADDRESS_AUTO, 27 : NETDEV_L2TP_LOCAL_ADDRESS_STATIC, 28 : NETDEV_L2TP_LOCAL_ADDRESS_DYNAMIC, 29 : _NETDEV_L2TP_LOCAL_ADDRESS_MAX, 30 : _NETDEV_L2TP_LOCAL_ADDRESS_INVALID = -1, 31 : } L2tpLocalAddressType; 32 : 33 : typedef struct L2tpTunnel L2tpTunnel; 34 : 35 : typedef struct L2tpSession { 36 : L2tpTunnel *tunnel; 37 : NetworkConfigSection *section; 38 : 39 : char *name; 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 : L2tpLocalAddressType local_address_type; 62 : union in_addr_union local; 63 : union in_addr_union remote; 64 : 65 : L2tpEncapType l2tp_encap_type; 66 : 67 : OrderedHashmap *sessions_by_section; 68 : }; 69 : 70 0 : DEFINE_NETDEV_CAST(L2TP, L2tpTunnel); 71 : extern const NetDevVTable l2tptnl_vtable; 72 : 73 : CONFIG_PARSER_PROTOTYPE(config_parse_l2tp_tunnel_address); 74 : CONFIG_PARSER_PROTOTYPE(config_parse_l2tp_tunnel_id); 75 : CONFIG_PARSER_PROTOTYPE(config_parse_l2tp_encap_type); 76 : CONFIG_PARSER_PROTOTYPE(config_parse_l2tp_session_l2spec); 77 : CONFIG_PARSER_PROTOTYPE(config_parse_l2tp_session_id); 78 : CONFIG_PARSER_PROTOTYPE(config_parse_l2tp_session_name);