46 const u8 *chassis_id = a->
data;
67 u8 chid_subtype,
const u8 * portid,
68 u8 portid_len,
u8 portid_subtype,
u16 ttl)
70 const size_t data_size =
88 return tlv->head.byte1 >> 1;
94 tlv->head.byte1 = (tlv->head.byte1 & 1) + (code << 1);
100 return (((
u16) (tlv->head.byte1 & 1)) << 8) + tlv->head.byte2;
106 tlv->head.byte2 = length & ((1 << 8) - 1);
107 if (length > (1 << 8) - 1)
109 tlv->head.byte1 |= 1;
113 tlv->head.byte1 &= (1 << 8) - 2;
122 const lldp_tlv_t *tlv = pkt;
124 #define TLV_VIOLATES_PKT_BOUNDARY(pkt, tlv) \ 125 (((((u8 *)tlv) + sizeof (lldp_tlv_t)) > ((u8 *)pkt + vec_len (pkt))) || \ 126 ((((u8 *)tlv) + lldp_tlv_get_length (tlv)) > ((u8 *)pkt + vec_len (pkt)))) 132 return LLDP_ERROR_BAD_TLV;
141 return LLDP_ERROR_BAD_TLV;
144 u8 chid_subtype = ((lldp_chassis_id_tlv_t *) tlv)->subtype;
145 u8 *chid = ((lldp_chassis_id_tlv_t *) tlv)->id;
153 return LLDP_ERROR_BAD_TLV;
156 if (l < STRUCT_SIZE_OF (lldp_port_id_tlv_t, subtype) +
158 l > STRUCT_SIZE_OF (lldp_chassis_id_tlv_t, subtype) +
161 return LLDP_ERROR_BAD_TLV;
164 u8 portid_subtype = ((lldp_port_id_tlv_t *) tlv)->subtype;
165 u8 *portid = ((lldp_port_id_tlv_t *) tlv)->id;
173 return LLDP_ERROR_BAD_TLV;
176 if (l != STRUCT_SIZE_OF (lldp_ttl_tlv_t, ttl))
178 return LLDP_ERROR_BAD_TLV;
180 u16 ttl = ntohs (((lldp_ttl_tlv_t *) tlv)->ttl);
187 #define F(num, type, str) \ 188 case LLDP_TLV_NAME (type): \ 194 return LLDP_ERROR_BAD_TLV;
204 return LLDP_ERROR_BAD_TLV;
207 portid_len, portid_subtype, ttl);
208 return LLDP_ERROR_NONE;
234 memset (n, 0,
sizeof (*n));
264 return LLDP_ERROR_DISABLED;
#define LLDP_MAX_CHASS_ID_LEN
#define LLDP_MIN_PORT_ID_LEN
#define hash_set(h, key, value)
vnet_main_t * vnet_get_main(void)
static f64 vlib_time_now(vlib_main_t *vm)
static vnet_sw_interface_t * vnet_get_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
#define LLDP_MIN_CHASS_ID_LEN
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
#define vec_add(V, E, N)
Add N elements to end of vector V (no header, unspecified alignment)
#define VLIB_INIT_FUNCTION(x)
#define foreach_lldp_optional_tlv_type(F)
#define vlib_call_init_function(vm, x)
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
uword * intf_by_hw_if_index
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
static_always_inline uword vlib_get_thread_index(void)
LLDP protocol declarations.
#define clib_memcpy(a, b, c)
void vl_api_rpc_call_main_thread(void *fp, u8 *data, u32 data_length)
lldp_port_id_subtype_t port_id_subtype
#define LLDP_MAX_PORT_ID_LEN
LLDP global declarations.
#define STRUCT_SIZE_OF(t, f)
lldp_chassis_id_subtype_t chassis_id_subtype
static clib_error_t * lldp_template_init(vlib_main_t *vm)