FD.io VPP  v20.09-64-g4f7b92f0a
Vector Packet Processing
sixrd.h
Go to the documentation of this file.
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,
37 #undef _
40 
41 extern sixrd_main_t sixrd_main;
42 
43 static_always_inline sixrd_tunnel_t *
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 *
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  */
sixrd_error_t
Definition: sixrd.h:33
static_always_inline sixrd_tunnel_t * find_tunnel_by_ip4_address(ip4_address_t *ip)
Definition: sixrd.h:44
vhost_vring_addr_t addr
Definition: vhost_user.h:111
unsigned char u8
Definition: types.h:56
#define static_always_inline
Definition: clib.h:108
unsigned int u32
Definition: types.h:88
#define hash_get(h, key)
Definition: hash.h:249
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:534
#define foreach_sixrd_error
Definition: sixrd.h:25
sixrd_main_t sixrd_main
vl_api_address_t ip
Definition: l2.api:501
u64 uword
Definition: types.h:112
static_always_inline sixrd_tunnel_t * ip4_sixrd_get_tunnel(u32 sdi, ip4_address_t *addr, u8 *error)
Definition: sixrd.h:55