NAT: DS-Lite (VPP-1040)
[vpp.git] / src / plugins / nat / dslite_dpo.c
1 /*
2  * Copyright (c) 2017 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 <nat/dslite_dpo.h>
18
19 dpo_type_t dslite_dpo_type;
20
21 void
22 dslite_dpo_create (dpo_proto_t dproto, u32 aftr_index, dpo_id_t * dpo)
23 {
24   dpo_set (dpo, dslite_dpo_type, dproto, aftr_index);
25 }
26
27 u8 *
28 format_dslite_dpo (u8 * s, va_list * args)
29 {
30   index_t index = va_arg (*args, index_t);
31   CLIB_UNUSED (u32 indent) = va_arg (*args, u32);
32
33   return (format (s, "DS-Lite: AFTR:%d", index));
34 }
35
36 static void
37 dslite_dpo_lock (dpo_id_t * dpo)
38 {
39 }
40
41 static void
42 dslite_dpo_unlock (dpo_id_t * dpo)
43 {
44 }
45
46 const static dpo_vft_t dslite_dpo_vft = {
47   .dv_lock = dslite_dpo_lock,
48   .dv_unlock = dslite_dpo_unlock,
49   .dv_format = format_dslite_dpo,
50 };
51
52 const static char *const dslite_ip4_nodes[] = {
53   "dslite-out2in",
54   NULL,
55 };
56
57 const static char *const dslite_ip6_nodes[] = {
58   "dslite-in2out",
59   NULL,
60 };
61
62 const static char *const *const dslite_nodes[DPO_PROTO_NUM] = {
63   [DPO_PROTO_IP4] = dslite_ip4_nodes,
64   [DPO_PROTO_IP6] = dslite_ip6_nodes,
65   [DPO_PROTO_MPLS] = NULL,
66 };
67
68 void
69 dslite_dpo_module_init (void)
70 {
71   dslite_dpo_type = dpo_register_new_type (&dslite_dpo_vft, dslite_nodes);
72 }
73
74 /*
75  * fd.io coding-style-patch-verification: ON
76  *
77  * Local Variables:
78  * eval: (c-set-style "gnu")
79  * End:
80  */