socket_test.sh: Don't hard code debug image with gdb.
[vpp.git] / src / vnet / ipip / sixrd.h
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:
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
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  *---------------------------------------------------------------------------
15  */
16 #include <stdbool.h>
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>
22
23 #define SIXRD_DEFAULT_MTU 1480  /* 1500 - IPv4 header */
24
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")
31
32
33 typedef enum
34 {
35 #define _(sym, str) SIXRD_ERROR_##sym,
36   foreach_sixrd_error
37 #undef _
38     SIXRD_N_ERROR,
39 } sixrd_error_t;
40
41 extern sixrd_main_t sixrd_main;
42
43 static_always_inline sixrd_tunnel_t *
44 find_tunnel_by_ip4_address (ip4_address_t * ip)
45 {
46   sixrd_main_t *sm = &sixrd_main;
47   uword *p;
48   p = hash_get (sm->tunnel_by_ip, ip->as_u32);
49   if (!p)
50     return NULL;
51   return pool_elt_at_index (sm->tunnels, p[0]);
52 }
53
54 static_always_inline sixrd_tunnel_t *
55 ip4_sixrd_get_tunnel (u32 sdi, ip4_address_t * addr, u8 * error)
56 {
57   sixrd_tunnel_t *t = find_tunnel_by_ip4_address (addr);
58   if (!t)
59     {
60       *error = SIXRD_ERROR_NO_TUNNEL;
61       return NULL;
62     }
63   return t;
64 }
65
66 /*
67  * fd.io coding-style-patch-verification: ON
68  *
69  * Local Variables:
70  * eval: (c-set-style "gnu")
71  * End:
72  */