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++)
134 t0 = (
u8 *) & h0->cdp.data;
140 nbytes_to_checksum = t0 - (
u8 *) & h0->cdp;
142 h0->cdp.checksum = htons (checksum);
147 -
sizeof (cdp_hdr_t);
174 hdlc_and_cdp_header_t *h0;
180 int nbytes_to_checksum;
186 for (i = 0; i < count; i++)
197 t0 = (
u8 *) & h0->cdp.data;
203 nbytes_to_checksum = t0 - (
u8 *) & h0->cdp;
205 h0->cdp.checksum = htons (checksum);
210 -
sizeof (cdp_hdr_t);
230 srp_and_cdp_header_t *h0;
236 int nbytes_to_checksum;
242 for (i = 0; i < count; i++)
253 t0 = (
u8 *) & h0->cdp.data;
263 nbytes_to_checksum = t0 - (
u8 *) & h0->cdp;
265 h0->cdp.checksum = htons (checksum);
270 -
sizeof (cdp_hdr_t);
347 static u32 *delete_list = 0;
354 vec_add1 (n_list, n);
359 for (i = 0; i <
vec_len (n_list); i++)
382 for (i = 0; i <
vec_len (delete_list); i++)
388 _vec_len (delete_list) = 0;
390 _vec_len (n_list) = 0;
400 ethernet_llc_snap_and_cdp_header_t h;
402 memset (&h, 0,
sizeof (h));
405 h.ethernet.dst_address[0] = 0x01;
407 h.ethernet.dst_address[2] = 0x0C;
408 h.ethernet.dst_address[3] = 0xCC;
409 h.ethernet.dst_address[4] = 0xCC;
410 h.ethernet.dst_address[5] = 0xCC;
417 h.llc.dst_sap = h.llc.src_sap = 0xAA;
418 h.llc.control = 0x03;
423 h.snap.oui[2] = 0x0C;
424 h.snap.protocol = htons (0x2000);
442 hdlc_and_cdp_header_t h;
444 memset (&h, 0,
sizeof (h));
446 h.hdlc.address = 0x0f;
448 h.hdlc.protocol = htons (0x2000);
464 srp_and_cdp_header_t h;
466 memset (&h, 0,
sizeof (h));
469 h.ethernet.dst_address[0] = 0x01;
471 h.ethernet.dst_address[2] = 0x0C;
472 h.ethernet.dst_address[3] = 0xCC;
473 h.ethernet.dst_address[4] = 0xCC;
474 h.ethernet.dst_address[5] = 0xCC;
481 h.srp.mode = SRP_MODE_data;
486 h.ethernet.type = htons (0x2000);
static void add_capability_tlv(vnet_hw_interface_t *hw, u8 **t0p)
sll srl srl sll sra u16x4 i
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)
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
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_physmem_alloc, char *fmt,...)
#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.
static void add_version_tlv(vnet_hw_interface_t *hw, u8 **t0p)
u16 current_length
Nbytes between current data and the end of this buffer.
#define pool_put(P, E)
Free an object E in pool P.
cdp_neighbor_t * neighbors
static void send_hello(cdp_main_t *cm, cdp_neighbor_t *n, int count)
void vlib_put_frame_to_node(vlib_main_t *vm, u32 to_node_index, vlib_frame_t *f)
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)
#define VNET_SW_INTERFACE_FLAG_ADMIN_UP
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)
void * vlib_packet_template_get_packet(vlib_main_t *vm, vlib_packet_template_t *t, u32 *bi_result)
vlib_frame_t * vlib_get_frame_to_node(vlib_main_t *vm, u32 to_node_index)
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.