blob: 430c1fbf2665178d2bf169924decb1c6e177aad0 [file] [log] [blame]
Neale Ranns0bfe5d82016-08-25 15:29:12 +01001/*
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/**
Neale Ranns0bfe5d82016-08-25 15:29:12 +010020 * The register MAP DPO type
21 */
22dpo_type_t map_dpo_type;
23dpo_type_t map_t_dpo_type;
24
Neale Ranns0bfe5d82016-08-25 15:29:12 +010025void
26map_dpo_create (dpo_proto_t dproto,
27 u32 domain_index,
28 dpo_id_t *dpo)
29{
Neale Ranns0bfe5d82016-08-25 15:29:12 +010030 dpo_set(dpo,
31 map_dpo_type,
32 dproto,
Neale Ranns9705c382017-02-20 20:29:41 -080033 domain_index);
Neale Ranns0bfe5d82016-08-25 15:29:12 +010034}
35
36void
37map_t_dpo_create (dpo_proto_t dproto,
38 u32 domain_index,
39 dpo_id_t *dpo)
40{
Neale Ranns0bfe5d82016-08-25 15:29:12 +010041 dpo_set(dpo,
42 map_t_dpo_type,
43 dproto,
Neale Ranns9705c382017-02-20 20:29:41 -080044 domain_index);
Neale Ranns0bfe5d82016-08-25 15:29:12 +010045}
46
47
48u8*
49format_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);
Neale Ranns0bfe5d82016-08-25 15:29:12 +010053
Neale Ranns9705c382017-02-20 20:29:41 -080054 return (format(s, "map: domain:%d", index));
Neale Ranns0bfe5d82016-08-25 15:29:12 +010055}
56
57u8*
58format_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);
Neale Ranns0bfe5d82016-08-25 15:29:12 +010062
Neale Ranns9705c382017-02-20 20:29:41 -080063 return (format(s, "map-t: domain:%d", index));
Neale Ranns0bfe5d82016-08-25 15:29:12 +010064}
65
66
67static void
68map_dpo_lock (dpo_id_t *dpo)
69{
Neale Ranns0bfe5d82016-08-25 15:29:12 +010070}
71
72static void
73map_dpo_unlock (dpo_id_t *dpo)
74{
Neale Ranns0bfe5d82016-08-25 15:29:12 +010075}
76
77const static dpo_vft_t md_vft = {
78 .dv_lock = map_dpo_lock,
79 .dv_unlock = map_dpo_unlock,
80 .dv_format = format_map_dpo,
81};
82
83const static char* const map_ip4_nodes[] =
84{
85 "ip4-map",
86 NULL,
87};
88const static char* const map_ip6_nodes[] =
89{
90 "ip6-map",
91 NULL,
92};
93
94const static char* const * const map_nodes[DPO_PROTO_NUM] =
95{
96 [DPO_PROTO_IP4] = map_ip4_nodes,
97 [DPO_PROTO_IP6] = map_ip6_nodes,
98 [DPO_PROTO_MPLS] = NULL,
99};
100
101const static dpo_vft_t md_t_vft = {
102 .dv_lock = map_dpo_lock,
103 .dv_unlock = map_dpo_unlock,
104 .dv_format = format_map_t_dpo,
105};
106
107const static char* const map_t_ip4_nodes[] =
108{
109 "ip4-map-t",
110 NULL,
111};
112const static char* const map_t_ip6_nodes[] =
113{
114 "ip6-map-t",
115 NULL,
116};
117
118const static char* const * const map_t_nodes[DPO_PROTO_NUM] =
119{
120 [DPO_PROTO_IP4] = map_t_ip4_nodes,
121 [DPO_PROTO_IP6] = map_t_ip6_nodes,
122 [DPO_PROTO_MPLS] = NULL,
123};
124
125void
126map_dpo_module_init (void)
127{
128 map_dpo_type = dpo_register_new_type(&md_vft, map_nodes);
129 map_t_dpo_type = dpo_register_new_type(&md_t_vft, map_t_nodes);
130}