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

lldp_decode:
  572|  1.14k|{
  573|  1.14k|	struct lldpd_chassis *chassis;
  574|  1.14k|	struct lldpd_port *port;
  575|  1.14k|	char lldpaddr[ETHER_ADDR_LEN];
  576|  1.14k|	const char dot1[] = LLDP_TLV_ORG_DOT1;
  ------------------
  |  |   45|  1.14k|  {                       \
  |  |   46|  1.14k|    0x00, 0x80, 0xc2      \
  |  |   47|  1.14k|  }
  ------------------
  577|  1.14k|	const char dot3[] = LLDP_TLV_ORG_DOT3;
  ------------------
  |  |   49|  1.14k|  {                       \
  |  |   50|  1.14k|    0x00, 0x12, 0x0f      \
  |  |   51|  1.14k|  }
  ------------------
  578|  1.14k|	const char med[] = LLDP_TLV_ORG_MED;
  ------------------
  |  |   53|  1.14k|  {                      \
  |  |   54|  1.14k|    0x00, 0x12, 0xbb     \
  |  |   55|  1.14k|  }
  ------------------
  579|  1.14k|	const char dcbx[] = LLDP_TLV_ORG_DCBX;
  ------------------
  |  |   57|  1.14k|  {                       \
  |  |   58|  1.14k|    0x00, 0x1b, 0x21      \
  |  |   59|  1.14k|  }
  ------------------
  580|  1.14k|	unsigned char orgid[3];
  581|  1.14k|	int length, gotend = 0, ttl_received = 0;
  582|  1.14k|	int tlv_size, tlv_type, tlv_subtype, tlv_count = 0;
  583|  1.14k|	u_int8_t *pos, *tlv;
  584|  1.14k|	char *b;
  585|  1.14k|#ifdef ENABLE_DOT1
  586|  1.14k|	struct lldpd_vlan *vlan = NULL;
  587|  1.14k|	int vlan_len;
  588|  1.14k|	struct lldpd_ppvid *ppvid;
  589|  1.14k|	struct lldpd_pi *pi = NULL;
  590|  1.14k|#endif
  591|  1.14k|	struct lldpd_mgmt *mgmt;
  592|  1.14k|	int af;
  593|  1.14k|	u_int8_t addr_str_length, addr_str_buffer[32] = { 0 };
  594|  1.14k|	u_int8_t addr_family, addr_length, *addr_ptr, iface_subtype;
  595|  1.14k|	u_int32_t iface_number, iface;
  596|  1.14k|	int unrecognized;
  597|  1.14k|#ifdef ENABLE_CUSTOM
  598|  1.14k|	struct lldpd_custom *custom = NULL;
  599|  1.14k|#endif
  600|       |
  601|  1.14k|	log_debug("lldp", "receive LLDP PDU on %s", hardware->h_ifname);
  602|       |
  603|  1.14k|	if ((chassis = calloc(1, sizeof(struct lldpd_chassis))) == NULL) {
  ------------------
  |  Branch (603:6): [True: 0, False: 1.14k]
  ------------------
  604|      0|		log_warn("lldp", "failed to allocate remote chassis");
  605|      0|		return -1;
  606|      0|	}
  607|  1.14k|	TAILQ_INIT(&chassis->c_mgmt);
  ------------------
  |  Branch (607:2): [Folded, False: 1.14k]
  ------------------
  608|  1.14k|	if ((port = calloc(1, sizeof(struct lldpd_port))) == NULL) {
  ------------------
  |  Branch (608:6): [True: 0, False: 1.14k]
  ------------------
  609|      0|		log_warn("lldp", "failed to allocate remote port");
  610|      0|		free(chassis);
  611|      0|		return -1;
  612|      0|	}
  613|  1.14k|#ifdef ENABLE_DOT1
  614|  1.14k|	TAILQ_INIT(&port->p_vlans);
  ------------------
  |  Branch (614:2): [Folded, False: 1.14k]
  ------------------
  615|  1.14k|	TAILQ_INIT(&port->p_ppvids);
  ------------------
  |  Branch (615:2): [Folded, False: 1.14k]
  ------------------
  616|  1.14k|	TAILQ_INIT(&port->p_pids);
  ------------------
  |  Branch (616:2): [Folded, False: 1.14k]
  ------------------
  617|  1.14k|#endif
  618|  1.14k|#ifdef ENABLE_CUSTOM
  619|  1.14k|	TAILQ_INIT(&port->p_custom_list);
  ------------------
  |  Branch (619:2): [Folded, False: 1.14k]
  ------------------
  620|  1.14k|#endif
  621|       |
  622|  1.14k|	length = s;
  623|  1.14k|	pos = (u_int8_t *)frame;
  624|       |
  625|  1.14k|	if (length < 2 * ETHER_ADDR_LEN + sizeof(u_int16_t)) {
  ------------------
  |  Branch (625:6): [True: 7, False: 1.14k]
  ------------------
  626|      7|		log_warnx("lldp", "too short frame received on %s", hardware->h_ifname);
  627|      7|		goto malformed;
  628|      7|	}
  629|  1.14k|	PEEK_BYTES(lldpaddr, ETHER_ADDR_LEN);
  ------------------
  |  |   66|  1.14k|  do {                           \
  |  |   67|  1.14k|    memcpy(value, pos, bytes);   \
  |  |   68|  1.14k|    length -= (bytes);           \
  |  |   69|  1.14k|    pos += (bytes);              \
  |  |   70|  1.14k|  } while (0)
  |  |  ------------------
  |  |  |  Branch (70:12): [Folded, False: 1.14k]
  |  |  ------------------
  ------------------
  630|  1.14k|	if (memcmp(lldpaddr, (const char[])LLDP_ADDR_NEAREST_BRIDGE, ETHER_ADDR_LEN) &&
  ------------------
  |  |   22|  1.14k|  {                                    \
  |  |   23|  1.14k|    0x01, 0x80, 0xc2, 0x00, 0x00, 0x0e \
  |  |   24|  1.14k|  }
  ------------------
  |  Branch (630:6): [True: 708, False: 434]
  ------------------
  631|    708|	    memcmp(lldpaddr, (const char[])LLDP_ADDR_NEAREST_NONTPMR_BRIDGE,
  ------------------
  |  |   26|    708|  {                                      \
  |  |   27|    708|    0x01, 0x80, 0xc2, 0x00, 0x00, 0x03   \
  |  |   28|    708|  }
  ------------------
  |  Branch (631:6): [True: 537, False: 171]
  ------------------
  632|    708|		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: 44, False: 493]
  ------------------
  634|    537|		ETHER_ADDR_LEN)) {
  635|     44|		log_info("lldp",
  636|     44|		    "frame not targeted at LLDP multicast address received on %s",
  637|     44|		    hardware->h_ifname);
  638|     44|		goto malformed;
  639|     44|	}
  640|  1.09k|	PEEK_DISCARD(ETHER_ADDR_LEN); /* Skip source address */
  ------------------
  |  |   72|  1.09k|  do {                      \
  |  |   73|  1.09k|    length -= (bytes);      \
  |  |   74|  1.09k|    pos += (bytes);         \
  |  |   75|  1.09k|  } while (0)
  |  |  ------------------
  |  |  |  Branch (75:12): [Folded, False: 1.09k]
  |  |  ------------------
  ------------------
  641|  1.09k|	if (PEEK_UINT16 != ETH_P_LLDP) {
  ------------------
  |  |   63|  1.09k|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  ------------------
  |  |  |  |   60|  1.09k|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|  1.09k|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   63|  1.09k|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
              	if (PEEK_UINT16 != ETH_P_LLDP) {
  ------------------
  |  |  269|  1.09k|#  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: 745]
  |  Branch (646:19): [True: 17.9k, False: 39]
  ------------------
  647|  17.9k|		if (length < 2) {
  ------------------
  |  Branch (647:7): [True: 77, False: 17.8k]
  ------------------
  648|     77|			log_warnx("lldp", "tlv header too short received on %s",
  649|     77|			    hardware->h_ifname);
  650|     77|			goto malformed;
  651|     77|		}
  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: 41, False: 17.8k]
  ------------------
  657|     41|			log_warnx("lldp", "frame too short for tlv received on %s",
  658|     41|			    hardware->h_ifname);
  659|     41|			goto malformed;
  660|     41|		}
  661|       |		/* Check order for mandatory TLVs */
  662|  17.8k|		tlv_count++;
  663|  17.8k|		switch (tlv_type) {
  ------------------
  |  Branch (663:11): [True: 844, False: 16.9k]
  ------------------
  664|    323|		case LLDP_TLV_CHASSIS_ID:
  ------------------
  |  |   35|    323|#define LLDP_TLV_CHASSIS_ID 1
  ------------------
  |  Branch (664:3): [True: 323, False: 17.4k]
  ------------------
  665|    323|			if (tlv_count != 1) {
  ------------------
  |  Branch (665:8): [True: 13, False: 310]
  ------------------
  666|     13|				log_warnx("lldp",
  667|     13|				    "Chassis ID TLV should be first on %s, but it is on position %d",
  668|     13|				    hardware->h_ifname, tlv_count);
  669|     13|				goto malformed;
  670|     13|			}
  671|    310|			break;
  672|    310|		case LLDP_TLV_PORT_ID:
  ------------------
  |  |   36|    265|#define LLDP_TLV_PORT_ID 2
  ------------------
  |  Branch (672:3): [True: 265, False: 17.5k]
  ------------------
  673|    265|			if (tlv_count != 2) {
  ------------------
  |  Branch (673:8): [True: 9, False: 256]
  ------------------
  674|      9|				log_warnx("lldp",
  675|      9|				    "Port ID TLV should be second on %s, but it is on position %d",
  676|      9|				    hardware->h_ifname, tlv_count);
  677|      9|				goto malformed;
  678|      9|			}
  679|    256|			break;
  680|    256|		case LLDP_TLV_TTL:
  ------------------
  |  |   37|    256|#define LLDP_TLV_TTL 3
  ------------------
  |  Branch (680:3): [True: 256, False: 17.5k]
  ------------------
  681|    256|			if (tlv_count != 3) {
  ------------------
  |  Branch (681:8): [True: 9, False: 247]
  ------------------
  682|      9|				log_warnx("lldp",
  683|      9|				    "TTL TLV should be third on %s, but it is on position %d",
  684|      9|				    hardware->h_ifname, tlv_count);
  685|      9|				goto malformed;
  686|      9|			}
  687|    247|			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: 10, False: 135]
  ------------------
  693|     10|				log_warnx("lldp",
  694|     10|				    "lldp end received with size not null on %s",
  695|     10|				    hardware->h_ifname);
  696|     10|				goto malformed;
  697|     10|			}
  698|    135|			if (length)
  ------------------
  |  Branch (698:8): [True: 39, False: 96]
  ------------------
  699|     39|				log_debug("lldp", "extra data after lldp end on %s",
  700|     39|				    hardware->h_ifname);
  701|    135|			gotend = 1;
  702|    135|			break;
  703|    310|		case LLDP_TLV_CHASSIS_ID:
  ------------------
  |  |   35|    310|#define LLDP_TLV_CHASSIS_ID 1
  ------------------
  |  Branch (703:3): [True: 310, False: 17.4k]
  ------------------
  704|    566|		case LLDP_TLV_PORT_ID:
  ------------------
  |  |   36|    566|#define LLDP_TLV_PORT_ID 2
  ------------------
  |  Branch (704:3): [True: 256, False: 17.5k]
  ------------------
  705|    566|			CHECK_TLV_SIZE(2, "Port/Chassis Id");
  ------------------
  |  |  555|    566|  do {                                                                             \
  |  |  556|    566|    if (tlv_size < (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (556:9): [True: 4, False: 562]
  |  |  ------------------
  |  |  557|      4|      log_warnx("lldp", name " TLV too short received on %s", hardware->h_ifname); \
  |  |  558|      4|      goto malformed;                                                              \
  |  |  559|      4|    }                                                                              \
  |  |  560|    566|  } while (0)
  |  |  ------------------
  |  |  |  Branch (560:12): [Folded, False: 562]
  |  |  ------------------
  ------------------
  706|    562|			CHECK_TLV_MAX_SIZE(256, "Port/Chassis Id");
  ------------------
  |  |  562|    562|  do {                                                                             \
  |  |  563|    562|    if (tlv_size > (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (563:9): [True: 1, False: 561]
  |  |  ------------------
  |  |  564|      1|      log_warnx("lldp", name " TLV too large received on %s", hardware->h_ifname); \
  |  |  565|      1|      goto malformed;                                                              \
  |  |  566|      1|    }                                                                              \
  |  |  567|    562|  } while (0)
  |  |  ------------------
  |  |  |  Branch (567:12): [Folded, False: 561]
  |  |  ------------------
  ------------------
  707|    561|			tlv_subtype = PEEK_UINT8;
  ------------------
  |  |   62|    561|#define PEEK_UINT8 PEEK(types.f_uint8, )
  |  |  ------------------
  |  |  |  |   60|    561|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    561|      func(type))
  |  |  ------------------
  ------------------
  708|    561|			if ((tlv_subtype == 0) || (tlv_subtype > 7)) {
  ------------------
  |  Branch (708:8): [True: 2, False: 559]
  |  Branch (708:30): [True: 18, False: 541]
  ------------------
  709|     20|				log_warnx("lldp",
  710|     20|				    "unknown subtype for tlv id received on %s",
  711|     20|				    hardware->h_ifname);
  712|     20|				goto malformed;
  713|     20|			}
  714|    541|			if ((b = (char *)calloc(1, tlv_size - 1)) == NULL) {
  ------------------
  |  Branch (714:8): [True: 0, False: 541]
  ------------------
  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|    541|			PEEK_BYTES(b, tlv_size - 1);
  ------------------
  |  |   66|    541|  do {                           \
  |  |   67|    541|    memcpy(value, pos, bytes);   \
  |  |   68|    541|    length -= (bytes);           \
  |  |   69|    541|    pos += (bytes);              \
  |  |   70|    541|  } while (0)
  |  |  ------------------
  |  |  |  Branch (70:12): [Folded, False: 541]
  |  |  ------------------
  ------------------
  722|    541|			if (tlv_type == LLDP_TLV_PORT_ID) {
  ------------------
  |  |   36|    541|#define LLDP_TLV_PORT_ID 2
  ------------------
  |  Branch (722:8): [True: 253, False: 288]
  ------------------
  723|    253|				if (port->p_id != NULL) {
  ------------------
  |  Branch (723:9): [True: 0, False: 253]
  ------------------
  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|    253|				port->p_id_subtype = tlv_subtype;
  731|    253|				port->p_id = b;
  732|    253|				port->p_id_len = tlv_size - 1;
  733|    288|			} else {
  734|    288|				if (chassis->c_id != NULL) {
  ------------------
  |  Branch (734:9): [True: 0, False: 288]
  ------------------
  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|    288|				chassis->c_id_subtype = tlv_subtype;
  742|    288|				chassis->c_id = b;
  743|    288|				chassis->c_id_len = tlv_size - 1;
  744|    288|			}
  745|    541|			break;
  746|    541|		case LLDP_TLV_TTL:
  ------------------
  |  |   37|    247|#define LLDP_TLV_TTL 3
  ------------------
  |  Branch (746:3): [True: 247, False: 17.5k]
  ------------------
  747|    247|			if (ttl_received) {
  ------------------
  |  Branch (747:8): [True: 0, False: 247]
  ------------------
  748|      0|				log_warnx("lldp", "TTL TLV received twice on %s",
  749|      0|				    hardware->h_ifname);
  750|      0|				goto malformed;
  751|      0|			}
  752|    247|			CHECK_TLV_SIZE(2, "TTL");
  ------------------
  |  |  555|    247|  do {                                                                             \
  |  |  556|    247|    if (tlv_size < (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (556:9): [True: 2, False: 245]
  |  |  ------------------
  |  |  557|      2|      log_warnx("lldp", name " TLV too short received on %s", hardware->h_ifname); \
  |  |  558|      2|      goto malformed;                                                              \
  |  |  559|      2|    }                                                                              \
  |  |  560|    247|  } while (0)
  |  |  ------------------
  |  |  |  Branch (560:12): [Folded, False: 245]
  |  |  ------------------
  ------------------
  753|    245|			port->p_ttl = PEEK_UINT16;
  ------------------
  |  |   63|    245|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  ------------------
  |  |  |  |   60|    245|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    245|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   63|    245|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  754|    245|			ttl_received = 1;
  755|    245|			break;
  756|    502|		case LLDP_TLV_PORT_DESCR:
  ------------------
  |  |   38|    502|#define LLDP_TLV_PORT_DESCR 4
  ------------------
  |  Branch (756:3): [True: 502, False: 17.2k]
  ------------------
  757|  1.94k|		case LLDP_TLV_SYSTEM_NAME:
  ------------------
  |  |   39|  1.94k|#define LLDP_TLV_SYSTEM_NAME 5
  ------------------
  |  Branch (757:3): [True: 1.44k, False: 16.3k]
  ------------------
  758|  4.85k|		case LLDP_TLV_SYSTEM_DESCR:
  ------------------
  |  |   40|  4.85k|#define LLDP_TLV_SYSTEM_DESCR 6
  ------------------
  |  Branch (758:3): [True: 2.90k, False: 14.8k]
  ------------------
  759|  4.85k|			if (tlv_size < 1) {
  ------------------
  |  Branch (759:8): [True: 4.22k, False: 624]
  ------------------
  760|  4.22k|				log_debug("lldp", "empty tlv received on %s",
  761|  4.22k|				    hardware->h_ifname);
  762|  4.22k|				break;
  763|  4.22k|			}
  764|    624|			if ((b = (char *)calloc(1, tlv_size + 1)) == NULL) {
  ------------------
  |  Branch (764:8): [True: 0, False: 624]
  ------------------
  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|    624|			PEEK_BYTES(b, tlv_size);
  ------------------
  |  |   66|    624|  do {                           \
  |  |   67|    624|    memcpy(value, pos, bytes);   \
  |  |   68|    624|    length -= (bytes);           \
  |  |   69|    624|    pos += (bytes);              \
  |  |   70|    624|  } while (0)
  |  |  ------------------
  |  |  |  Branch (70:12): [Folded, False: 624]
  |  |  ------------------
  ------------------
  772|    624|			switch (tlv_type) {
  773|    201|			case LLDP_TLV_PORT_DESCR:
  ------------------
  |  |   38|    201|#define LLDP_TLV_PORT_DESCR 4
  ------------------
  |  Branch (773:4): [True: 201, False: 423]
  ------------------
  774|    201|				free(port->p_descr);
  775|    201|				port->p_descr = b;
  776|    201|				break;
  777|    220|			case LLDP_TLV_SYSTEM_NAME:
  ------------------
  |  |   39|    220|#define LLDP_TLV_SYSTEM_NAME 5
  ------------------
  |  Branch (777:4): [True: 220, False: 404]
  ------------------
  778|    220|				free(chassis->c_name);
  779|    220|				chassis->c_name = b;
  780|    220|				break;
  781|    203|			case LLDP_TLV_SYSTEM_DESCR:
  ------------------
  |  |   40|    203|#define LLDP_TLV_SYSTEM_DESCR 6
  ------------------
  |  Branch (781:4): [True: 203, False: 421]
  ------------------
  782|    203|				free(chassis->c_descr);
  783|    203|				chassis->c_descr = b;
  784|    203|				break;
  785|      0|			default:
  ------------------
  |  Branch (785:4): [True: 0, False: 624]
  ------------------
  786|       |				/* unreachable */
  787|      0|				free(b);
  788|      0|				break;
  789|    624|			}
  790|    624|			break;
  791|    624|		case LLDP_TLV_SYSTEM_CAP:
  ------------------
  |  |   41|    404|#define LLDP_TLV_SYSTEM_CAP 7
  ------------------
  |  Branch (791:3): [True: 404, False: 17.3k]
  ------------------
  792|    404|			CHECK_TLV_SIZE(4, "System capabilities");
  ------------------
  |  |  555|    404|  do {                                                                             \
  |  |  556|    404|    if (tlv_size < (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (556:9): [True: 12, False: 392]
  |  |  ------------------
  |  |  557|     12|      log_warnx("lldp", name " TLV too short received on %s", hardware->h_ifname); \
  |  |  558|     12|      goto malformed;                                                              \
  |  |  559|     12|    }                                                                              \
  |  |  560|    404|  } while (0)
  |  |  ------------------
  |  |  |  Branch (560:12): [Folded, False: 392]
  |  |  ------------------
  ------------------
  793|    392|			chassis->c_cap_available = PEEK_UINT16;
  ------------------
  |  |   63|    392|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  ------------------
  |  |  |  |   60|    392|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    392|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   63|    392|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  794|    392|			chassis->c_cap_enabled = PEEK_UINT16;
  ------------------
  |  |   63|    392|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  ------------------
  |  |  |  |   60|    392|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    392|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   63|    392|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  795|    392|			break;
  796|    928|		case LLDP_TLV_MGMT_ADDR:
  ------------------
  |  |   42|    928|#define LLDP_TLV_MGMT_ADDR 8
  ------------------
  |  Branch (796:3): [True: 928, False: 16.8k]
  ------------------
  797|    928|			CHECK_TLV_SIZE(1, "Management address");
  ------------------
  |  |  555|    928|  do {                                                                             \
  |  |  556|    928|    if (tlv_size < (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (556:9): [True: 5, False: 923]
  |  |  ------------------
  |  |  557|      5|      log_warnx("lldp", name " TLV too short received on %s", hardware->h_ifname); \
  |  |  558|      5|      goto malformed;                                                              \
  |  |  559|      5|    }                                                                              \
  |  |  560|    928|  } while (0)
  |  |  ------------------
  |  |  |  Branch (560:12): [Folded, False: 923]
  |  |  ------------------
  ------------------
  798|    923|			addr_str_length = PEEK_UINT8;
  ------------------
  |  |   62|    923|#define PEEK_UINT8 PEEK(types.f_uint8, )
  |  |  ------------------
  |  |  |  |   60|    923|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    923|      func(type))
  |  |  ------------------
  ------------------
  799|    923|			if (addr_str_length < 1 ||
  ------------------
  |  Branch (799:8): [True: 6, False: 917]
  ------------------
  800|    917|			    addr_str_length > sizeof(addr_str_buffer)) {
  ------------------
  |  Branch (800:8): [True: 7, False: 910]
  ------------------
  801|     13|				log_warnx("lldp",
  802|     13|				    "invalid management address length on %s",
  803|     13|				    hardware->h_ifname);
  804|     13|				goto malformed;
  805|     13|			}
  806|    910|			CHECK_TLV_SIZE(1 + addr_str_length, "Management address");
  ------------------
  |  |  555|    910|  do {                                                                             \
  |  |  556|    910|    if (tlv_size < (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (556:9): [True: 6, False: 904]
  |  |  ------------------
  |  |  557|      6|      log_warnx("lldp", name " TLV too short received on %s", hardware->h_ifname); \
  |  |  558|      6|      goto malformed;                                                              \
  |  |  559|      6|    }                                                                              \
  |  |  560|    910|  } while (0)
  |  |  ------------------
  |  |  |  Branch (560:12): [Folded, False: 904]
  |  |  ------------------
  ------------------
  807|    904|			PEEK_BYTES(addr_str_buffer, addr_str_length);
  ------------------
  |  |   66|    904|  do {                           \
  |  |   67|    904|    memcpy(value, pos, bytes);   \
  |  |   68|    904|    length -= (bytes);           \
  |  |   69|    904|    pos += (bytes);              \
  |  |   70|    904|  } while (0)
  |  |  ------------------
  |  |  |  Branch (70:12): [Folded, False: 904]
  |  |  ------------------
  ------------------
  808|    904|			addr_length = addr_str_length - 1;
  809|    904|			addr_family = addr_str_buffer[0];
  810|    904|			addr_ptr = &addr_str_buffer[1];
  811|    904|			CHECK_TLV_SIZE(1 + addr_str_length + 5, "Management address");
  ------------------
  |  |  555|    904|  do {                                                                             \
  |  |  556|    904|    if (tlv_size < (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (556:9): [True: 5, False: 899]
  |  |  ------------------
  |  |  557|      5|      log_warnx("lldp", name " TLV too short received on %s", hardware->h_ifname); \
  |  |  558|      5|      goto malformed;                                                              \
  |  |  559|      5|    }                                                                              \
  |  |  560|    904|  } while (0)
  |  |  ------------------
  |  |  |  Branch (560:12): [Folded, False: 899]
  |  |  ------------------
  ------------------
  812|    899|			iface_subtype = PEEK_UINT8;
  ------------------
  |  |   62|    899|#define PEEK_UINT8 PEEK(types.f_uint8, )
  |  |  ------------------
  |  |  |  |   60|    899|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    899|      func(type))
  |  |  ------------------
  ------------------
  813|    899|			iface_number = PEEK_UINT32;
  ------------------
  |  |   64|    899|#define PEEK_UINT32 PEEK(types.f_uint32, ntohl)
  |  |  ------------------
  |  |  |  |   60|    899|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    899|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|    899|#define PEEK_UINT32 PEEK(types.f_uint32, ntohl)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  814|       |
  815|    899|			af = lldpd_af_from_lldp_proto(addr_family);
  816|    899|			if (af == LLDPD_AF_UNSPEC) break;
  ------------------
  |  Branch (816:8): [True: 231, False: 668]
  ------------------
  817|    668|			if (iface_subtype == LLDP_MGMT_IFACE_IFINDEX)
  ------------------
  |  |  277|    668|#define LLDP_MGMT_IFACE_IFINDEX 2
  ------------------
  |  Branch (817:8): [True: 389, False: 279]
  ------------------
  818|    389|				iface = iface_number;
  819|    279|			else
  820|    279|				iface = 0;
  821|    668|			mgmt = lldpd_alloc_mgmt(af, addr_ptr, addr_length, iface);
  822|    668|			if (mgmt == NULL) {
  ------------------
  |  Branch (822:8): [True: 1, False: 667]
  ------------------
  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|    668|			TAILQ_INSERT_TAIL(&chassis->c_mgmt, mgmt, m_entries);
  ------------------
  |  Branch (834:4): [Folded, False: 667]
  ------------------
  835|    667|			break;
  836|  10.0k|		case LLDP_TLV_ORG:
  ------------------
  |  |   26|  10.0k|#define LLDP_TLV_ORG 127
  ------------------
  |  Branch (836:3): [True: 10.0k, False: 7.76k]
  ------------------
  837|  10.0k|			CHECK_TLV_SIZE(1 + (int)sizeof(orgid), "Organisational");
  ------------------
  |  |  555|  10.0k|  do {                                                                             \
  |  |  556|  10.0k|    if (tlv_size < (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (556:9): [True: 12, False: 10.0k]
  |  |  ------------------
  |  |  557|     12|      log_warnx("lldp", name " TLV too short received on %s", hardware->h_ifname); \
  |  |  558|     12|      goto malformed;                                                              \
  |  |  559|     12|    }                                                                              \
  |  |  560|  10.0k|  } while (0)
  |  |  ------------------
  |  |  |  Branch (560:12): [Folded, False: 10.0k]
  |  |  ------------------
  ------------------
  838|  10.0k|			PEEK_BYTES(orgid, sizeof(orgid));
  ------------------
  |  |   66|  10.0k|  do {                           \
  |  |   67|  10.0k|    memcpy(value, pos, bytes);   \
  |  |   68|  10.0k|    length -= (bytes);           \
  |  |   69|  10.0k|    pos += (bytes);              \
  |  |   70|  10.0k|  } while (0)
  |  |  ------------------
  |  |  |  Branch (70:12): [Folded, False: 10.0k]
  |  |  ------------------
  ------------------
  839|  10.0k|			unrecognized = 0;
  840|  10.0k|			tlv_subtype = PEEK_UINT8;
  ------------------
  |  |   62|  10.0k|#define PEEK_UINT8 PEEK(types.f_uint8, )
  |  |  ------------------
  |  |  |  |   60|  10.0k|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|  10.0k|      func(type))
  |  |  ------------------
  ------------------
  841|  10.0k|			if (memcmp(dot1, orgid, sizeof(orgid)) == 0) {
  ------------------
  |  Branch (841:8): [True: 1.83k, False: 8.18k]
  ------------------
  842|       |#ifndef ENABLE_DOT1
  843|       |				unrecognized = 1;
  844|       |#else
  845|       |				/* Dot1 */
  846|  1.83k|				switch (tlv_subtype) {
  847|    286|				case LLDP_TLV_DOT1_VLANNAME:
  ------------------
  |  |   63|    286|#define LLDP_TLV_DOT1_VLANNAME 3
  ------------------
  |  Branch (847:5): [True: 286, False: 1.54k]
  ------------------
  848|    286|					CHECK_TLV_SIZE(7, "VLAN");
  ------------------
  |  |  555|    286|  do {                                                                             \
  |  |  556|    286|    if (tlv_size < (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (556:9): [True: 3, False: 283]
  |  |  ------------------
  |  |  557|      3|      log_warnx("lldp", name " TLV too short received on %s", hardware->h_ifname); \
  |  |  558|      3|      goto malformed;                                                              \
  |  |  559|      3|    }                                                                              \
  |  |  560|    286|  } while (0)
  |  |  ------------------
  |  |  |  Branch (560:12): [Folded, False: 283]
  |  |  ------------------
  ------------------
  849|    283|					if ((vlan = (struct lldpd_vlan *)calloc(1,
  ------------------
  |  Branch (849:10): [True: 0, False: 283]
  ------------------
  850|    283|						 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|    283|					vlan->v_vid = PEEK_UINT16;
  ------------------
  |  |   63|    283|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  ------------------
  |  |  |  |   60|    283|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    283|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   63|    283|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  859|    283|					vlan_len = PEEK_UINT8;
  ------------------
  |  |   62|    283|#define PEEK_UINT8 PEEK(types.f_uint8, )
  |  |  ------------------
  |  |  |  |   60|    283|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    283|      func(type))
  |  |  ------------------
  ------------------
  860|    283|					CHECK_TLV_SIZE(7 + vlan_len, "VLAN");
  ------------------
  |  |  555|    283|  do {                                                                             \
  |  |  556|    283|    if (tlv_size < (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (556:9): [True: 10, False: 273]
  |  |  ------------------
  |  |  557|     10|      log_warnx("lldp", name " TLV too short received on %s", hardware->h_ifname); \
  |  |  558|     10|      goto malformed;                                                              \
  |  |  559|     10|    }                                                                              \
  |  |  560|    283|  } while (0)
  |  |  ------------------
  |  |  |  Branch (560:12): [Folded, False: 273]
  |  |  ------------------
  ------------------
  861|    273|					if ((vlan->v_name = (char *)calloc(1,
  ------------------
  |  Branch (861:10): [True: 0, False: 273]
  ------------------
  862|    273|						 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|    273|					PEEK_BYTES(vlan->v_name, vlan_len);
  ------------------
  |  |   66|    273|  do {                           \
  |  |   67|    273|    memcpy(value, pos, bytes);   \
  |  |   68|    273|    length -= (bytes);           \
  |  |   69|    273|    pos += (bytes);              \
  |  |   70|    273|  } while (0)
  |  |  ------------------
  |  |  |  Branch (70:12): [Folded, False: 273]
  |  |  ------------------
  ------------------
  870|    273|					TAILQ_INSERT_TAIL(&port->p_vlans, vlan,
  ------------------
  |  Branch (870:6): [Folded, False: 273]
  ------------------
  871|    273|					    v_entries);
  872|    273|					vlan = NULL;
  873|    273|					break;
  874|    239|				case LLDP_TLV_DOT1_PVID:
  ------------------
  |  |   61|    239|#define LLDP_TLV_DOT1_PVID 1
  ------------------
  |  Branch (874:5): [True: 239, False: 1.59k]
  ------------------
  875|    239|					CHECK_TLV_SIZE(6, "PVID");
  ------------------
  |  |  555|    239|  do {                                                                             \
  |  |  556|    239|    if (tlv_size < (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (556:9): [True: 2, False: 237]
  |  |  ------------------
  |  |  557|      2|      log_warnx("lldp", name " TLV too short received on %s", hardware->h_ifname); \
  |  |  558|      2|      goto malformed;                                                              \
  |  |  559|      2|    }                                                                              \
  |  |  560|    239|  } while (0)
  |  |  ------------------
  |  |  |  Branch (560:12): [Folded, False: 237]
  |  |  ------------------
  ------------------
  876|    237|					port->p_pvid = PEEK_UINT16;
  ------------------
  |  |   63|    237|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  ------------------
  |  |  |  |   60|    237|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    237|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   63|    237|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  877|    237|					break;
  878|    397|				case LLDP_TLV_DOT1_PPVID:
  ------------------
  |  |   62|    397|#define LLDP_TLV_DOT1_PPVID 2
  ------------------
  |  Branch (878:5): [True: 397, False: 1.43k]
  ------------------
  879|    397|					CHECK_TLV_SIZE(7, "PPVID");
  ------------------
  |  |  555|    397|  do {                                                                             \
  |  |  556|    397|    if (tlv_size < (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (556:9): [True: 2, False: 395]
  |  |  ------------------
  |  |  557|      2|      log_warnx("lldp", name " TLV too short received on %s", hardware->h_ifname); \
  |  |  558|      2|      goto malformed;                                                              \
  |  |  559|      2|    }                                                                              \
  |  |  560|    397|  } while (0)
  |  |  ------------------
  |  |  |  Branch (560:12): [Folded, False: 395]
  |  |  ------------------
  ------------------
  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|    395|					if ((ppvid = (struct lldpd_ppvid *)calloc(1,
  ------------------
  |  Branch (888:10): [True: 0, False: 395]
  ------------------
  889|    395|						 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|    395|					ppvid->p_cap_status = PEEK_UINT8;
  ------------------
  |  |   62|    395|#define PEEK_UINT8 PEEK(types.f_uint8, )
  |  |  ------------------
  |  |  |  |   60|    395|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    395|      func(type))
  |  |  ------------------
  ------------------
  898|    395|					ppvid->p_ppvid = PEEK_UINT16;
  ------------------
  |  |   63|    395|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  ------------------
  |  |  |  |   60|    395|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    395|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   63|    395|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  899|    395|					TAILQ_INSERT_TAIL(&port->p_ppvids, ppvid,
  ------------------
  |  Branch (899:6): [Folded, False: 395]
  ------------------
  900|    395|					    p_entries);
  901|    395|					break;
  902|    410|				case LLDP_TLV_DOT1_PI:
  ------------------
  |  |   64|    410|#define LLDP_TLV_DOT1_PI 4
  ------------------
  |  Branch (902:5): [True: 410, 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|    410|					CHECK_TLV_SIZE(5, "PI");
  ------------------
  |  |  555|    410|  do {                                                                             \
  |  |  556|    410|    if (tlv_size < (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (556:9): [True: 1, False: 409]
  |  |  ------------------
  |  |  557|      1|      log_warnx("lldp", name " TLV too short received on %s", hardware->h_ifname); \
  |  |  558|      1|      goto malformed;                                                              \
  |  |  559|      1|    }                                                                              \
  |  |  560|    410|  } while (0)
  |  |  ------------------
  |  |  |  Branch (560:12): [Folded, False: 409]
  |  |  ------------------
  ------------------
  908|    409|					if ((pi = (struct lldpd_pi *)calloc(1,
  ------------------
  |  Branch (908:10): [True: 0, False: 409]
  ------------------
  909|    409|						 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|    409|					pi->p_pi_len = PEEK_UINT8;
  ------------------
  |  |   62|    409|#define PEEK_UINT8 PEEK(types.f_uint8, )
  |  |  ------------------
  |  |  |  |   60|    409|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    409|      func(type))
  |  |  ------------------
  ------------------
  918|    409|					CHECK_TLV_SIZE(5 + pi->p_pi_len, "PI");
  ------------------
  |  |  555|    409|  do {                                                                             \
  |  |  556|    409|    if (tlv_size < (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (556:9): [True: 9, False: 400]
  |  |  ------------------
  |  |  557|      9|      log_warnx("lldp", name " TLV too short received on %s", hardware->h_ifname); \
  |  |  558|      9|      goto malformed;                                                              \
  |  |  559|      9|    }                                                                              \
  |  |  560|    409|  } while (0)
  |  |  ------------------
  |  |  |  Branch (560:12): [Folded, False: 400]
  |  |  ------------------
  ------------------
  919|    400|					if ((pi->p_pi = (char *)calloc(1,
  ------------------
  |  Branch (919:10): [True: 0, False: 400]
  ------------------
  920|    400|						 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|    400|					PEEK_BYTES(pi->p_pi, pi->p_pi_len);
  ------------------
  |  |   66|    400|  do {                           \
  |  |   67|    400|    memcpy(value, pos, bytes);   \
  |  |   68|    400|    length -= (bytes);           \
  |  |   69|    400|    pos += (bytes);              \
  |  |   70|    400|  } while (0)
  |  |  ------------------
  |  |  |  Branch (70:12): [Folded, False: 400]
  |  |  ------------------
  ------------------
  928|    400|					TAILQ_INSERT_TAIL(&port->p_pids, pi, p_entries);
  ------------------
  |  Branch (928:6): [Folded, False: 400]
  ------------------
  929|    400|					pi = NULL;
  930|    400|					break;
  931|    499|				default:
  ------------------
  |  Branch (931:5): [True: 499, False: 1.33k]
  ------------------
  932|       |					/* Unknown Dot1 TLV, ignore it */
  933|    499|					unrecognized = 1;
  934|  1.83k|				}
  935|  1.83k|#endif
  936|  8.18k|			} else if (memcmp(dot3, orgid, sizeof(orgid)) == 0) {
  ------------------
  |  Branch (936:15): [True: 1.40k, False: 6.78k]
  ------------------
  937|       |#ifndef ENABLE_DOT3
  938|       |				unrecognized = 1;
  939|       |#else
  940|       |				/* Dot3 */
  941|  1.40k|				switch (tlv_subtype) {
  942|    196|				case LLDP_TLV_DOT3_MAC:
  ------------------
  |  |   66|    196|#define LLDP_TLV_DOT3_MAC 1
  ------------------
  |  Branch (942:5): [True: 196, False: 1.20k]
  ------------------
  943|    196|					CHECK_TLV_SIZE(9, "MAC/PHY");
  ------------------
  |  |  555|    196|  do {                                                                             \
  |  |  556|    196|    if (tlv_size < (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (556:9): [True: 1, False: 195]
  |  |  ------------------
  |  |  557|      1|      log_warnx("lldp", name " TLV too short received on %s", hardware->h_ifname); \
  |  |  558|      1|      goto malformed;                                                              \
  |  |  559|      1|    }                                                                              \
  |  |  560|    196|  } while (0)
  |  |  ------------------
  |  |  |  Branch (560:12): [Folded, False: 195]
  |  |  ------------------
  ------------------
  944|    195|					port->p_macphy.autoneg_support = PEEK_UINT8;
  ------------------
  |  |   62|    195|#define PEEK_UINT8 PEEK(types.f_uint8, )
  |  |  ------------------
  |  |  |  |   60|    195|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    195|      func(type))
  |  |  ------------------
  ------------------
  945|    195|					port->p_macphy.autoneg_enabled =
  946|    195|					    (port->p_macphy.autoneg_support & 0x2) >> 1;
  947|    195|					port->p_macphy.autoneg_support =
  948|    195|					    port->p_macphy.autoneg_support & 0x1;
  949|    195|					port->p_macphy.autoneg_advertised = PEEK_UINT16;
  ------------------
  |  |   63|    195|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  ------------------
  |  |  |  |   60|    195|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    195|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   63|    195|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  950|    195|					port->p_macphy.mau_type = PEEK_UINT16;
  ------------------
  |  |   63|    195|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  ------------------
  |  |  |  |   60|    195|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    195|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   63|    195|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  951|    195|					break;
  952|    204|				case LLDP_TLV_DOT3_LA:
  ------------------
  |  |   68|    204|#define LLDP_TLV_DOT3_LA 3
  ------------------
  |  Branch (952:5): [True: 204, False: 1.19k]
  ------------------
  953|    204|					CHECK_TLV_SIZE(9, "Link aggregation");
  ------------------
  |  |  555|    204|  do {                                                                             \
  |  |  556|    204|    if (tlv_size < (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (556:9): [True: 4, False: 200]
  |  |  ------------------
  |  |  557|      4|      log_warnx("lldp", name " TLV too short received on %s", hardware->h_ifname); \
  |  |  558|      4|      goto malformed;                                                              \
  |  |  559|      4|    }                                                                              \
  |  |  560|    204|  } while (0)
  |  |  ------------------
  |  |  |  Branch (560:12): [Folded, False: 200]
  |  |  ------------------
  ------------------
  954|    200|					PEEK_DISCARD_UINT8;
  ------------------
  |  |   76|    200|#define PEEK_DISCARD_UINT8 PEEK_DISCARD(1)
  |  |  ------------------
  |  |  |  |   72|    200|  do {                      \
  |  |  |  |   73|    200|    length -= (bytes);      \
  |  |  |  |   74|    200|    pos += (bytes);         \
  |  |  |  |   75|    200|  } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (75:12): [Folded, False: 200]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  955|    200|					port->p_aggregid = PEEK_UINT32;
  ------------------
  |  |   64|    200|#define PEEK_UINT32 PEEK(types.f_uint32, ntohl)
  |  |  ------------------
  |  |  |  |   60|    200|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    200|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|    200|#define PEEK_UINT32 PEEK(types.f_uint32, ntohl)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  956|    200|					break;
  957|    226|				case LLDP_TLV_DOT3_MFS:
  ------------------
  |  |   69|    226|#define LLDP_TLV_DOT3_MFS 4
  ------------------
  |  Branch (957:5): [True: 226, False: 1.17k]
  ------------------
  958|    226|					CHECK_TLV_SIZE(6, "MFS");
  ------------------
  |  |  555|    226|  do {                                                                             \
  |  |  556|    226|    if (tlv_size < (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (556:9): [True: 3, False: 223]
  |  |  ------------------
  |  |  557|      3|      log_warnx("lldp", name " TLV too short received on %s", hardware->h_ifname); \
  |  |  558|      3|      goto malformed;                                                              \
  |  |  559|      3|    }                                                                              \
  |  |  560|    226|  } while (0)
  |  |  ------------------
  |  |  |  Branch (560:12): [Folded, False: 223]
  |  |  ------------------
  ------------------
  959|    223|					port->p_mfs = PEEK_UINT16;
  ------------------
  |  |   63|    223|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  ------------------
  |  |  |  |   60|    223|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    223|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   63|    223|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  960|    223|					break;
  961|    490|				case LLDP_TLV_DOT3_POWER:
  ------------------
  |  |   67|    490|#define LLDP_TLV_DOT3_POWER 2
  ------------------
  |  Branch (961:5): [True: 490, False: 912]
  ------------------
  962|    490|					CHECK_TLV_SIZE(7, "Power");
  ------------------
  |  |  555|    490|  do {                                                                             \
  |  |  556|    490|    if (tlv_size < (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (556:9): [True: 3, False: 487]
  |  |  ------------------
  |  |  557|      3|      log_warnx("lldp", name " TLV too short received on %s", hardware->h_ifname); \
  |  |  558|      3|      goto malformed;                                                              \
  |  |  559|      3|    }                                                                              \
  |  |  560|    490|  } while (0)
  |  |  ------------------
  |  |  |  Branch (560:12): [Folded, False: 487]
  |  |  ------------------
  ------------------
  963|    487|					port->p_power.devicetype = PEEK_UINT8;
  ------------------
  |  |   62|    487|#define PEEK_UINT8 PEEK(types.f_uint8, )
  |  |  ------------------
  |  |  |  |   60|    487|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    487|      func(type))
  |  |  ------------------
  ------------------
  964|    487|					port->p_power.supported =
  965|    487|					    (port->p_power.devicetype & 0x2) >> 1;
  966|    487|					port->p_power.enabled =
  967|    487|					    (port->p_power.devicetype & 0x4) >> 2;
  968|    487|					port->p_power.paircontrol =
  969|    487|					    (port->p_power.devicetype & 0x8) >> 3;
  970|    487|					port->p_power.devicetype =
  971|    487|					    (port->p_power.devicetype & 0x1) ?
  ------------------
  |  Branch (971:10): [True: 103, False: 384]
  ------------------
  972|    103|					    LLDP_DOT3_POWER_PSE :
  ------------------
  |  |  204|    103|#define LLDP_DOT3_POWER_PSE 1
  ------------------
  973|    487|					    LLDP_DOT3_POWER_PD;
  ------------------
  |  |  205|    871|#define LLDP_DOT3_POWER_PD 2
  ------------------
  974|    487|					port->p_power.pairs = PEEK_UINT8;
  ------------------
  |  |   62|    487|#define PEEK_UINT8 PEEK(types.f_uint8, )
  |  |  ------------------
  |  |  |  |   60|    487|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    487|      func(type))
  |  |  ------------------
  ------------------
  975|    487|					port->p_power.class = PEEK_UINT8;
  ------------------
  |  |   62|    487|#define PEEK_UINT8 PEEK(types.f_uint8, )
  |  |  ------------------
  |  |  |  |   60|    487|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    487|      func(type))
  |  |  ------------------
  ------------------
  976|       |					/* 802.3at? */
  977|    487|					if (tlv_size >= 12) {
  ------------------
  |  Branch (977:10): [True: 289, False: 198]
  ------------------
  978|    289|						port->p_power.powertype = PEEK_UINT8;
  ------------------
  |  |   62|    289|#define PEEK_UINT8 PEEK(types.f_uint8, )
  |  |  ------------------
  |  |  |  |   60|    289|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    289|      func(type))
  |  |  ------------------
  ------------------
  979|    289|						port->p_power.source =
  980|    289|						    (port->p_power.powertype &
  981|    289|							(1 << 5 | 1 << 4)) >>
  982|    289|						    4;
  983|    289|						port->p_power.priority =
  984|    289|						    (port->p_power.powertype &
  985|    289|							(1 << 1 | 1 << 0));
  986|    289|						port->p_power.powertype =
  987|    289|						    (port->p_power.powertype &
  ------------------
  |  Branch (987:11): [True: 109, False: 180]
  ------------------
  988|    289|							(1 << 7)) ?
  989|    109|						    LLDP_DOT3_POWER_8023AT_TYPE1 :
  ------------------
  |  |  213|    109|#define LLDP_DOT3_POWER_8023AT_TYPE1 1
  ------------------
  990|    289|						    LLDP_DOT3_POWER_8023AT_TYPE2;
  ------------------
  |  |  214|    469|#define LLDP_DOT3_POWER_8023AT_TYPE2 2
  ------------------
  991|    289|						port->p_power.requested = PEEK_UINT16;
  ------------------
  |  |   63|    289|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  ------------------
  |  |  |  |   60|    289|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    289|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   63|    289|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  992|    289|						port->p_power.allocated = PEEK_UINT16;
  ------------------
  |  |   63|    289|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  ------------------
  |  |  |  |   60|    289|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    289|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   63|    289|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  993|    289|					} 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|    487|					if (tlv_size >= 29) {
  ------------------
  |  Branch (997:10): [True: 77, False: 410]
  ------------------
  998|     77|						port->p_power.requested_a = PEEK_UINT16;
  ------------------
  |  |   63|     77|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  ------------------
  |  |  |  |   60|     77|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|     77|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   63|     77|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  999|     77|						port->p_power.requested_b = PEEK_UINT16;
  ------------------
  |  |   63|     77|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  ------------------
  |  |  |  |   60|     77|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|     77|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   63|     77|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1000|     77|						port->p_power.allocated_a = PEEK_UINT16;
  ------------------
  |  |   63|     77|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  ------------------
  |  |  |  |   60|     77|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|     77|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   63|     77|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1001|     77|						port->p_power.allocated_b = PEEK_UINT16;
  ------------------
  |  |   63|     77|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  ------------------
  |  |  |  |   60|     77|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|     77|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   63|     77|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1002|     77|						port->p_power.pse_status = PEEK_UINT16;
  ------------------
  |  |   63|     77|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  ------------------
  |  |  |  |   60|     77|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|     77|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   63|     77|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1003|     77|						port->p_power.pd_status =
 1004|     77|						    (port->p_power.pse_status &
 1005|     77|							(1 << 13 | 1 << 12)) >>
 1006|     77|						    12;
 1007|     77|						port->p_power.pse_pairs_ext =
 1008|     77|						    (port->p_power.pse_status &
 1009|     77|							(1 << 11 | 1 << 10)) >>
 1010|     77|						    10;
 1011|     77|						port->p_power.class_a =
 1012|     77|						    (port->p_power.pse_status &
 1013|     77|							(1 << 9 | 1 << 8 | 1 << 7)) >>
 1014|     77|						    7;
 1015|     77|						port->p_power.class_b =
 1016|     77|						    (port->p_power.pse_status &
 1017|     77|							(1 << 6 | 1 << 5 | 1 << 4)) >>
 1018|     77|						    4;
 1019|     77|						port->p_power.class_ext =
 1020|     77|						    (port->p_power.pse_status & 0xf);
 1021|     77|						port->p_power.pse_status =
 1022|     77|						    (port->p_power.pse_status &
 1023|     77|							(1 << 15 | 1 << 14)) >>
 1024|     77|						    14;
 1025|     77|						port->p_power.type_ext = PEEK_UINT8;
  ------------------
  |  |   62|     77|#define PEEK_UINT8 PEEK(types.f_uint8, )
  |  |  ------------------
  |  |  |  |   60|     77|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|     77|      func(type))
  |  |  ------------------
  ------------------
 1026|     77|						port->p_power.pd_load =
 1027|     77|						    (port->p_power.type_ext & 0x1);
 1028|     77|						port->p_power.type_ext =
 1029|     77|						    ((port->p_power.type_ext &
 1030|     77|							 (1 << 3 | 1 << 2 | 1 << 1)) +
 1031|     77|							1);
 1032|     77|						port->p_power.pse_max = PEEK_UINT16;
  ------------------
  |  |   63|     77|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  ------------------
  |  |  |  |   60|     77|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|     77|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   63|     77|#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|    487|					break;
 1038|    286|				default:
  ------------------
  |  Branch (1038:5): [True: 286, False: 1.11k]
  ------------------
 1039|       |					/* Unknown Dot3 TLV, ignore it */
 1040|    286|					unrecognized = 1;
 1041|  1.40k|				}
 1042|  1.40k|#endif
 1043|  6.78k|			} else if (memcmp(med, orgid, sizeof(orgid)) == 0) {
  ------------------
  |  Branch (1043:15): [True: 5.55k, False: 1.22k]
  ------------------
 1044|       |				/* LLDP-MED */
 1045|       |#ifndef ENABLE_LLDPMED
 1046|       |				unrecognized = 1;
 1047|       |#else
 1048|  5.55k|				u_int32_t policy;
 1049|  5.55k|				unsigned loctype;
 1050|  5.55k|				unsigned power;
 1051|       |
 1052|  5.55k|				switch (tlv_subtype) {
 1053|    235|				case LLDP_TLV_MED_CAP:
  ------------------
  |  |   71|    235|#define LLDP_TLV_MED_CAP 1
  ------------------
  |  Branch (1053:5): [True: 235, False: 5.31k]
  ------------------
 1054|    235|					CHECK_TLV_SIZE(7, "LLDP-MED capabilities");
  ------------------
  |  |  555|    235|  do {                                                                             \
  |  |  556|    235|    if (tlv_size < (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (556:9): [True: 1, False: 234]
  |  |  ------------------
  |  |  557|      1|      log_warnx("lldp", name " TLV too short received on %s", hardware->h_ifname); \
  |  |  558|      1|      goto malformed;                                                              \
  |  |  559|      1|    }                                                                              \
  |  |  560|    235|  } while (0)
  |  |  ------------------
  |  |  |  Branch (560:12): [Folded, False: 234]
  |  |  ------------------
  ------------------
 1055|    234|					chassis->c_med_cap_available = PEEK_UINT16;
  ------------------
  |  |   63|    234|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  ------------------
  |  |  |  |   60|    234|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    234|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   63|    234|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1056|    234|					chassis->c_med_type = PEEK_UINT8;
  ------------------
  |  |   62|    234|#define PEEK_UINT8 PEEK(types.f_uint8, )
  |  |  ------------------
  |  |  |  |   60|    234|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    234|      func(type))
  |  |  ------------------
  ------------------
 1057|    234|					port->p_med_cap_enabled |= LLDP_MED_CAP_CAP;
  ------------------
  |  |  329|    234|#define LLDP_MED_CAP_CAP 0x01
  ------------------
 1058|    234|					break;
 1059|    727|				case LLDP_TLV_MED_POLICY:
  ------------------
  |  |   72|    727|#define LLDP_TLV_MED_POLICY 2
  ------------------
  |  Branch (1059:5): [True: 727, False: 4.82k]
  ------------------
 1060|    727|					CHECK_TLV_SIZE(8, "LLDP-MED policy");
  ------------------
  |  |  555|    727|  do {                                                                             \
  |  |  556|    727|    if (tlv_size < (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (556:9): [True: 3, False: 724]
  |  |  ------------------
  |  |  557|      3|      log_warnx("lldp", name " TLV too short received on %s", hardware->h_ifname); \
  |  |  558|      3|      goto malformed;                                                              \
  |  |  559|      3|    }                                                                              \
  |  |  560|    727|  } while (0)
  |  |  ------------------
  |  |  |  Branch (560:12): [Folded, False: 724]
  |  |  ------------------
  ------------------
 1061|    724|					policy = PEEK_UINT32;
  ------------------
  |  |   64|    724|#define PEEK_UINT32 PEEK(types.f_uint32, ntohl)
  |  |  ------------------
  |  |  |  |   60|    724|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    724|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|    724|#define PEEK_UINT32 PEEK(types.f_uint32, ntohl)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1062|    724|					if (((policy >> 24) < 1) ||
  ------------------
  |  Branch (1062:10): [True: 242, False: 482]
  ------------------
 1063|    487|					    ((policy >> 24) > LLDP_MED_APPTYPE_LAST)) {
  ------------------
  |  |  295|    482|#define LLDP_MED_APPTYPE_LAST LLDP_MED_APPTYPE_VIDEOSIGNAL
  |  |  ------------------
  |  |  |  |  294|    482|#define LLDP_MED_APPTYPE_VIDEOSIGNAL 8
  |  |  ------------------
  ------------------
  |  Branch (1063:10): [True: 245, False: 237]
  ------------------
 1064|    487|						log_info("lldp",
 1065|    487|						    "unknown policy field %d "
 1066|    487|						    "received on %s",
 1067|    487|						    policy, hardware->h_ifname);
 1068|    487|						break;
 1069|    487|					}
 1070|    237|					port->p_med_policy[(policy >> 24) - 1].type =
 1071|    237|					    (policy >> 24);
 1072|    237|					port->p_med_policy[(policy >> 24) - 1].unknown =
 1073|    237|					    ((policy & 0x800000) != 0);
 1074|    237|					port->p_med_policy[(policy >> 24) - 1].tagged =
 1075|    237|					    ((policy & 0x400000) != 0);
 1076|    237|					port->p_med_policy[(policy >> 24) - 1].vid =
 1077|    237|					    (policy & 0x001FFE00) >> 9;
 1078|    237|					port->p_med_policy[(policy >> 24) - 1]
 1079|    237|					    .priority = (policy & 0x1C0) >> 6;
 1080|    237|					port->p_med_policy[(policy >> 24) - 1].dscp =
 1081|    237|					    policy & 0x3F;
 1082|    237|					port->p_med_cap_enabled |= LLDP_MED_CAP_POLICY;
  ------------------
  |  |  330|    237|#define LLDP_MED_CAP_POLICY 0x02
  ------------------
 1083|    237|					break;
 1084|    600|				case LLDP_TLV_MED_LOCATION:
  ------------------
  |  |   73|    600|#define LLDP_TLV_MED_LOCATION 3
  ------------------
  |  Branch (1084:5): [True: 600, False: 4.95k]
  ------------------
 1085|    600|					CHECK_TLV_SIZE(5, "LLDP-MED Location");
  ------------------
  |  |  555|    600|  do {                                                                             \
  |  |  556|    600|    if (tlv_size < (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (556:9): [True: 1, False: 599]
  |  |  ------------------
  |  |  557|      1|      log_warnx("lldp", name " TLV too short received on %s", hardware->h_ifname); \
  |  |  558|      1|      goto malformed;                                                              \
  |  |  559|      1|    }                                                                              \
  |  |  560|    600|  } while (0)
  |  |  ------------------
  |  |  |  Branch (560:12): [Folded, False: 599]
  |  |  ------------------
  ------------------
 1086|    599|					loctype = PEEK_UINT8;
  ------------------
  |  |   62|    599|#define PEEK_UINT8 PEEK(types.f_uint8, )
  |  |  ------------------
  |  |  |  |   60|    599|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    599|      func(type))
  |  |  ------------------
  ------------------
 1087|    599|					if ((loctype < 1) ||
  ------------------
  |  Branch (1087:10): [True: 196, False: 403]
  ------------------
 1088|    403|					    (loctype > LLDP_MED_LOCFORMAT_LAST)) {
  ------------------
  |  |  301|    403|#define LLDP_MED_LOCFORMAT_LAST LLDP_MED_LOCFORMAT_ELIN
  |  |  ------------------
  |  |  |  |  300|    403|#define LLDP_MED_LOCFORMAT_ELIN 3
  |  |  ------------------
  ------------------
  |  Branch (1088:10): [True: 206, False: 197]
  ------------------
 1089|    402|						log_info("lldp",
 1090|    402|						    "unknown location type "
 1091|    402|						    "received on %s",
 1092|    402|						    hardware->h_ifname);
 1093|    402|						break;
 1094|    402|					}
 1095|    197|					free(port->p_med_location[loctype - 1].data);
 1096|    197|					if ((port->p_med_location[loctype - 1].data =
  ------------------
  |  Branch (1096:10): [True: 0, False: 197]
  ------------------
 1097|    197|						    (char *)malloc(tlv_size - 5)) ==
 1098|    197|					    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|    197|					PEEK_BYTES(
  ------------------
  |  |   66|    197|  do {                           \
  |  |   67|    197|    memcpy(value, pos, bytes);   \
  |  |   68|    197|    length -= (bytes);           \
  |  |   69|    197|    pos += (bytes);              \
  |  |   70|    197|  } while (0)
  |  |  ------------------
  |  |  |  Branch (70:12): [Folded, False: 197]
  |  |  ------------------
  ------------------
 1107|    197|					    port->p_med_location[loctype - 1].data,
 1108|    197|					    tlv_size - 5);
 1109|    197|					port->p_med_location[loctype - 1].data_len =
 1110|    197|					    tlv_size - 5;
 1111|    197|					port->p_med_location[loctype - 1].format =
 1112|    197|					    loctype;
 1113|    197|					port->p_med_cap_enabled |=
 1114|    197|					    LLDP_MED_CAP_LOCATION;
  ------------------
  |  |  331|    197|#define LLDP_MED_CAP_LOCATION 0x04
  ------------------
 1115|    197|					break;
 1116|  2.09k|				case LLDP_TLV_MED_MDI:
  ------------------
  |  |   74|  2.09k|#define LLDP_TLV_MED_MDI 4
  ------------------
  |  Branch (1116:5): [True: 2.09k, False: 3.45k]
  ------------------
 1117|  2.09k|					CHECK_TLV_SIZE(7, "LLDP-MED PoE-MDI");
  ------------------
  |  |  555|  2.09k|  do {                                                                             \
  |  |  556|  2.09k|    if (tlv_size < (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (556:9): [True: 3, False: 2.09k]
  |  |  ------------------
  |  |  557|      3|      log_warnx("lldp", name " TLV too short received on %s", hardware->h_ifname); \
  |  |  558|      3|      goto malformed;                                                              \
  |  |  559|      3|    }                                                                              \
  |  |  560|  2.09k|  } while (0)
  |  |  ------------------
  |  |  |  Branch (560:12): [Folded, False: 2.09k]
  |  |  ------------------
  ------------------
 1118|  2.09k|					power = PEEK_UINT8;
  ------------------
  |  |   62|  2.09k|#define PEEK_UINT8 PEEK(types.f_uint8, )
  |  |  ------------------
  |  |  |  |   60|  2.09k|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|  2.09k|      func(type))
  |  |  ------------------
  ------------------
 1119|  2.09k|					switch (power & 0xC0) {
 1120|    964|					case 0x0:
  ------------------
  |  Branch (1120:6): [True: 964, False: 1.12k]
  ------------------
 1121|    964|						port->p_med_power.devicetype =
 1122|    964|						    LLDP_MED_POW_TYPE_PSE;
  ------------------
  |  |  311|    964|#define LLDP_MED_POW_TYPE_PSE 1
  ------------------
 1123|    964|						port->p_med_cap_enabled |=
 1124|    964|						    LLDP_MED_CAP_MDI_PSE;
  ------------------
  |  |  332|    964|#define LLDP_MED_CAP_MDI_PSE 0x08
  ------------------
 1125|    964|						switch (power & 0x30) {
 1126|    200|						case 0x0:
  ------------------
  |  Branch (1126:7): [True: 200, False: 764]
  ------------------
 1127|    200|							port->p_med_power.source =
 1128|    200|							    LLDP_MED_POW_SOURCE_UNKNOWN;
  ------------------
  |  |  315|    200|#define LLDP_MED_POW_SOURCE_UNKNOWN 1
  ------------------
 1129|    200|							break;
 1130|    220|						case 0x10:
  ------------------
  |  Branch (1130:7): [True: 220, False: 744]
  ------------------
 1131|    220|							port->p_med_power.source =
 1132|    220|							    LLDP_MED_POW_SOURCE_PRIMARY;
  ------------------
  |  |  316|    220|#define LLDP_MED_POW_SOURCE_PRIMARY 2
  ------------------
 1133|    220|							break;
 1134|    244|						case 0x20:
  ------------------
  |  Branch (1134:7): [True: 244, False: 720]
  ------------------
 1135|    244|							port->p_med_power.source =
 1136|    244|							    LLDP_MED_POW_SOURCE_BACKUP;
  ------------------
  |  |  317|    244|#define LLDP_MED_POW_SOURCE_BACKUP 3
  ------------------
 1137|    244|							break;
 1138|    300|						default:
  ------------------
  |  Branch (1138:7): [True: 300, False: 664]
  ------------------
 1139|    300|							port->p_med_power.source =
 1140|    300|							    LLDP_MED_POW_SOURCE_RESERVED;
  ------------------
  |  |  318|    300|#define LLDP_MED_POW_SOURCE_RESERVED 4
  ------------------
 1141|    964|						}
 1142|    964|						break;
 1143|    964|					case 0x40:
  ------------------
  |  Branch (1143:6): [True: 882, False: 1.21k]
  ------------------
 1144|    882|						port->p_med_power.devicetype =
 1145|    882|						    LLDP_MED_POW_TYPE_PD;
  ------------------
  |  |  312|    882|#define LLDP_MED_POW_TYPE_PD 2
  ------------------
 1146|    882|						port->p_med_cap_enabled |=
 1147|    882|						    LLDP_MED_CAP_MDI_PD;
  ------------------
  |  |  333|    882|#define LLDP_MED_CAP_MDI_PD 0x10
  ------------------
 1148|    882|						switch (power & 0x30) {
 1149|    238|						case 0x0:
  ------------------
  |  Branch (1149:7): [True: 238, False: 644]
  ------------------
 1150|    238|							port->p_med_power.source =
 1151|    238|							    LLDP_MED_POW_SOURCE_UNKNOWN;
  ------------------
  |  |  315|    238|#define LLDP_MED_POW_SOURCE_UNKNOWN 1
  ------------------
 1152|    238|							break;
 1153|    205|						case 0x10:
  ------------------
  |  Branch (1153:7): [True: 205, False: 677]
  ------------------
 1154|    205|							port->p_med_power.source =
 1155|    205|							    LLDP_MED_POW_SOURCE_PSE;
  ------------------
  |  |  319|    205|#define LLDP_MED_POW_SOURCE_PSE 5
  ------------------
 1156|    205|							break;
 1157|    226|						case 0x20:
  ------------------
  |  Branch (1157:7): [True: 226, False: 656]
  ------------------
 1158|    226|							port->p_med_power.source =
 1159|    226|							    LLDP_MED_POW_SOURCE_LOCAL;
  ------------------
  |  |  320|    226|#define LLDP_MED_POW_SOURCE_LOCAL 6
  ------------------
 1160|    226|							break;
 1161|    213|						default:
  ------------------
  |  Branch (1161:7): [True: 213, False: 669]
  ------------------
 1162|    213|							port->p_med_power.source =
 1163|    213|							    LLDP_MED_POW_SOURCE_BOTH;
  ------------------
  |  |  321|    213|#define LLDP_MED_POW_SOURCE_BOTH 7
  ------------------
 1164|    882|						}
 1165|    882|						break;
 1166|    882|					default:
  ------------------
  |  Branch (1166:6): [True: 247, False: 1.84k]
  ------------------
 1167|    247|						port->p_med_power.devicetype =
 1168|    247|						    LLDP_MED_POW_TYPE_RESERVED;
  ------------------
  |  |  313|    247|#define LLDP_MED_POW_TYPE_RESERVED 3
  ------------------
 1169|  2.09k|					}
 1170|  2.09k|					if ((power & 0x0F) > LLDP_MED_POW_PRIO_LOW)
  ------------------
  |  |  326|  2.09k|#define LLDP_MED_POW_PRIO_LOW 3
  ------------------
  |  Branch (1170:10): [True: 1.20k, False: 888]
  ------------------
 1171|  1.20k|						port->p_med_power.priority =
 1172|  1.20k|						    LLDP_MED_POW_PRIO_UNKNOWN;
  ------------------
  |  |  323|  1.20k|#define LLDP_MED_POW_PRIO_UNKNOWN 0
  ------------------
 1173|    888|					else
 1174|    888|						port->p_med_power.priority =
 1175|    888|						    power & 0x0F;
 1176|  2.09k|					port->p_med_power.val = PEEK_UINT16;
  ------------------
  |  |   63|  2.09k|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  ------------------
  |  |  |  |   60|  2.09k|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|  2.09k|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   63|  2.09k|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1177|  2.09k|					break;
 1178|    206|				case LLDP_TLV_MED_IV_HW:
  ------------------
  |  |   75|    206|#define LLDP_TLV_MED_IV_HW 5
  ------------------
  |  Branch (1178:5): [True: 206, False: 5.34k]
  ------------------
 1179|    487|				case LLDP_TLV_MED_IV_SW:
  ------------------
  |  |   77|    487|#define LLDP_TLV_MED_IV_SW 7
  ------------------
  |  Branch (1179:5): [True: 281, False: 5.27k]
  ------------------
 1180|    734|				case LLDP_TLV_MED_IV_FW:
  ------------------
  |  |   76|    734|#define LLDP_TLV_MED_IV_FW 6
  ------------------
  |  Branch (1180:5): [True: 247, False: 5.30k]
  ------------------
 1181|    979|				case LLDP_TLV_MED_IV_SN:
  ------------------
  |  |   78|    979|#define LLDP_TLV_MED_IV_SN 8
  ------------------
  |  Branch (1181:5): [True: 245, False: 5.30k]
  ------------------
 1182|  1.17k|				case LLDP_TLV_MED_IV_MANUF:
  ------------------
  |  |   79|  1.17k|#define LLDP_TLV_MED_IV_MANUF 9
  ------------------
  |  Branch (1182:5): [True: 200, False: 5.35k]
  ------------------
 1183|  1.38k|				case LLDP_TLV_MED_IV_MODEL:
  ------------------
  |  |   80|  1.38k|#define LLDP_TLV_MED_IV_MODEL 10
  ------------------
  |  Branch (1183:5): [True: 201, False: 5.35k]
  ------------------
 1184|  1.69k|				case LLDP_TLV_MED_IV_ASSET:
  ------------------
  |  |   81|  1.69k|#define LLDP_TLV_MED_IV_ASSET 11
  ------------------
  |  Branch (1184:5): [True: 311, False: 5.24k]
  ------------------
 1185|  1.69k|					if (tlv_size <= 4)
  ------------------
  |  Branch (1185:10): [True: 1.45k, False: 235]
  ------------------
 1186|  1.45k|						b = NULL;
 1187|    235|					else {
 1188|    235|						if ((b = (char *)malloc(
  ------------------
  |  Branch (1188:11): [True: 0, False: 235]
  ------------------
 1189|    235|							 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|    235|						PEEK_BYTES(b, tlv_size - 4);
  ------------------
  |  |   66|    235|  do {                           \
  |  |   67|    235|    memcpy(value, pos, bytes);   \
  |  |   68|    235|    length -= (bytes);           \
  |  |   69|    235|    pos += (bytes);              \
  |  |   70|    235|  } while (0)
  |  |  ------------------
  |  |  |  Branch (70:12): [Folded, False: 235]
  |  |  ------------------
  ------------------
 1199|    235|						b[tlv_size - 4] = '\0';
 1200|    235|					}
 1201|  1.69k|					switch (tlv_subtype) {
 1202|    206|					case LLDP_TLV_MED_IV_HW:
  ------------------
  |  |   75|    206|#define LLDP_TLV_MED_IV_HW 5
  ------------------
  |  Branch (1202:6): [True: 206, False: 1.48k]
  ------------------
 1203|    206|						free(chassis->c_med_hw);
 1204|    206|						chassis->c_med_hw = b;
 1205|    206|						break;
 1206|    247|					case LLDP_TLV_MED_IV_FW:
  ------------------
  |  |   76|    247|#define LLDP_TLV_MED_IV_FW 6
  ------------------
  |  Branch (1206:6): [True: 247, False: 1.44k]
  ------------------
 1207|    247|						free(chassis->c_med_fw);
 1208|    247|						chassis->c_med_fw = b;
 1209|    247|						break;
 1210|    281|					case LLDP_TLV_MED_IV_SW:
  ------------------
  |  |   77|    281|#define LLDP_TLV_MED_IV_SW 7
  ------------------
  |  Branch (1210:6): [True: 281, False: 1.41k]
  ------------------
 1211|    281|						free(chassis->c_med_sw);
 1212|    281|						chassis->c_med_sw = b;
 1213|    281|						break;
 1214|    245|					case LLDP_TLV_MED_IV_SN:
  ------------------
  |  |   78|    245|#define LLDP_TLV_MED_IV_SN 8
  ------------------
  |  Branch (1214:6): [True: 245, False: 1.44k]
  ------------------
 1215|    245|						free(chassis->c_med_sn);
 1216|    245|						chassis->c_med_sn = b;
 1217|    245|						break;
 1218|    200|					case LLDP_TLV_MED_IV_MANUF:
  ------------------
  |  |   79|    200|#define LLDP_TLV_MED_IV_MANUF 9
  ------------------
  |  Branch (1218:6): [True: 200, False: 1.49k]
  ------------------
 1219|    200|						free(chassis->c_med_manuf);
 1220|    200|						chassis->c_med_manuf = b;
 1221|    200|						break;
 1222|    201|					case LLDP_TLV_MED_IV_MODEL:
  ------------------
  |  |   80|    201|#define LLDP_TLV_MED_IV_MODEL 10
  ------------------
  |  Branch (1222:6): [True: 201, False: 1.49k]
  ------------------
 1223|    201|						free(chassis->c_med_model);
 1224|    201|						chassis->c_med_model = b;
 1225|    201|						break;
 1226|    311|					case LLDP_TLV_MED_IV_ASSET:
  ------------------
  |  |   81|    311|#define LLDP_TLV_MED_IV_ASSET 11
  ------------------
  |  Branch (1226:6): [True: 311, False: 1.38k]
  ------------------
 1227|    311|						free(chassis->c_med_asset);
 1228|    311|						chassis->c_med_asset = b;
 1229|    311|						break;
 1230|      0|					default:
  ------------------
  |  Branch (1230:6): [True: 0, False: 1.69k]
  ------------------
 1231|       |						/* unreachable */
 1232|      0|						free(b);
 1233|      0|						break;
 1234|  1.69k|					}
 1235|  1.69k|					port->p_med_cap_enabled |= LLDP_MED_CAP_IV;
  ------------------
  |  |  334|  1.69k|#define LLDP_MED_CAP_IV 0x20
  ------------------
 1236|  1.69k|					break;
 1237|    205|				default:
  ------------------
  |  Branch (1237:5): [True: 205, False: 5.34k]
  ------------------
 1238|       |					/* Unknown LLDP MED, ignore it */
 1239|    205|					hardware->h_rx_unrecognized_cnt++;
 1240|  5.55k|				}
 1241|  5.55k|#endif /* ENABLE_LLDPMED */
 1242|  5.55k|			} else if (memcmp(dcbx, orgid, sizeof(orgid)) == 0) {
  ------------------
  |  Branch (1242:15): [True: 335, False: 894]
  ------------------
 1243|    335|				log_debug("lldp",
 1244|    335|				    "unsupported DCBX tlv received on %s - ignore",
 1245|    335|				    hardware->h_ifname);
 1246|    335|				unrecognized = 1;
 1247|    894|			} else {
 1248|    894|				log_debug("lldp",
 1249|    894|				    "unknown org tlv [%02x:%02x:%02x] received on %s",
 1250|    894|				    orgid[0], orgid[1], orgid[2], hardware->h_ifname);
 1251|    894|				unrecognized = 1;
 1252|    894|			}
 1253|  9.97k|			if (unrecognized) {
  ------------------
  |  Branch (1253:8): [True: 2.01k, False: 7.95k]
  ------------------
 1254|  2.01k|				hardware->h_rx_unrecognized_cnt++;
 1255|  2.01k|#ifdef ENABLE_CUSTOM
 1256|  2.01k|				custom = (struct lldpd_custom *)calloc(1,
 1257|  2.01k|				    sizeof(struct lldpd_custom));
 1258|  2.01k|				if (!custom) {
  ------------------
  |  Branch (1258:9): [True: 0, False: 2.01k]
  ------------------
 1259|      0|					log_warn("lldp",
 1260|      0|					    "unable to allocate memory for custom TLV");
 1261|      0|					goto malformed;
 1262|      0|				}
 1263|  2.01k|				custom->oui_info_len = tlv_size > 4 ? tlv_size - 4 : 0;
  ------------------
  |  Branch (1263:28): [True: 551, False: 1.46k]
  ------------------
 1264|  2.01k|				memcpy(custom->oui, orgid, sizeof(custom->oui));
 1265|  2.01k|				custom->subtype = tlv_subtype;
 1266|  2.01k|				if (custom->oui_info_len > 0) {
  ------------------
  |  Branch (1266:9): [True: 551, False: 1.46k]
  ------------------
 1267|    551|					custom->oui_info = malloc(custom->oui_info_len);
 1268|    551|					if (!custom->oui_info) {
  ------------------
  |  Branch (1268:10): [True: 0, False: 551]
  ------------------
 1269|      0|						log_warn("lldp",
 1270|      0|						    "unable to allocate memory for custom TLV data");
 1271|      0|						goto malformed;
 1272|      0|					}
 1273|    551|					PEEK_BYTES(custom->oui_info,
  ------------------
  |  |   66|    551|  do {                           \
  |  |   67|    551|    memcpy(value, pos, bytes);   \
  |  |   68|    551|    length -= (bytes);           \
  |  |   69|    551|    pos += (bytes);              \
  |  |   70|    551|  } while (0)
  |  |  ------------------
  |  |  |  Branch (70:12): [Folded, False: 551]
  |  |  ------------------
  ------------------
 1274|    551|					    custom->oui_info_len);
 1275|    551|				}
 1276|  2.01k|				TAILQ_INSERT_TAIL(&port->p_custom_list, custom, next);
  ------------------
  |  Branch (1276:5): [Folded, False: 2.01k]
  ------------------
 1277|  2.01k|				custom = NULL;
 1278|  2.01k|#endif
 1279|  2.01k|			}
 1280|  9.97k|			break;
 1281|  9.97k|		default:
  ------------------
  |  Branch (1281:3): [True: 618, False: 17.1k]
  ------------------
 1282|    618|			log_warnx("lldp", "unknown tlv (%d) received on %s", tlv_type,
 1283|    618|			    hardware->h_ifname);
 1284|    618|			hardware->h_rx_unrecognized_cnt++;
 1285|    618|			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|    784|	if ((chassis->c_id == NULL) || (port->p_id == NULL) || (!ttl_received) ||
  ------------------
  |  Branch (1295:6): [True: 540, False: 244]
  |  Branch (1295:33): [True: 25, False: 219]
  |  Branch (1295:57): [True: 8, False: 211]
  ------------------
 1296|    660|	    (gotend == 0)) {
  ------------------
  |  Branch (1296:6): [True: 87, False: 124]
  ------------------
 1297|    660|		log_warnx("lldp",
 1298|    660|		    "some mandatory tlv are missing for frame received on %s",
 1299|    660|		    hardware->h_ifname);
 1300|    660|		goto malformed;
 1301|    660|	}
 1302|    124|	*newchassis = chassis;
 1303|    124|	*newport = port;
 1304|    124|	return 1;
 1305|  1.02k|malformed:
 1306|  1.02k|#ifdef ENABLE_CUSTOM
 1307|  1.02k|	free(custom);
 1308|  1.02k|#endif
 1309|  1.02k|#ifdef ENABLE_DOT1
 1310|  1.02k|	free(vlan);
 1311|  1.02k|	free(pi);
 1312|  1.02k|#endif
 1313|  1.02k|	lldpd_chassis_cleanup(chassis, 1);
 1314|  1.02k|	lldpd_port_cleanup(port, 1);
 1315|  1.02k|	free(port);
 1316|  1.02k|	return -1;
 1317|    784|}
lldp.c:lldpd_af_from_lldp_proto:
   43|    899|{
   44|    899|	switch (proto) {
   45|    405|	case LLDP_MGMT_ADDR_IP4:
  ------------------
  |  |  273|    405|#define LLDP_MGMT_ADDR_IP4 1
  ------------------
  |  Branch (45:2): [True: 405, False: 494]
  ------------------
   46|    405|		return LLDPD_AF_IPV4;
   47|    263|	case LLDP_MGMT_ADDR_IP6:
  ------------------
  |  |  274|    263|#define LLDP_MGMT_ADDR_IP6 2
  ------------------
  |  Branch (47:2): [True: 263, False: 636]
  ------------------
   48|    263|		return LLDPD_AF_IPV6;
   49|    231|	default:
  ------------------
  |  Branch (49:2): [True: 231, False: 668]
  ------------------
   50|    231|		return LLDPD_AF_UNSPEC;
   51|    899|	}
   52|    899|}

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

log_register:
   64|  1.14k|{
   65|  1.14k|	logh = cb;
   66|  1.14k|}
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.57k|{
  215|  1.57k|	va_list ap;
  216|       |
  217|  1.57k|	va_start(ap, emsg);
  218|  1.57k|	vlog(LOG_WARNING, token, emsg, ap);
  219|       |	va_end(ap);
  220|  1.57k|}
log_info:
  224|    961|{
  225|    961|	va_list ap;
  226|       |
  227|    961|	if (use_syslog || debug > 0 || logh) {
  ------------------
  |  Branch (227:6): [True: 0, False: 961]
  |  Branch (227:20): [True: 0, False: 961]
  |  Branch (227:33): [True: 961, False: 0]
  ------------------
  228|    961|		va_start(ap, emsg);
  229|    961|		vlog(LOG_INFO, token, emsg, ap);
  230|       |		va_end(ap);
  231|    961|	}
  232|    961|}
log_debug:
  247|  9.61k|{
  248|  9.61k|	va_list ap;
  249|       |
  250|  9.61k|	if ((debug > 1 && log_debug_accept_token(token)) || logh) {
  ------------------
  |  Branch (250:7): [True: 0, False: 9.61k]
  |  Branch (250:20): [True: 0, False: 0]
  |  Branch (250:54): [True: 9.61k, False: 0]
  ------------------
  251|  9.61k|		va_start(ap, emsg);
  252|  9.61k|		vlog(LOG_DEBUG, token, emsg, ap);
  253|       |		va_end(ap);
  254|  9.61k|	}
  255|  9.61k|}
log.c:vlog:
  154|  12.1k|{
  155|  12.1k|	if (logh) {
  ------------------
  |  Branch (155:6): [True: 12.1k, False: 0]
  ------------------
  156|  12.1k|		char *result = NULL;
  157|  12.1k|		if (vasprintf(&result, fmt, ap) != -1) {
  ------------------
  |  Branch (157:7): [True: 12.1k, False: 0]
  ------------------
  158|  12.1k|			logh(pri, result);
  159|  12.1k|			free(result);
  160|  12.1k|			return;
  161|  12.1k|		}
  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.1k|	}
  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.1k|void donothing(int pri, const char *msg) {};
LLVMFuzzerTestOneInput:
   28|  1.17k|{
   29|  1.17k|	if (Size < kMinInputLength || Size > kMaxInputLength) {
  ------------------
  |  |   20|  2.34k|#define kMinInputLength 5
  ------------------
              	if (Size < kMinInputLength || Size > kMaxInputLength) {
  ------------------
  |  |   21|  1.17k|#define kMaxInputLength 2048
  ------------------
  |  Branch (29:6): [True: 4, False: 1.17k]
  |  Branch (29:32): [True: 21, False: 1.14k]
  ------------------
   30|     25|		return 1;
   31|     25|	}
   32|       |
   33|  1.14k|	struct lldpd_chassis *nchassis = NULL;
   34|  1.14k|	struct lldpd_port *nport = NULL;
   35|  1.14k|	struct lldpd_hardware hardware;
   36|       |
   37|  1.14k|	log_register(donothing);
   38|       |
   39|  1.14k|	lldp_decode(NULL, (char *)Data, Size, &hardware, &nchassis, &nport);
   40|       |
   41|  1.14k|	if (!nchassis || !nport) {
  ------------------
  |  Branch (41:6): [True: 1.02k, False: 124]
  |  Branch (41:19): [True: 0, False: 124]
  ------------------
   42|  1.02k|		return 1;
   43|  1.02k|	}
   44|       |
   45|    124|	lldpd_port_cleanup(nport, 1);
   46|    124|	free(nport);
   47|    124|	lldpd_chassis_cleanup(nchassis, 1);
   48|       |
   49|    124|	return 0;
   50|  1.14k|}

