FD.io VPP  v18.01.2-1-g9b554f3
Vector Packet Processing
cdp_node.h
Go to the documentation of this file.
1 /*
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:
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 #ifndef __included_cdp_node_h__
16 #define __included_cdp_node_h__
17 
18 #include <vlib/vlib.h>
19 #include <vlib/unix/unix.h>
20 
21 #include <vnet/snap/snap.h>
22 #include <vnet/hdlc/hdlc.h>
23 #include <vnet/hdlc/packet.h>
24 
25 #include <vppinfra/format.h>
26 #include <vppinfra/hash.h>
27 
28 #include <vnet/cdp/cdp_protocol.h>
29 
30 typedef enum
31 {
37 
38 typedef struct
39 {
40  /* neighbor's vlib software interface index */
42 
43  /* Timers */
46 
47  /* Neighbor time-to-live (usually 180s) */
49 
50  /* "no cdp run" or similar */
52 
53  /* tx packet template id for this neighbor */
55 
56  /* Jenkins hash optimization: avoid tlv scan, send short keepalive msg */
59 
60  /* Info we actually keep about each neighbor */
65 
66  /* last received packet, for the J-hash optimization */
69 
70 #define foreach_neighbor_string_field \
71 _(device_name) \
72 _(version) \
73 _(port_id) \
74 _(platform)
75 
76 typedef struct
77 {
78  /* pool of cdp neighbors */
80 
81  /* tx pcap debug enable */
83 
84  /* rapidly find a neighbor by vlib software interface index */
86 
87  /* Background process node index */
89 
90  /* Packet templates for different encap types */
92 
93  /* convenience variables */
96 } cdp_main_t;
97 
98 extern cdp_main_t cdp_main;
99 
100 /* Packet counters */
101 #define foreach_cdp_error \
102 _ (NONE, "good cdp packets (processed)") \
103 _ (CACHE_HIT, "good cdp packets (cache hit)") \
104 _ (BAD_TLV, "cdp packets with bad TLVs") \
105 _ (PROTOCOL_VERSION, "cdp packets with bad protocol versions") \
106 _ (CHECKSUM, "cdp packets with bad checksums") \
107 _ (DISABLED, "cdp packets received on disabled interfaces")
108 
109 typedef enum
110 {
111 #define _(sym,str) CDP_ERROR_##sym,
113 #undef _
115 } cdp_error_t;
116 
117 /* cdp packet trace capture */
118 typedef struct
119 {
121  u8 data[400];
123 
124 typedef enum
125 {
129 
130 
132 void cdp_periodic (vlib_main_t * vm);
133 void cdp_keepalive (cdp_main_t * cm, cdp_neighbor_t * n);
134 u16 cdp_checksum (void *p, int count);
135 u8 *cdp_input_format_trace (u8 * s, va_list * args);
136 
138 
139 #endif /* __included_cdp_node_h__ */
140 
141 /*
142  * fd.io coding-style-patch-verification: ON
143  *
144  * Local Variables:
145  * eval: (c-set-style "gnu")
146  * End:
147  */
u16 cdp_checksum(void *p, int count)
Definition: cdp_input.c:30
cdp_error_t cdp_input(vlib_main_t *vm, vlib_buffer_t *b0, u32 bi0)
Definition: cdp_input.c:301
cdp_error_t
Definition: cdp_node.h:109
cdp_process_event_t
Definition: cdp_node.h:124
u8 * version
Definition: cdp_node.h:62
u32 cdp_process_node_index
Definition: cdp_node.h:88
u8 packet_template_index
Definition: cdp_node.h:54
uword * neighbor_by_sw_if_index
Definition: cdp_node.h:85
u8 last_packet_signature_valid
Definition: cdp_node.h:57
#define foreach_cdp_error
Definition: cdp_node.h:101
vnet_main_t * vnet_main
Definition: cdp_node.h:95
f64 last_heard
Definition: cdp_node.h:44
cdp_neighbor_t * neighbors
Definition: cdp_node.h:79
serialize_function_t serialize_cdp_main
Definition: cdp_node.h:137
u8 * cdp_input_format_trace(u8 *s, va_list *args)
Definition: cdp_input.c:462
uword last_packet_signature
Definition: cdp_node.h:58
u8 tx_pcap_debug
Definition: cdp_node.h:82
void cdp_periodic(vlib_main_t *vm)
Definition: cdp_periodic.c:344
vlib_main_t * vm
Definition: buffer.c:283
u8 * last_rx_pkt
Definition: cdp_node.h:67
u8 * device_name
Definition: cdp_node.h:61
serialize_function_t unserialize_cdp_main
Definition: cdp_node.h:137
u8 ttl_in_seconds
Definition: cdp_node.h:48
unsigned int u32
Definition: types.h:88
vlib_main_t * vlib_main
Definition: cdp_node.h:94
size_t count
Definition: vapi.c:42
void cdp_keepalive(cdp_main_t *cm, cdp_neighbor_t *n)
cdp_packet_template_id_t
Definition: cdp_node.h:30
u64 uword
Definition: types.h:112
unsigned short u16
Definition: types.h:57
double f64
Definition: types.h:142
void( serialize_function_t)(serialize_main_t *m, va_list *va)
Definition: serialize.h:168
unsigned char u8
Definition: types.h:56
u8 * port_id
Definition: cdp_node.h:63
u8 * platform
Definition: cdp_node.h:64
cdp_main_t cdp_main
Definition: cdp_input.c:17
u32 sw_if_index
Definition: cdp_node.h:41