34 cdp_tlv_t *t = (cdp_tlv_t *) * t0p;
36 t->t = htons (CDP_TLV_device_name);
37 t->l = htons (3 +
sizeof (*t));
46 cdp_tlv_t *t = (cdp_tlv_t *) * t0p;
48 t->t = htons (CDP_TLV_port_id);
57 cdp_tlv_t *t = (cdp_tlv_t *) * t0p;
59 t->t = htons (CDP_TLV_version);
60 t->l = htons (12 +
sizeof (*t));
68 cdp_tlv_t *t = (cdp_tlv_t *) * t0p;
70 t->t = htons (CDP_TLV_platform);
71 t->l = htons (2 +
sizeof (*t));
79 cdp_tlv_t *t = (cdp_tlv_t *) * t0p;
82 t->t = htons (CDP_TLV_capabilities);
83 t->l = htons (4 +
sizeof (*t));
85 capabilities = htonl (capabilities);
86 clib_memcpy (&t->v, &capabilities, sizeof (capabilities));
107 ethernet_llc_snap_and_cdp_header_t *h0;
113 int nbytes_to_checksum;
119 for (i = 0; i <
count; i++)
137 t0 = (
u8 *) & h0->cdp.data;
143 nbytes_to_checksum = t0 - (
u8 *) & h0->cdp;
145 h0->cdp.checksum = htons (checksum);
150 -
sizeof (cdp_hdr_t);
177 hdlc_and_cdp_header_t *h0;
183 int nbytes_to_checksum;
189 for (i = 0; i <
count; i++)
203 t0 = (
u8 *) & h0->cdp.data;
209 nbytes_to_checksum = t0 - (
u8 *) & h0->cdp;
211 h0->cdp.checksum = htons (checksum);
216 -
sizeof (cdp_hdr_t);
236 srp_and_cdp_header_t *h0;
242 int nbytes_to_checksum;
248 for (i = 0; i <
count; i++)
262 t0 = (
u8 *) & h0->cdp.data;
272 nbytes_to_checksum = t0 - (
u8 *) & h0->cdp;
274 h0->cdp.checksum = htons (checksum);
279 -
sizeof (cdp_hdr_t);
356 static u32 *delete_list = 0;
363 vec_add1 (n_list, n);
368 for (i = 0; i <
vec_len (n_list); i++)
391 for (i = 0; i <
vec_len (delete_list); i++)
397 _vec_len (delete_list) = 0;
399 _vec_len (n_list) = 0;
409 ethernet_llc_snap_and_cdp_header_t
h;
411 memset (&h, 0,
sizeof (h));
414 h.ethernet.dst_address[0] = 0x01;
416 h.ethernet.dst_address[2] = 0x0C;
417 h.ethernet.dst_address[3] = 0xCC;
418 h.ethernet.dst_address[4] = 0xCC;
419 h.ethernet.dst_address[5] = 0xCC;
426 h.llc.dst_sap = h.llc.src_sap = 0xAA;
427 h.llc.control = 0x03;
432 h.snap.oui[2] = 0x0C;
433 h.snap.protocol = htons (0x2000);
451 hdlc_and_cdp_header_t
h;
453 memset (&h, 0,
sizeof (h));
455 h.hdlc.address = 0x0f;
457 h.hdlc.protocol = htons (0x2000);
473 srp_and_cdp_header_t
h;
475 memset (&h, 0,
sizeof (h));
478 h.ethernet.dst_address[0] = 0x01;
480 h.ethernet.dst_address[2] = 0x0C;
481 h.ethernet.dst_address[3] = 0xCC;
482 h.ethernet.dst_address[4] = 0xCC;
483 h.ethernet.dst_address[5] = 0xCC;
490 h.srp.mode = SRP_MODE_data;
495 h.ethernet.type = htons (0x2000);
static void add_capability_tlv(vnet_hw_interface_t *hw, u8 **t0p)
void cdp_periodic(vlib_main_t *vm)
#define hash_unset(h, key)
static vnet_hw_interface_t * vnet_get_sup_hw_interface(vnet_main_t *vnm, u32 sw_if_index)
static void delete_neighbor(cdp_main_t *cm, cdp_neighbor_t *n, int want_broadcast)
PCAP utility definitions.
static f64 vlib_time_now(vlib_main_t *vm)
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
static void add_tlvs(cdp_main_t *cm, vnet_hw_interface_t *hw, u8 **t0p)
u16 cdp_checksum(void *p, int count)
static vnet_sw_interface_t * vnet_get_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
static void srp_header_compute_parity(srp_header_t *h)
static void send_ethernet_hello(cdp_main_t *cm, cdp_neighbor_t *n, int count)
uword * neighbor_by_sw_if_index
memset(h->entries, 0, sizeof(h->entries[0])*entries)
void * vlib_packet_template_get_packet(vlib_main_t *vm, vlib_packet_template_t *t, u32 *bi_result)
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
#define VLIB_INIT_FUNCTION(x)
static void add_port_id_tlv(vnet_hw_interface_t *hw, u8 **t0p)
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
vlib_frame_t * vlib_get_frame_to_node(vlib_main_t *vm, u32 to_node_index)
static void add_version_tlv(vnet_hw_interface_t *hw, u8 **t0p)
void vlib_packet_template_init(vlib_main_t *vm, vlib_packet_template_t *t, void *packet_data, uword n_packet_data_bytes, uword min_n_buffers_each_alloc, char *fmt,...)
u16 current_length
Nbytes between current data and the end of this buffer.
void vlib_put_frame_to_node(vlib_main_t *vm, u32 to_node_index, vlib_frame_t *f)
#define pool_put(P, E)
Free an object E in pool P.
cdp_neighbor_t * neighbors
vnet_sw_interface_flags_t flags
static void send_hello(cdp_main_t *cm, cdp_neighbor_t *n, int count)
static void send_hdlc_hello(cdp_main_t *cm, cdp_neighbor_t *n, int count)
#define CDP_ROUTER_DEVICE
static void send_srp_hello(cdp_main_t *cm, cdp_neighbor_t *n, int count)
#define vec_free(V)
Free vector's memory (no header).
#define clib_memcpy(a, b, c)
static clib_error_t * cdp_periodic_init(vlib_main_t *vm)
vlib_packet_template_t packet_templates[CDP_N_PACKET_TEMPLATES]
static void add_device_name_tlv(vnet_hw_interface_t *hw, u8 **t0p)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
static int pick_packet_template(cdp_main_t *cm, cdp_neighbor_t *n)
static void add_platform_tlv(vnet_hw_interface_t *hw, u8 **t0p)
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.