Lines Matching refs:tlv

25 #include "lldp-tlv.h"
381 static int lldp_tlv_packet_read_u16_tlv(tlv_packet *tlv, uint16_t type, uint16_t *value) {
384 assert_return(tlv, -EINVAL);
386 r = lldp_tlv_packet_enter_container(tlv, type);
390 r = tlv_packet_read_u16(tlv, value);
391 r2 = lldp_tlv_packet_exit_container(tlv);
396 static int lldp_tlv_packet_read_string_tlv(tlv_packet *tlv, uint16_t type, char **data, uint16_t *length) {
400 assert_return(tlv, -EINVAL);
402 r = lldp_tlv_packet_enter_container(tlv, type);
406 r = tlv_packet_read_string(tlv, &s, length);
413 r2 = lldp_tlv_packet_exit_container(tlv);
418 int sd_lldp_packet_read_chassis_id(tlv_packet *tlv,
425 assert_return(tlv, -EINVAL);
427 r = lldp_tlv_packet_enter_container(tlv, LLDP_TYPE_CHASSIS_ID);
431 r = tlv_packet_read_u8(tlv, &subtype);
438 r = tlv_packet_read_bytes(tlv, data, length);
451 r2 = lldp_tlv_packet_exit_container(tlv);
456 int sd_lldp_packet_read_port_id(tlv_packet *tlv,
464 assert_return(tlv, -EINVAL);
466 r = lldp_tlv_packet_enter_container(tlv, LLDP_TYPE_PORT_ID);
470 r = tlv_packet_read_u8(tlv, &subtype);
480 r = tlv_packet_read_string(tlv, &s, length);
489 r = tlv_packet_read_bytes(tlv, data, length);
502 r2 = lldp_tlv_packet_exit_container(tlv);
507 int sd_lldp_packet_read_ttl(tlv_packet *tlv, uint16_t *ttl) {
508 return lldp_tlv_packet_read_u16_tlv(tlv, LLDP_TYPE_TTL, ttl);
511 int sd_lldp_packet_read_system_name(tlv_packet *tlv,
514 return lldp_tlv_packet_read_string_tlv(tlv, LLDP_TYPE_SYSTEM_NAME, data, length);
517 int sd_lldp_packet_read_system_description(tlv_packet *tlv,
520 return lldp_tlv_packet_read_string_tlv(tlv, LLDP_TYPE_SYSTEM_DESCRIPTION, data, length);
523 int sd_lldp_packet_read_port_description(tlv_packet *tlv,
526 return lldp_tlv_packet_read_string_tlv(tlv, LLDP_TYPE_PORT_DESCRIPTION, data, length);
529 int sd_lldp_packet_read_system_capability(tlv_packet *tlv, uint16_t *data) {
530 return lldp_tlv_packet_read_u16_tlv(tlv, LLDP_TYPE_SYSTEM_CAPABILITIES, data);
533 int sd_lldp_packet_read_port_vlan_id(tlv_packet *tlv, uint16_t *id) {
536 assert_return(tlv, -EINVAL);
538 r = lldp_tlv_packet_enter_container_oui(tlv, LLDP_OUI_802_1, LLDP_OUI_SUBTYPE_802_1_PORT_VLAN_ID);
542 r = tlv_packet_read_u16(tlv, id);
543 r2 = lldp_tlv_packet_exit_container(tlv);
548 int sd_lldp_packet_read_port_protocol_vlan_id(sd_lldp_packet *tlv, uint8_t *flags, uint16_t *id) {
551 assert_return(tlv, -EINVAL);
553 r = lldp_tlv_packet_enter_container_oui(tlv, LLDP_OUI_802_1, LLDP_OUI_SUBTYPE_802_1_PORT_PROTOCOL_VLAN_ID);
557 r = tlv_packet_read_u8(tlv, flags);
559 r = tlv_packet_read_u16(tlv, id);
561 r2 = lldp_tlv_packet_exit_container(tlv);
566 int sd_lldp_packet_read_vlan_name(tlv_packet *tlv, uint16_t *vlan_id, char **name, uint16_t *length) {
570 assert_return(tlv, -EINVAL);
572 r = lldp_tlv_packet_enter_container_oui(tlv, LLDP_OUI_802_1, LLDP_OUI_SUBTYPE_802_1_VLAN_NAME);
576 r = tlv_packet_read_u16(tlv, vlan_id);
578 r = tlv_packet_read_u8(tlv, &len);
580 r = tlv_packet_read_string(tlv, name, length);
585 r2 = lldp_tlv_packet_exit_container(tlv);
590 int sd_lldp_packet_read_management_vid(tlv_packet *tlv, uint16_t *id) {
593 assert_return(tlv, -EINVAL);
595 r = lldp_tlv_packet_enter_container_oui(tlv, LLDP_OUI_802_1, LLDP_OUI_SUBTYPE_802_1_MANAGEMENT_VID);
599 r = tlv_packet_read_u16(tlv, id);
600 r2 = lldp_tlv_packet_exit_container(tlv);
605 int sd_lldp_packet_read_link_aggregation(sd_lldp_packet *tlv, uint8_t *status, uint32_t *id) {
608 assert_return(tlv, -EINVAL);
610 r = lldp_tlv_packet_enter_container_oui(tlv, LLDP_OUI_802_1, LLDP_OUI_SUBTYPE_802_1_LINK_AGGREGATION);
614 r = tlv_packet_read_u8(tlv, status);
616 r = tlv_packet_read_u32(tlv, id);
618 r2 = lldp_tlv_packet_exit_container(tlv);
623 int sd_lldp_packet_get_destination_type(tlv_packet *tlv, int *dest) {
624 assert_return(tlv, -EINVAL);
628 if (!memcmp(&tlv->mac, LLDP_MAC_NEAREST_BRIDGE, ETH_ALEN))
630 else if (!memcmp(&tlv->mac, LLDP_MAC_NEAREST_NON_TPMR_BRIDGE, ETH_ALEN))
632 else if (!memcmp(&tlv->mac, LLDP_MAC_NEAREST_CUSTOMER_BRIDGE, ETH_ALEN))