FD.io VPP
v19.04.4-rc0-5-ge88582fac
Vector Packet Processing
cdp.h
Go to the documentation of this file.
1
2
/*
3
* cdp.h - cdp protocol plug-in
4
*
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:
9
*
10
* http://www.apache.org/licenses/LICENSE-2.0
11
*
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.
17
*/
18
#ifndef __included_cdp_h__
19
#define __included_cdp_h__
20
21
#include <
vlib/vlib.h
>
22
#include <
vlib/unix/unix.h
>
23
24
#include <
vnet/snap/snap.h
>
25
#include <
vnet/hdlc/hdlc.h
>
26
#include <
vnet/hdlc/packet.h
>
27
28
#include <
vppinfra/format.h
>
29
#include <
vppinfra/hash.h
>
30
31
#include "
cdp_protocol.h
"
32
33
typedef
enum
34
{
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
;
40
41
typedef
struct
42
{
43
/* neighbor's vlib software interface index */
44
u32
sw_if_index
;
45
46
/* Timers */
47
f64
last_heard
;
48
f64
last_sent
;
49
50
/* Neighbor time-to-live (usually 180s) */
51
u8
ttl_in_seconds
;
52
53
/* "no cdp run" or similar */
54
u8
disabled
;
55
56
/* tx packet template id for this neighbor */
57
u8
packet_template_index
;
58
59
/* Jenkins hash optimization: avoid tlv scan, send short keepalive msg */
60
u8
last_packet_signature_valid
;
61
uword
last_packet_signature
;
62
63
/* Info we actually keep about each neighbor */
64
u8
*
device_name
;
65
u8
*
version
;
66
u8
*
port_id
;
67
u8
*
platform
;
68
69
/* last received packet, for the J-hash optimization */
70
u8
*
last_rx_pkt
;
71
}
cdp_neighbor_t
;
72
73
#define foreach_neighbor_string_field \
74
_(device_name) \
75
_(version) \
76
_(port_id) \
77
_(platform)
78
79
typedef
struct
80
{
81
/* pool of cdp neighbors */
82
cdp_neighbor_t
*
neighbors
;
83
84
/* plugin message id base */
85
u16
msg_id_base
;
86
87
/* tx pcap debug enable */
88
u8
tx_pcap_debug
;
89
90
/* rapidly find a neighbor by vlib software interface index */
91
uword
*
neighbor_by_sw_if_index
;
92
93
/* Background process node index */
94
u32
cdp_process_node_index
;
95
96
/* top-level state */
97
int
enabled
;
98
int
cdp_protocol_registered
;
99
100
/* Packet templates for different encap types */
101
vlib_packet_template_t
packet_templates[
CDP_N_PACKET_TEMPLATES
];
102
103
/* convenience variables */
104
vlib_main_t
*
vlib_main
;
105
vnet_main_t
*
vnet_main
;
106
}
cdp_main_t
;
107
108
extern
cdp_main_t
cdp_main
;
109
extern
vlib_node_registration_t
cdp_process_node
;
110
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")
119
120
typedef
enum
121
{
122
#define _(sym,str) CDP_ERROR_##sym,
123
foreach_cdp_error
124
#undef _
125
CDP_N_ERROR
,
126
}
cdp_error_t
;
127
128
/* cdp packet trace capture */
129
typedef
struct
130
{
131
u32
len
;
132
u8
data
[400];
133
}
cdp_input_trace_t
;
134
135
typedef
enum
136
{
137
CDP_EVENT_ENABLE
,
138
CDP_EVENT_DISABLE
,
139
}
cdp_process_event_t
;
140
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);
146
147
#endif
/* __included_cdp_h__ */
148
149
/*
150
* fd.io coding-style-patch-verification: ON
151
*
152
* Local Variables:
153
* eval: (c-set-style "gnu")
154
* End:
155
*/
cdp_main_t::msg_id_base
u16 msg_id_base
Definition:
cdp.h:85
cdp_error_t
cdp_error_t
Definition:
cdp.h:120
cdp_protocol.h
cdp_main_t::enabled
int enabled
Definition:
cdp.h:97
cdp_input
cdp_error_t cdp_input(vlib_main_t *vm, vlib_buffer_t *b0, u32 bi0)
Definition:
cdp_input.c:323
CDP_EVENT_DISABLE
Definition:
cdp.h:138
cdp_main
cdp_main_t cdp_main
Definition:
cdp_input.c:17
cdp_neighbor_t::last_sent
f64 last_sent
Definition:
cdp.h:48
cdp_neighbor_t::version
u8 * version
Definition:
cdp.h:65
cdp_main_t::cdp_process_node_index
u32 cdp_process_node_index
Definition:
cdp.h:94
cdp_checksum
u16 cdp_checksum(void *p, int count)
Definition:
cdp_input.c:26
cdp_neighbor_t::packet_template_index
u8 packet_template_index
Definition:
cdp.h:57
data
u8 data[128]
Definition:
ipsec.api:248
u8
unsigned char u8
Definition:
types.h:56
CDP_EVENT_ENABLE
Definition:
cdp.h:137
hash.h
cdp_main_t::neighbor_by_sw_if_index
uword * neighbor_by_sw_if_index
Definition:
cdp.h:91
f64
double f64
Definition:
types.h:142
cdp_periodic
void cdp_periodic(vlib_main_t *vm)
Definition:
cdp_periodic.c:350
vlib_packet_template_t
Definition:
buffer_funcs.h:1312
u32
unsigned int u32
Definition:
types.h:88
cdp_neighbor_t::last_packet_signature_valid
u8 last_packet_signature_valid
Definition:
cdp.h:60
cdp_input_format_trace
u8 * cdp_input_format_trace(u8 *s, va_list *args)
Definition:
cdp_input.c:486
CDP_PACKET_TEMPLATE_ETHERNET
Definition:
cdp.h:35
cdp_main_t::vnet_main
vnet_main_t * vnet_main
Definition:
cdp.h:105
CDP_N_PACKET_TEMPLATES
Definition:
cdp.h:38
unix.h
u16
unsigned short u16
Definition:
types.h:57
cdp_neighbor_t::last_heard
f64 last_heard
Definition:
cdp.h:47
cdp_main_t::neighbors
cdp_neighbor_t * neighbors
Definition:
cdp.h:82
foreach_cdp_error
#define foreach_cdp_error
Definition:
cdp.h:112
format.h
CDP_N_ERROR
Definition:
cdp.h:125
cdp_neighbor_t::last_packet_signature
uword last_packet_signature
Definition:
cdp.h:61
cdp_main_t::tx_pcap_debug
u8 tx_pcap_debug
Definition:
cdp.h:88
cdp_process_event_t
cdp_process_event_t
Definition:
cdp.h:135
vm
vlib_main_t * vm
Definition:
buffer.c:312
packet.h
cdp_neighbor_t::last_rx_pkt
u8 * last_rx_pkt
Definition:
cdp.h:70
cdp_keepalive
void cdp_keepalive(cdp_main_t *cm, cdp_neighbor_t *n)
cdp_neighbor_t::device_name
u8 * device_name
Definition:
cdp.h:64
cdp_neighbor_t::ttl_in_seconds
u8 ttl_in_seconds
Definition:
cdp.h:51
hdlc.h
vlib.h
vnet_main_t
Definition:
vnet.h:51
cdp_main_t::vlib_main
vlib_main_t * vlib_main
Definition:
cdp.h:104
cdp_process_node
vlib_node_registration_t cdp_process_node
(constructor) VLIB_REGISTER_NODE (cdp_process_node)
Definition:
cdp_node.c:207
count
size_t count
Definition:
vapi.c:47
CDP_PACKET_TEMPLATE_HDLC
Definition:
cdp.h:36
CDP_PACKET_TEMPLATE_SRP
Definition:
cdp.h:37
cdp_packet_template_id_t
cdp_packet_template_id_t
Definition:
cdp.h:33
cdp_neighbor_t::disabled
u8 disabled
Definition:
cdp.h:54
vlib_node_registration_t
struct _vlib_node_registration vlib_node_registration_t
cdp_input_trace_t
Definition:
cdp.h:129
cdp_neighbor_t::port_id
u8 * port_id
Definition:
cdp.h:66
vlib_main_t
Definition:
main.h:68
vlib_buffer_t
VLIB buffer representation.
Definition:
buffer.h:102
uword
u64 uword
Definition:
types.h:112
cdp_main_t
Definition:
cdp.h:79
cdp_main_t::cdp_protocol_registered
int cdp_protocol_registered
Definition:
cdp.h:98
cdp_input_trace_t::len
u32 len
Definition:
cdp.h:131
cdp_neighbor_t::platform
u8 * platform
Definition:
cdp.h:67
cdp_neighbor_t
Definition:
cdp.h:41
cdp_neighbor_t::sw_if_index
u32 sw_if_index
Definition:
cdp.h:44
snap.h
src
plugins
cdp
cdp.h
Generated on Mon Jun 29 2020 12:02:00 for FD.io VPP by
1.8.13