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++)
200 t0 = (
u8 *) & h0->cdp.data;
206 nbytes_to_checksum = t0 - (
u8 *) & h0->cdp;
208 h0->cdp.checksum = htons (checksum);
213 -
sizeof (cdp_hdr_t);
233 srp_and_cdp_header_t *h0;
239 int nbytes_to_checksum;
245 for (i = 0; i <
count; i++)
256 t0 = (
u8 *) & h0->cdp.data;
266 nbytes_to_checksum = t0 - (
u8 *) & h0->cdp;
268 h0->cdp.checksum = htons (checksum);
273 -
sizeof (cdp_hdr_t);
350 static u32 *delete_list = 0;
357 vec_add1 (n_list, n);
362 for (i = 0; i <
vec_len (n_list); i++)
385 for (i = 0; i <
vec_len (delete_list); i++)
391 _vec_len (delete_list) = 0;
393 _vec_len (n_list) = 0;
403 ethernet_llc_snap_and_cdp_header_t
h;
405 memset (&h, 0,
sizeof (h));
408 h.ethernet.dst_address[0] = 0x01;
410 h.ethernet.dst_address[2] = 0x0C;
411 h.ethernet.dst_address[3] = 0xCC;
412 h.ethernet.dst_address[4] = 0xCC;
413 h.ethernet.dst_address[5] = 0xCC;
420 h.llc.dst_sap = h.llc.src_sap = 0xAA;
421 h.llc.control = 0x03;
426 h.snap.oui[2] = 0x0C;
427 h.snap.protocol = htons (0x2000);
445 hdlc_and_cdp_header_t
h;
447 memset (&h, 0,
sizeof (h));
449 h.hdlc.address = 0x0f;
451 h.hdlc.protocol = htons (0x2000);
467 srp_and_cdp_header_t
h;
469 memset (&h, 0,
sizeof (h));
472 h.ethernet.dst_address[0] = 0x01;
474 h.ethernet.dst_address[2] = 0x0C;
475 h.ethernet.dst_address[3] = 0xCC;
476 h.ethernet.dst_address[4] = 0xCC;
477 h.ethernet.dst_address[5] = 0xCC;
484 h.srp.mode = SRP_MODE_data;
489 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
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
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)
#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)
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.