FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
l2tp.h
Go to the documentation of this file.
1 /*
2  * l2tp.h : L2TPv3 tunnel support
3  *
4  * Copyright (c) 2013 Cisco and/or its affiliates.
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at:
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #ifndef __included_l2tp_h__
19 #define __included_l2tp_h__
20 
21 #include <vlib/vlib.h>
22 #include <vnet/ip/ip.h>
23 #include <l2tp/packet.h>
24 
25 typedef struct
26 {
27  /* ip6 addresses */
28  ip6_address_t our_address;
29  ip6_address_t client_address;
30 
31  /* l2tpv3 header parameters */
32  u64 local_cookie[2];
36 
37  /* tunnel interface */
40 
41  /* fib index used for outgoing encapsulated packets */
43 
46  u8 cookie_flags; /* in host byte order */
47 
50 
51 typedef enum
52 {
57 
58 typedef struct
59 {
60  /* session pool */
62 
63  /* ip6 -> l2 hash tables. Make up your minds, people... */
67 
69 
70  /* Counters */
72 
73  /* vector of free l2tpv3 tunnel interfaces */
75 
76  /* show device instance by real device instance */
78 
79  /* convenience */
82 
84 
85 } l2t_main_t;
86 
87 /* Packet trace structure */
88 typedef struct
89 {
92  ip6_address_t our_address;
93  ip6_address_t client_address;
94 } l2t_trace_t;
95 
96 extern l2t_main_t l2t_main;
100 
101 enum
102 {
105 };
106 
107 static inline u32
108 session_index_to_counter_index (u32 session_index, u32 counter_id)
109 {
110  return ((session_index << 1) + counter_id);
111 }
112 
113 u8 *format_l2t_trace (u8 * s, va_list * args);
114 
115 typedef struct
116 {
117  /* Any per-interface config would go here */
119 
120 uword unformat_pg_l2tp_header (unformat_input_t * input, va_list * args);
121 
124  ip6_address_t * client_address,
125  ip6_address_t * our_address,
126  u32 local_session_id,
127  u32 remote_session_id,
128  u64 local_cookie,
129  u64 remote_cookie,
130  int l2_sublayer_present,
131  u32 encap_fib_index, u32 * sw_if_index);
132 
135  u64 new_local_cookie, u64 new_remote_cookie);
136 
138  u32 sw_if_index, int enable_disable);
139 
140 #endif /* __included_l2tp_h__ */
141 
142 /*
143  * fd.io coding-style-patch-verification: ON
144  *
145  * Local Variables:
146  * eval: (c-set-style "gnu")
147  * End:
148  */
vlib.h
l2t_decap_local_node
vlib_node_registration_t l2t_decap_local_node
(constructor) VLIB_REGISTER_NODE (l2t_decap_local_node)
Definition: decap.c:275
create_l2tpv3_ipv6_tunnel
int create_l2tpv3_ipv6_tunnel(l2t_main_t *lm, ip6_address_t *client_address, ip6_address_t *our_address, u32 local_session_id, u32 remote_session_id, u64 local_cookie, u64 remote_cookie, int l2_sublayer_present, u32 encap_fib_index, u32 *sw_if_index)
Definition: l2tp.c:283
l2t_session_t::sw_if_index
u32 sw_if_index
Definition: l2tp.h:39
ip6_to_l2_lookup_t
ip6_to_l2_lookup_t
Definition: l2tp.h:51
l2t_session_t::l2_sublayer_present
u8 l2_sublayer_present
Definition: l2tp.h:45
format_l2t_trace
u8 * format_l2t_trace(u8 *s, va_list *args)
Definition: l2tp.c:30
l2t_main_t
Definition: l2tp.h:58
l2t_main_t::sessions
l2t_session_t * sessions
Definition: l2tp.h:61
L2T_LOOKUP_SESSION_ID
@ L2T_LOOKUP_SESSION_ID
Definition: l2tp.h:55
l2t_trace_t::is_user_to_network
int is_user_to_network
Definition: l2tp.h:90
l2t_session_t::hw_if_index
u32 hw_if_index
Definition: l2tp.h:38
l2t_session_t::local_session_id
u32 local_session_id
Definition: l2tp.h:34
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
l2t_main_t::session_by_dst_address
uword * session_by_dst_address
Definition: l2tp.h:65
unformat_input_t
struct _unformat_input_t unformat_input_t
session_index_to_counter_index
static u32 session_index_to_counter_index(u32 session_index, u32 counter_id)
Definition: l2tp.h:108
l2t_session_t::admin_up
u8 admin_up
Definition: l2tp.h:48
l2t_session_t::cookie_flags
u8 cookie_flags
Definition: l2tp.h:46
ip6_l2tpv3_config_t
Definition: l2tp.h:115
l2t_main_t::vlib_main
vlib_main_t * vlib_main
Definition: l2tp.h:80
l2t_main_t::vnet_main
vnet_main_t * vnet_main
Definition: l2tp.h:81
l2t_session_t::l2tp_hdr_size
u8 l2tp_hdr_size
Definition: l2tp.h:44
l2t_main_t::session_by_session_id
uword * session_by_session_id
Definition: l2tp.h:66
l2t_main_t::lookup_type
ip6_to_l2_lookup_t lookup_type
Definition: l2tp.h:68
l2tp_encap_init
void l2tp_encap_init(vlib_main_t *vm)
Definition: encap.c:218
uword
u64 uword
Definition: types.h:112
l2t_main_t::free_l2tpv3_tunnel_hw_if_indices
u32 * free_l2tpv3_tunnel_hw_if_indices
Definition: l2tp.h:74
l2t_trace_t::client_address
ip6_address_t client_address
Definition: l2tp.h:93
l2t_session_t::client_address
ip6_address_t client_address
Definition: l2tp.h:29
vlib_node_registration_t
struct _vlib_node_registration vlib_node_registration_t
l2tpv3_set_tunnel_cookies
int l2tpv3_set_tunnel_cookies(l2t_main_t *lm, u32 sw_if_index, u64 new_local_cookie, u64 new_remote_cookie)
Definition: l2tp.c:531
l2t_main_t::session_by_src_address
uword * session_by_src_address
Definition: l2tp.h:64
vnet_main_t
Definition: vnet.h:76
SESSION_COUNTER_NETWORK_TO_USER
@ SESSION_COUNTER_NETWORK_TO_USER
Definition: l2tp.h:104
l2t_main
l2t_main_t l2t_main
Definition: l2tp.c:26
l2t_session_t::remote_cookie
u64 remote_cookie
Definition: l2tp.h:33
u64
unsigned long u64
Definition: types.h:89
l2t_main_t::proto_registered
bool proto_registered
Definition: l2tp.h:83
vlib_combined_counter_main_t
A collection of combined counters.
Definition: counter.h:203
ip.h
L2T_LOOKUP_DST_ADDRESS
@ L2T_LOOKUP_DST_ADDRESS
Definition: l2tp.h:54
u32
unsigned int u32
Definition: types.h:88
l2tpv3_interface_enable_disable
int l2tpv3_interface_enable_disable(vnet_main_t *vnm, u32 sw_if_index, int enable_disable)
Definition: l2tp.c:614
l2t_trace_t::our_address
ip6_address_t our_address
Definition: l2tp.h:92
L2T_LOOKUP_SRC_ADDRESS
@ L2T_LOOKUP_SRC_ADDRESS
Definition: l2tp.h:53
packet.h
vlib_main_t
Definition: main.h:102
u8
unsigned char u8
Definition: types.h:56
l2t_main_t::dev_inst_by_real
u32 * dev_inst_by_real
Definition: l2tp.h:77
l2t_session_t
Definition: l2tp.h:25
l2t_trace_t
Definition: l2tp.h:88
l2t_main_t::counter_main
vlib_combined_counter_main_t counter_main
Definition: l2tp.h:71
SESSION_COUNTER_USER_TO_NETWORK
@ SESSION_COUNTER_USER_TO_NETWORK
Definition: l2tp.h:103
l2t_encap_node
vlib_node_registration_t l2t_encap_node
(constructor) VLIB_REGISTER_NODE (l2t_encap_node)
Definition: encap.c:196
unformat_pg_l2tp_header
uword unformat_pg_l2tp_header(unformat_input_t *input, va_list *args)
Definition: pg.c:41
sw_if_index
vl_api_interface_index_t sw_if_index
Definition: wireguard.api:34
l2t_trace_t::session_index
u32 session_index
Definition: l2tp.h:91
l2t_session_t::remote_session_id
u32 remote_session_id
Definition: l2tp.h:35
l2t_session_t::encap_fib_index
u32 encap_fib_index
Definition: l2tp.h:42
l2t_session_t::our_address
ip6_address_t our_address
Definition: l2tp.h:28
l2t_decap_node
vlib_node_registration_t l2t_decap_node
(constructor) VLIB_REGISTER_NODE (l2t_decap_node)
Definition: decap.c:253