FD.io VPP  v17.10-9-gd594711
Vector Packet Processing
map_dpo.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016 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 <vnet/ip/ip.h>
17 #include <vnet/map/map_dpo.h>
18 
19 /**
20  * The register MAP DPO type
21  */
24 
25 void
27  u32 domain_index,
28  dpo_id_t *dpo)
29 {
30  dpo_set(dpo,
32  dproto,
33  domain_index);
34 }
35 
36 void
38  u32 domain_index,
39  dpo_id_t *dpo)
40 {
41  dpo_set(dpo,
43  dproto,
44  domain_index);
45 }
46 
47 
48 u8*
49 format_map_dpo (u8 *s, va_list *args)
50 {
51  index_t index = va_arg (*args, index_t);
52  CLIB_UNUSED(u32 indent) = va_arg (*args, u32);
53 
54  return (format(s, "map: domain:%d", index));
55 }
56 
57 u8*
58 format_map_t_dpo (u8 *s, va_list *args)
59 {
60  index_t index = va_arg (*args, index_t);
61  CLIB_UNUSED(u32 indent) = va_arg (*args, u32);
62 
63  return (format(s, "map-t: domain:%d", index));
64 }
65 
66 
67 static void
69 {
70 }
71 
72 static void
74 {
75 }
76 
77 const static dpo_vft_t md_vft = {
79  .dv_unlock = map_dpo_unlock,
80  .dv_format = format_map_dpo,
81 };
82 
83 const static char* const map_ip4_nodes[] =
84 {
85  "ip4-map",
86  NULL,
87 };
88 const static char* const map_ip6_nodes[] =
89 {
90  "ip6-map",
91  NULL,
92 };
93 
94 const static char* const * const map_nodes[DPO_PROTO_NUM] =
95 {
98  [DPO_PROTO_MPLS] = NULL,
99 };
100 
101 const static dpo_vft_t md_t_vft = {
103  .dv_unlock = map_dpo_unlock,
104  .dv_format = format_map_t_dpo,
105 };
106 
107 const static char* const map_t_ip4_nodes[] =
108 {
109  "ip4-map-t",
110  NULL,
111 };
112 const static char* const map_t_ip6_nodes[] =
113 {
114  "ip6-map-t",
115  NULL,
116 };
117 
118 const static char* const * const map_t_nodes[DPO_PROTO_NUM] =
119 {
122  [DPO_PROTO_MPLS] = NULL,
123 };
124 
125 void
127 {
130 }
dpo_lock_fn_t dv_lock
A reference counting lock function.
Definition: dpo.h:350
static const char *const map_t_ip6_nodes[]
Definition: map_dpo.c:112
#define CLIB_UNUSED(x)
Definition: clib.h:79
A virtual function table regisitered for a DPO type.
Definition: dpo.h:345
#define NULL
Definition: clib.h:55
u32 index_t
A Data-Path Object is an object that represents actions that are applied to packets are they are swit...
Definition: dpo.h:41
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:419
void map_dpo_create(dpo_proto_t dproto, u32 domain_index, dpo_id_t *dpo)
A representation of a MAP DPO.
Definition: map_dpo.c:26
enum dpo_type_t_ dpo_type_t
Common types of data-path objects New types can be dynamically added using dpo_register_new_type() ...
static const char *const map_ip4_nodes[]
Definition: map_dpo.c:83
enum dpo_proto_t_ dpo_proto_t
Data path protocol.
dpo_type_t dpo_register_new_type(const dpo_vft_t *vft, const char *const *const *nodes)
Create and register a new DPO type.
Definition: dpo.c:319
u8 * format_map_t_dpo(u8 *s, va_list *args)
Definition: map_dpo.c:58
The identity of a DPO is a combination of its type and its instance number/index of objects of that t...
Definition: dpo.h:150
u8 * format_map_dpo(u8 *s, va_list *args)
Definition: map_dpo.c:49
static void map_dpo_lock(dpo_id_t *dpo)
Definition: map_dpo.c:68
void map_t_dpo_create(dpo_proto_t dproto, u32 domain_index, dpo_id_t *dpo)
Definition: map_dpo.c:37
static const char *const map_ip6_nodes[]
Definition: map_dpo.c:88
void map_dpo_module_init(void)
Definition: map_dpo.c:126
static void map_dpo_unlock(dpo_id_t *dpo)
Definition: map_dpo.c:73
dpo_type_t map_dpo_type
The register MAP DPO type.
Definition: map_dpo.c:22
static const char *const map_t_ip4_nodes[]
Definition: map_dpo.c:107
void dpo_set(dpo_id_t *dpo, dpo_type_t type, dpo_proto_t proto, index_t index)
Set/create a DPO ID The DPO will be locked.
Definition: dpo.c:179
unsigned int u32
Definition: types.h:88
static const char *const *const map_t_nodes[DPO_PROTO_NUM]
Definition: map_dpo.c:118
static const char *const *const map_nodes[DPO_PROTO_NUM]
Definition: map_dpo.c:94
#define DPO_PROTO_NUM
Definition: dpo.h:69
unsigned char u8
Definition: types.h:56
dpo_type_t map_t_dpo_type
Definition: map_dpo.c:23