FD.io VPP  v20.05-21-gb1500e9ff
Vector Packet Processing
lldp_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 /**
16  * @file
17  * @brief LLDP global declarations
18  */
19 #ifndef __included_lldp_node_h__
20 #define __included_lldp_node_h__
21 
22 #include <vlib/vlib.h>
23 #include <vlib/unix/unix.h>
24 #include <vnet/snap/snap.h>
25 #include <vppinfra/format.h>
26 #include <vppinfra/hash.h>
27 
29 
30 typedef struct lldp_intf
31 {
32  /* hw interface index */
34 
35  /* Timers */
38 
39  /* Info received from peer */
45 
46  /* Local info */
48 
49  /* management ipv4 address */
51 
52  /* management ipv6 address */
54 
55  /* management object identifier */
57 } lldp_intf_t;
58 
59 typedef struct
60 {
61  /* pool of lldp-enabled interface context data */
63 
64  /* rapidly find an interface by vlib hw interface index */
66 
67  /* Background process node index */
69 
70  /* interface idxs (into intfs pool) in the order of timing out */
72 
73  /* index of the interface which will time out next */
75 
76  /* packet template for sending out packets */
78 
79  /* convenience variables */
82 
83  /* system name advertised over LLDP (default is none) */
85 
86  /* IEEE Std 802.1AB-2009:
87  * 9.2.5.6 msgTxHold
88  * This variable is used, as a multiplier of msgTxInterval, to determine the
89  * value of txTTL that is carried in LLDP frames transmitted by the LLDP
90  * agent. The recommended default value of msgTxHold is 4; this value can
91  * be changed by management to any value in the range 1 through 100.
92  */
94 
95  /* IEEE Std 802.1AB-2009:
96  * 9.2.5.7 msgTxInterval
97  * This variable defines the time interval in timer ticks between
98  * transmissions during normal transmission periods (i.e., txFast is zero).
99  * The recommended default value for msgTxInterval is 30 s; this value can
100  * be changed by management to any value in the range 1 through 3600.
101  */
103 } lldp_main_t;
104 
105 #define LLDP_MIN_TX_HOLD (1)
106 #define LLDP_MAX_TX_HOLD (100)
107 #define LLDP_MIN_TX_INTERVAL (1)
108 #define LLDP_MAX_TX_INTERVAL (3600)
109 
110 extern lldp_main_t lldp_main;
111 
112 /* Packet counters */
113 #define foreach_lldp_error(F) \
114  F(NONE, "good lldp packets (processed)") \
115  F(CACHE_HIT, "good lldp packets (cache hit)") \
116  F(BAD_TLV, "lldp packets with bad TLVs") \
117  F(DISABLED, "lldp packets received on disabled interfaces")
118 
119 typedef enum
120 {
121 #define F(sym, str) LLDP_ERROR_##sym,
123 #undef F
124  LLDP_N_ERROR,
125 } lldp_error_t;
126 
127 /* lldp packet trace capture */
128 typedef struct
129 {
131  u8 data[400];
133 
134 typedef enum
135 {
138 
141 void lldp_delete_intf (lldp_main_t * lm, lldp_intf_t * n);
142 lldp_error_t lldp_input (vlib_main_t * vm, vlib_buffer_t * b0, u32 bi0);
143 u8 *lldp_input_format_trace (u8 * s, va_list * args);
144 void lldp_send_ethernet (lldp_main_t * lm, lldp_intf_t * n, int shutdown);
147 
148 #endif /* __included_lldp_node_h__ */
149 
150 /*
151  * fd.io coding-style-patch-verification: ON
152  *
153  * Local Variables:
154  * eval: (c-set-style "gnu")
155  * End:
156  */
vnet_main_t * vnet_main
Definition: lldp_node.h:81
u8 * mgmt_ip4
Definition: lldp_node.h:50
u32 hw_if_index
Definition: lldp_node.h:33
lldp_chassis_id_subtype_t
Definition: lldp_protocol.h:85
u32 intfs_timeouts_idx
Definition: lldp_node.h:74
u8 * chassis_id
Definition: lldp_node.h:40
lldp_intf_t * intfs
Definition: lldp_node.h:62
f64 last_sent
Definition: lldp_node.h:37
u32 * intfs_timeouts
Definition: lldp_node.h:71
u16 ttl
Definition: lldp_node.h:42
unsigned char u8
Definition: types.h:56
double f64
Definition: types.h:142
void lldp_unschedule_intf(lldp_main_t *lm, lldp_intf_t *n)
Definition: lldp_node.c:267
void lldp_send_ethernet(lldp_main_t *lm, lldp_intf_t *n, int shutdown)
Definition: lldp_output.c:199
u8 msg_tx_hold
Definition: lldp_node.h:93
u8 * lldp_input_format_trace(u8 *s, va_list *args)
Definition: lldp_cli.c:695
u8 * port_id
Definition: lldp_node.h:41
lldp_error_t lldp_input(vlib_main_t *vm, vlib_buffer_t *b0, u32 bi0)
Definition: lldp_input.c:249
void lldp_delete_intf(lldp_main_t *lm, lldp_intf_t *n)
Definition: lldp_output.c:250
unsigned int u32
Definition: types.h:88
lldp_error_t
Definition: lldp_node.h:119
u16 msg_tx_interval
Definition: lldp_node.h:102
uword * intf_by_hw_if_index
Definition: lldp_node.h:65
unsigned short u16
Definition: types.h:57
lldp_main_t lldp_main
Definition: lldp_input.c:117
vlib_main_t * vm
Definition: in2out_ed.c:1599
void lldp_schedule_intf(lldp_main_t *lm, lldp_intf_t *n)
Definition: lldp_node.c:242
u8 * port_desc
Definition: lldp_node.h:47
lldp_intf_t * lldp_get_intf(lldp_main_t *lm, u32 hw_if_index)
Definition: lldp_input.c:212
LLDP protocol declarations.
lldp_process_event_t
Definition: lldp_node.h:134
u8 * mgmt_oid
Definition: lldp_node.h:56
u8 data[128]
Definition: ipsec_types.api:89
u8 * mgmt_ip6
Definition: lldp_node.h:53
#define foreach_lldp_error(F)
Definition: lldp_node.h:113
u32 lldp_process_node_index
Definition: lldp_node.h:68
lldp_port_id_subtype_t
vlib_main_t * vlib_main
Definition: lldp_node.h:80
struct lldp_intf lldp_intf_t
lldp_port_id_subtype_t port_id_subtype
Definition: lldp_node.h:43
#define F(sym, str)
Definition: lldp_node.h:121
VLIB buffer representation.
Definition: buffer.h:102
u64 uword
Definition: types.h:112
lldp_chassis_id_subtype_t chassis_id_subtype
Definition: lldp_node.h:44
lldp_intf_t * lldp_create_intf(lldp_main_t *lm, u32 hw_if_index)
Definition: lldp_input.c:224
vlib_packet_template_t packet_template
Definition: lldp_node.h:77
u8 * sys_name
Definition: lldp_node.h:84
f64 last_heard
Definition: lldp_node.h:36