3 * cdp.h - cdp protocol plug-in
5 * Copyright (c) 2011-2018 by Cisco and/or its affiliates.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at:
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 #ifndef __included_cdp_h__
19 #define __included_cdp_h__
21 #include <vlib/vlib.h>
22 #include <vlib/unix/unix.h>
24 #include <vnet/snap/snap.h>
25 #include <vnet/hdlc/hdlc.h>
26 #include <vnet/hdlc/packet.h>
28 #include <vppinfra/format.h>
29 #include <vppinfra/hash.h>
31 #include "cdp_protocol.h"
35 CDP_PACKET_TEMPLATE_ETHERNET,
36 CDP_PACKET_TEMPLATE_HDLC,
37 CDP_PACKET_TEMPLATE_SRP,
38 CDP_N_PACKET_TEMPLATES,
39 } cdp_packet_template_id_t;
43 /* neighbor's vlib software interface index */
50 /* Neighbor time-to-live (usually 180s) */
53 /* "no cdp run" or similar */
56 /* tx packet template id for this neighbor */
57 u8 packet_template_index;
59 /* Jenkins hash optimization: avoid tlv scan, send short keepalive msg */
60 u8 last_packet_signature_valid;
61 uword last_packet_signature;
63 /* Info we actually keep about each neighbor */
69 /* last received packet, for the J-hash optimization */
73 #define foreach_neighbor_string_field \
81 /* pool of cdp neighbors */
82 cdp_neighbor_t *neighbors;
84 /* plugin message id base */
87 /* tx pcap debug enable */
90 /* rapidly find a neighbor by vlib software interface index */
91 uword *neighbor_by_sw_if_index;
93 /* Background process node index */
94 u32 cdp_process_node_index;
98 int cdp_protocol_registered;
100 /* Packet templates for different encap types */
101 vlib_packet_template_t packet_templates[CDP_N_PACKET_TEMPLATES];
103 /* convenience variables */
104 vlib_main_t *vlib_main;
105 vnet_main_t *vnet_main;
108 extern cdp_main_t cdp_main;
109 extern vlib_node_registration_t cdp_process_node;
111 /* Packet counters */
112 #define foreach_cdp_error \
113 _ (NONE, "good cdp packets (processed)") \
114 _ (CACHE_HIT, "good cdp packets (cache hit)") \
115 _ (BAD_TLV, "cdp packets with bad TLVs") \
116 _ (PROTOCOL_VERSION, "cdp packets with bad protocol versions") \
117 _ (CHECKSUM, "cdp packets with bad checksums") \
118 _ (DISABLED, "cdp packets received on disabled interfaces")
122 #define _(sym,str) CDP_ERROR_##sym,
128 /* cdp packet trace capture */
139 } cdp_process_event_t;
141 cdp_error_t cdp_input (vlib_main_t * vm, vlib_buffer_t * b0, u32 bi0);
142 void cdp_periodic (vlib_main_t * vm);
143 void cdp_keepalive (cdp_main_t * cm, cdp_neighbor_t * n);
144 u16 cdp_checksum (void *p, int count);
145 u8 *cdp_input_format_trace (u8 * s, va_list * args);
147 #endif /* __included_cdp_h__ */
150 * fd.io coding-style-patch-verification: ON
153 * eval: (c-set-style "gnu")