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.
17 * @brief LLDP global declarations
19 #ifndef __included_lldp_node_h__
20 #define __included_lldp_node_h__
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>
28 #include <vnet/lldp/lldp_protocol.h>
30 typedef struct lldp_intf
32 /* hw interface index */
39 /* Info received from peer */
43 lldp_port_id_subtype_t port_id_subtype;
44 lldp_chassis_id_subtype_t chassis_id_subtype;
53 /* pool of lldp-enabled interface context data */
56 /* rapidly find an interface by vlib hw interface index */
57 uword *intf_by_hw_if_index;
59 /* Background process node index */
60 u32 lldp_process_node_index;
62 /* interface idxs (into intfs pool) in the order of timing out */
65 /* index of the interface which will time out next */
66 u32 intfs_timeouts_idx;
68 /* packet template for sending out packets */
69 vlib_packet_template_t packet_template;
71 /* convenience variables */
72 vlib_main_t *vlib_main;
73 vnet_main_t *vnet_main;
75 /* system name advertised over LLDP (default is none) */
78 /* IEEE Std 802.1AB-2009:
80 * This variable is used, as a multiplier of msgTxInterval, to determine the
81 * value of txTTL that is carried in LLDP frames transmitted by the LLDP
82 * agent. The recommended default value of msgTxHold is 4; this value can
83 * be changed by management to any value in the range 1 through 100.
87 /* IEEE Std 802.1AB-2009:
88 * 9.2.5.7 msgTxInterval
89 * This variable defines the time interval in timer ticks between
90 * transmissions during normal transmission periods (i.e., txFast is zero).
91 * The recommended default value for msgTxInterval is 30 s; this value can
92 * be changed by management to any value in the range 1 through 3600.
97 #define LLDP_MIN_TX_HOLD (1)
98 #define LLDP_MAX_TX_HOLD (100)
99 #define LLDP_MIN_TX_INTERVAL (1)
100 #define LLDP_MAX_TX_INTERVAL (3600)
102 extern lldp_main_t lldp_main;
104 /* Packet counters */
105 #define foreach_lldp_error(F) \
106 F(NONE, "good lldp packets (processed)") \
107 F(CACHE_HIT, "good lldp packets (cache hit)") \
108 F(BAD_TLV, "lldp packets with bad TLVs") \
109 F(DISABLED, "lldp packets received on disabled interfaces")
113 #define F(sym, str) LLDP_ERROR_##sym,
114 foreach_lldp_error (F)
119 /* lldp packet trace capture */
124 } lldp_input_trace_t;
128 LLDP_EVENT_RESCHEDULE = 1,
129 } lldp_process_event_t;
131 lldp_intf_t *lldp_get_intf (lldp_main_t * lm, u32 hw_if_index);
132 lldp_intf_t *lldp_create_intf (lldp_main_t * lm, u32 hw_if_index);
133 void lldp_delete_intf (lldp_main_t * lm, lldp_intf_t * n);
134 lldp_error_t lldp_input (vlib_main_t * vm, vlib_buffer_t * b0, u32 bi0);
135 u8 *lldp_input_format_trace (u8 * s, va_list * args);
136 void lldp_send_ethernet (lldp_main_t * lm, lldp_intf_t * n, int shutdown);
137 void lldp_schedule_intf (lldp_main_t * lm, lldp_intf_t * n);
138 void lldp_unschedule_intf (lldp_main_t * lm, lldp_intf_t * n);
140 #endif /* __included_lldp_node_h__ */
143 * fd.io coding-style-patch-verification: ON
146 * eval: (c-set-style "gnu")