lldpd_alloc_mgmt:
  265|    679|{
  266|    679|	struct lldpd_mgmt *mgmt;
  267|       |
  268|    679|	log_debug("alloc", "allocate a new management address (family: %d)", family);
  269|       |
  270|    679|	if (family <= LLDPD_AF_UNSPEC || family >= LLDPD_AF_LAST) {
  ------------------
  |  Branch (270:6): [True: 0, False: 679]
  |  Branch (270:35): [True: 0, False: 679]
  ------------------
  271|      0|		errno = EAFNOSUPPORT;
  272|      0|		return NULL;
  273|      0|	}
  274|    679|	if (addrsize > LLDPD_MGMT_MAXADDRSIZE) {
  ------------------
  |  |  157|    679|#define LLDPD_MGMT_MAXADDRSIZE 16 /* sizeof(struct in6_addr) */
  ------------------
  |  Branch (274:6): [True: 1, False: 678]
  ------------------
  275|      1|		errno = EOVERFLOW;
  276|      1|		return NULL;
  277|      1|	}
  278|    678|	mgmt = calloc(1, sizeof(struct lldpd_mgmt));
  279|    678|	if (mgmt == NULL) {
  ------------------
  |  Branch (279:6): [True: 0, False: 678]
  ------------------
  280|      0|		errno = ENOMEM;
  281|      0|		return NULL;
  282|      0|	}
  283|    678|	mgmt->m_family = family;
  284|    678|	memcpy(&mgmt->m_addr, addrptr, addrsize);
  285|    678|	mgmt->m_addrsize = addrsize;
  286|    678|	mgmt->m_iface = iface;
  287|    678|	return mgmt;
  288|    678|}

