1 /*---------------------------------------------------------------------------
2 * Copyright (c) 2009-2014 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.
14 *---------------------------------------------------------------------------
17 #include <vnet/fib/ip6_fib.h>
18 #include <vnet/ip/ip.h>
19 #include <vnet/ipip/ipip.h>
20 #include <vnet/vnet.h>
21 #include <vppinfra/error.h>
23 #define SIXRD_DEFAULT_MTU 1480 /* 1500 - IPv4 header */
25 #define foreach_sixrd_error \
26 /* Must be first. */ \
27 _(NONE, "valid SIXRD packets") \
28 _(BAD_PROTOCOL, "bad protocol") \
29 _(SEC_CHECK, "security check failed") \
30 _(NO_TUNNEL, "no tunnel")
35 #define _(sym, str) SIXRD_ERROR_##sym,
41 extern sixrd_main_t sixrd_main;
43 static_always_inline sixrd_tunnel_t *
44 find_tunnel_by_ip4_address (ip4_address_t * ip)
46 sixrd_main_t *sm = &sixrd_main;
48 p = hash_get (sm->tunnel_by_ip, ip->as_u32);
51 return pool_elt_at_index (sm->tunnels, p[0]);
54 static_always_inline sixrd_tunnel_t *
55 ip4_sixrd_get_tunnel (u32 sdi, ip4_address_t * addr, u8 * error)
57 sixrd_tunnel_t *t = find_tunnel_by_ip4_address (addr);
60 *error = SIXRD_ERROR_NO_TUNNEL;
67 * fd.io coding-style-patch-verification: ON
70 * eval: (c-set-style "gnu")