2 * Copyright (c) 2017 Cisco and/or its affiliates.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
15 #ifndef __included_dslite_h__
16 #define __included_dslite_h__
18 #include <vppinfra/bihash_8_8.h>
19 #include <vppinfra/bihash_16_8.h>
20 #include <vppinfra/bihash_24_8.h>
29 ip6_address_t softwire_id;
37 } dslite_session_key_t;
40 typedef CLIB_PACKED (struct
42 snat_session_key_t out2in;
43 dslite_session_key_t in2out;
45 u32 per_b4_list_head_index;
55 u32 sessions_per_b4_list_head_index;
61 /* Main lookup tables */
62 clib_bihash_8_8_t out2in;
63 clib_bihash_24_8_t in2out;
66 clib_bihash_16_8_t b4_hash;
72 dslite_session_t *sessions;
74 /* Pool of doubly-linked list elements */
75 dlist_elt_t *list_pool;
76 } dslite_per_thread_data_t;
80 ip6_address_t aftr_ip6_addr;
81 ip4_address_t aftr_ip4_addr;
82 ip6_address_t b4_ip6_addr;
83 ip4_address_t b4_ip4_addr;
84 dslite_per_thread_data_t *per_thread_data;
85 snat_address_t *addr_pool;
87 u32 first_worker_index;
91 vlib_simple_counter_main_t total_b4s;
92 vlib_simple_counter_main_t total_sessions;
95 u32 dslite_in2out_node_index;
96 u32 dslite_in2out_slowpath_node_index;
97 u32 dslite_out2in_node_index;
99 /* If set then the DSLite component behaves as CPE/B4
100 * otherwise it behaves as AFTR */
115 #define foreach_dslite_error \
116 _(IN2OUT, "valid in2out DS-Lite packets") \
117 _(OUT2IN, "valid out2in DS-Lite packets") \
118 _(CE_ENCAP, "valid CE encap DS-Lite packets") \
119 _(CE_DECAP, "valid CE decap DS-Lite packets") \
120 _(NO_TRANSLATION, "no translation") \
121 _(BAD_IP6_PROTOCOL, "bad ip6 protocol") \
122 _(OUT_OF_PORTS, "out of ports") \
123 _(UNSUPPORTED_PROTOCOL, "unsupported protocol") \
124 _(BAD_ICMP_TYPE, "unsupported icmp type") \
125 _(UNKNOWN, "unknown")
129 #define _(sym,str) DSLITE_ERROR_##sym,
135 extern dslite_main_t dslite_main;
136 extern vlib_node_registration_t dslite_in2out_node;
137 extern vlib_node_registration_t dslite_in2out_slowpath_node;
138 extern vlib_node_registration_t dslite_out2in_node;
139 extern vlib_node_registration_t dslite_ce_encap_node;
140 extern vlib_node_registration_t dslite_ce_decap_node;
142 void dslite_init (vlib_main_t * vm);
143 void dslite_set_ce (dslite_main_t * dm, u8 set);
144 int dslite_set_aftr_ip6_addr (dslite_main_t * dm, ip6_address_t * addr);
145 int dslite_set_b4_ip6_addr (dslite_main_t * dm, ip6_address_t * addr);
146 int dslite_set_aftr_ip4_addr (dslite_main_t * dm, ip4_address_t * addr);
147 int dslite_set_b4_ip4_addr (dslite_main_t * dm, ip4_address_t * addr);
148 int dslite_add_del_pool_addr (dslite_main_t * dm, ip4_address_t * addr,
150 u8 *format_dslite_trace (u8 * s, va_list * args);
151 u8 *format_dslite_ce_trace (u8 * s, va_list * args);
153 #endif /* __included_dslite_h__ */
156 * fd.io coding-style-patch-verification: ON
159 * eval: (c-set-style "gnu")