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

lldp_decode:
  572|  1.15k|{
  573|  1.15k|	struct lldpd_chassis *chassis;
  574|  1.15k|	struct lldpd_port *port;
  575|  1.15k|	char lldpaddr[ETHER_ADDR_LEN];
  576|  1.15k|	const char dot1[] = LLDP_TLV_ORG_DOT1;
  ------------------
  |  |   45|  1.15k|  {                       \
  |  |   46|  1.15k|    0x00, 0x80, 0xc2      \
  |  |   47|  1.15k|  }
  ------------------
  577|  1.15k|	const char dot3[] = LLDP_TLV_ORG_DOT3;
  ------------------
  |  |   49|  1.15k|  {                       \
  |  |   50|  1.15k|    0x00, 0x12, 0x0f      \
  |  |   51|  1.15k|  }
  ------------------
  578|  1.15k|	const char med[] = LLDP_TLV_ORG_MED;
  ------------------
  |  |   53|  1.15k|  {                      \
  |  |   54|  1.15k|    0x00, 0x12, 0xbb     \
  |  |   55|  1.15k|  }
  ------------------
  579|  1.15k|	const char dcbx[] = LLDP_TLV_ORG_DCBX;
  ------------------
  |  |   57|  1.15k|  {                       \
  |  |   58|  1.15k|    0x00, 0x1b, 0x21      \
  |  |   59|  1.15k|  }
  ------------------
  580|  1.15k|	unsigned char orgid[3];
  581|  1.15k|	int length, gotend = 0, ttl_received = 0;
  582|  1.15k|	int tlv_size, tlv_type, tlv_subtype, tlv_count = 0;
  583|  1.15k|	u_int8_t *pos, *tlv;
  584|  1.15k|	char *b;
  585|  1.15k|#ifdef ENABLE_DOT1
  586|  1.15k|	struct lldpd_vlan *vlan = NULL;
  587|  1.15k|	int vlan_len;
  588|  1.15k|	struct lldpd_ppvid *ppvid;
  589|  1.15k|	struct lldpd_pi *pi = NULL;
  590|  1.15k|#endif
  591|  1.15k|	struct lldpd_mgmt *mgmt;
  592|  1.15k|	int af;
  593|  1.15k|	u_int8_t addr_str_length, addr_str_buffer[32] = { 0 };
  594|  1.15k|	u_int8_t addr_family, addr_length, *addr_ptr, iface_subtype;
  595|  1.15k|	u_int32_t iface_number, iface;
  596|  1.15k|	int unrecognized;
  597|  1.15k|#ifdef ENABLE_CUSTOM
  598|  1.15k|	struct lldpd_custom *custom = NULL;
  599|  1.15k|#endif
  600|       |
  601|  1.15k|	log_debug("lldp", "receive LLDP PDU on %s", hardware->h_ifname);
  602|       |
  603|  1.15k|	if ((chassis = calloc(1, sizeof(struct lldpd_chassis))) == NULL) {
  ------------------
  |  Branch (603:6): [True: 0, False: 1.15k]
  ------------------
  604|      0|		log_warn("lldp", "failed to allocate remote chassis");
  605|      0|		return -1;
  606|      0|	}
  607|  1.15k|	TAILQ_INIT(&chassis->c_mgmt);
  ------------------
  |  Branch (607:2): [Folded, False: 1.15k]
  ------------------
  608|  1.15k|	if ((port = calloc(1, sizeof(struct lldpd_port))) == NULL) {
  ------------------
  |  Branch (608:6): [True: 0, False: 1.15k]
  ------------------
  609|      0|		log_warn("lldp", "failed to allocate remote port");
  610|      0|		free(chassis);
  611|      0|		return -1;
  612|      0|	}
  613|  1.15k|#ifdef ENABLE_DOT1
  614|  1.15k|	TAILQ_INIT(&port->p_vlans);
  ------------------
  |  Branch (614:2): [Folded, False: 1.15k]
  ------------------
  615|  1.15k|	TAILQ_INIT(&port->p_ppvids);
  ------------------
  |  Branch (615:2): [Folded, False: 1.15k]
  ------------------
  616|  1.15k|	TAILQ_INIT(&port->p_pids);
  ------------------
  |  Branch (616:2): [Folded, False: 1.15k]
  ------------------
  617|  1.15k|#endif
  618|  1.15k|#ifdef ENABLE_CUSTOM
  619|  1.15k|	TAILQ_INIT(&port->p_custom_list);
  ------------------
  |  Branch (619:2): [Folded, False: 1.15k]
  ------------------
  620|  1.15k|#endif
  621|       |
  622|  1.15k|	length = s;
  623|  1.15k|	pos = (u_int8_t *)frame;
  624|       |
  625|  1.15k|	if (length < 2 * ETHER_ADDR_LEN + sizeof(u_int16_t)) {
  ------------------
  |  Branch (625:6): [True: 7, False: 1.15k]
  ------------------
  626|      7|		log_warnx("lldp", "too short frame received on %s", hardware->h_ifname);
  627|      7|		goto malformed;
  628|      7|	}
  629|  1.15k|	PEEK_BYTES(lldpaddr, ETHER_ADDR_LEN);
  ------------------
  |  |   66|  1.15k|  do {                           \
  |  |   67|  1.15k|    memcpy(value, pos, bytes);   \
  |  |   68|  1.15k|    length -= (bytes);           \
  |  |   69|  1.15k|    pos += (bytes);              \
  |  |   70|  1.15k|  } while (0)
  |  |  ------------------
  |  |  |  Branch (70:12): [Folded, False: 1.15k]
  |  |  ------------------
  ------------------
  630|  1.15k|	if (memcmp(lldpaddr, (const char[])LLDP_ADDR_NEAREST_BRIDGE, ETHER_ADDR_LEN) &&
  ------------------
  |  |   22|  1.15k|  {                                    \
  |  |   23|  1.15k|    0x01, 0x80, 0xc2, 0x00, 0x00, 0x0e \
  |  |   24|  1.15k|  }
  ------------------
  |  Branch (630:6): [True: 706, False: 445]
  ------------------
  631|    706|	    memcmp(lldpaddr, (const char[])LLDP_ADDR_NEAREST_NONTPMR_BRIDGE,
  ------------------
  |  |   26|    706|  {                                      \
  |  |   27|    706|    0x01, 0x80, 0xc2, 0x00, 0x00, 0x03   \
  |  |   28|    706|  }
  ------------------
  |  Branch (631:6): [True: 543, False: 163]
  ------------------
  632|    706|		ETHER_ADDR_LEN) &&
  633|    543|	    memcmp(lldpaddr, (const char[])LLDP_ADDR_NEAREST_CUSTOMER_BRIDGE,
  ------------------
  |  |   30|    543|  {                                       \
  |  |   31|    543|    0x01, 0x80, 0xc2, 0x00, 0x00, 0x00    \
  |  |   32|    543|  }
  ------------------
  |  Branch (633:6): [True: 43, False: 500]
  ------------------
  634|    543|		ETHER_ADDR_LEN)) {
  635|     43|		log_info("lldp",
  636|     43|		    "frame not targeted at LLDP multicast address received on %s",
  637|     43|		    hardware->h_ifname);
  638|     43|		goto malformed;
  639|     43|	}
  640|  1.10k|	PEEK_DISCARD(ETHER_ADDR_LEN); /* Skip source address */
  ------------------
  |  |   72|  1.10k|  do {                      \
  |  |   73|  1.10k|    length -= (bytes);      \
  |  |   74|  1.10k|    pos += (bytes);         \
  |  |   75|  1.10k|  } while (0)
  |  |  ------------------
  |  |  |  Branch (75:12): [Folded, False: 1.10k]
  |  |  ------------------
  ------------------
  641|  1.10k|	if (PEEK_UINT16 != ETH_P_LLDP) {
  ------------------
  |  |   63|  1.10k|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  ------------------
  |  |  |  |   60|  1.10k|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|  1.10k|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   63|  1.10k|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
              	if (PEEK_UINT16 != ETH_P_LLDP) {
  ------------------
  |  |  269|  1.10k|#  define ETH_P_LLDP 0x88cc
  ------------------
  |  Branch (641:6): [True: 28, False: 1.08k]
  ------------------
  642|     28|		log_info("lldp", "non LLDP frame received on %s", hardware->h_ifname);
  643|     28|		goto malformed;
  644|     28|	}
  645|       |
  646|  19.1k|	while (length && (!gotend)) {
  ------------------
  |  Branch (646:9): [True: 18.4k, False: 752]
  |  Branch (646:19): [True: 18.4k, False: 36]
  ------------------
  647|  18.4k|		if (length < 2) {
  ------------------
  |  Branch (647:7): [True: 77, False: 18.3k]
  ------------------
  648|     77|			log_warnx("lldp", "tlv header too short received on %s",
  649|     77|			    hardware->h_ifname);
  650|     77|			goto malformed;
  651|     77|		}
  652|  18.3k|		tlv_size = PEEK_UINT16;
  ------------------
  |  |   63|  18.3k|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  ------------------
  |  |  |  |   60|  18.3k|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|  18.3k|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   63|  18.3k|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  653|  18.3k|		tlv_type = tlv_size >> 9;
  654|  18.3k|		tlv_size = tlv_size & 0x1ff;
  655|  18.3k|		(void)PEEK_SAVE(tlv);
  ------------------
  |  |   81|  18.3k|#define PEEK_SAVE POKE_SAVE
  |  |  ------------------
  |  |  |  |   46|  18.3k|#define POKE_SAVE(where) (where = pos, 1)
  |  |  ------------------
  ------------------
  656|  18.3k|		if (length < tlv_size) {
  ------------------
  |  Branch (656:7): [True: 45, False: 18.2k]
  ------------------
  657|     45|			log_warnx("lldp", "frame too short for tlv received on %s",
  658|     45|			    hardware->h_ifname);
  659|     45|			goto malformed;
  660|     45|		}
  661|       |		/* Check order for mandatory TLVs */
  662|  18.2k|		tlv_count++;
  663|  18.2k|		switch (tlv_type) {
  ------------------
  |  Branch (663:11): [True: 858, False: 17.4k]
  ------------------
  664|    326|		case LLDP_TLV_CHASSIS_ID:
  ------------------
  |  |   35|    326|#define LLDP_TLV_CHASSIS_ID 1
  ------------------
  |  Branch (664:3): [True: 326, False: 17.9k]
  ------------------
  665|    326|			if (tlv_count != 1) {
  ------------------
  |  Branch (665:8): [True: 11, False: 315]
  ------------------
  666|     11|				log_warnx("lldp",
  667|     11|				    "Chassis ID TLV should be first on %s, but it is on position %d",
  668|     11|				    hardware->h_ifname, tlv_count);
  669|     11|				goto malformed;
  670|     11|			}
  671|    315|			break;
  672|    315|		case LLDP_TLV_PORT_ID:
  ------------------
  |  |   36|    270|#define LLDP_TLV_PORT_ID 2
  ------------------
  |  Branch (672:3): [True: 270, False: 18.0k]
  ------------------
  673|    270|			if (tlv_count != 2) {
  ------------------
  |  Branch (673:8): [True: 9, False: 261]
  ------------------
  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|    261|			break;
  680|    262|		case LLDP_TLV_TTL:
  ------------------
  |  |   37|    262|#define LLDP_TLV_TTL 3
  ------------------
  |  Branch (680:3): [True: 262, False: 18.0k]
  ------------------
  681|    262|			if (tlv_count != 3) {
  ------------------
  |  Branch (681:8): [True: 10, False: 252]
  ------------------
  682|     10|				log_warnx("lldp",
  683|     10|				    "TTL TLV should be third on %s, but it is on position %d",
  684|     10|				    hardware->h_ifname, tlv_count);
  685|     10|				goto malformed;
  686|     10|			}
  687|    252|			break;
  688|  18.2k|		}
  689|       |
  690|  18.2k|		switch (tlv_type) {
  691|    153|		case LLDP_TLV_END:
  ------------------
  |  |   34|    153|#define LLDP_TLV_END 0
  ------------------
  |  Branch (691:3): [True: 153, False: 18.0k]
  ------------------
  692|    153|			if (tlv_size != 0) {
  ------------------
  |  Branch (692:8): [True: 12, False: 141]
  ------------------
  693|     12|				log_warnx("lldp",
  694|     12|				    "lldp end received with size not null on %s",
  695|     12|				    hardware->h_ifname);
  696|     12|				goto malformed;
  697|     12|			}
  698|    141|			if (length)
  ------------------
  |  Branch (698:8): [True: 36, False: 105]
  ------------------
  699|     36|				log_debug("lldp", "extra data after lldp end on %s",
  700|     36|				    hardware->h_ifname);
  701|    141|			gotend = 1;
  702|    141|			break;
  703|    315|		case LLDP_TLV_CHASSIS_ID:
  ------------------
  |  |   35|    315|#define LLDP_TLV_CHASSIS_ID 1
  ------------------
  |  Branch (703:3): [True: 315, False: 17.9k]
  ------------------
  704|    576|		case LLDP_TLV_PORT_ID:
  ------------------
  |  |   36|    576|#define LLDP_TLV_PORT_ID 2
  ------------------
  |  Branch (704:3): [True: 261, False: 17.9k]
  ------------------
  705|    576|			CHECK_TLV_SIZE(2, "Port/Chassis Id");
  ------------------
  |  |  555|    576|  do {                                                                             \
  |  |  556|    576|    if (tlv_size < (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (556:9): [True: 5, False: 571]
  |  |  ------------------
  |  |  557|      5|      log_warnx("lldp", name " TLV too short received on %s", hardware->h_ifname); \
  |  |  558|      5|      goto malformed;                                                              \
  |  |  559|      5|    }                                                                              \
  |  |  560|    576|  } while (0)
  |  |  ------------------
  |  |  |  Branch (560:12): [Folded, False: 571]
  |  |  ------------------
  ------------------
  706|    571|			CHECK_TLV_MAX_SIZE(256, "Port/Chassis Id");
  ------------------
  |  |  562|    571|  do {                                                                             \
  |  |  563|    571|    if (tlv_size > (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (563:9): [True: 1, False: 570]
  |  |  ------------------
  |  |  564|      1|      log_warnx("lldp", name " TLV too large received on %s", hardware->h_ifname); \
  |  |  565|      1|      goto malformed;                                                              \
  |  |  566|      1|    }                                                                              \
  |  |  567|    571|  } while (0)
  |  |  ------------------
  |  |  |  Branch (567:12): [Folded, False: 570]
  |  |  ------------------
  ------------------
  707|    570|			tlv_subtype = PEEK_UINT8;
  ------------------
  |  |   62|    570|#define PEEK_UINT8 PEEK(types.f_uint8, )
  |  |  ------------------
  |  |  |  |   60|    570|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    570|      func(type))
  |  |  ------------------
  ------------------
  708|    570|			if ((tlv_subtype == 0) || (tlv_subtype > 7)) {
  ------------------
  |  Branch (708:8): [True: 2, False: 568]
  |  Branch (708:30): [True: 18, False: 550]
  ------------------
  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|    550|			if ((b = (char *)calloc(1, tlv_size - 1)) == NULL) {
  ------------------
  |  Branch (714:8): [True: 0, False: 550]
  ------------------
  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|    550|			PEEK_BYTES(b, tlv_size - 1);
  ------------------
  |  |   66|    550|  do {                           \
  |  |   67|    550|    memcpy(value, pos, bytes);   \
  |  |   68|    550|    length -= (bytes);           \
  |  |   69|    550|    pos += (bytes);              \
  |  |   70|    550|  } while (0)
  |  |  ------------------
  |  |  |  Branch (70:12): [Folded, False: 550]
  |  |  ------------------
  ------------------
  722|    550|			if (tlv_type == LLDP_TLV_PORT_ID) {
  ------------------
  |  |   36|    550|#define LLDP_TLV_PORT_ID 2
  ------------------
  |  Branch (722:8): [True: 257, False: 293]
  ------------------
  723|    257|				if (port->p_id != NULL) {
  ------------------
  |  Branch (723:9): [True: 0, False: 257]
  ------------------
  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|    257|				port->p_id_subtype = tlv_subtype;
  731|    257|				port->p_id = b;
  732|    257|				port->p_id_len = tlv_size - 1;
  733|    293|			} else {
  734|    293|				if (chassis->c_id != NULL) {
  ------------------
  |  Branch (734:9): [True: 0, False: 293]
  ------------------
  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|    293|				chassis->c_id_subtype = tlv_subtype;
  742|    293|				chassis->c_id = b;
  743|    293|				chassis->c_id_len = tlv_size - 1;
  744|    293|			}
  745|    550|			break;
  746|    550|		case LLDP_TLV_TTL:
  ------------------
  |  |   37|    252|#define LLDP_TLV_TTL 3
  ------------------
  |  Branch (746:3): [True: 252, False: 18.0k]
  ------------------
  747|    252|			if (ttl_received) {
  ------------------
  |  Branch (747:8): [True: 0, False: 252]
  ------------------
  748|      0|				log_warnx("lldp", "TTL TLV received twice on %s",
  749|      0|				    hardware->h_ifname);
  750|      0|				goto malformed;
  751|      0|			}
  752|    252|			CHECK_TLV_SIZE(2, "TTL");
  ------------------
  |  |  555|    252|  do {                                                                             \
  |  |  556|    252|    if (tlv_size < (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (556:9): [True: 2, False: 250]
  |  |  ------------------
  |  |  557|      2|      log_warnx("lldp", name " TLV too short received on %s", hardware->h_ifname); \
  |  |  558|      2|      goto malformed;                                                              \
  |  |  559|      2|    }                                                                              \
  |  |  560|    252|  } while (0)
  |  |  ------------------
  |  |  |  Branch (560:12): [Folded, False: 250]
  |  |  ------------------
  ------------------
  753|    250|			port->p_ttl = PEEK_UINT16;
  ------------------
  |  |   63|    250|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  ------------------
  |  |  |  |   60|    250|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    250|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   63|    250|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  754|    250|			ttl_received = 1;
  755|    250|			break;
  756|    603|		case LLDP_TLV_PORT_DESCR:
  ------------------
  |  |   38|    603|#define LLDP_TLV_PORT_DESCR 4
  ------------------
  |  Branch (756:3): [True: 603, False: 17.6k]
  ------------------
  757|  2.15k|		case LLDP_TLV_SYSTEM_NAME:
  ------------------
  |  |   39|  2.15k|#define LLDP_TLV_SYSTEM_NAME 5
  ------------------
  |  Branch (757:3): [True: 1.55k, False: 16.6k]
  ------------------
  758|  4.95k|		case LLDP_TLV_SYSTEM_DESCR:
  ------------------
  |  |   40|  4.95k|#define LLDP_TLV_SYSTEM_DESCR 6
  ------------------
  |  Branch (758:3): [True: 2.80k, False: 15.4k]
  ------------------
  759|  4.95k|			if (tlv_size < 1) {
  ------------------
  |  Branch (759:8): [True: 4.28k, False: 673]
  ------------------
  760|  4.28k|				log_debug("lldp", "empty tlv received on %s",
  761|  4.28k|				    hardware->h_ifname);
  762|  4.28k|				break;
  763|  4.28k|			}
  764|    673|			if ((b = (char *)calloc(1, tlv_size + 1)) == NULL) {
  ------------------
  |  Branch (764:8): [True: 0, False: 673]
  ------------------
  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|    673|			PEEK_BYTES(b, tlv_size);
  ------------------
  |  |   66|    673|  do {                           \
  |  |   67|    673|    memcpy(value, pos, bytes);   \
  |  |   68|    673|    length -= (bytes);           \
  |  |   69|    673|    pos += (bytes);              \
  |  |   70|    673|  } while (0)
  |  |  ------------------
  |  |  |  Branch (70:12): [Folded, False: 673]
  |  |  ------------------
  ------------------
  772|    673|			switch (tlv_type) {
  773|    212|			case LLDP_TLV_PORT_DESCR:
  ------------------
  |  |   38|    212|#define LLDP_TLV_PORT_DESCR 4
  ------------------
  |  Branch (773:4): [True: 212, False: 461]
  ------------------
  774|    212|				free(port->p_descr);
  775|    212|				port->p_descr = b;
  776|    212|				break;
  777|    253|			case LLDP_TLV_SYSTEM_NAME:
  ------------------
  |  |   39|    253|#define LLDP_TLV_SYSTEM_NAME 5
  ------------------
  |  Branch (777:4): [True: 253, False: 420]
  ------------------
  778|    253|				free(chassis->c_name);
  779|    253|				chassis->c_name = b;
  780|    253|				break;
  781|    208|			case LLDP_TLV_SYSTEM_DESCR:
  ------------------
  |  |   40|    208|#define LLDP_TLV_SYSTEM_DESCR 6
  ------------------
  |  Branch (781:4): [True: 208, False: 465]
  ------------------
  782|    208|				free(chassis->c_descr);
  783|    208|				chassis->c_descr = b;
  784|    208|				break;
  785|      0|			default:
  ------------------
  |  Branch (785:4): [True: 0, False: 673]
  ------------------
  786|       |				/* unreachable */
  787|      0|				free(b);
  788|      0|				break;
  789|    673|			}
  790|    673|			break;
  791|    673|		case LLDP_TLV_SYSTEM_CAP:
  ------------------
  |  |   41|    472|#define LLDP_TLV_SYSTEM_CAP 7
  ------------------
  |  Branch (791:3): [True: 472, False: 17.7k]
  ------------------
  792|    472|			CHECK_TLV_SIZE(4, "System capabilities");
  ------------------
  |  |  555|    472|  do {                                                                             \
  |  |  556|    472|    if (tlv_size < (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (556:9): [True: 12, False: 460]
  |  |  ------------------
  |  |  557|     12|      log_warnx("lldp", name " TLV too short received on %s", hardware->h_ifname); \
  |  |  558|     12|      goto malformed;                                                              \
  |  |  559|     12|    }                                                                              \
  |  |  560|    472|  } while (0)
  |  |  ------------------
  |  |  |  Branch (560:12): [Folded, False: 460]
  |  |  ------------------
  ------------------
  793|    460|			chassis->c_cap_available = PEEK_UINT16;
  ------------------
  |  |   63|    460|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  ------------------
  |  |  |  |   60|    460|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    460|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   63|    460|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  794|    460|			chassis->c_cap_enabled = PEEK_UINT16;
  ------------------
  |  |   63|    460|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  ------------------
  |  |  |  |   60|    460|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    460|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   63|    460|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  795|    460|			break;
  796|    911|		case LLDP_TLV_MGMT_ADDR:
  ------------------
  |  |   42|    911|#define LLDP_TLV_MGMT_ADDR 8
  ------------------
  |  Branch (796:3): [True: 911, False: 17.3k]
  ------------------
  797|    911|			CHECK_TLV_SIZE(1, "Management address");
  ------------------
  |  |  555|    911|  do {                                                                             \
  |  |  556|    911|    if (tlv_size < (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (556:9): [True: 5, False: 906]
  |  |  ------------------
  |  |  557|      5|      log_warnx("lldp", name " TLV too short received on %s", hardware->h_ifname); \
  |  |  558|      5|      goto malformed;                                                              \
  |  |  559|      5|    }                                                                              \
  |  |  560|    911|  } while (0)
  |  |  ------------------
  |  |  |  Branch (560:12): [Folded, False: 906]
  |  |  ------------------
  ------------------
  798|    906|			addr_str_length = PEEK_UINT8;
  ------------------
  |  |   62|    906|#define PEEK_UINT8 PEEK(types.f_uint8, )
  |  |  ------------------
  |  |  |  |   60|    906|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    906|      func(type))
  |  |  ------------------
  ------------------
  799|    906|			if (addr_str_length < 1 ||
  ------------------
  |  Branch (799:8): [True: 5, False: 901]
  ------------------
  800|    901|			    addr_str_length > sizeof(addr_str_buffer)) {
  ------------------
  |  Branch (800:8): [True: 7, False: 894]
  ------------------
  801|     12|				log_warnx("lldp",
  802|     12|				    "invalid management address length on %s",
  803|     12|				    hardware->h_ifname);
  804|     12|				goto malformed;
  805|     12|			}
  806|    894|			CHECK_TLV_SIZE(1 + addr_str_length, "Management address");
  ------------------
  |  |  555|    894|  do {                                                                             \
  |  |  556|    894|    if (tlv_size < (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (556:9): [True: 6, False: 888]
  |  |  ------------------
  |  |  557|      6|      log_warnx("lldp", name " TLV too short received on %s", hardware->h_ifname); \
  |  |  558|      6|      goto malformed;                                                              \
  |  |  559|      6|    }                                                                              \
  |  |  560|    894|  } while (0)
  |  |  ------------------
  |  |  |  Branch (560:12): [Folded, False: 888]
  |  |  ------------------
  ------------------
  807|    888|			PEEK_BYTES(addr_str_buffer, addr_str_length);
  ------------------
  |  |   66|    888|  do {                           \
  |  |   67|    888|    memcpy(value, pos, bytes);   \
  |  |   68|    888|    length -= (bytes);           \
  |  |   69|    888|    pos += (bytes);              \
  |  |   70|    888|  } while (0)
  |  |  ------------------
  |  |  |  Branch (70:12): [Folded, False: 888]
  |  |  ------------------
  ------------------
  808|    888|			addr_length = addr_str_length - 1;
  809|    888|			addr_family = addr_str_buffer[0];
  810|    888|			addr_ptr = &addr_str_buffer[1];
  811|    888|			CHECK_TLV_SIZE(1 + addr_str_length + 5, "Management address");
  ------------------
  |  |  555|    888|  do {                                                                             \
  |  |  556|    888|    if (tlv_size < (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (556:9): [True: 5, False: 883]
  |  |  ------------------
  |  |  557|      5|      log_warnx("lldp", name " TLV too short received on %s", hardware->h_ifname); \
  |  |  558|      5|      goto malformed;                                                              \
  |  |  559|      5|    }                                                                              \
  |  |  560|    888|  } while (0)
  |  |  ------------------
  |  |  |  Branch (560:12): [Folded, False: 883]
  |  |  ------------------
  ------------------
  812|    883|			iface_subtype = PEEK_UINT8;
  ------------------
  |  |   62|    883|#define PEEK_UINT8 PEEK(types.f_uint8, )
  |  |  ------------------
  |  |  |  |   60|    883|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    883|      func(type))
  |  |  ------------------
  ------------------
  813|    883|			iface_number = PEEK_UINT32;
  ------------------
  |  |   64|    883|#define PEEK_UINT32 PEEK(types.f_uint32, ntohl)
  |  |  ------------------
  |  |  |  |   60|    883|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    883|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|    883|#define PEEK_UINT32 PEEK(types.f_uint32, ntohl)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  814|       |
  815|    883|			af = lldpd_af_from_lldp_proto(addr_family);
  816|    883|			if (af == LLDPD_AF_UNSPEC) break;
  ------------------
  |  Branch (816:8): [True: 218, False: 665]
  ------------------
  817|    665|			if (iface_subtype == LLDP_MGMT_IFACE_IFINDEX)
  ------------------
  |  |  277|    665|#define LLDP_MGMT_IFACE_IFINDEX 2
  ------------------
  |  Branch (817:8): [True: 427, False: 238]
  ------------------
  818|    427|				iface = iface_number;
  819|    238|			else
  820|    238|				iface = 0;
  821|    665|			mgmt = lldpd_alloc_mgmt(af, addr_ptr, addr_length, iface);
  822|    665|			if (mgmt == NULL) {
  ------------------
  |  Branch (822:8): [True: 1, False: 664]
  ------------------
  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|    665|			TAILQ_INSERT_TAIL(&chassis->c_mgmt, mgmt, m_entries);
  ------------------
  |  Branch (834:4): [Folded, False: 664]
  ------------------
  835|    664|			break;
  836|  10.1k|		case LLDP_TLV_ORG:
  ------------------
  |  |   26|  10.1k|#define LLDP_TLV_ORG 127
  ------------------
  |  Branch (836:3): [True: 10.1k, False: 8.06k]
  ------------------
  837|  10.1k|			CHECK_TLV_SIZE(1 + (int)sizeof(orgid), "Organisational");
  ------------------
  |  |  555|  10.1k|  do {                                                                             \
  |  |  556|  10.1k|    if (tlv_size < (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (556:9): [True: 12, False: 10.1k]
  |  |  ------------------
  |  |  557|     12|      log_warnx("lldp", name " TLV too short received on %s", hardware->h_ifname); \
  |  |  558|     12|      goto malformed;                                                              \
  |  |  559|     12|    }                                                                              \
  |  |  560|  10.1k|  } while (0)
  |  |  ------------------
  |  |  |  Branch (560:12): [Folded, False: 10.1k]
  |  |  ------------------
  ------------------
  838|  10.1k|			PEEK_BYTES(orgid, sizeof(orgid));
  ------------------
  |  |   66|  10.1k|  do {                           \
  |  |   67|  10.1k|    memcpy(value, pos, bytes);   \
  |  |   68|  10.1k|    length -= (bytes);           \
  |  |   69|  10.1k|    pos += (bytes);              \
  |  |   70|  10.1k|  } while (0)
  |  |  ------------------
  |  |  |  Branch (70:12): [Folded, False: 10.1k]
  |  |  ------------------
  ------------------
  839|  10.1k|			unrecognized = 0;
  840|  10.1k|			tlv_subtype = PEEK_UINT8;
  ------------------
  |  |   62|  10.1k|#define PEEK_UINT8 PEEK(types.f_uint8, )
  |  |  ------------------
  |  |  |  |   60|  10.1k|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|  10.1k|      func(type))
  |  |  ------------------
  ------------------
  841|  10.1k|			if (memcmp(dot1, orgid, sizeof(orgid)) == 0) {
  ------------------
  |  Branch (841:8): [True: 1.85k, False: 8.32k]
  ------------------
  842|       |#ifndef ENABLE_DOT1
  843|       |				unrecognized = 1;
  844|       |#else
  845|       |				/* Dot1 */
  846|  1.85k|				switch (tlv_subtype) {
  847|    320|				case LLDP_TLV_DOT1_VLANNAME:
  ------------------
  |  |   63|    320|#define LLDP_TLV_DOT1_VLANNAME 3
  ------------------
  |  Branch (847:5): [True: 320, False: 1.53k]
  ------------------
  848|    320|					CHECK_TLV_SIZE(7, "VLAN");
  ------------------
  |  |  555|    320|  do {                                                                             \
  |  |  556|    320|    if (tlv_size < (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (556:9): [True: 3, False: 317]
  |  |  ------------------
  |  |  557|      3|      log_warnx("lldp", name " TLV too short received on %s", hardware->h_ifname); \
  |  |  558|      3|      goto malformed;                                                              \
  |  |  559|      3|    }                                                                              \
  |  |  560|    320|  } while (0)
  |  |  ------------------
  |  |  |  Branch (560:12): [Folded, False: 317]
  |  |  ------------------
  ------------------
  849|    317|					if ((vlan = (struct lldpd_vlan *)calloc(1,
  ------------------
  |  Branch (849:10): [True: 0, False: 317]
  ------------------
  850|    317|						 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|    317|					vlan->v_vid = PEEK_UINT16;
  ------------------
  |  |   63|    317|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  ------------------
  |  |  |  |   60|    317|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    317|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   63|    317|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  859|    317|					vlan_len = PEEK_UINT8;
  ------------------
  |  |   62|    317|#define PEEK_UINT8 PEEK(types.f_uint8, )
  |  |  ------------------
  |  |  |  |   60|    317|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    317|      func(type))
  |  |  ------------------
  ------------------
  860|    317|					CHECK_TLV_SIZE(7 + vlan_len, "VLAN");
  ------------------
  |  |  555|    317|  do {                                                                             \
  |  |  556|    317|    if (tlv_size < (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (556:9): [True: 10, False: 307]
  |  |  ------------------
  |  |  557|     10|      log_warnx("lldp", name " TLV too short received on %s", hardware->h_ifname); \
  |  |  558|     10|      goto malformed;                                                              \
  |  |  559|     10|    }                                                                              \
  |  |  560|    317|  } while (0)
  |  |  ------------------
  |  |  |  Branch (560:12): [Folded, False: 307]
  |  |  ------------------
  ------------------
  861|    307|					if ((vlan->v_name = (char *)calloc(1,
  ------------------
  |  Branch (861:10): [True: 0, False: 307]
  ------------------
  862|    307|						 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|    307|					PEEK_BYTES(vlan->v_name, vlan_len);
  ------------------
  |  |   66|    307|  do {                           \
  |  |   67|    307|    memcpy(value, pos, bytes);   \
  |  |   68|    307|    length -= (bytes);           \
  |  |   69|    307|    pos += (bytes);              \
  |  |   70|    307|  } while (0)
  |  |  ------------------
  |  |  |  Branch (70:12): [Folded, False: 307]
  |  |  ------------------
  ------------------
  870|    307|					TAILQ_INSERT_TAIL(&port->p_vlans, vlan,
  ------------------
  |  Branch (870:6): [Folded, False: 307]
  ------------------
  871|    307|					    v_entries);
  872|    307|					vlan = NULL;
  873|    307|					break;
  874|    236|				case LLDP_TLV_DOT1_PVID:
  ------------------
  |  |   61|    236|#define LLDP_TLV_DOT1_PVID 1
  ------------------
  |  Branch (874:5): [True: 236, False: 1.62k]
  ------------------
  875|    236|					CHECK_TLV_SIZE(6, "PVID");
  ------------------
  |  |  555|    236|  do {                                                                             \
  |  |  556|    236|    if (tlv_size < (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (556:9): [True: 2, False: 234]
  |  |  ------------------
  |  |  557|      2|      log_warnx("lldp", name " TLV too short received on %s", hardware->h_ifname); \
  |  |  558|      2|      goto malformed;                                                              \
  |  |  559|      2|    }                                                                              \
  |  |  560|    236|  } while (0)
  |  |  ------------------
  |  |  |  Branch (560:12): [Folded, False: 234]
  |  |  ------------------
  ------------------
  876|    234|					port->p_pvid = 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)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  877|    234|					break;
  878|    374|				case LLDP_TLV_DOT1_PPVID:
  ------------------
  |  |   62|    374|#define LLDP_TLV_DOT1_PPVID 2
  ------------------
  |  Branch (878:5): [True: 374, False: 1.48k]
  ------------------
  879|    374|					CHECK_TLV_SIZE(7, "PPVID");
  ------------------
  |  |  555|    374|  do {                                                                             \
  |  |  556|    374|    if (tlv_size < (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (556:9): [True: 2, False: 372]
  |  |  ------------------
  |  |  557|      2|      log_warnx("lldp", name " TLV too short received on %s", hardware->h_ifname); \
  |  |  558|      2|      goto malformed;                                                              \
  |  |  559|      2|    }                                                                              \
  |  |  560|    374|  } while (0)
  |  |  ------------------
  |  |  |  Branch (560:12): [Folded, False: 372]
  |  |  ------------------
  ------------------
  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|    372|					if ((ppvid = (struct lldpd_ppvid *)calloc(1,
  ------------------
  |  Branch (888:10): [True: 0, False: 372]
  ------------------
  889|    372|						 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|    372|					ppvid->p_cap_status = PEEK_UINT8;
  ------------------
  |  |   62|    372|#define PEEK_UINT8 PEEK(types.f_uint8, )
  |  |  ------------------
  |  |  |  |   60|    372|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    372|      func(type))
  |  |  ------------------
  ------------------
  898|    372|					ppvid->p_ppvid = PEEK_UINT16;
  ------------------
  |  |   63|    372|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  ------------------
  |  |  |  |   60|    372|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    372|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   63|    372|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  899|    372|					TAILQ_INSERT_TAIL(&port->p_ppvids, ppvid,
  ------------------
  |  Branch (899:6): [Folded, False: 372]
  ------------------
  900|    372|					    p_entries);
  901|    372|					break;
  902|    448|				case LLDP_TLV_DOT1_PI:
  ------------------
  |  |   64|    448|#define LLDP_TLV_DOT1_PI 4
  ------------------
  |  Branch (902:5): [True: 448, False: 1.40k]
  ------------------
  903|       |					/* validation needed */
  904|       |					/* PI has to be unique if more than
  905|       |					   one PI TLVs are received  - discard
  906|       |					   if duplicate ?? */
  907|    448|					CHECK_TLV_SIZE(5, "PI");
  ------------------
  |  |  555|    448|  do {                                                                             \
  |  |  556|    448|    if (tlv_size < (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (556:9): [True: 1, False: 447]
  |  |  ------------------
  |  |  557|      1|      log_warnx("lldp", name " TLV too short received on %s", hardware->h_ifname); \
  |  |  558|      1|      goto malformed;                                                              \
  |  |  559|      1|    }                                                                              \
  |  |  560|    448|  } while (0)
  |  |  ------------------
  |  |  |  Branch (560:12): [Folded, False: 447]
  |  |  ------------------
  ------------------
  908|    447|					if ((pi = (struct lldpd_pi *)calloc(1,
  ------------------
  |  Branch (908:10): [True: 0, False: 447]
  ------------------
  909|    447|						 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|    447|					pi->p_pi_len = PEEK_UINT8;
  ------------------
  |  |   62|    447|#define PEEK_UINT8 PEEK(types.f_uint8, )
  |  |  ------------------
  |  |  |  |   60|    447|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    447|      func(type))
  |  |  ------------------
  ------------------
  918|    447|					CHECK_TLV_SIZE(5 + pi->p_pi_len, "PI");
  ------------------
  |  |  555|    447|  do {                                                                             \
  |  |  556|    447|    if (tlv_size < (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (556:9): [True: 9, False: 438]
  |  |  ------------------
  |  |  557|      9|      log_warnx("lldp", name " TLV too short received on %s", hardware->h_ifname); \
  |  |  558|      9|      goto malformed;                                                              \
  |  |  559|      9|    }                                                                              \
  |  |  560|    447|  } while (0)
  |  |  ------------------
  |  |  |  Branch (560:12): [Folded, False: 438]
  |  |  ------------------
  ------------------
  919|    438|					if ((pi->p_pi = (char *)calloc(1,
  ------------------
  |  Branch (919:10): [True: 0, False: 438]
  ------------------
  920|    438|						 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|    438|					PEEK_BYTES(pi->p_pi, pi->p_pi_len);
  ------------------
  |  |   66|    438|  do {                           \
  |  |   67|    438|    memcpy(value, pos, bytes);   \
  |  |   68|    438|    length -= (bytes);           \
  |  |   69|    438|    pos += (bytes);              \
  |  |   70|    438|  } while (0)
  |  |  ------------------
  |  |  |  Branch (70:12): [Folded, False: 438]
  |  |  ------------------
  ------------------
  928|    438|					TAILQ_INSERT_TAIL(&port->p_pids, pi, p_entries);
  ------------------
  |  Branch (928:6): [Folded, False: 438]
  ------------------
  929|    438|					pi = NULL;
  930|    438|					break;
  931|    478|				default:
  ------------------
  |  Branch (931:5): [True: 478, False: 1.37k]
  ------------------
  932|       |					/* Unknown Dot1 TLV, ignore it */
  933|    478|					unrecognized = 1;
  934|  1.85k|				}
  935|  1.85k|#endif
  936|  8.32k|			} else if (memcmp(dot3, orgid, sizeof(orgid)) == 0) {
  ------------------
  |  Branch (936:15): [True: 1.33k, False: 6.98k]
  ------------------
  937|       |#ifndef ENABLE_DOT3
  938|       |				unrecognized = 1;
  939|       |#else
  940|       |				/* Dot3 */
  941|  1.33k|				switch (tlv_subtype) {
  942|    197|				case LLDP_TLV_DOT3_MAC:
  ------------------
  |  |   66|    197|#define LLDP_TLV_DOT3_MAC 1
  ------------------
  |  Branch (942:5): [True: 197, False: 1.13k]
  ------------------
  943|    197|					CHECK_TLV_SIZE(9, "MAC/PHY");
  ------------------
  |  |  555|    197|  do {                                                                             \
  |  |  556|    197|    if (tlv_size < (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (556:9): [True: 1, False: 196]
  |  |  ------------------
  |  |  557|      1|      log_warnx("lldp", name " TLV too short received on %s", hardware->h_ifname); \
  |  |  558|      1|      goto malformed;                                                              \
  |  |  559|      1|    }                                                                              \
  |  |  560|    197|  } while (0)
  |  |  ------------------
  |  |  |  Branch (560:12): [Folded, False: 196]
  |  |  ------------------
  ------------------
  944|    196|					port->p_macphy.autoneg_support = PEEK_UINT8;
  ------------------
  |  |   62|    196|#define PEEK_UINT8 PEEK(types.f_uint8, )
  |  |  ------------------
  |  |  |  |   60|    196|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    196|      func(type))
  |  |  ------------------
  ------------------
  945|    196|					port->p_macphy.autoneg_enabled =
  946|    196|					    (port->p_macphy.autoneg_support & 0x2) >> 1;
  947|    196|					port->p_macphy.autoneg_support =
  948|    196|					    port->p_macphy.autoneg_support & 0x1;
  949|    196|					port->p_macphy.autoneg_advertised = PEEK_UINT16;
  ------------------
  |  |   63|    196|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  ------------------
  |  |  |  |   60|    196|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    196|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   63|    196|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  950|    196|					port->p_macphy.mau_type = PEEK_UINT16;
  ------------------
  |  |   63|    196|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  ------------------
  |  |  |  |   60|    196|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    196|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   63|    196|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  951|    196|					break;
  952|    206|				case LLDP_TLV_DOT3_LA:
  ------------------
  |  |   68|    206|#define LLDP_TLV_DOT3_LA 3
  ------------------
  |  Branch (952:5): [True: 206, False: 1.12k]
  ------------------
  953|    206|					CHECK_TLV_SIZE(9, "Link aggregation");
  ------------------
  |  |  555|    206|  do {                                                                             \
  |  |  556|    206|    if (tlv_size < (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (556:9): [True: 4, False: 202]
  |  |  ------------------
  |  |  557|      4|      log_warnx("lldp", name " TLV too short received on %s", hardware->h_ifname); \
  |  |  558|      4|      goto malformed;                                                              \
  |  |  559|      4|    }                                                                              \
  |  |  560|    206|  } while (0)
  |  |  ------------------
  |  |  |  Branch (560:12): [Folded, False: 202]
  |  |  ------------------
  ------------------
  954|    202|					PEEK_DISCARD_UINT8;
  ------------------
  |  |   76|    202|#define PEEK_DISCARD_UINT8 PEEK_DISCARD(1)
  |  |  ------------------
  |  |  |  |   72|    202|  do {                      \
  |  |  |  |   73|    202|    length -= (bytes);      \
  |  |  |  |   74|    202|    pos += (bytes);         \
  |  |  |  |   75|    202|  } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (75:12): [Folded, False: 202]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  955|    202|					port->p_aggregid = PEEK_UINT32;
  ------------------
  |  |   64|    202|#define PEEK_UINT32 PEEK(types.f_uint32, ntohl)
  |  |  ------------------
  |  |  |  |   60|    202|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    202|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|    202|#define PEEK_UINT32 PEEK(types.f_uint32, ntohl)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  956|    202|					break;
  957|    208|				case LLDP_TLV_DOT3_MFS:
  ------------------
  |  |   69|    208|#define LLDP_TLV_DOT3_MFS 4
  ------------------
  |  Branch (957:5): [True: 208, False: 1.12k]
  ------------------
  958|    208|					CHECK_TLV_SIZE(6, "MFS");
  ------------------
  |  |  555|    208|  do {                                                                             \
  |  |  556|    208|    if (tlv_size < (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (556:9): [True: 3, False: 205]
  |  |  ------------------
  |  |  557|      3|      log_warnx("lldp", name " TLV too short received on %s", hardware->h_ifname); \
  |  |  558|      3|      goto malformed;                                                              \
  |  |  559|      3|    }                                                                              \
  |  |  560|    208|  } while (0)
  |  |  ------------------
  |  |  |  Branch (560:12): [Folded, False: 205]
  |  |  ------------------
  ------------------
  959|    205|					port->p_mfs = PEEK_UINT16;
  ------------------
  |  |   63|    205|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  ------------------
  |  |  |  |   60|    205|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    205|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   63|    205|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  960|    205|					break;
  961|    494|				case LLDP_TLV_DOT3_POWER:
  ------------------
  |  |   67|    494|#define LLDP_TLV_DOT3_POWER 2
  ------------------
  |  Branch (961:5): [True: 494, False: 840]
  ------------------
  962|    494|					CHECK_TLV_SIZE(7, "Power");
  ------------------
  |  |  555|    494|  do {                                                                             \
  |  |  556|    494|    if (tlv_size < (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (556:9): [True: 3, False: 491]
  |  |  ------------------
  |  |  557|      3|      log_warnx("lldp", name " TLV too short received on %s", hardware->h_ifname); \
  |  |  558|      3|      goto malformed;                                                              \
  |  |  559|      3|    }                                                                              \
  |  |  560|    494|  } while (0)
  |  |  ------------------
  |  |  |  Branch (560:12): [Folded, False: 491]
  |  |  ------------------
  ------------------
  963|    491|					port->p_power.devicetype = PEEK_UINT8;
  ------------------
  |  |   62|    491|#define PEEK_UINT8 PEEK(types.f_uint8, )
  |  |  ------------------
  |  |  |  |   60|    491|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    491|      func(type))
  |  |  ------------------
  ------------------
  964|    491|					port->p_power.supported =
  965|    491|					    (port->p_power.devicetype & 0x2) >> 1;
  966|    491|					port->p_power.enabled =
  967|    491|					    (port->p_power.devicetype & 0x4) >> 2;
  968|    491|					port->p_power.paircontrol =
  969|    491|					    (port->p_power.devicetype & 0x8) >> 3;
  970|    491|					port->p_power.devicetype =
  971|    491|					    (port->p_power.devicetype & 0x1) ?
  ------------------
  |  Branch (971:10): [True: 106, False: 385]
  ------------------
  972|    106|					    LLDP_DOT3_POWER_PSE :
  ------------------
  |  |  204|    106|#define LLDP_DOT3_POWER_PSE 1
  ------------------
  973|    491|					    LLDP_DOT3_POWER_PD;
  ------------------
  |  |  205|    876|#define LLDP_DOT3_POWER_PD 2
  ------------------
  974|    491|					port->p_power.pairs = PEEK_UINT8;
  ------------------
  |  |   62|    491|#define PEEK_UINT8 PEEK(types.f_uint8, )
  |  |  ------------------
  |  |  |  |   60|    491|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    491|      func(type))
  |  |  ------------------
  ------------------
  975|    491|					port->p_power.class = PEEK_UINT8;
  ------------------
  |  |   62|    491|#define PEEK_UINT8 PEEK(types.f_uint8, )
  |  |  ------------------
  |  |  |  |   60|    491|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    491|      func(type))
  |  |  ------------------
  ------------------
  976|       |					/* 802.3at? */
  977|    491|					if (tlv_size >= 12) {
  ------------------
  |  Branch (977:10): [True: 291, False: 200]
  ------------------
  978|    291|						port->p_power.powertype = PEEK_UINT8;
  ------------------
  |  |   62|    291|#define PEEK_UINT8 PEEK(types.f_uint8, )
  |  |  ------------------
  |  |  |  |   60|    291|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    291|      func(type))
  |  |  ------------------
  ------------------
  979|    291|						port->p_power.source =
  980|    291|						    (port->p_power.powertype &
  981|    291|							(1 << 5 | 1 << 4)) >>
  982|    291|						    4;
  983|    291|						port->p_power.priority =
  984|    291|						    (port->p_power.powertype &
  985|    291|							(1 << 1 | 1 << 0));
  986|    291|						port->p_power.powertype =
  987|    291|						    (port->p_power.powertype &
  ------------------
  |  Branch (987:11): [True: 110, False: 181]
  ------------------
  988|    291|							(1 << 7)) ?
  989|    110|						    LLDP_DOT3_POWER_8023AT_TYPE1 :
  ------------------
  |  |  213|    110|#define LLDP_DOT3_POWER_8023AT_TYPE1 1
  ------------------
  990|    291|						    LLDP_DOT3_POWER_8023AT_TYPE2;
  ------------------
  |  |  214|    472|#define LLDP_DOT3_POWER_8023AT_TYPE2 2
  ------------------
  991|    291|						port->p_power.requested = PEEK_UINT16;
  ------------------
  |  |   63|    291|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  ------------------
  |  |  |  |   60|    291|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    291|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   63|    291|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  992|    291|						port->p_power.allocated = PEEK_UINT16;
  ------------------
  |  |   63|    291|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  ------------------
  |  |  |  |   60|    291|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    291|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   63|    291|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  993|    291|					} else
  994|    200|						port->p_power.powertype =
  995|    200|						    LLDP_DOT3_POWER_8023AT_OFF;
  ------------------
  |  |  212|    200|#define LLDP_DOT3_POWER_8023AT_OFF 0
  ------------------
  996|       |					/* 802.3bt? */
  997|    491|					if (tlv_size >= 29) {
  ------------------
  |  Branch (997:10): [True: 77, False: 414]
  ------------------
  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|    414|					} else {
 1034|    414|						port->p_power.type_ext =
 1035|    414|						    LLDP_DOT3_POWER_8023BT_OFF;
  ------------------
  |  |  217|    414|#define LLDP_DOT3_POWER_8023BT_OFF 0
  ------------------
 1036|    414|					}
 1037|    491|					break;
 1038|    229|				default:
  ------------------
  |  Branch (1038:5): [True: 229, False: 1.10k]
  ------------------
 1039|       |					/* Unknown Dot3 TLV, ignore it */
 1040|    229|					unrecognized = 1;
 1041|  1.33k|				}
 1042|  1.33k|#endif
 1043|  6.98k|			} else if (memcmp(med, orgid, sizeof(orgid)) == 0) {
  ------------------
  |  Branch (1043:15): [True: 5.59k, False: 1.39k]
  ------------------
 1044|       |				/* LLDP-MED */
 1045|       |#ifndef ENABLE_LLDPMED
 1046|       |				unrecognized = 1;
 1047|       |#else
 1048|  5.59k|				u_int32_t policy;
 1049|  5.59k|				unsigned loctype;
 1050|  5.59k|				unsigned power;
 1051|       |
 1052|  5.59k|				switch (tlv_subtype) {
 1053|    243|				case LLDP_TLV_MED_CAP:
  ------------------
  |  |   71|    243|#define LLDP_TLV_MED_CAP 1
  ------------------
  |  Branch (1053:5): [True: 243, False: 5.34k]
  ------------------
 1054|    243|					CHECK_TLV_SIZE(7, "LLDP-MED capabilities");
  ------------------
  |  |  555|    243|  do {                                                                             \
  |  |  556|    243|    if (tlv_size < (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (556:9): [True: 1, False: 242]
  |  |  ------------------
  |  |  557|      1|      log_warnx("lldp", name " TLV too short received on %s", hardware->h_ifname); \
  |  |  558|      1|      goto malformed;                                                              \
  |  |  559|      1|    }                                                                              \
  |  |  560|    243|  } while (0)
  |  |  ------------------
  |  |  |  Branch (560:12): [Folded, False: 242]
  |  |  ------------------
  ------------------
 1055|    242|					chassis->c_med_cap_available = PEEK_UINT16;
  ------------------
  |  |   63|    242|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  ------------------
  |  |  |  |   60|    242|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    242|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   63|    242|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1056|    242|					chassis->c_med_type = PEEK_UINT8;
  ------------------
  |  |   62|    242|#define PEEK_UINT8 PEEK(types.f_uint8, )
  |  |  ------------------
  |  |  |  |   60|    242|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    242|      func(type))
  |  |  ------------------
  ------------------
 1057|    242|					port->p_med_cap_enabled |= LLDP_MED_CAP_CAP;
  ------------------
  |  |  329|    242|#define LLDP_MED_CAP_CAP 0x01
  ------------------
 1058|    242|					break;
 1059|    706|				case LLDP_TLV_MED_POLICY:
  ------------------
  |  |   72|    706|#define LLDP_TLV_MED_POLICY 2
  ------------------
  |  Branch (1059:5): [True: 706, False: 4.88k]
  ------------------
 1060|    706|					CHECK_TLV_SIZE(8, "LLDP-MED policy");
  ------------------
  |  |  555|    706|  do {                                                                             \
  |  |  556|    706|    if (tlv_size < (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (556:9): [True: 3, False: 703]
  |  |  ------------------
  |  |  557|      3|      log_warnx("lldp", name " TLV too short received on %s", hardware->h_ifname); \
  |  |  558|      3|      goto malformed;                                                              \
  |  |  559|      3|    }                                                                              \
  |  |  560|    706|  } while (0)
  |  |  ------------------
  |  |  |  Branch (560:12): [Folded, False: 703]
  |  |  ------------------
  ------------------
 1061|    703|					policy = PEEK_UINT32;
  ------------------
  |  |   64|    703|#define PEEK_UINT32 PEEK(types.f_uint32, ntohl)
  |  |  ------------------
  |  |  |  |   60|    703|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    703|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|    703|#define PEEK_UINT32 PEEK(types.f_uint32, ntohl)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1062|    703|					if (((policy >> 24) < 1) ||
  ------------------
  |  Branch (1062:10): [True: 226, False: 477]
  ------------------
 1063|    477|					    ((policy >> 24) > LLDP_MED_APPTYPE_LAST)) {
  ------------------
  |  |  295|    477|#define LLDP_MED_APPTYPE_LAST LLDP_MED_APPTYPE_VIDEOSIGNAL
  |  |  ------------------
  |  |  |  |  294|    477|#define LLDP_MED_APPTYPE_VIDEOSIGNAL 8
  |  |  ------------------
  ------------------
  |  Branch (1063:10): [True: 228, False: 249]
  ------------------
 1064|    454|						log_info("lldp",
 1065|    454|						    "unknown policy field %d "
 1066|    454|						    "received on %s",
 1067|    454|						    policy, hardware->h_ifname);
 1068|    454|						break;
 1069|    454|					}
 1070|    249|					port->p_med_policy[(policy >> 24) - 1].type =
 1071|    249|					    (policy >> 24);
 1072|    249|					port->p_med_policy[(policy >> 24) - 1].unknown =
 1073|    249|					    ((policy & 0x800000) != 0);
 1074|    249|					port->p_med_policy[(policy >> 24) - 1].tagged =
 1075|    249|					    ((policy & 0x400000) != 0);
 1076|    249|					port->p_med_policy[(policy >> 24) - 1].vid =
 1077|    249|					    (policy & 0x001FFE00) >> 9;
 1078|    249|					port->p_med_policy[(policy >> 24) - 1]
 1079|    249|					    .priority = (policy & 0x1C0) >> 6;
 1080|    249|					port->p_med_policy[(policy >> 24) - 1].dscp =
 1081|    249|					    policy & 0x3F;
 1082|    249|					port->p_med_cap_enabled |= LLDP_MED_CAP_POLICY;
  ------------------
  |  |  330|    249|#define LLDP_MED_CAP_POLICY 0x02
  ------------------
 1083|    249|					break;
 1084|    634|				case LLDP_TLV_MED_LOCATION:
  ------------------
  |  |   73|    634|#define LLDP_TLV_MED_LOCATION 3
  ------------------
  |  Branch (1084:5): [True: 634, False: 4.95k]
  ------------------
 1085|    634|					CHECK_TLV_SIZE(5, "LLDP-MED Location");
  ------------------
  |  |  555|    634|  do {                                                                             \
  |  |  556|    634|    if (tlv_size < (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (556:9): [True: 2, False: 632]
  |  |  ------------------
  |  |  557|      2|      log_warnx("lldp", name " TLV too short received on %s", hardware->h_ifname); \
  |  |  558|      2|      goto malformed;                                                              \
  |  |  559|      2|    }                                                                              \
  |  |  560|    634|  } while (0)
  |  |  ------------------
  |  |  |  Branch (560:12): [Folded, False: 632]
  |  |  ------------------
  ------------------
 1086|    632|					loctype = PEEK_UINT8;
  ------------------
  |  |   62|    632|#define PEEK_UINT8 PEEK(types.f_uint8, )
  |  |  ------------------
  |  |  |  |   60|    632|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    632|      func(type))
  |  |  ------------------
  ------------------
 1087|    632|					if ((loctype < 1) ||
  ------------------
  |  Branch (1087:10): [True: 201, False: 431]
  ------------------
 1088|    431|					    (loctype > LLDP_MED_LOCFORMAT_LAST)) {
  ------------------
  |  |  301|    431|#define LLDP_MED_LOCFORMAT_LAST LLDP_MED_LOCFORMAT_ELIN
  |  |  ------------------
  |  |  |  |  300|    431|#define LLDP_MED_LOCFORMAT_ELIN 3
  |  |  ------------------
  ------------------
  |  Branch (1088:10): [True: 226, False: 205]
  ------------------
 1089|    427|						log_info("lldp",
 1090|    427|						    "unknown location type "
 1091|    427|						    "received on %s",
 1092|    427|						    hardware->h_ifname);
 1093|    427|						break;
 1094|    427|					}
 1095|    205|					free(port->p_med_location[loctype - 1].data);
 1096|    205|					if ((port->p_med_location[loctype - 1].data =
  ------------------
  |  Branch (1096:10): [True: 0, False: 205]
  ------------------
 1097|    205|						    (char *)malloc(tlv_size - 5)) ==
 1098|    205|					    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|    205|					PEEK_BYTES(
  ------------------
  |  |   66|    205|  do {                           \
  |  |   67|    205|    memcpy(value, pos, bytes);   \
  |  |   68|    205|    length -= (bytes);           \
  |  |   69|    205|    pos += (bytes);              \
  |  |   70|    205|  } while (0)
  |  |  ------------------
  |  |  |  Branch (70:12): [Folded, False: 205]
  |  |  ------------------
  ------------------
 1107|    205|					    port->p_med_location[loctype - 1].data,
 1108|    205|					    tlv_size - 5);
 1109|    205|					port->p_med_location[loctype - 1].data_len =
 1110|    205|					    tlv_size - 5;
 1111|    205|					port->p_med_location[loctype - 1].format =
 1112|    205|					    loctype;
 1113|    205|					port->p_med_cap_enabled |=
 1114|    205|					    LLDP_MED_CAP_LOCATION;
  ------------------
  |  |  331|    205|#define LLDP_MED_CAP_LOCATION 0x04
  ------------------
 1115|    205|					break;
 1116|  1.84k|				case LLDP_TLV_MED_MDI:
  ------------------
  |  |   74|  1.84k|#define LLDP_TLV_MED_MDI 4
  ------------------
  |  Branch (1116:5): [True: 1.84k, False: 3.74k]
  ------------------
 1117|  1.84k|					CHECK_TLV_SIZE(7, "LLDP-MED PoE-MDI");
  ------------------
  |  |  555|  1.84k|  do {                                                                             \
  |  |  556|  1.84k|    if (tlv_size < (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (556:9): [True: 3, False: 1.84k]
  |  |  ------------------
  |  |  557|      3|      log_warnx("lldp", name " TLV too short received on %s", hardware->h_ifname); \
  |  |  558|      3|      goto malformed;                                                              \
  |  |  559|      3|    }                                                                              \
  |  |  560|  1.84k|  } while (0)
  |  |  ------------------
  |  |  |  Branch (560:12): [Folded, False: 1.84k]
  |  |  ------------------
  ------------------
 1118|  1.84k|					power = PEEK_UINT8;
  ------------------
  |  |   62|  1.84k|#define PEEK_UINT8 PEEK(types.f_uint8, )
  |  |  ------------------
  |  |  |  |   60|  1.84k|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|  1.84k|      func(type))
  |  |  ------------------
  ------------------
 1119|  1.84k|					switch (power & 0xC0) {
 1120|    849|					case 0x0:
  ------------------
  |  Branch (1120:6): [True: 849, False: 992]
  ------------------
 1121|    849|						port->p_med_power.devicetype =
 1122|    849|						    LLDP_MED_POW_TYPE_PSE;
  ------------------
  |  |  311|    849|#define LLDP_MED_POW_TYPE_PSE 1
  ------------------
 1123|    849|						port->p_med_cap_enabled |=
 1124|    849|						    LLDP_MED_CAP_MDI_PSE;
  ------------------
  |  |  332|    849|#define LLDP_MED_CAP_MDI_PSE 0x08
  ------------------
 1125|    849|						switch (power & 0x30) {
 1126|    214|						case 0x0:
  ------------------
  |  Branch (1126:7): [True: 214, False: 635]
  ------------------
 1127|    214|							port->p_med_power.source =
 1128|    214|							    LLDP_MED_POW_SOURCE_UNKNOWN;
  ------------------
  |  |  315|    214|#define LLDP_MED_POW_SOURCE_UNKNOWN 1
  ------------------
 1129|    214|							break;
 1130|    218|						case 0x10:
  ------------------
  |  Branch (1130:7): [True: 218, False: 631]
  ------------------
 1131|    218|							port->p_med_power.source =
 1132|    218|							    LLDP_MED_POW_SOURCE_PRIMARY;
  ------------------
  |  |  316|    218|#define LLDP_MED_POW_SOURCE_PRIMARY 2
  ------------------
 1133|    218|							break;
 1134|    222|						case 0x20:
  ------------------
  |  Branch (1134:7): [True: 222, False: 627]
  ------------------
 1135|    222|							port->p_med_power.source =
 1136|    222|							    LLDP_MED_POW_SOURCE_BACKUP;
  ------------------
  |  |  317|    222|#define LLDP_MED_POW_SOURCE_BACKUP 3
  ------------------
 1137|    222|							break;
 1138|    195|						default:
  ------------------
  |  Branch (1138:7): [True: 195, False: 654]
  ------------------
 1139|    195|							port->p_med_power.source =
 1140|    195|							    LLDP_MED_POW_SOURCE_RESERVED;
  ------------------
  |  |  318|    195|#define LLDP_MED_POW_SOURCE_RESERVED 4
  ------------------
 1141|    849|						}
 1142|    849|						break;
 1143|    849|					case 0x40:
  ------------------
  |  Branch (1143:6): [True: 726, False: 1.11k]
  ------------------
 1144|    726|						port->p_med_power.devicetype =
 1145|    726|						    LLDP_MED_POW_TYPE_PD;
  ------------------
  |  |  312|    726|#define LLDP_MED_POW_TYPE_PD 2
  ------------------
 1146|    726|						port->p_med_cap_enabled |=
 1147|    726|						    LLDP_MED_CAP_MDI_PD;
  ------------------
  |  |  333|    726|#define LLDP_MED_CAP_MDI_PD 0x10
  ------------------
 1148|    726|						switch (power & 0x30) {
 1149|    110|						case 0x0:
  ------------------
  |  Branch (1149:7): [True: 110, False: 616]
  ------------------
 1150|    110|							port->p_med_power.source =
 1151|    110|							    LLDP_MED_POW_SOURCE_UNKNOWN;
  ------------------
  |  |  315|    110|#define LLDP_MED_POW_SOURCE_UNKNOWN 1
  ------------------
 1152|    110|							break;
 1153|    201|						case 0x10:
  ------------------
  |  Branch (1153:7): [True: 201, False: 525]
  ------------------
 1154|    201|							port->p_med_power.source =
 1155|    201|							    LLDP_MED_POW_SOURCE_PSE;
  ------------------
  |  |  319|    201|#define LLDP_MED_POW_SOURCE_PSE 5
  ------------------
 1156|    201|							break;
 1157|    198|						case 0x20:
  ------------------
  |  Branch (1157:7): [True: 198, False: 528]
  ------------------
 1158|    198|							port->p_med_power.source =
 1159|    198|							    LLDP_MED_POW_SOURCE_LOCAL;
  ------------------
  |  |  320|    198|#define LLDP_MED_POW_SOURCE_LOCAL 6
  ------------------
 1160|    198|							break;
 1161|    217|						default:
  ------------------
  |  Branch (1161:7): [True: 217, False: 509]
  ------------------
 1162|    217|							port->p_med_power.source =
 1163|    217|							    LLDP_MED_POW_SOURCE_BOTH;
  ------------------
  |  |  321|    217|#define LLDP_MED_POW_SOURCE_BOTH 7
  ------------------
 1164|    726|						}
 1165|    726|						break;
 1166|    726|					default:
  ------------------
  |  Branch (1166:6): [True: 266, False: 1.57k]
  ------------------
 1167|    266|						port->p_med_power.devicetype =
 1168|    266|						    LLDP_MED_POW_TYPE_RESERVED;
  ------------------
  |  |  313|    266|#define LLDP_MED_POW_TYPE_RESERVED 3
  ------------------
 1169|  1.84k|					}
 1170|  1.84k|					if ((power & 0x0F) > LLDP_MED_POW_PRIO_LOW)
  ------------------
  |  |  326|  1.84k|#define LLDP_MED_POW_PRIO_LOW 3
  ------------------
  |  Branch (1170:10): [True: 1.07k, False: 768]
  ------------------
 1171|  1.07k|						port->p_med_power.priority =
 1172|  1.07k|						    LLDP_MED_POW_PRIO_UNKNOWN;
  ------------------
  |  |  323|  1.07k|#define LLDP_MED_POW_PRIO_UNKNOWN 0
  ------------------
 1173|    768|					else
 1174|    768|						port->p_med_power.priority =
 1175|    768|						    power & 0x0F;
 1176|  1.84k|					port->p_med_power.val = PEEK_UINT16;
  ------------------
  |  |   63|  1.84k|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  ------------------
  |  |  |  |   60|  1.84k|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|  1.84k|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   63|  1.84k|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1177|  1.84k|					break;
 1178|    212|				case LLDP_TLV_MED_IV_HW:
  ------------------
  |  |   75|    212|#define LLDP_TLV_MED_IV_HW 5
  ------------------
  |  Branch (1178:5): [True: 212, False: 5.37k]
  ------------------
 1179|    494|				case LLDP_TLV_MED_IV_SW:
  ------------------
  |  |   77|    494|#define LLDP_TLV_MED_IV_SW 7
  ------------------
  |  Branch (1179:5): [True: 282, False: 5.30k]
  ------------------
 1180|    720|				case LLDP_TLV_MED_IV_FW:
  ------------------
  |  |   76|    720|#define LLDP_TLV_MED_IV_FW 6
  ------------------
  |  Branch (1180:5): [True: 226, False: 5.36k]
  ------------------
 1181|  1.13k|				case LLDP_TLV_MED_IV_SN:
  ------------------
  |  |   78|  1.13k|#define LLDP_TLV_MED_IV_SN 8
  ------------------
  |  Branch (1181:5): [True: 411, False: 5.17k]
  ------------------
 1182|  1.33k|				case LLDP_TLV_MED_IV_MANUF:
  ------------------
  |  |   79|  1.33k|#define LLDP_TLV_MED_IV_MANUF 9
  ------------------
  |  Branch (1182:5): [True: 204, False: 5.38k]
  ------------------
 1183|  1.60k|				case LLDP_TLV_MED_IV_MODEL:
  ------------------
  |  |   80|  1.60k|#define LLDP_TLV_MED_IV_MODEL 10
  ------------------
  |  Branch (1183:5): [True: 271, False: 5.31k]
  ------------------
 1184|  1.88k|				case LLDP_TLV_MED_IV_ASSET:
  ------------------
  |  |   81|  1.88k|#define LLDP_TLV_MED_IV_ASSET 11
  ------------------
  |  Branch (1184:5): [True: 275, False: 5.31k]
  ------------------
 1185|  1.88k|					if (tlv_size <= 4)
  ------------------
  |  Branch (1185:10): [True: 1.45k, False: 423]
  ------------------
 1186|  1.45k|						b = NULL;
 1187|    423|					else {
 1188|    423|						if ((b = (char *)malloc(
  ------------------
  |  Branch (1188:11): [True: 0, False: 423]
  ------------------
 1189|    423|							 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|    423|						PEEK_BYTES(b, tlv_size - 4);
  ------------------
  |  |   66|    423|  do {                           \
  |  |   67|    423|    memcpy(value, pos, bytes);   \
  |  |   68|    423|    length -= (bytes);           \
  |  |   69|    423|    pos += (bytes);              \
  |  |   70|    423|  } while (0)
  |  |  ------------------
  |  |  |  Branch (70:12): [Folded, False: 423]
  |  |  ------------------
  ------------------
 1199|    423|						b[tlv_size - 4] = '\0';
 1200|    423|					}
 1201|  1.88k|					switch (tlv_subtype) {
 1202|    212|					case LLDP_TLV_MED_IV_HW:
  ------------------
  |  |   75|    212|#define LLDP_TLV_MED_IV_HW 5
  ------------------
  |  Branch (1202:6): [True: 212, False: 1.66k]
  ------------------
 1203|    212|						free(chassis->c_med_hw);
 1204|    212|						chassis->c_med_hw = b;
 1205|    212|						break;
 1206|    226|					case LLDP_TLV_MED_IV_FW:
  ------------------
  |  |   76|    226|#define LLDP_TLV_MED_IV_FW 6
  ------------------
  |  Branch (1206:6): [True: 226, False: 1.65k]
  ------------------
 1207|    226|						free(chassis->c_med_fw);
 1208|    226|						chassis->c_med_fw = b;
 1209|    226|						break;
 1210|    282|					case LLDP_TLV_MED_IV_SW:
  ------------------
  |  |   77|    282|#define LLDP_TLV_MED_IV_SW 7
  ------------------
  |  Branch (1210:6): [True: 282, False: 1.59k]
  ------------------
 1211|    282|						free(chassis->c_med_sw);
 1212|    282|						chassis->c_med_sw = b;
 1213|    282|						break;
 1214|    411|					case LLDP_TLV_MED_IV_SN:
  ------------------
  |  |   78|    411|#define LLDP_TLV_MED_IV_SN 8
  ------------------
  |  Branch (1214:6): [True: 411, False: 1.47k]
  ------------------
 1215|    411|						free(chassis->c_med_sn);
 1216|    411|						chassis->c_med_sn = b;
 1217|    411|						break;
 1218|    204|					case LLDP_TLV_MED_IV_MANUF:
  ------------------
  |  |   79|    204|#define LLDP_TLV_MED_IV_MANUF 9
  ------------------
  |  Branch (1218:6): [True: 204, False: 1.67k]
  ------------------
 1219|    204|						free(chassis->c_med_manuf);
 1220|    204|						chassis->c_med_manuf = b;
 1221|    204|						break;
 1222|    271|					case LLDP_TLV_MED_IV_MODEL:
  ------------------
  |  |   80|    271|#define LLDP_TLV_MED_IV_MODEL 10
  ------------------
  |  Branch (1222:6): [True: 271, False: 1.61k]
  ------------------
 1223|    271|						free(chassis->c_med_model);
 1224|    271|						chassis->c_med_model = b;
 1225|    271|						break;
 1226|    275|					case LLDP_TLV_MED_IV_ASSET:
  ------------------
  |  |   81|    275|#define LLDP_TLV_MED_IV_ASSET 11
  ------------------
  |  Branch (1226:6): [True: 275, False: 1.60k]
  ------------------
 1227|    275|						free(chassis->c_med_asset);
 1228|    275|						chassis->c_med_asset = b;
 1229|    275|						break;
 1230|      0|					default:
  ------------------
  |  Branch (1230:6): [True: 0, False: 1.88k]
  ------------------
 1231|       |						/* unreachable */
 1232|      0|						free(b);
 1233|      0|						break;
 1234|  1.88k|					}
 1235|  1.88k|					port->p_med_cap_enabled |= LLDP_MED_CAP_IV;
  ------------------
  |  |  334|  1.88k|#define LLDP_MED_CAP_IV 0x20
  ------------------
 1236|  1.88k|					break;
 1237|    282|				default:
  ------------------
  |  Branch (1237:5): [True: 282, False: 5.30k]
  ------------------
 1238|       |					/* Unknown LLDP MED, ignore it */
 1239|    282|					hardware->h_rx_unrecognized_cnt++;
 1240|  5.59k|				}
 1241|  5.59k|#endif /* ENABLE_LLDPMED */
 1242|  5.59k|			} else if (memcmp(dcbx, orgid, sizeof(orgid)) == 0) {
  ------------------
  |  Branch (1242:15): [True: 281, False: 1.11k]
  ------------------
 1243|    281|				log_debug("lldp",
 1244|    281|				    "unsupported DCBX tlv received on %s - ignore",
 1245|    281|				    hardware->h_ifname);
 1246|    281|				unrecognized = 1;
 1247|  1.11k|			} else {
 1248|  1.11k|				log_debug("lldp",
 1249|  1.11k|				    "unknown org tlv [%02x:%02x:%02x] received on %s",
 1250|  1.11k|				    orgid[0], orgid[1], orgid[2], hardware->h_ifname);
 1251|  1.11k|				unrecognized = 1;
 1252|  1.11k|			}
 1253|  10.1k|			if (unrecognized) {
  ------------------
  |  Branch (1253:8): [True: 2.10k, False: 8.02k]
  ------------------
 1254|  2.10k|				hardware->h_rx_unrecognized_cnt++;
 1255|  2.10k|#ifdef ENABLE_CUSTOM
 1256|  2.10k|				custom = (struct lldpd_custom *)calloc(1,
 1257|  2.10k|				    sizeof(struct lldpd_custom));
 1258|  2.10k|				if (!custom) {
  ------------------
  |  Branch (1258:9): [True: 0, False: 2.10k]
  ------------------
 1259|      0|					log_warn("lldp",
 1260|      0|					    "unable to allocate memory for custom TLV");
 1261|      0|					goto malformed;
 1262|      0|				}
 1263|  2.10k|				custom->oui_info_len = tlv_size > 4 ? tlv_size - 4 : 0;
  ------------------
  |  Branch (1263:28): [True: 622, False: 1.48k]
  ------------------
 1264|  2.10k|				memcpy(custom->oui, orgid, sizeof(custom->oui));
 1265|  2.10k|				custom->subtype = tlv_subtype;
 1266|  2.10k|				if (custom->oui_info_len > 0) {
  ------------------
  |  Branch (1266:9): [True: 622, False: 1.48k]
  ------------------
 1267|    622|					custom->oui_info = malloc(custom->oui_info_len);
 1268|    622|					if (!custom->oui_info) {
  ------------------
  |  Branch (1268:10): [True: 0, False: 622]
  ------------------
 1269|      0|						log_warn("lldp",
 1270|      0|						    "unable to allocate memory for custom TLV data");
 1271|      0|						goto malformed;
 1272|      0|					}
 1273|    622|					PEEK_BYTES(custom->oui_info,
  ------------------
  |  |   66|    622|  do {                           \
  |  |   67|    622|    memcpy(value, pos, bytes);   \
  |  |   68|    622|    length -= (bytes);           \
  |  |   69|    622|    pos += (bytes);              \
  |  |   70|    622|  } while (0)
  |  |  ------------------
  |  |  |  Branch (70:12): [Folded, False: 622]
  |  |  ------------------
  ------------------
 1274|    622|					    custom->oui_info_len);
 1275|    622|				}
 1276|  2.10k|				TAILQ_INSERT_TAIL(&port->p_custom_list, custom, next);
  ------------------
  |  Branch (1276:5): [Folded, False: 2.10k]
  ------------------
 1277|  2.10k|				custom = NULL;
 1278|  2.10k|#endif
 1279|  2.10k|			}
 1280|  10.1k|			break;
 1281|  10.1k|		default:
  ------------------
  |  Branch (1281:3): [True: 741, False: 17.5k]
  ------------------
 1282|    741|			log_warnx("lldp", "unknown tlv (%d) received on %s", tlv_type,
 1283|    741|			    hardware->h_ifname);
 1284|    741|			hardware->h_rx_unrecognized_cnt++;
 1285|    741|			break;
 1286|  18.2k|		}
 1287|  18.1k|		if (pos > tlv + tlv_size) {
  ------------------
  |  Branch (1287:7): [True: 0, False: 18.1k]
  ------------------
 1288|      0|			log_warnx("lldp", "BUG: already past TLV!");
 1289|      0|			goto malformed;
 1290|      0|		}
 1291|  18.1k|		PEEK_DISCARD(tlv + tlv_size - pos);
  ------------------
  |  |   72|  18.1k|  do {                      \
  |  |   73|  18.1k|    length -= (bytes);      \
  |  |   74|  18.1k|    pos += (bytes);         \
  |  |   75|  18.1k|  } while (0)
  |  |  ------------------
  |  |  |  Branch (75:12): [Folded, False: 18.1k]
  |  |  ------------------
  ------------------
 1292|  18.1k|	}
 1293|       |
 1294|       |	/* Some random check */
 1295|    788|	if ((chassis->c_id == NULL) || (port->p_id == NULL) || (!ttl_received) ||
  ------------------
  |  Branch (1295:6): [True: 542, False: 246]
  |  Branch (1295:33): [True: 26, False: 220]
  |  Branch (1295:57): [True: 7, False: 213]
  ------------------
 1296|    659|	    (gotend == 0)) {
  ------------------
  |  Branch (1296:6): [True: 84, False: 129]
  ------------------
 1297|    659|		log_warnx("lldp",
 1298|    659|		    "some mandatory tlv are missing for frame received on %s",
 1299|    659|		    hardware->h_ifname);
 1300|    659|		goto malformed;
 1301|    659|	}
 1302|    129|	*newchassis = chassis;
 1303|    129|	*newport = port;
 1304|    129|	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|    788|}
lldp.c:lldpd_af_from_lldp_proto:
   43|    883|{
   44|    883|	switch (proto) {
   45|    441|	case LLDP_MGMT_ADDR_IP4:
  ------------------
  |  |  273|    441|#define LLDP_MGMT_ADDR_IP4 1
  ------------------
  |  Branch (45:2): [True: 441, False: 442]
  ------------------
   46|    441|		return LLDPD_AF_IPV4;
   47|    224|	case LLDP_MGMT_ADDR_IP6:
  ------------------
  |  |  274|    224|#define LLDP_MGMT_ADDR_IP6 2
  ------------------
  |  Branch (47:2): [True: 224, False: 659]
  ------------------
   48|    224|		return LLDPD_AF_IPV6;
   49|    218|	default:
  ------------------
  |  Branch (49:2): [True: 218, False: 665]
  ------------------
   50|    218|		return LLDPD_AF_UNSPEC;
   51|    883|	}
   52|    883|}

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

log_register:
   64|  1.15k|{
   65|  1.15k|	logh = cb;
   66|  1.15k|}
log_warn:
  190|      1|{
  191|      1|	char *nfmt = NULL;
  192|      1|	va_list ap;
  193|       |
  194|       |	/* best effort to even work in out of memory situations */
  195|      1|	if (emsg == NULL)
  ------------------
  |  Branch (195:6): [True: 0, False: 1]
  ------------------
  196|      0|		logit(LOG_WARNING, "%s", strerror(errno));
  197|      1|	else {
  198|      1|		va_start(ap, emsg);
  199|       |
  200|      1|		if (asprintf(&nfmt, "%s: %s", emsg, strerror(errno)) == -1) {
  ------------------
  |  Branch (200:7): [True: 0, False: 1]
  ------------------
  201|       |			/* we tried it... */
  202|      0|			vlog(LOG_WARNING, token, emsg, ap);
  203|      0|			logit(LOG_WARNING, "%s", strerror(errno));
  204|      1|		} else {
  205|      1|			vlog(LOG_WARNING, token, nfmt, ap);
  206|      1|			free(nfmt);
  207|      1|		}
  208|       |		va_end(ap);
  209|      1|	}
  210|      1|}
log_warnx:
  214|  1.69k|{
  215|  1.69k|	va_list ap;
  216|       |
  217|  1.69k|	va_start(ap, emsg);
  218|  1.69k|	vlog(LOG_WARNING, token, emsg, ap);
  219|       |	va_end(ap);
  220|  1.69k|}
log_info:
  224|    952|{
  225|    952|	va_list ap;
  226|       |
  227|    952|	if (use_syslog || debug > 0 || logh) {
  ------------------
  |  Branch (227:6): [True: 0, False: 952]
  |  Branch (227:20): [True: 0, False: 952]
  |  Branch (227:33): [True: 952, False: 0]
  ------------------
  228|    952|		va_start(ap, emsg);
  229|    952|		vlog(LOG_INFO, token, emsg, ap);
  230|       |		va_end(ap);
  231|    952|	}
  232|    952|}
log_debug:
  247|  9.85k|{
  248|  9.85k|	va_list ap;
  249|       |
  250|  9.85k|	if ((debug > 1 && log_debug_accept_token(token)) || logh) {
  ------------------
  |  Branch (250:7): [True: 0, False: 9.85k]
  |  Branch (250:20): [True: 0, False: 0]
  |  Branch (250:54): [True: 9.85k, False: 0]
  ------------------
  251|  9.85k|		va_start(ap, emsg);
  252|  9.85k|		vlog(LOG_DEBUG, token, emsg, ap);
  253|       |		va_end(ap);
  254|  9.85k|	}
  255|  9.85k|}
log.c:vlog:
  154|  12.5k|{
  155|  12.5k|	if (logh) {
  ------------------
  |  Branch (155:6): [True: 12.5k, False: 0]
  ------------------
  156|  12.5k|		char *result = NULL;
  157|  12.5k|		if (vasprintf(&result, fmt, ap) != -1) {
  ------------------
  |  Branch (157:7): [True: 12.5k, False: 0]
  ------------------
  158|  12.5k|			logh(pri, result);
  159|  12.5k|			free(result);
  160|  12.5k|			return;
  161|  12.5k|		}
  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.5k|	}
  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.5k|void donothing(int pri, const char *msg) {};
LLVMFuzzerTestOneInput:
   28|  1.18k|{
   29|  1.18k|	if (Size < kMinInputLength || Size > kMaxInputLength) {
  ------------------
  |  |   20|  2.36k|#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.15k]
  ------------------
   30|     25|		return 1;
   31|     25|	}
   32|       |
   33|  1.15k|	struct lldpd_chassis *nchassis = NULL;
   34|  1.15k|	struct lldpd_port *nport = NULL;
   35|  1.15k|	struct lldpd_hardware hardware;
   36|       |
   37|  1.15k|	log_register(donothing);
   38|       |
   39|  1.15k|	lldp_decode(NULL, (char *)Data, Size, &hardware, &nchassis, &nport);
   40|       |
   41|  1.15k|	if (!nchassis || !nport) {
  ------------------
  |  Branch (41:6): [True: 1.02k, False: 129]
  |  Branch (41:19): [True: 0, False: 129]
  ------------------
   42|  1.02k|		return 1;
   43|  1.02k|	}
   44|       |
   45|    129|	lldpd_port_cleanup(nport, 1);
   46|    129|	free(nport);
   47|    129|	lldpd_chassis_cleanup(nchassis, 1);
   48|       |
   49|    129|	return 0;
   50|  1.15k|}

