Hybrid ICN (hICN) plugin  v21.06-rc0-4-g18fa668
hicn.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017-2020 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 #ifndef __HICN_H__
17 #define __HICN_H__
18 
19 #define ip_address_t hicn_ip_address_t
20 #define ip_address_cmp hicn_ip_address_cmp
21 #define ip_prefix_t hicn_ip_prefix_t
22 #define ip_prefix_cmp hicn_ip_prefix_cmp
23 #undef ip_prefix_len
24 #define ip_prefix_len hicn_ip_prefix_len
25 #include <hicn/hicn.h>
26 #undef ip_address_t
27 #undef ip_address_cmp
28 #undef ip_prefix_t
29 #undef ip_prefix_cmp
30 #undef ip_prefix_len
31 #define ip_prefix_len(_a) (_a)->len
32 
33 #include "faces/face.h"
34 
35 #include <netinet/in.h>
36 #include <vnet/ip/ip.h>
37 #include <vnet/tcp/tcp_packet.h>
38 #include <vnet/ip/ip6_packet.h>
39 #include <vnet/ip/ip4_packet.h>
40 #include <vnet/buffer.h>
41 
46 /*
47  * Update CMakeLists.txt as we have to manually replace the type for
48  * vppapigen
49  */
50 typedef u8 weight_t;
51 
52 #define ISV6(isv6, dov6, dov4) isv6 ? dov6 : dov4
53 #define HICN_IS_NAMEHASH_CACHED(b) \
54  (((u64) (b->opaque2)[0] != 0) || ((u64) (b->opaque2)[1] != 0))
55 
56 #ifndef VLIB_BUFFER_MIN_CHAIN_SEG_SIZE
57 #define VLIB_BUFFER_MIN_CHAIN_SEG_SIZE (128)
58 #endif
59 
60 /* vlib_buffer cloning utilities impose that current_lentgh is more that
61  * 2*CLIB_CACHE_LINE_BYTES. */
62 /* This flag is used to mark packets whose lenght is less that
63  * 2*CLIB_CACHE_LINE_BYTES. */
64 #define HICN_BUFFER_FLAGS_PKT_LESS_TWO_CL 0x02
65 #define HICN_BUFFER_FLAGS_FROM_UDP4_TUNNEL 0x04
66 #define HICN_BUFFER_FLAGS_FROM_UDP6_TUNNEL 0x08
67 #define HICN_BUFFER_FLAGS_FROM_CS 0x10
68 
69 /* The following is stored in the opaque2 field in the vlib_buffer_t */
70 typedef struct
71 {
72  /* hash of the name */
73  u64 name_hash;
74 
75  /* ids to prefetch a PIT/CS entry */
76  u32 node_id;
77  u32 bucket_id;
78  u8 hash_entry_id;
79  u8 hash_bucket_flags;
80 
81  u8 flags;
82  u8 dpo_ctx_id; /* used for data path */
83  u8 vft_id; /* " */
84 
85  hicn_face_id_t face_id; /* ingress iface, sizeof(u32) */
86  u32 in_faces_vec_id; /* vector of possible input face for a data packet */
87 
88  hicn_type_t type;
90 
91 STATIC_ASSERT (sizeof (hicn_buffer_t) <=
92  STRUCT_SIZE_OF (vlib_buffer_t, opaque2),
93  "hICN buffer opaque2 meta-data too large for vlib_buffer");
94 
95 always_inline hicn_buffer_t *
96 hicn_get_buffer (vlib_buffer_t *b0)
97 {
98  return (hicn_buffer_t *) &(b0->opaque2[0]);
99 }
100 
101 always_inline u8
102 hicn_is_v6 (hicn_header_t *pkt_hdr)
103 {
104  return ((pkt_hdr->v4.ip.version_ihl >> 4) != 4);
105 }
106 
107 #endif /* __HICN_H__ */
108 
109 /*
110  * fd.io coding-style-patch-verification: ON
111  *
112  * Local Variables: eval: (c-set-style "gnu") End:
113  */
face.h
hicn_header_t
Definition: header.h:91
hicn_buffer_t
Definition: api.h:65
hicn_type_t
hICN packet format type
Definition: base.h:56