lldp_decode:
  572|  1.15k|{
  573|  1.15k|	struct lldpd_chassis *chassis;
  574|  1.15k|	struct lldpd_port *port;
  575|  1.15k|	char lldpaddr[ETHER_ADDR_LEN];
  576|  1.15k|	const char dot1[] = LLDP_TLV_ORG_DOT1;
  ------------------
  |  |   45|  1.15k|  {                       \
  |  |   46|  1.15k|    0x00, 0x80, 0xc2      \
  |  |   47|  1.15k|  }
  ------------------
  577|  1.15k|	const char dot3[] = LLDP_TLV_ORG_DOT3;
  ------------------
  |  |   49|  1.15k|  {                       \
  |  |   50|  1.15k|    0x00, 0x12, 0x0f      \
  |  |   51|  1.15k|  }
  ------------------
  578|  1.15k|	const char med[] = LLDP_TLV_ORG_MED;
  ------------------
  |  |   53|  1.15k|  {                      \
  |  |   54|  1.15k|    0x00, 0x12, 0xbb     \
  |  |   55|  1.15k|  }
  ------------------
  579|  1.15k|	const char dcbx[] = LLDP_TLV_ORG_DCBX;
  ------------------
  |  |   57|  1.15k|  {                       \
  |  |   58|  1.15k|    0x00, 0x1b, 0x21      \
  |  |   59|  1.15k|  }
  ------------------
  580|  1.15k|	unsigned char orgid[3];
  581|  1.15k|	int length, gotend = 0, ttl_received = 0;
  582|  1.15k|	int tlv_size, tlv_type, tlv_subtype, tlv_count = 0;
  583|  1.15k|	u_int8_t *pos, *tlv;
  584|  1.15k|	char *b;
  585|  1.15k|#ifdef ENABLE_DOT1
  586|  1.15k|	struct lldpd_vlan *vlan = NULL;
  587|  1.15k|	int vlan_len;
  588|  1.15k|	struct lldpd_ppvid *ppvid;
  589|  1.15k|	struct lldpd_pi *pi = NULL;
  590|  1.15k|#endif
  591|  1.15k|	struct lldpd_mgmt *mgmt;
  592|  1.15k|	int af;
  593|  1.15k|	u_int8_t addr_str_length, addr_str_buffer[32] = { 0 };
  594|  1.15k|	u_int8_t addr_family, addr_length, *addr_ptr, iface_subtype;
  595|  1.15k|	u_int32_t iface_number, iface;
  596|  1.15k|	int unrecognized;
  597|  1.15k|#ifdef ENABLE_CUSTOM
  598|  1.15k|	struct lldpd_custom *custom = NULL;
  599|  1.15k|#endif
  600|       |
  601|  1.15k|	log_debug("lldp", "receive LLDP PDU on %s", hardware->h_ifname);
  602|       |
  603|  1.15k|	if ((chassis = calloc(1, sizeof(struct lldpd_chassis))) == NULL) {
  ------------------
  |  Branch (603:6): [True: 0, False: 1.15k]
  ------------------
  604|      0|		log_warn("lldp", "failed to allocate remote chassis");
  605|      0|		return -1;
  606|      0|	}
  607|  1.15k|	TAILQ_INIT(&chassis->c_mgmt);
  ------------------
  |  Branch (607:2): [Folded, False: 1.15k]
  ------------------
  608|  1.15k|	if ((port = calloc(1, sizeof(struct lldpd_port))) == NULL) {
  ------------------
  |  Branch (608:6): [True: 0, False: 1.15k]
  ------------------
  609|      0|		log_warn("lldp", "failed to allocate remote port");
  610|      0|		free(chassis);
  611|      0|		return -1;
  612|      0|	}
  613|  1.15k|#ifdef ENABLE_DOT1
  614|  1.15k|	TAILQ_INIT(&port->p_vlans);
  ------------------
  |  Branch (614:2): [Folded, False: 1.15k]
  ------------------
  615|  1.15k|	TAILQ_INIT(&port->p_ppvids);
  ------------------
  |  Branch (615:2): [Folded, False: 1.15k]
  ------------------
  616|  1.15k|	TAILQ_INIT(&port->p_pids);
  ------------------
  |  Branch (616:2): [Folded, False: 1.15k]
  ------------------
  617|  1.15k|#endif
  618|  1.15k|#ifdef ENABLE_CUSTOM
  619|  1.15k|	TAILQ_INIT(&port->p_custom_list);
  ------------------
  |  Branch (619:2): [Folded, False: 1.15k]
  ------------------
  620|  1.15k|#endif
  621|       |
  622|  1.15k|	length = s;
  623|  1.15k|	pos = (u_int8_t *)frame;
  624|       |
  625|  1.15k|	if (length < 2 * ETHER_ADDR_LEN + sizeof(u_int16_t)) {
  ------------------
  |  Branch (625:6): [True: 7, False: 1.15k]
  ------------------
  626|      7|		log_warnx("lldp", "too short frame received on %s", hardware->h_ifname);
  627|      7|		goto malformed;
  628|      7|	}
  629|  1.15k|	PEEK_BYTES(lldpaddr, ETHER_ADDR_LEN);
  ------------------
  |  |   66|  1.15k|  do {                           \
  |  |   67|  1.15k|    memcpy(value, pos, bytes);   \
  |  |   68|  1.15k|    length -= (bytes);           \
  |  |   69|  1.15k|    pos += (bytes);              \
  |  |   70|  1.15k|  } while (0)
  |  |  ------------------
  |  |  |  Branch (70:12): [Folded, False: 1.15k]
  |  |  ------------------
  ------------------
  630|  1.15k|	if (memcmp(lldpaddr, (const char[])LLDP_ADDR_NEAREST_BRIDGE, ETHER_ADDR_LEN) &&
  ------------------
  |  |   22|  1.15k|  {                                    \
  |  |   23|  1.15k|    0x01, 0x80, 0xc2, 0x00, 0x00, 0x0e \
  |  |   24|  1.15k|  }
  ------------------
  |  Branch (630:6): [True: 700, False: 452]
  ------------------
  631|    700|	    memcmp(lldpaddr, (const char[])LLDP_ADDR_NEAREST_NONTPMR_BRIDGE,
  ------------------
  |  |   26|    700|  {                                      \
  |  |   27|    700|    0x01, 0x80, 0xc2, 0x00, 0x00, 0x03   \
  |  |   28|    700|  }
  ------------------
  |  Branch (631:6): [True: 537, False: 163]
  ------------------
  632|    700|		ETHER_ADDR_LEN) &&
  633|    537|	    memcmp(lldpaddr, (const char[])LLDP_ADDR_NEAREST_CUSTOMER_BRIDGE,
  ------------------
  |  |   30|    537|  {                                       \
  |  |   31|    537|    0x01, 0x80, 0xc2, 0x00, 0x00, 0x00    \
  |  |   32|    537|  }
  ------------------
  |  Branch (633:6): [True: 47, False: 490]
  ------------------
  634|    537|		ETHER_ADDR_LEN)) {
  635|     47|		log_info("lldp",
  636|     47|		    "frame not targeted at LLDP multicast address received on %s",
  637|     47|		    hardware->h_ifname);
  638|     47|		goto malformed;
  639|     47|	}
  640|  1.10k|	PEEK_DISCARD(ETHER_ADDR_LEN); /* Skip source address */
  ------------------
  |  |   72|  1.10k|  do {                      \
  |  |   73|  1.10k|    length -= (bytes);      \
  |  |   74|  1.10k|    pos += (bytes);         \
  |  |   75|  1.10k|  } while (0)
  |  |  ------------------
  |  |  |  Branch (75:12): [Folded, False: 1.10k]
  |  |  ------------------
  ------------------
  641|  1.10k|	if (PEEK_UINT16 != ETH_P_LLDP) {
  ------------------
  |  |   63|  1.10k|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  ------------------
  |  |  |  |   60|  1.10k|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|  1.10k|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   63|  1.10k|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
              	if (PEEK_UINT16 != ETH_P_LLDP) {
  ------------------
  |  |  269|  1.10k|#  define ETH_P_LLDP 0x88cc
  ------------------
  |  Branch (641:6): [True: 28, False: 1.07k]
  ------------------
  642|     28|		log_info("lldp", "non LLDP frame received on %s", hardware->h_ifname);
  643|     28|		goto malformed;
  644|     28|	}
  645|       |
  646|  18.7k|	while (length && (!gotend)) {
  ------------------
  |  Branch (646:9): [True: 17.9k, False: 742]
  |  Branch (646:19): [True: 17.9k, False: 34]
  ------------------
  647|  17.9k|		if (length < 2) {
  ------------------
  |  Branch (647:7): [True: 75, False: 17.8k]
  ------------------
  648|     75|			log_warnx("lldp", "tlv header too short received on %s",
  649|     75|			    hardware->h_ifname);
  650|     75|			goto malformed;
  651|     75|		}
  652|  17.8k|		tlv_size = PEEK_UINT16;
  ------------------
  |  |   63|  17.8k|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  ------------------
  |  |  |  |   60|  17.8k|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|  17.8k|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   63|  17.8k|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  653|  17.8k|		tlv_type = tlv_size >> 9;
  654|  17.8k|		tlv_size = tlv_size & 0x1ff;
  655|  17.8k|		(void)PEEK_SAVE(tlv);
  ------------------
  |  |   81|  17.8k|#define PEEK_SAVE POKE_SAVE
  |  |  ------------------
  |  |  |  |   46|  17.8k|#define POKE_SAVE(where) (where = pos, 1)
  |  |  ------------------
  ------------------
  656|  17.8k|		if (length < tlv_size) {
  ------------------
  |  Branch (656:7): [True: 46, False: 17.8k]
  ------------------
  657|     46|			log_warnx("lldp", "frame too short for tlv received on %s",
  658|     46|			    hardware->h_ifname);
  659|     46|			goto malformed;
  660|     46|		}
  661|       |		/* Check order for mandatory TLVs */
  662|  17.8k|		tlv_count++;
  663|  17.8k|		switch (tlv_type) {
  ------------------
  |  Branch (663:11): [True: 878, False: 16.9k]
  ------------------
  664|    334|		case LLDP_TLV_CHASSIS_ID:
  ------------------
  |  |   35|    334|#define LLDP_TLV_CHASSIS_ID 1
  ------------------
  |  Branch (664:3): [True: 334, False: 17.4k]
  ------------------
  665|    334|			if (tlv_count != 1) {
  ------------------
  |  Branch (665:8): [True: 15, False: 319]
  ------------------
  666|     15|				log_warnx("lldp",
  667|     15|				    "Chassis ID TLV should be first on %s, but it is on position %d",
  668|     15|				    hardware->h_ifname, tlv_count);
  669|     15|				goto malformed;
  670|     15|			}
  671|    319|			break;
  672|    319|		case LLDP_TLV_PORT_ID:
  ------------------
  |  |   36|    277|#define LLDP_TLV_PORT_ID 2
  ------------------
  |  Branch (672:3): [True: 277, False: 17.5k]
  ------------------
  673|    277|			if (tlv_count != 2) {
  ------------------
  |  Branch (673:8): [True: 10, False: 267]
  ------------------
  674|     10|				log_warnx("lldp",
  675|     10|				    "Port ID TLV should be second on %s, but it is on position %d",
  676|     10|				    hardware->h_ifname, tlv_count);
  677|     10|				goto malformed;
  678|     10|			}
  679|    267|			break;
  680|    267|		case LLDP_TLV_TTL:
  ------------------
  |  |   37|    267|#define LLDP_TLV_TTL 3
  ------------------
  |  Branch (680:3): [True: 267, False: 17.5k]
  ------------------
  681|    267|			if (tlv_count != 3) {
  ------------------
  |  Branch (681:8): [True: 11, False: 256]
  ------------------
  682|     11|				log_warnx("lldp",
  683|     11|				    "TTL TLV should be third on %s, but it is on position %d",
  684|     11|				    hardware->h_ifname, tlv_count);
  685|     11|				goto malformed;
  686|     11|			}
  687|    256|			break;
  688|  17.8k|		}
  689|       |
  690|  17.7k|		switch (tlv_type) {
  691|    145|		case LLDP_TLV_END:
  ------------------
  |  |   34|    145|#define LLDP_TLV_END 0
  ------------------
  |  Branch (691:3): [True: 145, False: 17.6k]
  ------------------
  692|    145|			if (tlv_size != 0) {
  ------------------
  |  Branch (692:8): [True: 11, False: 134]
  ------------------
  693|     11|				log_warnx("lldp",
  694|     11|				    "lldp end received with size not null on %s",
  695|     11|				    hardware->h_ifname);
  696|     11|				goto malformed;
  697|     11|			}
  698|    134|			if (length)
  ------------------
  |  Branch (698:8): [True: 34, False: 100]
  ------------------
  699|     34|				log_debug("lldp", "extra data after lldp end on %s",
  700|     34|				    hardware->h_ifname);
  701|    134|			gotend = 1;
  702|    134|			break;
  703|    319|		case LLDP_TLV_CHASSIS_ID:
  ------------------
  |  |   35|    319|#define LLDP_TLV_CHASSIS_ID 1
  ------------------
  |  Branch (703:3): [True: 319, False: 17.4k]
  ------------------
  704|    586|		case LLDP_TLV_PORT_ID:
  ------------------
  |  |   36|    586|#define LLDP_TLV_PORT_ID 2
  ------------------
  |  Branch (704:3): [True: 267, False: 17.5k]
  ------------------
  705|    586|			CHECK_TLV_SIZE(2, "Port/Chassis Id");
  ------------------
  |  |  555|    586|  do {                                                                             \
  |  |  556|    586|    if (tlv_size < (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (556:9): [True: 7, False: 579]
  |  |  ------------------
  |  |  557|      7|      log_warnx("lldp", name " TLV too short received on %s", hardware->h_ifname); \
  |  |  558|      7|      goto malformed;                                                              \
  |  |  559|      7|    }                                                                              \
  |  |  560|    586|  } while (0)
  |  |  ------------------
  |  |  |  Branch (560:12): [Folded, False: 579]
  |  |  ------------------
  ------------------
  706|    579|			CHECK_TLV_MAX_SIZE(256, "Port/Chassis Id");
  ------------------
  |  |  562|    579|  do {                                                                             \
  |  |  563|    579|    if (tlv_size > (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (563:9): [True: 1, False: 578]
  |  |  ------------------
  |  |  564|      1|      log_warnx("lldp", name " TLV too large received on %s", hardware->h_ifname); \
  |  |  565|      1|      goto malformed;                                                              \
  |  |  566|      1|    }                                                                              \
  |  |  567|    579|  } while (0)
  |  |  ------------------
  |  |  |  Branch (567:12): [Folded, False: 578]
  |  |  ------------------
  ------------------
  707|    578|			tlv_subtype = PEEK_UINT8;
  ------------------
  |  |   62|    578|#define PEEK_UINT8 PEEK(types.f_uint8, )
  |  |  ------------------
  |  |  |  |   60|    578|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    578|      func(type))
  |  |  ------------------
  ------------------
  708|    578|			if ((tlv_subtype == 0) || (tlv_subtype > 7)) {
  ------------------
  |  Branch (708:8): [True: 2, False: 576]
  |  Branch (708:30): [True: 17, False: 559]
  ------------------
  709|     19|				log_warnx("lldp",
  710|     19|				    "unknown subtype for tlv id received on %s",
  711|     19|				    hardware->h_ifname);
  712|     19|				goto malformed;
  713|     19|			}
  714|    559|			if ((b = (char *)calloc(1, tlv_size - 1)) == NULL) {
  ------------------
  |  Branch (714:8): [True: 0, False: 559]
  ------------------
  715|      0|				log_warn("lldp",
  716|      0|				    "unable to allocate memory for id tlv "
  717|      0|				    "received on %s",
  718|      0|				    hardware->h_ifname);
  719|      0|				goto malformed;
  720|      0|			}
  721|    559|			PEEK_BYTES(b, tlv_size - 1);
  ------------------
  |  |   66|    559|  do {                           \
  |  |   67|    559|    memcpy(value, pos, bytes);   \
  |  |   68|    559|    length -= (bytes);           \
  |  |   69|    559|    pos += (bytes);              \
  |  |   70|    559|  } while (0)
  |  |  ------------------
  |  |  |  Branch (70:12): [Folded, False: 559]
  |  |  ------------------
  ------------------
  722|    559|			if (tlv_type == LLDP_TLV_PORT_ID) {
  ------------------
  |  |   36|    559|#define LLDP_TLV_PORT_ID 2
  ------------------
  |  Branch (722:8): [True: 262, False: 297]
  ------------------
  723|    262|				if (port->p_id != NULL) {
  ------------------
  |  Branch (723:9): [True: 0, False: 262]
  ------------------
  724|      0|					log_warnx("lldp",
  725|      0|					    "Port ID TLV received twice on %s",
  726|      0|					    hardware->h_ifname);
  727|      0|					free(b);
  728|      0|					goto malformed;
  729|      0|				}
  730|    262|				port->p_id_subtype = tlv_subtype;
  731|    262|				port->p_id = b;
  732|    262|				port->p_id_len = tlv_size - 1;
  733|    297|			} else {
  734|    297|				if (chassis->c_id != NULL) {
  ------------------
  |  Branch (734:9): [True: 0, False: 297]
  ------------------
  735|      0|					log_warnx("lldp",
  736|      0|					    "Chassis ID TLV received twice on %s",
  737|      0|					    hardware->h_ifname);
  738|      0|					free(b);
  739|      0|					goto malformed;
  740|      0|				}
  741|    297|				chassis->c_id_subtype = tlv_subtype;
  742|    297|				chassis->c_id = b;
  743|    297|				chassis->c_id_len = tlv_size - 1;
  744|    297|			}
  745|    559|			break;
  746|    559|		case LLDP_TLV_TTL:
  ------------------
  |  |   37|    256|#define LLDP_TLV_TTL 3
  ------------------
  |  Branch (746:3): [True: 256, False: 17.5k]
  ------------------
  747|    256|			if (ttl_received) {
  ------------------
  |  Branch (747:8): [True: 0, False: 256]
  ------------------
  748|      0|				log_warnx("lldp", "TTL TLV received twice on %s",
  749|      0|				    hardware->h_ifname);
  750|      0|				goto malformed;
  751|      0|			}
  752|    256|			CHECK_TLV_SIZE(2, "TTL");
  ------------------
  |  |  555|    256|  do {                                                                             \
  |  |  556|    256|    if (tlv_size < (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (556:9): [True: 2, False: 254]
  |  |  ------------------
  |  |  557|      2|      log_warnx("lldp", name " TLV too short received on %s", hardware->h_ifname); \
  |  |  558|      2|      goto malformed;                                                              \
  |  |  559|      2|    }                                                                              \
  |  |  560|    256|  } while (0)
  |  |  ------------------
  |  |  |  Branch (560:12): [Folded, False: 254]
  |  |  ------------------
  ------------------
  753|    254|			port->p_ttl = PEEK_UINT16;
  ------------------
  |  |   63|    254|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  ------------------
  |  |  |  |   60|    254|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    254|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   63|    254|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  754|    254|			ttl_received = 1;
  755|    254|			break;
  756|    481|		case LLDP_TLV_PORT_DESCR:
  ------------------
  |  |   38|    481|#define LLDP_TLV_PORT_DESCR 4
  ------------------
  |  Branch (756:3): [True: 481, False: 17.3k]
  ------------------
  757|  1.78k|		case LLDP_TLV_SYSTEM_NAME:
  ------------------
  |  |   39|  1.78k|#define LLDP_TLV_SYSTEM_NAME 5
  ------------------
  |  Branch (757:3): [True: 1.30k, False: 16.4k]
  ------------------
  758|  5.02k|		case LLDP_TLV_SYSTEM_DESCR:
  ------------------
  |  |   40|  5.02k|#define LLDP_TLV_SYSTEM_DESCR 6
  ------------------
  |  Branch (758:3): [True: 3.23k, False: 14.5k]
  ------------------
  759|  5.02k|			if (tlv_size < 1) {
  ------------------
  |  Branch (759:8): [True: 4.37k, False: 651]
  ------------------
  760|  4.37k|				log_debug("lldp", "empty tlv received on %s",
  761|  4.37k|				    hardware->h_ifname);
  762|  4.37k|				break;
  763|  4.37k|			}
  764|    651|			if ((b = (char *)calloc(1, tlv_size + 1)) == NULL) {
  ------------------
  |  Branch (764:8): [True: 0, False: 651]
  ------------------
  765|      0|				log_warn("lldp",
  766|      0|				    "unable to allocate memory for string tlv "
  767|      0|				    "received on %s",
  768|      0|				    hardware->h_ifname);
  769|      0|				goto malformed;
  770|      0|			}
  771|    651|			PEEK_BYTES(b, tlv_size);
  ------------------
  |  |   66|    651|  do {                           \
  |  |   67|    651|    memcpy(value, pos, bytes);   \
  |  |   68|    651|    length -= (bytes);           \
  |  |   69|    651|    pos += (bytes);              \
  |  |   70|    651|  } while (0)
  |  |  ------------------
  |  |  |  Branch (70:12): [Folded, False: 651]
  |  |  ------------------
  ------------------
  772|    651|			switch (tlv_type) {
  773|    218|			case LLDP_TLV_PORT_DESCR:
  ------------------
  |  |   38|    218|#define LLDP_TLV_PORT_DESCR 4
  ------------------
  |  Branch (773:4): [True: 218, False: 433]
  ------------------
  774|    218|				free(port->p_descr);
  775|    218|				port->p_descr = b;
  776|    218|				break;
  777|    214|			case LLDP_TLV_SYSTEM_NAME:
  ------------------
  |  |   39|    214|#define LLDP_TLV_SYSTEM_NAME 5
  ------------------
  |  Branch (777:4): [True: 214, False: 437]
  ------------------
  778|    214|				free(chassis->c_name);
  779|    214|				chassis->c_name = b;
  780|    214|				break;
  781|    219|			case LLDP_TLV_SYSTEM_DESCR:
  ------------------
  |  |   40|    219|#define LLDP_TLV_SYSTEM_DESCR 6
  ------------------
  |  Branch (781:4): [True: 219, False: 432]
  ------------------
  782|    219|				free(chassis->c_descr);
  783|    219|				chassis->c_descr = b;
  784|    219|				break;
  785|      0|			default:
  ------------------
  |  Branch (785:4): [True: 0, False: 651]
  ------------------
  786|       |				/* unreachable */
  787|      0|				free(b);
  788|      0|				break;
  789|    651|			}
  790|    651|			break;
  791|    651|		case LLDP_TLV_SYSTEM_CAP:
  ------------------
  |  |   41|    402|#define LLDP_TLV_SYSTEM_CAP 7
  ------------------
  |  Branch (791:3): [True: 402, False: 17.3k]
  ------------------
  792|    402|			CHECK_TLV_SIZE(4, "System capabilities");
  ------------------
  |  |  555|    402|  do {                                                                             \
  |  |  556|    402|    if (tlv_size < (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (556:9): [True: 12, False: 390]
  |  |  ------------------
  |  |  557|     12|      log_warnx("lldp", name " TLV too short received on %s", hardware->h_ifname); \
  |  |  558|     12|      goto malformed;                                                              \
  |  |  559|     12|    }                                                                              \
  |  |  560|    402|  } while (0)
  |  |  ------------------
  |  |  |  Branch (560:12): [Folded, False: 390]
  |  |  ------------------
  ------------------
  793|    390|			chassis->c_cap_available = PEEK_UINT16;
  ------------------
  |  |   63|    390|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  ------------------
  |  |  |  |   60|    390|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    390|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   63|    390|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  794|    390|			chassis->c_cap_enabled = PEEK_UINT16;
  ------------------
  |  |   63|    390|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  ------------------
  |  |  |  |   60|    390|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    390|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   63|    390|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  795|    390|			break;
  796|    956|		case LLDP_TLV_MGMT_ADDR:
  ------------------
  |  |   42|    956|#define LLDP_TLV_MGMT_ADDR 8
  ------------------
  |  Branch (796:3): [True: 956, False: 16.8k]
  ------------------
  797|    956|			CHECK_TLV_SIZE(1, "Management address");
  ------------------
  |  |  555|    956|  do {                                                                             \
  |  |  556|    956|    if (tlv_size < (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (556:9): [True: 2, False: 954]
  |  |  ------------------
  |  |  557|      2|      log_warnx("lldp", name " TLV too short received on %s", hardware->h_ifname); \
  |  |  558|      2|      goto malformed;                                                              \
  |  |  559|      2|    }                                                                              \
  |  |  560|    956|  } while (0)
  |  |  ------------------
  |  |  |  Branch (560:12): [Folded, False: 954]
  |  |  ------------------
  ------------------
  798|    954|			addr_str_length = PEEK_UINT8;
  ------------------
  |  |   62|    954|#define PEEK_UINT8 PEEK(types.f_uint8, )
  |  |  ------------------
  |  |  |  |   60|    954|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    954|      func(type))
  |  |  ------------------
  ------------------
  799|    954|			if (addr_str_length < 1 ||
  ------------------
  |  Branch (799:8): [True: 11, False: 943]
  ------------------
  800|    943|			    addr_str_length > sizeof(addr_str_buffer)) {
  ------------------
  |  Branch (800:8): [True: 7, False: 936]
  ------------------
  801|     18|				log_warnx("lldp",
  802|     18|				    "invalid management address length on %s",
  803|     18|				    hardware->h_ifname);
  804|     18|				goto malformed;
  805|     18|			}
  806|    936|			CHECK_TLV_SIZE(1 + addr_str_length, "Management address");
  ------------------
  |  |  555|    936|  do {                                                                             \
  |  |  556|    936|    if (tlv_size < (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (556:9): [True: 7, False: 929]
  |  |  ------------------
  |  |  557|      7|      log_warnx("lldp", name " TLV too short received on %s", hardware->h_ifname); \
  |  |  558|      7|      goto malformed;                                                              \
  |  |  559|      7|    }                                                                              \
  |  |  560|    936|  } while (0)
  |  |  ------------------
  |  |  |  Branch (560:12): [Folded, False: 929]
  |  |  ------------------
  ------------------
  807|    929|			PEEK_BYTES(addr_str_buffer, addr_str_length);
  ------------------
  |  |   66|    929|  do {                           \
  |  |   67|    929|    memcpy(value, pos, bytes);   \
  |  |   68|    929|    length -= (bytes);           \
  |  |   69|    929|    pos += (bytes);              \
  |  |   70|    929|  } while (0)
  |  |  ------------------
  |  |  |  Branch (70:12): [Folded, False: 929]
  |  |  ------------------
  ------------------
  808|    929|			addr_length = addr_str_length - 1;
  809|    929|			addr_family = addr_str_buffer[0];
  810|    929|			addr_ptr = &addr_str_buffer[1];
  811|    929|			CHECK_TLV_SIZE(1 + addr_str_length + 5, "Management address");
  ------------------
  |  |  555|    929|  do {                                                                             \
  |  |  556|    929|    if (tlv_size < (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (556:9): [True: 5, False: 924]
  |  |  ------------------
  |  |  557|      5|      log_warnx("lldp", name " TLV too short received on %s", hardware->h_ifname); \
  |  |  558|      5|      goto malformed;                                                              \
  |  |  559|      5|    }                                                                              \
  |  |  560|    929|  } while (0)
  |  |  ------------------
  |  |  |  Branch (560:12): [Folded, False: 924]
  |  |  ------------------
  ------------------
  812|    924|			iface_subtype = PEEK_UINT8;
  ------------------
  |  |   62|    924|#define PEEK_UINT8 PEEK(types.f_uint8, )
  |  |  ------------------
  |  |  |  |   60|    924|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    924|      func(type))
  |  |  ------------------
  ------------------
  813|    924|			iface_number = PEEK_UINT32;
  ------------------
  |  |   64|    924|#define PEEK_UINT32 PEEK(types.f_uint32, ntohl)
  |  |  ------------------
  |  |  |  |   60|    924|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    924|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|    924|#define PEEK_UINT32 PEEK(types.f_uint32, ntohl)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  814|       |
  815|    924|			af = lldpd_af_from_lldp_proto(addr_family);
  816|    924|			if (af == LLDPD_AF_UNSPEC) break;
  ------------------
  |  Branch (816:8): [True: 245, False: 679]
  ------------------
  817|    679|			if (iface_subtype == LLDP_MGMT_IFACE_IFINDEX)
  ------------------
  |  |  277|    679|#define LLDP_MGMT_IFACE_IFINDEX 2
  ------------------
  |  Branch (817:8): [True: 459, False: 220]
  ------------------
  818|    459|				iface = iface_number;
  819|    220|			else
  820|    220|				iface = 0;
  821|    679|			mgmt = lldpd_alloc_mgmt(af, addr_ptr, addr_length, iface);
  822|    679|			if (mgmt == NULL) {
  ------------------
  |  Branch (822:8): [True: 1, False: 678]
  ------------------
  823|      1|				if (errno == ENOMEM)
  ------------------
  |  Branch (823:9): [True: 0, False: 1]
  ------------------
  824|      0|					log_warn("lldp",
  825|      0|					    "unable to allocate memory "
  826|      0|					    "for management address");
  827|      1|				else
  828|      1|					log_warn("lldp",
  829|      1|					    "too large management address "
  830|      1|					    "received on %s",
  831|      1|					    hardware->h_ifname);
  832|      1|				goto malformed;
  833|      1|			}
  834|    679|			TAILQ_INSERT_TAIL(&chassis->c_mgmt, mgmt, m_entries);
  ------------------
  |  Branch (834:4): [Folded, False: 678]
  ------------------
  835|    678|			break;
  836|  9.86k|		case LLDP_TLV_ORG:
  ------------------
  |  |   26|  9.86k|#define LLDP_TLV_ORG 127
  ------------------
  |  Branch (836:3): [True: 9.86k, False: 7.92k]
  ------------------
  837|  9.86k|			CHECK_TLV_SIZE(1 + (int)sizeof(orgid), "Organisational");
  ------------------
  |  |  555|  9.86k|  do {                                                                             \
  |  |  556|  9.86k|    if (tlv_size < (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (556:9): [True: 15, False: 9.84k]
  |  |  ------------------
  |  |  557|     15|      log_warnx("lldp", name " TLV too short received on %s", hardware->h_ifname); \
  |  |  558|     15|      goto malformed;                                                              \
  |  |  559|     15|    }                                                                              \
  |  |  560|  9.86k|  } while (0)
  |  |  ------------------
  |  |  |  Branch (560:12): [Folded, False: 9.84k]
  |  |  ------------------
  ------------------
  838|  9.84k|			PEEK_BYTES(orgid, sizeof(orgid));
  ------------------
  |  |   66|  9.84k|  do {                           \
  |  |   67|  9.84k|    memcpy(value, pos, bytes);   \
  |  |   68|  9.84k|    length -= (bytes);           \
  |  |   69|  9.84k|    pos += (bytes);              \
  |  |   70|  9.84k|  } while (0)
  |  |  ------------------
  |  |  |  Branch (70:12): [Folded, False: 9.84k]
  |  |  ------------------
  ------------------
  839|  9.84k|			unrecognized = 0;
  840|  9.84k|			tlv_subtype = PEEK_UINT8;
  ------------------
  |  |   62|  9.84k|#define PEEK_UINT8 PEEK(types.f_uint8, )
  |  |  ------------------
  |  |  |  |   60|  9.84k|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|  9.84k|      func(type))
  |  |  ------------------
  ------------------
  841|  9.84k|			if (memcmp(dot1, orgid, sizeof(orgid)) == 0) {
  ------------------
  |  Branch (841:8): [True: 1.83k, False: 8.01k]
  ------------------
  842|       |#ifndef ENABLE_DOT1
  843|       |				unrecognized = 1;
  844|       |#else
  845|       |				/* Dot1 */
  846|  1.83k|				switch (tlv_subtype) {
  847|    424|				case LLDP_TLV_DOT1_VLANNAME:
  ------------------
  |  |   63|    424|#define LLDP_TLV_DOT1_VLANNAME 3
  ------------------
  |  Branch (847:5): [True: 424, False: 1.40k]
  ------------------
  848|    424|					CHECK_TLV_SIZE(7, "VLAN");
  ------------------
  |  |  555|    424|  do {                                                                             \
  |  |  556|    424|    if (tlv_size < (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (556:9): [True: 3, False: 421]
  |  |  ------------------
  |  |  557|      3|      log_warnx("lldp", name " TLV too short received on %s", hardware->h_ifname); \
  |  |  558|      3|      goto malformed;                                                              \
  |  |  559|      3|    }                                                                              \
  |  |  560|    424|  } while (0)
  |  |  ------------------
  |  |  |  Branch (560:12): [Folded, False: 421]
  |  |  ------------------
  ------------------
  849|    421|					if ((vlan = (struct lldpd_vlan *)calloc(1,
  ------------------
  |  Branch (849:10): [True: 0, False: 421]
  ------------------
  850|    421|						 sizeof(struct lldpd_vlan))) == NULL) {
  851|      0|						log_warn("lldp",
  852|      0|						    "unable to alloc vlan "
  853|      0|						    "structure for "
  854|      0|						    "tlv received on %s",
  855|      0|						    hardware->h_ifname);
  856|      0|						goto malformed;
  857|      0|					}
  858|    421|					vlan->v_vid = PEEK_UINT16;
  ------------------
  |  |   63|    421|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  ------------------
  |  |  |  |   60|    421|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    421|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   63|    421|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  859|    421|					vlan_len = PEEK_UINT8;
  ------------------
  |  |   62|    421|#define PEEK_UINT8 PEEK(types.f_uint8, )
  |  |  ------------------
  |  |  |  |   60|    421|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    421|      func(type))
  |  |  ------------------
  ------------------
  860|    421|					CHECK_TLV_SIZE(7 + vlan_len, "VLAN");
  ------------------
  |  |  555|    421|  do {                                                                             \
  |  |  556|    421|    if (tlv_size < (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (556:9): [True: 9, False: 412]
  |  |  ------------------
  |  |  557|      9|      log_warnx("lldp", name " TLV too short received on %s", hardware->h_ifname); \
  |  |  558|      9|      goto malformed;                                                              \
  |  |  559|      9|    }                                                                              \
  |  |  560|    421|  } while (0)
  |  |  ------------------
  |  |  |  Branch (560:12): [Folded, False: 412]
  |  |  ------------------
  ------------------
  861|    412|					if ((vlan->v_name = (char *)calloc(1,
  ------------------
  |  Branch (861:10): [True: 0, False: 412]
  ------------------
  862|    412|						 vlan_len + 1)) == NULL) {
  863|      0|						log_warn("lldp",
  864|      0|						    "unable to alloc vlan name for "
  865|      0|						    "tlv received on %s",
  866|      0|						    hardware->h_ifname);
  867|      0|						goto malformed;
  868|      0|					}
  869|    412|					PEEK_BYTES(vlan->v_name, vlan_len);
  ------------------
  |  |   66|    412|  do {                           \
  |  |   67|    412|    memcpy(value, pos, bytes);   \
  |  |   68|    412|    length -= (bytes);           \
  |  |   69|    412|    pos += (bytes);              \
  |  |   70|    412|  } while (0)
  |  |  ------------------
  |  |  |  Branch (70:12): [Folded, False: 412]
  |  |  ------------------
  ------------------
  870|    412|					TAILQ_INSERT_TAIL(&port->p_vlans, vlan,
  ------------------
  |  Branch (870:6): [Folded, False: 412]
  ------------------
  871|    412|					    v_entries);
  872|    412|					vlan = NULL;
  873|    412|					break;
  874|    230|				case LLDP_TLV_DOT1_PVID:
  ------------------
  |  |   61|    230|#define LLDP_TLV_DOT1_PVID 1
  ------------------
  |  Branch (874:5): [True: 230, False: 1.60k]
  ------------------
  875|    230|					CHECK_TLV_SIZE(6, "PVID");
  ------------------
  |  |  555|    230|  do {                                                                             \
  |  |  556|    230|    if (tlv_size < (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (556:9): [True: 2, False: 228]
  |  |  ------------------
  |  |  557|      2|      log_warnx("lldp", name " TLV too short received on %s", hardware->h_ifname); \
  |  |  558|      2|      goto malformed;                                                              \
  |  |  559|      2|    }                                                                              \
  |  |  560|    230|  } while (0)
  |  |  ------------------
  |  |  |  Branch (560:12): [Folded, False: 228]
  |  |  ------------------
  ------------------
  876|    228|					port->p_pvid = PEEK_UINT16;
  ------------------
  |  |   63|    228|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  ------------------
  |  |  |  |   60|    228|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    228|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   63|    228|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  877|    228|					break;
  878|    402|				case LLDP_TLV_DOT1_PPVID:
  ------------------
  |  |   62|    402|#define LLDP_TLV_DOT1_PPVID 2
  ------------------
  |  Branch (878:5): [True: 402, False: 1.42k]
  ------------------
  879|    402|					CHECK_TLV_SIZE(7, "PPVID");
  ------------------
  |  |  555|    402|  do {                                                                             \
  |  |  556|    402|    if (tlv_size < (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (556:9): [True: 2, False: 400]
  |  |  ------------------
  |  |  557|      2|      log_warnx("lldp", name " TLV too short received on %s", hardware->h_ifname); \
  |  |  558|      2|      goto malformed;                                                              \
  |  |  559|      2|    }                                                                              \
  |  |  560|    402|  } while (0)
  |  |  ------------------
  |  |  |  Branch (560:12): [Folded, False: 400]
  |  |  ------------------
  ------------------
  880|       |					/* validation needed */
  881|       |					/* PPVID has to be unique if more than
  882|       |					   one PPVID TLVs are received  -
  883|       |					   discard if duplicate */
  884|       |					/* if support bit is not set and
  885|       |					   enabled bit is set - PPVID TLV is
  886|       |					   considered error  and discarded */
  887|       |					/* if PPVID > 4096 - bad and discard */
  888|    400|					if ((ppvid = (struct lldpd_ppvid *)calloc(1,
  ------------------
  |  Branch (888:10): [True: 0, False: 400]
  ------------------
  889|    400|						 sizeof(struct lldpd_ppvid))) == NULL) {
  890|      0|						log_warn("lldp",
  891|      0|						    "unable to alloc ppvid "
  892|      0|						    "structure for "
  893|      0|						    "tlv received on %s",
  894|      0|						    hardware->h_ifname);
  895|      0|						goto malformed;
  896|      0|					}
  897|    400|					ppvid->p_cap_status = PEEK_UINT8;
  ------------------
  |  |   62|    400|#define PEEK_UINT8 PEEK(types.f_uint8, )
  |  |  ------------------
  |  |  |  |   60|    400|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    400|      func(type))
  |  |  ------------------
  ------------------
  898|    400|					ppvid->p_ppvid = PEEK_UINT16;
  ------------------
  |  |   63|    400|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  ------------------
  |  |  |  |   60|    400|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    400|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   63|    400|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  899|    400|					TAILQ_INSERT_TAIL(&port->p_ppvids, ppvid,
  ------------------
  |  Branch (899:6): [Folded, False: 400]
  ------------------
  900|    400|					    p_entries);
  901|    400|					break;
  902|    408|				case LLDP_TLV_DOT1_PI:
  ------------------
  |  |   64|    408|#define LLDP_TLV_DOT1_PI 4
  ------------------
  |  Branch (902:5): [True: 408, False: 1.42k]
  ------------------
  903|       |					/* validation needed */
  904|       |					/* PI has to be unique if more than
  905|       |					   one PI TLVs are received  - discard
  906|       |					   if duplicate ?? */
  907|    408|					CHECK_TLV_SIZE(5, "PI");
  ------------------
  |  |  555|    408|  do {                                                                             \
  |  |  556|    408|    if (tlv_size < (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (556:9): [True: 1, False: 407]
  |  |  ------------------
  |  |  557|      1|      log_warnx("lldp", name " TLV too short received on %s", hardware->h_ifname); \
  |  |  558|      1|      goto malformed;                                                              \
  |  |  559|      1|    }                                                                              \
  |  |  560|    408|  } while (0)
  |  |  ------------------
  |  |  |  Branch (560:12): [Folded, False: 407]
  |  |  ------------------
  ------------------
  908|    407|					if ((pi = (struct lldpd_pi *)calloc(1,
  ------------------
  |  Branch (908:10): [True: 0, False: 407]
  ------------------
  909|    407|						 sizeof(struct lldpd_pi))) == NULL) {
  910|      0|						log_warn("lldp",
  911|      0|						    "unable to alloc PI "
  912|      0|						    "structure for "
  913|      0|						    "tlv received on %s",
  914|      0|						    hardware->h_ifname);
  915|      0|						goto malformed;
  916|      0|					}
  917|    407|					pi->p_pi_len = PEEK_UINT8;
  ------------------
  |  |   62|    407|#define PEEK_UINT8 PEEK(types.f_uint8, )
  |  |  ------------------
  |  |  |  |   60|    407|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    407|      func(type))
  |  |  ------------------
  ------------------
  918|    407|					CHECK_TLV_SIZE(5 + pi->p_pi_len, "PI");
  ------------------
  |  |  555|    407|  do {                                                                             \
  |  |  556|    407|    if (tlv_size < (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (556:9): [True: 9, False: 398]
  |  |  ------------------
  |  |  557|      9|      log_warnx("lldp", name " TLV too short received on %s", hardware->h_ifname); \
  |  |  558|      9|      goto malformed;                                                              \
  |  |  559|      9|    }                                                                              \
  |  |  560|    407|  } while (0)
  |  |  ------------------
  |  |  |  Branch (560:12): [Folded, False: 398]
  |  |  ------------------
  ------------------
  919|    398|					if ((pi->p_pi = (char *)calloc(1,
  ------------------
  |  Branch (919:10): [True: 0, False: 398]
  ------------------
  920|    398|						 pi->p_pi_len)) == NULL) {
  921|      0|						log_warn("lldp",
  922|      0|						    "unable to alloc pid name for "
  923|      0|						    "tlv received on %s",
  924|      0|						    hardware->h_ifname);
  925|      0|						goto malformed;
  926|      0|					}
  927|    398|					PEEK_BYTES(pi->p_pi, pi->p_pi_len);
  ------------------
  |  |   66|    398|  do {                           \
  |  |   67|    398|    memcpy(value, pos, bytes);   \
  |  |   68|    398|    length -= (bytes);           \
  |  |   69|    398|    pos += (bytes);              \
  |  |   70|    398|  } while (0)
  |  |  ------------------
  |  |  |  Branch (70:12): [Folded, False: 398]
  |  |  ------------------
  ------------------
  928|    398|					TAILQ_INSERT_TAIL(&port->p_pids, pi, p_entries);
  ------------------
  |  Branch (928:6): [Folded, False: 398]
  ------------------
  929|    398|					pi = NULL;
  930|    398|					break;
  931|    367|				default:
  ------------------
  |  Branch (931:5): [True: 367, False: 1.46k]
  ------------------
  932|       |					/* Unknown Dot1 TLV, ignore it */
  933|    367|					unrecognized = 1;
  934|  1.83k|				}
  935|  1.83k|#endif
  936|  8.01k|			} else if (memcmp(dot3, orgid, sizeof(orgid)) == 0) {
  ------------------
  |  Branch (936:15): [True: 1.29k, False: 6.71k]
  ------------------
  937|       |#ifndef ENABLE_DOT3
  938|       |				unrecognized = 1;
  939|       |#else
  940|       |				/* Dot3 */
  941|  1.29k|				switch (tlv_subtype) {
  942|    197|				case LLDP_TLV_DOT3_MAC:
  ------------------
  |  |   66|    197|#define LLDP_TLV_DOT3_MAC 1
  ------------------
  |  Branch (942:5): [True: 197, False: 1.10k]
  ------------------
  943|    197|					CHECK_TLV_SIZE(9, "MAC/PHY");
  ------------------
  |  |  555|    197|  do {                                                                             \
  |  |  556|    197|    if (tlv_size < (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (556:9): [True: 1, False: 196]
  |  |  ------------------
  |  |  557|      1|      log_warnx("lldp", name " TLV too short received on %s", hardware->h_ifname); \
  |  |  558|      1|      goto malformed;                                                              \
  |  |  559|      1|    }                                                                              \
  |  |  560|    197|  } while (0)
  |  |  ------------------
  |  |  |  Branch (560:12): [Folded, False: 196]
  |  |  ------------------
  ------------------
  944|    196|					port->p_macphy.autoneg_support = PEEK_UINT8;
  ------------------
  |  |   62|    196|#define PEEK_UINT8 PEEK(types.f_uint8, )
  |  |  ------------------
  |  |  |  |   60|    196|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    196|      func(type))
  |  |  ------------------
  ------------------
  945|    196|					port->p_macphy.autoneg_enabled =
  946|    196|					    (port->p_macphy.autoneg_support & 0x2) >> 1;
  947|    196|					port->p_macphy.autoneg_support =
  948|    196|					    port->p_macphy.autoneg_support & 0x1;
  949|    196|					port->p_macphy.autoneg_advertised = PEEK_UINT16;
  ------------------
  |  |   63|    196|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  ------------------
  |  |  |  |   60|    196|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    196|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   63|    196|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  950|    196|					port->p_macphy.mau_type = PEEK_UINT16;
  ------------------
  |  |   63|    196|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  ------------------
  |  |  |  |   60|    196|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    196|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   63|    196|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  951|    196|					break;
  952|    206|				case LLDP_TLV_DOT3_LA:
  ------------------
  |  |   68|    206|#define LLDP_TLV_DOT3_LA 3
  ------------------
  |  Branch (952:5): [True: 206, False: 1.09k]
  ------------------
  953|    206|					CHECK_TLV_SIZE(9, "Link aggregation");
  ------------------
  |  |  555|    206|  do {                                                                             \
  |  |  556|    206|    if (tlv_size < (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (556:9): [True: 4, False: 202]
  |  |  ------------------
  |  |  557|      4|      log_warnx("lldp", name " TLV too short received on %s", hardware->h_ifname); \
  |  |  558|      4|      goto malformed;                                                              \
  |  |  559|      4|    }                                                                              \
  |  |  560|    206|  } while (0)
  |  |  ------------------
  |  |  |  Branch (560:12): [Folded, False: 202]
  |  |  ------------------
  ------------------
  954|    202|					PEEK_DISCARD_UINT8;
  ------------------
  |  |   76|    202|#define PEEK_DISCARD_UINT8 PEEK_DISCARD(1)
  |  |  ------------------
  |  |  |  |   72|    202|  do {                      \
  |  |  |  |   73|    202|    length -= (bytes);      \
  |  |  |  |   74|    202|    pos += (bytes);         \
  |  |  |  |   75|    202|  } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (75:12): [Folded, False: 202]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  955|    202|					port->p_aggregid = PEEK_UINT32;
  ------------------
  |  |   64|    202|#define PEEK_UINT32 PEEK(types.f_uint32, ntohl)
  |  |  ------------------
  |  |  |  |   60|    202|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    202|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|    202|#define PEEK_UINT32 PEEK(types.f_uint32, ntohl)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  956|    202|					break;
  957|    208|				case LLDP_TLV_DOT3_MFS:
  ------------------
  |  |   69|    208|#define LLDP_TLV_DOT3_MFS 4
  ------------------
  |  Branch (957:5): [True: 208, False: 1.09k]
  ------------------
  958|    208|					CHECK_TLV_SIZE(6, "MFS");
  ------------------
  |  |  555|    208|  do {                                                                             \
  |  |  556|    208|    if (tlv_size < (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (556:9): [True: 2, False: 206]
  |  |  ------------------
  |  |  557|      2|      log_warnx("lldp", name " TLV too short received on %s", hardware->h_ifname); \
  |  |  558|      2|      goto malformed;                                                              \
  |  |  559|      2|    }                                                                              \
  |  |  560|    208|  } while (0)
  |  |  ------------------
  |  |  |  Branch (560:12): [Folded, False: 206]
  |  |  ------------------
  ------------------
  959|    206|					port->p_mfs = PEEK_UINT16;
  ------------------
  |  |   63|    206|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  ------------------
  |  |  |  |   60|    206|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    206|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   63|    206|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  960|    206|					break;
  961|    491|				case LLDP_TLV_DOT3_POWER:
  ------------------
  |  |   67|    491|#define LLDP_TLV_DOT3_POWER 2
  ------------------
  |  Branch (961:5): [True: 491, False: 808]
  ------------------
  962|    491|					CHECK_TLV_SIZE(7, "Power");
  ------------------
  |  |  555|    491|  do {                                                                             \
  |  |  556|    491|    if (tlv_size < (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (556:9): [True: 3, False: 488]
  |  |  ------------------
  |  |  557|      3|      log_warnx("lldp", name " TLV too short received on %s", hardware->h_ifname); \
  |  |  558|      3|      goto malformed;                                                              \
  |  |  559|      3|    }                                                                              \
  |  |  560|    491|  } while (0)
  |  |  ------------------
  |  |  |  Branch (560:12): [Folded, False: 488]
  |  |  ------------------
  ------------------
  963|    488|					port->p_power.devicetype = PEEK_UINT8;
  ------------------
  |  |   62|    488|#define PEEK_UINT8 PEEK(types.f_uint8, )
  |  |  ------------------
  |  |  |  |   60|    488|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    488|      func(type))
  |  |  ------------------
  ------------------
  964|    488|					port->p_power.supported =
  965|    488|					    (port->p_power.devicetype & 0x2) >> 1;
  966|    488|					port->p_power.enabled =
  967|    488|					    (port->p_power.devicetype & 0x4) >> 2;
  968|    488|					port->p_power.paircontrol =
  969|    488|					    (port->p_power.devicetype & 0x8) >> 3;
  970|    488|					port->p_power.devicetype =
  971|    488|					    (port->p_power.devicetype & 0x1) ?
  ------------------
  |  Branch (971:10): [True: 94, False: 394]
  ------------------
  972|     94|					    LLDP_DOT3_POWER_PSE :
  ------------------
  |  |  204|     94|#define LLDP_DOT3_POWER_PSE 1
  ------------------
  973|    488|					    LLDP_DOT3_POWER_PD;
  ------------------
  |  |  205|    882|#define LLDP_DOT3_POWER_PD 2
  ------------------
  974|    488|					port->p_power.pairs = PEEK_UINT8;
  ------------------
  |  |   62|    488|#define PEEK_UINT8 PEEK(types.f_uint8, )
  |  |  ------------------
  |  |  |  |   60|    488|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    488|      func(type))
  |  |  ------------------
  ------------------
  975|    488|					port->p_power.class = PEEK_UINT8;
  ------------------
  |  |   62|    488|#define PEEK_UINT8 PEEK(types.f_uint8, )
  |  |  ------------------
  |  |  |  |   60|    488|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    488|      func(type))
  |  |  ------------------
  ------------------
  976|       |					/* 802.3at? */
  977|    488|					if (tlv_size >= 12) {
  ------------------
  |  Branch (977:10): [True: 290, False: 198]
  ------------------
  978|    290|						port->p_power.powertype = PEEK_UINT8;
  ------------------
  |  |   62|    290|#define PEEK_UINT8 PEEK(types.f_uint8, )
  |  |  ------------------
  |  |  |  |   60|    290|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    290|      func(type))
  |  |  ------------------
  ------------------
  979|    290|						port->p_power.source =
  980|    290|						    (port->p_power.powertype &
  981|    290|							(1 << 5 | 1 << 4)) >>
  982|    290|						    4;
  983|    290|						port->p_power.priority =
  984|    290|						    (port->p_power.powertype &
  985|    290|							(1 << 1 | 1 << 0));
  986|    290|						port->p_power.powertype =
  987|    290|						    (port->p_power.powertype &
  ------------------
  |  Branch (987:11): [True: 119, False: 171]
  ------------------
  988|    290|							(1 << 7)) ?
  989|    119|						    LLDP_DOT3_POWER_8023AT_TYPE1 :
  ------------------
  |  |  213|    119|#define LLDP_DOT3_POWER_8023AT_TYPE1 1
  ------------------
  990|    290|						    LLDP_DOT3_POWER_8023AT_TYPE2;
  ------------------
  |  |  214|    461|#define LLDP_DOT3_POWER_8023AT_TYPE2 2
  ------------------
  991|    290|						port->p_power.requested = PEEK_UINT16;
  ------------------
  |  |   63|    290|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  ------------------
  |  |  |  |   60|    290|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    290|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   63|    290|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  992|    290|						port->p_power.allocated = PEEK_UINT16;
  ------------------
  |  |   63|    290|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  ------------------
  |  |  |  |   60|    290|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    290|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   63|    290|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  993|    290|					} else
  994|    198|						port->p_power.powertype =
  995|    198|						    LLDP_DOT3_POWER_8023AT_OFF;
  ------------------
  |  |  212|    198|#define LLDP_DOT3_POWER_8023AT_OFF 0
  ------------------
  996|       |					/* 802.3bt? */
  997|    488|					if (tlv_size >= 29) {
  ------------------
  |  Branch (997:10): [True: 78, False: 410]
  ------------------
  998|     78|						port->p_power.requested_a = PEEK_UINT16;
  ------------------
  |  |   63|     78|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  ------------------
  |  |  |  |   60|     78|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|     78|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   63|     78|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  999|     78|						port->p_power.requested_b = PEEK_UINT16;
  ------------------
  |  |   63|     78|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  ------------------
  |  |  |  |   60|     78|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|     78|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   63|     78|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1000|     78|						port->p_power.allocated_a = PEEK_UINT16;
  ------------------
  |  |   63|     78|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  ------------------
  |  |  |  |   60|     78|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|     78|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   63|     78|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1001|     78|						port->p_power.allocated_b = PEEK_UINT16;
  ------------------
  |  |   63|     78|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  ------------------
  |  |  |  |   60|     78|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|     78|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   63|     78|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1002|     78|						port->p_power.pse_status = PEEK_UINT16;
  ------------------
  |  |   63|     78|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  ------------------
  |  |  |  |   60|     78|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|     78|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   63|     78|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1003|     78|						port->p_power.pd_status =
 1004|     78|						    (port->p_power.pse_status &
 1005|     78|							(1 << 13 | 1 << 12)) >>
 1006|     78|						    12;
 1007|     78|						port->p_power.pse_pairs_ext =
 1008|     78|						    (port->p_power.pse_status &
 1009|     78|							(1 << 11 | 1 << 10)) >>
 1010|     78|						    10;
 1011|     78|						port->p_power.class_a =
 1012|     78|						    (port->p_power.pse_status &
 1013|     78|							(1 << 9 | 1 << 8 | 1 << 7)) >>
 1014|     78|						    7;
 1015|     78|						port->p_power.class_b =
 1016|     78|						    (port->p_power.pse_status &
 1017|     78|							(1 << 6 | 1 << 5 | 1 << 4)) >>
 1018|     78|						    4;
 1019|     78|						port->p_power.class_ext =
 1020|     78|						    (port->p_power.pse_status & 0xf);
 1021|     78|						port->p_power.pse_status =
 1022|     78|						    (port->p_power.pse_status &
 1023|     78|							(1 << 15 | 1 << 14)) >>
 1024|     78|						    14;
 1025|     78|						port->p_power.type_ext = PEEK_UINT8;
  ------------------
  |  |   62|     78|#define PEEK_UINT8 PEEK(types.f_uint8, )
  |  |  ------------------
  |  |  |  |   60|     78|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|     78|      func(type))
  |  |  ------------------
  ------------------
 1026|     78|						port->p_power.pd_load =
 1027|     78|						    (port->p_power.type_ext & 0x1);
 1028|     78|						port->p_power.type_ext =
 1029|     78|						    ((port->p_power.type_ext &
 1030|     78|							 (1 << 3 | 1 << 2 | 1 << 1)) +
 1031|     78|							1);
 1032|     78|						port->p_power.pse_max = PEEK_UINT16;
  ------------------
  |  |   63|     78|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  ------------------
  |  |  |  |   60|     78|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|     78|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   63|     78|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1033|    410|					} else {
 1034|    410|						port->p_power.type_ext =
 1035|    410|						    LLDP_DOT3_POWER_8023BT_OFF;
  ------------------
  |  |  217|    410|#define LLDP_DOT3_POWER_8023BT_OFF 0
  ------------------
 1036|    410|					}
 1037|    488|					break;
 1038|    197|				default:
  ------------------
  |  Branch (1038:5): [True: 197, False: 1.10k]
  ------------------
 1039|       |					/* Unknown Dot3 TLV, ignore it */
 1040|    197|					unrecognized = 1;
 1041|  1.29k|				}
 1042|  1.29k|#endif
 1043|  6.71k|			} else if (memcmp(med, orgid, sizeof(orgid)) == 0) {
  ------------------
  |  Branch (1043:15): [True: 5.76k, False: 948]
  ------------------
 1044|       |				/* LLDP-MED */
 1045|       |#ifndef ENABLE_LLDPMED
 1046|       |				unrecognized = 1;
 1047|       |#else
 1048|  5.76k|				u_int32_t policy;
 1049|  5.76k|				unsigned loctype;
 1050|  5.76k|				unsigned power;
 1051|       |
 1052|  5.76k|				switch (tlv_subtype) {
 1053|    201|				case LLDP_TLV_MED_CAP:
  ------------------
  |  |   71|    201|#define LLDP_TLV_MED_CAP 1
  ------------------
  |  Branch (1053:5): [True: 201, False: 5.56k]
  ------------------
 1054|    201|					CHECK_TLV_SIZE(7, "LLDP-MED capabilities");
  ------------------
  |  |  555|    201|  do {                                                                             \
  |  |  556|    201|    if (tlv_size < (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (556:9): [True: 1, False: 200]
  |  |  ------------------
  |  |  557|      1|      log_warnx("lldp", name " TLV too short received on %s", hardware->h_ifname); \
  |  |  558|      1|      goto malformed;                                                              \
  |  |  559|      1|    }                                                                              \
  |  |  560|    201|  } while (0)
  |  |  ------------------
  |  |  |  Branch (560:12): [Folded, False: 200]
  |  |  ------------------
  ------------------
 1055|    200|					chassis->c_med_cap_available = PEEK_UINT16;
  ------------------
  |  |   63|    200|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  ------------------
  |  |  |  |   60|    200|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    200|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   63|    200|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1056|    200|					chassis->c_med_type = PEEK_UINT8;
  ------------------
  |  |   62|    200|#define PEEK_UINT8 PEEK(types.f_uint8, )
  |  |  ------------------
  |  |  |  |   60|    200|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    200|      func(type))
  |  |  ------------------
  ------------------
 1057|    200|					port->p_med_cap_enabled |= LLDP_MED_CAP_CAP;
  ------------------
  |  |  329|    200|#define LLDP_MED_CAP_CAP 0x01
  ------------------
 1058|    200|					break;
 1059|    754|				case LLDP_TLV_MED_POLICY:
  ------------------
  |  |   72|    754|#define LLDP_TLV_MED_POLICY 2
  ------------------
  |  Branch (1059:5): [True: 754, False: 5.01k]
  ------------------
 1060|    754|					CHECK_TLV_SIZE(8, "LLDP-MED policy");
  ------------------
  |  |  555|    754|  do {                                                                             \
  |  |  556|    754|    if (tlv_size < (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (556:9): [True: 3, False: 751]
  |  |  ------------------
  |  |  557|      3|      log_warnx("lldp", name " TLV too short received on %s", hardware->h_ifname); \
  |  |  558|      3|      goto malformed;                                                              \
  |  |  559|      3|    }                                                                              \
  |  |  560|    754|  } while (0)
  |  |  ------------------
  |  |  |  Branch (560:12): [Folded, False: 751]
  |  |  ------------------
  ------------------
 1061|    751|					policy = PEEK_UINT32;
  ------------------
  |  |   64|    751|#define PEEK_UINT32 PEEK(types.f_uint32, ntohl)
  |  |  ------------------
  |  |  |  |   60|    751|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    751|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|    751|#define PEEK_UINT32 PEEK(types.f_uint32, ntohl)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1062|    751|					if (((policy >> 24) < 1) ||
  ------------------
  |  Branch (1062:10): [True: 231, False: 520]
  ------------------
 1063|    521|					    ((policy >> 24) > LLDP_MED_APPTYPE_LAST)) {
  ------------------
  |  |  295|    520|#define LLDP_MED_APPTYPE_LAST LLDP_MED_APPTYPE_VIDEOSIGNAL
  |  |  ------------------
  |  |  |  |  294|    520|#define LLDP_MED_APPTYPE_VIDEOSIGNAL 8
  |  |  ------------------
  ------------------
  |  Branch (1063:10): [True: 290, False: 230]
  ------------------
 1064|    521|						log_info("lldp",
 1065|    521|						    "unknown policy field %d "
 1066|    521|						    "received on %s",
 1067|    521|						    policy, hardware->h_ifname);
 1068|    521|						break;
 1069|    521|					}
 1070|    230|					port->p_med_policy[(policy >> 24) - 1].type =
 1071|    230|					    (policy >> 24);
 1072|    230|					port->p_med_policy[(policy >> 24) - 1].unknown =
 1073|    230|					    ((policy & 0x800000) != 0);
 1074|    230|					port->p_med_policy[(policy >> 24) - 1].tagged =
 1075|    230|					    ((policy & 0x400000) != 0);
 1076|    230|					port->p_med_policy[(policy >> 24) - 1].vid =
 1077|    230|					    (policy & 0x001FFE00) >> 9;
 1078|    230|					port->p_med_policy[(policy >> 24) - 1]
 1079|    230|					    .priority = (policy & 0x1C0) >> 6;
 1080|    230|					port->p_med_policy[(policy >> 24) - 1].dscp =
 1081|    230|					    policy & 0x3F;
 1082|    230|					port->p_med_cap_enabled |= LLDP_MED_CAP_POLICY;
  ------------------
  |  |  330|    230|#define LLDP_MED_CAP_POLICY 0x02
  ------------------
 1083|    230|					break;
 1084|    661|				case LLDP_TLV_MED_LOCATION:
  ------------------
  |  |   73|    661|#define LLDP_TLV_MED_LOCATION 3
  ------------------
  |  Branch (1084:5): [True: 661, False: 5.10k]
  ------------------
 1085|    661|					CHECK_TLV_SIZE(5, "LLDP-MED Location");
  ------------------
  |  |  555|    661|  do {                                                                             \
  |  |  556|    661|    if (tlv_size < (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (556:9): [True: 1, False: 660]
  |  |  ------------------
  |  |  557|      1|      log_warnx("lldp", name " TLV too short received on %s", hardware->h_ifname); \
  |  |  558|      1|      goto malformed;                                                              \
  |  |  559|      1|    }                                                                              \
  |  |  560|    661|  } while (0)
  |  |  ------------------
  |  |  |  Branch (560:12): [Folded, False: 660]
  |  |  ------------------
  ------------------
 1086|    660|					loctype = PEEK_UINT8;
  ------------------
  |  |   62|    660|#define PEEK_UINT8 PEEK(types.f_uint8, )
  |  |  ------------------
  |  |  |  |   60|    660|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    660|      func(type))
  |  |  ------------------
  ------------------
 1087|    660|					if ((loctype < 1) ||
  ------------------
  |  Branch (1087:10): [True: 195, False: 465]
  ------------------
 1088|    465|					    (loctype > LLDP_MED_LOCFORMAT_LAST)) {
  ------------------
  |  |  301|    465|#define LLDP_MED_LOCFORMAT_LAST LLDP_MED_LOCFORMAT_ELIN
  |  |  ------------------
  |  |  |  |  300|    465|#define LLDP_MED_LOCFORMAT_ELIN 3
  |  |  ------------------
  ------------------
  |  Branch (1088:10): [True: 247, False: 218]
  ------------------
 1089|    442|						log_info("lldp",
 1090|    442|						    "unknown location type "
 1091|    442|						    "received on %s",
 1092|    442|						    hardware->h_ifname);
 1093|    442|						break;
 1094|    442|					}
 1095|    218|					free(port->p_med_location[loctype - 1].data);
 1096|    218|					if ((port->p_med_location[loctype - 1].data =
  ------------------
  |  Branch (1096:10): [True: 0, False: 218]
  ------------------
 1097|    218|						    (char *)malloc(tlv_size - 5)) ==
 1098|    218|					    NULL) {
 1099|      0|						log_warn("lldp",
 1100|      0|						    "unable to allocate memory "
 1101|      0|						    "for LLDP-MED location for "
 1102|      0|						    "frame received on %s",
 1103|      0|						    hardware->h_ifname);
 1104|      0|						goto malformed;
 1105|      0|					}
 1106|    218|					PEEK_BYTES(
  ------------------
  |  |   66|    218|  do {                           \
  |  |   67|    218|    memcpy(value, pos, bytes);   \
  |  |   68|    218|    length -= (bytes);           \
  |  |   69|    218|    pos += (bytes);              \
  |  |   70|    218|  } while (0)
  |  |  ------------------
  |  |  |  Branch (70:12): [Folded, False: 218]
  |  |  ------------------
  ------------------
 1107|    218|					    port->p_med_location[loctype - 1].data,
 1108|    218|					    tlv_size - 5);
 1109|    218|					port->p_med_location[loctype - 1].data_len =
 1110|    218|					    tlv_size - 5;
 1111|    218|					port->p_med_location[loctype - 1].format =
 1112|    218|					    loctype;
 1113|    218|					port->p_med_cap_enabled |=
 1114|    218|					    LLDP_MED_CAP_LOCATION;
  ------------------
  |  |  331|    218|#define LLDP_MED_CAP_LOCATION 0x04
  ------------------
 1115|    218|					break;
 1116|  2.14k|				case LLDP_TLV_MED_MDI:
  ------------------
  |  |   74|  2.14k|#define LLDP_TLV_MED_MDI 4
  ------------------
  |  Branch (1116:5): [True: 2.14k, False: 3.62k]
  ------------------
 1117|  2.14k|					CHECK_TLV_SIZE(7, "LLDP-MED PoE-MDI");
  ------------------
  |  |  555|  2.14k|  do {                                                                             \
  |  |  556|  2.14k|    if (tlv_size < (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (556:9): [True: 3, False: 2.14k]
  |  |  ------------------
  |  |  557|      3|      log_warnx("lldp", name " TLV too short received on %s", hardware->h_ifname); \
  |  |  558|      3|      goto malformed;                                                              \
  |  |  559|      3|    }                                                                              \
  |  |  560|  2.14k|  } while (0)
  |  |  ------------------
  |  |  |  Branch (560:12): [Folded, False: 2.14k]
  |  |  ------------------
  ------------------
 1118|  2.14k|					power = PEEK_UINT8;
  ------------------
  |  |   62|  2.14k|#define PEEK_UINT8 PEEK(types.f_uint8, )
  |  |  ------------------
  |  |  |  |   60|  2.14k|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|  2.14k|      func(type))
  |  |  ------------------
  ------------------
 1119|  2.14k|					switch (power & 0xC0) {
 1120|    944|					case 0x0:
  ------------------
  |  Branch (1120:6): [True: 944, False: 1.19k]
  ------------------
 1121|    944|						port->p_med_power.devicetype =
 1122|    944|						    LLDP_MED_POW_TYPE_PSE;
  ------------------
  |  |  311|    944|#define LLDP_MED_POW_TYPE_PSE 1
  ------------------
 1123|    944|						port->p_med_cap_enabled |=
 1124|    944|						    LLDP_MED_CAP_MDI_PSE;
  ------------------
  |  |  332|    944|#define LLDP_MED_CAP_MDI_PSE 0x08
  ------------------
 1125|    944|						switch (power & 0x30) {
 1126|    205|						case 0x0:
  ------------------
  |  Branch (1126:7): [True: 205, False: 739]
  ------------------
 1127|    205|							port->p_med_power.source =
 1128|    205|							    LLDP_MED_POW_SOURCE_UNKNOWN;
  ------------------
  |  |  315|    205|#define LLDP_MED_POW_SOURCE_UNKNOWN 1
  ------------------
 1129|    205|							break;
 1130|    320|						case 0x10:
  ------------------
  |  Branch (1130:7): [True: 320, False: 624]
  ------------------
 1131|    320|							port->p_med_power.source =
 1132|    320|							    LLDP_MED_POW_SOURCE_PRIMARY;
  ------------------
  |  |  316|    320|#define LLDP_MED_POW_SOURCE_PRIMARY 2
  ------------------
 1133|    320|							break;
 1134|    219|						case 0x20:
  ------------------
  |  Branch (1134:7): [True: 219, False: 725]
  ------------------
 1135|    219|							port->p_med_power.source =
 1136|    219|							    LLDP_MED_POW_SOURCE_BACKUP;
  ------------------
  |  |  317|    219|#define LLDP_MED_POW_SOURCE_BACKUP 3
  ------------------
 1137|    219|							break;
 1138|    200|						default:
  ------------------
  |  Branch (1138:7): [True: 200, False: 744]
  ------------------
 1139|    200|							port->p_med_power.source =
 1140|    200|							    LLDP_MED_POW_SOURCE_RESERVED;
  ------------------
  |  |  318|    200|#define LLDP_MED_POW_SOURCE_RESERVED 4
  ------------------
 1141|    944|						}
 1142|    944|						break;
 1143|    944|					case 0x40:
  ------------------
  |  Branch (1143:6): [True: 835, False: 1.30k]
  ------------------
 1144|    835|						port->p_med_power.devicetype =
 1145|    835|						    LLDP_MED_POW_TYPE_PD;
  ------------------
  |  |  312|    835|#define LLDP_MED_POW_TYPE_PD 2
  ------------------
 1146|    835|						port->p_med_cap_enabled |=
 1147|    835|						    LLDP_MED_CAP_MDI_PD;
  ------------------
  |  |  333|    835|#define LLDP_MED_CAP_MDI_PD 0x10
  ------------------
 1148|    835|						switch (power & 0x30) {
 1149|    242|						case 0x0:
  ------------------
  |  Branch (1149:7): [True: 242, False: 593]
  ------------------
 1150|    242|							port->p_med_power.source =
 1151|    242|							    LLDP_MED_POW_SOURCE_UNKNOWN;
  ------------------
  |  |  315|    242|#define LLDP_MED_POW_SOURCE_UNKNOWN 1
  ------------------
 1152|    242|							break;
 1153|    203|						case 0x10:
  ------------------
  |  Branch (1153:7): [True: 203, False: 632]
  ------------------
 1154|    203|							port->p_med_power.source =
 1155|    203|							    LLDP_MED_POW_SOURCE_PSE;
  ------------------
  |  |  319|    203|#define LLDP_MED_POW_SOURCE_PSE 5
  ------------------
 1156|    203|							break;
 1157|    195|						case 0x20:
  ------------------
  |  Branch (1157:7): [True: 195, False: 640]
  ------------------
 1158|    195|							port->p_med_power.source =
 1159|    195|							    LLDP_MED_POW_SOURCE_LOCAL;
  ------------------
  |  |  320|    195|#define LLDP_MED_POW_SOURCE_LOCAL 6
  ------------------
 1160|    195|							break;
 1161|    195|						default:
  ------------------
  |  Branch (1161:7): [True: 195, False: 640]
  ------------------
 1162|    195|							port->p_med_power.source =
 1163|    195|							    LLDP_MED_POW_SOURCE_BOTH;
  ------------------
  |  |  321|    195|#define LLDP_MED_POW_SOURCE_BOTH 7
  ------------------
 1164|    835|						}
 1165|    835|						break;
 1166|    835|					default:
  ------------------
  |  Branch (1166:6): [True: 362, False: 1.77k]
  ------------------
 1167|    362|						port->p_med_power.devicetype =
 1168|    362|						    LLDP_MED_POW_TYPE_RESERVED;
  ------------------
  |  |  313|    362|#define LLDP_MED_POW_TYPE_RESERVED 3
  ------------------
 1169|  2.14k|					}
 1170|  2.14k|					if ((power & 0x0F) > LLDP_MED_POW_PRIO_LOW)
  ------------------
  |  |  326|  2.14k|#define LLDP_MED_POW_PRIO_LOW 3
  ------------------
  |  Branch (1170:10): [True: 1.31k, False: 829]
  ------------------
 1171|  1.31k|						port->p_med_power.priority =
 1172|  1.31k|						    LLDP_MED_POW_PRIO_UNKNOWN;
  ------------------
  |  |  323|  1.31k|#define LLDP_MED_POW_PRIO_UNKNOWN 0
  ------------------
 1173|    829|					else
 1174|    829|						port->p_med_power.priority =
 1175|    829|						    power & 0x0F;
 1176|  2.14k|					port->p_med_power.val = PEEK_UINT16;
  ------------------
  |  |   63|  2.14k|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  ------------------
  |  |  |  |   60|  2.14k|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|  2.14k|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   63|  2.14k|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1177|  2.14k|					break;
 1178|    224|				case LLDP_TLV_MED_IV_HW:
  ------------------
  |  |   75|    224|#define LLDP_TLV_MED_IV_HW 5
  ------------------
  |  Branch (1178:5): [True: 224, False: 5.54k]
  ------------------
 1179|    509|				case LLDP_TLV_MED_IV_SW:
  ------------------
  |  |   77|    509|#define LLDP_TLV_MED_IV_SW 7
  ------------------
  |  Branch (1179:5): [True: 285, False: 5.48k]
  ------------------
 1180|    747|				case LLDP_TLV_MED_IV_FW:
  ------------------
  |  |   76|    747|#define LLDP_TLV_MED_IV_FW 6
  ------------------
  |  Branch (1180:5): [True: 238, False: 5.53k]
  ------------------
 1181|  1.04k|				case LLDP_TLV_MED_IV_SN:
  ------------------
  |  |   78|  1.04k|#define LLDP_TLV_MED_IV_SN 8
  ------------------
  |  Branch (1181:5): [True: 293, False: 5.47k]
  ------------------
 1182|  1.24k|				case LLDP_TLV_MED_IV_MANUF:
  ------------------
  |  |   79|  1.24k|#define LLDP_TLV_MED_IV_MANUF 9
  ------------------
  |  Branch (1182:5): [True: 208, False: 5.56k]
  ------------------
 1183|  1.51k|				case LLDP_TLV_MED_IV_MODEL:
  ------------------
  |  |   80|  1.51k|#define LLDP_TLV_MED_IV_MODEL 10
  ------------------
  |  Branch (1183:5): [True: 262, False: 5.50k]
  ------------------
 1184|  1.77k|				case LLDP_TLV_MED_IV_ASSET:
  ------------------
  |  |   81|  1.77k|#define LLDP_TLV_MED_IV_ASSET 11
  ------------------
  |  Branch (1184:5): [True: 263, False: 5.50k]
  ------------------
 1185|  1.77k|					if (tlv_size <= 4)
  ------------------
  |  Branch (1185:10): [True: 1.44k, False: 330]
  ------------------
 1186|  1.44k|						b = NULL;
 1187|    330|					else {
 1188|    330|						if ((b = (char *)malloc(
  ------------------
  |  Branch (1188:11): [True: 0, False: 330]
  ------------------
 1189|    330|							 tlv_size - 3)) == NULL) {
 1190|      0|							log_warn("lldp",
 1191|      0|							    "unable to allocate "
 1192|      0|							    "memory for LLDP-MED "
 1193|      0|							    "inventory for frame "
 1194|      0|							    "received on %s",
 1195|      0|							    hardware->h_ifname);
 1196|      0|							goto malformed;
 1197|      0|						}
 1198|    330|						PEEK_BYTES(b, tlv_size - 4);
  ------------------
  |  |   66|    330|  do {                           \
  |  |   67|    330|    memcpy(value, pos, bytes);   \
  |  |   68|    330|    length -= (bytes);           \
  |  |   69|    330|    pos += (bytes);              \
  |  |   70|    330|  } while (0)
  |  |  ------------------
  |  |  |  Branch (70:12): [Folded, False: 330]
  |  |  ------------------
  ------------------
 1199|    330|						b[tlv_size - 4] = '\0';
 1200|    330|					}
 1201|  1.77k|					switch (tlv_subtype) {
 1202|    224|					case LLDP_TLV_MED_IV_HW:
  ------------------
  |  |   75|    224|#define LLDP_TLV_MED_IV_HW 5
  ------------------
  |  Branch (1202:6): [True: 224, False: 1.54k]
  ------------------
 1203|    224|						free(chassis->c_med_hw);
 1204|    224|						chassis->c_med_hw = b;
 1205|    224|						break;
 1206|    238|					case LLDP_TLV_MED_IV_FW:
  ------------------
  |  |   76|    238|#define LLDP_TLV_MED_IV_FW 6
  ------------------
  |  Branch (1206:6): [True: 238, False: 1.53k]
  ------------------
 1207|    238|						free(chassis->c_med_fw);
 1208|    238|						chassis->c_med_fw = b;
 1209|    238|						break;
 1210|    285|					case LLDP_TLV_MED_IV_SW:
  ------------------
  |  |   77|    285|#define LLDP_TLV_MED_IV_SW 7
  ------------------
  |  Branch (1210:6): [True: 285, False: 1.48k]
  ------------------
 1211|    285|						free(chassis->c_med_sw);
 1212|    285|						chassis->c_med_sw = b;
 1213|    285|						break;
 1214|    293|					case LLDP_TLV_MED_IV_SN:
  ------------------
  |  |   78|    293|#define LLDP_TLV_MED_IV_SN 8
  ------------------
  |  Branch (1214:6): [True: 293, False: 1.48k]
  ------------------
 1215|    293|						free(chassis->c_med_sn);
 1216|    293|						chassis->c_med_sn = b;
 1217|    293|						break;
 1218|    208|					case LLDP_TLV_MED_IV_MANUF:
  ------------------
  |  |   79|    208|#define LLDP_TLV_MED_IV_MANUF 9
  ------------------
  |  Branch (1218:6): [True: 208, False: 1.56k]
  ------------------
 1219|    208|						free(chassis->c_med_manuf);
 1220|    208|						chassis->c_med_manuf = b;
 1221|    208|						break;
 1222|    262|					case LLDP_TLV_MED_IV_MODEL:
  ------------------
  |  |   80|    262|#define LLDP_TLV_MED_IV_MODEL 10
  ------------------
  |  Branch (1222:6): [True: 262, False: 1.51k]
  ------------------
 1223|    262|						free(chassis->c_med_model);
 1224|    262|						chassis->c_med_model = b;
 1225|    262|						break;
 1226|    263|					case LLDP_TLV_MED_IV_ASSET:
  ------------------
  |  |   81|    263|#define LLDP_TLV_MED_IV_ASSET 11
  ------------------
  |  Branch (1226:6): [True: 263, False: 1.51k]
  ------------------
 1227|    263|						free(chassis->c_med_asset);
 1228|    263|						chassis->c_med_asset = b;
 1229|    263|						break;
 1230|      0|					default:
  ------------------
  |  Branch (1230:6): [True: 0, False: 1.77k]
  ------------------
 1231|       |						/* unreachable */
 1232|      0|						free(b);
 1233|      0|						break;
 1234|  1.77k|					}
 1235|  1.77k|					port->p_med_cap_enabled |= LLDP_MED_CAP_IV;
  ------------------
  |  |  334|  1.77k|#define LLDP_MED_CAP_IV 0x20
  ------------------
 1236|  1.77k|					break;
 1237|    235|				default:
  ------------------
  |  Branch (1237:5): [True: 235, False: 5.53k]
  ------------------
 1238|       |					/* Unknown LLDP MED, ignore it */
 1239|    235|					hardware->h_rx_unrecognized_cnt++;
 1240|  5.76k|				}
 1241|  5.76k|#endif /* ENABLE_LLDPMED */
 1242|  5.76k|			} else if (memcmp(dcbx, orgid, sizeof(orgid)) == 0) {
  ------------------
  |  Branch (1242:15): [True: 278, False: 670]
  ------------------
 1243|    278|				log_debug("lldp",
 1244|    278|				    "unsupported DCBX tlv received on %s - ignore",
 1245|    278|				    hardware->h_ifname);
 1246|    278|				unrecognized = 1;
 1247|    670|			} else {
 1248|    670|				log_debug("lldp",
 1249|    670|				    "unknown org tlv [%02x:%02x:%02x] received on %s",
 1250|    670|				    orgid[0], orgid[1], orgid[2], hardware->h_ifname);
 1251|    670|				unrecognized = 1;
 1252|    670|			}
 1253|  9.80k|			if (unrecognized) {
  ------------------
  |  Branch (1253:8): [True: 1.51k, False: 8.29k]
  ------------------
 1254|  1.51k|				hardware->h_rx_unrecognized_cnt++;
 1255|  1.51k|#ifdef ENABLE_CUSTOM
 1256|  1.51k|				custom = (struct lldpd_custom *)calloc(1,
 1257|  1.51k|				    sizeof(struct lldpd_custom));
 1258|  1.51k|				if (!custom) {
  ------------------
  |  Branch (1258:9): [True: 0, False: 1.51k]
  ------------------
 1259|      0|					log_warn("lldp",
 1260|      0|					    "unable to allocate memory for custom TLV");
 1261|      0|					goto malformed;
 1262|      0|				}
 1263|  1.51k|				custom->oui_info_len = tlv_size > 4 ? tlv_size - 4 : 0;
  ------------------
  |  Branch (1263:28): [True: 472, False: 1.04k]
  ------------------
 1264|  1.51k|				memcpy(custom->oui, orgid, sizeof(custom->oui));
 1265|  1.51k|				custom->subtype = tlv_subtype;
 1266|  1.51k|				if (custom->oui_info_len > 0) {
  ------------------
  |  Branch (1266:9): [True: 472, False: 1.04k]
  ------------------
 1267|    472|					custom->oui_info = malloc(custom->oui_info_len);
 1268|    472|					if (!custom->oui_info) {
  ------------------
  |  Branch (1268:10): [True: 0, False: 472]
  ------------------
 1269|      0|						log_warn("lldp",
 1270|      0|						    "unable to allocate memory for custom TLV data");
 1271|      0|						goto malformed;
 1272|      0|					}
 1273|    472|					PEEK_BYTES(custom->oui_info,
  ------------------
  |  |   66|    472|  do {                           \
  |  |   67|    472|    memcpy(value, pos, bytes);   \
  |  |   68|    472|    length -= (bytes);           \
  |  |   69|    472|    pos += (bytes);              \
  |  |   70|    472|  } while (0)
  |  |  ------------------
  |  |  |  Branch (70:12): [Folded, False: 472]
  |  |  ------------------
  ------------------
 1274|    472|					    custom->oui_info_len);
 1275|    472|				}
 1276|  1.51k|				TAILQ_INSERT_TAIL(&port->p_custom_list, custom, next);
  ------------------
  |  Branch (1276:5): [Folded, False: 1.51k]
  ------------------
 1277|  1.51k|				custom = NULL;
 1278|  1.51k|#endif
 1279|  1.51k|			}
 1280|  9.80k|			break;
 1281|  9.80k|		default:
  ------------------
  |  Branch (1281:3): [True: 553, False: 17.2k]
  ------------------
 1282|    553|			log_warnx("lldp", "unknown tlv (%d) received on %s", tlv_type,
 1283|    553|			    hardware->h_ifname);
 1284|    553|			hardware->h_rx_unrecognized_cnt++;
 1285|    553|			break;
 1286|  17.7k|		}
 1287|  17.6k|		if (pos > tlv + tlv_size) {
  ------------------
  |  Branch (1287:7): [True: 0, False: 17.6k]
  ------------------
 1288|      0|			log_warnx("lldp", "BUG: already past TLV!");
 1289|      0|			goto malformed;
 1290|      0|		}
 1291|  17.6k|		PEEK_DISCARD(tlv + tlv_size - pos);
  ------------------
  |  |   72|  17.6k|  do {                      \
  |  |   73|  17.6k|    length -= (bytes);      \
  |  |   74|  17.6k|    pos += (bytes);         \
  |  |   75|  17.6k|  } while (0)
  |  |  ------------------
  |  |  |  Branch (75:12): [Folded, False: 17.6k]
  |  |  ------------------
  ------------------
 1292|  17.6k|	}
 1293|       |
 1294|       |	/* Some random check */
 1295|    776|	if ((chassis->c_id == NULL) || (port->p_id == NULL) || (!ttl_received) ||
  ------------------
  |  Branch (1295:6): [True: 533, False: 243]
  |  Branch (1295:33): [True: 27, False: 216]
  |  Branch (1295:57): [True: 8, False: 208]
  ------------------
 1296|    653|	    (gotend == 0)) {
  ------------------
  |  Branch (1296:6): [True: 85, False: 123]
  ------------------
 1297|    653|		log_warnx("lldp",
 1298|    653|		    "some mandatory tlv are missing for frame received on %s",
 1299|    653|		    hardware->h_ifname);
 1300|    653|		goto malformed;
 1301|    653|	}
 1302|    123|	*newchassis = chassis;
 1303|    123|	*newport = port;
 1304|    123|	return 1;
 1305|  1.03k|malformed:
 1306|  1.03k|#ifdef ENABLE_CUSTOM
 1307|  1.03k|	free(custom);
 1308|  1.03k|#endif
 1309|  1.03k|#ifdef ENABLE_DOT1
 1310|  1.03k|	free(vlan);
 1311|  1.03k|	free(pi);
 1312|  1.03k|#endif
 1313|  1.03k|	lldpd_chassis_cleanup(chassis, 1);
 1314|  1.03k|	lldpd_port_cleanup(port, 1);
 1315|  1.03k|	free(port);
 1316|  1.03k|	return -1;
 1317|    776|}
lldp.c:lldpd_af_from_lldp_proto:
   43|    924|{
   44|    924|	switch (proto) {
   45|    492|	case LLDP_MGMT_ADDR_IP4:
  ------------------
  |  |  273|    492|#define LLDP_MGMT_ADDR_IP4 1
  ------------------
  |  Branch (45:2): [True: 492, False: 432]
  ------------------
   46|    492|		return LLDPD_AF_IPV4;
   47|    187|	case LLDP_MGMT_ADDR_IP6:
  ------------------
  |  |  274|    187|#define LLDP_MGMT_ADDR_IP6 2
  ------------------
  |  Branch (47:2): [True: 187, False: 737]
  ------------------
   48|    187|		return LLDPD_AF_IPV6;
   49|    245|	default:
  ------------------
  |  Branch (49:2): [True: 245, False: 679]
  ------------------
   50|    245|		return LLDPD_AF_UNSPEC;
   51|    924|	}
   52|    924|}

lldpd_chassis_mgmt_cleanup:
   26|  1.15k|{
   27|  1.15k|	struct lldpd_mgmt *mgmt, *mgmt_next;
   28|       |
   29|  1.15k|	log_debug("alloc", "cleanup management addresses for chassis %s",
   30|  1.15k|	    chassis->c_name ? chassis->c_name : "(unknown)");
  ------------------
  |  Branch (30:6): [True: 19, False: 1.14k]
  ------------------
   31|       |
   32|  1.83k|	for (mgmt = TAILQ_FIRST(&chassis->c_mgmt); mgmt != NULL; mgmt = mgmt_next) {
  ------------------
  |  Branch (32:45): [True: 678, False: 1.15k]
  ------------------
   33|    678|		mgmt_next = TAILQ_NEXT(mgmt, m_entries);
   34|    678|		free(mgmt);
   35|    678|	}
   36|       |	TAILQ_INIT(&chassis->c_mgmt);
  ------------------
  |  Branch (36:2): [Folded, False: 1.15k]
  ------------------
   37|  1.15k|}
lldpd_chassis_cleanup:
   41|  1.15k|{
   42|  1.15k|	lldpd_chassis_mgmt_cleanup(chassis);
   43|  1.15k|	log_debug("alloc", "cleanup chassis %s",
   44|  1.15k|	    chassis->c_name ? chassis->c_name : "(unknown)");
  ------------------
  |  Branch (44:6): [True: 19, False: 1.14k]
  ------------------
   45|  1.15k|#ifdef ENABLE_LLDPMED
   46|  1.15k|	free(chassis->c_med_hw);
   47|  1.15k|	free(chassis->c_med_sw);
   48|  1.15k|	free(chassis->c_med_fw);
   49|  1.15k|	free(chassis->c_med_sn);
   50|  1.15k|	free(chassis->c_med_manuf);
   51|  1.15k|	free(chassis->c_med_model);
   52|  1.15k|	free(chassis->c_med_asset);
   53|  1.15k|#endif
   54|  1.15k|	free(chassis->c_id);
   55|  1.15k|	free(chassis->c_name);
   56|  1.15k|	free(chassis->c_descr);
   57|  1.15k|	if (all) free(chassis);
  ------------------
  |  Branch (57:6): [True: 1.15k, False: 0]
  ------------------
   58|  1.15k|}
lldpd_vlan_cleanup:
   63|  1.15k|{
   64|  1.15k|	struct lldpd_vlan *vlan, *vlan_next;
   65|  1.57k|	for (vlan = TAILQ_FIRST(&port->p_vlans); vlan != NULL; vlan = vlan_next) {
  ------------------
  |  Branch (65:43): [True: 412, False: 1.15k]
  ------------------
   66|    412|		free(vlan->v_name);
   67|    412|		vlan_next = TAILQ_NEXT(vlan, v_entries);
   68|    412|		free(vlan);
   69|    412|	}
   70|       |	TAILQ_INIT(&port->p_vlans);
  ------------------
  |  Branch (70:2): [Folded, False: 1.15k]
  ------------------
   71|  1.15k|	port->p_pvid = 0;
   72|  1.15k|}
lldpd_ppvid_cleanup:
   76|  1.15k|{
   77|  1.15k|	struct lldpd_ppvid *ppvid, *ppvid_next;
   78|  1.55k|	for (ppvid = TAILQ_FIRST(&port->p_ppvids); ppvid != NULL; ppvid = ppvid_next) {
  ------------------
  |  Branch (78:45): [True: 400, False: 1.15k]
  ------------------
   79|    400|		ppvid_next = TAILQ_NEXT(ppvid, p_entries);
   80|    400|		free(ppvid);
   81|    400|	}
   82|       |	TAILQ_INIT(&port->p_ppvids);
  ------------------
  |  Branch (82:2): [Folded, False: 1.15k]
  ------------------
   83|  1.15k|}
lldpd_pi_cleanup:
   87|  1.15k|{
   88|  1.15k|	struct lldpd_pi *pi, *pi_next;
   89|  1.55k|	for (pi = TAILQ_FIRST(&port->p_pids); pi != NULL; pi = pi_next) {
  ------------------
  |  Branch (89:40): [True: 398, False: 1.15k]
  ------------------
   90|    398|		free(pi->p_pi);
   91|    398|		pi_next = TAILQ_NEXT(pi, p_entries);
   92|    398|		free(pi);
   93|    398|	}
   94|       |	TAILQ_INIT(&port->p_pids);
  ------------------
  |  Branch (94:2): [Folded, False: 1.15k]
  ------------------
   95|  1.15k|}
lldpd_custom_list_cleanup:
  141|  1.15k|{
  142|  1.15k|	struct lldpd_custom *custom, *custom_next;
  143|  2.67k|	for (custom = TAILQ_FIRST(&port->p_custom_list); custom != NULL;
  ------------------
  |  Branch (143:51): [True: 1.51k, False: 1.15k]
  ------------------
  144|  1.51k|	     custom = custom_next) {
  145|  1.51k|		custom_next = TAILQ_NEXT(custom, next);
  146|  1.51k|		free(custom->oui_info);
  147|  1.51k|		free(custom);
  148|  1.51k|	}
  149|       |	TAILQ_INIT(&port->p_custom_list);
  ------------------
  |  Branch (149:2): [Folded, False: 1.15k]
  ------------------
  150|  1.15k|}
lldpd_port_cleanup:
  196|  1.15k|{
  197|  1.15k|#ifdef ENABLE_LLDPMED
  198|  1.15k|	int i;
  199|  1.15k|	if (all)
  ------------------
  |  Branch (199:6): [True: 1.15k, False: 0]
  ------------------
  200|  4.63k|		for (i = 0; i < LLDP_MED_LOCFORMAT_LAST; i++)
  ------------------
  |  |  301|  4.63k|#define LLDP_MED_LOCFORMAT_LAST LLDP_MED_LOCFORMAT_ELIN
  |  |  ------------------
  |  |  |  |  300|  4.63k|#define LLDP_MED_LOCFORMAT_ELIN 3
  |  |  ------------------
  ------------------
  |  Branch (200:15): [True: 3.47k, False: 1.15k]
  ------------------
  201|  3.47k|			free(port->p_med_location[i].data);
  202|  1.15k|#endif
  203|  1.15k|#ifdef ENABLE_DOT1
  204|  1.15k|	lldpd_vlan_cleanup(port);
  205|  1.15k|	lldpd_ppvid_cleanup(port);
  206|  1.15k|	lldpd_pi_cleanup(port);
  207|  1.15k|#endif
  208|       |	/* will set these to NULL so we don't free wrong memory */
  209|       |
  210|  1.15k|	if (all) {
  ------------------
  |  Branch (210:6): [True: 1.15k, False: 0]
  ------------------
  211|  1.15k|		free(port->p_id);
  212|  1.15k|		port->p_id = NULL;
  213|  1.15k|		free(port->p_descr);
  214|  1.15k|		port->p_descr = NULL;
  215|  1.15k|		free(port->p_lastframe);
  216|  1.15k|		if (port->p_chassis) { /* chassis may not have been attributed, yet */
  ------------------
  |  Branch (216:7): [True: 0, False: 1.15k]
  ------------------
  217|      0|			port->p_chassis->c_refcount--;
  218|      0|			port->p_chassis = NULL;
  219|      0|		}
  220|  1.15k|		free(port->p_vlan_advertise_pattern);
  221|       |		port->p_vlan_advertise_pattern = NULL;
  222|  1.15k|#ifdef ENABLE_CUSTOM
  223|  1.15k|		lldpd_custom_list_cleanup(port);
  224|  1.15k|#endif
  225|  1.15k|	}
  226|  1.15k|}

log_register:
   64|  1.15k|{
   65|  1.15k|	logh = cb;
   66|  1.15k|}
log_warn:
  190|      1|{
  191|      1|	char *nfmt = NULL;
  192|      1|	va_list ap;
  193|       |
  194|       |	/* best effort to even work in out of memory situations */
  195|      1|	if (emsg == NULL)
  ------------------
  |  Branch (195:6): [True: 0, False: 1]
  ------------------
  196|      0|		logit(LOG_WARNING, "%s", strerror(errno));
  197|      1|	else {
  198|      1|		va_start(ap, emsg);
  199|       |
  200|      1|		if (asprintf(&nfmt, "%s: %s", emsg, strerror(errno)) == -1) {
  ------------------
  |  Branch (200:7): [True: 0, False: 1]
  ------------------
  201|       |			/* we tried it... */
  202|      0|			vlog(LOG_WARNING, token, emsg, ap);
  203|      0|			logit(LOG_WARNING, "%s", strerror(errno));
  204|      1|		} else {
  205|      1|			vlog(LOG_WARNING, token, nfmt, ap);
  206|      1|			free(nfmt);
  207|      1|		}
  208|       |		va_end(ap);
  209|      1|	}
  210|      1|}
log_warnx:
  214|  1.51k|{
  215|  1.51k|	va_list ap;
  216|       |
  217|  1.51k|	va_start(ap, emsg);
  218|  1.51k|	vlog(LOG_WARNING, token, emsg, ap);
  219|       |	va_end(ap);
  220|  1.51k|}
log_info:
  224|  1.03k|{
  225|  1.03k|	va_list ap;
  226|       |
  227|  1.03k|	if (use_syslog || debug > 0 || logh) {
  ------------------
  |  Branch (227:6): [True: 0, False: 1.03k]
  |  Branch (227:20): [True: 0, False: 1.03k]
  |  Branch (227:33): [True: 1.03k, False: 0]
  ------------------
  228|  1.03k|		va_start(ap, emsg);
  229|  1.03k|		vlog(LOG_INFO, token, emsg, ap);
  230|       |		va_end(ap);
  231|  1.03k|	}
  232|  1.03k|}
log_debug:
  247|  9.50k|{
  248|  9.50k|	va_list ap;
  249|       |
  250|  9.50k|	if ((debug > 1 && log_debug_accept_token(token)) || logh) {
  ------------------
  |  Branch (250:7): [True: 0, False: 9.50k]
  |  Branch (250:20): [True: 0, False: 0]
  |  Branch (250:54): [True: 9.50k, False: 0]
  ------------------
  251|  9.50k|		va_start(ap, emsg);
  252|  9.50k|		vlog(LOG_DEBUG, token, emsg, ap);
  253|       |		va_end(ap);
  254|  9.50k|	}
  255|  9.50k|}
log.c:vlog:
  154|  12.0k|{
  155|  12.0k|	if (logh) {
  ------------------
  |  Branch (155:6): [True: 12.0k, False: 0]
  ------------------
  156|  12.0k|		char *result = NULL;
  157|  12.0k|		if (vasprintf(&result, fmt, ap) != -1) {
  ------------------
  |  Branch (157:7): [True: 12.0k, False: 0]
  ------------------
  158|  12.0k|			logh(pri, result);
  159|  12.0k|			free(result);
  160|  12.0k|			return;
  161|  12.0k|		}
  162|       |		/* Otherwise, abort. We don't know if "ap" is still OK. We could
  163|       |		 * have made a copy, but this is too much overhead for a
  164|       |		 * situation that shouldn't happen. */
  165|      0|		return;
  166|  12.0k|	}
  167|       |
  168|       |	/* Log to syslog if requested */
  169|      0|	if (use_syslog) {
  ------------------
  |  Branch (169:6): [True: 0, False: 0]
  ------------------
  170|      0|		va_list ap2;
  171|      0|		va_copy(ap2, ap);
  172|      0|		vsyslog(pri, fmt, ap2);
  173|      0|		va_end(ap2);
  174|      0|	}
  175|       |
  176|       |	/* Log to standard error in all cases. Format the caller's message
  177|       |	 * first so it is not re-interpreted as a format string by the
  178|       |	 * surrounding fprintf. */
  179|      0|	char *body = NULL;
  180|      0|	if (vasprintf(&body, fmt, ap) == -1) body = NULL;
  ------------------
  |  Branch (180:6): [True: 0, False: 0]
  ------------------
  181|      0|	fprintf(stderr, "%s %s%s%s]%s %s\n", date(), translate(STDERR_FILENO, pri),
  182|      0|	    token ? "/" : "", token ? token : "",
  ------------------
  |  Branch (182:6): [True: 0, False: 0]
  |  Branch (182:24): [True: 0, False: 0]
  ------------------
  183|      0|	    isatty(STDERR_FILENO) ? "\033[0m" : "", body ? body : fmt);
  ------------------
  |  Branch (183:6): [True: 0, False: 0]
  |  Branch (183:46): [True: 0, False: 0]
  ------------------
  184|      0|	free(body);
  185|       |	fflush(stderr);
  186|      0|}

donothing:
   24|  12.0k|void donothing(int pri, const char *msg) {};
LLVMFuzzerTestOneInput:
   28|  1.18k|{
   29|  1.18k|	if (Size < kMinInputLength || Size > kMaxInputLength) {
  ------------------
  |  |   20|  2.37k|#define kMinInputLength 5
  ------------------
              	if (Size < kMinInputLength || Size > kMaxInputLength) {
  ------------------
  |  |   21|  1.18k|#define kMaxInputLength 2048
  ------------------
  |  Branch (29:6): [True: 4, False: 1.18k]
  |  Branch (29:32): [True: 22, False: 1.15k]
  ------------------
   30|     26|		return 1;
   31|     26|	}
   32|       |
   33|  1.15k|	struct lldpd_chassis *nchassis = NULL;
   34|  1.15k|	struct lldpd_port *nport = NULL;
   35|  1.15k|	struct lldpd_hardware hardware;
   36|       |
   37|  1.15k|	log_register(donothing);
   38|       |
   39|  1.15k|	lldp_decode(NULL, (char *)Data, Size, &hardware, &nchassis, &nport);
   40|       |
   41|  1.15k|	if (!nchassis || !nport) {
  ------------------
  |  Branch (41:6): [True: 1.03k, False: 123]
  |  Branch (41:19): [True: 0, False: 123]
  ------------------
   42|  1.03k|		return 1;
   43|  1.03k|	}
   44|       |
   45|    123|	lldpd_port_cleanup(nport, 1);
   46|    123|	free(nport);
   47|    123|	lldpd_chassis_cleanup(nchassis, 1);
   48|       |
   49|    123|	return 0;
   50|  1.15k|}

