Line data Source code
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 : #include <vnet/ip/ip.h>
16 : #include <nat/dslite/dslite_dpo.h>
17 :
18 : dpo_type_t dslite_dpo_type;
19 : dpo_type_t dslite_ce_dpo_type;
20 :
21 : void
22 2 : dslite_dpo_create (dpo_proto_t dproto, u32 aftr_index, dpo_id_t * dpo)
23 : {
24 2 : dpo_set (dpo, dslite_dpo_type, dproto, aftr_index);
25 2 : }
26 :
27 : void
28 2 : dslite_ce_dpo_create (dpo_proto_t dproto, u32 b4_index, dpo_id_t * dpo)
29 : {
30 2 : dpo_set (dpo, dslite_ce_dpo_type, dproto, b4_index);
31 2 : }
32 :
33 : u8 *
34 0 : format_dslite_dpo (u8 * s, va_list * args)
35 : {
36 0 : index_t index = va_arg (*args, index_t);
37 0 : CLIB_UNUSED (u32 indent) = va_arg (*args, u32);
38 :
39 0 : return (format (s, "DS-Lite: AFTR:%d", index));
40 : }
41 :
42 : u8 *
43 0 : format_dslite_ce_dpo (u8 * s, va_list * args)
44 : {
45 0 : index_t index = va_arg (*args, index_t);
46 0 : CLIB_UNUSED (u32 indent) = va_arg (*args, u32);
47 :
48 0 : return (format (s, "DS-Lite: B4:%d", index));
49 : }
50 :
51 : static void
52 12 : dslite_dpo_lock (dpo_id_t * dpo)
53 : {
54 12 : }
55 :
56 : static void
57 6 : dslite_dpo_unlock (dpo_id_t * dpo)
58 : {
59 6 : }
60 :
61 : static void
62 12 : dslite_ce_dpo_lock (dpo_id_t * dpo)
63 : {
64 12 : }
65 :
66 : static void
67 6 : dslite_ce_dpo_unlock (dpo_id_t * dpo)
68 : {
69 6 : }
70 :
71 : const static dpo_vft_t dslite_dpo_vft = {
72 : .dv_lock = dslite_dpo_lock,
73 : .dv_unlock = dslite_dpo_unlock,
74 : .dv_format = format_dslite_dpo,
75 : };
76 :
77 : const static dpo_vft_t dslite_ce_dpo_vft = {
78 : .dv_lock = dslite_ce_dpo_lock,
79 : .dv_unlock = dslite_ce_dpo_unlock,
80 : .dv_format = format_dslite_ce_dpo,
81 : };
82 :
83 : const static char *const dslite_ip4_nodes[] = {
84 : "dslite-out2in",
85 : NULL,
86 : };
87 :
88 : const static char *const dslite_ip6_nodes[] = {
89 : "dslite-in2out",
90 : NULL,
91 : };
92 :
93 : const static char *const dslite_ce_ip4_nodes[] = {
94 : "dslite-ce-encap",
95 : NULL,
96 : };
97 :
98 : const static char *const dslite_ce_ip6_nodes[] = {
99 : "dslite-ce-decap",
100 : NULL,
101 : };
102 :
103 : const static char *const *const dslite_nodes[DPO_PROTO_NUM] = {
104 : [DPO_PROTO_IP4] = dslite_ip4_nodes,
105 : [DPO_PROTO_IP6] = dslite_ip6_nodes,
106 : [DPO_PROTO_MPLS] = NULL,
107 : };
108 :
109 : const static char *const *const dslite_ce_nodes[DPO_PROTO_NUM] = {
110 : [DPO_PROTO_IP4] = dslite_ce_ip4_nodes,
111 : [DPO_PROTO_IP6] = dslite_ce_ip6_nodes,
112 : [DPO_PROTO_MPLS] = NULL,
113 : };
114 :
115 : void
116 559 : dslite_dpo_module_init (void)
117 : {
118 559 : dslite_dpo_type = dpo_register_new_type (&dslite_dpo_vft, dslite_nodes);
119 559 : dslite_ce_dpo_type = dpo_register_new_type (&dslite_ce_dpo_vft,
120 : dslite_ce_nodes);
121 559 : }
122 :
123 : /*
124 : * fd.io coding-style-patch-verification: ON
125 : *
126 : * Local Variables:
127 : * eval: (c-set-style "gnu")
128 : * End:
129 : */
|