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

lldp_decode:
  572|  1.16k|{
  573|  1.16k|	struct lldpd_chassis *chassis;
  574|  1.16k|	struct lldpd_port *port;
  575|  1.16k|	char lldpaddr[ETHER_ADDR_LEN];
  576|  1.16k|	const char dot1[] = LLDP_TLV_ORG_DOT1;
  ------------------
  |  |   45|  1.16k|  {                       \
  |  |   46|  1.16k|    0x00, 0x80, 0xc2      \
  |  |   47|  1.16k|  }
  ------------------
  577|  1.16k|	const char dot3[] = LLDP_TLV_ORG_DOT3;
  ------------------
  |  |   49|  1.16k|  {                       \
  |  |   50|  1.16k|    0x00, 0x12, 0x0f      \
  |  |   51|  1.16k|  }
  ------------------
  578|  1.16k|	const char med[] = LLDP_TLV_ORG_MED;
  ------------------
  |  |   53|  1.16k|  {                      \
  |  |   54|  1.16k|    0x00, 0x12, 0xbb     \
  |  |   55|  1.16k|  }
  ------------------
  579|  1.16k|	const char dcbx[] = LLDP_TLV_ORG_DCBX;
  ------------------
  |  |   57|  1.16k|  {                       \
  |  |   58|  1.16k|    0x00, 0x1b, 0x21      \
  |  |   59|  1.16k|  }
  ------------------
  580|  1.16k|	unsigned char orgid[3];
  581|  1.16k|	int length, gotend = 0, ttl_received = 0;
  582|  1.16k|	int tlv_size, tlv_type, tlv_subtype, tlv_count = 0;
  583|  1.16k|	u_int8_t *pos, *tlv;
  584|  1.16k|	char *b;
  585|  1.16k|#ifdef ENABLE_DOT1
  586|  1.16k|	struct lldpd_vlan *vlan = NULL;
  587|  1.16k|	int vlan_len;
  588|  1.16k|	struct lldpd_ppvid *ppvid;
  589|  1.16k|	struct lldpd_pi *pi = NULL;
  590|  1.16k|#endif
  591|  1.16k|	struct lldpd_mgmt *mgmt;
  592|  1.16k|	int af;
  593|  1.16k|	u_int8_t addr_str_length, addr_str_buffer[32] = { 0 };
  594|  1.16k|	u_int8_t addr_family, addr_length, *addr_ptr, iface_subtype;
  595|  1.16k|	u_int32_t iface_number, iface;
  596|  1.16k|	int unrecognized;
  597|  1.16k|#ifdef ENABLE_CUSTOM
  598|  1.16k|	struct lldpd_custom *custom = NULL;
  599|  1.16k|#endif
  600|       |
  601|  1.16k|	log_debug("lldp", "receive LLDP PDU on %s", hardware->h_ifname);
  602|       |
  603|  1.16k|	if ((chassis = calloc(1, sizeof(struct lldpd_chassis))) == NULL) {
  ------------------
  |  Branch (603:6): [True: 0, False: 1.16k]
  ------------------
  604|      0|		log_warn("lldp", "failed to allocate remote chassis");
  605|      0|		return -1;
  606|      0|	}
  607|  1.16k|	TAILQ_INIT(&chassis->c_mgmt);
  ------------------
  |  Branch (607:2): [Folded, False: 1.16k]
  ------------------
  608|  1.16k|	if ((port = calloc(1, sizeof(struct lldpd_port))) == NULL) {
  ------------------
  |  Branch (608:6): [True: 0, False: 1.16k]
  ------------------
  609|      0|		log_warn("lldp", "failed to allocate remote port");
  610|      0|		free(chassis);
  611|      0|		return -1;
  612|      0|	}
  613|  1.16k|#ifdef ENABLE_DOT1
  614|  1.16k|	TAILQ_INIT(&port->p_vlans);
  ------------------
  |  Branch (614:2): [Folded, False: 1.16k]
  ------------------
  615|  1.16k|	TAILQ_INIT(&port->p_ppvids);
  ------------------
  |  Branch (615:2): [Folded, False: 1.16k]
  ------------------
  616|  1.16k|	TAILQ_INIT(&port->p_pids);
  ------------------
  |  Branch (616:2): [Folded, False: 1.16k]
  ------------------
  617|  1.16k|#endif
  618|  1.16k|#ifdef ENABLE_CUSTOM
  619|  1.16k|	TAILQ_INIT(&port->p_custom_list);
  ------------------
  |  Branch (619:2): [Folded, False: 1.16k]
  ------------------
  620|  1.16k|#endif
  621|       |
  622|  1.16k|	length = s;
  623|  1.16k|	pos = (u_int8_t *)frame;
  624|       |
  625|  1.16k|	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: 708, False: 448]
  ------------------
  631|    708|	    memcmp(lldpaddr, (const char[])LLDP_ADDR_NEAREST_NONTPMR_BRIDGE,
  ------------------
  |  |   26|    708|  {                                      \
  |  |   27|    708|    0x01, 0x80, 0xc2, 0x00, 0x00, 0x03   \
  |  |   28|    708|  }
  ------------------
  |  Branch (631:6): [True: 549, False: 159]
  ------------------
  632|    708|		ETHER_ADDR_LEN) &&
  633|    549|	    memcmp(lldpaddr, (const char[])LLDP_ADDR_NEAREST_CUSTOMER_BRIDGE,
  ------------------
  |  |   30|    549|  {                                       \
  |  |   31|    549|    0x01, 0x80, 0xc2, 0x00, 0x00, 0x00    \
  |  |   32|    549|  }
  ------------------
  |  Branch (633:6): [True: 46, False: 503]
  ------------------
  634|    549|		ETHER_ADDR_LEN)) {
  635|     46|		log_info("lldp",
  636|     46|		    "frame not targeted at LLDP multicast address received on %s",
  637|     46|		    hardware->h_ifname);
  638|     46|		goto malformed;
  639|     46|	}
  640|  1.11k|	PEEK_DISCARD(ETHER_ADDR_LEN); /* Skip source address */
  ------------------
  |  |   72|  1.11k|  do {                      \
  |  |   73|  1.11k|    length -= (bytes);      \
  |  |   74|  1.11k|    pos += (bytes);         \
  |  |   75|  1.11k|  } while (0)
  |  |  ------------------
  |  |  |  Branch (75:12): [Folded, False: 1.11k]
  |  |  ------------------
  ------------------
  641|  1.11k|	if (PEEK_UINT16 != ETH_P_LLDP) {
  ------------------
  |  |   63|  1.11k|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  ------------------
  |  |  |  |   60|  1.11k|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|  1.11k|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   63|  1.11k|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
              	if (PEEK_UINT16 != ETH_P_LLDP) {
  ------------------
  |  |  269|  1.11k|#  define ETH_P_LLDP 0x88cc
  ------------------
  |  Branch (641:6): [True: 27, False: 1.08k]
  ------------------
  642|     27|		log_info("lldp", "non LLDP frame received on %s", hardware->h_ifname);
  643|     27|		goto malformed;
  644|     27|	}
  645|       |
  646|  19.0k|	while (length && (!gotend)) {
  ------------------
  |  Branch (646:9): [True: 18.2k, False: 748]
  |  Branch (646:19): [True: 18.2k, False: 34]
  ------------------
  647|  18.2k|		if (length < 2) {
  ------------------
  |  Branch (647:7): [True: 78, False: 18.1k]
  ------------------
  648|     78|			log_warnx("lldp", "tlv header too short received on %s",
  649|     78|			    hardware->h_ifname);
  650|     78|			goto malformed;
  651|     78|		}
  652|  18.1k|		tlv_size = PEEK_UINT16;
  ------------------
  |  |   63|  18.1k|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  ------------------
  |  |  |  |   60|  18.1k|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|  18.1k|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   63|  18.1k|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  653|  18.1k|		tlv_type = tlv_size >> 9;
  654|  18.1k|		tlv_size = tlv_size & 0x1ff;
  655|  18.1k|		(void)PEEK_SAVE(tlv);
  ------------------
  |  |   81|  18.1k|#define PEEK_SAVE POKE_SAVE
  |  |  ------------------
  |  |  |  |   46|  18.1k|#define POKE_SAVE(where) (where = pos, 1)
  |  |  ------------------
  ------------------
  656|  18.1k|		if (length < tlv_size) {
  ------------------
  |  Branch (656:7): [True: 45, False: 18.0k]
  ------------------
  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.0k|		tlv_count++;
  663|  18.0k|		switch (tlv_type) {
  ------------------
  |  Branch (663:11): [True: 842, False: 17.2k]
  ------------------
  664|    322|		case LLDP_TLV_CHASSIS_ID:
  ------------------
  |  |   35|    322|#define LLDP_TLV_CHASSIS_ID 1
  ------------------
  |  Branch (664:3): [True: 322, False: 17.7k]
  ------------------
  665|    322|			if (tlv_count != 1) {
  ------------------
  |  Branch (665:8): [True: 12, False: 310]
  ------------------
  666|     12|				log_warnx("lldp",
  667|     12|				    "Chassis ID TLV should be first on %s, but it is on position %d",
  668|     12|				    hardware->h_ifname, tlv_count);
  669|     12|				goto malformed;
  670|     12|			}
  671|    310|			break;
  672|    310|		case LLDP_TLV_PORT_ID:
  ------------------
  |  |   36|    264|#define LLDP_TLV_PORT_ID 2
  ------------------
  |  Branch (672:3): [True: 264, False: 17.8k]
  ------------------
  673|    264|			if (tlv_count != 2) {
  ------------------
  |  Branch (673:8): [True: 9, False: 255]
  ------------------
  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|    255|			break;
  680|    256|		case LLDP_TLV_TTL:
  ------------------
  |  |   37|    256|#define LLDP_TLV_TTL 3
  ------------------
  |  Branch (680:3): [True: 256, False: 17.8k]
  ------------------
  681|    256|			if (tlv_count != 3) {
  ------------------
  |  Branch (681:8): [True: 10, False: 246]
  ------------------
  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|    246|			break;
  688|  18.0k|		}
  689|       |
  690|  18.0k|		switch (tlv_type) {
  691|    135|		case LLDP_TLV_END:
  ------------------
  |  |   34|    135|#define LLDP_TLV_END 0
  ------------------
  |  Branch (691:3): [True: 135, False: 17.9k]
  ------------------
  692|    135|			if (tlv_size != 0) {
  ------------------
  |  Branch (692:8): [True: 12, False: 123]
  ------------------
  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|    123|			if (length)
  ------------------
  |  Branch (698:8): [True: 34, False: 89]
  ------------------
  699|     34|				log_debug("lldp", "extra data after lldp end on %s",
  700|     34|				    hardware->h_ifname);
  701|    123|			gotend = 1;
  702|    123|			break;
  703|    310|		case LLDP_TLV_CHASSIS_ID:
  ------------------
  |  |   35|    310|#define LLDP_TLV_CHASSIS_ID 1
  ------------------
  |  Branch (703:3): [True: 310, False: 17.7k]
  ------------------
  704|    565|		case LLDP_TLV_PORT_ID:
  ------------------
  |  |   36|    565|#define LLDP_TLV_PORT_ID 2
  ------------------
  |  Branch (704:3): [True: 255, False: 17.8k]
  ------------------
  705|    565|			CHECK_TLV_SIZE(2, "Port/Chassis Id");
  ------------------
  |  |  555|    565|  do {                                                                             \
  |  |  556|    565|    if (tlv_size < (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (556:9): [True: 5, False: 560]
  |  |  ------------------
  |  |  557|      5|      log_warnx("lldp", name " TLV too short received on %s", hardware->h_ifname); \
  |  |  558|      5|      goto malformed;                                                              \
  |  |  559|      5|    }                                                                              \
  |  |  560|    565|  } while (0)
  |  |  ------------------
  |  |  |  Branch (560:12): [Folded, False: 560]
  |  |  ------------------
  ------------------
  706|    560|			CHECK_TLV_MAX_SIZE(256, "Port/Chassis Id");
  ------------------
  |  |  562|    560|  do {                                                                             \
  |  |  563|    560|    if (tlv_size > (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (563:9): [True: 1, False: 559]
  |  |  ------------------
  |  |  564|      1|      log_warnx("lldp", name " TLV too large received on %s", hardware->h_ifname); \
  |  |  565|      1|      goto malformed;                                                              \
  |  |  566|      1|    }                                                                              \
  |  |  567|    560|  } while (0)
  |  |  ------------------
  |  |  |  Branch (567:12): [Folded, False: 559]
  |  |  ------------------
  ------------------
  707|    559|			tlv_subtype = PEEK_UINT8;
  ------------------
  |  |   62|    559|#define PEEK_UINT8 PEEK(types.f_uint8, )
  |  |  ------------------
  |  |  |  |   60|    559|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    559|      func(type))
  |  |  ------------------
  ------------------
  708|    559|			if ((tlv_subtype == 0) || (tlv_subtype > 7)) {
  ------------------
  |  Branch (708:8): [True: 2, False: 557]
  |  Branch (708:30): [True: 20, False: 537]
  ------------------
  709|     22|				log_warnx("lldp",
  710|     22|				    "unknown subtype for tlv id received on %s",
  711|     22|				    hardware->h_ifname);
  712|     22|				goto malformed;
  713|     22|			}
  714|    537|			if ((b = (char *)calloc(1, tlv_size - 1)) == NULL) {
  ------------------
  |  Branch (714:8): [True: 0, False: 537]
  ------------------
  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|    537|			PEEK_BYTES(b, tlv_size - 1);
  ------------------
  |  |   66|    537|  do {                           \
  |  |   67|    537|    memcpy(value, pos, bytes);   \
  |  |   68|    537|    length -= (bytes);           \
  |  |   69|    537|    pos += (bytes);              \
  |  |   70|    537|  } while (0)
  |  |  ------------------
  |  |  |  Branch (70:12): [Folded, False: 537]
  |  |  ------------------
  ------------------
  722|    537|			if (tlv_type == LLDP_TLV_PORT_ID) {
  ------------------
  |  |   36|    537|#define LLDP_TLV_PORT_ID 2
  ------------------
  |  Branch (722:8): [True: 251, False: 286]
  ------------------
  723|    251|				if (port->p_id != NULL) {
  ------------------
  |  Branch (723:9): [True: 0, False: 251]
  ------------------
  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|    251|				port->p_id_subtype = tlv_subtype;
  731|    251|				port->p_id = b;
  732|    251|				port->p_id_len = tlv_size - 1;
  733|    286|			} else {
  734|    286|				if (chassis->c_id != NULL) {
  ------------------
  |  Branch (734:9): [True: 0, False: 286]
  ------------------
  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|    286|				chassis->c_id_subtype = tlv_subtype;
  742|    286|				chassis->c_id = b;
  743|    286|				chassis->c_id_len = tlv_size - 1;
  744|    286|			}
  745|    537|			break;
  746|    537|		case LLDP_TLV_TTL:
  ------------------
  |  |   37|    246|#define LLDP_TLV_TTL 3
  ------------------
  |  Branch (746:3): [True: 246, False: 17.8k]
  ------------------
  747|    246|			if (ttl_received) {
  ------------------
  |  Branch (747:8): [True: 0, False: 246]
  ------------------
  748|      0|				log_warnx("lldp", "TTL TLV received twice on %s",
  749|      0|				    hardware->h_ifname);
  750|      0|				goto malformed;
  751|      0|			}
  752|    246|			CHECK_TLV_SIZE(2, "TTL");
  ------------------
  |  |  555|    246|  do {                                                                             \
  |  |  556|    246|    if (tlv_size < (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (556:9): [True: 3, False: 243]
  |  |  ------------------
  |  |  557|      3|      log_warnx("lldp", name " TLV too short received on %s", hardware->h_ifname); \
  |  |  558|      3|      goto malformed;                                                              \
  |  |  559|      3|    }                                                                              \
  |  |  560|    246|  } while (0)
  |  |  ------------------
  |  |  |  Branch (560:12): [Folded, False: 243]
  |  |  ------------------
  ------------------
  753|    243|			port->p_ttl = PEEK_UINT16;
  ------------------
  |  |   63|    243|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  ------------------
  |  |  |  |   60|    243|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    243|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   63|    243|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  754|    243|			ttl_received = 1;
  755|    243|			break;
  756|    627|		case LLDP_TLV_PORT_DESCR:
  ------------------
  |  |   38|    627|#define LLDP_TLV_PORT_DESCR 4
  ------------------
  |  Branch (756:3): [True: 627, False: 17.4k]
  ------------------
  757|  1.85k|		case LLDP_TLV_SYSTEM_NAME:
  ------------------
  |  |   39|  1.85k|#define LLDP_TLV_SYSTEM_NAME 5
  ------------------
  |  Branch (757:3): [True: 1.22k, False: 16.8k]
  ------------------
  758|  4.86k|		case LLDP_TLV_SYSTEM_DESCR:
  ------------------
  |  |   40|  4.86k|#define LLDP_TLV_SYSTEM_DESCR 6
  ------------------
  |  Branch (758:3): [True: 3.01k, False: 15.0k]
  ------------------
  759|  4.86k|			if (tlv_size < 1) {
  ------------------
  |  Branch (759:8): [True: 4.24k, False: 624]
  ------------------
  760|  4.24k|				log_debug("lldp", "empty tlv received on %s",
  761|  4.24k|				    hardware->h_ifname);
  762|  4.24k|				break;
  763|  4.24k|			}
  764|    624|			if ((b = (char *)calloc(1, tlv_size + 1)) == NULL) {
  ------------------
  |  Branch (764:8): [True: 0, False: 624]
  ------------------
  765|      0|				log_warn("lldp",
  766|      0|				    "unable to allocate memory for string tlv "
  767|      0|				    "received on %s",
  768|      0|				    hardware->h_ifname);
  769|      0|				goto malformed;
  770|      0|			}
  771|    624|			PEEK_BYTES(b, tlv_size);
  ------------------
  |  |   66|    624|  do {                           \
  |  |   67|    624|    memcpy(value, pos, bytes);   \
  |  |   68|    624|    length -= (bytes);           \
  |  |   69|    624|    pos += (bytes);              \
  |  |   70|    624|  } while (0)
  |  |  ------------------
  |  |  |  Branch (70:12): [Folded, False: 624]
  |  |  ------------------
  ------------------
  772|    624|			switch (tlv_type) {
  773|    202|			case LLDP_TLV_PORT_DESCR:
  ------------------
  |  |   38|    202|#define LLDP_TLV_PORT_DESCR 4
  ------------------
  |  Branch (773:4): [True: 202, False: 422]
  ------------------
  774|    202|				free(port->p_descr);
  775|    202|				port->p_descr = b;
  776|    202|				break;
  777|    211|			case LLDP_TLV_SYSTEM_NAME:
  ------------------
  |  |   39|    211|#define LLDP_TLV_SYSTEM_NAME 5
  ------------------
  |  Branch (777:4): [True: 211, False: 413]
  ------------------
  778|    211|				free(chassis->c_name);
  779|    211|				chassis->c_name = b;
  780|    211|				break;
  781|    211|			case LLDP_TLV_SYSTEM_DESCR:
  ------------------
  |  |   40|    211|#define LLDP_TLV_SYSTEM_DESCR 6
  ------------------
  |  Branch (781:4): [True: 211, False: 413]
  ------------------
  782|    211|				free(chassis->c_descr);
  783|    211|				chassis->c_descr = b;
  784|    211|				break;
  785|      0|			default:
  ------------------
  |  Branch (785:4): [True: 0, False: 624]
  ------------------
  786|       |				/* unreachable */
  787|      0|				free(b);
  788|      0|				break;
  789|    624|			}
  790|    624|			break;
  791|    624|		case LLDP_TLV_SYSTEM_CAP:
  ------------------
  |  |   41|    410|#define LLDP_TLV_SYSTEM_CAP 7
  ------------------
  |  Branch (791:3): [True: 410, False: 17.6k]
  ------------------
  792|    410|			CHECK_TLV_SIZE(4, "System capabilities");
  ------------------
  |  |  555|    410|  do {                                                                             \
  |  |  556|    410|    if (tlv_size < (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (556:9): [True: 11, False: 399]
  |  |  ------------------
  |  |  557|     11|      log_warnx("lldp", name " TLV too short received on %s", hardware->h_ifname); \
  |  |  558|     11|      goto malformed;                                                              \
  |  |  559|     11|    }                                                                              \
  |  |  560|    410|  } while (0)
  |  |  ------------------
  |  |  |  Branch (560:12): [Folded, False: 399]
  |  |  ------------------
  ------------------
  793|    399|			chassis->c_cap_available = PEEK_UINT16;
  ------------------
  |  |   63|    399|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  ------------------
  |  |  |  |   60|    399|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    399|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   63|    399|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  794|    399|			chassis->c_cap_enabled = PEEK_UINT16;
  ------------------
  |  |   63|    399|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  ------------------
  |  |  |  |   60|    399|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    399|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   63|    399|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  795|    399|			break;
  796|    947|		case LLDP_TLV_MGMT_ADDR:
  ------------------
  |  |   42|    947|#define LLDP_TLV_MGMT_ADDR 8
  ------------------
  |  Branch (796:3): [True: 947, False: 17.1k]
  ------------------
  797|    947|			CHECK_TLV_SIZE(1, "Management address");
  ------------------
  |  |  555|    947|  do {                                                                             \
  |  |  556|    947|    if (tlv_size < (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (556:9): [True: 4, False: 943]
  |  |  ------------------
  |  |  557|      4|      log_warnx("lldp", name " TLV too short received on %s", hardware->h_ifname); \
  |  |  558|      4|      goto malformed;                                                              \
  |  |  559|      4|    }                                                                              \
  |  |  560|    947|  } while (0)
  |  |  ------------------
  |  |  |  Branch (560:12): [Folded, False: 943]
  |  |  ------------------
  ------------------
  798|    943|			addr_str_length = PEEK_UINT8;
  ------------------
  |  |   62|    943|#define PEEK_UINT8 PEEK(types.f_uint8, )
  |  |  ------------------
  |  |  |  |   60|    943|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    943|      func(type))
  |  |  ------------------
  ------------------
  799|    943|			if (addr_str_length < 1 ||
  ------------------
  |  Branch (799:8): [True: 11, False: 932]
  ------------------
  800|    932|			    addr_str_length > sizeof(addr_str_buffer)) {
  ------------------
  |  Branch (800:8): [True: 8, False: 924]
  ------------------
  801|     19|				log_warnx("lldp",
  802|     19|				    "invalid management address length on %s",
  803|     19|				    hardware->h_ifname);
  804|     19|				goto malformed;
  805|     19|			}
  806|    924|			CHECK_TLV_SIZE(1 + addr_str_length, "Management address");
  ------------------
  |  |  555|    924|  do {                                                                             \
  |  |  556|    924|    if (tlv_size < (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (556:9): [True: 6, False: 918]
  |  |  ------------------
  |  |  557|      6|      log_warnx("lldp", name " TLV too short received on %s", hardware->h_ifname); \
  |  |  558|      6|      goto malformed;                                                              \
  |  |  559|      6|    }                                                                              \
  |  |  560|    924|  } while (0)
  |  |  ------------------
  |  |  |  Branch (560:12): [Folded, False: 918]
  |  |  ------------------
  ------------------
  807|    918|			PEEK_BYTES(addr_str_buffer, addr_str_length);
  ------------------
  |  |   66|    918|  do {                           \
  |  |   67|    918|    memcpy(value, pos, bytes);   \
  |  |   68|    918|    length -= (bytes);           \
  |  |   69|    918|    pos += (bytes);              \
  |  |   70|    918|  } while (0)
  |  |  ------------------
  |  |  |  Branch (70:12): [Folded, False: 918]
  |  |  ------------------
  ------------------
  808|    918|			addr_length = addr_str_length - 1;
  809|    918|			addr_family = addr_str_buffer[0];
  810|    918|			addr_ptr = &addr_str_buffer[1];
  811|    918|			CHECK_TLV_SIZE(1 + addr_str_length + 5, "Management address");
  ------------------
  |  |  555|    918|  do {                                                                             \
  |  |  556|    918|    if (tlv_size < (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (556:9): [True: 5, False: 913]
  |  |  ------------------
  |  |  557|      5|      log_warnx("lldp", name " TLV too short received on %s", hardware->h_ifname); \
  |  |  558|      5|      goto malformed;                                                              \
  |  |  559|      5|    }                                                                              \
  |  |  560|    918|  } while (0)
  |  |  ------------------
  |  |  |  Branch (560:12): [Folded, False: 913]
  |  |  ------------------
  ------------------
  812|    913|			iface_subtype = PEEK_UINT8;
  ------------------
  |  |   62|    913|#define PEEK_UINT8 PEEK(types.f_uint8, )
  |  |  ------------------
  |  |  |  |   60|    913|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    913|      func(type))
  |  |  ------------------
  ------------------
  813|    913|			iface_number = PEEK_UINT32;
  ------------------
  |  |   64|    913|#define PEEK_UINT32 PEEK(types.f_uint32, ntohl)
  |  |  ------------------
  |  |  |  |   60|    913|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    913|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|    913|#define PEEK_UINT32 PEEK(types.f_uint32, ntohl)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  814|       |
  815|    913|			af = lldpd_af_from_lldp_proto(addr_family);
  816|    913|			if (af == LLDPD_AF_UNSPEC) break;
  ------------------
  |  Branch (816:8): [True: 229, False: 684]
  ------------------
  817|    684|			if (iface_subtype == LLDP_MGMT_IFACE_IFINDEX)
  ------------------
  |  |  277|    684|#define LLDP_MGMT_IFACE_IFINDEX 2
  ------------------
  |  Branch (817:8): [True: 448, False: 236]
  ------------------
  818|    448|				iface = iface_number;
  819|    236|			else
  820|    236|				iface = 0;
  821|    684|			mgmt = lldpd_alloc_mgmt(af, addr_ptr, addr_length, iface);
  822|    684|			if (mgmt == NULL) {
  ------------------
  |  Branch (822:8): [True: 1, False: 683]
  ------------------
  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|    684|			TAILQ_INSERT_TAIL(&chassis->c_mgmt, mgmt, m_entries);
  ------------------
  |  Branch (834:4): [Folded, False: 683]
  ------------------
  835|    683|			break;
  836|  10.2k|		case LLDP_TLV_ORG:
  ------------------
  |  |   26|  10.2k|#define LLDP_TLV_ORG 127
  ------------------
  |  Branch (836:3): [True: 10.2k, False: 7.79k]
  ------------------
  837|  10.2k|			CHECK_TLV_SIZE(1 + (int)sizeof(orgid), "Organisational");
  ------------------
  |  |  555|  10.2k|  do {                                                                             \
  |  |  556|  10.2k|    if (tlv_size < (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (556:9): [True: 13, False: 10.2k]
  |  |  ------------------
  |  |  557|     13|      log_warnx("lldp", name " TLV too short received on %s", hardware->h_ifname); \
  |  |  558|     13|      goto malformed;                                                              \
  |  |  559|     13|    }                                                                              \
  |  |  560|  10.2k|  } while (0)
  |  |  ------------------
  |  |  |  Branch (560:12): [Folded, False: 10.2k]
  |  |  ------------------
  ------------------
  838|  10.2k|			PEEK_BYTES(orgid, sizeof(orgid));
  ------------------
  |  |   66|  10.2k|  do {                           \
  |  |   67|  10.2k|    memcpy(value, pos, bytes);   \
  |  |   68|  10.2k|    length -= (bytes);           \
  |  |   69|  10.2k|    pos += (bytes);              \
  |  |   70|  10.2k|  } while (0)
  |  |  ------------------
  |  |  |  Branch (70:12): [Folded, False: 10.2k]
  |  |  ------------------
  ------------------
  839|  10.2k|			unrecognized = 0;
  840|  10.2k|			tlv_subtype = PEEK_UINT8;
  ------------------
  |  |   62|  10.2k|#define PEEK_UINT8 PEEK(types.f_uint8, )
  |  |  ------------------
  |  |  |  |   60|  10.2k|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|  10.2k|      func(type))
  |  |  ------------------
  ------------------
  841|  10.2k|			if (memcmp(dot1, orgid, sizeof(orgid)) == 0) {
  ------------------
  |  Branch (841:8): [True: 1.81k, False: 8.45k]
  ------------------
  842|       |#ifndef ENABLE_DOT1
  843|       |				unrecognized = 1;
  844|       |#else
  845|       |				/* Dot1 */
  846|  1.81k|				switch (tlv_subtype) {
  847|    416|				case LLDP_TLV_DOT1_VLANNAME:
  ------------------
  |  |   63|    416|#define LLDP_TLV_DOT1_VLANNAME 3
  ------------------
  |  Branch (847:5): [True: 416, False: 1.39k]
  ------------------
  848|    416|					CHECK_TLV_SIZE(7, "VLAN");
  ------------------
  |  |  555|    416|  do {                                                                             \
  |  |  556|    416|    if (tlv_size < (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (556:9): [True: 2, False: 414]
  |  |  ------------------
  |  |  557|      2|      log_warnx("lldp", name " TLV too short received on %s", hardware->h_ifname); \
  |  |  558|      2|      goto malformed;                                                              \
  |  |  559|      2|    }                                                                              \
  |  |  560|    416|  } while (0)
  |  |  ------------------
  |  |  |  Branch (560:12): [Folded, False: 414]
  |  |  ------------------
  ------------------
  849|    414|					if ((vlan = (struct lldpd_vlan *)calloc(1,
  ------------------
  |  Branch (849:10): [True: 0, False: 414]
  ------------------
  850|    414|						 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|    414|					vlan->v_vid = PEEK_UINT16;
  ------------------
  |  |   63|    414|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  ------------------
  |  |  |  |   60|    414|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    414|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   63|    414|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  859|    414|					vlan_len = PEEK_UINT8;
  ------------------
  |  |   62|    414|#define PEEK_UINT8 PEEK(types.f_uint8, )
  |  |  ------------------
  |  |  |  |   60|    414|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    414|      func(type))
  |  |  ------------------
  ------------------
  860|    414|					CHECK_TLV_SIZE(7 + vlan_len, "VLAN");
  ------------------
  |  |  555|    414|  do {                                                                             \
  |  |  556|    414|    if (tlv_size < (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (556:9): [True: 10, False: 404]
  |  |  ------------------
  |  |  557|     10|      log_warnx("lldp", name " TLV too short received on %s", hardware->h_ifname); \
  |  |  558|     10|      goto malformed;                                                              \
  |  |  559|     10|    }                                                                              \
  |  |  560|    414|  } while (0)
  |  |  ------------------
  |  |  |  Branch (560:12): [Folded, False: 404]
  |  |  ------------------
  ------------------
  861|    404|					if ((vlan->v_name = (char *)calloc(1,
  ------------------
  |  Branch (861:10): [True: 0, False: 404]
  ------------------
  862|    404|						 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|    404|					PEEK_BYTES(vlan->v_name, vlan_len);
  ------------------
  |  |   66|    404|  do {                           \
  |  |   67|    404|    memcpy(value, pos, bytes);   \
  |  |   68|    404|    length -= (bytes);           \
  |  |   69|    404|    pos += (bytes);              \
  |  |   70|    404|  } while (0)
  |  |  ------------------
  |  |  |  Branch (70:12): [Folded, False: 404]
  |  |  ------------------
  ------------------
  870|    404|					TAILQ_INSERT_TAIL(&port->p_vlans, vlan,
  ------------------
  |  Branch (870:6): [Folded, False: 404]
  ------------------
  871|    404|					    v_entries);
  872|    404|					vlan = NULL;
  873|    404|					break;
  874|    205|				case LLDP_TLV_DOT1_PVID:
  ------------------
  |  |   61|    205|#define LLDP_TLV_DOT1_PVID 1
  ------------------
  |  Branch (874:5): [True: 205, False: 1.60k]
  ------------------
  875|    205|					CHECK_TLV_SIZE(6, "PVID");
  ------------------
  |  |  555|    205|  do {                                                                             \
  |  |  556|    205|    if (tlv_size < (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (556:9): [True: 2, False: 203]
  |  |  ------------------
  |  |  557|      2|      log_warnx("lldp", name " TLV too short received on %s", hardware->h_ifname); \
  |  |  558|      2|      goto malformed;                                                              \
  |  |  559|      2|    }                                                                              \
  |  |  560|    205|  } while (0)
  |  |  ------------------
  |  |  |  Branch (560:12): [Folded, False: 203]
  |  |  ------------------
  ------------------
  876|    203|					port->p_pvid = PEEK_UINT16;
  ------------------
  |  |   63|    203|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  ------------------
  |  |  |  |   60|    203|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    203|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   63|    203|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  877|    203|					break;
  878|    401|				case LLDP_TLV_DOT1_PPVID:
  ------------------
  |  |   62|    401|#define LLDP_TLV_DOT1_PPVID 2
  ------------------
  |  Branch (878:5): [True: 401, False: 1.41k]
  ------------------
  879|    401|					CHECK_TLV_SIZE(7, "PPVID");
  ------------------
  |  |  555|    401|  do {                                                                             \
  |  |  556|    401|    if (tlv_size < (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (556:9): [True: 2, False: 399]
  |  |  ------------------
  |  |  557|      2|      log_warnx("lldp", name " TLV too short received on %s", hardware->h_ifname); \
  |  |  558|      2|      goto malformed;                                                              \
  |  |  559|      2|    }                                                                              \
  |  |  560|    401|  } while (0)
  |  |  ------------------
  |  |  |  Branch (560:12): [Folded, False: 399]
  |  |  ------------------
  ------------------
  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|    399|					if ((ppvid = (struct lldpd_ppvid *)calloc(1,
  ------------------
  |  Branch (888:10): [True: 0, False: 399]
  ------------------
  889|    399|						 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|    399|					ppvid->p_cap_status = PEEK_UINT8;
  ------------------
  |  |   62|    399|#define PEEK_UINT8 PEEK(types.f_uint8, )
  |  |  ------------------
  |  |  |  |   60|    399|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    399|      func(type))
  |  |  ------------------
  ------------------
  898|    399|					ppvid->p_ppvid = PEEK_UINT16;
  ------------------
  |  |   63|    399|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  ------------------
  |  |  |  |   60|    399|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    399|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   63|    399|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  899|    399|					TAILQ_INSERT_TAIL(&port->p_ppvids, ppvid,
  ------------------
  |  Branch (899:6): [Folded, False: 399]
  ------------------
  900|    399|					    p_entries);
  901|    399|					break;
  902|    416|				case LLDP_TLV_DOT1_PI:
  ------------------
  |  |   64|    416|#define LLDP_TLV_DOT1_PI 4
  ------------------
  |  Branch (902:5): [True: 416, False: 1.39k]
  ------------------
  903|       |					/* validation needed */
  904|       |					/* PI has to be unique if more than
  905|       |					   one PI TLVs are received  - discard
  906|       |					   if duplicate ?? */
  907|    416|					CHECK_TLV_SIZE(5, "PI");
  ------------------
  |  |  555|    416|  do {                                                                             \
  |  |  556|    416|    if (tlv_size < (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (556:9): [True: 1, False: 415]
  |  |  ------------------
  |  |  557|      1|      log_warnx("lldp", name " TLV too short received on %s", hardware->h_ifname); \
  |  |  558|      1|      goto malformed;                                                              \
  |  |  559|      1|    }                                                                              \
  |  |  560|    416|  } while (0)
  |  |  ------------------
  |  |  |  Branch (560:12): [Folded, False: 415]
  |  |  ------------------
  ------------------
  908|    415|					if ((pi = (struct lldpd_pi *)calloc(1,
  ------------------
  |  Branch (908:10): [True: 0, False: 415]
  ------------------
  909|    415|						 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|    415|					pi->p_pi_len = PEEK_UINT8;
  ------------------
  |  |   62|    415|#define PEEK_UINT8 PEEK(types.f_uint8, )
  |  |  ------------------
  |  |  |  |   60|    415|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    415|      func(type))
  |  |  ------------------
  ------------------
  918|    415|					CHECK_TLV_SIZE(5 + pi->p_pi_len, "PI");
  ------------------
  |  |  555|    415|  do {                                                                             \
  |  |  556|    415|    if (tlv_size < (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (556:9): [True: 9, False: 406]
  |  |  ------------------
  |  |  557|      9|      log_warnx("lldp", name " TLV too short received on %s", hardware->h_ifname); \
  |  |  558|      9|      goto malformed;                                                              \
  |  |  559|      9|    }                                                                              \
  |  |  560|    415|  } while (0)
  |  |  ------------------
  |  |  |  Branch (560:12): [Folded, False: 406]
  |  |  ------------------
  ------------------
  919|    406|					if ((pi->p_pi = (char *)calloc(1,
  ------------------
  |  Branch (919:10): [True: 0, False: 406]
  ------------------
  920|    406|						 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|    406|					PEEK_BYTES(pi->p_pi, pi->p_pi_len);
  ------------------
  |  |   66|    406|  do {                           \
  |  |   67|    406|    memcpy(value, pos, bytes);   \
  |  |   68|    406|    length -= (bytes);           \
  |  |   69|    406|    pos += (bytes);              \
  |  |   70|    406|  } while (0)
  |  |  ------------------
  |  |  |  Branch (70:12): [Folded, False: 406]
  |  |  ------------------
  ------------------
  928|    406|					TAILQ_INSERT_TAIL(&port->p_pids, pi, p_entries);
  ------------------
  |  Branch (928:6): [Folded, False: 406]
  ------------------
  929|    406|					pi = NULL;
  930|    406|					break;
  931|    374|				default:
  ------------------
  |  Branch (931:5): [True: 374, False: 1.43k]
  ------------------
  932|       |					/* Unknown Dot1 TLV, ignore it */
  933|    374|					unrecognized = 1;
  934|  1.81k|				}
  935|  1.81k|#endif
  936|  8.45k|			} else if (memcmp(dot3, orgid, sizeof(orgid)) == 0) {
  ------------------
  |  Branch (936:15): [True: 1.40k, False: 7.04k]
  ------------------
  937|       |#ifndef ENABLE_DOT3
  938|       |				unrecognized = 1;
  939|       |#else
  940|       |				/* Dot3 */
  941|  1.40k|				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.21k]
  ------------------
  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|    221|				case LLDP_TLV_DOT3_LA:
  ------------------
  |  |   68|    221|#define LLDP_TLV_DOT3_LA 3
  ------------------
  |  Branch (952:5): [True: 221, False: 1.18k]
  ------------------
  953|    221|					CHECK_TLV_SIZE(9, "Link aggregation");
  ------------------
  |  |  555|    221|  do {                                                                             \
  |  |  556|    221|    if (tlv_size < (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (556:9): [True: 4, False: 217]
  |  |  ------------------
  |  |  557|      4|      log_warnx("lldp", name " TLV too short received on %s", hardware->h_ifname); \
  |  |  558|      4|      goto malformed;                                                              \
  |  |  559|      4|    }                                                                              \
  |  |  560|    221|  } while (0)
  |  |  ------------------
  |  |  |  Branch (560:12): [Folded, False: 217]
  |  |  ------------------
  ------------------
  954|    217|					PEEK_DISCARD_UINT8;
  ------------------
  |  |   76|    217|#define PEEK_DISCARD_UINT8 PEEK_DISCARD(1)
  |  |  ------------------
  |  |  |  |   72|    217|  do {                      \
  |  |  |  |   73|    217|    length -= (bytes);      \
  |  |  |  |   74|    217|    pos += (bytes);         \
  |  |  |  |   75|    217|  } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (75:12): [Folded, False: 217]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  955|    217|					port->p_aggregid = PEEK_UINT32;
  ------------------
  |  |   64|    217|#define PEEK_UINT32 PEEK(types.f_uint32, ntohl)
  |  |  ------------------
  |  |  |  |   60|    217|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    217|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|    217|#define PEEK_UINT32 PEEK(types.f_uint32, ntohl)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  956|    217|					break;
  957|    212|				case LLDP_TLV_DOT3_MFS:
  ------------------
  |  |   69|    212|#define LLDP_TLV_DOT3_MFS 4
  ------------------
  |  Branch (957:5): [True: 212, False: 1.19k]
  ------------------
  958|    212|					CHECK_TLV_SIZE(6, "MFS");
  ------------------
  |  |  555|    212|  do {                                                                             \
  |  |  556|    212|    if (tlv_size < (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (556:9): [True: 3, False: 209]
  |  |  ------------------
  |  |  557|      3|      log_warnx("lldp", name " TLV too short received on %s", hardware->h_ifname); \
  |  |  558|      3|      goto malformed;                                                              \
  |  |  559|      3|    }                                                                              \
  |  |  560|    212|  } while (0)
  |  |  ------------------
  |  |  |  Branch (560:12): [Folded, False: 209]
  |  |  ------------------
  ------------------
  959|    209|					port->p_mfs = PEEK_UINT16;
  ------------------
  |  |   63|    209|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  ------------------
  |  |  |  |   60|    209|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    209|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   63|    209|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  960|    209|					break;
  961|    529|				case LLDP_TLV_DOT3_POWER:
  ------------------
  |  |   67|    529|#define LLDP_TLV_DOT3_POWER 2
  ------------------
  |  Branch (961:5): [True: 529, False: 879]
  ------------------
  962|    529|					CHECK_TLV_SIZE(7, "Power");
  ------------------
  |  |  555|    529|  do {                                                                             \
  |  |  556|    529|    if (tlv_size < (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (556:9): [True: 3, False: 526]
  |  |  ------------------
  |  |  557|      3|      log_warnx("lldp", name " TLV too short received on %s", hardware->h_ifname); \
  |  |  558|      3|      goto malformed;                                                              \
  |  |  559|      3|    }                                                                              \
  |  |  560|    529|  } while (0)
  |  |  ------------------
  |  |  |  Branch (560:12): [Folded, False: 526]
  |  |  ------------------
  ------------------
  963|    526|					port->p_power.devicetype = PEEK_UINT8;
  ------------------
  |  |   62|    526|#define PEEK_UINT8 PEEK(types.f_uint8, )
  |  |  ------------------
  |  |  |  |   60|    526|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    526|      func(type))
  |  |  ------------------
  ------------------
  964|    526|					port->p_power.supported =
  965|    526|					    (port->p_power.devicetype & 0x2) >> 1;
  966|    526|					port->p_power.enabled =
  967|    526|					    (port->p_power.devicetype & 0x4) >> 2;
  968|    526|					port->p_power.paircontrol =
  969|    526|					    (port->p_power.devicetype & 0x8) >> 3;
  970|    526|					port->p_power.devicetype =
  971|    526|					    (port->p_power.devicetype & 0x1) ?
  ------------------
  |  Branch (971:10): [True: 100, False: 426]
  ------------------
  972|    100|					    LLDP_DOT3_POWER_PSE :
  ------------------
  |  |  204|    100|#define LLDP_DOT3_POWER_PSE 1
  ------------------
  973|    526|					    LLDP_DOT3_POWER_PD;
  ------------------
  |  |  205|    952|#define LLDP_DOT3_POWER_PD 2
  ------------------
  974|    526|					port->p_power.pairs = PEEK_UINT8;
  ------------------
  |  |   62|    526|#define PEEK_UINT8 PEEK(types.f_uint8, )
  |  |  ------------------
  |  |  |  |   60|    526|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    526|      func(type))
  |  |  ------------------
  ------------------
  975|    526|					port->p_power.class = PEEK_UINT8;
  ------------------
  |  |   62|    526|#define PEEK_UINT8 PEEK(types.f_uint8, )
  |  |  ------------------
  |  |  |  |   60|    526|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    526|      func(type))
  |  |  ------------------
  ------------------
  976|       |					/* 802.3at? */
  977|    526|					if (tlv_size >= 12) {
  ------------------
  |  Branch (977:10): [True: 326, False: 200]
  ------------------
  978|    326|						port->p_power.powertype = PEEK_UINT8;
  ------------------
  |  |   62|    326|#define PEEK_UINT8 PEEK(types.f_uint8, )
  |  |  ------------------
  |  |  |  |   60|    326|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    326|      func(type))
  |  |  ------------------
  ------------------
  979|    326|						port->p_power.source =
  980|    326|						    (port->p_power.powertype &
  981|    326|							(1 << 5 | 1 << 4)) >>
  982|    326|						    4;
  983|    326|						port->p_power.priority =
  984|    326|						    (port->p_power.powertype &
  985|    326|							(1 << 1 | 1 << 0));
  986|    326|						port->p_power.powertype =
  987|    326|						    (port->p_power.powertype &
  ------------------
  |  Branch (987:11): [True: 134, False: 192]
  ------------------
  988|    326|							(1 << 7)) ?
  989|    134|						    LLDP_DOT3_POWER_8023AT_TYPE1 :
  ------------------
  |  |  213|    134|#define LLDP_DOT3_POWER_8023AT_TYPE1 1
  ------------------
  990|    326|						    LLDP_DOT3_POWER_8023AT_TYPE2;
  ------------------
  |  |  214|    518|#define LLDP_DOT3_POWER_8023AT_TYPE2 2
  ------------------
  991|    326|						port->p_power.requested = PEEK_UINT16;
  ------------------
  |  |   63|    326|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  ------------------
  |  |  |  |   60|    326|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    326|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   63|    326|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  992|    326|						port->p_power.allocated = PEEK_UINT16;
  ------------------
  |  |   63|    326|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  ------------------
  |  |  |  |   60|    326|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    326|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   63|    326|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  993|    326|					} 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|    526|					if (tlv_size >= 29) {
  ------------------
  |  Branch (997:10): [True: 79, False: 447]
  ------------------
  998|     79|						port->p_power.requested_a = PEEK_UINT16;
  ------------------
  |  |   63|     79|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  ------------------
  |  |  |  |   60|     79|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|     79|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   63|     79|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  999|     79|						port->p_power.requested_b = PEEK_UINT16;
  ------------------
  |  |   63|     79|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  ------------------
  |  |  |  |   60|     79|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|     79|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   63|     79|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1000|     79|						port->p_power.allocated_a = PEEK_UINT16;
  ------------------
  |  |   63|     79|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  ------------------
  |  |  |  |   60|     79|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|     79|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   63|     79|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1001|     79|						port->p_power.allocated_b = PEEK_UINT16;
  ------------------
  |  |   63|     79|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  ------------------
  |  |  |  |   60|     79|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|     79|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   63|     79|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1002|     79|						port->p_power.pse_status = PEEK_UINT16;
  ------------------
  |  |   63|     79|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  ------------------
  |  |  |  |   60|     79|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|     79|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   63|     79|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1003|     79|						port->p_power.pd_status =
 1004|     79|						    (port->p_power.pse_status &
 1005|     79|							(1 << 13 | 1 << 12)) >>
 1006|     79|						    12;
 1007|     79|						port->p_power.pse_pairs_ext =
 1008|     79|						    (port->p_power.pse_status &
 1009|     79|							(1 << 11 | 1 << 10)) >>
 1010|     79|						    10;
 1011|     79|						port->p_power.class_a =
 1012|     79|						    (port->p_power.pse_status &
 1013|     79|							(1 << 9 | 1 << 8 | 1 << 7)) >>
 1014|     79|						    7;
 1015|     79|						port->p_power.class_b =
 1016|     79|						    (port->p_power.pse_status &
 1017|     79|							(1 << 6 | 1 << 5 | 1 << 4)) >>
 1018|     79|						    4;
 1019|     79|						port->p_power.class_ext =
 1020|     79|						    (port->p_power.pse_status & 0xf);
 1021|     79|						port->p_power.pse_status =
 1022|     79|						    (port->p_power.pse_status &
 1023|     79|							(1 << 15 | 1 << 14)) >>
 1024|     79|						    14;
 1025|     79|						port->p_power.type_ext = PEEK_UINT8;
  ------------------
  |  |   62|     79|#define PEEK_UINT8 PEEK(types.f_uint8, )
  |  |  ------------------
  |  |  |  |   60|     79|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|     79|      func(type))
  |  |  ------------------
  ------------------
 1026|     79|						port->p_power.pd_load =
 1027|     79|						    (port->p_power.type_ext & 0x1);
 1028|     79|						port->p_power.type_ext =
 1029|     79|						    ((port->p_power.type_ext &
 1030|     79|							 (1 << 3 | 1 << 2 | 1 << 1)) +
 1031|     79|							1);
 1032|     79|						port->p_power.pse_max = PEEK_UINT16;
  ------------------
  |  |   63|     79|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  ------------------
  |  |  |  |   60|     79|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|     79|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   63|     79|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1033|    447|					} else {
 1034|    447|						port->p_power.type_ext =
 1035|    447|						    LLDP_DOT3_POWER_8023BT_OFF;
  ------------------
  |  |  217|    447|#define LLDP_DOT3_POWER_8023BT_OFF 0
  ------------------
 1036|    447|					}
 1037|    526|					break;
 1038|    249|				default:
  ------------------
  |  Branch (1038:5): [True: 249, False: 1.15k]
  ------------------
 1039|       |					/* Unknown Dot3 TLV, ignore it */
 1040|    249|					unrecognized = 1;
 1041|  1.40k|				}
 1042|  1.40k|#endif
 1043|  7.04k|			} else if (memcmp(med, orgid, sizeof(orgid)) == 0) {
  ------------------
  |  Branch (1043:15): [True: 5.63k, False: 1.40k]
  ------------------
 1044|       |				/* LLDP-MED */
 1045|       |#ifndef ENABLE_LLDPMED
 1046|       |				unrecognized = 1;
 1047|       |#else
 1048|  5.63k|				u_int32_t policy;
 1049|  5.63k|				unsigned loctype;
 1050|  5.63k|				unsigned power;
 1051|       |
 1052|  5.63k|				switch (tlv_subtype) {
 1053|    245|				case LLDP_TLV_MED_CAP:
  ------------------
  |  |   71|    245|#define LLDP_TLV_MED_CAP 1
  ------------------
  |  Branch (1053:5): [True: 245, False: 5.39k]
  ------------------
 1054|    245|					CHECK_TLV_SIZE(7, "LLDP-MED capabilities");
  ------------------
  |  |  555|    245|  do {                                                                             \
  |  |  556|    245|    if (tlv_size < (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (556:9): [True: 1, False: 244]
  |  |  ------------------
  |  |  557|      1|      log_warnx("lldp", name " TLV too short received on %s", hardware->h_ifname); \
  |  |  558|      1|      goto malformed;                                                              \
  |  |  559|      1|    }                                                                              \
  |  |  560|    245|  } while (0)
  |  |  ------------------
  |  |  |  Branch (560:12): [Folded, False: 244]
  |  |  ------------------
  ------------------
 1055|    244|					chassis->c_med_cap_available = PEEK_UINT16;
  ------------------
  |  |   63|    244|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  ------------------
  |  |  |  |   60|    244|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    244|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   63|    244|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1056|    244|					chassis->c_med_type = PEEK_UINT8;
  ------------------
  |  |   62|    244|#define PEEK_UINT8 PEEK(types.f_uint8, )
  |  |  ------------------
  |  |  |  |   60|    244|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    244|      func(type))
  |  |  ------------------
  ------------------
 1057|    244|					port->p_med_cap_enabled |= LLDP_MED_CAP_CAP;
  ------------------
  |  |  329|    244|#define LLDP_MED_CAP_CAP 0x01
  ------------------
 1058|    244|					break;
 1059|    683|				case LLDP_TLV_MED_POLICY:
  ------------------
  |  |   72|    683|#define LLDP_TLV_MED_POLICY 2
  ------------------
  |  Branch (1059:5): [True: 683, False: 4.95k]
  ------------------
 1060|    683|					CHECK_TLV_SIZE(8, "LLDP-MED policy");
  ------------------
  |  |  555|    683|  do {                                                                             \
  |  |  556|    683|    if (tlv_size < (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (556:9): [True: 3, False: 680]
  |  |  ------------------
  |  |  557|      3|      log_warnx("lldp", name " TLV too short received on %s", hardware->h_ifname); \
  |  |  558|      3|      goto malformed;                                                              \
  |  |  559|      3|    }                                                                              \
  |  |  560|    683|  } while (0)
  |  |  ------------------
  |  |  |  Branch (560:12): [Folded, False: 680]
  |  |  ------------------
  ------------------
 1061|    680|					policy = PEEK_UINT32;
  ------------------
  |  |   64|    680|#define PEEK_UINT32 PEEK(types.f_uint32, ntohl)
  |  |  ------------------
  |  |  |  |   60|    680|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    680|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|    680|#define PEEK_UINT32 PEEK(types.f_uint32, ntohl)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1062|    680|					if (((policy >> 24) < 1) ||
  ------------------
  |  Branch (1062:10): [True: 220, False: 460]
  ------------------
 1063|    460|					    ((policy >> 24) > LLDP_MED_APPTYPE_LAST)) {
  ------------------
  |  |  295|    460|#define LLDP_MED_APPTYPE_LAST LLDP_MED_APPTYPE_VIDEOSIGNAL
  |  |  ------------------
  |  |  |  |  294|    460|#define LLDP_MED_APPTYPE_VIDEOSIGNAL 8
  |  |  ------------------
  ------------------
  |  Branch (1063:10): [True: 223, False: 237]
  ------------------
 1064|    443|						log_info("lldp",
 1065|    443|						    "unknown policy field %d "
 1066|    443|						    "received on %s",
 1067|    443|						    policy, hardware->h_ifname);
 1068|    443|						break;
 1069|    443|					}
 1070|    237|					port->p_med_policy[(policy >> 24) - 1].type =
 1071|    237|					    (policy >> 24);
 1072|    237|					port->p_med_policy[(policy >> 24) - 1].unknown =
 1073|    237|					    ((policy & 0x800000) != 0);
 1074|    237|					port->p_med_policy[(policy >> 24) - 1].tagged =
 1075|    237|					    ((policy & 0x400000) != 0);
 1076|    237|					port->p_med_policy[(policy >> 24) - 1].vid =
 1077|    237|					    (policy & 0x001FFE00) >> 9;
 1078|    237|					port->p_med_policy[(policy >> 24) - 1]
 1079|    237|					    .priority = (policy & 0x1C0) >> 6;
 1080|    237|					port->p_med_policy[(policy >> 24) - 1].dscp =
 1081|    237|					    policy & 0x3F;
 1082|    237|					port->p_med_cap_enabled |= LLDP_MED_CAP_POLICY;
  ------------------
  |  |  330|    237|#define LLDP_MED_CAP_POLICY 0x02
  ------------------
 1083|    237|					break;
 1084|    594|				case LLDP_TLV_MED_LOCATION:
  ------------------
  |  |   73|    594|#define LLDP_TLV_MED_LOCATION 3
  ------------------
  |  Branch (1084:5): [True: 594, False: 5.04k]
  ------------------
 1085|    594|					CHECK_TLV_SIZE(5, "LLDP-MED Location");
  ------------------
  |  |  555|    594|  do {                                                                             \
  |  |  556|    594|    if (tlv_size < (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (556:9): [True: 1, False: 593]
  |  |  ------------------
  |  |  557|      1|      log_warnx("lldp", name " TLV too short received on %s", hardware->h_ifname); \
  |  |  558|      1|      goto malformed;                                                              \
  |  |  559|      1|    }                                                                              \
  |  |  560|    594|  } while (0)
  |  |  ------------------
  |  |  |  Branch (560:12): [Folded, False: 593]
  |  |  ------------------
  ------------------
 1086|    593|					loctype = PEEK_UINT8;
  ------------------
  |  |   62|    593|#define PEEK_UINT8 PEEK(types.f_uint8, )
  |  |  ------------------
  |  |  |  |   60|    593|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|    593|      func(type))
  |  |  ------------------
  ------------------
 1087|    593|					if ((loctype < 1) ||
  ------------------
  |  Branch (1087:10): [True: 194, False: 399]
  ------------------
 1088|    399|					    (loctype > LLDP_MED_LOCFORMAT_LAST)) {
  ------------------
  |  |  301|    399|#define LLDP_MED_LOCFORMAT_LAST LLDP_MED_LOCFORMAT_ELIN
  |  |  ------------------
  |  |  |  |  300|    399|#define LLDP_MED_LOCFORMAT_ELIN 3
  |  |  ------------------
  ------------------
  |  Branch (1088:10): [True: 203, False: 196]
  ------------------
 1089|    397|						log_info("lldp",
 1090|    397|						    "unknown location type "
 1091|    397|						    "received on %s",
 1092|    397|						    hardware->h_ifname);
 1093|    397|						break;
 1094|    397|					}
 1095|    196|					free(port->p_med_location[loctype - 1].data);
 1096|    196|					if ((port->p_med_location[loctype - 1].data =
  ------------------
  |  Branch (1096:10): [True: 0, False: 196]
  ------------------
 1097|    196|						    (char *)malloc(tlv_size - 5)) ==
 1098|    196|					    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|    196|					PEEK_BYTES(
  ------------------
  |  |   66|    196|  do {                           \
  |  |   67|    196|    memcpy(value, pos, bytes);   \
  |  |   68|    196|    length -= (bytes);           \
  |  |   69|    196|    pos += (bytes);              \
  |  |   70|    196|  } while (0)
  |  |  ------------------
  |  |  |  Branch (70:12): [Folded, False: 196]
  |  |  ------------------
  ------------------
 1107|    196|					    port->p_med_location[loctype - 1].data,
 1108|    196|					    tlv_size - 5);
 1109|    196|					port->p_med_location[loctype - 1].data_len =
 1110|    196|					    tlv_size - 5;
 1111|    196|					port->p_med_location[loctype - 1].format =
 1112|    196|					    loctype;
 1113|    196|					port->p_med_cap_enabled |=
 1114|    196|					    LLDP_MED_CAP_LOCATION;
  ------------------
  |  |  331|    196|#define LLDP_MED_CAP_LOCATION 0x04
  ------------------
 1115|    196|					break;
 1116|  2.05k|				case LLDP_TLV_MED_MDI:
  ------------------
  |  |   74|  2.05k|#define LLDP_TLV_MED_MDI 4
  ------------------
  |  Branch (1116:5): [True: 2.05k, False: 3.58k]
  ------------------
 1117|  2.05k|					CHECK_TLV_SIZE(7, "LLDP-MED PoE-MDI");
  ------------------
  |  |  555|  2.05k|  do {                                                                             \
  |  |  556|  2.05k|    if (tlv_size < (x)) {                                                          \
  |  |  ------------------
  |  |  |  Branch (556:9): [True: 3, False: 2.04k]
  |  |  ------------------
  |  |  557|      3|      log_warnx("lldp", name " TLV too short received on %s", hardware->h_ifname); \
  |  |  558|      3|      goto malformed;                                                              \
  |  |  559|      3|    }                                                                              \
  |  |  560|  2.05k|  } while (0)
  |  |  ------------------
  |  |  |  Branch (560:12): [Folded, False: 2.04k]
  |  |  ------------------
  ------------------
 1118|  2.04k|					power = PEEK_UINT8;
  ------------------
  |  |   62|  2.04k|#define PEEK_UINT8 PEEK(types.f_uint8, )
  |  |  ------------------
  |  |  |  |   60|  2.04k|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|  2.04k|      func(type))
  |  |  ------------------
  ------------------
 1119|  2.04k|					switch (power & 0xC0) {
 1120|    848|					case 0x0:
  ------------------
  |  Branch (1120:6): [True: 848, False: 1.20k]
  ------------------
 1121|    848|						port->p_med_power.devicetype =
 1122|    848|						    LLDP_MED_POW_TYPE_PSE;
  ------------------
  |  |  311|    848|#define LLDP_MED_POW_TYPE_PSE 1
  ------------------
 1123|    848|						port->p_med_cap_enabled |=
 1124|    848|						    LLDP_MED_CAP_MDI_PSE;
  ------------------
  |  |  332|    848|#define LLDP_MED_CAP_MDI_PSE 0x08
  ------------------
 1125|    848|						switch (power & 0x30) {
 1126|    204|						case 0x0:
  ------------------
  |  Branch (1126:7): [True: 204, False: 644]
  ------------------
 1127|    204|							port->p_med_power.source =
 1128|    204|							    LLDP_MED_POW_SOURCE_UNKNOWN;
  ------------------
  |  |  315|    204|#define LLDP_MED_POW_SOURCE_UNKNOWN 1
  ------------------
 1129|    204|							break;
 1130|    223|						case 0x10:
  ------------------
  |  Branch (1130:7): [True: 223, False: 625]
  ------------------
 1131|    223|							port->p_med_power.source =
 1132|    223|							    LLDP_MED_POW_SOURCE_PRIMARY;
  ------------------
  |  |  316|    223|#define LLDP_MED_POW_SOURCE_PRIMARY 2
  ------------------
 1133|    223|							break;
 1134|    223|						case 0x20:
  ------------------
  |  Branch (1134:7): [True: 223, False: 625]
  ------------------
 1135|    223|							port->p_med_power.source =
 1136|    223|							    LLDP_MED_POW_SOURCE_BACKUP;
  ------------------
  |  |  317|    223|#define LLDP_MED_POW_SOURCE_BACKUP 3
  ------------------
 1137|    223|							break;
 1138|    198|						default:
  ------------------
  |  Branch (1138:7): [True: 198, False: 650]
  ------------------
 1139|    198|							port->p_med_power.source =
 1140|    198|							    LLDP_MED_POW_SOURCE_RESERVED;
  ------------------
  |  |  318|    198|#define LLDP_MED_POW_SOURCE_RESERVED 4
  ------------------
 1141|    848|						}
 1142|    848|						break;
 1143|    848|					case 0x40:
  ------------------
  |  Branch (1143:6): [True: 841, False: 1.20k]
  ------------------
 1144|    841|						port->p_med_power.devicetype =
 1145|    841|						    LLDP_MED_POW_TYPE_PD;
  ------------------
  |  |  312|    841|#define LLDP_MED_POW_TYPE_PD 2
  ------------------
 1146|    841|						port->p_med_cap_enabled |=
 1147|    841|						    LLDP_MED_CAP_MDI_PD;
  ------------------
  |  |  333|    841|#define LLDP_MED_CAP_MDI_PD 0x10
  ------------------
 1148|    841|						switch (power & 0x30) {
 1149|    242|						case 0x0:
  ------------------
  |  Branch (1149:7): [True: 242, False: 599]
  ------------------
 1150|    242|							port->p_med_power.source =
 1151|    242|							    LLDP_MED_POW_SOURCE_UNKNOWN;
  ------------------
  |  |  315|    242|#define LLDP_MED_POW_SOURCE_UNKNOWN 1
  ------------------
 1152|    242|							break;
 1153|    198|						case 0x10:
  ------------------
  |  Branch (1153:7): [True: 198, False: 643]
  ------------------
 1154|    198|							port->p_med_power.source =
 1155|    198|							    LLDP_MED_POW_SOURCE_PSE;
  ------------------
  |  |  319|    198|#define LLDP_MED_POW_SOURCE_PSE 5
  ------------------
 1156|    198|							break;
 1157|    203|						case 0x20:
  ------------------
  |  Branch (1157:7): [True: 203, False: 638]
  ------------------
 1158|    203|							port->p_med_power.source =
 1159|    203|							    LLDP_MED_POW_SOURCE_LOCAL;
  ------------------
  |  |  320|    203|#define LLDP_MED_POW_SOURCE_LOCAL 6
  ------------------
 1160|    203|							break;
 1161|    198|						default:
  ------------------
  |  Branch (1161:7): [True: 198, False: 643]
  ------------------
 1162|    198|							port->p_med_power.source =
 1163|    198|							    LLDP_MED_POW_SOURCE_BOTH;
  ------------------
  |  |  321|    198|#define LLDP_MED_POW_SOURCE_BOTH 7
  ------------------
 1164|    841|						}
 1165|    841|						break;
 1166|    841|					default:
  ------------------
  |  Branch (1166:6): [True: 360, False: 1.68k]
  ------------------
 1167|    360|						port->p_med_power.devicetype =
 1168|    360|						    LLDP_MED_POW_TYPE_RESERVED;
  ------------------
  |  |  313|    360|#define LLDP_MED_POW_TYPE_RESERVED 3
  ------------------
 1169|  2.04k|					}
 1170|  2.04k|					if ((power & 0x0F) > LLDP_MED_POW_PRIO_LOW)
  ------------------
  |  |  326|  2.04k|#define LLDP_MED_POW_PRIO_LOW 3
  ------------------
  |  Branch (1170:10): [True: 1.09k, False: 958]
  ------------------
 1171|  1.09k|						port->p_med_power.priority =
 1172|  1.09k|						    LLDP_MED_POW_PRIO_UNKNOWN;
  ------------------
  |  |  323|  1.09k|#define LLDP_MED_POW_PRIO_UNKNOWN 0
  ------------------
 1173|    958|					else
 1174|    958|						port->p_med_power.priority =
 1175|    958|						    power & 0x0F;
 1176|  2.04k|					port->p_med_power.val = PEEK_UINT16;
  ------------------
  |  |   63|  2.04k|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  ------------------
  |  |  |  |   60|  2.04k|  (memcpy(&type, pos, sizeof(type)), length -= sizeof(type), pos += sizeof(type), \
  |  |  |  |   61|  2.04k|      func(type))
  |  |  |  |  ------------------
  |  |  |  |  |  |   63|  2.04k|#define PEEK_UINT16 PEEK(types.f_uint16, ntohs)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1177|  2.04k|					break;
 1178|    301|				case LLDP_TLV_MED_IV_HW:
  ------------------
  |  |   75|    301|#define LLDP_TLV_MED_IV_HW 5
  ------------------
  |  Branch (1178:5): [True: 301, False: 5.33k]
  ------------------
 1179|    598|				case LLDP_TLV_MED_IV_SW:
  ------------------
  |  |   77|    598|#define LLDP_TLV_MED_IV_SW 7
  ------------------
  |  Branch (1179:5): [True: 297, False: 5.34k]
  ------------------
 1180|    831|				case LLDP_TLV_MED_IV_FW:
  ------------------
  |  |   76|    831|#define LLDP_TLV_MED_IV_FW 6
  ------------------
  |  Branch (1180:5): [True: 233, False: 5.40k]
  ------------------
 1181|  1.07k|				case LLDP_TLV_MED_IV_SN:
  ------------------
  |  |   78|  1.07k|#define LLDP_TLV_MED_IV_SN 8
  ------------------
  |  Branch (1181:5): [True: 244, False: 5.39k]
  ------------------
 1182|  1.28k|				case LLDP_TLV_MED_IV_MANUF:
  ------------------
  |  |   79|  1.28k|#define LLDP_TLV_MED_IV_MANUF 9
  ------------------
  |  Branch (1182:5): [True: 207, False: 5.43k]
  ------------------
 1183|  1.55k|				case LLDP_TLV_MED_IV_MODEL:
  ------------------
  |  |   80|  1.55k|#define LLDP_TLV_MED_IV_MODEL 10
  ------------------
  |  Branch (1183:5): [True: 274, False: 5.36k]
  ------------------
 1184|  1.85k|				case LLDP_TLV_MED_IV_ASSET:
  ------------------
  |  |   81|  1.85k|#define LLDP_TLV_MED_IV_ASSET 11
  ------------------
  |  Branch (1184:5): [True: 294, False: 5.34k]
  ------------------
 1185|  1.85k|					if (tlv_size <= 4)
  ------------------
  |  Branch (1185:10): [True: 1.54k, False: 306]
  ------------------
 1186|  1.54k|						b = NULL;
 1187|    306|					else {
 1188|    306|						if ((b = (char *)malloc(
  ------------------
  |  Branch (1188:11): [True: 0, False: 306]
  ------------------
 1189|    306|							 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|    306|						PEEK_BYTES(b, tlv_size - 4);
  ------------------
  |  |   66|    306|  do {                           \
  |  |   67|    306|    memcpy(value, pos, bytes);   \
  |  |   68|    306|    length -= (bytes);           \
  |  |   69|    306|    pos += (bytes);              \
  |  |   70|    306|  } while (0)
  |  |  ------------------
  |  |  |  Branch (70:12): [Folded, False: 306]
  |  |  ------------------
  ------------------
 1199|    306|						b[tlv_size - 4] = '\0';
 1200|    306|					}
 1201|  1.85k|					switch (tlv_subtype) {
 1202|    301|					case LLDP_TLV_MED_IV_HW:
  ------------------
  |  |   75|    301|#define LLDP_TLV_MED_IV_HW 5
  ------------------
  |  Branch (1202:6): [True: 301, False: 1.54k]
  ------------------
 1203|    301|						free(chassis->c_med_hw);
 1204|    301|						chassis->c_med_hw = b;
 1205|    301|						break;
 1206|    233|					case LLDP_TLV_MED_IV_FW:
  ------------------
  |  |   76|    233|#define LLDP_TLV_MED_IV_FW 6
  ------------------
  |  Branch (1206:6): [True: 233, False: 1.61k]
  ------------------
 1207|    233|						free(chassis->c_med_fw);
 1208|    233|						chassis->c_med_fw = b;
 1209|    233|						break;
 1210|    297|					case LLDP_TLV_MED_IV_SW:
  ------------------
  |  |   77|    297|#define LLDP_TLV_MED_IV_SW 7
  ------------------
  |  Branch (1210:6): [True: 297, False: 1.55k]
  ------------------
 1211|    297|						free(chassis->c_med_sw);
 1212|    297|						chassis->c_med_sw = b;
 1213|    297|						break;
 1214|    244|					case LLDP_TLV_MED_IV_SN:
  ------------------
  |  |   78|    244|#define LLDP_TLV_MED_IV_SN 8
  ------------------
  |  Branch (1214:6): [True: 244, False: 1.60k]
  ------------------
 1215|    244|						free(chassis->c_med_sn);
 1216|    244|						chassis->c_med_sn = b;
 1217|    244|						break;
 1218|    207|					case LLDP_TLV_MED_IV_MANUF:
  ------------------
  |  |   79|    207|#define LLDP_TLV_MED_IV_MANUF 9
  ------------------
  |  Branch (1218:6): [True: 207, False: 1.64k]
  ------------------
 1219|    207|						free(chassis->c_med_manuf);
 1220|    207|						chassis->c_med_manuf = b;
 1221|    207|						break;
 1222|    274|					case LLDP_TLV_MED_IV_MODEL:
  ------------------
  |  |   80|    274|#define LLDP_TLV_MED_IV_MODEL 10
  ------------------
  |  Branch (1222:6): [True: 274, False: 1.57k]
  ------------------
 1223|    274|						free(chassis->c_med_model);
 1224|    274|						chassis->c_med_model = b;
 1225|    274|						break;
 1226|    294|					case LLDP_TLV_MED_IV_ASSET:
  ------------------
  |  |   81|    294|#define LLDP_TLV_MED_IV_ASSET 11
  ------------------
  |  Branch (1226:6): [True: 294, False: 1.55k]
  ------------------
 1227|    294|						free(chassis->c_med_asset);
 1228|    294|						chassis->c_med_asset = b;
 1229|    294|						break;
 1230|      0|					default:
  ------------------
  |  Branch (1230:6): [True: 0, False: 1.85k]
  ------------------
 1231|       |						/* unreachable */
 1232|      0|						free(b);
 1233|      0|						break;
 1234|  1.85k|					}
 1235|  1.85k|					port->p_med_cap_enabled |= LLDP_MED_CAP_IV;
  ------------------
  |  |  334|  1.85k|#define LLDP_MED_CAP_IV 0x20
  ------------------
 1236|  1.85k|					break;
 1237|    215|				default:
  ------------------
  |  Branch (1237:5): [True: 215, False: 5.42k]
  ------------------
 1238|       |					/* Unknown LLDP MED, ignore it */
 1239|    215|					hardware->h_rx_unrecognized_cnt++;
 1240|  5.63k|				}
 1241|  5.63k|#endif /* ENABLE_LLDPMED */
 1242|  5.63k|			} else if (memcmp(dcbx, orgid, sizeof(orgid)) == 0) {
  ------------------
  |  Branch (1242:15): [True: 407, False: 997]
  ------------------
 1243|    407|				log_debug("lldp",
 1244|    407|				    "unsupported DCBX tlv received on %s - ignore",
 1245|    407|				    hardware->h_ifname);
 1246|    407|				unrecognized = 1;
 1247|    997|			} else {
 1248|    997|				log_debug("lldp",
 1249|    997|				    "unknown org tlv [%02x:%02x:%02x] received on %s",
 1250|    997|				    orgid[0], orgid[1], orgid[2], hardware->h_ifname);
 1251|    997|				unrecognized = 1;
 1252|    997|			}
 1253|  10.2k|			if (unrecognized) {
  ------------------
  |  Branch (1253:8): [True: 2.02k, False: 8.19k]
  ------------------
 1254|  2.02k|				hardware->h_rx_unrecognized_cnt++;
 1255|  2.02k|#ifdef ENABLE_CUSTOM
 1256|  2.02k|				custom = (struct lldpd_custom *)calloc(1,
 1257|  2.02k|				    sizeof(struct lldpd_custom));
 1258|  2.02k|				if (!custom) {
  ------------------
  |  Branch (1258:9): [True: 0, False: 2.02k]
  ------------------
 1259|      0|					log_warn("lldp",
 1260|      0|					    "unable to allocate memory for custom TLV");
 1261|      0|					goto malformed;
 1262|      0|				}
 1263|  2.02k|				custom->oui_info_len = tlv_size > 4 ? tlv_size - 4 : 0;
  ------------------
  |  Branch (1263:28): [True: 689, False: 1.33k]
  ------------------
 1264|  2.02k|				memcpy(custom->oui, orgid, sizeof(custom->oui));
 1265|  2.02k|				custom->subtype = tlv_subtype;
 1266|  2.02k|				if (custom->oui_info_len > 0) {
  ------------------
  |  Branch (1266:9): [True: 689, False: 1.33k]
  ------------------
 1267|    689|					custom->oui_info = malloc(custom->oui_info_len);
 1268|    689|					if (!custom->oui_info) {
  ------------------
  |  Branch (1268:10): [True: 0, False: 689]
  ------------------
 1269|      0|						log_warn("lldp",
 1270|      0|						    "unable to allocate memory for custom TLV data");
 1271|      0|						goto malformed;
 1272|      0|					}
 1273|    689|					PEEK_BYTES(custom->oui_info,
  ------------------
  |  |   66|    689|  do {                           \
  |  |   67|    689|    memcpy(value, pos, bytes);   \
  |  |   68|    689|    length -= (bytes);           \
  |  |   69|    689|    pos += (bytes);              \
  |  |   70|    689|  } while (0)
  |  |  ------------------
  |  |  |  Branch (70:12): [Folded, False: 689]
  |  |  ------------------
  ------------------
 1274|    689|					    custom->oui_info_len);
 1275|    689|				}
 1276|  2.02k|				TAILQ_INSERT_TAIL(&port->p_custom_list, custom, next);
  ------------------
  |  Branch (1276:5): [Folded, False: 2.02k]
  ------------------
 1277|  2.02k|				custom = NULL;
 1278|  2.02k|#endif
 1279|  2.02k|			}
 1280|  10.2k|			break;
 1281|  10.2k|		default:
  ------------------
  |  Branch (1281:3): [True: 623, False: 17.4k]
  ------------------
 1282|    623|			log_warnx("lldp", "unknown tlv (%d) received on %s", tlv_type,
 1283|    623|			    hardware->h_ifname);
 1284|    623|			hardware->h_rx_unrecognized_cnt++;
 1285|    623|			break;
 1286|  18.0k|		}
 1287|  17.9k|		if (pos > tlv + tlv_size) {
  ------------------
  |  Branch (1287:7): [True: 0, False: 17.9k]
  ------------------
 1288|      0|			log_warnx("lldp", "BUG: already past TLV!");
 1289|      0|			goto malformed;
 1290|      0|		}
 1291|  17.9k|		PEEK_DISCARD(tlv + tlv_size - pos);
  ------------------
  |  |   72|  17.9k|  do {                      \
  |  |   73|  17.9k|    length -= (bytes);      \
  |  |   74|  17.9k|    pos += (bytes);         \
  |  |   75|  17.9k|  } while (0)
  |  |  ------------------
  |  |  |  Branch (75:12): [Folded, False: 17.9k]
  |  |  ------------------
  ------------------
 1292|  17.9k|	}
 1293|       |
 1294|       |	/* Some random check */
 1295|    782|	if ((chassis->c_id == NULL) || (port->p_id == NULL) || (!ttl_received) ||
  ------------------
  |  Branch (1295:6): [True: 550, False: 232]
  |  Branch (1295:33): [True: 27, False: 205]
  |  Branch (1295:57): [True: 8, False: 197]
  ------------------
 1296|    669|	    (gotend == 0)) {
  ------------------
  |  Branch (1296:6): [True: 84, False: 113]
  ------------------
 1297|    669|		log_warnx("lldp",
 1298|    669|		    "some mandatory tlv are missing for frame received on %s",
 1299|    669|		    hardware->h_ifname);
 1300|    669|		goto malformed;
 1301|    669|	}
 1302|    113|	*newchassis = chassis;
 1303|    113|	*newport = port;
 1304|    113|	return 1;
 1305|  1.05k|malformed:
 1306|  1.05k|#ifdef ENABLE_CUSTOM
 1307|  1.05k|	free(custom);
 1308|  1.05k|#endif
 1309|  1.05k|#ifdef ENABLE_DOT1
 1310|  1.05k|	free(vlan);
 1311|  1.05k|	free(pi);
 1312|  1.05k|#endif
 1313|  1.05k|	lldpd_chassis_cleanup(chassis, 1);
 1314|  1.05k|	lldpd_port_cleanup(port, 1);
 1315|  1.05k|	free(port);
 1316|  1.05k|	return -1;
 1317|    782|}
lldp.c:lldpd_af_from_lldp_proto:
   43|    913|{
   44|    913|	switch (proto) {
   45|    459|	case LLDP_MGMT_ADDR_IP4:
  ------------------
  |  |  273|    459|#define LLDP_MGMT_ADDR_IP4 1
  ------------------
  |  Branch (45:2): [True: 459, False: 454]
  ------------------
   46|    459|		return LLDPD_AF_IPV4;
   47|    225|	case LLDP_MGMT_ADDR_IP6:
  ------------------
  |  |  274|    225|#define LLDP_MGMT_ADDR_IP6 2
  ------------------
  |  Branch (47:2): [True: 225, False: 688]
  ------------------
   48|    225|		return LLDPD_AF_IPV6;
   49|    229|	default:
  ------------------
  |  Branch (49:2): [True: 229, False: 684]
  ------------------
   50|    229|		return LLDPD_AF_UNSPEC;
   51|    913|	}
   52|    913|}

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

log_register:
   64|  1.16k|{
   65|  1.16k|	logh = cb;
   66|  1.16k|}
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.59k|{
  215|  1.59k|	va_list ap;
  216|       |
  217|  1.59k|	va_start(ap, emsg);
  218|  1.59k|	vlog(LOG_WARNING, token, emsg, ap);
  219|       |	va_end(ap);
  220|  1.59k|}
log_info:
  224|    913|{
  225|    913|	va_list ap;
  226|       |
  227|    913|	if (use_syslog || debug > 0 || logh) {
  ------------------
  |  Branch (227:6): [True: 0, False: 913]
  |  Branch (227:20): [True: 0, False: 913]
  |  Branch (227:33): [True: 913, False: 0]
  ------------------
  228|    913|		va_start(ap, emsg);
  229|    913|		vlog(LOG_INFO, token, emsg, ap);
  230|       |		va_end(ap);
  231|    913|	}
  232|    913|}
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.3k|{
  155|  12.3k|	if (logh) {
  ------------------
  |  Branch (155:6): [True: 12.3k, False: 0]
  ------------------
  156|  12.3k|		char *result = NULL;
  157|  12.3k|		if (vasprintf(&result, fmt, ap) != -1) {
  ------------------
  |  Branch (157:7): [True: 12.3k, False: 0]
  ------------------
  158|  12.3k|			logh(pri, result);
  159|  12.3k|			free(result);
  160|  12.3k|			return;
  161|  12.3k|		}
  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.3k|	}
  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.3k|void donothing(int pri, const char *msg) {};
LLVMFuzzerTestOneInput:
   28|  1.18k|{
   29|  1.18k|	if (Size < kMinInputLength || Size > kMaxInputLength) {
  ------------------
  |  |   20|  2.37k|#define kMinInputLength 5
  ------------------
              	if (Size < kMinInputLength || Size > kMaxInputLength) {
  ------------------
  |  |   21|  1.18k|#define kMaxInputLength 2048
  ------------------
  |  Branch (29:6): [True: 4, False: 1.18k]
  |  Branch (29:32): [True: 22, False: 1.16k]
  ------------------
   30|     26|		return 1;
   31|     26|	}
   32|       |
   33|  1.16k|	struct lldpd_chassis *nchassis = NULL;
   34|  1.16k|	struct lldpd_port *nport = NULL;
   35|  1.16k|	struct lldpd_hardware hardware;
   36|       |
   37|  1.16k|	log_register(donothing);
   38|       |
   39|  1.16k|	lldp_decode(NULL, (char *)Data, Size, &hardware, &nchassis, &nport);
   40|       |
   41|  1.16k|	if (!nchassis || !nport) {
  ------------------
  |  Branch (41:6): [True: 1.05k, False: 113]
  |  Branch (41:19): [True: 0, False: 113]
  ------------------
   42|  1.05k|		return 1;
   43|  1.05k|	}
   44|       |
   45|    113|	lldpd_port_cleanup(nport, 1);
   46|    113|	free(nport);
   47|    113|	lldpd_chassis_cleanup(nchassis, 1);
   48|       |
   49|    113|	return 0;
   50|  1.16k|}

