2 * l2tp.h : L2TPv3 tunnel support
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:
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 #ifndef __included_l2tp_h__
19 #define __included_l2tp_h__
21 #include <vlib/vlib.h>
22 #include <vnet/ip/ip.h>
23 #include <vnet/l2tp/packet.h>
27 ip6_address_t our_address;
28 ip6_address_t client_address;
30 /* $$$$ maybe add encap-path lookup fib ID? */
32 /* l2tpv3 header parameters */
36 u32 remote_session_id;
38 /* tunnel interface */
43 u8 l2_sublayer_present;
44 u8 cookie_flags; /* in host byte order */
48 L2T_LOOKUP_SRC_ADDRESS = 0,
49 L2T_LOOKUP_DST_ADDRESS,
50 L2T_LOOKUP_SESSION_ID,
55 l2t_session_t *sessions;
57 /* ip6 -> l2 hash tables. Make up your minds, people... */
58 uword *session_by_src_address;
59 uword *session_by_dst_address;
60 uword *session_by_session_id;
62 ip6_to_l2_lookup_t lookup_type;
65 vlib_combined_counter_main_t counter_main;
67 /* vector of free l2tpv3 tunnel interfaces */
68 u32 * free_l2tpv3_tunnel_hw_if_indices;
70 /* show device instance by real device instance */
71 u32 * dev_inst_by_real;
74 vlib_main_t *vlib_main;
75 vnet_main_t *vnet_main;
79 /* Packet trace structure */
81 int is_user_to_network;
83 ip6_address_t our_address;
84 ip6_address_t client_address;
88 extern vlib_node_registration_t l2t_encap_node;
89 extern vlib_node_registration_t l2t_decap_node;
92 SESSION_COUNTER_USER_TO_NETWORK=0,
93 SESSION_COUNTER_NETWORK_TO_USER,
96 static inline u32 session_index_to_counter_index (u32 session_index,
99 return ((session_index << 1) + counter_id);
102 u8 * format_l2t_trace (u8 * s, va_list * args);
105 // Any per-interface config would go here
106 } ip6_l2tpv3_config_t;
108 uword unformat_pg_l2tp_header (unformat_input_t * input, va_list * args);
110 void l2tp_encap_init (vlib_main_t *vm);
111 void l2tp_decap_init (void);
112 int create_l2tpv3_ipv6_tunnel (l2t_main_t * lm,
113 ip6_address_t * client_address,
114 ip6_address_t * our_address,
115 u32 local_session_id,
116 u32 remote_session_id,
119 int l2_sublayer_present,
122 int l2tpv3_set_tunnel_cookies (l2t_main_t * lm,
124 u64 new_local_cookie,
125 u64 new_remote_cookie);
127 int l2tpv3_interface_enable_disable (vnet_main_t * vnm,
131 #endif /* __included_l2tp_h__ */