19 #define DEBUG_TLV_DUMP 0 46 sum = (sum & 0xFFFF) + (sum >> 16);
66 cdp_tlv_t *t = va_arg (*va, cdp_tlv_t *);
78 #if DEBUG_TLV_DUMP > 0 82 return CDP_ERROR_NONE;
88 cdp_tlv_t *t = va_arg (*va, cdp_tlv_t *);
94 for (i = 0; i < (t->l -
sizeof (*t)); i++)
101 #if DEBUG_TLV_DUMP == 0 112 #if DEBUG_TLV_DUMP > 0 116 return CDP_ERROR_NONE;
120 #define format_unused_tlv format_generic_tlv 121 #define format_device_name_tlv format_text_tlv 122 #define format_address_tlv format_generic_tlv 123 #define format_port_id_tlv format_text_tlv 124 #define format_capabilities_tlv format_generic_tlv 125 #define format_version_tlv format_text_tlv 126 #define format_platform_tlv format_text_tlv 127 #define format_ipprefix_tlv format_generic_tlv 128 #define format_hello_tlv format_generic_tlv 129 #define format_vtp_domain_tlv format_generic_tlv 130 #define format_native_vlan_tlv format_generic_tlv 131 #define format_duplex_tlv format_generic_tlv 132 #define format_appl_vlan_tlv format_generic_tlv 133 #define format_trigger_tlv format_generic_tlv 134 #define format_power_tlv format_generic_tlv 135 #define format_mtu_tlv format_generic_tlv 136 #define format_trust_tlv format_generic_tlv 137 #define format_cos_tlv format_generic_tlv 138 #define format_sysname_tlv format_generic_tlv 139 #define format_sysobject_tlv format_generic_tlv 140 #define format_mgmt_addr_tlv format_generic_tlv 141 #define format_physical_loc_tlv format_generic_tlv 142 #define format_mgmt_addr2_tlv format_generic_tlv 143 #define format_power_requested_tlv format_generic_tlv 144 #define format_power_available_tlv format_generic_tlv 145 #define format_port_unidirectional_tlv format_generic_tlv 146 #define format_unknown_28_tlv format_generic_tlv 147 #define format_energywise_tlv format_generic_tlv 148 #define format_unknown_30_tlv format_generic_tlv 149 #define format_spare_poe_tlv format_generic_tlv 155 return CDP_ERROR_BAD_TLV;
159 #define foreach_text_to_struct_tlv \ 160 _(device_name,DEBUG_TLV_DUMP) \ 161 _(version,DEBUG_TLV_DUMP) \ 162 _(platform,DEBUG_TLV_DUMP) \ 163 _(port_id,DEBUG_TLV_DUMP) 167 cdp_error_t process_##z##_tlv (cdp_main_t *cm, cdp_neighbor_t *n, \ 172 fformat(stdout, "%U\n", format_text_tlv, t); \ 175 _vec_len(n->z) = 0; \ 177 for (i = 0; i < (t->l - sizeof (*t)); i++) \ 178 vec_add1(n->z, t->v[i]); \ 182 return CDP_ERROR_NONE; \ 188 #define process_address_tlv process_generic_tlv 189 #define process_capabilities_tlv process_generic_tlv 190 #define process_ipprefix_tlv process_generic_tlv 191 #define process_hello_tlv process_generic_tlv 192 #define process_vtp_domain_tlv process_generic_tlv 193 #define process_native_vlan_tlv process_generic_tlv 194 #define process_duplex_tlv process_generic_tlv 195 #define process_appl_vlan_tlv process_generic_tlv 196 #define process_trigger_tlv process_generic_tlv 197 #define process_power_tlv process_generic_tlv 198 #define process_mtu_tlv process_generic_tlv 199 #define process_trust_tlv process_generic_tlv 200 #define process_cos_tlv process_generic_tlv 201 #define process_sysname_tlv process_generic_tlv 202 #define process_sysobject_tlv process_generic_tlv 203 #define process_mgmt_addr_tlv process_generic_tlv 204 #define process_physical_loc_tlv process_generic_tlv 205 #define process_mgmt_addr2_tlv process_generic_tlv 206 #define process_power_requested_tlv process_generic_tlv 207 #define process_power_available_tlv process_generic_tlv 208 #define process_port_unidirectional_tlv process_generic_tlv 209 #define process_unknown_28_tlv process_generic_tlv 210 #define process_energywise_tlv process_generic_tlv 211 #define process_unknown_30_tlv process_generic_tlv 212 #define process_spare_poe_tlv process_generic_tlv 216 #define _(a) {#a, CDP_TLV_##a, format_##a##_tlv, process_##a##_tlv}, 221 #if DEBUG_TLV_DUMP == 0 227 cdp_hdr_t *h = va_arg (*va, cdp_hdr_t *);
229 s =
format (s,
"version %d, ttl %d(secs), cksum 0x%04x\n",
230 h->version, h->ttl, h->checksum);
237 #if DEBUG_TLV_DUMP > 0 241 if (h->version != 1 && h->version != 2)
242 return CDP_ERROR_PROTOCOL_VERSION;
246 return CDP_ERROR_NONE;
258 u16 computed_checksum;
262 if (computed_checksum)
263 return CDP_ERROR_CHECKSUM;
265 h = (cdp_hdr_t *)cur;
274 tlv = (cdp_tlv_t *)cur;
275 tlv->t = ntohs(tlv->t);
276 tlv->l = ntohs(tlv->l);
278 return CDP_ERROR_BAD_TLV;
279 handler = &tlv_handlers[tlv->t];
281 e = (*fp)(cm, n, tlv);
288 return CDP_ERROR_NONE;
300 uword last_packet_signature;
309 memset (n, 0,
sizeof (*n));
329 return CDP_ERROR_DISABLED;
349 last_packet_signature =
354 e = CDP_ERROR_CACHE_HIT;
362 if (e == CDP_ERROR_NONE) {
402 "%=25s %=15s %=25s %=10s\n",
403 "Our Port",
"Peer System",
"Peer Port",
"Last Heard");
407 hw = vnet_get_sup_hw_interface (vnm, n->sw_if_index);
409 if (n->disabled == 0)
410 s = format (s,
"%=25s %=15s %=25s %=10.1f\n",
411 hw->name, n->device_name, n->port_id,
432 .short_help =
"Show cdp command",
451 u8 * (*fp)(cdp_tlv_t *);
455 h = (cdp_hdr_t *)cur;
460 while (cur < t->data + t->
len) {
461 tlv = (cdp_tlv_t *)cur;
462 tlv->t = ntohs(tlv->t);
463 tlv->l = ntohs(tlv->l);
465 s =
format (s,
"BAD_TLV\n");
468 handler = &tlv_handlers[tlv->t];
470 s =
format (s,
" %U", fp, tlv);
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
#define hash_set(h, key, value)
sll srl srl sll sra u16x4 i
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
uword * neighbor_by_sw_if_index
vnet_main_t * vnet_get_main(void)
#define pool_foreach(VAR, POOL, BODY)
#define VLIB_INIT_FUNCTION(x)
always_inline uword vlib_buffer_length_in_chain(vlib_main_t *vm, vlib_buffer_t *b)
Get length in bytes of the buffer chain.
u8 last_packet_signature_valid
#define vlib_call_init_function(vm, x)
#define pool_elt_at_index(p, i)
always_inline uword vlib_buffer_contents(vlib_main_t *vm, u32 buffer_index, u8 *contents)
Copy buffer contents to memory.
cdp_neighbor_t * neighbors
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
uword last_packet_signature
void vnet_cdp_node_reference(void)
static clib_error_t * cdp_periodic_init(vlib_main_t *vm)
#define VLIB_CLI_COMMAND(x,...)
#define hash_create(elts, value_bytes)
uword hash_memory(void *p, word n_bytes, uword state)
struct _mc_serialize_msg mc_serialize_msg_t
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
always_inline f64 vlib_time_now(vlib_main_t *vm)