blob: d1661dcc8e0b9443e0a5fd4f4d63bd6bb3dafa99 [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 * @brief
17 * The data-path object representing puntping the packet
18 */
19
20#include <vnet/dpo/dpo.h>
21
22static dpo_id_t punt_dpos[DPO_PROTO_NUM];
23
24const dpo_id_t *
25punt_dpo_get (dpo_proto_t proto)
26{
27 dpo_set(&punt_dpos[proto], DPO_PUNT, proto, 1);
28
29 return (&punt_dpos[proto]);
30}
31
32int
33dpo_is_punt (const dpo_id_t *dpo)
34{
35 return (dpo->dpoi_type == DPO_PUNT);
36}
37
38static void
39punt_dpo_lock (dpo_id_t *dpo)
40{
41 /*
42 * not maintaining a lock count on the punt
43 * more trouble than it's worth.
44 * There always needs to be one around. no point it managaing its lifetime
45 */
46}
47static void
48punt_dpo_unlock (dpo_id_t *dpo)
49{
50}
51
52static u8*
53format_punt_dpo (u8 *s, va_list *ap)
54{
Billy McFallcfcf1e22016-10-14 09:51:49 -040055 CLIB_UNUSED(index_t index) = va_arg(*ap, index_t);
56 CLIB_UNUSED(u32 indent) = va_arg(*ap, u32);
Neale Ranns0bfe5d82016-08-25 15:29:12 +010057
58 return (format(s, "dpo-punt"));
59}
60
61const static dpo_vft_t punt_vft = {
62 .dv_lock = punt_dpo_lock,
63 .dv_unlock = punt_dpo_unlock,
64 .dv_format = format_punt_dpo,
65};
66
67/**
68 * @brief The per-protocol VLIB graph nodes that are assigned to a punt
69 * object.
70 *
71 * this means that these graph nodes are ones from which a punt is the
72 * parent object in the DPO-graph.
73 */
74const static char* const punt_ip4_nodes[] =
75{
76 "ip4-punt",
77 NULL,
78};
79const static char* const punt_ip6_nodes[] =
80{
81 "ip6-punt",
82 NULL,
83};
84const static char* const punt_mpls_nodes[] =
85{
86 "mpls-punt",
87 NULL,
88};
89const static char* const * const punt_nodes[DPO_PROTO_NUM] =
90{
91 [DPO_PROTO_IP4] = punt_ip4_nodes,
92 [DPO_PROTO_IP6] = punt_ip6_nodes,
93 [DPO_PROTO_MPLS] = punt_mpls_nodes,
94};
95
96void
97punt_dpo_module_init (void)
98{
99 dpo_register(DPO_PUNT, &punt_vft, punt_nodes);
100}