FD.io VPP
v16.06
Vector Packet Processing
Main Page
Related Pages
Data Structures
Source
Files
Symbols
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
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
;
36
37
typedef
struct
{
38
/* neighbor's vlib software interface index */
39
u32
sw_if_index
;
40
41
/* Timers */
42
f64
last_heard
;
43
f64
last_sent
;
44
45
/* Neighbor time-to-live (usually 180s) */
46
u8
ttl_in_seconds
;
47
48
/* "no cdp run" or similar */
49
u8
disabled
;
50
51
/* tx packet template id for this neighbor */
52
u8
packet_template_index
;
53
54
/* Jenkins hash optimization: avoid tlv scan, send short keepalive msg */
55
u8
last_packet_signature_valid
;
56
uword
last_packet_signature
;
57
58
/* Info we actually keep about each neighbor */
59
u8
*
device_name
;
60
u8
*
version
;
61
u8
*
port_id
;
62
u8
*
platform
;
63
64
/* last received packet, for the J-hash optimization */
65
u8
*
last_rx_pkt
;
66
}
cdp_neighbor_t
;
67
68
#define foreach_neighbor_string_field \
69
_(device_name) \
70
_(version) \
71
_(port_id) \
72
_(platform)
73
74
typedef
struct
{
75
/* pool of cdp neighbors */
76
cdp_neighbor_t
*
neighbors
;
77
78
/* tx pcap debug enable */
79
u8
tx_pcap_debug
;
80
81
/* rapidly find a neighbor by vlib software interface index */
82
uword
*
neighbor_by_sw_if_index
;
83
84
/* Background process node index */
85
u32
cdp_process_node_index
;
86
87
/* Packet templates for different encap types */
88
vlib_packet_template_t
packet_templates [
CDP_N_PACKET_TEMPLATES
];
89
90
/* convenience variables */
91
vlib_main_t
*
vlib_main
;
92
vnet_main_t
*
vnet_main
;
93
}
cdp_main_t
;
94
95
cdp_main_t
cdp_main
;
96
97
/* Packet counters */
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")
105
106
typedef
enum
{
107
#define _(sym,str) CDP_ERROR_##sym,
108
foreach_cdp_error
109
#undef _
110
CDP_N_ERROR
,
111
}
cdp_error_t
;
112
113
/* cdp packet trace capture */
114
typedef
struct
{
115
u32
len
;
116
u8
data[400];
117
}
cdp_input_trace_t
;
118
119
typedef
enum
{
120
CDP_EVENT_SEND_NEIGHBOR
,
121
CDP_EVENT_SEND_KEEPALIVE
,
122
}
cdp_process_event_t
;
123
124
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);
130
131
serialize_function_t
serialize_cdp_main
,
unserialize_cdp_main
;
132
133
#endif
/* __included_cdp_node_h__ */
cdp_checksum
u16 cdp_checksum(void *p, int count)
Definition:
cdp_input.c:29
CDP_EVENT_SEND_KEEPALIVE
Definition:
cdp_node.h:121
cdp_protocol.h
cdp_input
cdp_error_t cdp_input(vlib_main_t *vm, vlib_buffer_t *b0, u32 bi0)
Definition:
cdp_input.c:294
cdp_error_t
cdp_error_t
Definition:
cdp_node.h:106
cdp_neighbor_t::last_sent
f64 last_sent
Definition:
cdp_node.h:43
cdp_process_event_t
cdp_process_event_t
Definition:
cdp_node.h:119
cdp_neighbor_t::version
u8 * version
Definition:
cdp_node.h:60
cdp_main_t::cdp_process_node_index
u32 cdp_process_node_index
Definition:
cdp_node.h:85
cdp_neighbor_t::packet_template_index
u8 packet_template_index
Definition:
cdp_node.h:52
hash.h
cdp_main_t::neighbor_by_sw_if_index
uword * neighbor_by_sw_if_index
Definition:
cdp_node.h:82
vlib_packet_template_t
Definition:
buffer_funcs.h:518
cdp_neighbor_t::last_packet_signature_valid
u8 last_packet_signature_valid
Definition:
cdp_node.h:55
CDP_EVENT_SEND_NEIGHBOR
Definition:
cdp_node.h:120
foreach_cdp_error
#define foreach_cdp_error
Definition:
cdp_node.h:98
cdp_main_t::vnet_main
vnet_main_t * vnet_main
Definition:
cdp_node.h:92
cdp_neighbor_t::last_heard
f64 last_heard
Definition:
cdp_node.h:42
cdp_main_t::neighbors
cdp_neighbor_t * neighbors
Definition:
cdp_node.h:76
serialize_cdp_main
serialize_function_t serialize_cdp_main
Definition:
cdp_node.h:131
unix.h
cdp_input_format_trace
u8 * cdp_input_format_trace(u8 *s, va_list *args)
Definition:
cdp_input.c:442
cdp_neighbor_t::last_packet_signature
uword last_packet_signature
Definition:
cdp_node.h:56
cdp_main_t::tx_pcap_debug
u8 tx_pcap_debug
Definition:
cdp_node.h:79
CDP_PACKET_TEMPLATE_SRP
Definition:
cdp_node.h:33
cdp_periodic
void cdp_periodic(vlib_main_t *vm)
Definition:
cdp_periodic.c:330
packet.h
cdp_neighbor_t::last_rx_pkt
u8 * last_rx_pkt
Definition:
cdp_node.h:65
vlib_buffer_t
Definition:
buffer.h:73
cdp_neighbor_t::device_name
u8 * device_name
Definition:
cdp_node.h:59
unserialize_cdp_main
serialize_function_t unserialize_cdp_main
Definition:
cdp_node.h:131
CDP_N_PACKET_TEMPLATES
Definition:
cdp_node.h:34
cdp_neighbor_t::ttl_in_seconds
u8 ttl_in_seconds
Definition:
cdp_node.h:46
hdlc.h
vlib.h
vnet_main_t
Definition:
vnet.h:58
CDP_N_ERROR
Definition:
cdp_node.h:110
u32
unsigned int u32
Definition:
types.h:88
format.h
cdp_main_t::vlib_main
vlib_main_t * vlib_main
Definition:
cdp_node.h:91
cdp_keepalive
void cdp_keepalive(cdp_main_t *cm, cdp_neighbor_t *n)
cdp_packet_template_id_t
cdp_packet_template_id_t
Definition:
cdp_node.h:30
uword
u64 uword
Definition:
types.h:112
cdp_neighbor_t::disabled
u8 disabled
Definition:
cdp_node.h:49
u16
unsigned short u16
Definition:
types.h:57
cdp_input_trace_t
Definition:
cdp_node.h:114
f64
double f64
Definition:
types.h:140
serialize_function_t
void( serialize_function_t)(serialize_main_t *m, va_list *va)
Definition:
serialize.h:154
u8
unsigned char u8
Definition:
types.h:56
cdp_neighbor_t::port_id
u8 * port_id
Definition:
cdp_node.h:61
vlib_main_t
Definition:
main.h:59
cdp_main_t
Definition:
cdp_node.h:74
cdp_input_trace_t::len
u32 len
Definition:
cdp_node.h:115
cdp_neighbor_t::platform
u8 * platform
Definition:
cdp_node.h:62
cdp_neighbor_t
Definition:
cdp_node.h:37
cdp_main
cdp_main_t cdp_main
Definition:
cdp_node.h:95
CDP_PACKET_TEMPLATE_HDLC
Definition:
cdp_node.h:32
cdp_neighbor_t::sw_if_index
u32 sw_if_index
Definition:
cdp_node.h:39
snap.h
CDP_PACKET_TEMPLATE_ETHERNET
Definition:
cdp_node.h:31
vnet
vnet
cdp
cdp_node.h
Generated on Thu Sep 1 2016 09:11:32 for FD.io VPP by
1.8.11