33 cdp_tlv_t *t = (cdp_tlv_t *) *t0p;
35 t->t = htons(CDP_TLV_device_name);
36 t->l = htons(3 +
sizeof (*t));
44 cdp_tlv_t *t = (cdp_tlv_t *) *t0p;
46 t->t = htons(CDP_TLV_port_id);
54 cdp_tlv_t *t = (cdp_tlv_t *) *t0p;
56 t->t = htons(CDP_TLV_version);
57 t->l = htons(12 +
sizeof (*t));
64 cdp_tlv_t *t = (cdp_tlv_t *) *t0p;
66 t->t = htons(CDP_TLV_platform);
67 t->l = htons(2 +
sizeof (*t));
74 cdp_tlv_t *t = (cdp_tlv_t *) *t0p;
77 t->t = htons(CDP_TLV_capabilities);
78 t->l = htons(4 +
sizeof (*t));
80 capabilities = htonl (capabilities);
81 clib_memcpy (&t->v, &capabilities, sizeof (capabilities));
101 ethernet_llc_snap_and_cdp_header_t *h0;
107 int nbytes_to_checksum;
113 for (i = 0; i < count; i++) {
128 t0 = (
u8 *) &h0->cdp.data;
134 nbytes_to_checksum = t0 - (
u8 *)&h0->cdp;
136 h0->cdp.checksum = htons (checksum);
141 -
sizeof (cdp_hdr_t) ;
168 hdlc_and_cdp_header_t *h0;
174 int nbytes_to_checksum;
180 for (i = 0; i < count; i++) {
191 t0 = (
u8 *) &h0->cdp.data;
197 nbytes_to_checksum = t0 - (
u8 *)&h0->cdp;
199 h0->cdp.checksum = htons (checksum);
204 -
sizeof (cdp_hdr_t) ;
224 srp_and_cdp_header_t *h0;
230 int nbytes_to_checksum;
236 for (i = 0; i < count; i++) {
247 t0 = (
u8 *) &h0->cdp.data;
257 nbytes_to_checksum = t0 - (
u8 *)&h0->cdp;
259 h0->cdp.checksum = htons (checksum);
264 -
sizeof (cdp_hdr_t) ;
336 static u32 * delete_list = 0;
342 vec_add1 (n_list, n);
346 for (i = 0; i <
vec_len (n_list); i++) {
368 for (i = 0; i <
vec_len (delete_list); i++) {
373 _vec_len (delete_list) = 0;
375 _vec_len (n_list) = 0;
384 ethernet_llc_snap_and_cdp_header_t h;
386 memset (&h, 0,
sizeof (h));
389 h.ethernet.dst_address[0] = 0x01;
391 h.ethernet.dst_address[2] = 0x0C;
392 h.ethernet.dst_address[3] = 0xCC;
393 h.ethernet.dst_address[4] = 0xCC;
394 h.ethernet.dst_address[5] = 0xCC;
401 h.llc.dst_sap = h.llc.src_sap = 0xAA;
402 h.llc.control = 0x03;
407 h.snap.oui[2] = 0x0C;
408 h.snap.protocol = htons (0x2000);
427 hdlc_and_cdp_header_t h;
429 memset (&h, 0,
sizeof (h));
431 h.hdlc.address = 0x0f;
433 h.hdlc.protocol = htons (0x2000);
450 srp_and_cdp_header_t h;
452 memset (&h, 0,
sizeof (h));
455 h.ethernet.dst_address[0] = 0x01;
457 h.ethernet.dst_address[2] = 0x0C;
458 h.ethernet.dst_address[3] = 0xCC;
459 h.ethernet.dst_address[4] = 0xCC;
460 h.ethernet.dst_address[5] = 0xCC;
467 h.srp.mode = SRP_MODE_data;
472 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)
always_inline void srp_header_compute_parity(srp_header_t *h)
#define hash_unset(h, key)
void * vlib_packet_template_get_packet(vlib_main_t *vm, vlib_packet_template_t *t, u32 *bi_result)
static void delete_neighbor(cdp_main_t *cm, cdp_neighbor_t *n, int want_broadcast)
#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 void send_ethernet_hello(cdp_main_t *cm, cdp_neighbor_t *n, int count)
uword * neighbor_by_sw_if_index
#define pool_foreach(VAR, POOL, BODY)
#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)
always_inline void * vlib_frame_vector_args(vlib_frame_t *f)
u16 current_length
Nbytes between current data and the end of this buffer.
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)
always_inline vnet_hw_interface_t * vnet_get_sup_hw_interface(vnet_main_t *vnm, u32 sw_if_index)
static clib_error_t * cdp_periodic_init(vlib_main_t *vm)
#define VNET_SW_INTERFACE_FLAG_ADMIN_UP
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,...)
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)
always_inline vnet_sw_interface_t * vnet_get_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
static int pick_packet_template(cdp_main_t *cm, cdp_neighbor_t *n)
always_inline f64 vlib_time_now(vlib_main_t *vm)
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)
always_inline vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.