2 * Copyright (c) 2011-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:
7 * http://www.apache.org/licenses/LICENSE-2.0
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.
15 #ifndef __included_cdp_node_h__
16 #define __included_cdp_node_h__
18 #include <vlib/vlib.h>
19 #include <vlib/unix/unix.h>
21 #include <vnet/snap/snap.h>
22 #include <vnet/hdlc/hdlc.h>
23 #include <vnet/hdlc/packet.h>
25 #include <vppinfra/format.h>
26 #include <vppinfra/hash.h>
28 #include <vnet/cdp/cdp_protocol.h>
31 CDP_PACKET_TEMPLATE_ETHERNET,
32 CDP_PACKET_TEMPLATE_HDLC,
33 CDP_PACKET_TEMPLATE_SRP,
34 CDP_N_PACKET_TEMPLATES,
35 } cdp_packet_template_id_t;
38 /* neighbor's vlib software interface index */
45 /* Neighbor time-to-live (usually 180s) */
48 /* "no cdp run" or similar */
51 /* tx packet template id for this neighbor */
52 u8 packet_template_index;
54 /* Jenkins hash optimization: avoid tlv scan, send short keepalive msg */
55 u8 last_packet_signature_valid;
56 uword last_packet_signature;
58 /* Info we actually keep about each neighbor */
64 /* last received packet, for the J-hash optimization */
68 #define foreach_neighbor_string_field \
75 /* pool of cdp neighbors */
76 cdp_neighbor_t *neighbors;
78 /* tx pcap debug enable */
81 /* rapidly find a neighbor by vlib software interface index */
82 uword *neighbor_by_sw_if_index;
84 /* Background process node index */
85 u32 cdp_process_node_index;
87 /* Packet templates for different encap types */
88 vlib_packet_template_t packet_templates [CDP_N_PACKET_TEMPLATES];
90 /* convenience variables */
91 vlib_main_t *vlib_main;
92 vnet_main_t *vnet_main;
98 #define foreach_cdp_error \
99 _ (NONE, "good cdp packets (processed)") \
100 _ (CACHE_HIT, "good cdp packets (cache hit)") \
101 _ (BAD_TLV, "cdp packets with bad TLVs") \
102 _ (PROTOCOL_VERSION, "cdp packets with bad protocol versions") \
103 _ (CHECKSUM, "cdp packets with bad checksums") \
104 _ (DISABLED, "cdp packets received on disabled interfaces")
107 #define _(sym,str) CDP_ERROR_##sym,
113 /* cdp packet trace capture */
120 CDP_EVENT_SEND_NEIGHBOR,
121 CDP_EVENT_SEND_KEEPALIVE,
122 } cdp_process_event_t;
125 cdp_error_t cdp_input (vlib_main_t * vm, vlib_buffer_t * b0, u32 bi0);
126 void cdp_periodic (vlib_main_t * vm);
127 void cdp_keepalive (cdp_main_t * cm, cdp_neighbor_t * n);
128 u16 cdp_checksum (void *p, int count);
129 u8 * cdp_input_format_trace (u8 * s, va_list * args);
131 serialize_function_t serialize_cdp_main, unserialize_cdp_main;
133 #endif /* __included_cdp_node_h__ */