coap_net.c:coap_pdu_release_lkd:
  436|    103|coap_pdu_release_lkd(coap_pdu_t *pdu) {
  437|    103|  coap_delete_pdu_lkd(pdu);
  438|    103|}
coap_resource.c:coap_pdu_release_lkd:
  436|    107|coap_pdu_release_lkd(coap_pdu_t *pdu) {
  437|    107|  coap_delete_pdu_lkd(pdu);
  438|    107|}

coap_is_af_llc:
  172|     35|coap_is_af_llc(const coap_address_t *a) {
  173|     35|#if COAP_AF_LLC_SUPPORT
  174|     35|  return a->addr.sa.sa_family == AF_LLC;
  175|       |#else /* ! COAP_AF_LLC_SUPPORT */
  176|       |  (void)a;
  177|       |  return 0;
  178|       |#endif /* ! COAP_AF_LLC_SUPPORT */
  179|     35|}
coap_is_mcast:
  182|    344|coap_is_mcast(const coap_address_t *a) {
  183|    344|  if (!a)
  ------------------
  |  Branch (183:7): [True: 0, False: 344]
  ------------------
  184|      0|    return 0;
  185|       |
  186|       |  /* Treat broadcast in same way as multicast */
  187|    344|  if (coap_is_bcast(a))
  ------------------
  |  Branch (187:7): [True: 0, False: 344]
  ------------------
  188|      0|    return 1;
  189|       |
  190|    344|  switch (a->addr.sa.sa_family) {
  191|      0|#if COAP_IPV4_SUPPORT
  192|    344|  case AF_INET:
  ------------------
  |  Branch (192:3): [True: 344, False: 0]
  ------------------
  193|    344|    return IN_MULTICAST(ntohl(a->addr.sin.sin_addr.s_addr));
  194|      0|#endif /* COAP_IPV4_SUPPORT */
  195|      0|#if COAP_IPV6_SUPPORT
  196|      0|  case  AF_INET6:
  ------------------
  |  Branch (196:3): [True: 0, False: 344]
  ------------------
  197|      0|#if COAP_IPV4_SUPPORT
  198|      0|    return IN6_IS_ADDR_MULTICAST(&a->addr.sin6.sin6_addr) ||
  ------------------
  |  Branch (198:12): [True: 0, False: 0]
  ------------------
  199|      0|           (IN6_IS_ADDR_V4MAPPED(&a->addr.sin6.sin6_addr) &&
  ------------------
  |  Branch (199:13): [True: 0, False: 0]
  ------------------
  200|      0|            IN_MULTICAST(ntohl(a->addr.sin6.sin6_addr.s6_addr[12])));
  ------------------
  |  Branch (200:13): [True: 0, False: 0]
  ------------------
  201|       |#else /* ! COAP_IPV4_SUPPORT */
  202|       |    return a->addr.sin6.sin6_addr.s6_addr[0] == 0xff;
  203|       |#endif /* ! COAP_IPV4_SUPPORT */
  204|      0|#endif /* COAP_IPV6_SUPPORT */
  205|      0|  default:  /* fall through and signal not multicast */
  ------------------
  |  Branch (205:3): [True: 0, False: 344]
  ------------------
  206|      0|    ;
  207|    344|  }
  208|      0|  return 0;
  209|    344|}
coap_is_bcast:
  227|    344|coap_is_bcast(const coap_address_t *a) {
  228|    344|#if COAP_IPV4_SUPPORT
  229|    344|  struct in_addr ipv4;
  230|    344|#if defined(HAVE_GETIFADDRS) && !defined(__ZEPHYR__)
  231|    344|  int i;
  232|    344|  coap_tick_t now;
  233|    344|#endif /* HAVE_GETIFADDRS && !defined(__ZEPHYR__) */
  234|    344|#endif /* COAP_IPV4_SUPPORT */
  235|       |
  236|    344|  if (!a)
  ------------------
  |  Branch (236:7): [True: 0, False: 344]
  ------------------
  237|      0|    return 0;
  238|       |
  239|    344|  switch (a->addr.sa.sa_family) {
  240|      0|#if COAP_IPV4_SUPPORT
  241|    344|  case AF_INET:
  ------------------
  |  Branch (241:3): [True: 344, False: 0]
  ------------------
  242|    344|    ipv4.s_addr = a->addr.sin.sin_addr.s_addr;
  243|    344|    break;
  244|      0|#endif /* COAP_IPV4_SUPPORT */
  245|      0|#if COAP_IPV6_SUPPORT
  246|      0|  case  AF_INET6:
  ------------------
  |  Branch (246:3): [True: 0, False: 344]
  ------------------
  247|      0|#if COAP_IPV4_SUPPORT
  248|      0|    if (IN6_IS_ADDR_V4MAPPED(&a->addr.sin6.sin6_addr)) {
  ------------------
  |  Branch (248:9): [True: 0, False: 0]
  ------------------
  249|      0|      memcpy(&ipv4, &a->addr.sin6.sin6_addr.s6_addr[12], sizeof(ipv4));
  250|      0|      break;
  251|      0|    }
  252|      0|#endif /* COAP_IPV4_SUPPORT */
  253|       |    /* IPv6 does not support broadcast */
  254|      0|    return 0;
  255|      0|#endif /* COAP_IPV6_SUPPORT */
  256|      0|  default:
  ------------------
  |  Branch (256:3): [True: 0, False: 344]
  ------------------
  257|      0|    return 0;
  258|    344|  }
  259|    344|#if COAP_IPV4_SUPPORT
  260|       |#ifndef INADDR_BROADCAST
  261|       |#define INADDR_BROADCAST ((uint32_t)0xffffffffUL)
  262|       |#endif /* !INADDR_BROADCAST */
  263|    344|  if (ipv4.s_addr == INADDR_BROADCAST)
  ------------------
  |  Branch (263:7): [True: 0, False: 344]
  ------------------
  264|      0|    return 1;
  265|       |
  266|    344|#if defined(HAVE_GETIFADDRS) && !defined(__ZEPHYR__)
  267|    344|  coap_ticks(&now);
  268|    344|  if (bcst_cnt == -1 ||
  ------------------
  |  Branch (268:7): [True: 1, False: 343]
  ------------------
  269|    343|      (now - last_refresh) > (COAP_BCST_REFRESH_SECS * COAP_TICKS_PER_SECOND)) {
  ------------------
  |  |  217|    343|#define COAP_BCST_REFRESH_SECS 30
  ------------------
                    (now - last_refresh) > (COAP_BCST_REFRESH_SECS * COAP_TICKS_PER_SECOND)) {
  ------------------
  |  |  164|    343|#define COAP_TICKS_PER_SECOND ((coap_tick_t)(1000U))
  ------------------
  |  Branch (269:7): [True: 0, False: 343]
  ------------------
  270|       |    /* Determine the list of broadcast interfaces */
  271|      1|    struct ifaddrs *ifa = NULL;
  272|      1|    struct ifaddrs *ife;
  273|       |
  274|      1|    if (getifaddrs(&ifa) != 0) {
  ------------------
  |  Branch (274:9): [True: 0, False: 1]
  ------------------
  275|      0|      coap_log_warn("coap_is_bcst: Cannot determine any broadcast addresses\n");
  ------------------
  |  |  108|      0|#define coap_log_warn(...) coap_log(COAP_LOG_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  276|      0|      return 0;
  277|      0|    }
  278|      1|    bcst_cnt = 0;
  279|      1|    last_refresh = now;
  280|      1|    ife = ifa;
  281|      5|    while (ife && bcst_cnt < COAP_BCST_CNT) {
  ------------------
  |  |  212|      4|#define COAP_BCST_CNT 15
  ------------------
  |  Branch (281:12): [True: 4, False: 1]
  |  Branch (281:19): [True: 4, False: 0]
  ------------------
  282|      4|      if (ife->ifa_addr && ife->ifa_addr->sa_family == AF_INET &&
  ------------------
  |  Branch (282:11): [True: 4, False: 0]
  |  Branch (282:28): [True: 2, False: 2]
  ------------------
  283|      2|          ife->ifa_flags & IFF_BROADCAST) {
  ------------------
  |  Branch (283:11): [True: 1, False: 1]
  ------------------
  284|      1|        struct in_addr netmask;
  285|       |
  286|       |        /*
  287|       |         * Sometimes the broadcast IP is set to the IP address, even though
  288|       |         * netmask is not set to 0xffffffff, so unsafe to use ifa_broadaddr.
  289|       |         */
  290|      1|        netmask.s_addr = ((struct sockaddr_in *)ife->ifa_netmask)->sin_addr.s_addr;
  291|      1|        if (netmask.s_addr != 0xffffffff) {
  ------------------
  |  Branch (291:13): [True: 1, False: 0]
  ------------------
  292|      1|          b_ipv4[bcst_cnt].s_addr = ((struct sockaddr_in *)ife->ifa_addr)->sin_addr.s_addr |
  293|      1|                                    ~netmask.s_addr;
  294|      1|          bcst_cnt++;
  295|      1|        }
  296|      1|      }
  297|      4|      ife = ife->ifa_next;
  298|      4|    }
  299|      1|    if (ife) {
  ------------------
  |  Branch (299:9): [True: 0, False: 1]
  ------------------
  300|      0|      coap_log_warn("coap_is_bcst: Insufficient space for broadcast addresses\n");
  ------------------
  |  |  108|      0|#define coap_log_warn(...) coap_log(COAP_LOG_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  301|      0|    }
  302|      1|    freeifaddrs(ifa);
  303|      1|  }
  304|    688|  for (i = 0; i < bcst_cnt; i++) {
  ------------------
  |  Branch (304:15): [True: 344, False: 344]
  ------------------
  305|    344|    if (ipv4.s_addr == b_ipv4[i].s_addr)
  ------------------
  |  Branch (305:9): [True: 0, False: 344]
  ------------------
  306|      0|      return 1;
  307|    344|  }
  308|    344|#endif /* HAVE_GETIFADDRS && !defined(__ZEPHYR__) */
  309|       |
  310|       |#if defined(_WIN32)
  311|       |
  312|       |  int i;
  313|       |  coap_tick_t now;
  314|       |
  315|       |  coap_ticks(&now);
  316|       |  if (bcst_cnt == -1 ||
  317|       |      (now - last_refresh) > (COAP_BCST_REFRESH_SECS * COAP_TICKS_PER_SECOND)) {
  318|       |    /* Determine the list of broadcast interfaces */
  319|       |
  320|       |    /* Variables used by GetIpAddrTable */
  321|       |    PMIB_IPADDRTABLE pIPAddrTable;
  322|       |    DWORD dwSize = 0;
  323|       |    DWORD dwRetVal = 0;
  324|       |
  325|       |    /* Assume just 2 interfaces as a starting point */
  326|       |    pIPAddrTable = (MIB_IPADDRTABLE *)coap_malloc_type(COAP_STRING, 2 * sizeof(MIB_IPADDRTABLE));
  327|       |
  328|       |    if (pIPAddrTable) {
  329|       |      /* Check that 2 interfaces are sufficient */
  330|       |      if (GetIpAddrTable(pIPAddrTable, &dwSize, 0) == ERROR_INSUFFICIENT_BUFFER) {
  331|       |        coap_free_type(COAP_STRING, pIPAddrTable);
  332|       |        pIPAddrTable = (MIB_IPADDRTABLE *)coap_malloc_type(COAP_STRING, dwSize);
  333|       |
  334|       |      }
  335|       |      if (pIPAddrTable == NULL) {
  336|       |        coap_log_warn("coap_is_bcst: Cannot determine any broadcast addresses\n");
  337|       |        return 0;
  338|       |      }
  339|       |    }
  340|       |    /* Now get the actual data */
  341|       |    if ((dwRetVal = GetIpAddrTable(pIPAddrTable, &dwSize, 0)) != NO_ERROR) {
  342|       |      coap_log_warn("GetIpAddrTable failed with error %d\n", dwRetVal);
  343|       |      return 0;
  344|       |    }
  345|       |
  346|       |    bcst_cnt = 0;
  347|       |    last_refresh = now;
  348|       |
  349|       |    for (i = 0; i < (int)pIPAddrTable->dwNumEntries && bcst_cnt < COAP_BCST_CNT; i++) {
  350|       |      struct in_addr netmask;
  351|       |
  352|       |      /* Unsafe to use dwBCastAddr */
  353|       |      netmask.s_addr = (u_long)pIPAddrTable->table[i].dwMask;
  354|       |      if (netmask.s_addr != 0xffffffff) {
  355|       |        b_ipv4[bcst_cnt].s_addr = (u_long)pIPAddrTable->table[i].dwAddr |
  356|       |                                  ~netmask.s_addr;
  357|       |        bcst_cnt++;
  358|       |      }
  359|       |    }
  360|       |    if (i != (int)pIPAddrTable->dwNumEntries) {
  361|       |      coap_log_warn("coap_is_bcst: Insufficient space for broadcast addresses\n");
  362|       |    }
  363|       |
  364|       |    if (pIPAddrTable) {
  365|       |      coap_free_type(COAP_STRING, pIPAddrTable);
  366|       |      pIPAddrTable = NULL;
  367|       |    }
  368|       |  }
  369|       |
  370|       |  for (i = 0; i < bcst_cnt; i++) {
  371|       |    if (ipv4.s_addr == b_ipv4[i].s_addr)
  372|       |      return 1;
  373|       |  }
  374|       |#endif /* _WIN32 */
  375|       |
  376|    344|#endif /* COAP_IPV4_SUPPORT */
  377|    344|  return 0;
  378|    344|}
coap_address_init:
  383|    105|coap_address_init(coap_address_t *addr) {
  384|    105|  assert(addr);
  ------------------
  |  Branch (384:3): [True: 105, False: 0]
  ------------------
  385|    105|  memset(addr, 0, sizeof(coap_address_t));
  386|    105|#if !defined(WITH_LWIP) && !defined(WITH_CONTIKI) && !defined(RIOT_VERSION)
  387|       |  /* lwip and Contiki have constant address sizes and don't need the .size part */
  388|    105|  addr->size = sizeof(addr->addr);
  389|    105|#endif
  390|    105|}
coap_address_copy:
 1134|    319|coap_address_copy(coap_address_t *dst, const coap_address_t *src) {
 1135|       |#if defined(WITH_LWIP) || defined(WITH_CONTIKI)
 1136|       |  memcpy(dst, src, sizeof(coap_address_t));
 1137|       |#else
 1138|    319|  memset(dst, 0, sizeof(coap_address_t));
 1139|    319|  dst->size = src->size;
 1140|    319|#if COAP_IPV6_SUPPORT
 1141|    319|  if (src->addr.sa.sa_family == AF_INET6) {
  ------------------
  |  Branch (1141:7): [True: 0, False: 319]
  ------------------
 1142|      0|    dst->addr.sin6.sin6_family = src->addr.sin6.sin6_family;
 1143|      0|    dst->addr.sin6.sin6_addr = src->addr.sin6.sin6_addr;
 1144|      0|    dst->addr.sin6.sin6_port = src->addr.sin6.sin6_port;
 1145|      0|    dst->addr.sin6.sin6_scope_id = src->addr.sin6.sin6_scope_id;
 1146|      0|  }
 1147|    319|#endif /* COAP_IPV6_SUPPORT */
 1148|    319|#if COAP_IPV4_SUPPORT && COAP_IPV6_SUPPORT
 1149|    319|  else
 1150|    319|#endif /* COAP_IPV4_SUPPORT && COAP_IPV6_SUPPORT */
 1151|    319|#if COAP_IPV4_SUPPORT
 1152|    319|    if (src->addr.sa.sa_family == AF_INET) {
  ------------------
  |  Branch (1152:9): [True: 319, False: 0]
  ------------------
 1153|    319|      dst->addr.sin = src->addr.sin;
 1154|    319|    }
 1155|      0|#endif /* COAP_IPV4_SUPPORT */
 1156|      0|    else {
 1157|      0|      memcpy(&dst->addr, &src->addr, src->size);
 1158|      0|    }
 1159|    319|#endif
 1160|    319|}

coap_find_async_lkd:
  193|    100|coap_find_async_lkd(coap_session_t *session, coap_bin_const_t token) {
  194|    100|  coap_async_t *tmp;
  195|       |
  196|    100|  coap_lock_check_locked();
  ------------------
  |  |  638|    100|#define coap_lock_check_locked() {}
  ------------------
  197|    100|  SEARCH_PAIR(session->context->async_state, tmp,
  ------------------
  |  |   38|    100|  SEARCH_PAIR3(head,out,field1,val1,field2,val2,field3,val3,next)
  |  |  ------------------
  |  |  |  |   41|    100|  do {                                                                  \
  |  |  |  |   42|    100|    LL_FOREACH2(head,out,next) {                                        \
  |  |  |  |  ------------------
  |  |  |  |  |  |  422|    100|    for ((el) = (head); el; (el) = (el)->next)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (422:25): [True: 0, False: 100]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |   43|      0|      if ((out)->field1 == (val1) && (out)->field2 == (val2) &&         \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (43:11): [True: 0, False: 0]
  |  |  |  |  |  Branch (43:38): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   44|      0|          ((val2) == 0 || memcmp((out)->field3, (val3), (val2)) == 0)) break; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (44:12): [True: 0, False: 0]
  |  |  |  |  |  Branch (44:27): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   45|      0|    }                                                                   \
  |  |  |  |   46|    100|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (46:11): [Folded, False: 100]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  198|    100|              session, session,
  199|    100|              pdu->actual_token.length, token.length,
  200|    100|              pdu->actual_token.s, token.s);
  201|    100|  return tmp;
  202|    100|}
coap_delete_all_async:
  238|     35|coap_delete_all_async(coap_context_t *context) {
  239|     35|  coap_async_t *astate, *tmp;
  240|       |
  241|     35|  LL_FOREACH_SAFE(context->async_state, astate, tmp) {
  ------------------
  |  |  425|     35|    LL_FOREACH_SAFE2(head,el,tmp,next)
  |  |  ------------------
  |  |  |  |  428|     35|  for ((el) = (head); (el) && ((tmp) = (el)->next, 1); (el) = (tmp))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (428:23): [True: 0, False: 35]
  |  |  |  |  |  Branch (428:31): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  242|      0|    coap_free_async_sub(context, astate);
  243|      0|  }
  244|       |  context->async_state = NULL;
  245|     35|}

coap_opt_block_num:
   52|      4|coap_opt_block_num(const coap_opt_t *block_opt) {
   53|      4|  unsigned int num = 0;
   54|      4|  uint16_t len;
   55|       |
   56|      4|  len = coap_opt_length(block_opt);
   57|       |
   58|      4|  if (len == 0) {
  ------------------
  |  Branch (58:7): [True: 0, False: 4]
  ------------------
   59|      0|    return 0;
   60|      0|  }
   61|       |
   62|      4|  if (len > 1) {
  ------------------
  |  Branch (62:7): [True: 4, False: 0]
  ------------------
   63|      4|    num = coap_decode_var_bytes(coap_opt_value(block_opt),
   64|      4|                                coap_opt_length(block_opt) - 1);
   65|      4|  }
   66|       |
   67|      4|  return (num << 4) | ((COAP_OPT_BLOCK_END_BYTE(block_opt) & 0xF0) >> 4);
  ------------------
  |  |   87|      4|  ((coap_opt_length(opt) && coap_opt_value(opt)) ? \
  |  |  ------------------
  |  |  |  Branch (87:5): [True: 4, False: 0]
  |  |  |  Branch (87:29): [True: 4, False: 0]
  |  |  ------------------
  |  |   88|      4|   *(coap_opt_value(opt) + (coap_opt_length(opt)-1)) : 0)
  ------------------
   68|      4|}
coap_get_block_b:
   72|    447|                 coap_option_num_t number, coap_block_b_t *block) {
   73|    447|  coap_opt_iterator_t opt_iter;
   74|    447|  coap_opt_t *option;
   75|       |
   76|    447|  assert(block);
  ------------------
  |  Branch (76:3): [True: 447, False: 0]
  ------------------
   77|    447|  memset(block, 0, sizeof(coap_block_b_t));
   78|       |
   79|    447|  if (pdu && (option = coap_check_option(pdu, number, &opt_iter)) != NULL) {
  ------------------
  |  Branch (79:7): [True: 447, False: 0]
  |  Branch (79:14): [True: 4, False: 443]
  ------------------
   80|      4|    uint32_t num;
   81|       |
   82|      4|    if (COAP_OPT_BLOCK_MORE(option))
  ------------------
  |  |   92|      4|  (coap_opt_length(opt) ? (COAP_OPT_BLOCK_END_BYTE(opt) & 0x08) : 0)
  |  |  ------------------
  |  |  |  |   87|      4|  ((coap_opt_length(opt) && coap_opt_value(opt)) ? \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (87:5): [True: 4, False: 0]
  |  |  |  |  |  Branch (87:29): [True: 4, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   88|      4|   *(coap_opt_value(opt) + (coap_opt_length(opt)-1)) : 0)
  |  |  ------------------
  |  |  |  Branch (92:3): [True: 1, False: 3]
  |  |  |  Branch (92:4): [True: 4, False: 0]
  |  |  ------------------
  ------------------
   83|      1|      block->m = 1;
   84|      4|    block->aszx = block->szx = COAP_OPT_BLOCK_SZX(option);
  ------------------
  |  |   96|      4|  (coap_opt_length(opt) ? (COAP_OPT_BLOCK_END_BYTE(opt) & 0x07) : 0)
  |  |  ------------------
  |  |  |  |   87|      4|  ((coap_opt_length(opt) && coap_opt_value(opt)) ? \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (87:5): [True: 4, False: 0]
  |  |  |  |  |  Branch (87:29): [True: 4, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   88|      4|   *(coap_opt_value(opt) + (coap_opt_length(opt)-1)) : 0)
  |  |  ------------------
  |  |  |  Branch (96:4): [True: 4, False: 0]
  |  |  ------------------
  ------------------
   85|      4|    if (block->szx == 7) {
  ------------------
  |  Branch (85:9): [True: 0, False: 4]
  ------------------
   86|      0|      size_t length;
   87|      0|      const uint8_t *data;
   88|       |
   89|      0|      if (session == NULL || COAP_PROTO_NOT_RELIABLE(session->proto) ||
  ------------------
  |  |   41|      0|#define COAP_PROTO_NOT_RELIABLE(p) ((p)==COAP_PROTO_UDP || (p)==COAP_PROTO_DTLS)
  |  |  ------------------
  |  |  |  Branch (41:37): [True: 0, False: 0]
  |  |  |  Branch (41:60): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (89:11): [True: 0, False: 0]
  ------------------
   90|      0|          !(session->csm_bert_rem_support && session->csm_bert_loc_support))
  ------------------
  |  Branch (90:13): [True: 0, False: 0]
  |  Branch (90:46): [True: 0, False: 0]
  ------------------
   91|       |        /* No BERT support */
   92|      0|        return 0;
   93|       |
   94|      0|      block->szx = 6; /* BERT is 1024 block chunks */
   95|      0|      block->bert = 1;
   96|      0|      if (coap_get_data(pdu, &length, &data)) {
  ------------------
  |  Branch (96:11): [True: 0, False: 0]
  ------------------
   97|      0|        if (block->m && (length % 1024) != 0) {
  ------------------
  |  Branch (97:13): [True: 0, False: 0]
  |  Branch (97:25): [True: 0, False: 0]
  ------------------
   98|      0|          coap_log_debug("block: Oversized packet - reduced to %" PRIuS " from %" PRIuS "\n",
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   99|      0|                         length - (length % 1024), length);
  100|      0|          length -= length % 1024;
  101|      0|        }
  102|      0|        block->chunk_size = (uint32_t)length;
  103|      0|      } else
  104|      0|        block->chunk_size = 0;
  105|      4|    } else {
  106|      4|      block->chunk_size = (size_t)1 << (block->szx + 4);
  107|      4|    }
  108|      4|    block->defined = 1;
  109|       |
  110|       |    /* The block number is at most 20 bits, so values above 2^20 - 1
  111|       |     * are illegal. */
  112|      4|    num = coap_opt_block_num(option);
  113|      4|    if (num > 0xFFFFF) {
  ------------------
  |  Branch (113:9): [True: 0, False: 4]
  ------------------
  114|      0|      return 0;
  115|      0|    }
  116|      4|    block->num = num;
  117|      4|    return 1;
  118|      4|  }
  119|       |
  120|    443|  return 0;
  121|    447|}
coap_find_lg_xmit_response:
  774|    186|                           const coap_string_t *query) {
  775|    186|  coap_lg_xmit_t *lg_xmit;
  776|    186|  coap_opt_iterator_t opt_iter;
  777|    186|  coap_opt_t *rtag_opt = coap_check_option(request,
  778|    186|                                           COAP_OPTION_RTAG,
  779|    186|                                           &opt_iter);
  780|    186|  size_t rtag_length = rtag_opt ? coap_opt_length(rtag_opt) : 0;
  ------------------
  |  Branch (780:24): [True: 0, False: 186]
  ------------------
  781|    186|  const uint8_t *rtag = rtag_opt ? coap_opt_value(rtag_opt) : NULL;
  ------------------
  |  Branch (781:25): [True: 0, False: 186]
  ------------------
  782|       |
  783|    186|  LL_FOREACH(session->lg_xmit, lg_xmit) {
  ------------------
  |  |  419|    186|    LL_FOREACH2(head,el,next)
  |  |  ------------------
  |  |  |  |  422|    186|    for ((el) = (head); el; (el) = (el)->next)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (422:25): [True: 0, False: 186]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  784|      0|    static coap_string_t empty = { 0, NULL};
  785|       |
  786|      0|    if (COAP_PDU_IS_REQUEST(lg_xmit->sent_pdu) ||
  ------------------
  |  |   99|      0|#define COAP_PDU_IS_REQUEST(pdu)   (!COAP_PDU_IS_EMPTY(pdu) && (pdu)->code < 32)
  |  |  ------------------
  |  |  |  |   98|      0|#define COAP_PDU_IS_EMPTY(pdu)     ((pdu)->code == 0)
  |  |  ------------------
  |  |  |  Branch (99:37): [True: 0, False: 0]
  |  |  |  Branch (99:64): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  787|      0|        resource != lg_xmit->b.b2.resource ||
  ------------------
  |  Branch (787:9): [True: 0, False: 0]
  ------------------
  788|      0|        request->code != lg_xmit->b.b2.request_method ||
  ------------------
  |  Branch (788:9): [True: 0, False: 0]
  ------------------
  789|      0|        !coap_string_equal(query ? query : &empty,
  ------------------
  |  |  209|      0|  ((string1)->length == (string2)->length && ((string1)->length == 0 || \
  |  |  ------------------
  |  |  |  Branch (209:4): [True: 0, False: 0]
  |  |  |  Branch (209:5): [True: 0, False: 0]
  |  |  |  Branch (209:26): [True: 0, False: 0]
  |  |  |  Branch (209:47): [True: 0, False: 0]
  |  |  |  Branch (209:48): [True: 0, False: 0]
  |  |  ------------------
  |  |  210|      0|                                              ((string1)->s && (string2)->s && \
  |  |  ------------------
  |  |  |  Branch (210:48): [True: 0, False: 0]
  |  |  |  Branch (210:49): [True: 0, False: 0]
  |  |  |  Branch (210:64): [True: 0, False: 0]
  |  |  |  Branch (210:65): [True: 0, False: 0]
  |  |  ------------------
  |  |  211|      0|                                               memcmp((string1)->s, (string2)->s, (string1)->length) == 0)))
  |  |  ------------------
  |  |  |  Branch (211:48): [True: 0, False: 0]
  |  |  |  Branch (211:56): [True: 0, False: 0]
  |  |  |  Branch (211:70): [True: 0, False: 0]
  |  |  |  Branch (211:84): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  790|      0|                           lg_xmit->b.b2.query ?
  791|      0|                           lg_xmit->b.b2.query : &empty)) {
  792|       |      /* try out the next one */
  793|      0|      continue;
  794|      0|    }
  795|       |    /* lg_xmit is a response */
  796|      0|    if (rtag_opt || lg_xmit->b.b2.rtag_set == 1) {
  ------------------
  |  Branch (796:9): [True: 0, False: 0]
  |  Branch (796:21): [True: 0, False: 0]
  ------------------
  797|      0|      if (!(rtag_opt && lg_xmit->b.b2.rtag_set == 1))
  ------------------
  |  Branch (797:13): [True: 0, False: 0]
  |  Branch (797:25): [True: 0, False: 0]
  ------------------
  798|      0|        continue;
  799|      0|      if (lg_xmit->b.b2.rtag_length != rtag_length ||
  ------------------
  |  Branch (799:11): [True: 0, False: 0]
  ------------------
  800|      0|          memcmp(lg_xmit->b.b2.rtag, rtag, rtag_length) != 0)
  ------------------
  |  Branch (800:11): [True: 0, False: 0]
  ------------------
  801|      0|        continue;
  802|      0|    }
  803|      0|    return lg_xmit;
  804|      0|  }
  805|    186|  return NULL;
  806|    186|}
coap_check_code_lg_xmit:
 5400|    186|                        const coap_string_t *query) {
 5401|    186|  coap_lg_xmit_t *lg_xmit;
 5402|       |
 5403|    186|  if (response->code == 0)
  ------------------
  |  Branch (5403:7): [True: 0, False: 186]
  ------------------
 5404|      0|    return;
 5405|    186|  lg_xmit = coap_find_lg_xmit_response(session, request, resource, query);
 5406|    186|  if (lg_xmit && lg_xmit->sent_pdu && lg_xmit->sent_pdu->code == 0) {
  ------------------
  |  Branch (5406:7): [True: 0, False: 186]
  |  Branch (5406:18): [True: 0, False: 0]
  |  Branch (5406:39): [True: 0, False: 0]
  ------------------
 5407|      0|    lg_xmit->sent_pdu->code = response->code;
 5408|      0|    return;
 5409|      0|  }
 5410|    186|}

coap_cache_derive_key_w_ignore:
   89|    142|                               size_t cache_ignore_count) {
   90|    142|  coap_opt_t *option;
   91|    142|  coap_opt_iterator_t opt_iter;
   92|    142|  coap_digest_ctx_t *dctx;
   93|    142|  coap_digest_t digest;
   94|    142|  coap_cache_key_t *cache_key;
   95|       |
   96|    142|  if (!coap_option_iterator_init(pdu, &opt_iter, COAP_OPT_ALL)) {
  ------------------
  |  |  230|    142|#define COAP_OPT_ALL NULL
  ------------------
  |  Branch (96:7): [True: 0, False: 142]
  ------------------
   97|      0|    return NULL;
   98|      0|  }
   99|       |
  100|    142|  dctx = coap_digest_setup();
  101|    142|  if (!dctx)
  ------------------
  |  Branch (101:7): [True: 0, False: 142]
  ------------------
  102|      0|    return NULL;
  103|       |
  104|    142|  if (session_based == COAP_CACHE_IS_SESSION_BASED ||
  ------------------
  |  Branch (104:7): [True: 142, False: 0]
  ------------------
  105|    142|      session_based == COAP_CACHE_IS_SESSION_BASED_NO_DATA) {
  ------------------
  |  Branch (105:7): [True: 0, False: 0]
  ------------------
  106|       |    /* Include the session ptr */
  107|    142|    if (!coap_digest_update(dctx, (const uint8_t *)&session, sizeof(session))) {
  ------------------
  |  Branch (107:9): [True: 0, False: 142]
  ------------------
  108|      0|      goto update_fail;
  109|      0|    }
  110|    142|  }
  111|    426|  while ((option = coap_option_next(&opt_iter))) {
  ------------------
  |  Branch (111:10): [True: 284, False: 142]
  ------------------
  112|    284|    if (is_cache_key(opt_iter.number, cache_ignore_count,
  ------------------
  |  Branch (112:9): [True: 142, False: 142]
  ------------------
  113|    284|                     cache_ignore_options)) {
  114|    142|      uint32_t olen = coap_opt_length(option);
  115|       |
  116|    142|      if (!coap_digest_update(dctx, (const uint8_t *)&opt_iter.number,
  ------------------
  |  Branch (116:11): [True: 0, False: 142]
  ------------------
  117|    142|                              sizeof(opt_iter.number))) {
  118|      0|        goto update_fail;
  119|      0|      }
  120|       |      /* Length-delimit the value so distinct option sequences cannot hash to
  121|       |         the same key (the value is not self-terminating). */
  122|    142|      if (!coap_digest_update(dctx, (const uint8_t *)&olen, sizeof(olen))) {
  ------------------
  |  Branch (122:11): [True: 0, False: 142]
  ------------------
  123|      0|        goto update_fail;
  124|      0|      }
  125|    142|      if (!coap_digest_update(dctx, coap_opt_value(option), olen)) {
  ------------------
  |  Branch (125:11): [True: 0, False: 142]
  ------------------
  126|      0|        goto update_fail;
  127|      0|      }
  128|    142|    }
  129|    284|  }
  130|       |
  131|       |  /* The body of a FETCH payload is part of the cache key,
  132|       |   * see https://rfc-editor.org/rfc/rfc8132#section-2 */
  133|    142|  if (pdu->code == COAP_REQUEST_CODE_FETCH &&
  ------------------
  |  Branch (133:7): [True: 0, False: 142]
  ------------------
  134|      0|      session_based != COAP_CACHE_IS_SESSION_BASED_NO_DATA) {
  ------------------
  |  Branch (134:7): [True: 0, False: 0]
  ------------------
  135|      0|    size_t len;
  136|      0|    const uint8_t *data;
  137|      0|    if (coap_get_data(pdu, &len, &data)) {
  ------------------
  |  Branch (137:9): [True: 0, False: 0]
  ------------------
  138|      0|      if (!coap_digest_update(dctx, data, len)) {
  ------------------
  |  Branch (138:11): [True: 0, False: 0]
  ------------------
  139|      0|        goto update_fail;
  140|      0|      }
  141|      0|    }
  142|      0|  }
  143|       |
  144|    142|  if (!coap_digest_final(dctx, &digest)) {
  ------------------
  |  Branch (144:7): [True: 0, False: 142]
  ------------------
  145|       |    /* coap_digest_final() is guaranteed to free off dctx no matter what */
  146|      0|    return NULL;
  147|      0|  }
  148|    142|  cache_key = coap_malloc_type(COAP_CACHE_KEY, sizeof(coap_cache_key_t));
  149|    142|  if (cache_key) {
  ------------------
  |  Branch (149:7): [True: 142, False: 0]
  ------------------
  150|    142|    memcpy(cache_key->key, digest.key, sizeof(cache_key->key));
  151|    142|  }
  152|    142|  return cache_key;
  153|      0|update_fail:
  154|      0|  coap_digest_free(dctx);
  155|       |  return NULL;
  156|    142|}
coap_delete_cache_key:
  168|    142|coap_delete_cache_key(coap_cache_key_t *cache_key) {
  169|    142|  coap_free_type(COAP_CACHE_KEY, cache_key);
  170|    142|}
coap_cache.c:is_cache_key:
   24|    284|             const uint16_t *cache_ignore_options) {
   25|    284|  size_t i;
   26|       |
   27|       |  /* https://rfc-editor.org/rfc/rfc7252#section-5.4.6 Nocachekey definition */
   28|    284|  if ((option_type & 0x1e) == 0x1c)
  ------------------
  |  Branch (28:7): [True: 0, False: 284]
  ------------------
   29|      0|    return 0;
   30|       |  /*
   31|       |   * https://rfc-editor.org/rfc/rfc7641#section-2 Observe is not a
   32|       |   * part of the cache-key.
   33|       |   */
   34|    284|  if (option_type == COAP_OPTION_OBSERVE)
  ------------------
  |  Branch (34:7): [True: 142, False: 142]
  ------------------
   35|    142|    return 0;
   36|       |
   37|       |  /* Check for option user has defined as not part of cache-key */
   38|    426|  for (i = 0; i < cache_ignore_count; i++) {
  ------------------
  |  Branch (38:15): [True: 284, False: 142]
  ------------------
   39|    284|    if (cache_ignore_options[i] == option_type) {
  ------------------
  |  Branch (39:9): [True: 0, False: 284]
  ------------------
   40|      0|      return 0;
   41|      0|    }
   42|    284|  }
   43|       |
   44|    142|  return 1;
   45|    142|}

coap_get_log_level:
  103|  2.09k|coap_get_log_level(void) {
  104|  2.09k|  return maxlog;
  105|  2.09k|}
coap_set_log_level:
  108|     35|coap_set_log_level(coap_log_t level) {
  109|     35|  if (level > COAP_MAX_LOGGING_LEVEL)
  ------------------
  |  |   48|     35|#define COAP_MAX_LOGGING_LEVEL 8
  ------------------
  |  Branch (109:7): [True: 0, False: 35]
  ------------------
  110|      0|    level = COAP_MAX_LOGGING_LEVEL;
  ------------------
  |  |   48|      0|#define COAP_MAX_LOGGING_LEVEL 8
  ------------------
  111|     35|  maxlog = level;
  112|     35|}
coap_show_pdu:
  845|    426|coap_show_pdu(coap_log_t level, const coap_pdu_t *pdu) {
  846|       |#if COAP_CONSTRAINED_STACK
  847|       |  /* Proxy-Uri: can be 1034 bytes long */
  848|       |  /* buf and outbuf can be protected by m_show_pdu if needed */
  849|       |  static unsigned char buf[USE_BUF_SIZE];
  850|       |  static char outbuf[COAP_DEBUG_BUF_SIZE];
  851|       |#else /* ! COAP_CONSTRAINED_STACK */
  852|       |  /* Proxy-Uri: can be 1034 bytes long */
  853|    426|  unsigned char buf[USE_BUF_SIZE];
  854|    426|  char outbuf[COAP_DEBUG_BUF_SIZE];
  855|    426|#endif /* ! COAP_CONSTRAINED_STACK */
  856|    426|  size_t buf_len = 0; /* takes the number of bytes written to buf */
  857|    426|  int have_options = 0;
  858|    426|  uint32_t i;
  859|    426|  coap_opt_iterator_t opt_iter;
  860|    426|  coap_opt_t *option;
  861|    426|  int content_format = -1;
  862|    426|  size_t data_len;
  863|    426|  const uint8_t *data;
  864|    426|  uint32_t opt_len;
  865|    426|  const uint8_t *opt_val;
  866|    426|  size_t outbuflen = 0;
  867|    426|  int is_oscore_payload = 0;
  868|    426|  const char *exp;
  869|    426|  uint32_t value;
  870|       |
  871|       |  /* Save time if not needed */
  872|    426|  if (level > coap_get_log_level())
  ------------------
  |  Branch (872:7): [True: 426, False: 0]
  ------------------
  873|    426|    return;
  874|       |
  875|       |#if COAP_THREAD_SAFE
  876|       |  coap_mutex_lock(&m_show_pdu);
  877|       |#endif /* COAP_THREAD_SAFE */
  878|      0|  if (!pdu->session || COAP_PROTO_NOT_RELIABLE(pdu->session->proto)) {
  ------------------
  |  |   41|      0|#define COAP_PROTO_NOT_RELIABLE(p) ((p)==COAP_PROTO_UDP || (p)==COAP_PROTO_DTLS)
  |  |  ------------------
  |  |  |  Branch (41:37): [True: 0, False: 0]
  |  |  |  Branch (41:60): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (878:7): [True: 0, False: 0]
  ------------------
  879|      0|    snprintf(outbuf, sizeof(outbuf), "v:%d t:%s c:%s i:%04x {",
  880|      0|             COAP_DEFAULT_VERSION, msg_type_string(pdu->type),
  ------------------
  |  |   35|      0|#define COAP_DEFAULT_VERSION      1 /* version of CoAP supported */
  ------------------
  881|      0|             msg_code_string(pdu->code), pdu->mid);
  882|      0|  } else if (pdu->session->proto == COAP_PROTO_WS ||
  ------------------
  |  Branch (882:14): [True: 0, False: 0]
  ------------------
  883|      0|             pdu->session->proto == COAP_PROTO_WSS) {
  ------------------
  |  Branch (883:14): [True: 0, False: 0]
  ------------------
  884|      0|    if (pdu->type != COAP_MESSAGE_CON)
  ------------------
  |  Branch (884:9): [True: 0, False: 0]
  ------------------
  885|      0|      coap_log_alert("WebSocket: type != CON\n");
  ------------------
  |  |   90|      0|#define coap_log_alert(...) coap_log(COAP_LOG_ALERT, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  886|      0|    snprintf(outbuf, sizeof(outbuf), "v:WebSocket c:%s {",
  887|      0|             msg_code_string(pdu->code));
  888|      0|  } else {
  889|      0|    if (pdu->type != COAP_MESSAGE_CON)
  ------------------
  |  Branch (889:9): [True: 0, False: 0]
  ------------------
  890|      0|      coap_log_alert("Reliable: type != CON\n");
  ------------------
  |  |   90|      0|#define coap_log_alert(...) coap_log(COAP_LOG_ALERT, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  891|      0|    snprintf(outbuf, sizeof(outbuf), "v:Reliable c:%s {",
  892|      0|             msg_code_string(pdu->code));
  893|      0|  }
  894|       |
  895|      0|  outbuflen = strlen(outbuf);
  896|      0|  for (i = 0; i < pdu->actual_token.length; i++) {
  ------------------
  |  Branch (896:15): [True: 0, False: 0]
  ------------------
  897|      0|    coap_snprintf(outbuf, sizeof(outbuf), &outbuflen,
  898|      0|                  "%02x", pdu->actual_token.s[i]);
  899|      0|  }
  900|      0|  coap_snprintf(outbuf, sizeof(outbuf), &outbuflen, "}");
  901|       |
  902|       |  /* show options, if any */
  903|      0|  coap_option_iterator_init(pdu, &opt_iter, COAP_OPT_ALL);
  ------------------
  |  |  230|      0|#define COAP_OPT_ALL NULL
  ------------------
  904|       |
  905|      0|  coap_snprintf(outbuf, sizeof(outbuf), &outbuflen, " [");
  906|      0|  while ((option = coap_option_next(&opt_iter))) {
  ------------------
  |  Branch (906:10): [True: 0, False: 0]
  ------------------
  907|      0|    buf[0] = '\000';
  908|      0|    buf_len = 0;
  909|      0|    if (!have_options) {
  ------------------
  |  Branch (909:9): [True: 0, False: 0]
  ------------------
  910|      0|      have_options = 1;
  911|      0|    } else {
  912|      0|      coap_snprintf(outbuf, sizeof(outbuf), &outbuflen, ",");
  913|      0|    }
  914|       |
  915|      0|    if (pdu->code == COAP_SIGNALING_CODE_CSM) {
  ------------------
  |  Branch (915:9): [True: 0, False: 0]
  ------------------
  916|      0|      switch ((coap_sig_csm_opt_t)opt_iter.number) {
  917|      0|      case COAP_SIG_OPT_EXTENDED_TOKEN_LENGTH:
  ------------------
  |  Branch (917:7): [True: 0, False: 0]
  ------------------
  918|      0|      case COAP_SIG_OPT_MAX_MESSAGE_SIZE:
  ------------------
  |  Branch (918:7): [True: 0, False: 0]
  ------------------
  919|      0|        coap_snprintf((char *)buf, sizeof(buf), &buf_len, "%u",
  920|      0|                      coap_decode_var_bytes(coap_opt_value(option),
  921|      0|                                            coap_opt_length(option)));
  922|      0|        break;
  923|      0|      case COAP_SIG_OPT_BLOCK_WISE_TRANSFER:
  ------------------
  |  Branch (923:7): [True: 0, False: 0]
  ------------------
  924|      0|      default:
  ------------------
  |  Branch (924:7): [True: 0, False: 0]
  ------------------
  925|      0|        break;
  926|      0|      }
  927|      0|    } else if (pdu->code == COAP_SIGNALING_CODE_PING ||
  ------------------
  |  Branch (927:16): [True: 0, False: 0]
  ------------------
  928|      0|               pdu->code == COAP_SIGNALING_CODE_PONG) {
  ------------------
  |  Branch (928:16): [True: 0, False: 0]
  ------------------
  929|      0|      switch ((coap_sig_ping_opt_t)opt_iter.number) {
  930|      0|      case COAP_SIG_OPT_CUSTODY:
  ------------------
  |  Branch (930:7): [True: 0, False: 0]
  ------------------
  931|      0|      default:
  ------------------
  |  Branch (931:7): [True: 0, False: 0]
  ------------------
  932|      0|        break;
  933|      0|      }
  934|      0|    } else if (pdu->code == COAP_SIGNALING_CODE_RELEASE) {
  ------------------
  |  Branch (934:16): [True: 0, False: 0]
  ------------------
  935|      0|      switch ((coap_sig_release_opt_t)opt_iter.number) {
  936|      0|      case COAP_SIG_OPT_ALTERNATIVE_ADDRESS:
  ------------------
  |  Branch (936:7): [True: 0, False: 0]
  ------------------
  937|      0|        buf_len = print_readable(coap_opt_value(option),
  938|      0|                                 coap_opt_length(option),
  939|      0|                                 buf, sizeof(buf), 0);
  940|      0|        break;
  941|      0|      case COAP_SIG_OPT_HOLD_OFF:
  ------------------
  |  Branch (941:7): [True: 0, False: 0]
  ------------------
  942|      0|        coap_snprintf((char *)buf, sizeof(buf), &buf_len, "%u",
  943|      0|                      coap_decode_var_bytes(coap_opt_value(option),
  944|      0|                                            coap_opt_length(option)));
  945|      0|        break;
  946|      0|      default:
  ------------------
  |  Branch (946:7): [True: 0, False: 0]
  ------------------
  947|      0|        break;
  948|      0|      }
  949|      0|    } else if (pdu->code == COAP_SIGNALING_CODE_ABORT) {
  ------------------
  |  Branch (949:16): [True: 0, False: 0]
  ------------------
  950|      0|      switch ((coap_sig_abort_opt_t)opt_iter.number) {
  951|      0|      case COAP_SIG_OPT_BAD_CSM_OPTION:
  ------------------
  |  Branch (951:7): [True: 0, False: 0]
  ------------------
  952|      0|        coap_snprintf((char *)buf, sizeof(buf), &buf_len, "%u",
  953|      0|                      coap_decode_var_bytes(coap_opt_value(option),
  954|      0|                                            coap_opt_length(option)));
  955|      0|        break;
  956|      0|      default:
  ------------------
  |  Branch (956:7): [True: 0, False: 0]
  ------------------
  957|      0|        break;
  958|      0|      }
  959|      0|    } else {
  960|      0|      switch ((coap_code_opt_num_t)opt_iter.number) {
  961|      0|      case COAP_OPTION_CONTENT_FORMAT:
  ------------------
  |  Branch (961:7): [True: 0, False: 0]
  ------------------
  962|      0|      case COAP_OPTION_ACCEPT:
  ------------------
  |  Branch (962:7): [True: 0, False: 0]
  ------------------
  963|      0|        content_format = (int)coap_decode_var_bytes(coap_opt_value(option),
  964|      0|                                                    coap_opt_length(option));
  965|       |
  966|      0|        buf_len = print_content_format(content_format, buf, sizeof(buf));
  967|      0|        break;
  968|       |
  969|      0|      case COAP_OPTION_BLOCK1:
  ------------------
  |  Branch (969:7): [True: 0, False: 0]
  ------------------
  970|      0|      case COAP_OPTION_BLOCK2:
  ------------------
  |  Branch (970:7): [True: 0, False: 0]
  ------------------
  971|      0|      case COAP_OPTION_Q_BLOCK1:
  ------------------
  |  Branch (971:7): [True: 0, False: 0]
  ------------------
  972|      0|      case COAP_OPTION_Q_BLOCK2:
  ------------------
  |  Branch (972:7): [True: 0, False: 0]
  ------------------
  973|       |        /* split block option into number/more/size where more is the
  974|       |         * letter M if set, the _ otherwise */
  975|      0|        if (COAP_OPT_BLOCK_SZX(option) == 7) {
  ------------------
  |  |   96|      0|  (coap_opt_length(opt) ? (COAP_OPT_BLOCK_END_BYTE(opt) & 0x07) : 0)
  |  |  ------------------
  |  |  |  |   87|      0|  ((coap_opt_length(opt) && coap_opt_value(opt)) ? \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (87:5): [True: 0, False: 0]
  |  |  |  |  |  Branch (87:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   88|      0|   *(coap_opt_value(opt) + (coap_opt_length(opt)-1)) : 0)
  |  |  ------------------
  |  |  |  Branch (96:4): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (975:13): [True: 0, False: 0]
  ------------------
  976|      0|          if (coap_get_data(pdu, &data_len, &data))
  ------------------
  |  Branch (976:15): [True: 0, False: 0]
  ------------------
  977|      0|            coap_snprintf((char *)buf, sizeof(buf), &buf_len, "%u/%c/BERT(%" PRIuS ")",
  978|      0|                          coap_opt_block_num(option), /* block number */
  979|      0|                          COAP_OPT_BLOCK_MORE(option) ? 'M' : '_', /* M bit */
  ------------------
  |  |   92|      0|  (coap_opt_length(opt) ? (COAP_OPT_BLOCK_END_BYTE(opt) & 0x08) : 0)
  |  |  ------------------
  |  |  |  |   87|      0|  ((coap_opt_length(opt) && coap_opt_value(opt)) ? \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (87:5): [True: 0, False: 0]
  |  |  |  |  |  Branch (87:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   88|      0|   *(coap_opt_value(opt) + (coap_opt_length(opt)-1)) : 0)
  |  |  ------------------
  |  |  |  Branch (92:3): [True: 0, False: 0]
  |  |  |  Branch (92:4): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  980|      0|                          data_len);
  981|      0|          else
  982|      0|            coap_snprintf((char *)buf, sizeof(buf), &buf_len, "%u/%c/BERT",
  983|      0|                          coap_opt_block_num(option), /* block number */
  984|      0|                          COAP_OPT_BLOCK_MORE(option) ? 'M' : '_'); /* M bit */
  ------------------
  |  |   92|      0|  (coap_opt_length(opt) ? (COAP_OPT_BLOCK_END_BYTE(opt) & 0x08) : 0)
  |  |  ------------------
  |  |  |  |   87|      0|  ((coap_opt_length(opt) && coap_opt_value(opt)) ? \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (87:5): [True: 0, False: 0]
  |  |  |  |  |  Branch (87:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   88|      0|   *(coap_opt_value(opt) + (coap_opt_length(opt)-1)) : 0)
  |  |  ------------------
  |  |  |  Branch (92:3): [True: 0, False: 0]
  |  |  |  Branch (92:4): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  985|      0|        } else {
  986|      0|          coap_snprintf((char *)buf, sizeof(buf), &buf_len, "%u/%c/%u",
  987|      0|                        coap_opt_block_num(option), /* block number */
  988|      0|                        COAP_OPT_BLOCK_MORE(option) ? 'M' : '_', /* M bit */
  ------------------
  |  |   92|      0|  (coap_opt_length(opt) ? (COAP_OPT_BLOCK_END_BYTE(opt) & 0x08) : 0)
  |  |  ------------------
  |  |  |  |   87|      0|  ((coap_opt_length(opt) && coap_opt_value(opt)) ? \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (87:5): [True: 0, False: 0]
  |  |  |  |  |  Branch (87:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   88|      0|   *(coap_opt_value(opt) + (coap_opt_length(opt)-1)) : 0)
  |  |  ------------------
  |  |  |  Branch (92:3): [True: 0, False: 0]
  |  |  |  Branch (92:4): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  989|      0|                        (unsigned)(1u << (COAP_OPT_BLOCK_SZX(option) + 4))); /* block size */
  ------------------
  |  |   96|      0|  (coap_opt_length(opt) ? (COAP_OPT_BLOCK_END_BYTE(opt) & 0x07) : 0)
  |  |  ------------------
  |  |  |  |   87|      0|  ((coap_opt_length(opt) && coap_opt_value(opt)) ? \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (87:5): [True: 0, False: 0]
  |  |  |  |  |  Branch (87:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   88|      0|   *(coap_opt_value(opt) + (coap_opt_length(opt)-1)) : 0)
  |  |  ------------------
  |  |  |  Branch (96:4): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  990|      0|        }
  991|       |
  992|      0|        break;
  993|       |
  994|      0|      case COAP_OPTION_OSCORE:
  ------------------
  |  Branch (994:7): [True: 0, False: 0]
  ------------------
  995|      0|        opt_len = coap_opt_length(option);
  996|      0|        buf[0] = '\000';
  997|      0|        if (opt_len) {
  ------------------
  |  Branch (997:13): [True: 0, False: 0]
  ------------------
  998|      0|          size_t ofs = 1;
  999|      0|          size_t cnt;
 1000|       |
 1001|      0|          opt_val = coap_opt_value(option);
 1002|      0|          if (opt_val[0] & 0x20) {
  ------------------
  |  Branch (1002:15): [True: 0, False: 0]
  ------------------
 1003|       |            /* Group Flag */
 1004|      0|            snprintf((char *)buf, sizeof(buf), "grp");
 1005|      0|          }
 1006|      0|          if (opt_val[0] & 0x07) {
  ------------------
  |  Branch (1006:15): [True: 0, False: 0]
  ------------------
 1007|       |            /* Partial IV */
 1008|      0|            cnt = opt_val[0] & 0x07;
 1009|      0|            if (cnt > opt_len - ofs)
  ------------------
  |  Branch (1009:17): [True: 0, False: 0]
  ------------------
 1010|      0|              goto no_more;
 1011|      0|            buf_len = strlen((char *)buf);
 1012|      0|            coap_snprintf((char *)buf, sizeof(buf), &buf_len, "%spIV=0x",
 1013|      0|                          buf_len ? "," : "");
  ------------------
  |  Branch (1013:27): [True: 0, False: 0]
  ------------------
 1014|      0|            for (i = 0; (uint32_t)i < cnt; i++) {
  ------------------
  |  Branch (1014:25): [True: 0, False: 0]
  ------------------
 1015|      0|              coap_snprintf((char *)buf, sizeof(buf), &buf_len,
 1016|      0|                            "%02x", opt_val[ofs + i]);
 1017|      0|            }
 1018|      0|            ofs += cnt;
 1019|      0|          }
 1020|      0|          if (opt_val[0] & 0x10) {
  ------------------
  |  Branch (1020:15): [True: 0, False: 0]
  ------------------
 1021|       |            /* kid context */
 1022|      0|            if (ofs >= opt_len)
  ------------------
  |  Branch (1022:17): [True: 0, False: 0]
  ------------------
 1023|      0|              goto no_more;
 1024|      0|            cnt = opt_val[ofs];
 1025|      0|            if (cnt > opt_len - ofs - 1)
  ------------------
  |  Branch (1025:17): [True: 0, False: 0]
  ------------------
 1026|      0|              goto no_more;
 1027|      0|            ofs++;
 1028|      0|            buf_len = strlen((char *)buf);
 1029|      0|            coap_snprintf((char *)buf, sizeof(buf), &buf_len, "%skc=0x",
 1030|      0|                          buf_len ? "," : "");
  ------------------
  |  Branch (1030:27): [True: 0, False: 0]
  ------------------
 1031|      0|            for (i = 0; (uint32_t)i < cnt; i++) {
  ------------------
  |  Branch (1031:25): [True: 0, False: 0]
  ------------------
 1032|      0|              coap_snprintf((char *)buf, sizeof(buf), &buf_len,
 1033|      0|                            "%02x", opt_val[ofs + i]);
 1034|      0|            }
 1035|      0|            ofs += cnt;
 1036|      0|          }
 1037|      0|          if (opt_val[0] & 0x08) {
  ------------------
  |  Branch (1037:15): [True: 0, False: 0]
  ------------------
 1038|       |            /* kid */
 1039|      0|            if (ofs >= opt_len)
  ------------------
  |  Branch (1039:17): [True: 0, False: 0]
  ------------------
 1040|      0|              goto no_more;
 1041|      0|            cnt = opt_len - ofs;
 1042|      0|            buf_len = strlen((char *)buf);
 1043|      0|            coap_snprintf((char *)buf, sizeof(buf), &buf_len, "%skid=0x",
 1044|      0|                          buf_len ? "," : "");
  ------------------
  |  Branch (1044:27): [True: 0, False: 0]
  ------------------
 1045|      0|            for (i = 0; (uint32_t)i < cnt; i++) {
  ------------------
  |  Branch (1045:25): [True: 0, False: 0]
  ------------------
 1046|      0|              coap_snprintf((char *)buf, sizeof(buf), &buf_len,
 1047|      0|                            "%02x", opt_val[ofs + i]);
 1048|      0|            }
 1049|      0|          }
 1050|      0|        }
 1051|      0|no_more:
 1052|      0|        buf_len = strlen((char *)buf);
 1053|      0|        is_oscore_payload = 1;
 1054|      0|        break;
 1055|       |
 1056|      0|      case COAP_OPTION_URI_PORT:
  ------------------
  |  Branch (1056:7): [True: 0, False: 0]
  ------------------
 1057|      0|      case COAP_OPTION_MAXAGE:
  ------------------
  |  Branch (1057:7): [True: 0, False: 0]
  ------------------
 1058|      0|      case COAP_OPTION_OBSERVE:
  ------------------
  |  Branch (1058:7): [True: 0, False: 0]
  ------------------
 1059|      0|      case COAP_OPTION_SIZE1:
  ------------------
  |  Branch (1059:7): [True: 0, False: 0]
  ------------------
 1060|      0|      case COAP_OPTION_SIZE2:
  ------------------
  |  Branch (1060:7): [True: 0, False: 0]
  ------------------
 1061|      0|      case COAP_OPTION_HOP_LIMIT:
  ------------------
  |  Branch (1061:7): [True: 0, False: 0]
  ------------------
 1062|      0|        if (coap_opt_length(option)) {
  ------------------
  |  Branch (1062:13): [True: 0, False: 0]
  ------------------
 1063|       |          /* show values as unsigned decimal value */
 1064|      0|          coap_snprintf((char *)buf, sizeof(buf), &buf_len, "%u",
 1065|      0|                        coap_decode_var_bytes(coap_opt_value(option),
 1066|      0|                                              coap_opt_length(option)));
 1067|      0|        }
 1068|      0|        break;
 1069|       |
 1070|      0|      case COAP_OPTION_IF_MATCH:
  ------------------
  |  Branch (1070:7): [True: 0, False: 0]
  ------------------
 1071|      0|      case COAP_OPTION_ETAG:
  ------------------
  |  Branch (1071:7): [True: 0, False: 0]
  ------------------
 1072|      0|      case COAP_OPTION_ECHO:
  ------------------
  |  Branch (1072:7): [True: 0, False: 0]
  ------------------
 1073|      0|      case COAP_OPTION_NORESPONSE:
  ------------------
  |  Branch (1073:7): [True: 0, False: 0]
  ------------------
 1074|      0|      case COAP_OPTION_RTAG:
  ------------------
  |  Branch (1074:7): [True: 0, False: 0]
  ------------------
 1075|      0|        opt_len = coap_opt_length(option);
 1076|      0|        opt_val = coap_opt_value(option);
 1077|      0|        snprintf((char *)buf, sizeof(buf), "0x");
 1078|      0|        buf_len = strlen((char *)buf);
 1079|      0|        for (i = 0; (uint32_t)i < opt_len; i++) {
  ------------------
  |  Branch (1079:21): [True: 0, False: 0]
  ------------------
 1080|      0|          coap_snprintf((char *)buf, sizeof(buf), &buf_len,
 1081|      0|                        "%02x", opt_val[i]);
 1082|      0|        }
 1083|      0|        break;
 1084|      0|      case COAP_OPTION_URI_PATH_ABB:
  ------------------
  |  Branch (1084:7): [True: 0, False: 0]
  ------------------
 1085|      0|        value = coap_decode_var_bytes(coap_opt_value(option),
 1086|      0|                                      coap_opt_length(option));
 1087|      0|        exp = coap_map_abbrev_uri_path(coap_upa_server_mapping_chain, value);
 1088|      0|        if (!exp) {
  ------------------
  |  Branch (1088:13): [True: 0, False: 0]
  ------------------
 1089|      0|          exp = coap_map_abbrev_uri_path(coap_upa_client_fallback_chain, value);
 1090|      0|        }
 1091|      0|        if (exp) {
  ------------------
  |  Branch (1091:13): [True: 0, False: 0]
  ------------------
 1092|      0|          snprintf((char *)&buf, sizeof(buf), "%s", exp);
 1093|      0|        } else {
 1094|      0|          snprintf((char *)&buf, sizeof(buf), "(%" PRIu32 ")", value);
 1095|      0|        }
 1096|      0|        buf_len = strlen((char *)buf);
 1097|      0|        break;
 1098|      0|      case COAP_OPTION_URI_PATH:
  ------------------
  |  Branch (1098:7): [True: 0, False: 0]
  ------------------
 1099|      0|      case COAP_OPTION_PROXY_URI:
  ------------------
  |  Branch (1099:7): [True: 0, False: 0]
  ------------------
 1100|      0|      case COAP_OPTION_URI_HOST:
  ------------------
  |  Branch (1100:7): [True: 0, False: 0]
  ------------------
 1101|      0|      case COAP_OPTION_LOCATION_PATH:
  ------------------
  |  Branch (1101:7): [True: 0, False: 0]
  ------------------
 1102|      0|      case COAP_OPTION_LOCATION_QUERY:
  ------------------
  |  Branch (1102:7): [True: 0, False: 0]
  ------------------
 1103|      0|      case COAP_OPTION_PROXY_SCHEME:
  ------------------
  |  Branch (1103:7): [True: 0, False: 0]
  ------------------
 1104|      0|      case COAP_OPTION_URI_QUERY:
  ------------------
  |  Branch (1104:7): [True: 0, False: 0]
  ------------------
 1105|      0|        buf_len = print_readable(coap_opt_value(option),
 1106|      0|                                 coap_opt_length(option),
 1107|      0|                                 buf, sizeof(buf), 0);
 1108|      0|        break;
 1109|      0|      case COAP_OPTION_IF_NONE_MATCH:
  ------------------
  |  Branch (1109:7): [True: 0, False: 0]
  ------------------
 1110|      0|      case COAP_OPTION_EDHOC:
  ------------------
  |  Branch (1110:7): [True: 0, False: 0]
  ------------------
 1111|      0|      default:
  ------------------
  |  Branch (1111:7): [True: 0, False: 0]
  ------------------
 1112|      0|        buf_len = print_readable(coap_opt_value(option),
 1113|      0|                                 coap_opt_length(option),
 1114|      0|                                 buf, sizeof(buf), 1);
 1115|      0|      }
 1116|      0|    }
 1117|      0|    coap_snprintf(outbuf, sizeof(outbuf), &outbuflen,
 1118|      0|                  " %s:%.*s", coap_option_string(pdu->code, opt_iter.number),
 1119|      0|                  (int)buf_len, buf);
 1120|      0|  }
 1121|       |
 1122|      0|  coap_snprintf(outbuf, sizeof(outbuf), &outbuflen, " ]");
 1123|       |
 1124|      0|  if (coap_get_data(pdu, &data_len, &data)) {
  ------------------
  |  Branch (1124:7): [True: 0, False: 0]
  ------------------
 1125|      0|    if (!enable_data_for_show_pdu) {
  ------------------
  |  Branch (1125:9): [True: 0, False: 0]
  ------------------
 1126|       |      /* Only output data if wanted */
 1127|      0|      coap_snprintf(outbuf, sizeof(outbuf), &outbuflen, " :: ");
 1128|      0|      coap_snprintf(outbuf, sizeof(outbuf), &outbuflen,
 1129|      0|                    "data length %"PRIuS " (data suppressed)\n", data_len);
 1130|      0|      COAP_DO_SHOW_OUTPUT_LINE;
  ------------------
  |  |  812|      0|  do {                                      \
  |  |  813|      0|    if (use_fprintf_for_show_pdu) {         \
  |  |  ------------------
  |  |  |  Branch (813:9): [True: 0, False: 0]
  |  |  ------------------
  |  |  814|      0|      fprintf(COAP_DEBUG_FD, "%s", outbuf); \
  |  |  ------------------
  |  |  |  |   37|      0|#define COAP_DEBUG_FD stdout
  |  |  ------------------
  |  |  815|      0|    }                                       \
  |  |  816|      0|    else {                                  \
  |  |  817|      0|      coap_log(level, "%s", outbuf);        \
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  818|      0|    }                                       \
  |  |  819|      0|  } while (0)
  |  |  ------------------
  |  |  |  Branch (819:12): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1131|       |#if COAP_THREAD_SAFE
 1132|       |      coap_mutex_unlock(&m_show_pdu);
 1133|       |#endif /* COAP_THREAD_SAFE */
 1134|      0|      return;
 1135|      0|    }
 1136|       |
 1137|      0|    coap_snprintf(outbuf, sizeof(outbuf), &outbuflen, " :: ");
 1138|       |
 1139|      0|    if (is_binary(content_format) || !isprint(data[0]) || is_oscore_payload) {
  ------------------
  |  Branch (1139:9): [True: 0, False: 0]
  |  Branch (1139:38): [True: 0, False: 0]
  |  Branch (1139:59): [True: 0, False: 0]
  ------------------
 1140|      0|      size_t keep_data_len = data_len;
 1141|      0|      const uint8_t *keep_data = data;
 1142|       |
 1143|      0|      coap_snprintf(outbuf, sizeof(outbuf), &outbuflen,
 1144|      0|                    "binary data length %"PRIuS "\n", data_len);
 1145|      0|      COAP_DO_SHOW_OUTPUT_LINE;
  ------------------
  |  |  812|      0|  do {                                      \
  |  |  813|      0|    if (use_fprintf_for_show_pdu) {         \
  |  |  ------------------
  |  |  |  Branch (813:9): [True: 0, False: 0]
  |  |  ------------------
  |  |  814|      0|      fprintf(COAP_DEBUG_FD, "%s", outbuf); \
  |  |  ------------------
  |  |  |  |   37|      0|#define COAP_DEBUG_FD stdout
  |  |  ------------------
  |  |  815|      0|    }                                       \
  |  |  816|      0|    else {                                  \
  |  |  817|      0|      coap_log(level, "%s", outbuf);        \
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  818|      0|    }                                       \
  |  |  819|      0|  } while (0)
  |  |  ------------------
  |  |  |  Branch (819:12): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1146|       |      /*
 1147|       |       * Output hex dump of binary data as a continuous entry
 1148|       |       */
 1149|      0|      outbuf[0] = '\000';
 1150|      0|      snprintf(outbuf, sizeof(outbuf),  "<<");
 1151|      0|      outbuflen = strlen(outbuf);
 1152|      0|      while (data_len--) {
  ------------------
  |  Branch (1152:14): [True: 0, False: 0]
  ------------------
 1153|      0|        coap_snprintf(outbuf, sizeof(outbuf), &outbuflen, "%02x", *data++);
 1154|      0|      }
 1155|      0|      coap_snprintf(outbuf, sizeof(outbuf), &outbuflen, ">>");
 1156|      0|      data_len = keep_data_len;
 1157|      0|      data = keep_data;
 1158|      0|      if (outbuflen == sizeof(outbuf)-1)
  ------------------
  |  Branch (1158:11): [True: 0, False: 0]
  ------------------
 1159|      0|        outbuflen--;
 1160|      0|      coap_snprintf(outbuf, sizeof(outbuf), &outbuflen, "\n");
 1161|      0|      COAP_DO_SHOW_OUTPUT_LINE;
  ------------------
  |  |  812|      0|  do {                                      \
  |  |  813|      0|    if (use_fprintf_for_show_pdu) {         \
  |  |  ------------------
  |  |  |  Branch (813:9): [True: 0, False: 0]
  |  |  ------------------
  |  |  814|      0|      fprintf(COAP_DEBUG_FD, "%s", outbuf); \
  |  |  ------------------
  |  |  |  |   37|      0|#define COAP_DEBUG_FD stdout
  |  |  ------------------
  |  |  815|      0|    }                                       \
  |  |  816|      0|    else {                                  \
  |  |  817|      0|      coap_log(level, "%s", outbuf);        \
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  818|      0|    }                                       \
  |  |  819|      0|  } while (0)
  |  |  ------------------
  |  |  |  Branch (819:12): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1162|       |      /*
 1163|       |       * Output ascii readable (if possible), immediately under the
 1164|       |       * hex value of the character output above to help binary debugging
 1165|       |       */
 1166|      0|      outbuf[0] = '\000';
 1167|      0|      snprintf(outbuf, sizeof(outbuf),  "<<");
 1168|      0|      outbuflen = strlen(outbuf);
 1169|      0|      while (data_len--) {
  ------------------
  |  Branch (1169:14): [True: 0, False: 0]
  ------------------
 1170|      0|        coap_snprintf(outbuf, sizeof(outbuf), &outbuflen,
 1171|      0|                      "%c ", isprint(*data) ? *data : '.');
  ------------------
  |  Branch (1171:30): [True: 0, False: 0]
  ------------------
 1172|      0|        data++;
 1173|      0|      }
 1174|      0|      coap_snprintf(outbuf, sizeof(outbuf), &outbuflen, ">>");
 1175|      0|    } else {
 1176|      0|      size_t max_length;
 1177|       |
 1178|      0|      outbuflen = strlen(outbuf);
 1179|      0|      max_length = sizeof(outbuf)-outbuflen;
 1180|      0|      if (max_length > 1) {
  ------------------
  |  Branch (1180:11): [True: 0, False: 0]
  ------------------
 1181|      0|        outbuf[outbuflen++] = '\'';
 1182|      0|        outbuf[outbuflen] = '\000';
 1183|      0|        max_length--;
 1184|      0|      }
 1185|      0|      if (max_length > 1) {
  ------------------
  |  Branch (1185:11): [True: 0, False: 0]
  ------------------
 1186|      0|        outbuflen += print_readable(data, data_len,
 1187|      0|                                    (unsigned char *)&outbuf[outbuflen],
 1188|      0|                                    max_length, 0);
 1189|      0|      }
 1190|       |      /* print_readable may be handling unprintables - hence headroom of 4 */
 1191|      0|      if (outbuflen < sizeof(outbuf)-4-1) {
  ------------------
  |  Branch (1191:11): [True: 0, False: 0]
  ------------------
 1192|      0|        outbuf[outbuflen++] = '\'';
 1193|      0|        outbuf[outbuflen] = '\000';
 1194|      0|      }
 1195|      0|    }
 1196|      0|  }
 1197|       |
 1198|      0|  if (outbuflen == sizeof(outbuf)-1)
  ------------------
  |  Branch (1198:7): [True: 0, False: 0]
  ------------------
 1199|      0|    outbuflen--;
 1200|      0|  coap_snprintf(outbuf, sizeof(outbuf), &outbuflen, "\n");
 1201|      0|  COAP_DO_SHOW_OUTPUT_LINE;
  ------------------
  |  |  812|      0|  do {                                      \
  |  |  813|      0|    if (use_fprintf_for_show_pdu) {         \
  |  |  ------------------
  |  |  |  Branch (813:9): [True: 0, False: 0]
  |  |  ------------------
  |  |  814|      0|      fprintf(COAP_DEBUG_FD, "%s", outbuf); \
  |  |  ------------------
  |  |  |  |   37|      0|#define COAP_DEBUG_FD stdout
  |  |  ------------------
  |  |  815|      0|    }                                       \
  |  |  816|      0|    else {                                  \
  |  |  817|      0|      coap_log(level, "%s", outbuf);        \
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  818|      0|    }                                       \
  |  |  819|      0|  } while (0)
  |  |  ------------------
  |  |  |  Branch (819:12): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1202|       |
 1203|       |#if COAP_THREAD_SAFE
 1204|       |  coap_mutex_unlock(&m_show_pdu);
 1205|       |#endif /* COAP_THREAD_SAFE */
 1206|      0|}
coap_debug_set_packet_loss:
 1515|     35|coap_debug_set_packet_loss(const char *loss_level) {
 1516|     35|  return coap_debug_set_packet_common(loss_level, packet_loss_intervals,
 1517|     35|                                      &num_packet_loss_intervals, &packet_loss_level, &send_packet_count);
 1518|     35|}
coap_debug_send_packet:
 1521|    216|coap_debug_send_packet(void) {
 1522|    216|  ++send_packet_count;
 1523|    216|  if (num_packet_loss_intervals > 0) {
  ------------------
  |  Branch (1523:7): [True: 0, False: 216]
  ------------------
 1524|      0|    int i;
 1525|      0|    for (i = 0; i < num_packet_loss_intervals; i++) {
  ------------------
  |  Branch (1525:17): [True: 0, False: 0]
  ------------------
 1526|      0|      if (send_packet_count >= packet_loss_intervals[i].start &&
  ------------------
  |  Branch (1526:11): [True: 0, False: 0]
  ------------------
 1527|      0|          send_packet_count <= packet_loss_intervals[i].end) {
  ------------------
  |  Branch (1527:11): [True: 0, False: 0]
  ------------------
 1528|      0|        coap_log_debug("Following packet no %" PRIuS " dropped\n", send_packet_count);
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1529|      0|        return 0;
 1530|      0|      }
 1531|      0|    }
 1532|      0|  }
 1533|    216|  if (packet_loss_level > 0) {
  ------------------
  |  Branch (1533:7): [True: 216, False: 0]
  ------------------
 1534|    216|    uint16_t r = 0;
 1535|    216|    coap_prng_lkd((uint8_t *)&r, 2);
 1536|    216|    if (r < packet_loss_level) {
  ------------------
  |  Branch (1536:9): [True: 101, False: 115]
  ------------------
 1537|    101|      coap_log_debug("Following packet no %"PRIuS " dropped\n", send_packet_count);
  ------------------
  |  |  126|    101|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|    101|#define coap_log(level, ...) do { \
  |  |  |  |  291|    101|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 101]
  |  |  |  |  ------------------
  |  |  |  |  292|    101|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|    101|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 101]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1538|    101|      return 0;
 1539|    101|    }
 1540|    216|  }
 1541|    115|  if (num_packet_fail_intervals > 0) {
  ------------------
  |  Branch (1541:7): [True: 0, False: 115]
  ------------------
 1542|      0|    int i;
 1543|      0|    for (i = 0; i < num_packet_fail_intervals; i++) {
  ------------------
  |  Branch (1543:17): [True: 0, False: 0]
  ------------------
 1544|      0|      if (send_packet_count >= packet_fail_intervals[i].start &&
  ------------------
  |  Branch (1544:11): [True: 0, False: 0]
  ------------------
 1545|      0|          send_packet_count <= packet_fail_intervals[i].end) {
  ------------------
  |  Branch (1545:11): [True: 0, False: 0]
  ------------------
 1546|      0|        coap_log_debug("Following packet no %"PRIuS " failed\n", send_packet_count);
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1547|      0|        errno = ECONNREFUSED;
 1548|      0|        return -1;
 1549|      0|      }
 1550|      0|    }
 1551|      0|  }
 1552|    115|  if (packet_fail_level > 0) {
  ------------------
  |  Branch (1552:7): [True: 115, False: 0]
  ------------------
 1553|    115|    uint16_t r = 0;
 1554|    115|    coap_prng_lkd((uint8_t *)&r, 2);
 1555|    115|    if (r < packet_fail_level) {
  ------------------
  |  Branch (1555:9): [True: 115, False: 0]
  ------------------
 1556|    115|      coap_log_debug("Following packet no %"PRIuS " failed\n", send_packet_count);
  ------------------
  |  |  126|    115|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|    115|#define coap_log(level, ...) do { \
  |  |  |  |  291|    115|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 115]
  |  |  |  |  ------------------
  |  |  |  |  292|    115|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|    115|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 115]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1557|    115|      errno = ECONNREFUSED;
 1558|    115|      return -1;
 1559|    115|    }
 1560|    115|  }
 1561|      0|  return 1;
 1562|    115|}
coap_debug_set_packet_fail:
 1565|     35|coap_debug_set_packet_fail(const char *fail_level) {
 1566|     35|  return coap_debug_set_packet_common(fail_level, packet_fail_intervals,
 1567|     35|                                      &num_packet_fail_intervals, &packet_fail_level, &send_packet_count);
 1568|     35|}
coap_debug_recv_packet:
 1577|      5|coap_debug_recv_packet(void) {
 1578|      5|  ++recv_packet_count;
 1579|      5|  if (num_packet_drop_intervals > 0) {
  ------------------
  |  Branch (1579:7): [True: 0, False: 5]
  ------------------
 1580|      0|    int i;
 1581|      0|    for (i = 0; i < num_packet_drop_intervals; i++) {
  ------------------
  |  Branch (1581:17): [True: 0, False: 0]
  ------------------
 1582|      0|      if (recv_packet_count >= packet_drop_intervals[i].start &&
  ------------------
  |  Branch (1582:11): [True: 0, False: 0]
  ------------------
 1583|      0|          recv_packet_count <= packet_drop_intervals[i].end) {
  ------------------
  |  Branch (1583:11): [True: 0, False: 0]
  ------------------
 1584|      0|        coap_log_debug("Incoming packet no %" PRIuS " dropped\n", recv_packet_count);
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1585|      0|        return 0;
 1586|      0|      }
 1587|      0|    }
 1588|      0|  }
 1589|      5|  if (packet_drop_level > 0) {
  ------------------
  |  Branch (1589:7): [True: 0, False: 5]
  ------------------
 1590|      0|    uint16_t r = 0;
 1591|      0|    coap_prng_lkd((uint8_t *)&r, 2);
 1592|      0|    if (r < packet_drop_level) {
  ------------------
  |  Branch (1592:9): [True: 0, False: 0]
  ------------------
 1593|      0|      coap_log_debug("Incoming packet no %"PRIuS " dropped\n", recv_packet_count);
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1594|      0|      return 0;
 1595|      0|    }
 1596|      0|  }
 1597|      5|  return 1;
 1598|      5|}
coap_debug_reset:
 1602|     35|coap_debug_reset(void) {
 1603|       |  log_handler = NULL;
 1604|     35|  maxlog = COAP_LOG_WARN;
 1605|     35|  use_fprintf_for_show_pdu = 1;
 1606|     35|  num_packet_loss_intervals = 0;
 1607|     35|  packet_loss_level = 0;
 1608|     35|  num_packet_fail_intervals = 0;
 1609|     35|  packet_fail_level = 0;
 1610|     35|  send_packet_count = 0;
 1611|     35|  num_packet_drop_intervals = 0;
 1612|     35|  packet_drop_level = 0;
 1613|     35|  recv_packet_count = 0;
 1614|     35|}
coap_debug.c:coap_debug_set_packet_common:
 1470|     70|                             int *num_intervals, uint16_t *level, size_t *count) {
 1471|     70|  const char *p = loss_level;
 1472|     70|  char *end = NULL;
 1473|     70|  int n = (int)strtol(p, &end, 10), i = 0;
 1474|       |
 1475|     70|  *level = 0;
 1476|     70|  *num_intervals = 0;
 1477|       |
 1478|     70|  if (end == p || n < 0)
  ------------------
  |  Branch (1478:7): [True: 0, False: 70]
  |  Branch (1478:19): [True: 0, False: 70]
  ------------------
 1479|      0|    return 0;
 1480|     70|  if (*end == '%') {
  ------------------
  |  Branch (1480:7): [True: 70, False: 0]
  ------------------
 1481|     70|    if (n > 100)
  ------------------
  |  Branch (1481:9): [True: 0, False: 70]
  ------------------
 1482|      0|      n = 100;
 1483|     70|    *level = n * 0xffff / 100;
 1484|     70|    coap_log_debug("packet loss level set to %d%%\n", n);
  ------------------
  |  |  126|     70|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|     70|#define coap_log(level, ...) do { \
  |  |  |  |  291|     70|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 70]
  |  |  |  |  ------------------
  |  |  |  |  292|     70|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|     70|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 70]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1485|     70|  } else {
 1486|      0|    if (n <= 0)
  ------------------
  |  Branch (1486:9): [True: 0, False: 0]
  ------------------
 1487|      0|      return 0;
 1488|      0|    while (i < COAP_DEBUG_INTERVAL_COUNT) {
  ------------------
  |  | 1450|      0|#define COAP_DEBUG_INTERVAL_COUNT 10
  ------------------
  |  Branch (1488:12): [True: 0, False: 0]
  ------------------
 1489|      0|      intervals[i].start = n;
 1490|      0|      if (*end == '-') {
  ------------------
  |  Branch (1490:11): [True: 0, False: 0]
  ------------------
 1491|      0|        p = end + 1;
 1492|      0|        n = (int)strtol(p, &end, 10);
 1493|      0|        if (end == p || n <= 0)
  ------------------
  |  Branch (1493:13): [True: 0, False: 0]
  |  Branch (1493:25): [True: 0, False: 0]
  ------------------
 1494|      0|          return 0;
 1495|      0|      }
 1496|      0|      intervals[i++].end = n;
 1497|      0|      if (*end == 0)
  ------------------
  |  Branch (1497:11): [True: 0, False: 0]
  ------------------
 1498|      0|        break;
 1499|      0|      if (*end != ',')
  ------------------
  |  Branch (1499:11): [True: 0, False: 0]
  ------------------
 1500|      0|        return 0;
 1501|      0|      p = end + 1;
 1502|      0|      n = (int)strtol(p, &end, 10);
 1503|      0|      if (end == p || n <= 0)
  ------------------
  |  Branch (1503:11): [True: 0, False: 0]
  |  Branch (1503:23): [True: 0, False: 0]
  ------------------
 1504|      0|        return 0;
 1505|      0|    }
 1506|      0|    if (i == COAP_DEBUG_INTERVAL_COUNT)
  ------------------
  |  | 1450|      0|#define COAP_DEBUG_INTERVAL_COUNT 10
  ------------------
  |  Branch (1506:9): [True: 0, False: 0]
  ------------------
 1507|      0|      return 0;
 1508|      0|    *num_intervals = i;
 1509|      0|  }
 1510|     70|  *count = 0;
 1511|     70|  return 1;
 1512|     70|}

coap_socket_connect_udp:
  217|     35|                        coap_address_t *remote_addr) {
  218|     35|  int on = 1;
  219|     35|#if COAP_IPV6_SUPPORT
  220|     35|  int off = 0;
  221|     35|#endif /* COAP_IPV6_SUPPORT */
  222|       |#ifdef _WIN32
  223|       |  u_long u_on = 1;
  224|       |#endif
  225|     35|  coap_address_t connect_addr;
  226|     35|  int is_mcast = coap_is_mcast(server);
  227|     35|  coap_address_copy(&connect_addr, server);
  228|       |
  229|     35|  sock->flags &= ~(COAP_SOCKET_CONNECTED | COAP_SOCKET_MULTICAST);
  ------------------
  |  |   77|     35|#define COAP_SOCKET_CONNECTED    0x0004  /**< the socket is connected */
  ------------------
                sock->flags &= ~(COAP_SOCKET_CONNECTED | COAP_SOCKET_MULTICAST);
  ------------------
  |  |   87|     35|#define COAP_SOCKET_MULTICAST    0x1000  /**< socket is used for multicast communication */
  ------------------
  230|     35|  sock->fd = socket(connect_addr.addr.sa.sa_family, SOCK_DGRAM, 0);
  231|       |
  232|     35|  if (sock->fd == COAP_INVALID_SOCKET) {
  ------------------
  |  |   52|     35|#define COAP_INVALID_SOCKET (-1)
  ------------------
  |  Branch (232:7): [True: 0, False: 35]
  ------------------
  233|      0|    coap_log_warn("coap_socket_connect_udp: socket: %s\n",
  ------------------
  |  |  108|      0|#define coap_log_warn(...) coap_log(COAP_LOG_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  234|      0|                  coap_socket_strerror());
  235|      0|    goto error;
  236|      0|  }
  237|       |
  238|       |#ifdef _WIN32
  239|       |  if (ioctlsocket(sock->fd, FIONBIO, &u_on) == COAP_SOCKET_ERROR)
  240|       |#else
  241|     35|  if (ioctl(sock->fd, FIONBIO, &on) == COAP_SOCKET_ERROR)
  ------------------
  |  |   51|     35|#define COAP_SOCKET_ERROR (-1)
  ------------------
  |  Branch (241:7): [True: 0, False: 35]
  ------------------
  242|      0|#endif
  243|      0|  {
  244|       |    /* Ignore Zephyr unexpected Success response */
  245|      0|    if (errno != 0) {
  ------------------
  |  Branch (245:9): [True: 0, False: 0]
  ------------------
  246|      0|      int keep_errno = errno;
  247|       |
  248|      0|      coap_log_warn("coap_socket_connect_udp: ioctl FIONBIO: %s (%d)\n",
  ------------------
  |  |  108|      0|#define coap_log_warn(...) coap_log(COAP_LOG_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  249|      0|                    coap_socket_strerror(), keep_errno);
  250|      0|    }
  251|      0|  }
  252|       |
  253|     35|  switch (connect_addr.addr.sa.sa_family) {
  254|      0|#if COAP_IPV4_SUPPORT
  255|     35|  case AF_INET:
  ------------------
  |  Branch (255:3): [True: 35, False: 0]
  ------------------
  256|     35|    if (connect_addr.addr.sin.sin_port == 0)
  ------------------
  |  Branch (256:9): [True: 35, False: 0]
  ------------------
  257|     35|      connect_addr.addr.sin.sin_port = htons(default_port);
  258|     35|#if IP_RECVERR && defined(HAVE_STRUCT_CMSGHDR) && defined(HAVE_LINUX_ERRQUEUE_H)
  259|     35|    if (setsockopt(sock->fd, IPPROTO_IP, IP_RECVERR, OPTVAL_T(&on),
  ------------------
  |  |   34|     35|# define OPTVAL_T(t)         (t)
  ------------------
  |  Branch (259:9): [True: 0, False: 35]
  ------------------
  260|     35|                   sizeof(on)) == COAP_SOCKET_ERROR)
  ------------------
  |  |   51|     35|#define COAP_SOCKET_ERROR (-1)
  ------------------
  261|     35|      coap_log_alert("coap_socket_connect_udp: setsockopt IP_RECVERR: %s\n",
  ------------------
  |  |   90|      0|#define coap_log_alert(...) coap_log(COAP_LOG_ALERT, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  262|     35|                     coap_socket_strerror());
  263|     35|#endif /* IP_RECVERR && HAVE_STRUCT_CMSGHDR && HAVE_LINUX_ERRQUEUE_H */
  264|     35|    break;
  265|      0|#endif /* COAP_IPV4_SUPPORT */
  266|      0|#if COAP_IPV6_SUPPORT
  267|      0|  case AF_INET6:
  ------------------
  |  Branch (267:3): [True: 0, False: 35]
  ------------------
  268|      0|    if (connect_addr.addr.sin6.sin6_port == 0)
  ------------------
  |  Branch (268:9): [True: 0, False: 0]
  ------------------
  269|      0|      connect_addr.addr.sin6.sin6_port = htons(default_port);
  270|       |    /* Configure the socket as dual-stacked */
  271|      0|    if (setsockopt(sock->fd, IPPROTO_IPV6, IPV6_V6ONLY, OPTVAL_T(&off),
  ------------------
  |  |   34|      0|# define OPTVAL_T(t)         (t)
  ------------------
  |  Branch (271:9): [True: 0, False: 0]
  ------------------
  272|      0|                   sizeof(off)) == COAP_SOCKET_ERROR)
  ------------------
  |  |   51|      0|#define COAP_SOCKET_ERROR (-1)
  ------------------
  273|      0|      if (errno != ENOSYS) {
  ------------------
  |  Branch (273:11): [True: 0, False: 0]
  ------------------
  274|      0|        coap_log_warn("coap_socket_connect_udp: setsockopt IPV6_V6ONLY: %s\n",
  ------------------
  |  |  108|      0|#define coap_log_warn(...) coap_log(COAP_LOG_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  275|      0|                      coap_socket_strerror());
  276|      0|      }
  277|      0|#if IPV6_RECVERR && defined(HAVE_STRUCT_CMSGHDR) && defined(HAVE_LINUX_ERRQUEUE_H)
  278|      0|    if (setsockopt(sock->fd, IPPROTO_IPV6, IPV6_RECVERR, OPTVAL_T(&on),
  ------------------
  |  |   34|      0|# define OPTVAL_T(t)         (t)
  ------------------
  |  Branch (278:9): [True: 0, False: 0]
  ------------------
  279|      0|                   sizeof(on)) == COAP_SOCKET_ERROR)
  ------------------
  |  |   51|      0|#define COAP_SOCKET_ERROR (-1)
  ------------------
  280|      0|      coap_log_alert("coap_socket_connect_udp: setsockopt IPV6_RECVERR: %s\n",
  ------------------
  |  |   90|      0|#define coap_log_alert(...) coap_log(COAP_LOG_ALERT, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  281|      0|                     coap_socket_strerror());
  282|      0|#endif /* IPV6_RECVERR && HAVE_STRUCT_CMSGHDR && HAVE_LINUX_ERRQUEUE_H */
  283|      0|#endif /* COAP_IPV6_SUPPORT */
  284|      0|    break;
  285|      0|#if COAP_AF_UNIX_SUPPORT
  286|      0|  case AF_UNIX:
  ------------------
  |  Branch (286:3): [True: 0, False: 35]
  ------------------
  287|      0|    break;
  288|      0|#endif /* COAP_AF_UNIX_SUPPORT */
  289|      0|#if COAP_AF_LLC_SUPPORT
  290|      0|  case AF_LLC:
  ------------------
  |  Branch (290:3): [True: 0, False: 35]
  ------------------
  291|      0|    break;
  292|      0|#endif /* COAP_AF_LLC_SUPPORT */
  293|      0|  default:
  ------------------
  |  Branch (293:3): [True: 0, False: 35]
  ------------------
  294|      0|    coap_log_alert("coap_socket_connect_udp: unsupported sa_family %d\n",
  ------------------
  |  |   90|      0|#define coap_log_alert(...) coap_log(COAP_LOG_ALERT, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  295|      0|                   connect_addr.addr.sa.sa_family);
  296|      0|    goto error;;
  297|     35|  }
  298|       |
  299|     35|  if (local_if && local_if->addr.sa.sa_family) {
  ------------------
  |  Branch (299:7): [True: 0, False: 35]
  |  Branch (299:19): [True: 0, False: 0]
  ------------------
  300|      0|    if (local_if->addr.sa.sa_family != connect_addr.addr.sa.sa_family) {
  ------------------
  |  Branch (300:9): [True: 0, False: 0]
  ------------------
  301|      0|      coap_log_warn("coap_socket_connect_udp: local address family != "
  ------------------
  |  |  108|      0|#define coap_log_warn(...) coap_log(COAP_LOG_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  302|      0|                    "remote address family\n");
  303|      0|      goto error;
  304|      0|    }
  305|      0|    if (setsockopt(sock->fd, SOL_SOCKET, SO_REUSEADDR, OPTVAL_T(&on), sizeof(on)) == COAP_SOCKET_ERROR)
  ------------------
  |  |   34|      0|# define OPTVAL_T(t)         (t)
  ------------------
                  if (setsockopt(sock->fd, SOL_SOCKET, SO_REUSEADDR, OPTVAL_T(&on), sizeof(on)) == COAP_SOCKET_ERROR)
  ------------------
  |  |   51|      0|#define COAP_SOCKET_ERROR (-1)
  ------------------
  |  Branch (305:9): [True: 0, False: 0]
  ------------------
  306|      0|      coap_log_warn("coap_socket_connect_udp: setsockopt SO_REUSEADDR: %s\n",
  ------------------
  |  |  108|      0|#define coap_log_warn(...) coap_log(COAP_LOG_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  307|      0|                    coap_socket_strerror());
  308|      0|    if (bind(sock->fd, &local_if->addr.sa,
  ------------------
  |  Branch (308:9): [True: 0, False: 0]
  ------------------
  309|      0|#if COAP_IPV4_SUPPORT
  310|      0|             local_if->addr.sa.sa_family == AF_INET ?
  ------------------
  |  Branch (310:14): [True: 0, False: 0]
  ------------------
  311|      0|             (socklen_t)sizeof(struct sockaddr_in) :
  312|      0|#endif /* COAP_IPV4_SUPPORT */
  313|      0|             (socklen_t)local_if->size) == COAP_SOCKET_ERROR) {
  ------------------
  |  |   51|      0|#define COAP_SOCKET_ERROR (-1)
  ------------------
  314|      0|      coap_log_warn("coap_socket_connect_udp: bind: %s\n",
  ------------------
  |  |  108|      0|#define coap_log_warn(...) coap_log(COAP_LOG_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  315|      0|                    coap_socket_strerror());
  316|      0|      goto error;
  317|      0|    }
  318|      0|#if COAP_AF_UNIX_SUPPORT
  319|     35|  } else if (connect_addr.addr.sa.sa_family == AF_UNIX) {
  ------------------
  |  Branch (319:14): [True: 0, False: 35]
  ------------------
  320|       |    /* Need to bind to a local address for clarity over endpoints */
  321|      0|    coap_log_warn("coap_socket_connect_udp: local address required\n");
  ------------------
  |  |  108|      0|#define coap_log_warn(...) coap_log(COAP_LOG_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  322|      0|    goto error;
  323|      0|#endif /* COAP_AF_UNIX_SUPPORT */
  324|      0|  }
  325|       |
  326|       |  /* special treatment for sockets that are used for multicast communication */
  327|     35|  if (is_mcast) {
  ------------------
  |  Branch (327:7): [True: 0, False: 35]
  ------------------
  328|      0|    if (!(local_if && local_if->addr.sa.sa_family)) {
  ------------------
  |  Branch (328:11): [True: 0, False: 0]
  |  Branch (328:23): [True: 0, False: 0]
  ------------------
  329|       |      /* Bind to a (unused) port to simplify logging */
  330|      0|      coap_address_t bind_addr;
  331|       |
  332|      0|      coap_address_init(&bind_addr);
  333|      0|      bind_addr.addr.sa.sa_family = connect_addr.addr.sa.sa_family;
  334|      0|      if (bind(sock->fd, &bind_addr.addr.sa,
  ------------------
  |  Branch (334:11): [True: 0, False: 0]
  ------------------
  335|      0|#if COAP_IPV4_SUPPORT
  336|      0|               bind_addr.addr.sa.sa_family == AF_INET ?
  ------------------
  |  Branch (336:16): [True: 0, False: 0]
  ------------------
  337|      0|               (socklen_t)sizeof(struct sockaddr_in) :
  338|      0|#endif /* COAP_IPV4_SUPPORT */
  339|      0|               (socklen_t)bind_addr.size) == COAP_SOCKET_ERROR) {
  ------------------
  |  |   51|      0|#define COAP_SOCKET_ERROR (-1)
  ------------------
  340|      0|        coap_log_warn("coap_socket_connect_udp: bind: %s\n",
  ------------------
  |  |  108|      0|#define coap_log_warn(...) coap_log(COAP_LOG_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  341|      0|                      coap_socket_strerror());
  342|      0|        goto error;
  343|      0|      }
  344|      0|    }
  345|      0|    if (getsockname(sock->fd, &local_addr->addr.sa, &local_addr->size) == COAP_SOCKET_ERROR) {
  ------------------
  |  |   51|      0|#define COAP_SOCKET_ERROR (-1)
  ------------------
  |  Branch (345:9): [True: 0, False: 0]
  ------------------
  346|      0|      coap_log_warn("coap_socket_connect_udp: getsockname for multicast socket: %s\n",
  ------------------
  |  |  108|      0|#define coap_log_warn(...) coap_log(COAP_LOG_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  347|      0|                    coap_socket_strerror());
  348|      0|    }
  349|      0|    coap_address_copy(remote_addr, &connect_addr);
  350|      0|    coap_address_copy(&sock->mcast_addr, &connect_addr);
  351|      0|    sock->flags |= COAP_SOCKET_MULTICAST;
  ------------------
  |  |   87|      0|#define COAP_SOCKET_MULTICAST    0x1000  /**< socket is used for multicast communication */
  ------------------
  352|      0|    if (coap_is_bcast(server) &&
  ------------------
  |  Branch (352:9): [True: 0, False: 0]
  ------------------
  353|      0|        setsockopt(sock->fd, SOL_SOCKET, SO_BROADCAST, OPTVAL_T(&on),
  ------------------
  |  |   34|      0|# define OPTVAL_T(t)         (t)
  ------------------
  |  Branch (353:9): [True: 0, False: 0]
  ------------------
  354|      0|                   sizeof(on)) == COAP_SOCKET_ERROR)
  ------------------
  |  |   51|      0|#define COAP_SOCKET_ERROR (-1)
  ------------------
  355|      0|      coap_log_warn("coap_socket_connect_udp: setsockopt SO_BROADCAST: %s\n",
  ------------------
  |  |  108|      0|#define coap_log_warn(...) coap_log(COAP_LOG_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  356|      0|                    coap_socket_strerror());
  357|      0|    return 1;
  358|      0|  }
  359|       |
  360|     35|  switch (connect_addr.addr.sa.sa_family) {
  361|      0|#if COAP_AF_LLC_SUPPORT
  362|       |  /* Only SOCK_STREAM type AF_LLC sockets can be connect()ed. */
  363|      0|  case AF_LLC:
  ------------------
  |  Branch (363:3): [True: 0, False: 35]
  ------------------
  364|      0|    break;
  365|      0|#endif /* COAP_AF_LLC_SUPPORT */
  366|      0|#if COAP_AF_UNIX_SUPPORT
  367|      0|  case AF_UNIX:
  ------------------
  |  Branch (367:3): [True: 0, False: 35]
  ------------------
  368|      0|#endif /* COAP_AF_UNIX_SUPPORT */
  369|     35|  default:
  ------------------
  |  Branch (369:3): [True: 35, False: 0]
  ------------------
  370|     35|    if (connect(sock->fd, &connect_addr.addr.sa, connect_addr.size) == COAP_SOCKET_ERROR) {
  ------------------
  |  |   51|     35|#define COAP_SOCKET_ERROR (-1)
  ------------------
  |  Branch (370:9): [True: 0, False: 35]
  ------------------
  371|      0|#if COAP_AF_UNIX_SUPPORT
  372|      0|      if (connect_addr.addr.sa.sa_family == AF_UNIX) {
  ------------------
  |  Branch (372:11): [True: 0, False: 0]
  ------------------
  373|      0|        coap_log_warn("coap_socket_connect_udp: connect: %s: %s\n",
  ------------------
  |  |  108|      0|#define coap_log_warn(...) coap_log(COAP_LOG_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  374|      0|                      connect_addr.addr.cun.sun_path, coap_socket_strerror());
  375|      0|      } else
  376|      0|#endif /* COAP_AF_UNIX_SUPPORT */
  377|      0|      {
  378|      0|        coap_log_warn("coap_socket_connect_udp: connect: %s (%d)\n",
  ------------------
  |  |  108|      0|#define coap_log_warn(...) coap_log(COAP_LOG_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  379|      0|                      coap_socket_strerror(), connect_addr.addr.sa.sa_family);
  380|      0|      }
  381|      0|      goto error;
  382|      0|    }
  383|       |
  384|     35|    if (getpeername(sock->fd, &remote_addr->addr.sa, &remote_addr->size) == COAP_SOCKET_ERROR) {
  ------------------
  |  |   51|     35|#define COAP_SOCKET_ERROR (-1)
  ------------------
  |  Branch (384:9): [True: 0, False: 35]
  ------------------
  385|      0|      coap_log_warn("coap_socket_connect_udp: getpeername: %s\n",
  ------------------
  |  |  108|      0|#define coap_log_warn(...) coap_log(COAP_LOG_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  386|      0|                    coap_socket_strerror());
  387|      0|    }
  388|     35|    break;
  389|     35|  }
  390|       |
  391|     35|  if (getsockname(sock->fd, &local_addr->addr.sa, &local_addr->size) == COAP_SOCKET_ERROR) {
  ------------------
  |  |   51|     35|#define COAP_SOCKET_ERROR (-1)
  ------------------
  |  Branch (391:7): [True: 0, False: 35]
  ------------------
  392|      0|    coap_log_warn("coap_socket_connect_udp: getsockname: %s\n",
  ------------------
  |  |  108|      0|#define coap_log_warn(...) coap_log(COAP_LOG_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  393|      0|                  coap_socket_strerror());
  394|      0|  }
  395|       |
  396|     35|#if COAP_AF_LLC_SUPPORT
  397|       |  /* AF_LLC sockets send to the local address without an explicit destination. */
  398|     35|  if (coap_is_af_llc(&connect_addr))
  ------------------
  |  Branch (398:7): [True: 0, False: 35]
  ------------------
  399|      0|    sock->flags |= COAP_SOCKET_WANT_SENDTO;
  ------------------
  |  |   89|      0|#define COAP_SOCKET_WANT_SENDTO  0x4000  /**< socket requires a destination address for sending */
  ------------------
  400|     35|#endif /* COAP_AF_LLC_SUPPORT */
  401|       |
  402|     35|  sock->flags |= COAP_SOCKET_CONNECTED;
  ------------------
  |  |   77|     35|#define COAP_SOCKET_CONNECTED    0x0004  /**< the socket is connected */
  ------------------
  403|     35|  return 1;
  404|       |
  405|      0|error:
  406|      0|  coap_socket_dgrm_close(sock);
  407|      0|  return 0;
  408|     35|}
coap_socket_send:
  621|    216|                 const uint8_t *data, size_t datalen) {
  622|    216|  ssize_t bytes_written = 0;
  623|    216|  int r;
  624|       |
  625|    216|#if COAP_CLIENT_SUPPORT
  626|    216|  coap_test_cid_tuple_change(session);
  627|    216|#endif /* COAP_CLIENT_SUPPORT */
  628|       |
  629|    216|  if ((r = coap_debug_send_packet()) != 1) {
  ------------------
  |  Branch (629:7): [True: 216, False: 0]
  ------------------
  630|    216|    if (r)
  ------------------
  |  Branch (630:9): [True: 115, False: 101]
  ------------------
  631|    115|      bytes_written = -1;
  632|    101|    else
  633|    101|      bytes_written = (ssize_t)datalen;
  634|    216|  } else if (sock->flags & COAP_SOCKET_CONNECTED &&
  ------------------
  |  |   77|      0|#define COAP_SOCKET_CONNECTED    0x0004  /**< the socket is connected */
  ------------------
  |  Branch (634:14): [True: 0, False: 0]
  ------------------
  635|      0|             !(sock->flags & COAP_SOCKET_WANT_SENDTO)) {
  ------------------
  |  |   89|      0|#define COAP_SOCKET_WANT_SENDTO  0x4000  /**< socket requires a destination address for sending */
  ------------------
  |  Branch (635:14): [True: 0, False: 0]
  ------------------
  636|       |#ifdef _WIN32
  637|       |    bytes_written = send(sock->fd, (const char *)data, (int)datalen, 0);
  638|       |#else
  639|      0|    bytes_written = send(sock->fd, data, datalen, 0);
  640|      0|#endif
  641|      0|  } else {
  642|       |#if defined(_WIN32)
  643|       |    DWORD dwNumberOfBytesSent = 0;
  644|       |#endif /* _WIN32 */
  645|      0|#ifdef HAVE_STRUCT_CMSGHDR
  646|       |    /* a buffer large enough to hold all packet info types, ipv6 is the largest */
  647|      0|    char buf[CMSG_SPACE(sizeof(struct in6_pktinfo))];
  648|      0|    struct msghdr mhdr;
  649|      0|    struct iovec iov[1];
  650|      0|    const void *addr = &session->addr_info.remote.addr;
  651|       |
  652|      0|    assert(session);
  ------------------
  |  Branch (652:5): [True: 0, False: 0]
  ------------------
  653|       |
  654|      0|    memcpy(&iov[0].iov_base, &data, sizeof(iov[0].iov_base));
  655|      0|    iov[0].iov_len = (iov_len_t)datalen;
  656|       |
  657|      0|    memset(buf, 0, sizeof(buf));
  658|       |
  659|      0|    memset(&mhdr, 0, sizeof(struct msghdr));
  660|      0|    memcpy(&mhdr.msg_name, &addr, sizeof(mhdr.msg_name));
  661|      0|    mhdr.msg_namelen = session->addr_info.remote.addr.sa.sa_family == AF_INET ?
  ------------------
  |  Branch (661:24): [True: 0, False: 0]
  ------------------
  662|      0|                       (socklen_t)sizeof(struct sockaddr_in) :
  663|      0|                       session->addr_info.remote.size;
  664|       |
  665|      0|    mhdr.msg_iov = iov;
  666|      0|    mhdr.msg_iovlen = 1;
  667|       |
  668|      0|    if (!coap_address_isany(&session->addr_info.local) &&
  ------------------
  |  Branch (668:9): [True: 0, False: 0]
  ------------------
  669|      0|        !coap_is_mcast(&session->addr_info.local)) {
  ------------------
  |  Branch (669:9): [True: 0, False: 0]
  ------------------
  670|      0|      switch (session->addr_info.local.addr.sa.sa_family) {
  671|      0|#if COAP_IPV6_SUPPORT
  672|      0|      case AF_INET6: {
  ------------------
  |  Branch (672:7): [True: 0, False: 0]
  ------------------
  673|      0|        struct cmsghdr *cmsg;
  674|       |
  675|      0|#if COAP_IPV4_SUPPORT
  676|      0|        if (IN6_IS_ADDR_V4MAPPED(&session->addr_info.local.addr.sin6.sin6_addr)) {
  ------------------
  |  Branch (676:13): [True: 0, False: 0]
  ------------------
  677|      0|#if defined(IP_PKTINFO)
  678|      0|          struct in_pktinfo *pktinfo;
  679|      0|          mhdr.msg_control = buf;
  680|      0|          mhdr.msg_controllen = CMSG_SPACE(sizeof(struct in_pktinfo));
  681|       |
  682|      0|          cmsg = CMSG_FIRSTHDR(&mhdr);
  ------------------
  |  Branch (682:18): [True: 0, False: 0]
  ------------------
  683|      0|          cmsg->cmsg_level = COAP_SOL_IP;
  ------------------
  |  |  438|      0|#define COAP_SOL_IP SOL_IP
  ------------------
  684|      0|          cmsg->cmsg_type = IP_PKTINFO;
  685|      0|          cmsg->cmsg_len = CMSG_LEN(sizeof(struct in_pktinfo));
  686|       |
  687|      0|          pktinfo = (struct in_pktinfo *)CMSG_DATA(cmsg);
  688|       |
  689|      0|          pktinfo->ipi_ifindex = session->ifindex;
  690|      0|          memcpy(&pktinfo->ipi_spec_dst,
  691|      0|                 session->addr_info.local.addr.sin6.sin6_addr.s6_addr + 12,
  692|      0|                 sizeof(pktinfo->ipi_spec_dst));
  693|       |#elif defined(IP_SENDSRCADDR)
  694|       |          mhdr.msg_control = buf;
  695|       |          mhdr.msg_controllen = CMSG_SPACE(sizeof(struct in_addr));
  696|       |
  697|       |          cmsg = CMSG_FIRSTHDR(&mhdr);
  698|       |          cmsg->cmsg_level = IPPROTO_IP;
  699|       |          cmsg->cmsg_type = IP_SENDSRCADDR;
  700|       |          cmsg->cmsg_len = CMSG_LEN(sizeof(struct in_addr));
  701|       |
  702|       |          memcpy(CMSG_DATA(cmsg),
  703|       |                 session->addr_info.local.addr.sin6.sin6_addr.s6_addr + 12,
  704|       |                 sizeof(struct in_addr));
  705|       |#endif /* IP_PKTINFO */
  706|      0|        } else {
  707|      0|#endif /* COAP_IPV4_SUPPORT */
  708|      0|          struct in6_pktinfo *pktinfo;
  709|      0|          mhdr.msg_control = buf;
  710|      0|          mhdr.msg_controllen = CMSG_SPACE(sizeof(struct in6_pktinfo));
  711|       |
  712|      0|          cmsg = CMSG_FIRSTHDR(&mhdr);
  ------------------
  |  Branch (712:18): [True: 0, False: 0]
  ------------------
  713|      0|          cmsg->cmsg_level = IPPROTO_IPV6;
  714|      0|          cmsg->cmsg_type = IPV6_PKTINFO;
  715|      0|          cmsg->cmsg_len = CMSG_LEN(sizeof(struct in6_pktinfo));
  716|       |
  717|      0|          pktinfo = (struct in6_pktinfo *)CMSG_DATA(cmsg);
  718|       |
  719|      0|          if (coap_is_mcast(&session->addr_info.remote)) {
  ------------------
  |  Branch (719:15): [True: 0, False: 0]
  ------------------
  720|      0|            pktinfo->ipi6_ifindex = session->addr_info.remote.addr.sin6.sin6_scope_id;
  721|      0|          } else {
  722|      0|            pktinfo->ipi6_ifindex = session->ifindex;
  723|      0|          }
  724|      0|          memcpy(&pktinfo->ipi6_addr,
  725|      0|                 &session->addr_info.local.addr.sin6.sin6_addr,
  726|      0|                 sizeof(pktinfo->ipi6_addr));
  727|      0|#if COAP_IPV4_SUPPORT
  728|      0|        }
  729|      0|#endif /* COAP_IPV4_SUPPORT */
  730|      0|        break;
  731|      0|      }
  732|      0|#endif /* COAP_IPV6_SUPPORT */
  733|      0|#if COAP_IPV4_SUPPORT
  734|      0|      case AF_INET: {
  ------------------
  |  Branch (734:7): [True: 0, False: 0]
  ------------------
  735|      0|#if defined(IP_PKTINFO)
  736|      0|        struct cmsghdr *cmsg;
  737|      0|        struct in_pktinfo *pktinfo;
  738|       |
  739|      0|        mhdr.msg_control = buf;
  740|      0|        mhdr.msg_controllen = CMSG_SPACE(sizeof(struct in_pktinfo));
  741|       |
  742|      0|        cmsg = CMSG_FIRSTHDR(&mhdr);
  ------------------
  |  Branch (742:16): [True: 0, False: 0]
  ------------------
  743|      0|        cmsg->cmsg_level = COAP_SOL_IP;
  ------------------
  |  |  438|      0|#define COAP_SOL_IP SOL_IP
  ------------------
  744|      0|        cmsg->cmsg_type = IP_PKTINFO;
  745|      0|        cmsg->cmsg_len = CMSG_LEN(sizeof(struct in_pktinfo));
  746|       |
  747|      0|        pktinfo = (struct in_pktinfo *)CMSG_DATA(cmsg);
  748|       |
  749|      0|        pktinfo->ipi_ifindex = session->ifindex;
  750|      0|        memcpy(&pktinfo->ipi_spec_dst,
  751|      0|               &session->addr_info.local.addr.sin.sin_addr,
  752|      0|               sizeof(pktinfo->ipi_spec_dst));
  753|       |#elif defined(IP_SENDSRCADDR)
  754|       |        struct cmsghdr *cmsg;
  755|       |        mhdr.msg_control = buf;
  756|       |        mhdr.msg_controllen = CMSG_SPACE(sizeof(struct in_addr));
  757|       |
  758|       |        cmsg = CMSG_FIRSTHDR(&mhdr);
  759|       |        cmsg->cmsg_level = IPPROTO_IP;
  760|       |        cmsg->cmsg_type = IP_SENDSRCADDR;
  761|       |        cmsg->cmsg_len = CMSG_LEN(sizeof(struct in_addr));
  762|       |
  763|       |        memcpy(CMSG_DATA(cmsg),
  764|       |               &session->addr_info.local.addr.sin.sin_addr,
  765|       |               sizeof(struct in_addr));
  766|       |#endif /* IP_PKTINFO */
  767|      0|        break;
  768|      0|      }
  769|      0|#endif /* COAP_IPV4_SUPPORT */
  770|      0|#if COAP_AF_UNIX_SUPPORT
  771|      0|      case AF_UNIX:
  ------------------
  |  Branch (771:7): [True: 0, False: 0]
  ------------------
  772|      0|        break;
  773|      0|#endif /* COAP_AF_UNIX_SUPPORT */
  774|      0|#if COAP_AF_LLC_SUPPORT
  775|      0|      case AF_LLC:
  ------------------
  |  Branch (775:7): [True: 0, False: 0]
  ------------------
  776|      0|        break;
  777|      0|#endif /* COAP_AF_LLC_SUPPORT */
  778|      0|      default:
  ------------------
  |  Branch (778:7): [True: 0, False: 0]
  ------------------
  779|       |        /* error */
  780|      0|        coap_log_warn("protocol not supported\n");
  ------------------
  |  |  108|      0|#define coap_log_warn(...) coap_log(COAP_LOG_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  781|      0|        return -1;
  782|      0|      }
  783|      0|    }
  784|      0|#endif /* HAVE_STRUCT_CMSGHDR */
  785|       |
  786|       |#if defined(_WIN32)
  787|       |    r = WSASendMsg(sock->fd, &mhdr, 0 /*dwFlags*/, &dwNumberOfBytesSent, NULL /*lpOverlapped*/,
  788|       |                   NULL /*lpCompletionRoutine*/);
  789|       |    if (r == 0)
  790|       |      bytes_written = (ssize_t)dwNumberOfBytesSent;
  791|       |    else {
  792|       |      bytes_written = -1;
  793|       |      coap_win_error_to_errno();
  794|       |    }
  795|       |#else /* !_WIN32 */
  796|      0|#ifdef HAVE_STRUCT_CMSGHDR
  797|      0|    bytes_written = sendmsg(sock->fd, &mhdr, 0);
  798|       |#else /* ! HAVE_STRUCT_CMSGHDR */
  799|       |    bytes_written = sendto(sock->fd, (const void *)data, datalen, 0,
  800|       |                           &session->addr_info.remote.addr.sa,
  801|       |                           session->addr_info.remote.size);
  802|       |#endif /* ! HAVE_STRUCT_CMSGHDR */
  803|      0|#endif /* !_WIN32 */
  804|      0|  }
  805|       |
  806|    216|  if (bytes_written < 0)
  ------------------
  |  Branch (806:7): [True: 115, False: 101]
  ------------------
  807|    216|    coap_log_warn("coap_socket_send: %s\n", coap_socket_strerror());
  ------------------
  |  |  108|    115|#define coap_log_warn(...) coap_log(COAP_LOG_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|    115|#define coap_log(level, ...) do { \
  |  |  |  |  291|    115|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 115]
  |  |  |  |  ------------------
  |  |  |  |  292|    115|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|    115|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 115]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  808|       |
  809|    216|  return bytes_written;
  810|    216|}
coap_socket_dgrm_close:
 1052|     35|coap_socket_dgrm_close(coap_socket_t *sock) {
 1053|     35|  if (sock->fd != COAP_INVALID_SOCKET && !(sock->flags & COAP_SOCKET_SLAVE)) {
  ------------------
  |  |   52|     70|#define COAP_INVALID_SOCKET (-1)
  ------------------
                if (sock->fd != COAP_INVALID_SOCKET && !(sock->flags & COAP_SOCKET_SLAVE)) {
  ------------------
  |  |   88|     35|#define COAP_SOCKET_SLAVE        0x2000  /**< socket is a slave socket - do not close */
  ------------------
  |  Branch (1053:7): [True: 35, False: 0]
  |  Branch (1053:42): [True: 35, False: 0]
  ------------------
 1054|     35|#ifdef COAP_EPOLL_SUPPORT
 1055|     35|#if COAP_SERVER_SUPPORT
 1056|     35|    coap_context_t *context = sock->session ? sock->session->context :
  ------------------
  |  Branch (1056:31): [True: 35, False: 0]
  ------------------
 1057|     35|                              sock->endpoint ? sock->endpoint->context : NULL;
  ------------------
  |  Branch (1057:31): [True: 0, False: 0]
  ------------------
 1058|       |#else /* ! COAP_SERVER_SUPPORT */
 1059|       |    coap_context_t *context = sock->session ? sock->session->context : NULL;
 1060|       |#endif /* ! COAP_SERVER_SUPPORT */
 1061|     35|    if (context != NULL) {
  ------------------
  |  Branch (1061:9): [True: 35, False: 0]
  ------------------
 1062|     35|      int ret;
 1063|     35|      struct epoll_event event;
 1064|       |
 1065|       |      /* Kernels prior to 2.6.9 expect non NULL event parameter */
 1066|     35|      ret = epoll_ctl(context->epfd, EPOLL_CTL_DEL, sock->fd, &event);
 1067|     35|      if (ret == -1 && errno != ENOENT) {
  ------------------
  |  Branch (1067:11): [True: 0, False: 35]
  |  Branch (1067:24): [True: 0, False: 0]
  ------------------
 1068|      0|        coap_log_err("%s: epoll_ctl DEL failed: %d: %s (%d)\n",
  ------------------
  |  |  102|      0|#define coap_log_err(...) coap_log(COAP_LOG_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1069|      0|                     "coap_socket_close",
 1070|      0|                     sock->fd,
 1071|      0|                     coap_socket_strerror(), errno);
 1072|      0|      }
 1073|     35|    }
 1074|     35|#endif /* COAP_EPOLL_SUPPORT */
 1075|     35|#if COAP_SERVER_SUPPORT
 1076|     35|#if COAP_AF_UNIX_SUPPORT
 1077|     35|    if (sock->endpoint &&
  ------------------
  |  Branch (1077:9): [True: 0, False: 35]
  ------------------
 1078|      0|        sock->endpoint->bind_addr.addr.sa.sa_family == AF_UNIX) {
  ------------------
  |  Branch (1078:9): [True: 0, False: 0]
  ------------------
 1079|       |      /* Clean up Unix endpoint */
 1080|       |#ifdef _WIN32
 1081|       |      _unlink(sock->endpoint->bind_addr.addr.cun.sun_path);
 1082|       |#else /* ! _WIN32 */
 1083|      0|      unlink(sock->endpoint->bind_addr.addr.cun.sun_path);
 1084|      0|#endif /* ! _WIN32 */
 1085|      0|    }
 1086|     35|#endif /* COAP_AF_UNIX_SUPPORT */
 1087|     35|    sock->endpoint = NULL;
 1088|     35|#endif /* COAP_SERVER_SUPPORT */
 1089|     35|#if COAP_CLIENT_SUPPORT
 1090|     35|#if COAP_AF_UNIX_SUPPORT
 1091|     35|    if (sock->session && sock->session->type == COAP_SESSION_TYPE_CLIENT &&
  ------------------
  |  Branch (1091:9): [True: 35, False: 0]
  |  Branch (1091:26): [True: 35, False: 0]
  ------------------
 1092|     35|        sock->session->addr_info.local.addr.sa.sa_family == AF_UNIX) {
  ------------------
  |  Branch (1092:9): [True: 0, False: 35]
  ------------------
 1093|       |      /* Clean up Unix endpoint */
 1094|       |#ifdef _WIN32
 1095|       |      _unlink(sock->session->addr_info.local.addr.cun.sun_path);
 1096|       |#else /* ! _WIN32 */
 1097|      0|      unlink(sock->session->addr_info.local.addr.cun.sun_path);
 1098|      0|#endif /* ! _WIN32 */
 1099|      0|    }
 1100|     35|#endif /* COAP_AF_UNIX_SUPPORT */
 1101|     35|#endif /* COAP_CLIENT_SUPPORT */
 1102|     35|    sock->session = NULL;
 1103|     35|    coap_closesocket(sock->fd);
  ------------------
  |  |   50|     35|#define coap_closesocket close
  ------------------
 1104|     35|    sock->fd = COAP_INVALID_SOCKET;
  ------------------
  |  |   52|     35|#define COAP_INVALID_SOCKET (-1)
  ------------------
 1105|     35|    sock->flags = COAP_SOCKET_EMPTY;
  ------------------
  |  |   74|     35|#define COAP_SOCKET_EMPTY        0x0000  /**< the socket is not used */
  ------------------
 1106|     35|  }
 1107|     35|}
coap_dgrm_posix.c:coap_test_cid_tuple_change:
  487|    216|coap_test_cid_tuple_change(coap_session_t *session) {
  488|    216|  if (session->type == COAP_SESSION_TYPE_CLIENT &&
  ------------------
  |  Branch (488:7): [True: 216, False: 0]
  ------------------
  489|    216|      session->negotiated_cid &&
  ------------------
  |  Branch (489:7): [True: 0, False: 216]
  ------------------
  490|      0|      session->state == COAP_SESSION_STATE_ESTABLISHED &&
  ------------------
  |  Branch (490:7): [True: 0, False: 0]
  ------------------
  491|      0|      session->proto == COAP_PROTO_DTLS && session->context->testing_cids) {
  ------------------
  |  Branch (491:7): [True: 0, False: 0]
  |  Branch (491:44): [True: 0, False: 0]
  ------------------
  492|      0|    if ((++cid_track_counter) % session->context->testing_cids == 0) {
  ------------------
  |  Branch (492:9): [True: 0, False: 0]
  ------------------
  493|      0|      coap_address_t local_if = session->addr_info.local;
  494|      0|      uint16_t port = coap_address_get_port(&local_if);
  495|       |
  496|      0|      port++;
  497|      0|      coap_address_set_port(&local_if, port);
  498|       |
  499|      0|      coap_socket_dgrm_close(&session->sock);
  500|      0|      session->sock.session = session;
  501|      0|      if (!coap_socket_connect_udp(&session->sock, &local_if, &session->addr_info.remote,
  ------------------
  |  Branch (501:11): [True: 0, False: 0]
  ------------------
  502|      0|                                   port,
  503|      0|                                   &session->addr_info.local,
  504|      0|                                   &session->addr_info.remote)) {
  505|      0|        coap_log_err("Tuple change for CID failed\n");
  ------------------
  |  |  102|      0|#define coap_log_err(...) coap_log(COAP_LOG_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  506|      0|        return;
  507|      0|#ifdef COAP_EPOLL_SUPPORT
  508|      0|      } else {
  509|      0|        coap_epoll_ctl_add(&session->sock,
  510|      0|                           EPOLLIN |
  511|      0|                           ((session->sock.flags & COAP_SOCKET_WANT_CONNECT) ?
  ------------------
  |  |   82|      0|#define COAP_SOCKET_WANT_CONNECT 0x0080  /**< non blocking client socket is waiting for connect */
  ------------------
  |  Branch (511:29): [True: 0, False: 0]
  ------------------
  512|      0|                            EPOLLOUT : 0),
  513|      0|                           __func__);
  514|      0|#endif /* COAP_EPOLL_SUPPORT */
  515|      0|      }
  516|      0|      session->sock.flags |= COAP_SOCKET_NOT_EMPTY | COAP_SOCKET_WANT_READ | COAP_SOCKET_BOUND;
  ------------------
  |  |   75|      0|#define COAP_SOCKET_NOT_EMPTY    0x0001  /**< the socket is not empty */
  ------------------
                    session->sock.flags |= COAP_SOCKET_NOT_EMPTY | COAP_SOCKET_WANT_READ | COAP_SOCKET_BOUND;
  ------------------
  |  |   79|      0|#define COAP_SOCKET_WANT_READ    0x0010  /**< non blocking socket is waiting for reading */
  ------------------
                    session->sock.flags |= COAP_SOCKET_NOT_EMPTY | COAP_SOCKET_WANT_READ | COAP_SOCKET_BOUND;
  ------------------
  |  |   76|      0|#define COAP_SOCKET_BOUND        0x0002  /**< the socket is bound */
  ------------------
  517|      0|    }
  518|      0|  }
  519|    216|}

coap_fls:
   21|  2.21k|coap_fls(unsigned int i) {
   22|  2.21k|  return coap_flsll(i);
   23|  2.21k|}
coap_flsll:
   28|  2.21k|coap_flsll(long long j) {
   29|  2.21k|  unsigned long long i = (unsigned long long)j;
   30|  2.21k|  int n;
   31|  18.1k|  for (n = 0; i; n++)
  ------------------
  |  Branch (31:15): [True: 15.9k, False: 2.21k]
  ------------------
   32|  15.9k|    i >>= 1;
   33|  2.21k|  return n;
   34|  2.21k|}
coap_decode_var_bytes:
   38|     76|coap_decode_var_bytes(const uint8_t *buf, size_t len) {
   39|     76|  unsigned int i, n = 0;
   40|    158|  for (i = 0; i < len; ++i)
  ------------------
  |  Branch (40:15): [True: 82, False: 76]
  ------------------
   41|     82|    n = (n << 8) + buf[i];
   42|       |
   43|     76|  return n;
   44|     76|}
coap_encode_var_safe:
   47|    143|coap_encode_var_safe(uint8_t *buf, size_t length, unsigned int val) {
   48|    143|  unsigned int n, i;
   49|       |
   50|    143|  if (val == 0)
  ------------------
  |  Branch (50:7): [True: 0, False: 143]
  ------------------
   51|      0|    return 0;
   52|       |
   53|    288|  for (n = 0, i = val; i && n < sizeof(val); ++n)
  ------------------
  |  Branch (53:24): [True: 145, False: 143]
  |  Branch (53:29): [True: 145, False: 0]
  ------------------
   54|    145|    i >>= 8;
   55|       |
   56|    143|  if (n > length) {
  ------------------
  |  Branch (56:7): [True: 0, False: 143]
  ------------------
   57|      0|    assert(n <= length);
  ------------------
  |  Branch (57:5): [True: 0, False: 0]
  ------------------
   58|      0|    return 0;
   59|      0|  }
   60|    143|  i = n;
   61|    288|  while (i) {
  ------------------
  |  Branch (61:10): [True: 145, False: 143]
  ------------------
   62|    145|    i--;
   63|    145|    buf[i] = val & 0xff;
   64|    145|    val >>= 8;
   65|    145|  }
   66|       |
   67|    143|  return n;
   68|    143|}

coap_register_event_handler:
   25|     35|                            coap_event_handler_t hnd) {
   26|     35|  context->event_cb = hnd;
   27|     35|}

coap_epoll_ctl_add:
   62|     35|                   const char *func) {
   63|     35|  int ret;
   64|     35|  struct epoll_event event;
   65|     35|  coap_context_t *context;
   66|       |
   67|       |#if COAP_MAX_LOGGING_LEVEL < _COAP_LOG_ERR
   68|       |  (void)func;
   69|       |#endif
   70|       |
   71|     35|  if (sock == NULL)
  ------------------
  |  Branch (71:7): [True: 0, False: 35]
  ------------------
   72|      0|    return;
   73|       |
   74|     35|#if COAP_SERVER_SUPPORT
   75|     35|  context = sock->session ? sock->session->context :
  ------------------
  |  Branch (75:13): [True: 35, False: 0]
  ------------------
   76|     35|            sock->endpoint ? sock->endpoint->context : NULL;
  ------------------
  |  Branch (76:13): [True: 0, False: 0]
  ------------------
   77|       |#else /* ! COAP_SERVER_SUPPORT */
   78|       |  context = sock->session ? sock->session->context : NULL;
   79|       |#endif /* ! COAP_SERVER_SUPPORT */
   80|     35|  if (context == NULL)
  ------------------
  |  Branch (80:7): [True: 0, False: 35]
  ------------------
   81|      0|    return;
   82|       |
   83|       |  /* Needed if running 32bit as ptr is only 32bit */
   84|     35|  memset(&event, 0, sizeof(event));
   85|     35|  event.events = events;
   86|     35|  event.data.ptr = sock;
   87|       |
   88|     35|  ret = epoll_ctl(context->epfd, EPOLL_CTL_ADD, sock->fd, &event);
   89|     35|  if (ret == -1) {
  ------------------
  |  Branch (89:7): [True: 0, False: 35]
  ------------------
   90|      0|    coap_log_err("%s: epoll_ctl ADD failed: %s (%d)\n",
  ------------------
  |  |  102|      0|#define coap_log_err(...) coap_log(COAP_LOG_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   91|      0|                 func,
   92|      0|                 coap_socket_strerror(), errno);
   93|      0|  }
   94|     35|}

coap_memory_init:
  623|     35|coap_memory_init(void) {
  624|     35|}
coap_malloc_type:
  627|  1.94k|coap_malloc_type(coap_memory_tag_t type, size_t size) {
  628|  1.94k|  void *ptr;
  629|       |
  630|  1.94k|  (void)type;
  631|  1.94k|  ptr = malloc(size);
  632|       |#if COAP_MEMORY_TYPE_TRACK
  633|       |  assert(type < COAP_MEM_TAG_LAST);
  634|       |  if (ptr) {
  635|       |    track_counts[type]++;
  636|       |    if (track_counts[type] > peak_counts[type])
  637|       |      peak_counts[type] = track_counts[type];
  638|       |  } else {
  639|       |    fail_counts[type]++;
  640|       |  }
  641|       |#endif /* COAP_MEMORY_TYPE_TRACK */
  642|  1.94k|  return ptr;
  643|  1.94k|}
coap_free_type:
  666|  3.05k|coap_free_type(coap_memory_tag_t type, void *p) {
  667|  3.05k|  (void)type;
  668|       |#if COAP_MEMORY_TYPE_TRACK
  669|       |  assert(type < COAP_MEM_TAG_LAST);
  670|       |  if (p)
  671|       |    track_counts[type]--;
  672|       |#endif /* COAP_MEMORY_TYPE_TRACK */
  673|  3.05k|  free(p);
  674|  3.05k|}
coap_dump_memory_type_counts:
  735|     35|coap_dump_memory_type_counts(coap_log_t level) {
  736|       |#if COAP_MEMORY_TYPE_TRACK
  737|       |  int i;
  738|       |
  739|       |  coap_log(level, "*  Memory type counts\n");
  740|       |  for (i = 0; i < COAP_MEM_TAG_LAST; i++) {
  741|       |    const char *name = "?";
  742|       |
  743|       |
  744|       |    switch (i) {
  745|       |      MAKE_CASE(COAP_STRING);
  746|       |      MAKE_CASE(COAP_ATTRIBUTE_NAME);
  747|       |      MAKE_CASE(COAP_ATTRIBUTE_VALUE);
  748|       |      MAKE_CASE(COAP_PACKET);
  749|       |      MAKE_CASE(COAP_NODE);
  750|       |      MAKE_CASE(COAP_CONTEXT);
  751|       |      MAKE_CASE(COAP_ENDPOINT);
  752|       |      MAKE_CASE(COAP_PDU);
  753|       |      MAKE_CASE(COAP_PDU_BUF);
  754|       |      MAKE_CASE(COAP_RESOURCE);
  755|       |      MAKE_CASE(COAP_RESOURCEATTR);
  756|       |      MAKE_CASE(COAP_DTLS_SESSION);
  757|       |      MAKE_CASE(COAP_SESSION);
  758|       |      MAKE_CASE(COAP_OPTLIST);
  759|       |      MAKE_CASE(COAP_CACHE_KEY);
  760|       |      MAKE_CASE(COAP_CACHE_ENTRY);
  761|       |      MAKE_CASE(COAP_LG_XMIT);
  762|       |      MAKE_CASE(COAP_LG_CRCV);
  763|       |      MAKE_CASE(COAP_LG_SRCV);
  764|       |      MAKE_CASE(COAP_DIGEST_CTX);
  765|       |      MAKE_CASE(COAP_SUBSCRIPTION);
  766|       |      MAKE_CASE(COAP_DTLS_CONTEXT);
  767|       |      MAKE_CASE(COAP_OSCORE_COM);
  768|       |      MAKE_CASE(COAP_OSCORE_SEN);
  769|       |      MAKE_CASE(COAP_OSCORE_REC);
  770|       |      MAKE_CASE(COAP_OSCORE_EX);
  771|       |      MAKE_CASE(COAP_OSCORE_EP);
  772|       |      MAKE_CASE(COAP_OSCORE_BUF);
  773|       |      MAKE_CASE(COAP_COSE);
  774|       |    case COAP_MEM_TAG_LAST:
  775|       |    default:
  776|       |      break;
  777|       |    }
  778|       |    coap_log(level, "*    %-20s in-use %3d peak %3d failed %2d\n",
  779|       |             name, track_counts[i], peak_counts[i], fail_counts[i]);
  780|       |  }
  781|       |#else /* COAP_MEMORY_TYPE_TRACK */
  782|     35|  (void)level;
  783|     35|#endif /* COAP_MEMORY_TYPE_TRACK */
  784|     35|}

coap_delete_node_lkd:
  206|    103|coap_delete_node_lkd(coap_queue_t *node) {
  207|    103|  if (!node)
  ------------------
  |  Branch (207:7): [True: 103, False: 0]
  ------------------
  208|    103|    return 0;
  209|       |
  210|      0|  coap_delete_pdu_lkd(node->pdu);
  211|      0|  if (node->session) {
  ------------------
  |  Branch (211:7): [True: 0, False: 0]
  ------------------
  212|       |    /*
  213|       |     * Need to remove out of context->sendqueue as added in by coap_wait_ack()
  214|       |     */
  215|      0|    if (node->session->context->sendqueue) {
  ------------------
  |  Branch (215:9): [True: 0, False: 0]
  ------------------
  216|      0|      LL_DELETE(node->session->context->sendqueue, node);
  ------------------
  |  |  391|      0|    LL_DELETE2(head,del,next)
  |  |  ------------------
  |  |  |  |  393|      0|#define LL_DELETE2(head,del,next)                                                              \
  |  |  |  |  394|      0|do {                                                                                           \
  |  |  |  |  395|      0|  LDECLTYPE(head) _tmp;                                                                        \
  |  |  |  |  ------------------
  |  |  |  |  |  |   81|      0|#define LDECLTYPE(x) __typeof(x)
  |  |  |  |  ------------------
  |  |  |  |  396|      0|  if ((head) == (del)) {                                                                       \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (396:7): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  397|      0|    (head)=(head)->next;                                                                       \
  |  |  |  |  398|      0|  } else {                                                                                     \
  |  |  |  |  399|      0|    _tmp = (head);                                                                             \
  |  |  |  |  400|      0|    while (_tmp->next && (_tmp->next != (del))) {                                              \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (400:12): [True: 0, False: 0]
  |  |  |  |  |  Branch (400:26): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  401|      0|      _tmp = _tmp->next;                                                                       \
  |  |  |  |  402|      0|    }                                                                                          \
  |  |  |  |  403|      0|    if (_tmp->next) {                                                                          \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (403:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  404|      0|      _tmp->next = (del)->next;                                                                \
  |  |  |  |  405|      0|    }                                                                                          \
  |  |  |  |  406|      0|  }                                                                                            \
  |  |  |  |  407|      0|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (407:10): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  217|      0|    }
  218|      0|    coap_session_release_lkd(node->session);
  219|      0|  }
  220|      0|  coap_free_node(node);
  221|       |
  222|      0|  return 1;
  223|    103|}
coap_delete_all:
  226|     35|coap_delete_all(coap_queue_t *queue) {
  227|     35|  if (!queue)
  ------------------
  |  Branch (227:7): [True: 35, False: 0]
  ------------------
  228|     35|    return;
  229|       |
  230|      0|  coap_delete_all(queue->next);
  231|      0|  coap_delete_node_lkd(queue);
  232|      0|}
coap_new_context:
  737|     35|coap_new_context(const coap_address_t *listen_addr) {
  738|     35|  coap_context_t *c;
  739|       |
  740|       |#if ! COAP_SERVER_SUPPORT
  741|       |  (void)listen_addr;
  742|       |#endif /* COAP_SERVER_SUPPORT */
  743|       |
  744|     35|  if (!coap_started) {
  ------------------
  |  Branch (744:7): [True: 0, False: 35]
  ------------------
  745|      0|    coap_startup();
  746|      0|    coap_log_warn("coap_startup() should be called before any other "
  ------------------
  |  |  108|      0|#define coap_log_warn(...) coap_log(COAP_LOG_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  747|      0|                  "coap_*() functions are called\n");
  748|      0|  }
  749|       |
  750|     35|  c = coap_malloc_type(COAP_CONTEXT, sizeof(coap_context_t));
  751|     35|  if (!c) {
  ------------------
  |  Branch (751:7): [True: 0, False: 35]
  ------------------
  752|      0|    coap_log_emerg("coap_init: malloc: failed\n");
  ------------------
  |  |   87|      0|#define coap_log_emerg(...) coap_log(COAP_LOG_EMERG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  753|      0|    return NULL;
  754|      0|  }
  755|     35|  memset(c, 0, sizeof(coap_context_t));
  756|       |
  757|     35|  coap_lock_lock(coap_free_type(COAP_CONTEXT, c); return NULL);
  758|     35|#ifdef COAP_EPOLL_SUPPORT
  759|     35|  c->epfd = epoll_create1(0);
  760|     35|  if (c->epfd == -1) {
  ------------------
  |  Branch (760:7): [True: 0, False: 35]
  ------------------
  761|      0|    coap_log_err("coap_new_context: Unable to epoll_create: %s (%d)\n",
  ------------------
  |  |  102|      0|#define coap_log_err(...) coap_log(COAP_LOG_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  762|      0|                 coap_socket_strerror(),
  763|      0|                 errno);
  764|      0|    goto onerror;
  765|      0|  }
  766|     35|  if (c->epfd != -1) {
  ------------------
  |  Branch (766:7): [True: 35, False: 0]
  ------------------
  767|     35|    c->eptimerfd = timerfd_create(CLOCK_REALTIME, TFD_NONBLOCK);
  768|     35|    if (c->eptimerfd == -1) {
  ------------------
  |  Branch (768:9): [True: 0, False: 35]
  ------------------
  769|      0|      coap_log_err("coap_new_context: Unable to timerfd_create: %s (%d)\n",
  ------------------
  |  |  102|      0|#define coap_log_err(...) coap_log(COAP_LOG_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  770|      0|                   coap_socket_strerror(),
  771|      0|                   errno);
  772|      0|      goto onerror;
  773|     35|    } else {
  774|     35|      int ret;
  775|     35|      struct epoll_event event;
  776|       |
  777|       |      /* Needed if running 32bit as ptr is only 32bit */
  778|     35|      memset(&event, 0, sizeof(event));
  779|     35|      event.events = EPOLLIN;
  780|       |      /* We special case this event by setting to NULL */
  781|     35|      event.data.ptr = NULL;
  782|       |
  783|     35|      ret = epoll_ctl(c->epfd, EPOLL_CTL_ADD, c->eptimerfd, &event);
  784|     35|      if (ret == -1) {
  ------------------
  |  Branch (784:11): [True: 0, False: 35]
  ------------------
  785|      0|        coap_log_err("%s: epoll_ctl ADD failed: %s (%d)\n",
  ------------------
  |  |  102|      0|#define coap_log_err(...) coap_log(COAP_LOG_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  786|      0|                     "coap_new_context",
  787|      0|                     coap_socket_strerror(), errno);
  788|      0|        goto onerror;
  789|      0|      }
  790|     35|    }
  791|     35|  }
  792|     35|#endif /* COAP_EPOLL_SUPPORT */
  793|       |
  794|     35|  if (coap_dtls_is_supported() || coap_tls_is_supported()) {
  ------------------
  |  Branch (794:7): [True: 35, False: 0]
  |  Branch (794:35): [True: 0, False: 0]
  ------------------
  795|     35|    c->dtls_context = coap_dtls_new_context(c);
  796|     35|    if (!c->dtls_context) {
  ------------------
  |  Branch (796:9): [True: 0, False: 35]
  ------------------
  797|      0|      coap_log_emerg("coap_init: no DTLS context available\n");
  ------------------
  |  |   87|      0|#define coap_log_emerg(...) coap_log(COAP_LOG_EMERG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  798|      0|      goto onerror;
  799|      0|    }
  800|     35|  }
  801|       |
  802|       |  /* set default CSM values */
  803|     35|  c->csm_timeout_ms = 1000;
  804|     35|  c->csm_max_message_size = COAP_DEFAULT_MAX_PDU_RX_SIZE;
  ------------------
  |  |   84|     35|#define COAP_DEFAULT_MAX_PDU_RX_SIZE (8UL*1024*1024+256)
  ------------------
  805|       |
  806|     35|#if COAP_SERVER_SUPPORT
  807|     35|  if (listen_addr) {
  ------------------
  |  Branch (807:7): [True: 0, False: 35]
  ------------------
  808|      0|    coap_endpoint_t *endpoint = coap_new_endpoint_lkd(c, listen_addr, COAP_PROTO_UDP);
  809|      0|    if (endpoint == NULL) {
  ------------------
  |  Branch (809:9): [True: 0, False: 0]
  ------------------
  810|      0|      goto onerror;
  811|      0|    }
  812|      0|  }
  813|     35|#endif /* COAP_SERVER_SUPPORT */
  814|       |
  815|     35|  c->max_token_size = COAP_TOKEN_DEFAULT_MAX; /* RFC8974 */
  ------------------
  |  |   58|     35|#define COAP_TOKEN_DEFAULT_MAX 8
  ------------------
  816|     35|#if COAP_ASYNC_SUPPORT
  817|     35|  c->max_async = COAP_ASYNC_MAX_CONTEXT;
  ------------------
  |  |   28|     35|#define COAP_ASYNC_MAX_CONTEXT 64
  ------------------
  818|     35|  c->max_async_per_session = COAP_ASYNC_MAX_SESSION;
  ------------------
  |  |   31|     35|#define COAP_ASYNC_MAX_SESSION 8
  ------------------
  819|     35|#endif /* COAP_ASYNC_SUPPORT */
  820|       |
  821|       |#if defined(WITH_LWIP)
  822|       |#if NO_SYS == 0
  823|       |  if (sys_sem_new(&c->coap_io_timeout_sem, 0) != ERR_OK)
  824|       |    coap_log_warn("coap_new_context: Failed to set up semaphore\n");
  825|       |#endif /* NO_SYS == 0 */
  826|       |#endif /* ! WITH_LWIP */
  827|     35|  coap_lock_unlock();
  828|     35|  return c;
  829|       |
  830|      0|onerror:
  831|      0|  coap_lock_unlock();
  832|      0|  coap_free_type(COAP_CONTEXT, c);
  833|       |  return NULL;
  834|     35|}
coap_free_context:
  851|     35|coap_free_context(coap_context_t *context) {
  852|     35|  if (!context)
  ------------------
  |  Branch (852:7): [True: 0, False: 35]
  ------------------
  853|      0|    return;
  854|     35|  coap_lock_lock(return);
  855|     35|  coap_free_context_lkd(context);
  856|     35|  coap_lock_unlock();
  857|     35|}
coap_free_context_lkd:
  860|     35|coap_free_context_lkd(coap_context_t *context) {
  861|     35|  if (!context)
  ------------------
  |  Branch (861:7): [True: 0, False: 35]
  ------------------
  862|      0|    return;
  863|       |
  864|     35|  coap_lock_check_locked();
  ------------------
  |  |  638|     35|#define coap_lock_check_locked() {}
  ------------------
  865|     35|#if COAP_SERVER_SUPPORT
  866|       |  /* Removing a resource may cause a NON unsolicited observe to be sent */
  867|     35|  context->context_going_away = 1;
  868|     35|  if (context->shutdown_no_send_observe)
  ------------------
  |  Branch (868:7): [True: 0, False: 35]
  ------------------
  869|      0|    context->observe_no_clear = 1;
  870|     35|  coap_delete_all_resources(context);
  871|     35|#endif /* COAP_SERVER_SUPPORT */
  872|     35|#if COAP_CLIENT_SUPPORT
  873|       |  /* Stop any attempts at reconnection */
  874|     35|  context->reconnect_time = 0;
  875|     35|#endif /* COAP_CLIENT_SUPPORT */
  876|       |
  877|     35|  coap_delete_all(context->sendqueue);
  878|     35|  context->sendqueue = NULL;
  879|       |
  880|       |#ifdef WITH_LWIP
  881|       |  if (context->timer_configured) {
  882|       |    LOCK_TCPIP_CORE();
  883|       |    sys_untimeout(coap_io_process_timeout, (void *)context);
  884|       |    UNLOCK_TCPIP_CORE();
  885|       |    context->timer_configured = 0;
  886|       |  }
  887|       |#endif /* WITH_LWIP */
  888|       |
  889|     35|#if COAP_ASYNC_SUPPORT
  890|     35|  coap_delete_all_async(context);
  891|     35|#endif /* COAP_ASYNC_SUPPORT */
  892|       |
  893|     35|#if COAP_SERVER_SUPPORT
  894|     35|  coap_cache_entry_t *cp, *ctmp;
  895|     35|  coap_endpoint_t *ep, *tmp;
  896|       |
  897|     35|  HASH_ITER(hh, context->cache, cp, ctmp) {
  ------------------
  |  | 1071|     35|#define HASH_ITER(hh,head,el,tmp)                                                \
  |  | 1072|     35|for(((el)=(head)), ((tmp)=DECLTYPE(el)((head!=NULL)?(head)->hh.next:NULL));      \
  |  |  ------------------
  |  |  |  |   66|     35|#define DECLTYPE(x) (__typeof(x))
  |  |  ------------------
  |  |  |  Branch (1072:40): [True: 0, False: 35]
  |  |  ------------------
  |  | 1073|     35|  (el) != NULL; ((el)=(tmp)), ((tmp)=DECLTYPE(el)((tmp!=NULL)?(tmp)->hh.next:NULL)))
  |  |  ------------------
  |  |  |  |   66|      0|#define DECLTYPE(x) (__typeof(x))
  |  |  ------------------
  |  |  |  Branch (1073:3): [True: 0, False: 35]
  |  |  |  Branch (1073:51): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  898|      0|    coap_delete_cache_entry(context, cp);
  899|      0|  }
  900|     35|  if (context->cache_ignore_count) {
  ------------------
  |  Branch (900:7): [True: 0, False: 35]
  ------------------
  901|      0|    coap_free_type(COAP_STRING, context->cache_ignore_options);
  902|      0|  }
  903|       |
  904|     35|  LL_FOREACH_SAFE(context->endpoint, ep, tmp) {
  ------------------
  |  |  425|     35|    LL_FOREACH_SAFE2(head,el,tmp,next)
  |  |  ------------------
  |  |  |  |  428|     35|  for ((el) = (head); (el) && ((tmp) = (el)->next, 1); (el) = (tmp))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (428:23): [True: 0, False: 35]
  |  |  |  |  |  Branch (428:31): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  905|      0|    coap_free_endpoint_lkd(ep);
  906|      0|  }
  907|     35|#endif /* COAP_SERVER_SUPPORT */
  908|       |
  909|     35|#if COAP_CLIENT_SUPPORT
  910|     35|  coap_session_t *sp, *rtmp;
  911|       |
  912|     35|  SESSIONS_ITER_CL_SAFE(context->sessions, sp, rtmp) {
  ------------------
  |  | 1074|     35|  for ((el) = (e),                           \
  |  | 1075|     35|       (rtmp) = (el) ? (el)->hh.next : NULL; \
  |  |  ------------------
  |  |  |  Branch (1075:17): [True: 35, False: 0]
  |  |  ------------------
  |  | 1076|     70|       (el);                                 \
  |  |  ------------------
  |  |  |  Branch (1076:8): [True: 35, False: 35]
  |  |  ------------------
  |  | 1077|     35|       (el) = coap_get_next_session_cl((e), (el), &(rtmp)))
  ------------------
  913|     35|    coap_session_release_lkd(sp);
  914|     35|  }
  915|     35|#endif /* COAP_CLIENT_SUPPORT */
  916|       |
  917|     35|#if COAP_OSCORE_SUPPORT
  918|     35|  coap_delete_all_oscore(context);
  919|     35|#endif /* COAP_OSCORE_SUPPORT */
  920|       |
  921|     35|  if (context->dtls_context)
  ------------------
  |  Branch (921:7): [True: 35, False: 0]
  ------------------
  922|     35|    coap_dtls_free_context(context->dtls_context);
  923|     35|#ifdef COAP_EPOLL_SUPPORT
  924|     35|  if (context->eptimerfd != -1) {
  ------------------
  |  Branch (924:7): [True: 35, False: 0]
  ------------------
  925|     35|    int ret;
  926|     35|    struct epoll_event event;
  927|       |
  928|       |    /* Kernels prior to 2.6.9 expect non NULL event parameter */
  929|     35|    ret = epoll_ctl(context->epfd, EPOLL_CTL_DEL, context->eptimerfd, &event);
  930|     35|    if (ret == -1) {
  ------------------
  |  Branch (930:9): [True: 0, False: 35]
  ------------------
  931|      0|      coap_log_err("%s: epoll_ctl DEL failed: %s (%d)\n",
  ------------------
  |  |  102|      0|#define coap_log_err(...) coap_log(COAP_LOG_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  932|      0|                   "coap_free_context",
  933|      0|                   coap_socket_strerror(), errno);
  934|      0|    }
  935|     35|    close(context->eptimerfd);
  936|     35|    context->eptimerfd = -1;
  937|     35|  }
  938|     35|  if (context->epfd != -1) {
  ------------------
  |  Branch (938:7): [True: 35, False: 0]
  ------------------
  939|     35|    close(context->epfd);
  940|     35|    context->epfd = -1;
  941|     35|  }
  942|     35|#endif /* COAP_EPOLL_SUPPORT */
  943|     35|#if COAP_SERVER_SUPPORT
  944|     35|#if COAP_WITH_OBSERVE_PERSIST
  945|     35|  coap_persist_cleanup(context);
  946|     35|#endif /* COAP_WITH_OBSERVE_PERSIST */
  947|     35|#endif /* COAP_SERVER_SUPPORT */
  948|     35|#if COAP_PROXY_SUPPORT
  949|     35|  coap_proxy_cleanup(context);
  950|     35|#endif /* COAP_PROXY_SUPPORT */
  951|       |
  952|     35|  if (context->app_cb) {
  ------------------
  |  Branch (952:7): [True: 0, False: 35]
  ------------------
  953|      0|    coap_lock_callback(context->app_cb(context->app_data));
  ------------------
  |  |  651|      0|#define coap_lock_callback(func) func
  ------------------
  954|      0|  }
  955|       |#if defined(WITH_LWIP)
  956|       |#if NO_SYS == 0
  957|       |  sys_sem_free(&context->coap_io_timeout_sem);
  958|       |#endif /* NO_SYS == 0 */
  959|       |#endif /* ! WITH_LWIP */
  960|       |#if COAP_THREAD_SAFE && !WITH_LWIP
  961|       |  coap_io_process_remove_threads_lkd(context);
  962|       |#endif /* COAP_THREAD_SAFE && !WITH_LWIP */
  963|     35|  coap_free_type(COAP_CONTEXT, context);
  964|     35|  coap_dump_memory_type_counts(COAP_LOG_DEBUG);
  965|     35|}
coap_option_check_critical:
 1040|    203|                           coap_crit_type_t is_proxy) {
 1041|    203|  coap_context_t *ctx = session->context;
 1042|    203|  coap_opt_iterator_t opt_iter;
 1043|    203|  coap_opt_t *option;
 1044|    203|  int ok = 1;
 1045|    203|  coap_option_num_t last_number = -1;
 1046|       |
 1047|    203|  coap_option_iterator_init(pdu, &opt_iter, COAP_OPT_ALL);
  ------------------
  |  |  230|    203|#define COAP_OPT_ALL NULL
  ------------------
 1048|       |
 1049|    619|  while ((option = coap_option_next(&opt_iter))) {
  ------------------
  |  Branch (1049:10): [True: 417, False: 202]
  ------------------
 1050|       |    /* Check for explicitly reserved option RFC 5272 12.2 Table 7 */
 1051|       |    /* Need to check reserved options */
 1052|    417|    switch (opt_iter.number) {
 1053|      0|    case 0:
  ------------------
  |  Branch (1053:5): [True: 0, False: 417]
  ------------------
 1054|      0|    case 128:
  ------------------
  |  Branch (1054:5): [True: 0, False: 417]
  ------------------
 1055|      0|    case 132:
  ------------------
  |  Branch (1055:5): [True: 0, False: 417]
  ------------------
 1056|      0|    case 136:
  ------------------
  |  Branch (1056:5): [True: 0, False: 417]
  ------------------
 1057|      0|    case 140:
  ------------------
  |  Branch (1057:5): [True: 0, False: 417]
  ------------------
 1058|      0|      if (coap_option_filter_get(&ctx->known_options, opt_iter.number) <= 0) {
  ------------------
  |  Branch (1058:11): [True: 0, False: 0]
  ------------------
 1059|      0|        coap_log_debug("Unknown reserved option %d\n", opt_iter.number);
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1060|      0|        ok = 0;
 1061|       |
 1062|       |        /* When opt_iter.number cannot be set in unknown, all of the appropriate
 1063|       |         * slots have been used up and no more options can be tracked.
 1064|       |         * Safe to break out of this loop as ok is already set. */
 1065|      0|        if (coap_option_filter_set(unknown, opt_iter.number) == 0) {
  ------------------
  |  Branch (1065:13): [True: 0, False: 0]
  ------------------
 1066|      0|          goto overflow;
 1067|      0|        }
 1068|      0|      }
 1069|      0|      break;
 1070|    417|    default:
  ------------------
  |  Branch (1070:5): [True: 417, False: 0]
  ------------------
 1071|    417|      break;
 1072|    417|    }
 1073|    417|    if (opt_iter.number & 0x01) {
  ------------------
  |  Branch (1073:9): [True: 226, False: 191]
  ------------------
 1074|       |      /* first check the known built-in critical options */
 1075|    226|      switch (opt_iter.number) {
 1076|      0|#if COAP_Q_BLOCK_SUPPORT
 1077|      0|      case COAP_OPTION_Q_BLOCK1:
  ------------------
  |  Branch (1077:7): [True: 0, False: 226]
  ------------------
 1078|      0|      case COAP_OPTION_Q_BLOCK2:
  ------------------
  |  Branch (1078:7): [True: 0, False: 226]
  ------------------
 1079|      0|        if (!(ctx->block_mode & COAP_BLOCK_TRY_Q_BLOCK)) {
  ------------------
  |  |   67|      0|#define COAP_BLOCK_TRY_Q_BLOCK   0x04 /* Try Q-Block method */
  ------------------
  |  Branch (1079:13): [True: 0, False: 0]
  ------------------
 1080|      0|          coap_log_debug("Critical option '%s' (%d) disabled - not supported\n",
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1081|      0|                         coap_option_string(pdu->code, opt_iter.number), opt_iter.number);
 1082|      0|          ok = 0;
 1083|       |          /* When opt_iter.number cannot be set in unknown, all of the appropriate
 1084|       |           * slots have been used up and no more options can be tracked.
 1085|       |           * Safe to break out of this loop as ok is already set. */
 1086|      0|          if (coap_option_filter_set(unknown, opt_iter.number) == 0) {
  ------------------
  |  Branch (1086:15): [True: 0, False: 0]
  ------------------
 1087|      0|            goto overflow;
 1088|      0|          }
 1089|      0|        }
 1090|      0|        break;
 1091|      0|#endif /* COAP_Q_BLOCK_SUPPORT */
 1092|      0|      case COAP_OPTION_IF_MATCH:
  ------------------
  |  Branch (1092:7): [True: 0, False: 226]
  ------------------
 1093|      0|      case COAP_OPTION_URI_HOST:
  ------------------
  |  Branch (1093:7): [True: 0, False: 226]
  ------------------
 1094|      0|      case COAP_OPTION_IF_NONE_MATCH:
  ------------------
  |  Branch (1094:7): [True: 0, False: 226]
  ------------------
 1095|      0|      case COAP_OPTION_URI_PORT:
  ------------------
  |  Branch (1095:7): [True: 0, False: 226]
  ------------------
 1096|    196|      case COAP_OPTION_URI_PATH:
  ------------------
  |  Branch (1096:7): [True: 196, False: 30]
  ------------------
 1097|    198|      case COAP_OPTION_URI_PATH_ABB:
  ------------------
  |  Branch (1097:7): [True: 2, False: 224]
  ------------------
 1098|    202|      case COAP_OPTION_URI_QUERY:
  ------------------
  |  Branch (1098:7): [True: 4, False: 222]
  ------------------
 1099|    204|      case COAP_OPTION_ACCEPT:
  ------------------
  |  Branch (1099:7): [True: 2, False: 224]
  ------------------
 1100|    208|      case COAP_OPTION_BLOCK2:
  ------------------
  |  Branch (1100:7): [True: 4, False: 222]
  ------------------
 1101|    210|      case COAP_OPTION_BLOCK1:
  ------------------
  |  Branch (1101:7): [True: 2, False: 224]
  ------------------
 1102|    210|      case COAP_OPTION_PROXY_URI:
  ------------------
  |  Branch (1102:7): [True: 0, False: 226]
  ------------------
 1103|    210|      case COAP_OPTION_PROXY_SCHEME:
  ------------------
  |  Branch (1103:7): [True: 0, False: 226]
  ------------------
 1104|    210|        break;
 1105|      0|      case COAP_OPTION_OSCORE:
  ------------------
  |  Branch (1105:7): [True: 0, False: 226]
  ------------------
 1106|       |        /* Valid critical if doing OSCORE */
 1107|      0|#if COAP_OSCORE_SUPPORT
 1108|       |        /* Generally configured or has coap oscore enabled helper function */
 1109|      0|        if (ctx->p_osc_ctx || ctx->oscore_find_cb)
  ------------------
  |  Branch (1109:13): [True: 0, False: 0]
  |  Branch (1109:31): [True: 0, False: 0]
  ------------------
 1110|      0|          break;
 1111|      0|#endif /* COAP_OSCORE_SUPPORT */
 1112|       |      /* Fall Through */
 1113|     16|      default:
  ------------------
  |  Branch (1113:7): [True: 16, False: 210]
  ------------------
 1114|     16|        if (coap_option_filter_get(&ctx->known_options, opt_iter.number) <= 0) {
  ------------------
  |  Branch (1114:13): [True: 16, False: 0]
  ------------------
 1115|     16|#if COAP_SERVER_SUPPORT
 1116|     16|          if ((opt_iter.number & 0x02) == 0) {
  ------------------
  |  Branch (1116:15): [True: 12, False: 4]
  ------------------
 1117|       |            /* Safe to forward critical? - check if proxy pdu */
 1118|     12|            if (is_proxy == COAP_CRIT_UNKNOWN) {
  ------------------
  |  Branch (1118:17): [True: 0, False: 12]
  ------------------
 1119|      0|              is_proxy = coap_is_session_proxy(session, pdu);
 1120|      0|            }
 1121|     12|            if (is_proxy == COAP_CRIT_PROXY) {
  ------------------
  |  Branch (1121:17): [True: 0, False: 12]
  ------------------
 1122|      0|              pdu->crit_opt = 1;
 1123|      0|              break;
 1124|      0|            }
 1125|     12|          }
 1126|     16|#endif /* COAP_SERVER_SUPPORT */
 1127|     16|          coap_log_debug("Critical option %u dropped\n", opt_iter.number);
  ------------------
  |  |  126|     16|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|     16|#define coap_log(level, ...) do { \
  |  |  |  |  291|     16|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 16]
  |  |  |  |  ------------------
  |  |  |  |  292|     16|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|     16|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 16]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1128|     16|          ok = 0;
 1129|       |
 1130|       |          /* When opt_iter.number cannot be set in unknown, all of the appropriate
 1131|       |           * slots have been used up and no more options can be tracked.
 1132|       |           * Safe to break out of this loop as ok is already set. */
 1133|     16|          if (coap_option_filter_set(unknown, opt_iter.number) == 0) {
  ------------------
  |  Branch (1133:15): [True: 1, False: 15]
  ------------------
 1134|      1|            goto overflow;
 1135|      1|          }
 1136|     16|        }
 1137|    226|      }
 1138|    226|    }
 1139|    416|    if (opt_iter.number & 0x02) {
  ------------------
  |  Branch (1139:9): [True: 362, False: 54]
  ------------------
 1140|       |      /* Check for safe to forward for a proxy */
 1141|    362|      if (is_proxy == COAP_CRIT_UNKNOWN) {
  ------------------
  |  Branch (1141:11): [True: 197, False: 165]
  ------------------
 1142|    197|        is_proxy = coap_is_session_proxy(session, pdu);
 1143|    197|      }
 1144|    362|      if (is_proxy == COAP_CRIT_PROXY) {
  ------------------
  |  Branch (1144:11): [True: 0, False: 362]
  ------------------
 1145|      0|        switch (opt_iter.number) {
 1146|      0|        case COAP_OPTION_URI_HOST:
  ------------------
  |  Branch (1146:9): [True: 0, False: 0]
  ------------------
 1147|      0|        case COAP_OPTION_OBSERVE:
  ------------------
  |  Branch (1147:9): [True: 0, False: 0]
  ------------------
 1148|      0|        case COAP_OPTION_URI_PORT:
  ------------------
  |  Branch (1148:9): [True: 0, False: 0]
  ------------------
 1149|      0|        case COAP_OPTION_URI_PATH:
  ------------------
  |  Branch (1149:9): [True: 0, False: 0]
  ------------------
 1150|      0|        case COAP_OPTION_MAXAGE:
  ------------------
  |  Branch (1150:9): [True: 0, False: 0]
  ------------------
 1151|      0|        case COAP_OPTION_URI_QUERY:
  ------------------
  |  Branch (1151:9): [True: 0, False: 0]
  ------------------
 1152|      0|        case COAP_OPTION_Q_BLOCK1:
  ------------------
  |  Branch (1152:9): [True: 0, False: 0]
  ------------------
 1153|      0|        case COAP_OPTION_BLOCK2:
  ------------------
  |  Branch (1153:9): [True: 0, False: 0]
  ------------------
 1154|      0|        case COAP_OPTION_BLOCK1:
  ------------------
  |  Branch (1154:9): [True: 0, False: 0]
  ------------------
 1155|      0|        case COAP_OPTION_Q_BLOCK2:
  ------------------
  |  Branch (1155:9): [True: 0, False: 0]
  ------------------
 1156|      0|        case COAP_OPTION_PROXY_URI:
  ------------------
  |  Branch (1156:9): [True: 0, False: 0]
  ------------------
 1157|      0|        case COAP_OPTION_PROXY_SCHEME:
  ------------------
  |  Branch (1157:9): [True: 0, False: 0]
  ------------------
 1158|      0|          break;
 1159|      0|        default:
  ------------------
  |  Branch (1159:9): [True: 0, False: 0]
  ------------------
 1160|      0|          coap_log_debug("Not Safe option %u cannot be forwarded - dropped\n",
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1161|      0|                         opt_iter.number);
 1162|      0|          ok = 0;
 1163|       |
 1164|       |          /* When opt_iter.number cannot be set in unknown, all of the appropriate
 1165|       |           * slots have been used up and no more options can be tracked.
 1166|       |           * Safe to break out of this loop as ok is already set. */
 1167|      0|          if (coap_option_filter_set(unknown, opt_iter.number) == 0) {
  ------------------
  |  Branch (1167:15): [True: 0, False: 0]
  ------------------
 1168|      0|            goto overflow;
 1169|      0|          }
 1170|      0|        }
 1171|      0|      }
 1172|    362|    }
 1173|    416|    if (last_number == opt_iter.number) {
  ------------------
  |  Branch (1173:9): [True: 30, False: 386]
  ------------------
 1174|       |      /* Check for duplicated option RFC 5272 5.4.5 */
 1175|     30|      if (!coap_option_check_repeatable(pdu, opt_iter.number)) {
  ------------------
  |  Branch (1175:11): [True: 0, False: 30]
  ------------------
 1176|      0|        if (coap_option_filter_get(&ctx->known_options, opt_iter.number) <= 0) {
  ------------------
  |  Branch (1176:13): [True: 0, False: 0]
  ------------------
 1177|      0|          if (opt_iter.number & 0x01) {
  ------------------
  |  Branch (1177:15): [True: 0, False: 0]
  ------------------
 1178|      0|            ok = 0;
 1179|      0|            if (coap_option_filter_set(unknown, opt_iter.number) == 0) {
  ------------------
  |  Branch (1179:17): [True: 0, False: 0]
  ------------------
 1180|      0|              goto overflow;
 1181|      0|            }
 1182|      0|          } else {
 1183|      0|            size_t opt_size = opt_iter.next_option - option;
 1184|       |
 1185|       |            /* RFC 7252 5.4.5: ignore supernumerary elective options.
 1186|       |             * A duplicate has delta zero, so the next delta is unchanged. */
 1187|      0|            memmove(option, opt_iter.next_option, opt_iter.length);
 1188|      0|            pdu->used_size -= opt_size;
 1189|      0|            if (pdu->data)
  ------------------
  |  Branch (1189:17): [True: 0, False: 0]
  ------------------
 1190|      0|              pdu->data -= opt_size;
 1191|      0|            opt_iter.next_option = option;
 1192|      0|          }
 1193|      0|        }
 1194|      0|      }
 1195|    386|    } else if (opt_iter.number == COAP_OPTION_BLOCK2 &&
  ------------------
  |  Branch (1195:16): [True: 4, False: 382]
  ------------------
 1196|      4|               COAP_PDU_IS_REQUEST(pdu)) {
  ------------------
  |  |   99|      4|#define COAP_PDU_IS_REQUEST(pdu)   (!COAP_PDU_IS_EMPTY(pdu) && (pdu)->code < 32)
  |  |  ------------------
  |  |  |  |   98|      8|#define COAP_PDU_IS_EMPTY(pdu)     ((pdu)->code == 0)
  |  |  ------------------
  |  |  |  Branch (99:37): [True: 4, False: 0]
  |  |  |  Branch (99:64): [True: 4, False: 0]
  |  |  ------------------
  ------------------
 1197|       |      /* Check the M Bit is not set on a GET request RFC 7959 2.2 */
 1198|      4|      coap_block_b_t block;
 1199|       |
 1200|      4|      if (coap_get_block_b(session, pdu, opt_iter.number, &block)) {
  ------------------
  |  Branch (1200:11): [True: 4, False: 0]
  ------------------
 1201|      4|        if (block.m) {
  ------------------
  |  Branch (1201:13): [True: 1, False: 3]
  ------------------
 1202|      1|          size_t used_size = pdu->used_size;
 1203|      1|          unsigned char buf[4];
 1204|       |
 1205|      1|          coap_log_debug("Option Block2 has invalid set M bit - cleared\n");
  ------------------
  |  |  126|      1|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      1|#define coap_log(level, ...) do { \
  |  |  |  |  291|      1|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  292|      1|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      1|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1206|      1|          block.m = 0;
 1207|      1|          coap_update_option(pdu, opt_iter.number,
 1208|      1|                             coap_encode_var_safe(buf, sizeof(buf),
 1209|      1|                                                  ((block.num << 4) |
 1210|      1|                                                   (block.m << 3) |
 1211|      1|                                                   block.aszx)),
 1212|      1|                             buf);
 1213|      1|          if (used_size != pdu->used_size) {
  ------------------
  |  Branch (1213:15): [True: 0, False: 1]
  ------------------
 1214|       |            /* Unfortunately need to restart the scan */
 1215|      0|            coap_option_iterator_init(pdu, &opt_iter, COAP_OPT_ALL);
  ------------------
  |  |  230|      0|#define COAP_OPT_ALL NULL
  ------------------
 1216|      0|            last_number = -1;
 1217|      0|            continue;
 1218|      0|          }
 1219|      1|        }
 1220|      4|      }
 1221|      4|    }
 1222|    416|    last_number = opt_iter.number;
 1223|    416|  }
 1224|    203|overflow:
 1225|    203|  return ok;
 1226|    203|}
coap_send_rst_lkd:
 1239|     12|coap_send_rst_lkd(coap_session_t *session, const coap_pdu_t *request) {
 1240|     12|  if (request->type == COAP_MESSAGE_CON || request->type == COAP_MESSAGE_NON)
  ------------------
  |  Branch (1240:7): [True: 7, False: 5]
  |  Branch (1240:44): [True: 1, False: 4]
  ------------------
 1241|      8|    return coap_send_message_type_lkd(session, request, COAP_MESSAGE_RST);
 1242|      4|  return COAP_INVALID_MID;
  ------------------
  |  |  198|      4|#define COAP_INVALID_MID -1
  ------------------
 1243|     12|}
coap_session_send_pdu:
 1271|    216|coap_session_send_pdu(coap_session_t *session, coap_pdu_t *pdu) {
 1272|    216|  ssize_t bytes_written = -1;
 1273|    216|  assert(pdu->hdr_size > 0);
  ------------------
  |  Branch (1273:3): [True: 216, False: 0]
  ------------------
 1274|       |
 1275|       |  /* Caller handles partial writes */
 1276|    216|  bytes_written = session->sock.lfunc[COAP_LAYER_SESSION].l_write(session,
 1277|    216|                  pdu->token - pdu->hdr_size,
 1278|    216|                  pdu->used_size + pdu->hdr_size);
 1279|    216|  coap_show_pdu(COAP_LOG_DEBUG, pdu);
 1280|    216|  return bytes_written;
 1281|    216|}
coap_send_message_type_lkd:
 1369|      8|                           coap_pdu_type_t type) {
 1370|      8|  coap_pdu_t *response;
 1371|      8|  coap_mid_t result = COAP_INVALID_MID;
  ------------------
  |  |  198|      8|#define COAP_INVALID_MID -1
  ------------------
 1372|       |
 1373|      8|  coap_lock_check_locked();
  ------------------
  |  |  638|      8|#define coap_lock_check_locked() {}
  ------------------
 1374|      8|  if (request && COAP_PROTO_NOT_RELIABLE(session->proto) &&
  ------------------
  |  |   41|     16|#define COAP_PROTO_NOT_RELIABLE(p) ((p)==COAP_PROTO_UDP || (p)==COAP_PROTO_DTLS)
  |  |  ------------------
  |  |  |  Branch (41:37): [True: 8, False: 0]
  |  |  |  Branch (41:60): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (1374:7): [True: 8, False: 0]
  ------------------
 1375|      8|      !(type == COAP_MESSAGE_RST && coap_is_mcast(&session->addr_info.local))) {
  ------------------
  |  Branch (1375:9): [True: 8, False: 0]
  |  Branch (1375:37): [True: 0, False: 8]
  ------------------
 1376|      8|    response = coap_pdu_init(type, 0, request->mid, 0);
 1377|      8|    if (response)
  ------------------
  |  Branch (1377:9): [True: 8, False: 0]
  ------------------
 1378|      8|      result = coap_send_internal(session, response, NULL);
 1379|      8|  }
 1380|      8|  return result;
 1381|      8|}
coap_check_code_class:
 1584|    289|coap_check_code_class(coap_session_t *session, coap_pdu_t *pdu) {
 1585|       |
 1586|       |  /* Check validity of sending code */
 1587|    289|  switch (COAP_RESPONSE_CLASS(pdu->code)) {
  ------------------
  |  |   99|    289|#define COAP_RESPONSE_CLASS(C) (((C) >> 5) & 0xFF)
  ------------------
 1588|    102|  case 0: /* Empty or request */
  ------------------
  |  Branch (1588:3): [True: 102, False: 187]
  ------------------
 1589|    289|  case 2: /* Success */
  ------------------
  |  Branch (1589:3): [True: 187, False: 102]
  ------------------
 1590|    289|  case 3: /* Reserved for future use */
  ------------------
  |  Branch (1590:3): [True: 0, False: 289]
  ------------------
 1591|    289|  case 4: /* Client error */
  ------------------
  |  Branch (1591:3): [True: 0, False: 289]
  ------------------
 1592|    289|  case 5: /* Server error */
  ------------------
  |  Branch (1592:3): [True: 0, False: 289]
  ------------------
 1593|    289|    break;
 1594|      0|  case 7: /* Reliable signalling */
  ------------------
  |  Branch (1594:3): [True: 0, False: 289]
  ------------------
 1595|      0|    if (COAP_PROTO_RELIABLE(session->proto))
  ------------------
  |  |   42|      0|#define COAP_PROTO_RELIABLE(p) ((p)==COAP_PROTO_TCP || (p)==COAP_PROTO_TLS || \
  |  |  ------------------
  |  |  |  Branch (42:33): [True: 0, False: 0]
  |  |  |  Branch (42:56): [True: 0, False: 0]
  |  |  ------------------
  |  |   43|      0|                                (p)==COAP_PROTO_WS || (p)==COAP_PROTO_WSS)
  |  |  ------------------
  |  |  |  Branch (43:33): [True: 0, False: 0]
  |  |  |  Branch (43:55): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1596|      0|      break;
 1597|       |  /* Not valid if UDP */
 1598|       |  /* Fall through */
 1599|      0|  case 1: /* Invalid */
  ------------------
  |  Branch (1599:3): [True: 0, False: 289]
  ------------------
 1600|      0|  case 6: /* Invalid */
  ------------------
  |  Branch (1600:3): [True: 0, False: 289]
  ------------------
 1601|      0|  default:
  ------------------
  |  Branch (1601:3): [True: 0, False: 289]
  ------------------
 1602|      0|    return 0;
 1603|    289|  }
 1604|    289|  return 1;
 1605|    289|}
coap_send_internal:
 2170|    216|coap_send_internal(coap_session_t *session, coap_pdu_t *pdu, coap_pdu_t *request_pdu) {
 2171|    216|  uint8_t r;
 2172|    216|  ssize_t bytes_written;
 2173|       |
 2174|       |#if ! COAP_SERVER_SUPPORT
 2175|       |  (void)request_pdu;
 2176|       |#endif /* COAP_SERVER_SUPPORT */
 2177|    216|  pdu->session = session;
 2178|    216|  if (session->disconnect_pending) {
  ------------------
  |  Branch (2178:7): [True: 0, False: 216]
  ------------------
 2179|       |    /* The session is about to be disconnected */
 2180|      0|    goto error;
 2181|      0|  }
 2182|    216|#if COAP_CLIENT_SUPPORT
 2183|    216|  if (session->session_failed) {
  ------------------
  |  Branch (2183:7): [True: 0, False: 216]
  ------------------
 2184|      0|    coap_session_reconnect(session);
 2185|      0|    if (session->session_failed)
  ------------------
  |  Branch (2185:9): [True: 0, False: 0]
  ------------------
 2186|      0|      goto error;
 2187|      0|  }
 2188|    216|#endif /* COAP_CLIENT_SUPPORT */
 2189|    216|  if (pdu->type == COAP_MESSAGE_NON && session->rl_ticks_per_packet) {
  ------------------
  |  Branch (2189:7): [True: 118, False: 98]
  |  Branch (2189:40): [True: 0, False: 118]
  ------------------
 2190|      0|    coap_tick_t now;
 2191|       |
 2192|      0|    if (!session->is_rate_limiting) {
  ------------------
  |  Branch (2192:9): [True: 0, False: 0]
  ------------------
 2193|      0|      coap_ticks(&now);
 2194|      0|#if (COAP_MAX_LOGGING_LEVEL >= _COAP_LOG_DEBUG)
 2195|      0|      if (now - session->last_tx < session->rl_ticks_per_packet) {
  ------------------
  |  Branch (2195:11): [True: 0, False: 0]
  ------------------
 2196|      0|        uint32_t rem = (uint32_t)(session->rl_ticks_per_packet -
 2197|      0|                                  (now - session->last_tx)) * 1000 / COAP_TICKS_PER_SECOND;
  ------------------
  |  |  164|      0|#define COAP_TICKS_PER_SECOND ((coap_tick_t)(1000U))
  ------------------
 2198|      0|        coap_log_debug("** %s: mid 0x%04x: delaying transmission (%" PRIu32 ".%03" PRIu32 "s)\n",
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2199|      0|                       coap_session_str(session), pdu->mid, rem / 1000, rem %1000);
 2200|      0|        coap_show_pdu(COAP_LOG_DEBUG, pdu);
 2201|      0|      }
 2202|      0|#endif /* COAP_MAX_LOGGING_LEVEL >= _COAP_LOG_DEBUG */
 2203|      0|      while (1) {
  ------------------
  |  Branch (2203:14): [True: 0, Folded]
  ------------------
 2204|      0|        uint32_t timeout_ms;
 2205|       |
 2206|      0|        if (send_recv_terminate || session->disconnect_pending) {
  ------------------
  |  Branch (2206:13): [True: 0, False: 0]
  |  Branch (2206:36): [True: 0, False: 0]
  ------------------
 2207|      0|          goto error;
 2208|      0|        }
 2209|       |
 2210|      0|        if (now - session->last_tx >= session->rl_ticks_per_packet) {
  ------------------
  |  Branch (2210:13): [True: 0, False: 0]
  ------------------
 2211|      0|          break;
 2212|      0|        }
 2213|      0|        timeout_ms = (uint32_t)(((session->rl_ticks_per_packet - (now - session->last_tx)) *
 2214|      0|                                 1000) / COAP_TICKS_PER_SECOND);
  ------------------
  |  |  164|      0|#define COAP_TICKS_PER_SECOND ((coap_tick_t)(1000U))
  ------------------
 2215|       |
 2216|      0|        if (timeout_ms == 0) {
  ------------------
  |  Branch (2216:13): [True: 0, False: 0]
  ------------------
 2217|      0|          timeout_ms = COAP_IO_NO_WAIT;
  ------------------
  |  |  867|      0|#define COAP_IO_NO_WAIT ((uint32_t)-1)
  ------------------
 2218|      0|        }
 2219|       |
 2220|      0|        session->is_rate_limiting = 1;
 2221|      0|        coap_io_process_lkd(session->context, timeout_ms);
 2222|      0|        session->is_rate_limiting = 0;
 2223|      0|        coap_ticks(&now);
 2224|      0|      }
 2225|      0|      coap_log_debug("** %s: mid 0x%04x: now transmitting\n",
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2226|      0|                     coap_session_str(session), pdu->mid);
 2227|      0|      session->last_tx = now;
 2228|      0|    }
 2229|      0|  }
 2230|    216|#if COAP_PROXY_SUPPORT
 2231|    216|  if (session->server_list) {
  ------------------
  |  Branch (2231:7): [True: 0, False: 216]
  ------------------
 2232|       |    /* Local session wanting to use proxy logic */
 2233|      0|    return coap_proxy_local_write(session, pdu);
 2234|      0|  }
 2235|    216|#endif /* COAP_PROXY_SUPPORT */
 2236|    216|  if (pdu->code == COAP_RESPONSE_CODE(508)) {
  ------------------
  |  |   96|    216|#define COAP_RESPONSE_CODE(N) (((N)/100 << 5) | (N)%100)
  ------------------
  |  Branch (2236:7): [True: 0, False: 216]
  ------------------
 2237|       |    /*
 2238|       |     * Need to prepend our IP identifier to the data as per
 2239|       |     * https://rfc-editor.org/rfc/rfc8768.html#section-4
 2240|       |     */
 2241|      0|    if (!prepend_508_ip(session, pdu)) {
  ------------------
  |  Branch (2241:9): [True: 0, False: 0]
  ------------------
 2242|      0|      return (coap_mid_t)COAP_DROPPED_RESPONSE;
  ------------------
  |  |   92|      0|#define COAP_DROPPED_RESPONSE -2
  ------------------
 2243|      0|    }
 2244|      0|  }
 2245|       |
 2246|    216|  if (session->echo) {
  ------------------
  |  Branch (2246:7): [True: 0, False: 216]
  ------------------
 2247|      0|    if (!coap_insert_option(pdu, COAP_OPTION_ECHO, session->echo->length,
  ------------------
  |  Branch (2247:9): [True: 0, False: 0]
  ------------------
 2248|      0|                            session->echo->s))
 2249|      0|      goto error;
 2250|      0|    coap_delete_bin_const(session->echo);
 2251|      0|    session->echo = NULL;
 2252|      0|  }
 2253|    216|#if COAP_OSCORE_SUPPORT
 2254|    216|  if (session->oscore_encryption) {
  ------------------
  |  Branch (2254:7): [True: 0, False: 216]
  ------------------
 2255|       |    /* Need to convert Proxy-Uri to Proxy-Scheme option if needed */
 2256|      0|    if (COAP_PDU_IS_REQUEST(pdu) && !coap_rebuild_pdu_for_proxy(pdu))
  ------------------
  |  |   99|      0|#define COAP_PDU_IS_REQUEST(pdu)   (!COAP_PDU_IS_EMPTY(pdu) && (pdu)->code < 32)
  |  |  ------------------
  |  |  |  |   98|      0|#define COAP_PDU_IS_EMPTY(pdu)     ((pdu)->code == 0)
  |  |  ------------------
  |  |  |  Branch (99:37): [True: 0, False: 0]
  |  |  |  Branch (99:64): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (2256:37): [True: 0, False: 0]
  ------------------
 2257|      0|      goto error;
 2258|      0|  }
 2259|    216|#endif /* COAP_OSCORE_SUPPORT */
 2260|       |
 2261|    216|  if (!coap_pdu_encode_header(pdu, session->proto)) {
  ------------------
  |  Branch (2261:7): [True: 0, False: 216]
  ------------------
 2262|      0|    goto error;
 2263|      0|  }
 2264|       |
 2265|    216|#if !COAP_DISABLE_TCP
 2266|    216|  if (COAP_PROTO_RELIABLE(session->proto) &&
  ------------------
  |  |   42|    432|#define COAP_PROTO_RELIABLE(p) ((p)==COAP_PROTO_TCP || (p)==COAP_PROTO_TLS || \
  |  |  ------------------
  |  |  |  Branch (42:33): [True: 0, False: 216]
  |  |  |  Branch (42:56): [True: 0, False: 216]
  |  |  ------------------
  |  |   43|    216|                                (p)==COAP_PROTO_WS || (p)==COAP_PROTO_WSS)
  |  |  ------------------
  |  |  |  Branch (43:33): [True: 0, False: 216]
  |  |  |  Branch (43:55): [True: 0, False: 216]
  |  |  ------------------
  ------------------
 2267|      0|      session->state == COAP_SESSION_STATE_ESTABLISHED) {
  ------------------
  |  Branch (2267:7): [True: 0, False: 0]
  ------------------
 2268|      0|    coap_opt_iterator_t opt_iter;
 2269|       |
 2270|      0|    if (!session->csm_block_supported) {
  ------------------
  |  Branch (2270:9): [True: 0, False: 0]
  ------------------
 2271|       |      /*
 2272|       |       * Need to check that this instance is not sending any block options as
 2273|       |       * the remote end via CSM has not informed us that there is support
 2274|       |       * https://rfc-editor.org/rfc/rfc8323#section-5.3.2
 2275|       |       * This includes potential BERT blocks.
 2276|       |       */
 2277|      0|      if (coap_check_option(pdu, COAP_OPTION_BLOCK1, &opt_iter) != NULL) {
  ------------------
  |  Branch (2277:11): [True: 0, False: 0]
  ------------------
 2278|      0|        coap_log_debug("Remote end did not indicate CSM support for Block1 enabled\n");
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2279|      0|      }
 2280|      0|      if (coap_check_option(pdu, COAP_OPTION_BLOCK2, &opt_iter) != NULL) {
  ------------------
  |  Branch (2280:11): [True: 0, False: 0]
  ------------------
 2281|      0|        coap_log_debug("Remote end did not indicate CSM support for Block2 enabled\n");
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2282|      0|      }
 2283|      0|    } else if (!session->csm_bert_rem_support) {
  ------------------
  |  Branch (2283:16): [True: 0, False: 0]
  ------------------
 2284|      0|      coap_opt_t *opt;
 2285|       |
 2286|      0|      opt = coap_check_option(pdu, COAP_OPTION_BLOCK1, &opt_iter);
 2287|      0|      if (opt && COAP_OPT_BLOCK_SZX(opt) == 7) {
  ------------------
  |  |   96|      0|  (coap_opt_length(opt) ? (COAP_OPT_BLOCK_END_BYTE(opt) & 0x07) : 0)
  |  |  ------------------
  |  |  |  |   87|      0|  ((coap_opt_length(opt) && coap_opt_value(opt)) ? \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (87:5): [True: 0, False: 0]
  |  |  |  |  |  Branch (87:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   88|      0|   *(coap_opt_value(opt) + (coap_opt_length(opt)-1)) : 0)
  |  |  ------------------
  |  |  |  Branch (96:4): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (2287:11): [True: 0, False: 0]
  |  Branch (2287:18): [True: 0, False: 0]
  ------------------
 2288|      0|        coap_log_debug("Remote end did not indicate CSM support for BERT Block1\n");
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2289|      0|      }
 2290|      0|      opt = coap_check_option(pdu, COAP_OPTION_BLOCK2, &opt_iter);
 2291|      0|      if (opt && COAP_OPT_BLOCK_SZX(opt) == 7) {
  ------------------
  |  |   96|      0|  (coap_opt_length(opt) ? (COAP_OPT_BLOCK_END_BYTE(opt) & 0x07) : 0)
  |  |  ------------------
  |  |  |  |   87|      0|  ((coap_opt_length(opt) && coap_opt_value(opt)) ? \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (87:5): [True: 0, False: 0]
  |  |  |  |  |  Branch (87:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   88|      0|   *(coap_opt_value(opt) + (coap_opt_length(opt)-1)) : 0)
  |  |  ------------------
  |  |  |  Branch (96:4): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (2291:11): [True: 0, False: 0]
  |  Branch (2291:18): [True: 0, False: 0]
  ------------------
 2292|      0|        coap_log_debug("Remote end did not indicate CSM support for BERT Block2\n");
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2293|      0|      }
 2294|      0|    }
 2295|      0|  }
 2296|    216|#endif /* !COAP_DISABLE_TCP */
 2297|       |
 2298|    216|#if COAP_OSCORE_SUPPORT
 2299|    216|  if (session->oscore_encryption &&
  ------------------
  |  Branch (2299:7): [True: 0, False: 216]
  ------------------
 2300|      0|      pdu->type != COAP_MESSAGE_RST &&
  ------------------
  |  Branch (2300:7): [True: 0, False: 0]
  ------------------
 2301|      0|      !(pdu->type == COAP_MESSAGE_ACK && pdu->code == COAP_EMPTY_CODE) &&
  ------------------
  |  Branch (2301:9): [True: 0, False: 0]
  |  Branch (2301:42): [True: 0, False: 0]
  ------------------
 2302|      0|      !(COAP_PROTO_RELIABLE(session->proto) && pdu->code == COAP_SIGNALING_CODE_PONG)) {
  ------------------
  |  |   42|      0|#define COAP_PROTO_RELIABLE(p) ((p)==COAP_PROTO_TCP || (p)==COAP_PROTO_TLS || \
  |  |  ------------------
  |  |  |  Branch (42:33): [True: 0, False: 0]
  |  |  |  Branch (42:56): [True: 0, False: 0]
  |  |  ------------------
  |  |   43|      0|                                (p)==COAP_PROTO_WS || (p)==COAP_PROTO_WSS)
  |  |  ------------------
  |  |  |  Branch (43:33): [True: 0, False: 0]
  |  |  |  Branch (43:55): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (2302:48): [True: 0, False: 0]
  ------------------
 2303|       |    /* Refactor PDU as appropriate RFC8613 */
 2304|      0|    coap_pdu_t *osc_pdu = coap_oscore_new_pdu_encrypted_lkd(session, pdu, NULL, 0);
 2305|       |
 2306|      0|    if (osc_pdu == NULL) {
  ------------------
  |  Branch (2306:9): [True: 0, False: 0]
  ------------------
 2307|      0|      coap_log_warn("OSCORE: PDU could not be encrypted\n");
  ------------------
  |  |  108|      0|#define coap_log_warn(...) coap_log(COAP_LOG_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2308|      0|      if (coap_get_log_level() < COAP_LOG_DEBUG)
  ------------------
  |  Branch (2308:11): [True: 0, False: 0]
  ------------------
 2309|      0|        coap_show_pdu(COAP_LOG_WARN, pdu);
 2310|      0|      goto error;
 2311|      0|    }
 2312|      0|    bytes_written = coap_send_pdu(session, osc_pdu, NULL);
 2313|      0|    coap_delete_pdu_lkd(pdu);
 2314|      0|    pdu = osc_pdu;
 2315|      0|  } else
 2316|    216|#endif /* COAP_OSCORE_SUPPORT */
 2317|    216|    bytes_written = coap_send_pdu(session, pdu, NULL);
 2318|       |
 2319|    216|#if COAP_SERVER_SUPPORT
 2320|    216|  if (session->last_resp_pdu != pdu &&
  ------------------
  |  Branch (2320:7): [True: 216, False: 0]
  ------------------
 2321|    216|      request_pdu && COAP_PROTO_NOT_RELIABLE(session->proto) &&
  ------------------
  |  |   41|    316|#define COAP_PROTO_NOT_RELIABLE(p) ((p)==COAP_PROTO_UDP || (p)==COAP_PROTO_DTLS)
  |  |  ------------------
  |  |  |  Branch (41:37): [True: 100, False: 0]
  |  |  |  Branch (41:60): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (2321:7): [True: 100, False: 116]
  ------------------
 2322|    100|      COAP_PDU_IS_REQUEST(request_pdu) &&
  ------------------
  |  |   99|    316|#define COAP_PDU_IS_REQUEST(pdu)   (!COAP_PDU_IS_EMPTY(pdu) && (pdu)->code < 32)
  |  |  ------------------
  |  |  |  |   98|    200|#define COAP_PDU_IS_EMPTY(pdu)     ((pdu)->code == 0)
  |  |  ------------------
  |  |  |  Branch (99:37): [True: 100, False: 0]
  |  |  |  Branch (99:64): [True: 100, False: 0]
  |  |  ------------------
  ------------------
 2323|    100|      COAP_PDU_IS_RESPONSE(pdu) && pdu->type == COAP_MESSAGE_ACK) {
  ------------------
  |  |  101|    316|#define COAP_PDU_IS_RESPONSE(pdu)  ((pdu)->code >= 64 && (pdu)->code < 192)
  |  |  ------------------
  |  |  |  Branch (101:37): [True: 99, False: 1]
  |  |  |  Branch (101:58): [True: 99, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (2323:36): [True: 88, False: 11]
  ------------------
 2324|     88|    coap_delete_pdu_lkd(session->last_resp_pdu);
 2325|     88|    session->last_resp_pdu = pdu;
 2326|     88|    coap_pdu_reference_lkd(session->last_resp_pdu);
 2327|     88|  }
 2328|    216|#endif /* COAP_SERVER_SUPPORT */
 2329|       |
 2330|    216|  if (bytes_written == COAP_PDU_DELAYED) {
  ------------------
  |  |   94|    216|#define COAP_PDU_DELAYED -3
  ------------------
  |  Branch (2330:7): [True: 0, False: 216]
  ------------------
 2331|       |    /* do not free pdu as it is stored with session for later use */
 2332|      0|    return pdu->mid;
 2333|      0|  }
 2334|    216|  if (bytes_written < 0) {
  ------------------
  |  Branch (2334:7): [True: 115, False: 101]
  ------------------
 2335|    115|    if (pdu->code != 0)
  ------------------
  |  Branch (2335:9): [True: 108, False: 7]
  ------------------
 2336|    108|      coap_session_disconnected_lkd(session, COAP_NACK_NOT_DELIVERABLE);
 2337|    115|    goto error;
 2338|    115|  }
 2339|       |
 2340|    101|#if !COAP_DISABLE_TCP
 2341|    101|  if (COAP_PROTO_RELIABLE(session->proto) &&
  ------------------
  |  |   42|    202|#define COAP_PROTO_RELIABLE(p) ((p)==COAP_PROTO_TCP || (p)==COAP_PROTO_TLS || \
  |  |  ------------------
  |  |  |  Branch (42:33): [True: 0, False: 101]
  |  |  |  Branch (42:56): [True: 0, False: 101]
  |  |  ------------------
  |  |   43|    101|                                (p)==COAP_PROTO_WS || (p)==COAP_PROTO_WSS)
  |  |  ------------------
  |  |  |  Branch (43:33): [True: 0, False: 101]
  |  |  |  Branch (43:55): [True: 0, False: 101]
  |  |  ------------------
  ------------------
 2342|      0|      (size_t)bytes_written < pdu->used_size + pdu->hdr_size) {
  ------------------
  |  Branch (2342:7): [True: 0, False: 0]
  ------------------
 2343|      0|    if (coap_session_delay_pdu(session, pdu, NULL) == COAP_PDU_DELAYED) {
  ------------------
  |  |   94|      0|#define COAP_PDU_DELAYED -3
  ------------------
  |  Branch (2343:9): [True: 0, False: 0]
  ------------------
 2344|      0|      session->partial_write = (size_t)bytes_written;
 2345|       |      /* do not free pdu as it is stored with session for later use */
 2346|      0|      return pdu->mid;
 2347|      0|    } else {
 2348|      0|      goto error;
 2349|      0|    }
 2350|      0|  }
 2351|    101|#endif /* !COAP_DISABLE_TCP */
 2352|       |
 2353|    101|  if (pdu->type != COAP_MESSAGE_CON
  ------------------
  |  Branch (2353:7): [True: 101, False: 0]
  ------------------
 2354|    101|      || COAP_PROTO_RELIABLE(session->proto)) {
  ------------------
  |  |   42|      0|#define COAP_PROTO_RELIABLE(p) ((p)==COAP_PROTO_TCP || (p)==COAP_PROTO_TLS || \
  |  |  ------------------
  |  |  |  Branch (42:33): [True: 0, False: 0]
  |  |  |  Branch (42:56): [True: 0, False: 0]
  |  |  ------------------
  |  |   43|      0|                                (p)==COAP_PROTO_WS || (p)==COAP_PROTO_WSS)
  |  |  ------------------
  |  |  |  Branch (43:33): [True: 0, False: 0]
  |  |  |  Branch (43:55): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 2355|    101|    coap_mid_t id = pdu->mid;
 2356|    101|    coap_delete_pdu_lkd(pdu);
 2357|    101|    return id;
 2358|    101|  }
 2359|       |
 2360|      0|  coap_queue_t *node = coap_new_node();
 2361|      0|  if (!node) {
  ------------------
  |  Branch (2361:7): [True: 0, False: 0]
  ------------------
 2362|      0|    coap_log_debug("coap_wait_ack: insufficient memory\n");
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2363|      0|    goto error;
 2364|      0|  }
 2365|       |
 2366|      0|  node->id = pdu->mid;
 2367|      0|  node->pdu = pdu;
 2368|      0|  coap_prng_lkd(&r, sizeof(r));
 2369|       |  /* add timeout in range [ACK_TIMEOUT...ACK_TIMEOUT * ACK_RANDOM_FACTOR] */
 2370|      0|  node->timeout = coap_calc_timeout(session, r);
 2371|      0|  return coap_wait_ack(session->context, session, node);
 2372|    115|error:
 2373|    115|  coap_delete_pdu_lkd(pdu);
 2374|    115|  return COAP_INVALID_MID;
  ------------------
  |  |  198|    115|#define COAP_INVALID_MID -1
  ------------------
 2375|      0|}
coap_handle_dgram:
 3188|     28|                  uint8_t *msg, size_t msg_len) {
 3189|       |
 3190|     28|  coap_pdu_t *pdu = NULL;
 3191|     28|  coap_opt_filter_t error_opts;
 3192|       |
 3193|     28|  assert(COAP_PROTO_NOT_RELIABLE(session->proto));
  ------------------
  |  Branch (3193:3): [True: 28, False: 0]
  |  Branch (3193:3): [True: 0, False: 0]
  ------------------
 3194|     28|#if COAP_SERVER_SUPPORT
 3195|       |  /* The DTLS layer has authenticated the record, so the address can change */
 3196|     28|  coap_session_cid_update_addr(session);
 3197|     28|#endif /* COAP_SERVER_SUPPORT */
 3198|     28|  if (msg_len < 4) {
  ------------------
  |  Branch (3198:7): [True: 0, False: 28]
  ------------------
 3199|       |    /* Minimum size of CoAP header - ignore runt */
 3200|      0|    return -1;
 3201|      0|  }
 3202|     28|  if ((msg[0] >> 6) != COAP_DEFAULT_VERSION) {
  ------------------
  |  |   35|     28|#define COAP_DEFAULT_VERSION      1 /* version of CoAP supported */
  ------------------
  |  Branch (3202:7): [True: 9, False: 19]
  ------------------
 3203|       |    /*
 3204|       |     * As per https://datatracker.ietf.org/doc/html/rfc7252#section-3,
 3205|       |     * this MUST be silently ignored.
 3206|       |     */
 3207|      9|    coap_log_debug("coap_handle_dgram: UDP version not supported\n");
  ------------------
  |  |  126|      9|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      9|#define coap_log(level, ...) do { \
  |  |  |  |  291|      9|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 9]
  |  |  |  |  ------------------
  |  |  |  |  292|      9|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      9|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 9]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3208|      9|    return -1;
 3209|      9|  }
 3210|       |
 3211|       |  /* Need max space in case PDU is updated with updated token etc. */
 3212|     19|  pdu = coap_pdu_init(0, 0, 0, coap_session_max_pdu_rcv_size(session));
 3213|     19|  if (!pdu)
  ------------------
  |  Branch (3213:7): [True: 0, False: 19]
  ------------------
 3214|      0|    goto error;
 3215|       |
 3216|     19|  coap_option_filter_clear(&error_opts);
 3217|     19|  if (!coap_pdu_parse2(session->proto, msg, msg_len, pdu, &error_opts)) {
  ------------------
  |  Branch (3217:7): [True: 14, False: 5]
  ------------------
 3218|     14|    coap_handle_event_lkd(session->context, COAP_EVENT_BAD_PACKET, session);
 3219|     14|    coap_log_warn("discard malformed PDU\n");
  ------------------
  |  |  108|     14|#define coap_log_warn(...) coap_log(COAP_LOG_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|     14|#define coap_log(level, ...) do { \
  |  |  |  |  291|     14|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 14]
  |  |  |  |  ------------------
  |  |  |  |  292|     14|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|     14|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 14]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3220|     14|    if (error_opts.mask && COAP_PDU_IS_REQUEST(pdu)) {
  ------------------
  |  |   99|      7|#define COAP_PDU_IS_REQUEST(pdu)   (!COAP_PDU_IS_EMPTY(pdu) && (pdu)->code < 32)
  |  |  ------------------
  |  |  |  |   98|     14|#define COAP_PDU_IS_EMPTY(pdu)     ((pdu)->code == 0)
  |  |  ------------------
  |  |  |  Branch (99:37): [True: 7, False: 0]
  |  |  |  Branch (99:64): [True: 2, False: 5]
  |  |  ------------------
  ------------------
  |  Branch (3220:9): [True: 7, False: 7]
  ------------------
 3221|      2|      coap_pdu_t *response =
 3222|      2|          coap_new_error_response(pdu,
 3223|      2|                                  COAP_RESPONSE_CODE(402), &error_opts);
  ------------------
  |  |   96|      2|#define COAP_RESPONSE_CODE(N) (((N)/100 << 5) | (N)%100)
  ------------------
 3224|      2|      if (!response) {
  ------------------
  |  Branch (3224:11): [True: 1, False: 1]
  ------------------
 3225|      1|        coap_log_warn("coap_handle_dgram: cannot create error response\n");
  ------------------
  |  |  108|      1|#define coap_log_warn(...) coap_log(COAP_LOG_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      1|#define coap_log(level, ...) do { \
  |  |  |  |  291|      1|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  292|      1|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      1|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3226|      1|      } else {
 3227|      1|        if (coap_send_internal(session, response, NULL) == COAP_INVALID_MID)
  ------------------
  |  |  198|      1|#define COAP_INVALID_MID -1
  ------------------
  |  Branch (3227:13): [True: 0, False: 1]
  ------------------
 3228|      1|          coap_log_warn("coap_handle_dgram: error sending response\n");
  ------------------
  |  |  108|      0|#define coap_log_warn(...) coap_log(COAP_LOG_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3229|      1|      }
 3230|      2|      coap_delete_pdu_lkd(pdu);
 3231|      2|      return -1;
 3232|     12|    } else {
 3233|     12|      goto error;
 3234|     12|    }
 3235|     14|  }
 3236|       |
 3237|      5|  if (coap_debug_recv_packet()) {
  ------------------
  |  Branch (3237:7): [True: 5, False: 0]
  ------------------
 3238|      5|    coap_dispatch(ctx, session, pdu);
 3239|      5|  } else {
 3240|      0|    coap_show_pdu(COAP_LOG_DEBUG, pdu);
 3241|      0|  }
 3242|      5|  coap_delete_pdu_lkd(pdu);
 3243|      5|  return 0;
 3244|       |
 3245|     12|error:
 3246|       |  /*
 3247|       |   * https://rfc-editor.org/rfc/rfc7252#section-4.2 MUST send RST
 3248|       |   * https://rfc-editor.org/rfc/rfc7252#section-4.3 MAY send RST
 3249|       |   */
 3250|     12|  coap_send_rst_lkd(session, pdu);
 3251|     12|  coap_delete_pdu_lkd(pdu);
 3252|     12|  return -1;
 3253|     19|}
coap_remove_first_from_delayq:
 3278|    251|coap_remove_first_from_delayq(coap_session_t *session) {
 3279|    251|  coap_queue_t *q = session->delayqueue;
 3280|       |
 3281|    251|  if (q) {
  ------------------
  |  Branch (3281:7): [True: 0, False: 251]
  ------------------
 3282|      0|    session->delayqueue = q->next;
 3283|      0|    if (session->delayqueue == NULL)
  ------------------
  |  Branch (3283:9): [True: 0, False: 0]
  ------------------
 3284|      0|      session->delayqueue_tail = NULL;
 3285|       |    q->next = NULL;
 3286|      0|  }
 3287|    251|  return q;
 3288|    251|}
coap_remove_from_queue:
 3311|      2|                       coap_bin_const_t *token, coap_queue_t **node) {
 3312|      2|  coap_queue_t *p, *q;
 3313|       |
 3314|      2|  if (!queue || !*queue) {
  ------------------
  |  Branch (3314:7): [True: 0, False: 2]
  |  Branch (3314:17): [True: 2, False: 0]
  ------------------
 3315|      2|    *node = NULL;
 3316|      2|    return 0;
 3317|      2|  }
 3318|       |
 3319|       |  /* replace queue head if PDU's time is less than head's time */
 3320|       |
 3321|      0|  if (session == (*queue)->session && mid == (*queue)->id &&
  ------------------
  |  Branch (3321:7): [True: 0, False: 0]
  |  Branch (3321:39): [True: 0, False: 0]
  ------------------
 3322|      0|      (!token || coap_binary_equal(token, &(*queue)->pdu->actual_token))) { /* found message id */
  ------------------
  |  |  223|      0|  ((binary1)->length == (binary2)->length && ((binary1)->length == 0 || \
  |  |  ------------------
  |  |  |  Branch (223:4): [True: 0, False: 0]
  |  |  |  Branch (223:47): [True: 0, False: 0]
  |  |  ------------------
  |  |  224|      0|                                              ((binary1)->s && (binary2)->s && \
  |  |  ------------------
  |  |  |  Branch (224:48): [True: 0, False: 0]
  |  |  |  Branch (224:64): [True: 0, False: 0]
  |  |  ------------------
  |  |  225|      0|                                               memcmp((binary1)->s, (binary2)->s, (binary1)->length) == 0)))
  |  |  ------------------
  |  |  |  Branch (225:48): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (3322:8): [True: 0, False: 0]
  ------------------
 3323|      0|    *node = *queue;
 3324|      0|    *queue = (*queue)->next;
 3325|      0|    if (*queue) {          /* adjust relative time of new queue head */
  ------------------
  |  Branch (3325:9): [True: 0, False: 0]
  ------------------
 3326|      0|      (*queue)->t += (*node)->t;
 3327|      0|    }
 3328|      0|    (*node)->next = NULL;
 3329|      0|    coap_log_debug("** %s: mid=0x%04x: removed (1)\n",
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3330|      0|                   coap_session_str(session), mid);
 3331|      0|    return 1;
 3332|      0|  }
 3333|       |
 3334|       |  /* search message id in queue to remove (only first occurrence will be removed) */
 3335|      0|  q = *queue;
 3336|      0|  do {
 3337|      0|    p = q;
 3338|      0|    q = q->next;
 3339|      0|  } while (q && (session != q->session || mid != q->id ||
  ------------------
  |  Branch (3339:12): [True: 0, False: 0]
  |  Branch (3339:18): [True: 0, False: 0]
  |  Branch (3339:43): [True: 0, False: 0]
  ------------------
 3340|      0|                 (token && ! coap_binary_equal(token, &q->pdu->actual_token))));
  ------------------
  |  |  223|      0|  ((binary1)->length == (binary2)->length && ((binary1)->length == 0 || \
  |  |  ------------------
  |  |  |  Branch (223:4): [True: 0, False: 0]
  |  |  |  Branch (223:47): [True: 0, False: 0]
  |  |  ------------------
  |  |  224|      0|                                              ((binary1)->s && (binary2)->s && \
  |  |  ------------------
  |  |  |  Branch (224:48): [True: 0, False: 0]
  |  |  |  Branch (224:64): [True: 0, False: 0]
  |  |  ------------------
  |  |  225|      0|                                               memcmp((binary1)->s, (binary2)->s, (binary1)->length) == 0)))
  |  |  ------------------
  |  |  |  Branch (225:48): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (3340:19): [True: 0, False: 0]
  ------------------
 3341|       |
 3342|      0|  if (q) {                        /* found message id */
  ------------------
  |  Branch (3342:7): [True: 0, False: 0]
  ------------------
 3343|      0|    p->next = q->next;
 3344|      0|    if (p->next) {                /* must update relative time of p->next */
  ------------------
  |  Branch (3344:9): [True: 0, False: 0]
  ------------------
 3345|      0|      p->next->t += q->t;
 3346|      0|    }
 3347|      0|    q->next = NULL;
 3348|      0|    *node = q;
 3349|      0|    coap_log_debug("** %s: mid=0x%04x: removed (2)\n",
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3350|      0|                   coap_session_str(session), mid);
 3351|      0|    return 1;
 3352|      0|  }
 3353|       |
 3354|      0|  *node = NULL;
 3355|      0|  return 0;
 3356|       |
 3357|      0|}
coap_cancel_session_messages:
 3420|    108|                             coap_nack_reason_t reason) {
 3421|    108|  coap_queue_t *p, *q;
 3422|       |
 3423|    108|  while (context->sendqueue && context->sendqueue->session == session) {
  ------------------
  |  Branch (3423:10): [True: 0, False: 108]
  |  Branch (3423:32): [True: 0, False: 0]
  ------------------
 3424|      0|    q = context->sendqueue;
 3425|      0|    context->sendqueue = q->next;
 3426|      0|    coap_log_debug("** %s: mid=0x%04x: removed (3)\n",
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3427|      0|                   coap_session_str(session), q->id);
 3428|      0|    if (q->pdu->type == COAP_MESSAGE_CON) {
  ------------------
  |  Branch (3428:9): [True: 0, False: 0]
  ------------------
 3429|      0|      coap_handle_nack(session, q->pdu, reason, q->id);
 3430|      0|    }
 3431|      0|    coap_delete_node_lkd(q);
 3432|      0|  }
 3433|       |
 3434|    108|  if (!context->sendqueue)
  ------------------
  |  Branch (3434:7): [True: 108, False: 0]
  ------------------
 3435|    108|    return;
 3436|       |
 3437|      0|  p = context->sendqueue;
 3438|      0|  q = p->next;
 3439|       |
 3440|      0|  while (q) {
  ------------------
  |  Branch (3440:10): [True: 0, False: 0]
  ------------------
 3441|      0|    if (q->session == session) {
  ------------------
  |  Branch (3441:9): [True: 0, False: 0]
  ------------------
 3442|      0|      p->next = q->next;
 3443|      0|      coap_log_debug("** %s: mid=0x%04x: removed (4)\n",
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3444|      0|                     coap_session_str(session), q->id);
 3445|      0|      if (q->pdu->type == COAP_MESSAGE_CON) {
  ------------------
  |  Branch (3445:11): [True: 0, False: 0]
  ------------------
 3446|      0|        coap_handle_nack(session, q->pdu, reason, q->id);
 3447|      0|      }
 3448|      0|      coap_delete_node_lkd(q);
 3449|      0|      q = p->next;
 3450|      0|    } else {
 3451|      0|      p = q;
 3452|      0|      q = q->next;
 3453|      0|    }
 3454|      0|  }
 3455|      0|}
coap_new_error_response:
 3492|     23|                        coap_opt_filter_t *opts) {
 3493|     23|  coap_opt_iterator_t opt_iter;
 3494|     23|  coap_pdu_t *response;
 3495|     23|  unsigned char type;
 3496|       |
 3497|     23|#if COAP_ERROR_PHRASE_LENGTH > 0
 3498|     23|  const char *phrase;
 3499|     23|  if (code != COAP_RESPONSE_CODE(508)) {
  ------------------
  |  |   96|     23|#define COAP_RESPONSE_CODE(N) (((N)/100 << 5) | (N)%100)
  ------------------
  |  Branch (3499:7): [True: 23, False: 0]
  ------------------
 3500|     23|    phrase = coap_response_phrase(code);
 3501|     23|  } else {
 3502|      0|    phrase = NULL;
 3503|      0|  }
 3504|     23|#endif
 3505|       |
 3506|     23|  assert(request);
  ------------------
  |  Branch (3506:3): [True: 23, False: 0]
  ------------------
 3507|       |
 3508|     23|  if (request->type != COAP_MESSAGE_NON && request->type != COAP_MESSAGE_CON)
  ------------------
  |  Branch (3508:7): [True: 15, False: 8]
  |  Branch (3508:44): [True: 1, False: 14]
  ------------------
 3509|      1|    return NULL;
 3510|       |
 3511|       |  /* cannot send ACK if original request was not confirmable */
 3512|     22|  type = request->type == COAP_MESSAGE_CON ?
  ------------------
  |  Branch (3512:10): [True: 14, False: 8]
  ------------------
 3513|     14|         COAP_MESSAGE_ACK : COAP_MESSAGE_NON;
 3514|       |
 3515|       |  /* Now create the response and fill with options and payload data. */
 3516|     22|  response = coap_pdu_init(type, code, request->mid,
 3517|     22|                           request->session ?
  ------------------
  |  Branch (3517:28): [True: 21, False: 1]
  ------------------
 3518|     21|                           coap_session_max_pdu_size_lkd(request->session) : 512);
 3519|     22|  if (response) {
  ------------------
  |  Branch (3519:7): [True: 22, False: 0]
  ------------------
 3520|       |    /* copy token */
 3521|     22|    if (request->actual_token.length &&
  ------------------
  |  Branch (3521:9): [True: 14, False: 8]
  ------------------
 3522|     14|        !coap_add_token(response, request->actual_token.length,
  ------------------
  |  Branch (3522:9): [True: 0, False: 14]
  ------------------
 3523|     14|                        request->actual_token.s)) {
 3524|      0|      coap_log_debug("cannot add token to error response\n");
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3525|      0|      coap_delete_pdu_lkd(response);
 3526|      0|      return NULL;
 3527|      0|    }
 3528|     22|    if (response->code == COAP_RESPONSE_CODE(402)) {
  ------------------
  |  |   96|     22|#define COAP_RESPONSE_CODE(N) (((N)/100 << 5) | (N)%100)
  ------------------
  |  Branch (3528:9): [True: 2, False: 20]
  ------------------
 3529|      2|      char buf[128];
 3530|      2|      int first = 1;
 3531|      2|      int i;
 3532|      2|      size_t len;
 3533|       |
 3534|      2|#if COAP_ERROR_PHRASE_LENGTH > 0
 3535|      2|      snprintf(buf, sizeof(buf), "%s", phrase ? phrase : "");
  ------------------
  |  Branch (3535:40): [True: 2, False: 0]
  ------------------
 3536|       |#else
 3537|       |      buf[0] = '\000';
 3538|       |#endif
 3539|       |      /* copy all reported options into diagnostic message */
 3540|     14|      for (i = COAP_OPT_FILTER_SHORT - 1; i >= 0; i--) {
  ------------------
  |  |  200|      2|#define COAP_OPT_FILTER_SHORT 6
  ------------------
  |  Branch (3540:43): [True: 12, False: 2]
  ------------------
 3541|     12|        if (opts->mask & (1 << (COAP_OPT_FILTER_LONG + i))) {
  ------------------
  |  |  208|     12|#define COAP_OPT_FILTER_LONG  2
  ------------------
  |  Branch (3541:13): [True: 1, False: 11]
  ------------------
 3542|      1|          len = strlen(buf);
 3543|      1|          snprintf(&buf[len], sizeof(buf) - len, "%s%d", first ? " " : ",",
  ------------------
  |  Branch (3543:58): [True: 1, False: 0]
  ------------------
 3544|      1|                   opts->short_opts[i]);
 3545|      1|          first = 0;
 3546|      1|        }
 3547|     12|      }
 3548|      6|      for (i = COAP_OPT_FILTER_LONG - 1; i >= 0; i--) {
  ------------------
  |  |  208|      2|#define COAP_OPT_FILTER_LONG  2
  ------------------
  |  Branch (3548:42): [True: 4, False: 2]
  ------------------
 3549|      4|        if (opts->mask & (1 << i)) {
  ------------------
  |  Branch (3549:13): [True: 0, False: 4]
  ------------------
 3550|      0|          len = strlen(buf);
 3551|      0|          snprintf(&buf[len], sizeof(buf) - len, "%s%d", first ? " " : ",",
  ------------------
  |  Branch (3551:58): [True: 0, False: 0]
  ------------------
 3552|      0|                   opts->long_opts[i]);
 3553|      0|          first = 0;
 3554|      0|        }
 3555|      4|      }
 3556|      2|      coap_add_data(response, (size_t)strlen(buf), (const uint8_t *)buf);
 3557|     20|    } else if (opts && opts->mask) {
  ------------------
  |  Branch (3557:16): [True: 20, False: 0]
  |  Branch (3557:24): [True: 0, False: 20]
  ------------------
 3558|      0|      coap_opt_t *option;
 3559|       |
 3560|       |      /* copy all options */
 3561|      0|      coap_option_iterator_init(request, &opt_iter, opts);
 3562|      0|      while ((option = coap_option_next(&opt_iter))) {
  ------------------
  |  Branch (3562:14): [True: 0, False: 0]
  ------------------
 3563|      0|        coap_add_option_internal(response, opt_iter.number,
 3564|      0|                                 coap_opt_length(option),
 3565|      0|                                 coap_opt_value(option));
 3566|      0|      }
 3567|      0|#if COAP_ERROR_PHRASE_LENGTH > 0
 3568|      0|      if (phrase)
  ------------------
  |  Branch (3568:11): [True: 0, False: 0]
  ------------------
 3569|      0|        coap_add_data(response, (size_t)strlen(phrase), (const uint8_t *)phrase);
 3570|     20|    } else {
 3571|       |      /* note that diagnostic messages do not need a Content-Format option. */
 3572|     20|      if (phrase)
  ------------------
  |  Branch (3572:11): [True: 20, False: 0]
  ------------------
 3573|     20|        coap_add_data(response, (size_t)strlen(phrase), (const uint8_t *)phrase);
 3574|     20|#endif
 3575|     20|    }
 3576|     22|  }
 3577|       |
 3578|     22|  return response;
 3579|     22|}
coap_dispatch:
 5427|    103|              coap_pdu_t *pdu) {
 5428|    103|  if (session->disconnect_pending) {
  ------------------
  |  Branch (5428:7): [True: 0, False: 103]
  ------------------
 5429|       |    /* The session is about to be disconnected */
 5430|      0|    coap_log_debug("***%s: coap_dispatch: PDU dropped, session about to be disconnected\n",
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5431|      0|                   coap_session_str(session));
 5432|      0|    return;
 5433|      0|  }
 5434|       |  /*
 5435|       |   * The handlers may send on the session. If such a send fails, or the
 5436|       |   * session is otherwise to be disconnected, it is not disconnected until
 5437|       |   * the PDU has been dealt with.
 5438|       |   */
 5439|    103|  coap_session_hold_lkd(session);
 5440|    103|  coap_dispatch_pdu(context, session, pdu);
 5441|    103|  coap_session_unhold_lkd(session);
 5442|    103|}
coap_handle_event_lkd:
 5537|     14|                      coap_session_t *session) {
 5538|     14|  int ret = 0;
 5539|       |
 5540|     14|  coap_log_debug("***EVENT: %s\n", coap_event_name(event));
  ------------------
  |  |  126|     14|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|     14|#define coap_log(level, ...) do { \
  |  |  |  |  291|     14|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 14]
  |  |  |  |  ------------------
  |  |  |  |  292|     14|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|     14|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 14]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5541|       |
 5542|     14|#if COAP_PROXY_SUPPORT
 5543|     14|  if (event == COAP_EVENT_SERVER_SESSION_DEL)
  ------------------
  |  Branch (5543:7): [True: 0, False: 14]
  ------------------
 5544|      0|    coap_proxy_remove_association(session, 0);
 5545|     14|#endif /* COAP_PROXY_SUPPORT */
 5546|       |
 5547|     14|  if (context->event_cb) {
  ------------------
  |  Branch (5547:7): [True: 14, False: 0]
  ------------------
 5548|     14|    coap_lock_callback_ret(ret, context->event_cb(session, event));
  ------------------
  |  |  666|     14|#define coap_lock_callback_ret(r,func) (r) = func
  ------------------
 5549|     14|#if COAP_CLIENT_SUPPORT
 5550|     14|    switch (event) {
 5551|      0|    case COAP_EVENT_DTLS_CLOSED:
  ------------------
  |  Branch (5551:5): [True: 0, False: 14]
  ------------------
 5552|      0|    case COAP_EVENT_TCP_CLOSED:
  ------------------
  |  Branch (5552:5): [True: 0, False: 14]
  ------------------
 5553|      0|    case COAP_EVENT_SESSION_CLOSED:
  ------------------
  |  Branch (5553:5): [True: 0, False: 14]
  ------------------
 5554|      0|    case COAP_EVENT_OSCORE_DECRYPTION_FAILURE:
  ------------------
  |  Branch (5554:5): [True: 0, False: 14]
  ------------------
 5555|      0|    case COAP_EVENT_OSCORE_NOT_ENABLED:
  ------------------
  |  Branch (5555:5): [True: 0, False: 14]
  ------------------
 5556|      0|    case COAP_EVENT_OSCORE_NO_PROTECTED_PAYLOAD:
  ------------------
  |  Branch (5556:5): [True: 0, False: 14]
  ------------------
 5557|      0|    case COAP_EVENT_OSCORE_NO_SECURITY:
  ------------------
  |  Branch (5557:5): [True: 0, False: 14]
  ------------------
 5558|      0|    case COAP_EVENT_OSCORE_INTERNAL_ERROR:
  ------------------
  |  Branch (5558:5): [True: 0, False: 14]
  ------------------
 5559|      0|    case COAP_EVENT_OSCORE_DECODE_ERROR:
  ------------------
  |  Branch (5559:5): [True: 0, False: 14]
  ------------------
 5560|      0|    case COAP_EVENT_OSCORE_SIGNATURE_FAILURE:
  ------------------
  |  Branch (5560:5): [True: 0, False: 14]
  ------------------
 5561|      0|    case COAP_EVENT_WS_PACKET_SIZE:
  ------------------
  |  Branch (5561:5): [True: 0, False: 14]
  ------------------
 5562|      0|    case COAP_EVENT_WS_CLOSED:
  ------------------
  |  Branch (5562:5): [True: 0, False: 14]
  ------------------
 5563|     14|    case COAP_EVENT_BAD_PACKET:
  ------------------
  |  Branch (5563:5): [True: 14, False: 0]
  ------------------
 5564|     14|    case COAP_EVENT_FIRST_PDU_FAIL:
  ------------------
  |  Branch (5564:5): [True: 0, False: 14]
  ------------------
 5565|     14|    case COAP_EVENT_RECONNECT_NO_MORE:
  ------------------
  |  Branch (5565:5): [True: 0, False: 14]
  ------------------
 5566|       |      /* Those that are deemed fatal to end sending a request */
 5567|     14|      session->doing_send_recv = 0;
 5568|     14|      break;
 5569|      0|    case COAP_EVENT_DTLS_CONNECTED:
  ------------------
  |  Branch (5569:5): [True: 0, False: 14]
  ------------------
 5570|       |      /* Session will now be available as well - for call-home */
 5571|      0|      if (session->type == COAP_SESSION_TYPE_SERVER && session->proto == COAP_PROTO_DTLS) {
  ------------------
  |  Branch (5571:11): [True: 0, False: 0]
  |  Branch (5571:56): [True: 0, False: 0]
  ------------------
 5572|      0|        coap_handle_event_lkd(context, COAP_EVENT_SERVER_SESSION_CONNECTED,
 5573|      0|                              session);
 5574|      0|      }
 5575|      0|      break;
 5576|      0|    case COAP_EVENT_DTLS_RENEGOTIATE:
  ------------------
  |  Branch (5576:5): [True: 0, False: 14]
  ------------------
 5577|      0|    case COAP_EVENT_DTLS_ERROR:
  ------------------
  |  Branch (5577:5): [True: 0, False: 14]
  ------------------
 5578|      0|    case COAP_EVENT_TCP_CONNECTED:
  ------------------
  |  Branch (5578:5): [True: 0, False: 14]
  ------------------
 5579|      0|    case COAP_EVENT_TCP_FAILED:
  ------------------
  |  Branch (5579:5): [True: 0, False: 14]
  ------------------
 5580|      0|    case COAP_EVENT_RECONNECT_FAILED:
  ------------------
  |  Branch (5580:5): [True: 0, False: 14]
  ------------------
 5581|      0|      break;
 5582|      0|    case COAP_EVENT_SESSION_CONNECTED:
  ------------------
  |  Branch (5582:5): [True: 0, False: 14]
  ------------------
 5583|       |      /* Session will now be available as well - for call-home if not (D)TLS */
 5584|      0|      if (session->type == COAP_SESSION_TYPE_SERVER &&
  ------------------
  |  Branch (5584:11): [True: 0, False: 0]
  ------------------
 5585|      0|          (session->proto == COAP_PROTO_TCP || session->proto == COAP_PROTO_TLS)) {
  ------------------
  |  Branch (5585:12): [True: 0, False: 0]
  |  Branch (5585:48): [True: 0, False: 0]
  ------------------
 5586|      0|        coap_handle_event_lkd(context, COAP_EVENT_SERVER_SESSION_CONNECTED,
 5587|      0|                              session);
 5588|      0|      }
 5589|      0|      break;
 5590|      0|    case COAP_EVENT_SESSION_FAILED:
  ------------------
  |  Branch (5590:5): [True: 0, False: 14]
  ------------------
 5591|      0|    case COAP_EVENT_PARTIAL_BLOCK:
  ------------------
  |  Branch (5591:5): [True: 0, False: 14]
  ------------------
 5592|      0|    case COAP_EVENT_XMIT_BLOCK_FAIL:
  ------------------
  |  Branch (5592:5): [True: 0, False: 14]
  ------------------
 5593|      0|    case COAP_EVENT_BLOCK_ISSUE:
  ------------------
  |  Branch (5593:5): [True: 0, False: 14]
  ------------------
 5594|      0|      break;
 5595|      0|    case COAP_EVENT_SERVER_SESSION_NEW:
  ------------------
  |  Branch (5595:5): [True: 0, False: 14]
  ------------------
 5596|       |      /* Session will now be available as well - for call-home if not (D)TLS */
 5597|      0|      if (session->proto == COAP_PROTO_UDP) {
  ------------------
  |  Branch (5597:11): [True: 0, False: 0]
  ------------------
 5598|      0|        coap_handle_event_lkd(context, COAP_EVENT_SERVER_SESSION_CONNECTED,
 5599|      0|                              session);
 5600|      0|      }
 5601|      0|      break;
 5602|      0|    case COAP_EVENT_SERVER_SESSION_DEL:
  ------------------
  |  Branch (5602:5): [True: 0, False: 14]
  ------------------
 5603|      0|    case COAP_EVENT_SERVER_SESSION_CONNECTED:
  ------------------
  |  Branch (5603:5): [True: 0, False: 14]
  ------------------
 5604|      0|    case COAP_EVENT_OSCORE_RECIPIENT_CHANGED:
  ------------------
  |  Branch (5604:5): [True: 0, False: 14]
  ------------------
 5605|      0|    case COAP_EVENT_MSG_RETRANSMITTED:
  ------------------
  |  Branch (5605:5): [True: 0, False: 14]
  ------------------
 5606|      0|    case COAP_EVENT_WS_CONNECTED:
  ------------------
  |  Branch (5606:5): [True: 0, False: 14]
  ------------------
 5607|      0|    case COAP_EVENT_KEEPALIVE_FAILURE:
  ------------------
  |  Branch (5607:5): [True: 0, False: 14]
  ------------------
 5608|      0|    case COAP_EVENT_RECONNECT_SUCCESS:
  ------------------
  |  Branch (5608:5): [True: 0, False: 14]
  ------------------
 5609|      0|    case COAP_EVENT_RECONNECT_STARTED:
  ------------------
  |  Branch (5609:5): [True: 0, False: 14]
  ------------------
 5610|      0|    default:
  ------------------
  |  Branch (5610:5): [True: 0, False: 14]
  ------------------
 5611|      0|      break;
 5612|     14|    }
 5613|     14|#endif /* COAP_CLIENT_SUPPORT */
 5614|     14|  }
 5615|     14|  return ret;
 5616|     14|}
coap_startup:
 5720|     35|coap_startup(void) {
 5721|     35|  coap_tick_t now;
 5722|     35|#ifndef WITH_CONTIKI
 5723|     35|  uint64_t us;
 5724|     35|#endif /* !WITH_CONTIKI */
 5725|       |
 5726|     35|  if (coap_started)
  ------------------
  |  Branch (5726:7): [True: 0, False: 35]
  ------------------
 5727|      0|    return;
 5728|     35|  coap_started = 1;
 5729|       |
 5730|       |#if COAP_THREAD_SAFE
 5731|       |  coap_lock_init(&global_lock);
 5732|       |  coap_mutex_init(&m_show_pdu);
 5733|       |  coap_mutex_init(&m_log_impl);
 5734|       |  coap_mutex_init(&m_io_threads);
 5735|       |#endif /* COAP_THREAD_SAFE */
 5736|       |
 5737|       |#if defined(HAVE_WINSOCK2_H)
 5738|       |  WORD wVersionRequested = MAKEWORD(2, 2);
 5739|       |  WSADATA wsaData;
 5740|       |  WSAStartup(wVersionRequested, &wsaData);
 5741|       |#endif
 5742|     35|  coap_clock_init();
 5743|     35|  coap_ticks(&now);
 5744|     35|#ifndef WITH_CONTIKI
 5745|     35|  us = coap_ticks_to_rt_us(now);
 5746|       |  /* Be accurate to the nearest (approx) us */
 5747|     35|  coap_prng_init_lkd((unsigned int)us);
 5748|       |#else /* WITH_CONTIKI */
 5749|       |  coap_start_io_process();
 5750|       |#endif /* WITH_CONTIKI */
 5751|     35|  coap_memory_init();
 5752|     35|  coap_dtls_startup();
 5753|       |#ifdef WITH_LWIP
 5754|       |  coap_io_lwip_init();
 5755|       |#endif /* WITH_LWIP */
 5756|     35|#if COAP_SERVER_SUPPORT
 5757|     35|  static coap_str_const_t well_known = { sizeof(".well-known/core")-1,
 5758|     35|                                         (const uint8_t *)".well-known/core"
 5759|     35|                                       };
 5760|     35|  memset(&resource_uri_wellknown, 0, sizeof(resource_uri_wellknown));
 5761|     35|  resource_uri_wellknown.ref = 1;
 5762|     35|  resource_uri_wellknown.handler[COAP_REQUEST_GET-1] = hnd_get_wellknown_lkd;
 5763|     35|  resource_uri_wellknown.flags = COAP_RESOURCE_FLAGS_HAS_MCAST_SUPPORT;
  ------------------
  |  |   89|     35|#define COAP_RESOURCE_FLAGS_HAS_MCAST_SUPPORT 0x8
  ------------------
 5764|     35|  resource_uri_wellknown.uri_path = &well_known;
 5765|     35|#endif /* COAP_SERVER_SUPPORT */
 5766|     35|  send_recv_terminate = 0;
 5767|     35|  coap_prng_lkd(&coap_unique_id, sizeof(coap_unique_id));
 5768|     35|}
coap_cleanup:
 5771|     35|coap_cleanup(void) {
 5772|     35|  if (!coap_started)
  ------------------
  |  Branch (5772:7): [True: 0, False: 35]
  ------------------
 5773|      0|    return;
 5774|     35|  coap_started = 0;
 5775|       |#if defined(HAVE_WINSOCK2_H)
 5776|       |  WSACleanup();
 5777|       |#elif defined(WITH_CONTIKI)
 5778|       |  coap_stop_io_process();
 5779|       |#endif
 5780|       |#ifdef WITH_LWIP
 5781|       |  coap_io_lwip_cleanup();
 5782|       |#endif /* WITH_LWIP */
 5783|     35|  coap_dtls_shutdown();
 5784|       |
 5785|     35|  coap_delete_upa_chain(coap_upa_client_fallback_chain);
 5786|     35|  coap_upa_client_fallback_chain = NULL;
 5787|     35|  coap_delete_upa_chain(coap_upa_server_mapping_chain);
 5788|     35|  coap_upa_server_mapping_chain = NULL;
 5789|       |#if COAP_THREAD_SAFE
 5790|       |  coap_mutex_destroy(&m_show_pdu);
 5791|       |  coap_mutex_destroy(&m_log_impl);
 5792|       |  coap_mutex_destroy(&m_io_threads);
 5793|       |#endif /* COAP_THREAD_SAFE */
 5794|       |
 5795|     35|  coap_debug_reset();
 5796|     35|}
coap_net.c:coap_is_session_proxy:
  968|    197|coap_is_session_proxy(coap_session_t *session, coap_pdu_t *pdu) {
  969|    197|#if COAP_SERVER_SUPPORT
  970|    197|  coap_opt_iterator_t t_iter;
  971|    197|  coap_opt_t *proxy_uri = NULL;
  972|    197|  coap_opt_t *proxy_scheme = NULL;
  973|       |
  974|    197|  if (session->proxy_session) {
  ------------------
  |  Branch (974:7): [True: 0, False: 197]
  ------------------
  975|      0|    return COAP_CRIT_PROXY;
  976|    197|  } else if (COAP_PDU_IS_REQUEST(pdu) && session->context->unknown_resource &&
  ------------------
  |  |   99|    394|#define COAP_PDU_IS_REQUEST(pdu)   (!COAP_PDU_IS_EMPTY(pdu) && (pdu)->code < 32)
  |  |  ------------------
  |  |  |  |   98|    394|#define COAP_PDU_IS_EMPTY(pdu)     ((pdu)->code == 0)
  |  |  ------------------
  |  |  |  Branch (99:37): [True: 197, False: 0]
  |  |  |  Branch (99:64): [True: 197, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (976:42): [True: 0, False: 197]
  ------------------
  977|      0|             session->context->unknown_resource->is_reverse_proxy) {
  ------------------
  |  Branch (977:14): [True: 0, False: 0]
  ------------------
  978|      0|    return COAP_CRIT_PROXY;
  979|    197|  } else if (COAP_PDU_IS_REQUEST(pdu) && session->context->proxy_uri_resource &&
  ------------------
  |  |   99|    394|#define COAP_PDU_IS_REQUEST(pdu)   (!COAP_PDU_IS_EMPTY(pdu) && (pdu)->code < 32)
  |  |  ------------------
  |  |  |  |   98|    394|#define COAP_PDU_IS_EMPTY(pdu)     ((pdu)->code == 0)
  |  |  ------------------
  |  |  |  Branch (99:37): [True: 197, False: 0]
  |  |  |  Branch (99:64): [True: 197, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (979:42): [True: 0, False: 197]
  ------------------
  980|      0|             ((proxy_uri = coap_check_option(pdu, COAP_OPTION_PROXY_URI, &t_iter)) ||
  ------------------
  |  Branch (980:15): [True: 0, False: 0]
  ------------------
  981|      0|              (proxy_scheme = coap_check_option(pdu, COAP_OPTION_PROXY_SCHEME, &t_iter)))) {
  ------------------
  |  Branch (981:15): [True: 0, False: 0]
  ------------------
  982|      0|    if (proxy_uri || proxy_scheme) {
  ------------------
  |  Branch (982:9): [True: 0, False: 0]
  |  Branch (982:22): [True: 0, False: 0]
  ------------------
  983|      0|      coap_uri_t uri;
  984|       |
  985|       |      /* Duplicates some of the code in handle_request() */
  986|      0|      if (proxy_uri) {
  ------------------
  |  Branch (986:11): [True: 0, False: 0]
  ------------------
  987|      0|        if (coap_split_proxy_uri(coap_opt_value(proxy_uri),
  ------------------
  |  Branch (987:13): [True: 0, False: 0]
  ------------------
  988|      0|                                 coap_opt_length(proxy_uri), &uri) < 0) {
  989|      0|          return COAP_CRIT_PROXY;
  990|      0|        }
  991|      0|      } else {
  992|      0|        coap_opt_t *opt;
  993|      0|        coap_resource_t *resource;
  994|       |
  995|      0|        memset(&uri, 0, sizeof(uri));
  996|      0|        opt = coap_check_option(pdu, COAP_OPTION_URI_HOST, &t_iter);
  997|      0|        if (opt) {
  ------------------
  |  Branch (997:13): [True: 0, False: 0]
  ------------------
  998|      0|          uri.host.length = coap_opt_length(opt);
  999|      0|          uri.host.s = coap_opt_value(opt);
 1000|      0|        } else {
 1001|      0|          uri.host.length = 0;
 1002|      0|        }
 1003|       |        /* See if we are the endpoint */
 1004|      0|        resource = session->context->proxy_uri_resource;
 1005|      0|        if (uri.host.length && resource->proxy_name_count &&
  ------------------
  |  Branch (1005:13): [True: 0, False: 0]
  |  Branch (1005:32): [True: 0, False: 0]
  ------------------
 1006|      0|            resource->proxy_name_list) {
  ------------------
  |  Branch (1006:13): [True: 0, False: 0]
  ------------------
 1007|      0|          size_t i;
 1008|       |
 1009|      0|          if (resource->proxy_name_count == 1 &&
  ------------------
  |  Branch (1009:15): [True: 0, False: 0]
  ------------------
 1010|      0|              resource->proxy_name_list[0]->length == 0) {
  ------------------
  |  Branch (1010:15): [True: 0, False: 0]
  ------------------
 1011|       |            /* If proxy_name_list[0] is zero length, then this is the endpoint */
 1012|      0|            i = 0;
 1013|      0|          } else {
 1014|      0|            for (i = 0; i < resource->proxy_name_count; i++) {
  ------------------
  |  Branch (1014:25): [True: 0, False: 0]
  ------------------
 1015|      0|              if (coap_string_equal(&uri.host, resource->proxy_name_list[i])) {
  ------------------
  |  |  209|      0|  ((string1)->length == (string2)->length && ((string1)->length == 0 || \
  |  |  ------------------
  |  |  |  Branch (209:4): [True: 0, False: 0]
  |  |  |  Branch (209:47): [True: 0, False: 0]
  |  |  ------------------
  |  |  210|      0|                                              ((string1)->s && (string2)->s && \
  |  |  ------------------
  |  |  |  Branch (210:48): [True: 0, False: 0]
  |  |  |  Branch (210:64): [True: 0, False: 0]
  |  |  ------------------
  |  |  211|      0|                                               memcmp((string1)->s, (string2)->s, (string1)->length) == 0)))
  |  |  ------------------
  |  |  |  Branch (211:48): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1016|      0|                break;
 1017|      0|              }
 1018|      0|            }
 1019|      0|          }
 1020|      0|          if (i != resource->proxy_name_count) {
  ------------------
  |  Branch (1020:15): [True: 0, False: 0]
  ------------------
 1021|      0|            return COAP_CRIT_NOT_PROXY;
 1022|      0|          }
 1023|      0|        }
 1024|      0|      }
 1025|      0|      return COAP_CRIT_PROXY;
 1026|      0|    }
 1027|      0|  }
 1028|    197|  return COAP_CRIT_NOT_PROXY;
 1029|       |#else /* ! COAP_SERVER_SUPPORT */
 1030|       |#endif /* ! COAP_SERVER_SUPPORT */
 1031|      0|  (void)session;
 1032|      0|  (void)pdu;
 1033|      0|  return COAP_CRIT_NOT_PROXY;
 1034|    197|}
coap_net.c:coap_send_pdu:
 1284|    216|coap_send_pdu(coap_session_t *session, coap_pdu_t *pdu, coap_queue_t *node) {
 1285|    216|  ssize_t bytes_written;
 1286|       |
 1287|    216|  if (session->disconnect_pending) {
  ------------------
  |  Branch (1287:7): [True: 0, False: 216]
  ------------------
 1288|       |    /* The session is about to be disconnected */
 1289|      0|    return -1;
 1290|      0|  }
 1291|    216|  if (session->state == COAP_SESSION_STATE_NONE) {
  ------------------
  |  Branch (1291:7): [True: 0, False: 216]
  ------------------
 1292|       |#if ! COAP_CLIENT_SUPPORT
 1293|       |    return -1;
 1294|       |#else /* COAP_CLIENT_SUPPORT */
 1295|      0|    if (session->type != COAP_SESSION_TYPE_CLIENT)
  ------------------
  |  Branch (1295:9): [True: 0, False: 0]
  ------------------
 1296|      0|      return -1;
 1297|      0|#endif /* COAP_CLIENT_SUPPORT */
 1298|      0|  }
 1299|       |
 1300|    216|  if (pdu->type == COAP_MESSAGE_CON &&
  ------------------
  |  Branch (1300:7): [True: 0, False: 216]
  ------------------
 1301|      0|      (session->sock.flags & COAP_SOCKET_NOT_EMPTY) &&
  ------------------
  |  |   75|      0|#define COAP_SOCKET_NOT_EMPTY    0x0001  /**< the socket is not empty */
  ------------------
  |  Branch (1301:7): [True: 0, False: 0]
  ------------------
 1302|      0|      coap_is_mcast(&session->addr_info.remote)) {
  ------------------
  |  Branch (1302:7): [True: 0, False: 0]
  ------------------
 1303|       |    /* Violates RFC72522 8.1 */
 1304|      0|    coap_log_err("Multicast requests cannot be Confirmable (RFC7252 8.1)\n");
  ------------------
  |  |  102|      0|#define coap_log_err(...) coap_log(COAP_LOG_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1305|      0|    return -1;
 1306|      0|  }
 1307|       |
 1308|    216|  if (session->state != COAP_SESSION_STATE_ESTABLISHED ||
  ------------------
  |  Branch (1308:7): [True: 0, False: 216]
  ------------------
 1309|    216|      (pdu->type == COAP_MESSAGE_CON &&
  ------------------
  |  Branch (1309:8): [True: 0, False: 216]
  ------------------
 1310|      0|       session->con_active >= COAP_NSTART(session))) {
  ------------------
  |  |  876|      0|#define COAP_NSTART(s) ((s)->nstart)
  ------------------
  |  Branch (1310:8): [True: 0, False: 0]
  ------------------
 1311|      0|    return coap_session_delay_pdu(session, pdu, node);
 1312|      0|  }
 1313|       |
 1314|    216|  if ((session->sock.flags & COAP_SOCKET_NOT_EMPTY) &&
  ------------------
  |  |   75|    216|#define COAP_SOCKET_NOT_EMPTY    0x0001  /**< the socket is not empty */
  ------------------
  |  Branch (1314:7): [True: 70, False: 146]
  ------------------
 1315|     70|      (session->sock.flags & COAP_SOCKET_WANT_WRITE))
  ------------------
  |  |   80|     70|#define COAP_SOCKET_WANT_WRITE   0x0020  /**< non blocking socket is waiting for writing */
  ------------------
  |  Branch (1315:7): [True: 0, False: 70]
  ------------------
 1316|      0|    return coap_session_delay_pdu(session, pdu, node);
 1317|       |
 1318|    216|  bytes_written = coap_session_send_pdu(session, pdu);
 1319|    216|  if (bytes_written >= 0 && pdu->type == COAP_MESSAGE_CON &&
  ------------------
  |  Branch (1319:7): [True: 101, False: 115]
  |  Branch (1319:29): [True: 0, False: 101]
  ------------------
 1320|      0|      COAP_PROTO_NOT_RELIABLE(session->proto))
  ------------------
  |  |   41|      0|#define COAP_PROTO_NOT_RELIABLE(p) ((p)==COAP_PROTO_UDP || (p)==COAP_PROTO_DTLS)
  |  |  ------------------
  |  |  |  Branch (41:37): [True: 0, False: 0]
  |  |  |  Branch (41:60): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1321|      0|    session->con_active++;
 1322|    216|  return bytes_written;
 1323|    216|}
coap_net.c:coap_dispatch_pdu:
 4907|    103|                  coap_pdu_t *pdu) {
 4908|    103|  coap_queue_t *sent = NULL;
 4909|    103|  coap_pdu_t *response;
 4910|    103|  coap_pdu_t *orig_pdu = NULL;
 4911|    103|  coap_opt_filter_t opt_filter;
 4912|    103|  int is_ping_rst;
 4913|    103|  int packet_is_bad = 0;
 4914|    103|#if COAP_OSCORE_SUPPORT
 4915|    103|  coap_opt_iterator_t opt_iter;
 4916|    103|  coap_pdu_t *dec_pdu = NULL;
 4917|    103|#endif /* COAP_OSCORE_SUPPORT */
 4918|    103|  int is_ext_token_rst = 0;
 4919|    103|  int oscore_invalid = 0;
 4920|    103|  int is_local_mcast = 0;
 4921|       |
 4922|    103|  coap_pdu_reference_lkd(pdu);
 4923|    103|  pdu->session = session;
 4924|    103|  coap_show_pdu(COAP_LOG_DEBUG, pdu);
 4925|       |
 4926|    103|  if (COAP_PDU_IS_REQUEST(pdu) && coap_is_mcast(&session->addr_info.local)) {
  ------------------
  |  |   99|    206|#define COAP_PDU_IS_REQUEST(pdu)   (!COAP_PDU_IS_EMPTY(pdu) && (pdu)->code < 32)
  |  |  ------------------
  |  |  |  |   98|    206|#define COAP_PDU_IS_EMPTY(pdu)     ((pdu)->code == 0)
  |  |  ------------------
  |  |  |  Branch (99:37): [True: 103, False: 0]
  |  |  |  Branch (99:64): [True: 102, False: 1]
  |  |  ------------------
  ------------------
  |  Branch (4926:35): [True: 0, False: 102]
  ------------------
 4927|       |    /* Need to be careful with responses to multicast requests */
 4928|      0|    is_local_mcast = 1;
 4929|      0|    if (COAP_PROTO_RELIABLE(session->proto) || pdu->type != COAP_MESSAGE_NON) {
  ------------------
  |  |   42|      0|#define COAP_PROTO_RELIABLE(p) ((p)==COAP_PROTO_TCP || (p)==COAP_PROTO_TLS || \
  |  |  ------------------
  |  |  |  Branch (42:33): [True: 0, False: 0]
  |  |  |  Branch (42:56): [True: 0, False: 0]
  |  |  ------------------
  |  |   43|      0|                                (p)==COAP_PROTO_WS || (p)==COAP_PROTO_WSS)
  |  |  ------------------
  |  |  |  Branch (43:33): [True: 0, False: 0]
  |  |  |  Branch (43:55): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (4929:48): [True: 0, False: 0]
  ------------------
 4930|      0|      coap_log_info("Invalid multicast packet received RFC7252 8.1\n");
  ------------------
  |  |  114|      0|#define coap_log_info(...) coap_log(COAP_LOG_INFO, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4931|      0|      return;
 4932|      0|    }
 4933|      0|  }
 4934|       |
 4935|       |  /* Check validity of received code */
 4936|    103|  if (!coap_check_code_class(session, pdu)) {
  ------------------
  |  Branch (4936:7): [True: 0, False: 103]
  ------------------
 4937|      0|    coap_log_info("coap_dispatch: Received invalid PDU code (%d.%02d)\n",
  ------------------
  |  |  114|      0|#define coap_log_info(...) coap_log(COAP_LOG_INFO, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4938|      0|                  COAP_RESPONSE_CLASS(pdu->code),
 4939|      0|                  pdu->code & 0x1f);
 4940|      0|    packet_is_bad = 1;
 4941|      0|    if (pdu->type == COAP_MESSAGE_CON) {
  ------------------
  |  Branch (4941:9): [True: 0, False: 0]
  ------------------
 4942|      0|      coap_send_message_type_lkd(session, pdu, COAP_MESSAGE_RST);
 4943|      0|    }
 4944|       |    /* find message id in sendqueue to stop retransmission (code is not 0.00) */
 4945|      0|    coap_remove_from_queue(&context->sendqueue, session, pdu->mid, &pdu->actual_token, &sent);
 4946|      0|    goto cleanup;
 4947|      0|  }
 4948|       |
 4949|    103|  coap_option_filter_clear(&opt_filter);
 4950|       |
 4951|    103|#if COAP_SERVER_SUPPORT
 4952|       |  /* See if this a repeat request */
 4953|    103|  if (COAP_PDU_IS_REQUEST(pdu) && session->last_resp_pdu &&
  ------------------
  |  |   99|    206|#define COAP_PDU_IS_REQUEST(pdu)   (!COAP_PDU_IS_EMPTY(pdu) && (pdu)->code < 32)
  |  |  ------------------
  |  |  |  |   98|    206|#define COAP_PDU_IS_EMPTY(pdu)     ((pdu)->code == 0)
  |  |  ------------------
  |  |  |  Branch (99:37): [True: 103, False: 0]
  |  |  |  Branch (99:64): [True: 102, False: 1]
  |  |  ------------------
  ------------------
  |  Branch (4953:35): [True: 67, False: 35]
  ------------------
 4954|     67|      pdu->mid == session->last_resp_pdu->mid) {
  ------------------
  |  Branch (4954:7): [True: 0, False: 67]
  ------------------
 4955|      0|#if COAP_OSCORE_SUPPORT
 4956|      0|    uint8_t oscore_encryption = session->oscore_encryption;
 4957|       |
 4958|      0|    session->oscore_encryption = 0;
 4959|      0|#endif /* COAP_OSCORE_SUPPORT */
 4960|       |    /* Account for coap_send_internal() doing a coap_delete_pdu() and
 4961|       |       last_resp_pdu must not be removed */
 4962|      0|    coap_pdu_reference_lkd(session->last_resp_pdu);
 4963|      0|    coap_log_debug("Retransmit response to duplicate request\n");
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4964|      0|    if (coap_send_internal(session, session->last_resp_pdu, NULL) != COAP_INVALID_MID) {
  ------------------
  |  |  198|      0|#define COAP_INVALID_MID -1
  ------------------
  |  Branch (4964:9): [True: 0, False: 0]
  ------------------
 4965|      0|#if COAP_OSCORE_SUPPORT
 4966|      0|      session->oscore_encryption = oscore_encryption;
 4967|      0|#endif /* COAP_OSCORE_SUPPORT */
 4968|      0|      goto finish;
 4969|      0|    }
 4970|      0|#if COAP_OSCORE_SUPPORT
 4971|      0|    session->oscore_encryption = oscore_encryption;
 4972|      0|#endif /* COAP_OSCORE_SUPPORT */
 4973|      0|  }
 4974|    103|#endif /* COAP_SERVER_SUPPORT */
 4975|    103|  if (pdu->type == COAP_MESSAGE_NON || pdu->type == COAP_MESSAGE_CON) {
  ------------------
  |  Branch (4975:7): [True: 11, False: 92]
  |  Branch (4975:40): [True: 89, False: 3]
  ------------------
 4976|    100|    if (!check_token_size(session, pdu, is_local_mcast)) {
  ------------------
  |  Branch (4976:9): [True: 0, False: 100]
  ------------------
 4977|      0|      goto cleanup;
 4978|      0|    }
 4979|    100|  }
 4980|    103|#if COAP_OSCORE_SUPPORT
 4981|    103|  if (!COAP_PDU_IS_SIGNALING(pdu) &&
  ------------------
  |  |  102|    206|#define COAP_PDU_IS_SIGNALING(pdu) ((pdu)->code >= 224)
  ------------------
  |  Branch (4981:7): [True: 103, False: 0]
  ------------------
 4982|    103|      coap_option_check_critical(session, pdu, &opt_filter, COAP_CRIT_UNKNOWN) == 0) {
  ------------------
  |  Branch (4982:7): [True: 1, False: 102]
  ------------------
 4983|      1|    if (!is_local_mcast && (pdu->type == COAP_MESSAGE_CON || pdu->type == COAP_MESSAGE_NON)) {
  ------------------
  |  Branch (4983:9): [True: 1, False: 0]
  |  Branch (4983:29): [True: 0, False: 1]
  |  Branch (4983:62): [True: 0, False: 1]
  ------------------
 4984|      0|      if (COAP_PDU_IS_REQUEST(pdu)) {
  ------------------
  |  |   99|      0|#define COAP_PDU_IS_REQUEST(pdu)   (!COAP_PDU_IS_EMPTY(pdu) && (pdu)->code < 32)
  |  |  ------------------
  |  |  |  |   98|      0|#define COAP_PDU_IS_EMPTY(pdu)     ((pdu)->code == 0)
  |  |  ------------------
  |  |  |  Branch (99:37): [True: 0, False: 0]
  |  |  |  Branch (99:64): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 4985|      0|        response =
 4986|      0|            coap_new_error_response(pdu, COAP_RESPONSE_CODE(402), &opt_filter);
  ------------------
  |  |   96|      0|#define COAP_RESPONSE_CODE(N) (((N)/100 << 5) | (N)%100)
  ------------------
 4987|       |
 4988|      0|        if (!response) {
  ------------------
  |  Branch (4988:13): [True: 0, False: 0]
  ------------------
 4989|      0|          coap_log_warn("coap_dispatch: cannot create error response\n");
  ------------------
  |  |  108|      0|#define coap_log_warn(...) coap_log(COAP_LOG_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4990|      0|        } else {
 4991|      0|          if (coap_send_internal(session, response, NULL) == COAP_INVALID_MID)
  ------------------
  |  |  198|      0|#define COAP_INVALID_MID -1
  ------------------
  |  Branch (4991:15): [True: 0, False: 0]
  ------------------
 4992|      0|            coap_log_warn("coap_dispatch: error sending response\n");
  ------------------
  |  |  108|      0|#define coap_log_warn(...) coap_log(COAP_LOG_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4993|      0|        }
 4994|      0|      } else {
 4995|      0|        coap_send_rst_lkd(session, pdu);
 4996|      0|      }
 4997|      0|    }
 4998|      1|    goto cleanup;
 4999|      1|  }
 5000|       |
 5001|    102|  if (coap_check_option(pdu, COAP_OPTION_OSCORE, &opt_iter) != NULL) {
  ------------------
  |  Branch (5001:7): [True: 0, False: 102]
  ------------------
 5002|      0|    int decrypt = 1;
 5003|      0|#if COAP_SERVER_SUPPORT
 5004|      0|    coap_opt_t *opt;
 5005|      0|    coap_resource_t *resource;
 5006|      0|    coap_uri_t uri;
 5007|      0|#endif /* COAP_SERVER_SUPPORT */
 5008|       |
 5009|      0|    if (COAP_PDU_IS_RESPONSE(pdu) && !session->oscore_encryption)
  ------------------
  |  |  101|      0|#define COAP_PDU_IS_RESPONSE(pdu)  ((pdu)->code >= 64 && (pdu)->code < 192)
  |  |  ------------------
  |  |  |  Branch (101:37): [True: 0, False: 0]
  |  |  |  Branch (101:58): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (5009:38): [True: 0, False: 0]
  ------------------
 5010|      0|      decrypt = 0;
 5011|       |
 5012|      0|#if COAP_SERVER_SUPPORT
 5013|      0|    if (decrypt && COAP_PDU_IS_REQUEST(pdu) &&
  ------------------
  |  |   99|      0|#define COAP_PDU_IS_REQUEST(pdu)   (!COAP_PDU_IS_EMPTY(pdu) && (pdu)->code < 32)
  |  |  ------------------
  |  |  |  |   98|      0|#define COAP_PDU_IS_EMPTY(pdu)     ((pdu)->code == 0)
  |  |  ------------------
  |  |  |  Branch (99:37): [True: 0, False: 0]
  |  |  |  Branch (99:64): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (5013:9): [True: 0, False: 0]
  ------------------
 5014|      0|        coap_check_option(pdu, COAP_OPTION_PROXY_SCHEME, &opt_iter) != NULL &&
  ------------------
  |  Branch (5014:9): [True: 0, False: 0]
  ------------------
 5015|      0|        (opt = coap_check_option(pdu, COAP_OPTION_URI_HOST, &opt_iter))
  ------------------
  |  Branch (5015:9): [True: 0, False: 0]
  ------------------
 5016|      0|        != NULL) {
 5017|       |      /* Need to check whether this is a direct or proxy session */
 5018|      0|      memset(&uri, 0, sizeof(uri));
 5019|      0|      uri.host.length = coap_opt_length(opt);
 5020|      0|      uri.host.s = coap_opt_value(opt);
 5021|      0|      resource = context->proxy_uri_resource;
 5022|      0|      if (uri.host.length && resource && resource->proxy_name_count &&
  ------------------
  |  Branch (5022:11): [True: 0, False: 0]
  |  Branch (5022:30): [True: 0, False: 0]
  |  Branch (5022:42): [True: 0, False: 0]
  ------------------
 5023|      0|          resource->proxy_name_list) {
  ------------------
  |  Branch (5023:11): [True: 0, False: 0]
  ------------------
 5024|      0|        size_t i;
 5025|      0|        for (i = 0; i < resource->proxy_name_count; i++) {
  ------------------
  |  Branch (5025:21): [True: 0, False: 0]
  ------------------
 5026|      0|          if (coap_string_equal(&uri.host, resource->proxy_name_list[i])) {
  ------------------
  |  |  209|      0|  ((string1)->length == (string2)->length && ((string1)->length == 0 || \
  |  |  ------------------
  |  |  |  Branch (209:4): [True: 0, False: 0]
  |  |  |  Branch (209:47): [True: 0, False: 0]
  |  |  ------------------
  |  |  210|      0|                                              ((string1)->s && (string2)->s && \
  |  |  ------------------
  |  |  |  Branch (210:48): [True: 0, False: 0]
  |  |  |  Branch (210:64): [True: 0, False: 0]
  |  |  ------------------
  |  |  211|      0|                                               memcmp((string1)->s, (string2)->s, (string1)->length) == 0)))
  |  |  ------------------
  |  |  |  Branch (211:48): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 5027|      0|            break;
 5028|      0|          }
 5029|      0|        }
 5030|      0|        if (i == resource->proxy_name_count) {
  ------------------
  |  Branch (5030:13): [True: 0, False: 0]
  ------------------
 5031|       |          /* This server is not hosting the proxy connection endpoint */
 5032|      0|          decrypt = 0;
 5033|      0|        }
 5034|      0|      }
 5035|      0|    }
 5036|      0|#endif /* COAP_SERVER_SUPPORT */
 5037|      0|    if (decrypt) {
  ------------------
  |  Branch (5037:9): [True: 0, False: 0]
  ------------------
 5038|      0|#if COAP_ASYNC_SUPPORT
 5039|       |      /*
 5040|       |       * RFC7252 request deduplication must run before OSCORE replay checks
 5041|       |       * (RFC8613).  A retransmitted CON for a request with a pending separate
 5042|       |       * (async) response carries the same Sender Sequence Number and would
 5043|       |       * otherwise be rejected during decrypt with an unprotected 4.01 instead
 5044|       |       * of retransmitting the empty ACK.  The outer token matches the pending
 5045|       |       * async entry (see handle_request()).
 5046|       |       */
 5047|      0|      if (COAP_PDU_IS_REQUEST(pdu) && pdu->type == COAP_MESSAGE_CON) {
  ------------------
  |  |   99|      0|#define COAP_PDU_IS_REQUEST(pdu)   (!COAP_PDU_IS_EMPTY(pdu) && (pdu)->code < 32)
  |  |  ------------------
  |  |  |  |   98|      0|#define COAP_PDU_IS_EMPTY(pdu)     ((pdu)->code == 0)
  |  |  ------------------
  |  |  |  Branch (99:37): [True: 0, False: 0]
  |  |  |  Branch (99:64): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (5047:39): [True: 0, False: 0]
  ------------------
 5048|      0|        coap_async_t *dup_async = coap_find_async_lkd(session, pdu->actual_token);
 5049|       |
 5050|      0|        if (dup_async) {
  ------------------
  |  Branch (5050:13): [True: 0, False: 0]
  ------------------
 5051|      0|          coap_tick_t now;
 5052|       |
 5053|      0|          coap_ticks(&now);
 5054|      0|          if (dup_async->delay == 0 || dup_async->delay > now) {
  ------------------
  |  Branch (5054:15): [True: 0, False: 0]
  |  Branch (5054:40): [True: 0, False: 0]
  ------------------
 5055|      0|            coap_log_info("Duplicate request, async response pending\n");
  ------------------
  |  |  114|      0|#define coap_log_info(...) coap_log(COAP_LOG_INFO, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5056|      0|            coap_send_ack_lkd(session, pdu);
 5057|      0|            goto finish;
 5058|      0|          }
 5059|      0|        }
 5060|      0|      }
 5061|      0|#endif /* COAP_ASYNC_SUPPORT */
 5062|       |      /* find message id in sendqueue to stop retransmission and get sent (not empty packet) */
 5063|      0|      coap_remove_from_queue(&context->sendqueue, session, pdu->mid, &pdu->actual_token, &sent);
 5064|       |      /* Bump ref so pdu is not freed of, and keep a pointer to it */
 5065|      0|      orig_pdu = pdu;
 5066|      0|      coap_pdu_reference_lkd(orig_pdu);
 5067|      0|      if ((dec_pdu = coap_oscore_decrypt_pdu(session, pdu)) == NULL) {
  ------------------
  |  Branch (5067:11): [True: 0, False: 0]
  ------------------
 5068|      0|        if (session->recipient_ctx == NULL ||
  ------------------
  |  Branch (5068:13): [True: 0, False: 0]
  ------------------
 5069|      0|            (session->recipient_ctx->initial_state == 0 &&
  ------------------
  |  Branch (5069:14): [True: 0, False: 0]
  ------------------
 5070|      0|             session->b_2_step == COAP_OSCORE_B_2_NONE)) {
  ------------------
  |  Branch (5070:14): [True: 0, False: 0]
  ------------------
 5071|      0|          coap_log_warn("OSCORE: PDU could not be decrypted\n");
  ------------------
  |  |  108|      0|#define coap_log_warn(...) coap_log(COAP_LOG_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5072|      0|        }
 5073|      0|        coap_delete_node_lkd(sent);
 5074|      0|        coap_delete_pdu_lkd(orig_pdu);
 5075|      0|        goto finish;
 5076|      0|      } else {
 5077|      0|        session->oscore_encryption = 1;
 5078|      0|        coap_pdu_reference_lkd(dec_pdu);
 5079|      0|        coap_pdu_release_lkd(pdu);
 5080|      0|        pdu = dec_pdu;
 5081|      0|      }
 5082|      0|      coap_log_debug("Decrypted PDU\n");
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5083|      0|      coap_show_pdu(COAP_LOG_DEBUG, pdu);
 5084|      0|    }
 5085|    102|  } else if (COAP_PDU_IS_RESPONSE(pdu) &&
  ------------------
  |  |  101|    204|#define COAP_PDU_IS_RESPONSE(pdu)  ((pdu)->code >= 64 && (pdu)->code < 192)
  |  |  ------------------
  |  |  |  Branch (101:37): [True: 1, False: 101]
  |  |  |  Branch (101:58): [True: 1, False: 0]
  |  |  ------------------
  ------------------
 5086|      1|             session->oscore_encryption &&
  ------------------
  |  Branch (5086:14): [True: 0, False: 1]
  ------------------
 5087|      0|             pdu->type != COAP_MESSAGE_RST) {
  ------------------
  |  Branch (5087:14): [True: 0, False: 0]
  ------------------
 5088|      0|    if (COAP_RESPONSE_CLASS(pdu->code) == 2) {
  ------------------
  |  |   99|      0|#define COAP_RESPONSE_CLASS(C) (((C) >> 5) & 0xFF)
  ------------------
  |  Branch (5088:9): [True: 0, False: 0]
  ------------------
 5089|       |      /* Violates RFC 8613 2 */
 5090|      0|      coap_log_err("received an invalid response to the OSCORE request\n");
  ------------------
  |  |  102|      0|#define coap_log_err(...) coap_log(COAP_LOG_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5091|      0|      oscore_invalid = 1;
 5092|      0|    }
 5093|      0|  }
 5094|    102|#endif /* COAP_OSCORE_SUPPORT */
 5095|       |
 5096|    102|  switch (pdu->type) {
 5097|      0|  case COAP_MESSAGE_ACK:
  ------------------
  |  Branch (5097:3): [True: 0, False: 102]
  ------------------
 5098|      0|    if (NULL == sent) {
  ------------------
  |  Branch (5098:9): [True: 0, False: 0]
  ------------------
 5099|       |      /* find message id in sendqueue to stop retransmission (no token if empty) */
 5100|      0|      coap_remove_from_queue(&context->sendqueue, session, pdu->mid,
 5101|      0|                             pdu->code == 0 ? NULL : &pdu->actual_token, &sent);
  ------------------
  |  Branch (5101:30): [True: 0, False: 0]
  ------------------
 5102|      0|    }
 5103|       |
 5104|      0|    if (sent && session->con_active) {
  ------------------
  |  Branch (5104:9): [True: 0, False: 0]
  |  Branch (5104:17): [True: 0, False: 0]
  ------------------
 5105|      0|      session->con_active--;
 5106|      0|      if (session->state == COAP_SESSION_STATE_ESTABLISHED)
  ------------------
  |  Branch (5106:11): [True: 0, False: 0]
  ------------------
 5107|       |        /* Flush out any entries on session->delayqueue */
 5108|      0|        coap_session_connected(session);
 5109|      0|    }
 5110|      0|    if (oscore_invalid ||
  ------------------
  |  Branch (5110:9): [True: 0, False: 0]
  ------------------
 5111|      0|        coap_option_check_critical(session, pdu, &opt_filter, COAP_CRIT_UNKNOWN) == 0) {
  ------------------
  |  Branch (5111:9): [True: 0, False: 0]
  ------------------
 5112|      0|      packet_is_bad = 1;
 5113|      0|      goto cleanup;
 5114|      0|    }
 5115|       |
 5116|      0|#if COAP_SERVER_SUPPORT
 5117|       |    /* if sent code was >= 64 the message might have been a
 5118|       |     * notification. Then, we must flag the observer to be alive
 5119|       |     * by setting obs->fail_cnt = 0. */
 5120|      0|    if (sent && COAP_RESPONSE_CLASS(sent->pdu->code) == 2) {
  ------------------
  |  |   99|      0|#define COAP_RESPONSE_CLASS(C) (((C) >> 5) & 0xFF)
  ------------------
  |  Branch (5120:9): [True: 0, False: 0]
  |  Branch (5120:17): [True: 0, False: 0]
  ------------------
 5121|      0|      coap_touch_observer(context, sent->session, &sent->pdu->actual_token);
 5122|      0|    }
 5123|      0|#endif /* COAP_SERVER_SUPPORT */
 5124|       |
 5125|      0|#if COAP_Q_BLOCK_SUPPORT
 5126|      0|    if (session->lg_xmit && sent && sent->pdu && sent->pdu->type == COAP_MESSAGE_CON &&
  ------------------
  |  Branch (5126:9): [True: 0, False: 0]
  |  Branch (5126:29): [True: 0, False: 0]
  |  Branch (5126:37): [True: 0, False: 0]
  |  Branch (5126:50): [True: 0, False: 0]
  ------------------
 5127|      0|        !(session->block_mode & COAP_BLOCK_PROBE_Q_BLOCK)) {
  ------------------
  |  |   74|      0|#define COAP_BLOCK_PROBE_Q_BLOCK 0x80000000 /* Set when Q_BLOCK probing */
  ------------------
  |  Branch (5127:9): [True: 0, False: 0]
  ------------------
 5128|      0|      int doing_q_block = 0;
 5129|      0|      coap_lg_xmit_t *lg_xmit = NULL;
 5130|       |
 5131|      0|      LL_FOREACH(session->lg_xmit, lg_xmit) {
  ------------------
  |  |  419|      0|    LL_FOREACH2(head,el,next)
  |  |  ------------------
  |  |  |  |  422|      0|    for ((el) = (head); el; (el) = (el)->next)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (422:25): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5132|      0|        if ((lg_xmit->option == COAP_OPTION_Q_BLOCK1 || lg_xmit->option == COAP_OPTION_Q_BLOCK2) &&
  ------------------
  |  Branch (5132:14): [True: 0, False: 0]
  |  Branch (5132:57): [True: 0, False: 0]
  ------------------
 5133|      0|            lg_xmit->last_all_sent == 0 && lg_xmit->sent_pdu->type != COAP_MESSAGE_NON) {
  ------------------
  |  Branch (5133:13): [True: 0, False: 0]
  |  Branch (5133:44): [True: 0, False: 0]
  ------------------
 5134|      0|          doing_q_block = 1;
 5135|      0|          break;
 5136|      0|        }
 5137|      0|      }
 5138|      0|      if (doing_q_block && lg_xmit) {
  ------------------
  |  Branch (5138:11): [True: 0, False: 0]
  |  Branch (5138:28): [True: 0, False: 0]
  ------------------
 5139|      0|        coap_block_b_t block;
 5140|       |
 5141|      0|        memset(&block, 0, sizeof(block));
 5142|      0|        if (lg_xmit->option == COAP_OPTION_Q_BLOCK1) {
  ------------------
  |  Branch (5142:13): [True: 0, False: 0]
  ------------------
 5143|      0|          block.num = lg_xmit->last_block + lg_xmit->b.b1.count;
 5144|      0|        } else {
 5145|      0|          block.num = lg_xmit->last_block;
 5146|      0|        }
 5147|      0|        block.m = 1;
 5148|      0|        block.szx = block.aszx = lg_xmit->blk_size;
 5149|      0|        block.defined = 1;
 5150|      0|        block.bert = 0;
 5151|      0|        block.chunk_size = 1024;
 5152|       |
 5153|      0|        coap_send_q_blocks(session, lg_xmit, block,
 5154|      0|                           lg_xmit->sent_pdu, COAP_SEND_SKIP_PDU);
 5155|      0|      }
 5156|      0|    }
 5157|      0|#endif /* COAP_Q_BLOCK_SUPPORT */
 5158|      0|    if (pdu->code == 0) {
  ------------------
  |  Branch (5158:9): [True: 0, False: 0]
  ------------------
 5159|      0|#if COAP_CLIENT_SUPPORT
 5160|       |      /*
 5161|       |       * In coap_send(), lg_crcv was not set up if type is CON and protocol is not
 5162|       |       * reliable to save overhead as this can be set up on detection of a (Q)-Block2
 5163|       |       * response if the response was piggy-backed. Here, a separate response
 5164|       |       * detected and so the lg_crcv needs to be set up before the sent PDU
 5165|       |       * information is lost.
 5166|       |       *
 5167|       |       * lg_crcv was not set up if not a CoAP request.
 5168|       |       *
 5169|       |       * lg_crcv was always set up in coap_send() if Observe, Oscore and (Q)-Block1
 5170|       |       * options.
 5171|       |       */
 5172|      0|      if (sent &&
  ------------------
  |  Branch (5172:11): [True: 0, False: 0]
  ------------------
 5173|      0|          !coap_check_send_need_lg_crcv(session, sent->pdu) &&
  ------------------
  |  Branch (5173:11): [True: 0, False: 0]
  ------------------
 5174|      0|          COAP_PDU_IS_REQUEST(sent->pdu)) {
  ------------------
  |  |   99|      0|#define COAP_PDU_IS_REQUEST(pdu)   (!COAP_PDU_IS_EMPTY(pdu) && (pdu)->code < 32)
  |  |  ------------------
  |  |  |  |   98|      0|#define COAP_PDU_IS_EMPTY(pdu)     ((pdu)->code == 0)
  |  |  ------------------
  |  |  |  Branch (99:37): [True: 0, False: 0]
  |  |  |  Branch (99:64): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 5175|       |        /*
 5176|       |         * lg_crcv was not set up in coap_send(). It could have been set up
 5177|       |         * the first separate response.
 5178|       |         * See if there already is a lg_crcv set up.
 5179|       |         */
 5180|      0|        coap_lg_crcv_t *lg_crcv;
 5181|      0|        uint64_t token_match =
 5182|      0|            STATE_TOKEN_BASE(coap_decode_var_bytes8(sent->pdu->actual_token.s,
  ------------------
  |  |   41|      0|#define STATE_TOKEN_BASE(t) ((t) & (0xffffffffffffffffULL >> STATE_MAX_BLK_CNT_BITS))
  |  |  ------------------
  |  |  |  |   39|      0|#define STATE_MAX_BLK_CNT_BITS 20
  |  |  ------------------
  ------------------
 5183|      0|                                                    sent->pdu->actual_token.length));
 5184|       |
 5185|      0|        LL_FOREACH(session->lg_crcv, lg_crcv) {
  ------------------
  |  |  419|      0|    LL_FOREACH2(head,el,next)
  |  |  ------------------
  |  |  |  |  422|      0|    for ((el) = (head); el; (el) = (el)->next)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (422:25): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5186|      0|          if (token_match == STATE_TOKEN_BASE(lg_crcv->state_token) ||
  ------------------
  |  |   41|      0|#define STATE_TOKEN_BASE(t) ((t) & (0xffffffffffffffffULL >> STATE_MAX_BLK_CNT_BITS))
  |  |  ------------------
  |  |  |  |   39|      0|#define STATE_MAX_BLK_CNT_BITS 20
  |  |  ------------------
  ------------------
  |  Branch (5186:15): [True: 0, False: 0]
  ------------------
 5187|      0|              coap_binary_equal(&sent->pdu->actual_token, lg_crcv->app_token)) {
  ------------------
  |  |  223|      0|  ((binary1)->length == (binary2)->length && ((binary1)->length == 0 || \
  |  |  ------------------
  |  |  |  Branch (223:4): [True: 0, False: 0]
  |  |  |  Branch (223:47): [True: 0, False: 0]
  |  |  ------------------
  |  |  224|      0|                                              ((binary1)->s && (binary2)->s && \
  |  |  ------------------
  |  |  |  Branch (224:48): [True: 0, False: 0]
  |  |  |  Branch (224:64): [True: 0, False: 0]
  |  |  ------------------
  |  |  225|      0|                                               memcmp((binary1)->s, (binary2)->s, (binary1)->length) == 0)))
  |  |  ------------------
  |  |  |  Branch (225:48): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 5188|      0|            break;
 5189|      0|          }
 5190|      0|        }
 5191|      0|        if (!lg_crcv) {
  ------------------
  |  Branch (5191:13): [True: 0, False: 0]
  ------------------
 5192|       |          /*
 5193|       |           * Need to set up a lg_crcv as it was not set up in coap_send()
 5194|       |           * to save time, but server has not sent back a piggy-back response.
 5195|       |           */
 5196|      0|          lg_crcv = coap_block_new_lg_crcv(session, sent->pdu, NULL);
 5197|      0|          if (lg_crcv) {
  ------------------
  |  Branch (5197:15): [True: 0, False: 0]
  ------------------
 5198|      0|            LL_PREPEND(session->lg_crcv, lg_crcv);
  ------------------
  |  |  320|      0|    LL_PREPEND2(head,add,next)
  |  |  ------------------
  |  |  |  |  322|      0|#define LL_PREPEND2(head,add,next)                                                             \
  |  |  |  |  323|      0|do {                                                                                           \
  |  |  |  |  324|      0|  (add)->next = (head);                                                                        \
  |  |  |  |  325|      0|  (head) = (add);                                                                              \
  |  |  |  |  326|      0|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (326:10): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5199|      0|          }
 5200|      0|        }
 5201|      0|      }
 5202|      0|#endif /* COAP_CLIENT_SUPPORT */
 5203|       |      /* an empty ACK needs no further handling */
 5204|      0|      goto cleanup;
 5205|      0|    } else if (COAP_PDU_IS_REQUEST(pdu)) {
  ------------------
  |  |   99|      0|#define COAP_PDU_IS_REQUEST(pdu)   (!COAP_PDU_IS_EMPTY(pdu) && (pdu)->code < 32)
  |  |  ------------------
  |  |  |  |   98|      0|#define COAP_PDU_IS_EMPTY(pdu)     ((pdu)->code == 0)
  |  |  ------------------
  |  |  |  Branch (99:37): [True: 0, False: 0]
  |  |  |  Branch (99:64): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 5206|       |      /* This is not legitimate - Request using ACK - ignore */
 5207|      0|      coap_log_debug("dropped ACK with request code (%d.%02d)\n",
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5208|      0|                     COAP_RESPONSE_CLASS(pdu->code),
 5209|      0|                     pdu->code & 0x1f);
 5210|      0|      packet_is_bad = 1;
 5211|      0|      goto cleanup;
 5212|      0|    }
 5213|       |
 5214|      0|    break;
 5215|       |
 5216|      2|  case COAP_MESSAGE_RST:
  ------------------
  |  Branch (5216:3): [True: 2, False: 100]
  ------------------
 5217|       |    /* We have sent something the receiver disliked, so we remove
 5218|       |     * not only the message id but also the subscriptions we might
 5219|       |     * have. */
 5220|      2|    is_ping_rst = 0;
 5221|      2|    if (pdu->mid == session->last_ping_mid &&
  ------------------
  |  Branch (5221:9): [True: 0, False: 2]
  ------------------
 5222|      0|        session->last_ping > 0)
  ------------------
  |  Branch (5222:9): [True: 0, False: 0]
  ------------------
 5223|      0|      is_ping_rst = 1;
 5224|       |
 5225|      2|#if COAP_CLIENT_SUPPORT
 5226|      2|#if COAP_Q_BLOCK_SUPPORT
 5227|       |    /* Check to see if checking out Q-Block support */
 5228|      2|    if (session->block_mode & COAP_BLOCK_PROBE_Q_BLOCK &&
  ------------------
  |  |   74|      4|#define COAP_BLOCK_PROBE_Q_BLOCK 0x80000000 /* Set when Q_BLOCK probing */
  ------------------
  |  Branch (5228:9): [True: 0, False: 2]
  ------------------
 5229|      0|        session->remote_test_mid == pdu->mid) {
  ------------------
  |  Branch (5229:9): [True: 0, False: 0]
  ------------------
 5230|      0|      coap_log_debug("Q-Block support not available\n");
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5231|      0|      set_block_mode_drop_q(session->block_mode);
  ------------------
  |  |   89|      0|  do { \
  |  |   90|      0|    block_mode &= ~(COAP_BLOCK_TRY_Q_BLOCK |\
  |  |  ------------------
  |  |  |  |   67|      0|#define COAP_BLOCK_TRY_Q_BLOCK   0x04 /* Try Q-Block method */
  |  |  ------------------
  |  |   91|      0|                    COAP_BLOCK_PROBE_Q_BLOCK |\
  |  |  ------------------
  |  |  |  |   74|      0|#define COAP_BLOCK_PROBE_Q_BLOCK 0x80000000 /* Set when Q_BLOCK probing */
  |  |  ------------------
  |  |   92|      0|                    COAP_BLOCK_HAS_Q_BLOCK | \
  |  |  ------------------
  |  |  |  |   73|      0|#define COAP_BLOCK_HAS_Q_BLOCK   0x40000000 /* Set when Q_BLOCK supported */
  |  |  ------------------
  |  |   93|      0|                    COAP_BLOCK_USE_M_Q_BLOCK | \
  |  |  ------------------
  |  |  |  |   68|      0|#define COAP_BLOCK_USE_M_Q_BLOCK 0x08 /* Use M bit when recovering Q-Block2 */
  |  |  ------------------
  |  |   94|      0|                    COAP_BLOCK_FORCE_Q_BLOCK); \
  |  |  ------------------
  |  |  |  |   74|      0|#define COAP_BLOCK_FORCE_Q_BLOCK  0x200 /* force Q-Block method without support check */
  |  |  ------------------
  |  |   95|      0|  } while (0)
  |  |  ------------------
  |  |  |  Branch (95:12): [Folded, False: 0]
  |  |  ------------------
  ------------------
 5232|      0|      coap_reset_doing_first(session);
 5233|      0|    }
 5234|      2|#endif /* COAP_Q_BLOCK_SUPPORT */
 5235|       |
 5236|       |    /* Check to see if checking out extended token support */
 5237|      2|    if (session->max_token_checked == COAP_EXT_T_CHECKING &&
  ------------------
  |  Branch (5237:9): [True: 0, False: 2]
  ------------------
 5238|      0|        session->remote_test_mid == pdu->mid) {
  ------------------
  |  Branch (5238:9): [True: 0, False: 0]
  ------------------
 5239|      0|      coap_log_debug("Extended Token support not available\n");
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5240|      0|      session->max_token_size = COAP_TOKEN_DEFAULT_MAX;
  ------------------
  |  |   58|      0|#define COAP_TOKEN_DEFAULT_MAX 8
  ------------------
 5241|      0|      session->max_token_checked = COAP_EXT_T_CHECKED;
 5242|      0|      coap_reset_doing_first(session);
 5243|      0|      is_ext_token_rst = 1;
 5244|      0|    }
 5245|      2|#endif /* COAP_CLIENT_SUPPORT */
 5246|       |
 5247|      2|    if (!is_ping_rst && !is_ext_token_rst)
  ------------------
  |  Branch (5247:9): [True: 2, False: 0]
  |  Branch (5247:25): [True: 2, False: 0]
  ------------------
 5248|      2|      coap_log_alert("got RST for mid=0x%04x\n", pdu->mid);
  ------------------
  |  |   90|      2|#define coap_log_alert(...) coap_log(COAP_LOG_ALERT, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      2|#define coap_log(level, ...) do { \
  |  |  |  |  291|      2|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 2]
  |  |  |  |  ------------------
  |  |  |  |  292|      2|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      2|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 2]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5249|       |
 5250|      2|    if (session->con_active) {
  ------------------
  |  Branch (5250:9): [True: 0, False: 2]
  ------------------
 5251|      0|      session->con_active--;
 5252|      0|      if (session->state == COAP_SESSION_STATE_ESTABLISHED)
  ------------------
  |  Branch (5252:11): [True: 0, False: 0]
  ------------------
 5253|       |        /* Flush out any entries on session->delayqueue */
 5254|      0|        coap_session_connected(session);
 5255|      0|    }
 5256|       |
 5257|       |    /* find message id in sendqueue to stop retransmission (no token as RST) */
 5258|      2|    coap_remove_from_queue(&context->sendqueue, session, pdu->mid, NULL, &sent);
 5259|       |
 5260|      2|    if (sent) {
  ------------------
  |  Branch (5260:9): [True: 0, False: 2]
  ------------------
 5261|      0|      if (!is_ping_rst)
  ------------------
  |  Branch (5261:11): [True: 0, False: 0]
  ------------------
 5262|      0|        coap_cancel(context, sent);
 5263|       |
 5264|      0|      if (!is_ping_rst && !is_ext_token_rst) {
  ------------------
  |  Branch (5264:11): [True: 0, False: 0]
  |  Branch (5264:27): [True: 0, False: 0]
  ------------------
 5265|      0|        if (sent->pdu->type==COAP_MESSAGE_CON) {
  ------------------
  |  Branch (5265:13): [True: 0, False: 0]
  ------------------
 5266|      0|          coap_handle_nack(sent->session, sent->pdu, COAP_NACK_RST, sent->id);
 5267|      0|        }
 5268|      0|      } else if (is_ping_rst) {
  ------------------
  |  Branch (5268:18): [True: 0, False: 0]
  ------------------
 5269|      0|        if (context->pong_cb) {
  ------------------
  |  Branch (5269:13): [True: 0, False: 0]
  ------------------
 5270|      0|          coap_lock_callback(context->pong_cb(session, pdu, pdu->mid));
  ------------------
  |  |  651|      0|#define coap_lock_callback(func) func
  ------------------
 5271|      0|        }
 5272|      0|        session->last_pong = session->last_rx_tx;
 5273|      0|        session->ping_failed = 0;
 5274|      0|        session->last_ping_mid = COAP_INVALID_MID;
  ------------------
  |  |  198|      0|#define COAP_INVALID_MID -1
  ------------------
 5275|      0|      }
 5276|      2|    } else {
 5277|      2|#if COAP_SERVER_SUPPORT
 5278|       |      /* Need to check is there is a subscription active and delete it */
 5279|      2|      RESOURCES_ITER(context->resources, r) {
  ------------------
  |  |  193|      2|  coap_resource_t *tmp, *rtmp; \
  |  |  194|      2|  HASH_ITER(hh, (r), tmp, rtmp)
  |  |  ------------------
  |  |  |  | 1071|      2|#define HASH_ITER(hh,head,el,tmp)                                                \
  |  |  |  | 1072|      2|for(((el)=(head)), ((tmp)=DECLTYPE(el)((head!=NULL)?(head)->hh.next:NULL));      \
  |  |  |  |  ------------------
  |  |  |  |  |  |   66|      2|#define DECLTYPE(x) (__typeof(x))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (1072:40): [True: 2, False: 0]
  |  |  |  |  ------------------
  |  |  |  | 1073|      4|  (el) != NULL; ((el)=(tmp)), ((tmp)=DECLTYPE(el)((tmp!=NULL)?(tmp)->hh.next:NULL)))
  |  |  |  |  ------------------
  |  |  |  |  |  |   66|      2|#define DECLTYPE(x) (__typeof(x))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (1073:3): [True: 2, False: 2]
  |  |  |  |  |  Branch (1073:51): [True: 0, False: 2]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5280|      2|        coap_subscription_t *obs, *tmp;
 5281|      2|        LL_FOREACH_SAFE(r->subscribers, obs, tmp) {
  ------------------
  |  |  425|      2|    LL_FOREACH_SAFE2(head,el,tmp,next)
  |  |  ------------------
  |  |  |  |  428|      2|  for ((el) = (head); (el) && ((tmp) = (el)->next, 1); (el) = (tmp))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (428:23): [True: 0, False: 2]
  |  |  |  |  |  Branch (428:31): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5282|      0|          if (obs->pdu->mid == pdu->mid && obs->session == session) {
  ------------------
  |  Branch (5282:15): [True: 0, False: 0]
  |  Branch (5282:44): [True: 0, False: 0]
  ------------------
 5283|       |            /* Need to do this now as session may get de-referenced */
 5284|      0|            coap_session_reference_lkd(session);
 5285|      0|            coap_delete_observer(r, session, &obs->pdu->actual_token);
 5286|      0|            coap_handle_nack(session, NULL, COAP_NACK_RST, pdu->mid);
 5287|      0|            coap_session_release_lkd(session);
 5288|      0|            goto cleanup;
 5289|      0|          }
 5290|      0|        }
 5291|      2|      }
 5292|      2|#endif /* COAP_SERVER_SUPPORT */
 5293|      2|      coap_handle_nack(session, NULL, COAP_NACK_RST, pdu->mid);
 5294|      2|    }
 5295|      2|#if COAP_PROXY_SUPPORT
 5296|      2|    if (!is_ping_rst) {
  ------------------
  |  Branch (5296:9): [True: 2, False: 0]
  ------------------
 5297|       |      /* Need to check is there is a proxy subscription active and delete it */
 5298|      2|      coap_delete_proxy_subscriber(session, NULL, pdu->mid, COAP_PROXY_SUBS_MID);
 5299|      2|    }
 5300|      2|#endif /* COAP_PROXY_SUPPORT */
 5301|      2|    goto cleanup;
 5302|       |
 5303|     11|  case COAP_MESSAGE_NON:
  ------------------
  |  Branch (5303:3): [True: 11, False: 91]
  ------------------
 5304|       |    /* check for oscore issue or unknown critical options */
 5305|     11|    if (oscore_invalid ||
  ------------------
  |  Branch (5305:9): [True: 0, False: 11]
  ------------------
 5306|     11|        coap_option_check_critical(session, pdu, &opt_filter, COAP_CRIT_UNKNOWN) == 0) {
  ------------------
  |  Branch (5306:9): [True: 0, False: 11]
  ------------------
 5307|      0|      packet_is_bad = 1;
 5308|      0|      if (COAP_PDU_IS_REQUEST(pdu)) {
  ------------------
  |  |   99|      0|#define COAP_PDU_IS_REQUEST(pdu)   (!COAP_PDU_IS_EMPTY(pdu) && (pdu)->code < 32)
  |  |  ------------------
  |  |  |  |   98|      0|#define COAP_PDU_IS_EMPTY(pdu)     ((pdu)->code == 0)
  |  |  ------------------
  |  |  |  Branch (99:37): [True: 0, False: 0]
  |  |  |  Branch (99:64): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 5309|      0|        response =
 5310|      0|            coap_new_error_response(pdu, COAP_RESPONSE_CODE(402), &opt_filter);
  ------------------
  |  |   96|      0|#define COAP_RESPONSE_CODE(N) (((N)/100 << 5) | (N)%100)
  ------------------
 5311|       |
 5312|      0|        if (!response) {
  ------------------
  |  Branch (5312:13): [True: 0, False: 0]
  ------------------
 5313|      0|          coap_log_warn("coap_dispatch: cannot create error response\n");
  ------------------
  |  |  108|      0|#define coap_log_warn(...) coap_log(COAP_LOG_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5314|      0|        } else {
 5315|      0|          if (coap_send_internal(session, response, NULL) == COAP_INVALID_MID)
  ------------------
  |  |  198|      0|#define COAP_INVALID_MID -1
  ------------------
  |  Branch (5315:15): [True: 0, False: 0]
  ------------------
 5316|      0|            coap_log_warn("coap_dispatch: error sending response\n");
  ------------------
  |  |  108|      0|#define coap_log_warn(...) coap_log(COAP_LOG_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5317|      0|        }
 5318|      0|      } else {
 5319|      0|        coap_send_rst_lkd(session, pdu);
 5320|      0|      }
 5321|      0|      goto cleanup;
 5322|      0|    }
 5323|     11|    break;
 5324|       |
 5325|     89|  case COAP_MESSAGE_CON:
  ------------------
  |  Branch (5325:3): [True: 89, False: 13]
  ------------------
 5326|       |    /* In a lossy context, the ACK of a separate response may have
 5327|       |     * been lost, so we need to stop retransmitting requests with the
 5328|       |     * same token. Matching on token potentially containing ext length bytes.
 5329|       |     */
 5330|       |    /* find message token in sendqueue to stop retransmission */
 5331|     89|    if (pdu->code != 0)
  ------------------
  |  Branch (5331:9): [True: 89, False: 0]
  ------------------
 5332|     89|      coap_remove_from_queue_token(&context->sendqueue, session, &pdu->actual_token, &sent);
 5333|       |
 5334|       |    /* check for oscore issue or unknown critical options in non-signaling messages */
 5335|     89|    if (oscore_invalid ||
  ------------------
  |  Branch (5335:9): [True: 0, False: 89]
  ------------------
 5336|     89|        (!COAP_PDU_IS_SIGNALING(pdu) &&
  ------------------
  |  |  102|    178|#define COAP_PDU_IS_SIGNALING(pdu) ((pdu)->code >= 224)
  ------------------
  |  Branch (5336:10): [True: 89, False: 0]
  ------------------
 5337|     89|         coap_option_check_critical(session, pdu, &opt_filter, COAP_CRIT_UNKNOWN) == 0)) {
  ------------------
  |  Branch (5337:10): [True: 0, False: 89]
  ------------------
 5338|      0|      packet_is_bad = 1;
 5339|      0|      if (COAP_PDU_IS_REQUEST(pdu)) {
  ------------------
  |  |   99|      0|#define COAP_PDU_IS_REQUEST(pdu)   (!COAP_PDU_IS_EMPTY(pdu) && (pdu)->code < 32)
  |  |  ------------------
  |  |  |  |   98|      0|#define COAP_PDU_IS_EMPTY(pdu)     ((pdu)->code == 0)
  |  |  ------------------
  |  |  |  Branch (99:37): [True: 0, False: 0]
  |  |  |  Branch (99:64): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 5340|      0|        response =
 5341|      0|            coap_new_error_response(pdu, COAP_RESPONSE_CODE(402), &opt_filter);
  ------------------
  |  |   96|      0|#define COAP_RESPONSE_CODE(N) (((N)/100 << 5) | (N)%100)
  ------------------
 5342|       |
 5343|      0|        if (!response) {
  ------------------
  |  Branch (5343:13): [True: 0, False: 0]
  ------------------
 5344|      0|          coap_log_warn("coap_dispatch: cannot create error response\n");
  ------------------
  |  |  108|      0|#define coap_log_warn(...) coap_log(COAP_LOG_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5345|      0|        } else {
 5346|      0|          if (coap_send_internal(session, response, NULL) == COAP_INVALID_MID)
  ------------------
  |  |  198|      0|#define COAP_INVALID_MID -1
  ------------------
  |  Branch (5346:15): [True: 0, False: 0]
  ------------------
 5347|      0|            coap_log_warn("coap_dispatch: error sending response\n");
  ------------------
  |  |  108|      0|#define coap_log_warn(...) coap_log(COAP_LOG_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5348|      0|        }
 5349|      0|      } else {
 5350|      0|        coap_send_rst_lkd(session, pdu);
 5351|      0|      }
 5352|      0|      goto cleanup;
 5353|      0|    }
 5354|     89|    break;
 5355|     89|  default:
  ------------------
  |  Branch (5355:3): [True: 0, False: 102]
  ------------------
 5356|      0|    break;
 5357|    102|  }
 5358|       |
 5359|       |  /* Pass message to upper layer if a specific handler was
 5360|       |    * registered for a request that should be handled locally. */
 5361|    100|#if !COAP_DISABLE_TCP
 5362|    100|  if (COAP_PDU_IS_SIGNALING(pdu))
  ------------------
  |  |  102|    100|#define COAP_PDU_IS_SIGNALING(pdu) ((pdu)->code >= 224)
  |  |  ------------------
  |  |  |  Branch (102:36): [True: 0, False: 100]
  |  |  ------------------
  ------------------
 5363|      0|    handle_signaling(context, session, pdu);
 5364|    100|  else
 5365|    100|#endif /* !COAP_DISABLE_TCP */
 5366|    100|#if COAP_SERVER_SUPPORT
 5367|    100|    if (COAP_PDU_IS_REQUEST(pdu))
  ------------------
  |  |   99|    100|#define COAP_PDU_IS_REQUEST(pdu)   (!COAP_PDU_IS_EMPTY(pdu) && (pdu)->code < 32)
  |  |  ------------------
  |  |  |  |   98|    200|#define COAP_PDU_IS_EMPTY(pdu)     ((pdu)->code == 0)
  |  |  ------------------
  |  |  |  Branch (99:37): [True: 100, False: 0]
  |  |  |  Branch (99:64): [True: 100, False: 0]
  |  |  ------------------
  ------------------
 5368|    100|      handle_request(context, session, pdu, orig_pdu);
 5369|      0|    else
 5370|      0|#endif /* COAP_SERVER_SUPPORT */
 5371|      0|#if COAP_CLIENT_SUPPORT
 5372|      0|      if (COAP_PDU_IS_RESPONSE(pdu))
  ------------------
  |  |  101|      0|#define COAP_PDU_IS_RESPONSE(pdu)  ((pdu)->code >= 64 && (pdu)->code < 192)
  |  |  ------------------
  |  |  |  Branch (101:37): [True: 0, False: 0]
  |  |  |  Branch (101:58): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 5373|      0|        handle_response(context, session, sent ? sent->pdu : NULL, pdu);
  ------------------
  |  Branch (5373:43): [True: 0, False: 0]
  ------------------
 5374|      0|      else
 5375|      0|#endif /* COAP_CLIENT_SUPPORT */
 5376|      0|      {
 5377|      0|        if (COAP_PDU_IS_EMPTY(pdu)) {
  ------------------
  |  |   98|      0|#define COAP_PDU_IS_EMPTY(pdu)     ((pdu)->code == 0)
  |  |  ------------------
  |  |  |  Branch (98:36): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 5378|      0|          if (context->ping_cb) {
  ------------------
  |  Branch (5378:15): [True: 0, False: 0]
  ------------------
 5379|      0|            coap_lock_callback(context->ping_cb(session, pdu, pdu->mid));
  ------------------
  |  |  651|      0|#define coap_lock_callback(func) func
  ------------------
 5380|      0|          }
 5381|      0|        } else {
 5382|      0|          packet_is_bad = 1;
 5383|      0|        }
 5384|      0|        coap_log_debug("dropped message with invalid code (%d.%02d)\n",
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5385|      0|                       COAP_RESPONSE_CLASS(pdu->code),
 5386|      0|                       pdu->code & 0x1f);
 5387|       |
 5388|      0|        if (!coap_is_mcast(&session->addr_info.local)) {
  ------------------
  |  Branch (5388:13): [True: 0, False: 0]
  ------------------
 5389|      0|          if (COAP_PDU_IS_EMPTY(pdu)) {
  ------------------
  |  |   98|      0|#define COAP_PDU_IS_EMPTY(pdu)     ((pdu)->code == 0)
  |  |  ------------------
  |  |  |  Branch (98:36): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 5390|      0|            if (COAP_PROTO_NOT_RELIABLE(session->proto)) {
  ------------------
  |  |   41|      0|#define COAP_PROTO_NOT_RELIABLE(p) ((p)==COAP_PROTO_UDP || (p)==COAP_PROTO_DTLS)
  |  |  ------------------
  |  |  |  Branch (41:37): [True: 0, False: 0]
  |  |  |  Branch (41:60): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 5391|      0|              coap_tick_t now;
 5392|      0|              coap_ticks(&now);
 5393|      0|              if (session->last_tx_rst + COAP_TICKS_PER_SECOND/4 < now) {
  ------------------
  |  |  164|      0|#define COAP_TICKS_PER_SECOND ((coap_tick_t)(1000U))
  ------------------
  |  Branch (5393:19): [True: 0, False: 0]
  ------------------
 5394|      0|                coap_send_message_type_lkd(session, pdu, COAP_MESSAGE_RST);
 5395|      0|                session->last_tx_rst = now;
 5396|      0|              }
 5397|      0|            }
 5398|      0|          } else {
 5399|      0|            if (pdu->type == COAP_MESSAGE_CON)
  ------------------
  |  Branch (5399:17): [True: 0, False: 0]
  ------------------
 5400|      0|              coap_send_message_type_lkd(session, pdu, COAP_MESSAGE_RST);
 5401|      0|          }
 5402|      0|        }
 5403|      0|      }
 5404|       |
 5405|    103|cleanup:
 5406|    103|  if (packet_is_bad) {
  ------------------
  |  Branch (5406:7): [True: 0, False: 103]
  ------------------
 5407|      0|    if (sent) {
  ------------------
  |  Branch (5407:9): [True: 0, False: 0]
  ------------------
 5408|      0|      coap_handle_nack(session, sent->pdu, COAP_NACK_BAD_RESPONSE, sent->id);
 5409|      0|    } else {
 5410|      0|      coap_handle_event_lkd(context, COAP_EVENT_BAD_PACKET, session);
 5411|      0|    }
 5412|      0|  }
 5413|    103|  coap_delete_pdu_lkd(orig_pdu);
 5414|    103|  coap_delete_node_lkd(sent);
 5415|    103|#if COAP_OSCORE_SUPPORT
 5416|    103|  coap_delete_pdu_lkd(dec_pdu);
 5417|    103|#endif /* COAP_OSCORE_SUPPORT */
 5418|       |
 5419|    103|#if COAP_SERVER_SUPPORT || COAP_OSCORE_SUPPORT
 5420|    103|finish:
 5421|    103|#endif /* COAP_SERVER_SUPPORT || COAP_OSCORE_SUPPORT */
 5422|    103|  coap_pdu_release_lkd(pdu);
 5423|    103|}
coap_net.c:check_token_size:
 4871|    100|check_token_size(coap_session_t *session, const coap_pdu_t *pdu, int is_local_mcast) {
 4872|    100|  if (COAP_PDU_IS_REQUEST(pdu) &&
  ------------------
  |  |   99|    200|#define COAP_PDU_IS_REQUEST(pdu)   (!COAP_PDU_IS_EMPTY(pdu) && (pdu)->code < 32)
  |  |  ------------------
  |  |  |  |   98|    200|#define COAP_PDU_IS_EMPTY(pdu)     ((pdu)->code == 0)
  |  |  ------------------
  |  |  |  Branch (99:37): [True: 100, False: 0]
  |  |  |  Branch (99:64): [True: 100, False: 0]
  |  |  ------------------
  ------------------
 4873|    100|      pdu->actual_token.length >
  ------------------
  |  Branch (4873:7): [True: 0, False: 100]
  ------------------
 4874|    100|      (session->type == COAP_SESSION_TYPE_CLIENT ?
  ------------------
  |  Branch (4874:8): [True: 100, False: 0]
  ------------------
 4875|    100|       session->max_token_size : session->context->max_token_size)) {
 4876|       |    /* https://rfc-editor.org/rfc/rfc8974#section-2.2.2 */
 4877|      0|    if (is_local_mcast)
  ------------------
  |  Branch (4877:9): [True: 0, False: 0]
  ------------------
 4878|      0|      return 0;
 4879|      0|    if (session->max_token_size > COAP_TOKEN_DEFAULT_MAX) {
  ------------------
  |  |   58|      0|#define COAP_TOKEN_DEFAULT_MAX 8
  ------------------
  |  Branch (4879:9): [True: 0, False: 0]
  ------------------
 4880|      0|      coap_opt_filter_t opt_filter;
 4881|      0|      coap_pdu_t *response;
 4882|       |
 4883|      0|      memset(&opt_filter, 0, sizeof(coap_opt_filter_t));
 4884|      0|      response = coap_new_error_response(pdu, COAP_RESPONSE_CODE(400),
  ------------------
  |  |   96|      0|#define COAP_RESPONSE_CODE(N) (((N)/100 << 5) | (N)%100)
  ------------------
 4885|      0|                                         &opt_filter);
 4886|      0|      if (!response) {
  ------------------
  |  Branch (4886:11): [True: 0, False: 0]
  ------------------
 4887|      0|        coap_log_warn("coap_dispatch: cannot create error response\n");
  ------------------
  |  |  108|      0|#define coap_log_warn(...) coap_log(COAP_LOG_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4888|      0|      } else {
 4889|       |        /*
 4890|       |         * Note - have to leave in oversize token as per
 4891|       |         * https://rfc-editor.org/rfc/rfc7252#section-5.3.1
 4892|       |         */
 4893|      0|        if (coap_send_internal(session, response, NULL) == COAP_INVALID_MID)
  ------------------
  |  |  198|      0|#define COAP_INVALID_MID -1
  ------------------
  |  Branch (4893:13): [True: 0, False: 0]
  ------------------
 4894|      0|          coap_log_warn("coap_dispatch: error sending response\n");
  ------------------
  |  |  108|      0|#define coap_log_warn(...) coap_log(COAP_LOG_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4895|      0|      }
 4896|      0|    } else {
 4897|       |      /* Indicate no extended token support */
 4898|      0|      coap_send_rst_lkd(session, pdu);
 4899|      0|    }
 4900|      0|    return 0;
 4901|      0|  }
 4902|    100|  return 1;
 4903|    100|}
coap_net.c:coap_remove_from_queue_token:
 3361|     89|                             coap_bin_const_t *token, coap_queue_t **node) {
 3362|     89|  coap_queue_t *p, *q;
 3363|       |
 3364|     89|  if (!queue || !*queue)
  ------------------
  |  Branch (3364:7): [True: 0, False: 89]
  |  Branch (3364:17): [True: 89, False: 0]
  ------------------
 3365|     89|    return 0;
 3366|       |
 3367|       |  /* replace queue head if PDU's time is less than head's time */
 3368|       |
 3369|      0|  if (session == (*queue)->session &&
  ------------------
  |  Branch (3369:7): [True: 0, False: 0]
  ------------------
 3370|      0|      (!token || coap_binary_equal(&(*queue)->pdu->actual_token, token))) { /* found token */
  ------------------
  |  |  223|      0|  ((binary1)->length == (binary2)->length && ((binary1)->length == 0 || \
  |  |  ------------------
  |  |  |  Branch (223:4): [True: 0, False: 0]
  |  |  |  Branch (223:47): [True: 0, False: 0]
  |  |  ------------------
  |  |  224|      0|                                              ((binary1)->s && (binary2)->s && \
  |  |  ------------------
  |  |  |  Branch (224:48): [True: 0, False: 0]
  |  |  |  Branch (224:64): [True: 0, False: 0]
  |  |  ------------------
  |  |  225|      0|                                               memcmp((binary1)->s, (binary2)->s, (binary1)->length) == 0)))
  |  |  ------------------
  |  |  |  Branch (225:48): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (3370:8): [True: 0, False: 0]
  ------------------
 3371|      0|    *node = *queue;
 3372|      0|    *queue = (*queue)->next;
 3373|      0|    if (*queue) {          /* adjust relative time of new queue head */
  ------------------
  |  Branch (3373:9): [True: 0, False: 0]
  ------------------
 3374|      0|      (*queue)->t += (*node)->t;
 3375|      0|    }
 3376|      0|    (*node)->next = NULL;
 3377|      0|    coap_log_debug("** %s: mid=0x%04x: removed (7)\n",
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3378|      0|                   coap_session_str(session), (*node)->id);
 3379|      0|    if ((*node)->pdu->type == COAP_MESSAGE_CON && session->con_active) {
  ------------------
  |  Branch (3379:9): [True: 0, False: 0]
  |  Branch (3379:51): [True: 0, False: 0]
  ------------------
 3380|      0|      session->con_active--;
 3381|      0|      if (session->state == COAP_SESSION_STATE_ESTABLISHED)
  ------------------
  |  Branch (3381:11): [True: 0, False: 0]
  ------------------
 3382|       |        /* Flush out any entries on session->delayqueue */
 3383|      0|        coap_session_connected(session);
 3384|      0|    }
 3385|      0|    return 1;
 3386|      0|  }
 3387|       |
 3388|       |  /* search token in queue to remove (only first occurrence will be removed) */
 3389|      0|  q = *queue;
 3390|      0|  do {
 3391|      0|    p = q;
 3392|      0|    q = q->next;
 3393|      0|  } while (q && (session != q->session ||
  ------------------
  |  Branch (3393:12): [True: 0, False: 0]
  |  Branch (3393:18): [True: 0, False: 0]
  ------------------
 3394|      0|                 !(!token || coap_binary_equal(&q->pdu->actual_token, token))));
  ------------------
  |  |  223|      0|  ((binary1)->length == (binary2)->length && ((binary1)->length == 0 || \
  |  |  ------------------
  |  |  |  Branch (223:4): [True: 0, False: 0]
  |  |  |  Branch (223:47): [True: 0, False: 0]
  |  |  ------------------
  |  |  224|      0|                                              ((binary1)->s && (binary2)->s && \
  |  |  ------------------
  |  |  |  Branch (224:48): [True: 0, False: 0]
  |  |  |  Branch (224:64): [True: 0, False: 0]
  |  |  ------------------
  |  |  225|      0|                                               memcmp((binary1)->s, (binary2)->s, (binary1)->length) == 0)))
  |  |  ------------------
  |  |  |  Branch (225:48): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (3394:20): [True: 0, False: 0]
  ------------------
 3395|       |
 3396|      0|  if (q) {                        /* found token */
  ------------------
  |  Branch (3396:7): [True: 0, False: 0]
  ------------------
 3397|      0|    p->next = q->next;
 3398|      0|    if (p->next) {                /* must update relative time of p->next */
  ------------------
  |  Branch (3398:9): [True: 0, False: 0]
  ------------------
 3399|      0|      p->next->t += q->t;
 3400|      0|    }
 3401|      0|    q->next = NULL;
 3402|      0|    *node = q;
 3403|      0|    coap_log_debug("** %s: mid=0x%04x: removed (8)\n",
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3404|      0|                   coap_session_str(session), (*node)->id);
 3405|      0|    if (q->pdu->type == COAP_MESSAGE_CON && session->con_active) {
  ------------------
  |  Branch (3405:9): [True: 0, False: 0]
  |  Branch (3405:45): [True: 0, False: 0]
  ------------------
 3406|      0|      session->con_active--;
 3407|      0|      if (session->state == COAP_SESSION_STATE_ESTABLISHED)
  ------------------
  |  Branch (3407:11): [True: 0, False: 0]
  ------------------
 3408|       |        /* Flush out any entries on session->delayqueue */
 3409|      0|        coap_session_connected(session);
 3410|      0|    }
 3411|      0|    return 1;
 3412|      0|  }
 3413|       |
 3414|      0|  return 0;
 3415|       |
 3416|      0|}
coap_net.c:handle_request:
 3869|    100|               coap_pdu_t *orig_pdu) {
 3870|    100|  coap_method_handler_t h = NULL;
 3871|    100|  coap_pdu_t *response = NULL;
 3872|    100|  coap_opt_filter_t opt_filter;
 3873|    100|  coap_resource_t *resource = NULL;
 3874|       |  /* The respond field indicates whether a response must be treated
 3875|       |   * specially due to a No-Response option that declares disinterest
 3876|       |   * or interest in a specific response class. DEFAULT indicates that
 3877|       |   * No-Response has not been specified. */
 3878|    100|  enum respond_t respond = RESPONSE_DEFAULT;
 3879|    100|  coap_opt_iterator_t opt_iter;
 3880|    100|  coap_opt_t *opt;
 3881|    100|  int is_proxy_uri = 0;
 3882|    100|  int is_proxy_scheme = 0;
 3883|    100|  int hop_limit = -1;
 3884|    100|  int resp = 0;
 3885|    100|  coap_string_t *query = NULL;
 3886|    100|  coap_opt_t *observe = NULL;
 3887|    100|  coap_string_t *uri_path = NULL;
 3888|    100|  int observe_action = COAP_OBSERVE_CANCEL;
  ------------------
  |  |   44|    100|#define COAP_OBSERVE_CANCEL 1
  ------------------
 3889|    100|  coap_block_b_t block;
 3890|    100|  int added_block = 0;
 3891|    100|  coap_lg_srcv_t *free_lg_srcv = NULL;
 3892|    100|#if COAP_Q_BLOCK_SUPPORT
 3893|    100|  int lg_xmit_ctrl = 0;
 3894|    100|#endif /* COAP_Q_BLOCK_SUPPORT */
 3895|    100|#if COAP_ASYNC_SUPPORT
 3896|    100|  coap_async_t *async;
 3897|    100|#endif /* COAP_ASYNC_SUPPORT */
 3898|       |
 3899|    100|#if COAP_ASYNC_SUPPORT
 3900|    100|  async = coap_find_async_lkd(session, pdu->actual_token);
 3901|    100|  if (async) {
  ------------------
  |  Branch (3901:7): [True: 0, False: 100]
  ------------------
 3902|      0|    coap_tick_t now;
 3903|       |
 3904|      0|    coap_ticks(&now);
 3905|      0|    if (async->delay == 0 || async->delay > now) {
  ------------------
  |  Branch (3905:9): [True: 0, False: 0]
  |  Branch (3905:30): [True: 0, False: 0]
  ------------------
 3906|       |      /* re-transmit missing ACK (only if CON) */
 3907|      0|      coap_log_info("Retransmit async response\n");
  ------------------
  |  |  114|      0|#define coap_log_info(...) coap_log(COAP_LOG_INFO, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3908|      0|      coap_send_ack_lkd(session, pdu);
 3909|       |      /* and do not pass on to the upper layers */
 3910|      0|      return;
 3911|      0|    }
 3912|      0|  }
 3913|    100|#endif /* COAP_ASYNC_SUPPORT */
 3914|       |
 3915|    100|  coap_option_filter_clear(&opt_filter);
 3916|    100|  if (!(context->unknown_resource && context->unknown_resource->is_reverse_proxy)) {
  ------------------
  |  Branch (3916:9): [True: 0, False: 100]
  |  Branch (3916:38): [True: 0, False: 0]
  ------------------
 3917|    100|    opt = coap_check_option(pdu, COAP_OPTION_PROXY_SCHEME, &opt_iter);
 3918|    100|    if (opt) {
  ------------------
  |  Branch (3918:9): [True: 0, False: 100]
  ------------------
 3919|      0|      opt = coap_check_option(pdu, COAP_OPTION_URI_HOST, &opt_iter);
 3920|      0|      if (!opt) {
  ------------------
  |  Branch (3920:11): [True: 0, False: 0]
  ------------------
 3921|      0|        coap_log_debug("Proxy-Scheme requires Uri-Host\n");
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3922|      0|        resp = 402;
 3923|      0|        goto fail_response;
 3924|      0|      }
 3925|      0|      is_proxy_scheme = 1;
 3926|      0|    }
 3927|       |
 3928|    100|    opt = coap_check_option(pdu, COAP_OPTION_PROXY_URI, &opt_iter);
 3929|    100|    if (opt)
  ------------------
  |  Branch (3929:9): [True: 0, False: 100]
  ------------------
 3930|      0|      is_proxy_uri = 1;
 3931|    100|  }
 3932|       |
 3933|    100|  if (is_proxy_scheme || is_proxy_uri) {
  ------------------
  |  Branch (3933:7): [True: 0, False: 100]
  |  Branch (3933:26): [True: 0, False: 100]
  ------------------
 3934|      0|    coap_uri_t uri;
 3935|       |
 3936|      0|    if (!context->proxy_uri_resource) {
  ------------------
  |  Branch (3936:9): [True: 0, False: 0]
  ------------------
 3937|       |      /* Need to return a 5.05 RFC7252 Section 5.7.2 */
 3938|      0|      coap_log_debug("Proxy-%s support not configured\n",
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (292:30): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3939|      0|                     is_proxy_scheme ? "Scheme" : "Uri");
 3940|      0|      resp = 505;
 3941|      0|      goto fail_response;
 3942|      0|    }
 3943|      0|    if (((size_t)pdu->code - 1 <
  ------------------
  |  Branch (3943:9): [True: 0, False: 0]
  ------------------
 3944|      0|         (sizeof(resource->handler) / sizeof(resource->handler[0]))) &&
 3945|      0|        !(context->proxy_uri_resource->handler[pdu->code - 1])) {
  ------------------
  |  Branch (3945:9): [True: 0, False: 0]
  ------------------
 3946|       |      /* Need to return a 5.05 RFC7252 Section 5.7.2 */
 3947|      0|      coap_log_debug("Proxy-%s code %d.%02d handler not supported\n",
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (292:30): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3948|      0|                     is_proxy_scheme ? "Scheme" : "Uri",
 3949|      0|                     pdu->code/100,  pdu->code%100);
 3950|      0|      resp = 505;
 3951|      0|      goto fail_response;
 3952|      0|    }
 3953|       |
 3954|       |    /* Need to check if authority is the proxy endpoint RFC7252 Section 5.7.2 */
 3955|      0|    if (is_proxy_uri) {
  ------------------
  |  Branch (3955:9): [True: 0, False: 0]
  ------------------
 3956|      0|      if (coap_split_proxy_uri(coap_opt_value(opt),
  ------------------
  |  Branch (3956:11): [True: 0, False: 0]
  ------------------
 3957|      0|                               coap_opt_length(opt), &uri) < 0) {
 3958|       |        /* Need to return a 5.05 RFC7252 Section 5.7.2 */
 3959|      0|        coap_log_debug("Proxy-URI not decodable\n");
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3960|      0|        resp = 505;
 3961|      0|        goto fail_response;
 3962|      0|      }
 3963|      0|    } else {
 3964|      0|      memset(&uri, 0, sizeof(uri));
 3965|      0|      opt = coap_check_option(pdu, COAP_OPTION_URI_HOST, &opt_iter);
 3966|      0|      if (opt) {
  ------------------
  |  Branch (3966:11): [True: 0, False: 0]
  ------------------
 3967|      0|        uri.host.length = coap_opt_length(opt);
 3968|      0|        uri.host.s = coap_opt_value(opt);
 3969|      0|      } else
 3970|      0|        uri.host.length = 0;
 3971|      0|    }
 3972|       |
 3973|      0|    resource = context->proxy_uri_resource;
 3974|      0|    if (uri.host.length && resource->proxy_name_count &&
  ------------------
  |  Branch (3974:9): [True: 0, False: 0]
  |  Branch (3974:28): [True: 0, False: 0]
  ------------------
 3975|      0|        resource->proxy_name_list) {
  ------------------
  |  Branch (3975:9): [True: 0, False: 0]
  ------------------
 3976|      0|      size_t i;
 3977|       |
 3978|      0|      if (resource->proxy_name_count == 1 &&
  ------------------
  |  Branch (3978:11): [True: 0, False: 0]
  ------------------
 3979|      0|          resource->proxy_name_list[0]->length == 0) {
  ------------------
  |  Branch (3979:11): [True: 0, False: 0]
  ------------------
 3980|       |        /* If proxy_name_list[0] is zero length, then this is the endpoint */
 3981|      0|        i = 0;
 3982|      0|      } else {
 3983|      0|        for (i = 0; i < resource->proxy_name_count; i++) {
  ------------------
  |  Branch (3983:21): [True: 0, False: 0]
  ------------------
 3984|      0|          if (coap_string_equal(&uri.host, resource->proxy_name_list[i])) {
  ------------------
  |  |  209|      0|  ((string1)->length == (string2)->length && ((string1)->length == 0 || \
  |  |  ------------------
  |  |  |  Branch (209:4): [True: 0, False: 0]
  |  |  |  Branch (209:47): [True: 0, False: 0]
  |  |  ------------------
  |  |  210|      0|                                              ((string1)->s && (string2)->s && \
  |  |  ------------------
  |  |  |  Branch (210:48): [True: 0, False: 0]
  |  |  |  Branch (210:64): [True: 0, False: 0]
  |  |  ------------------
  |  |  211|      0|                                               memcmp((string1)->s, (string2)->s, (string1)->length) == 0)))
  |  |  ------------------
  |  |  |  Branch (211:48): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 3985|      0|            break;
 3986|      0|          }
 3987|      0|        }
 3988|      0|      }
 3989|      0|      if (i != resource->proxy_name_count) {
  ------------------
  |  Branch (3989:11): [True: 0, False: 0]
  ------------------
 3990|       |        /* This server is hosting the proxy connection endpoint */
 3991|      0|        if (pdu->crit_opt) {
  ------------------
  |  Branch (3991:13): [True: 0, False: 0]
  ------------------
 3992|       |          /* Cannot handle critical option */
 3993|      0|          pdu->crit_opt = 0;
 3994|      0|          resp = 402;
 3995|      0|          resource = NULL;
 3996|      0|          goto fail_response;
 3997|      0|        }
 3998|      0|        is_proxy_uri = 0;
 3999|      0|        is_proxy_scheme = 0;
 4000|      0|      }
 4001|      0|    }
 4002|      0|    resource = NULL;
 4003|      0|  }
 4004|    100|  assert(resource == NULL);
  ------------------
  |  Branch (4004:3): [True: 100, False: 0]
  ------------------
 4005|       |
 4006|    100|  opt = coap_check_option(pdu, COAP_OPTION_HOP_LIMIT, &opt_iter);
 4007|    100|  if (opt) {
  ------------------
  |  Branch (4007:7): [True: 0, False: 100]
  ------------------
 4008|      0|    hop_limit =
 4009|      0|        coap_decode_var_bytes(coap_opt_value(opt), coap_opt_length(opt));
 4010|      0|    if (hop_limit < 1 || hop_limit > 255) {
  ------------------
  |  Branch (4010:9): [True: 0, False: 0]
  |  Branch (4010:26): [True: 0, False: 0]
  ------------------
 4011|       |      /* Need to return a 4.00 RFC8768 Section 3 */
 4012|      0|      coap_log_info("Invalid Hop Limit\n");
  ------------------
  |  |  114|      0|#define coap_log_info(...) coap_log(COAP_LOG_INFO, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4013|      0|      resp = 400;
 4014|      0|      goto fail_response;
 4015|      0|    }
 4016|      0|  }
 4017|       |
 4018|    100|  uri_path = coap_get_uri_path(pdu);
 4019|    100|  if (!uri_path) {
  ------------------
  |  Branch (4019:7): [True: 1, False: 99]
  ------------------
 4020|      1|    resp = 402;
 4021|      1|    goto fail_response;
 4022|      1|  }
 4023|       |
 4024|     99|  if (!is_proxy_uri && !is_proxy_scheme) {
  ------------------
  |  Branch (4024:7): [True: 99, False: 0]
  |  Branch (4024:24): [True: 99, False: 0]
  ------------------
 4025|       |    /* try to find the resource from the request URI */
 4026|     99|    coap_str_const_t uri_path_c = { uri_path->length, uri_path->s };
 4027|     99|    resource = coap_get_resource_from_uri_path_lkd(context, &uri_path_c);
 4028|     99|  }
 4029|       |
 4030|     99|  if ((resource == NULL) || (resource->is_unknown == 1) ||
  ------------------
  |  Branch (4030:7): [True: 1, False: 98]
  |  Branch (4030:29): [True: 0, False: 98]
  ------------------
 4031|     98|      (resource->is_proxy_uri == 1)) {
  ------------------
  |  Branch (4031:7): [True: 0, False: 98]
  ------------------
 4032|       |    /* The resource was not found or there is an unexpected match against the
 4033|       |     * resource defined for handling unknown or proxy URIs.
 4034|       |     */
 4035|      1|    if (resource != NULL)
  ------------------
  |  Branch (4035:9): [True: 0, False: 1]
  ------------------
 4036|       |      /* Close down unexpected match */
 4037|      0|      resource = NULL;
 4038|       |    /*
 4039|       |     * Check if the request URI happens to be the well-known URI, or if the
 4040|       |     * unknown resource handler is defined, a PUT or optionally other methods,
 4041|       |     * if configured, for the unknown handler.
 4042|       |     *
 4043|       |     * if a PROXY URI/Scheme request and proxy URI handler defined, call the
 4044|       |     *  proxy URI handler.
 4045|       |     *
 4046|       |     * else if unknown URI handler defined and COAP_RESOURCE_HANDLE_WELLKNOWN_CORE
 4047|       |     *  set, call the unknown URI handler with any unknown URI (including
 4048|       |     *  .well-known/core) if the appropriate method is defined.
 4049|       |     *
 4050|       |     * else if well-known URI generate a default response.
 4051|       |     *
 4052|       |     * else if unknown URI handler defined, call the unknown
 4053|       |     *  URI handler (to allow for potential generation of resource
 4054|       |     *  [RFC7272 5.8.3]) if the appropriate method is defined.
 4055|       |     *
 4056|       |     * else if DELETE return 2.02 (RFC7252: 5.8.4.  DELETE).
 4057|       |     *
 4058|       |     * else return 4.04.
 4059|       |     */
 4060|       |
 4061|      1|    if (is_proxy_uri || is_proxy_scheme) {
  ------------------
  |  Branch (4061:9): [True: 0, False: 1]
  |  Branch (4061:25): [True: 0, False: 1]
  ------------------
 4062|      0|      resource = context->proxy_uri_resource;
 4063|      1|    } else if (context->unknown_resource != NULL &&
  ------------------
  |  Branch (4063:16): [True: 0, False: 1]
  ------------------
 4064|      0|               context->unknown_resource->flags & COAP_RESOURCE_HANDLE_WELLKNOWN_CORE &&
  ------------------
  |  |  162|      1|#define COAP_RESOURCE_HANDLE_WELLKNOWN_CORE 0x800
  ------------------
  |  Branch (4064:16): [True: 0, False: 0]
  ------------------
 4065|      0|               ((size_t)pdu->code - 1 <
  ------------------
  |  Branch (4065:16): [True: 0, False: 0]
  ------------------
 4066|      0|                (sizeof(resource->handler) / sizeof(coap_method_handler_t))) &&
 4067|      0|               (context->unknown_resource->handler[pdu->code - 1])) {
  ------------------
  |  Branch (4067:16): [True: 0, False: 0]
  ------------------
 4068|      0|      resource = context->unknown_resource;
 4069|      1|    } else if (coap_string_equal(uri_path, &coap_default_uri_wellknown)) {
  ------------------
  |  |  209|      1|  ((string1)->length == (string2)->length && ((string1)->length == 0 || \
  |  |  ------------------
  |  |  |  Branch (209:4): [True: 0, False: 1]
  |  |  |  Branch (209:47): [True: 0, False: 0]
  |  |  ------------------
  |  |  210|      0|                                              ((string1)->s && (string2)->s && \
  |  |  ------------------
  |  |  |  Branch (210:48): [True: 0, False: 0]
  |  |  |  Branch (210:64): [True: 0, False: 0]
  |  |  ------------------
  |  |  211|      0|                                               memcmp((string1)->s, (string2)->s, (string1)->length) == 0)))
  |  |  ------------------
  |  |  |  Branch (211:48): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 4070|       |      /* request for .well-known/core */
 4071|      0|      resource = &resource_uri_wellknown;
 4072|      1|    } else if ((context->unknown_resource != NULL) &&
  ------------------
  |  Branch (4072:16): [True: 0, False: 1]
  ------------------
 4073|      0|               ((size_t)pdu->code - 1 <
  ------------------
  |  Branch (4073:16): [True: 0, False: 0]
  ------------------
 4074|      0|                (sizeof(resource->handler) / sizeof(coap_method_handler_t))) &&
 4075|      0|               (context->unknown_resource->handler[pdu->code - 1])) {
  ------------------
  |  Branch (4075:16): [True: 0, False: 0]
  ------------------
 4076|       |      /*
 4077|       |       * The unknown_resource can be used to handle undefined resources
 4078|       |       * for a PUT request and can support any other registered handler
 4079|       |       * defined for it
 4080|       |       * Example set up code:-
 4081|       |       *   r = coap_resource_unknown_init(hnd_put_unknown);
 4082|       |       *   coap_register_request_handler(r, COAP_REQUEST_POST,
 4083|       |       *                                 hnd_post_unknown);
 4084|       |       *   coap_register_request_handler(r, COAP_REQUEST_GET,
 4085|       |       *                                 hnd_get_unknown);
 4086|       |       *   coap_register_request_handler(r, COAP_REQUEST_DELETE,
 4087|       |       *                                 hnd_delete_unknown);
 4088|       |       *   coap_add_resource(ctx, r);
 4089|       |       *
 4090|       |       * Note: It is not possible to observe the unknown_resource, a separate
 4091|       |       *       resource must be created (by PUT or POST) which has a GET
 4092|       |       *       handler to be observed
 4093|       |       */
 4094|      0|      resource = context->unknown_resource;
 4095|      1|    } else if (pdu->code == COAP_REQUEST_CODE_DELETE) {
  ------------------
  |  Branch (4095:16): [True: 0, False: 1]
  ------------------
 4096|       |      /*
 4097|       |       * Request for DELETE on non-existent resource (RFC7252: 5.8.4.  DELETE)
 4098|       |       */
 4099|      0|      coap_log_debug("request for unknown resource '%*.*s',"
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4100|      0|                     " return 2.02\n",
 4101|      0|                     (int)uri_path->length,
 4102|      0|                     (int)uri_path->length,
 4103|      0|                     uri_path->s);
 4104|      0|      resp = 202;
 4105|      0|      goto fail_response;
 4106|      1|    } else if (context->dyn_create_handler != NULL) {
  ------------------
  |  Branch (4106:16): [True: 0, False: 1]
  ------------------
 4107|      0|      resource = coap_add_dynamic_resource(session, pdu);
 4108|      0|      if (!resource) {
  ------------------
  |  Branch (4108:11): [True: 0, False: 0]
  ------------------
 4109|      0|        resp = 406;
 4110|      0|        goto fail_response;
 4111|      0|      }
 4112|      1|    } else { /* request for any another resource, return 4.04 */
 4113|       |
 4114|      1|      coap_log_debug("request for unknown resource '%*.*s', return 4.04\n",
  ------------------
  |  |  126|      1|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      1|#define coap_log(level, ...) do { \
  |  |  |  |  291|      1|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  292|      1|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      1|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4115|      1|                     (int)uri_path->length, (int)uri_path->length, uri_path->s);
 4116|      1|      resp = 404;
 4117|      1|      goto fail_response;
 4118|      1|    }
 4119|       |
 4120|      1|  }
 4121|       |
 4122|     98|  coap_resource_reference_lkd(resource);
 4123|       |
 4124|     98|  if (hop_limit >= 0 &&
  ------------------
  |  Branch (4124:7): [True: 0, False: 98]
  ------------------
 4125|      0|      (is_proxy_scheme || is_proxy_uri ||
  ------------------
  |  Branch (4125:8): [True: 0, False: 0]
  |  Branch (4125:27): [True: 0, False: 0]
  ------------------
 4126|      0|       (resource == context->unknown_resource && resource->is_reverse_proxy))) {
  ------------------
  |  Branch (4126:9): [True: 0, False: 0]
  |  Branch (4126:50): [True: 0, False: 0]
  ------------------
 4127|      0|    uint8_t buf[4];
 4128|       |
 4129|      0|    if (hop_limit == 1) {
  ------------------
  |  Branch (4129:9): [True: 0, False: 0]
  ------------------
 4130|      0|      coap_log_info("Hop Limit expired\n");
  ------------------
  |  |  114|      0|#define coap_log_info(...) coap_log(COAP_LOG_INFO, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4131|      0|      if (resource == context->unknown_resource && resource->is_reverse_proxy) {
  ------------------
  |  Branch (4131:11): [True: 0, False: 0]
  |  Branch (4131:52): [True: 0, False: 0]
  ------------------
 4132|       |        /* Need to hide this is a reverse proxy */
 4133|      0|        resp = 404;
 4134|      0|      } else {
 4135|       |        /* coap_send_internal() will fill in the IP address for us */
 4136|      0|        resp = 508;
 4137|      0|      }
 4138|      0|      goto fail_response;
 4139|      0|    }
 4140|       |    /* hop_limit == 0 or > 255 checked earlier */
 4141|      0|    hop_limit--;
 4142|      0|    coap_update_option(pdu, COAP_OPTION_HOP_LIMIT,
 4143|      0|                       coap_encode_var_safe8(buf, sizeof(buf), hop_limit),
 4144|      0|                       buf);
 4145|      0|  }
 4146|       |
 4147|     98|#if COAP_OSCORE_SUPPORT
 4148|     98|  if ((resource->flags & COAP_RESOURCE_FLAGS_OSCORE_ONLY) && !session->oscore_encryption) {
  ------------------
  |  |  155|     98|#define COAP_RESOURCE_FLAGS_OSCORE_ONLY 0x400
  ------------------
  |  Branch (4148:7): [True: 0, False: 98]
  |  Branch (4148:62): [True: 0, False: 0]
  ------------------
 4149|      0|    coap_log_debug("request for OSCORE only resource '%*.*s', return 4.04\n",
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4150|      0|                   (int)uri_path->length, (int)uri_path->length, uri_path->s);
 4151|      0|    resp = 401;
 4152|      0|    goto fail_response;
 4153|      0|  }
 4154|     98|#endif /* COAP_OSCORE_SUPPORT */
 4155|     98|  if (resource->is_unknown == 0 && resource->is_proxy_uri == 0) {
  ------------------
  |  Branch (4155:7): [True: 98, False: 0]
  |  Branch (4155:36): [True: 98, False: 0]
  ------------------
 4156|       |    /* Check for existing resource and If-Non-Match */
 4157|     98|    opt = coap_check_option(pdu, COAP_OPTION_IF_NONE_MATCH, &opt_iter);
 4158|     98|    if (opt) {
  ------------------
  |  Branch (4158:9): [True: 0, False: 98]
  ------------------
 4159|      0|      resp = 412;
 4160|      0|      goto fail_response;
 4161|      0|    }
 4162|     98|  }
 4163|       |
 4164|       |  /* the resource was found, check if there is a registered handler */
 4165|     98|  if ((size_t)pdu->code - 1 <
  ------------------
  |  Branch (4165:7): [True: 98, False: 0]
  ------------------
 4166|     98|      sizeof(resource->handler) / sizeof(coap_method_handler_t))
 4167|     98|    h = resource->handler[pdu->code - 1];
 4168|       |
 4169|     98|  if (h == NULL) {
  ------------------
  |  Branch (4169:7): [True: 19, False: 79]
  ------------------
 4170|     19|    resp = 405;
 4171|     19|    goto fail_response;
 4172|     19|  }
 4173|     79|  if (pdu->code == COAP_REQUEST_CODE_FETCH) {
  ------------------
  |  Branch (4173:7): [True: 0, False: 79]
  ------------------
 4174|      0|    if (coap_check_option(pdu, COAP_OPTION_OSCORE, &opt_iter) == NULL) {
  ------------------
  |  Branch (4174:9): [True: 0, False: 0]
  ------------------
 4175|      0|      opt = coap_check_option(pdu, COAP_OPTION_CONTENT_FORMAT, &opt_iter);
 4176|      0|      if (opt == NULL) {
  ------------------
  |  Branch (4176:11): [True: 0, False: 0]
  ------------------
 4177|       |        /* RFC 8132 2.3.1 */
 4178|      0|        resp = 415;
 4179|      0|        goto fail_response;
 4180|      0|      }
 4181|      0|    }
 4182|      0|  }
 4183|     79|  if (context->mcast_per_resource &&
  ------------------
  |  Branch (4183:7): [True: 0, False: 79]
  ------------------
 4184|      0|      (resource->flags & COAP_RESOURCE_FLAGS_HAS_MCAST_SUPPORT) == 0 &&
  ------------------
  |  |   89|      0|#define COAP_RESOURCE_FLAGS_HAS_MCAST_SUPPORT 0x8
  ------------------
  |  Branch (4184:7): [True: 0, False: 0]
  ------------------
 4185|      0|      coap_is_mcast(&session->addr_info.local)) {
  ------------------
  |  Branch (4185:7): [True: 0, False: 0]
  ------------------
 4186|      0|    resp = 405;
 4187|      0|    goto fail_response;
 4188|      0|  }
 4189|       |
 4190|     79|  if (pdu->type == COAP_MESSAGE_CON) {
  ------------------
  |  Branch (4190:7): [True: 76, False: 3]
  ------------------
 4191|     76|    response = coap_pdu_init(COAP_MESSAGE_ACK, 0, pdu->mid,
 4192|     76|                             coap_session_max_pdu_size_lkd(session));
 4193|     76|  } else {
 4194|      3|    response = coap_pdu_init(COAP_MESSAGE_NON, 0, coap_new_message_id_lkd(session),
 4195|      3|                             coap_session_max_pdu_size_lkd(session));
 4196|      3|  }
 4197|     79|  if (!response) {
  ------------------
  |  Branch (4197:7): [True: 0, False: 79]
  ------------------
 4198|      0|    coap_log_err("could not create response PDU\n");
  ------------------
  |  |  102|      0|#define coap_log_err(...) coap_log(COAP_LOG_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4199|      0|    resp = 500;
 4200|      0|    goto fail_response;
 4201|      0|  }
 4202|     79|  response->session = session;
 4203|     79|#if COAP_ASYNC_SUPPORT
 4204|       |  /* If handling a separate response, need CON, not ACK response */
 4205|     79|  if (async && pdu->type == COAP_MESSAGE_CON)
  ------------------
  |  Branch (4205:7): [True: 0, False: 79]
  |  Branch (4205:16): [True: 0, False: 0]
  ------------------
 4206|      0|    response->type = COAP_MESSAGE_CON;
 4207|     79|#endif /* COAP_ASYNC_SUPPORT */
 4208|       |  /* A lot of the reliable code assumes type is CON */
 4209|     79|  if (COAP_PROTO_RELIABLE(session->proto) && response->type != COAP_MESSAGE_CON)
  ------------------
  |  |   42|    158|#define COAP_PROTO_RELIABLE(p) ((p)==COAP_PROTO_TCP || (p)==COAP_PROTO_TLS || \
  |  |  ------------------
  |  |  |  Branch (42:33): [True: 0, False: 79]
  |  |  |  Branch (42:56): [True: 0, False: 79]
  |  |  ------------------
  |  |   43|     79|                                (p)==COAP_PROTO_WS || (p)==COAP_PROTO_WSS)
  |  |  ------------------
  |  |  |  Branch (43:33): [True: 0, False: 79]
  |  |  |  Branch (43:55): [True: 0, False: 79]
  |  |  ------------------
  ------------------
  |  Branch (4209:46): [True: 0, False: 0]
  ------------------
 4210|      0|    response->type = COAP_MESSAGE_CON;
 4211|       |
 4212|     79|  if (!coap_add_token(response, pdu->actual_token.length,
  ------------------
  |  Branch (4212:7): [True: 0, False: 79]
  ------------------
 4213|     79|                      pdu->actual_token.s)) {
 4214|      0|    resp = 500;
 4215|      0|    goto fail_response;
 4216|      0|  }
 4217|       |
 4218|       |  /*
 4219|       |   * RFC7959 2.2: the SZX value 7 "is reserved, i.e., MUST NOT be sent and
 4220|       |   * MUST lead to a 4.00 Bad Request response code upon reception in a
 4221|       |   * request".  SZX 7 is only meaningful as the BERT escape (RFC8323 6),
 4222|       |   * which needs a reliable transport with BERT negotiated in both CSMs.
 4223|       |   * Anywhere else it must be rejected here: coap_get_block_b() reports a
 4224|       |   * reserved SZX as "no Block option present", which is indistinguishable
 4225|       |   * further down from a request that never carried one.
 4226|       |   */
 4227|     79|  if (COAP_PROTO_NOT_RELIABLE(session->proto) ||
  ------------------
  |  |   41|    158|#define COAP_PROTO_NOT_RELIABLE(p) ((p)==COAP_PROTO_UDP || (p)==COAP_PROTO_DTLS)
  |  |  ------------------
  |  |  |  Branch (41:37): [True: 79, False: 0]
  |  |  |  Branch (41:60): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 4228|     79|      !(session->csm_bert_rem_support && session->csm_bert_loc_support)) {
  ------------------
  |  Branch (4228:9): [True: 0, False: 0]
  |  Branch (4228:42): [True: 0, False: 0]
  ------------------
 4229|     79|    static const coap_option_num_t block_nums[] = {
 4230|     79|      COAP_OPTION_BLOCK1, COAP_OPTION_BLOCK2, COAP_OPTION_Q_BLOCK1, COAP_OPTION_Q_BLOCK2
 4231|     79|    };
 4232|     79|    size_t bn;
 4233|       |
 4234|    395|    for (bn = 0; bn < sizeof(block_nums)/sizeof(block_nums[0]); bn++) {
  ------------------
  |  Branch (4234:18): [True: 316, False: 79]
  ------------------
 4235|    316|      coap_opt_t *block_opt = coap_check_option(pdu, block_nums[bn], &opt_iter);
 4236|       |
 4237|    316|      if (block_opt && COAP_OPT_BLOCK_SZX(block_opt) == 7) {
  ------------------
  |  |   96|      2|  (coap_opt_length(opt) ? (COAP_OPT_BLOCK_END_BYTE(opt) & 0x07) : 0)
  |  |  ------------------
  |  |  |  |   87|      1|  ((coap_opt_length(opt) && coap_opt_value(opt)) ? \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (87:5): [True: 1, False: 0]
  |  |  |  |  |  Branch (87:29): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   88|      1|   *(coap_opt_value(opt) + (coap_opt_length(opt)-1)) : 0)
  |  |  ------------------
  |  |  |  Branch (96:4): [True: 1, False: 1]
  |  |  ------------------
  ------------------
  |  Branch (4237:11): [True: 2, False: 314]
  |  Branch (4237:24): [True: 0, False: 2]
  ------------------
 4238|      0|        coap_log_debug("request: reserved Block SZX 7 (RFC7959 2.2)\n");
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4239|      0|        resp = 400;
 4240|      0|        goto fail_response;
 4241|      0|      }
 4242|    316|    }
 4243|     79|  }
 4244|       |
 4245|     79|  query = coap_get_query(pdu);
 4246|       |
 4247|       |  /* check for Observe option RFC7641 and RFC8132 */
 4248|     79|  if (resource->observable &&
  ------------------
  |  Branch (4248:7): [True: 79, False: 0]
  ------------------
 4249|     79|      (pdu->code == COAP_REQUEST_CODE_GET ||
  ------------------
  |  Branch (4249:8): [True: 79, False: 0]
  ------------------
 4250|     79|       pdu->code == COAP_REQUEST_CODE_FETCH)) {
  ------------------
  |  Branch (4250:8): [True: 0, False: 0]
  ------------------
 4251|     79|    observe = coap_check_option(pdu, COAP_OPTION_OBSERVE, &opt_iter);
 4252|     79|  }
 4253|       |
 4254|       |  /*
 4255|       |   * See if blocks need to be aggregated or next requests sent off
 4256|       |   * before invoking application request handler
 4257|       |   */
 4258|     79|  if (session->block_mode & COAP_BLOCK_USE_LIBCOAP) {
  ------------------
  |  |   65|     79|#define COAP_BLOCK_USE_LIBCOAP  0x01 /* Use libcoap to do block requests */
  ------------------
  |  Branch (4258:7): [True: 0, False: 79]
  ------------------
 4259|      0|    uint32_t block_mode = session->block_mode;
 4260|       |
 4261|      0|    if (observe ||
  ------------------
  |  Branch (4261:9): [True: 0, False: 0]
  ------------------
 4262|      0|        resource->flags & COAP_RESOURCE_FLAGS_FORCE_SINGLE_BODY)
  ------------------
  |  |  150|      0|#define COAP_RESOURCE_FLAGS_FORCE_SINGLE_BODY 0x200
  ------------------
  |  Branch (4262:9): [True: 0, False: 0]
  ------------------
 4263|      0|      session->block_mode |= COAP_BLOCK_SINGLE_BODY;
  ------------------
  |  |   66|      0|#define COAP_BLOCK_SINGLE_BODY  0x02 /* Deliver the data as a single body */
  ------------------
 4264|      0|    if (coap_handle_request_put_block(context, session, pdu, response,
  ------------------
  |  Branch (4264:9): [True: 0, False: 0]
  ------------------
 4265|      0|                                      resource, observe,
 4266|      0|                                      &added_block, &free_lg_srcv)) {
 4267|      0|      session->block_mode = block_mode;
 4268|      0|      goto skip_handler;
 4269|      0|    }
 4270|      0|    session->block_mode = block_mode;
 4271|       |
 4272|      0|    if (coap_handle_request_send_block(session, pdu, response, resource,
  ------------------
  |  Branch (4272:9): [True: 0, False: 0]
  ------------------
 4273|      0|                                       query)) {
 4274|      0|#if COAP_Q_BLOCK_SUPPORT
 4275|      0|      lg_xmit_ctrl = 1;
 4276|      0|#endif /* COAP_Q_BLOCK_SUPPORT */
 4277|      0|      goto skip_handler;
 4278|      0|    }
 4279|      0|  }
 4280|       |
 4281|     79|  if (observe) {
  ------------------
  |  Branch (4281:7): [True: 70, False: 9]
  ------------------
 4282|     70|    observe_action =
 4283|     70|        coap_decode_var_bytes(coap_opt_value(observe),
 4284|     70|                              coap_opt_length(observe));
 4285|       |
 4286|     70|    if (observe_action == COAP_OBSERVE_ESTABLISH) {
  ------------------
  |  |   37|     70|#define COAP_OBSERVE_ESTABLISH 0
  ------------------
  |  Branch (4286:9): [True: 35, False: 35]
  ------------------
 4287|     35|      coap_subscription_t *subscription;
 4288|       |
 4289|     35|      if (coap_get_block_b(session, pdu, COAP_OPTION_BLOCK2, &block)) {
  ------------------
  |  Branch (4289:11): [True: 0, False: 35]
  ------------------
 4290|      0|        if (block.num != 0) {
  ------------------
  |  Branch (4290:13): [True: 0, False: 0]
  ------------------
 4291|      0|          response->code = COAP_RESPONSE_CODE(400);
  ------------------
  |  |   96|      0|#define COAP_RESPONSE_CODE(N) (((N)/100 << 5) | (N)%100)
  ------------------
 4292|      0|          goto skip_handler;
 4293|      0|        }
 4294|      0|#if COAP_Q_BLOCK_SUPPORT
 4295|     35|      } else if (coap_get_block_b(session, pdu, COAP_OPTION_Q_BLOCK2,
  ------------------
  |  Branch (4295:18): [True: 0, False: 35]
  ------------------
 4296|     35|                                  &block)) {
 4297|      0|        if (block.num != 0) {
  ------------------
  |  Branch (4297:13): [True: 0, False: 0]
  ------------------
 4298|      0|          response->code = COAP_RESPONSE_CODE(400);
  ------------------
  |  |   96|      0|#define COAP_RESPONSE_CODE(N) (((N)/100 << 5) | (N)%100)
  ------------------
 4299|      0|          goto skip_handler;
 4300|      0|        }
 4301|      0|#endif /* COAP_Q_BLOCK_SUPPORT */
 4302|      0|      }
 4303|     35|      subscription = coap_add_observer(resource, session, &pdu->actual_token,
 4304|     35|                                       pdu);
 4305|     35|      if (subscription) {
  ------------------
  |  Branch (4305:11): [True: 35, False: 0]
  ------------------
 4306|     35|        uint8_t buf[4];
 4307|       |
 4308|     35|        coap_touch_observer(context, session, &pdu->actual_token);
 4309|     35|        coap_insert_option(response, COAP_OPTION_OBSERVE,
 4310|     35|                           coap_encode_var_safe(buf, sizeof(buf),
 4311|     35|                                                resource->observe),
 4312|     35|                           buf);
 4313|     35|      }
 4314|     35|    } else if (observe_action == COAP_OBSERVE_CANCEL) {
  ------------------
  |  |   44|     35|#define COAP_OBSERVE_CANCEL 1
  ------------------
  |  Branch (4314:16): [True: 35, False: 0]
  ------------------
 4315|     35|      coap_delete_observer_request(resource, session, &pdu->actual_token, pdu, free_lg_srcv != NULL);
 4316|     35|    } else {
 4317|      0|      coap_log_info("observe: unexpected action %d\n", observe_action);
  ------------------
  |  |  114|      0|#define coap_log_info(...) coap_log(COAP_LOG_INFO, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4318|      0|    }
 4319|     70|  }
 4320|       |
 4321|     79|#if COAP_WITH_OBSERVE_PERSIST
 4322|       |  /* If we are maintaining Observe persist */
 4323|     79|  if (resource == context->unknown_resource) {
  ------------------
  |  Branch (4323:7): [True: 0, False: 79]
  ------------------
 4324|      0|    context->unknown_pdu = pdu;
 4325|      0|    context->unknown_session = session;
 4326|      0|  } else
 4327|     79|    context->unknown_pdu = NULL;
 4328|     79|#endif /* COAP_WITH_OBSERVE_PERSIST */
 4329|       |
 4330|       |  /*
 4331|       |   * Call the request handler with everything set up
 4332|       |   */
 4333|     79|  if (resource == &resource_uri_wellknown) {
  ------------------
  |  Branch (4333:7): [True: 0, False: 79]
  ------------------
 4334|       |    /* Leave context locked */
 4335|      0|    coap_log_debug("call handler for pseudo resource '%*.*s' (3)\n",
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4336|      0|                   (int)resource->uri_path->length, (int)resource->uri_path->length,
 4337|      0|                   resource->uri_path->s);
 4338|      0|    h(resource, session, pdu, query, response);
 4339|      0|    if (COAP_RESPONSE_CLASS(response->code) == 2 && response->data == NULL &&
  ------------------
  |  |   99|      0|#define COAP_RESPONSE_CLASS(C) (((C) >> 5) & 0xFF)
  ------------------
  |  Branch (4339:9): [True: 0, False: 0]
  |  Branch (4339:53): [True: 0, False: 0]
  ------------------
 4340|      0|        coap_is_mcast(&session->addr_info.local)) {
  ------------------
  |  Branch (4340:9): [True: 0, False: 0]
  ------------------
 4341|      0|      goto drop_it_debug;
 4342|      0|    }
 4343|     79|  } else {
 4344|     79|    coap_log_debug("call custom handler for resource '%*.*s' (3)\n",
  ------------------
  |  |  126|     79|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|     79|#define coap_log(level, ...) do { \
  |  |  |  |  291|     79|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 79]
  |  |  |  |  ------------------
  |  |  |  |  292|     79|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|     79|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 79]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4345|     79|                   (int)resource->uri_path->length, (int)resource->uri_path->length,
 4346|     79|                   resource->uri_path->s);
 4347|     79|    if (resource->flags & COAP_RESOURCE_SAFE_REQUEST_HANDLER) {
  ------------------
  |  |  181|     79|#define COAP_RESOURCE_SAFE_REQUEST_HANDLER 0x4000
  ------------------
  |  Branch (4347:9): [True: 0, False: 79]
  ------------------
 4348|      0|      coap_lock_callback_release(h(resource, session, pdu, query, response),
  ------------------
  |  |  680|      0|#define coap_lock_callback_release(func,failed) func
  ------------------
 4349|       |                                 /* context is being freed off */
 4350|      0|                                 goto finish);
 4351|     79|    } else {
 4352|     79|      coap_lock_specific_callback_release(&resource->lock,
  ------------------
  |  |  692|     79|#define coap_lock_specific_callback_release(lock,func,failed) func
  ------------------
 4353|     79|                                          h(resource, session, pdu, query, response),
 4354|       |                                          /* context is being freed off */
 4355|     79|                                          goto finish);
 4356|     79|    }
 4357|     79|  }
 4358|       |
 4359|       |  /* Check validity of response code */
 4360|     79|  if (!coap_check_code_class(session, response)) {
  ------------------
  |  Branch (4360:7): [True: 0, False: 79]
  ------------------
 4361|      0|    coap_log_warn("handle_request: Invalid PDU response code (%d.%02d)\n",
  ------------------
  |  |  108|      0|#define coap_log_warn(...) coap_log(COAP_LOG_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4362|      0|                  COAP_RESPONSE_CLASS(response->code),
 4363|      0|                  response->code & 0x1f);
 4364|      0|    goto drop_it_no_debug;
 4365|      0|  }
 4366|       |
 4367|       |  /* Check correct content type returned by application */
 4368|     79|  if (response->code != 0 && (opt = coap_check_option(pdu, COAP_OPTION_ACCEPT, &opt_iter)) &&
  ------------------
  |  Branch (4368:7): [True: 79, False: 0]
  |  Branch (4368:30): [True: 1, False: 78]
  ------------------
 4369|      1|      !(COAP_RESPONSE_CLASS(response->code) == 4 || COAP_RESPONSE_CLASS(response->code) == 5)) {
  ------------------
  |  |   99|      1|#define COAP_RESPONSE_CLASS(C) (((C) >> 5) & 0xFF)
  ------------------
                    !(COAP_RESPONSE_CLASS(response->code) == 4 || COAP_RESPONSE_CLASS(response->code) == 5)) {
  ------------------
  |  |   99|      1|#define COAP_RESPONSE_CLASS(C) (((C) >> 5) & 0xFF)
  ------------------
  |  Branch (4369:9): [True: 0, False: 1]
  |  Branch (4369:53): [True: 0, False: 1]
  ------------------
 4370|      1|    coap_opt_t *ropt = coap_check_option(response, COAP_OPTION_CONTENT_FORMAT, &opt_iter);
 4371|       |
 4372|      1|    if (!ropt) {
  ------------------
  |  Branch (4372:9): [True: 1, False: 0]
  ------------------
 4373|      1|      coap_add_option_internal(response, COAP_OPTION_CONTENT_FORMAT,
 4374|      1|                               coap_opt_length(opt), coap_opt_value(opt));
 4375|      1|    } else if (coap_opt_length(opt) != coap_opt_length(ropt) ||
  ------------------
  |  Branch (4375:16): [True: 0, False: 0]
  ------------------
 4376|      0|               memcmp(coap_opt_value(opt), coap_opt_value(ropt), coap_opt_length(opt)) != 0) {
  ------------------
  |  Branch (4376:16): [True: 0, False: 0]
  ------------------
 4377|      0|      coap_show_pdu(COAP_LOG_DEBUG, response);
 4378|      0|      coap_log_debug("handle_request: response: Invalid Content-Format\n");
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4379|       |      /* Need to convert response to 4.06 as incorrect content type */
 4380|      0|      response->code = COAP_RESPONSE_CODE(406);
  ------------------
  |  |   96|      0|#define COAP_RESPONSE_CODE(N) (((N)/100 << 5) | (N)%100)
  ------------------
 4381|      0|      response->used_size = response->e_token_length;
 4382|      0|      response->data = NULL;
 4383|      0|      response->max_opt = 0;
 4384|      0|      coap_add_option_internal(response, COAP_OPTION_ACCEPT,
 4385|      0|                               coap_opt_length(opt),
 4386|      0|                               coap_opt_value(opt));
 4387|      0|      coap_add_data(response, sizeof("Not Acceptable")-1, (const uint8_t *)"Not Acceptable");
 4388|      0|    }
 4389|      1|  }
 4390|       |
 4391|       |  /* Check if lg_xmit generated and update PDU code if so */
 4392|     79|  coap_check_code_lg_xmit(session, pdu, response, resource, query);
 4393|       |
 4394|     79|  if (free_lg_srcv) {
  ------------------
  |  Branch (4394:7): [True: 0, False: 79]
  ------------------
 4395|       |    /* Check to see if the server is doing a 4.01 + Echo response */
 4396|      0|    if (response->code ==  COAP_RESPONSE_CODE(401) &&
  ------------------
  |  |   96|      0|#define COAP_RESPONSE_CODE(N) (((N)/100 << 5) | (N)%100)
  ------------------
  |  Branch (4396:9): [True: 0, False: 0]
  ------------------
 4397|      0|        coap_check_option(response, COAP_OPTION_ECHO, &opt_iter)) {
  ------------------
  |  Branch (4397:9): [True: 0, False: 0]
  ------------------
 4398|       |      /* Need to keep lg_srcv around for client's response */
 4399|      0|    } else {
 4400|      0|      coap_lg_srcv_t *lg_srcv;
 4401|       |      /*
 4402|       |       * Need to check free_lg_srcv still exists in case of error or timing window
 4403|       |       */
 4404|      0|      LL_FOREACH(session->lg_srcv, lg_srcv) {
  ------------------
  |  |  419|      0|    LL_FOREACH2(head,el,next)
  |  |  ------------------
  |  |  |  |  422|      0|    for ((el) = (head); el; (el) = (el)->next)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (422:25): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4405|      0|        if (lg_srcv == free_lg_srcv) {
  ------------------
  |  Branch (4405:13): [True: 0, False: 0]
  ------------------
 4406|      0|#if COAP_Q_BLOCK_SUPPORT
 4407|      0|          if (lg_srcv->block_option == COAP_OPTION_Q_BLOCK1) {
  ------------------
  |  Branch (4407:15): [True: 0, False: 0]
  ------------------
 4408|      0|            coap_tick_t adjust;
 4409|       |
 4410|       |            /* cache the lg_srcv for 1 second */
 4411|      0|            if (COAP_NON_RECEIVE_TIMEOUT_TICKS(session) >= COAP_TICKS_PER_SECOND) {
  ------------------
  |  |  972|      0|#define COAP_NON_RECEIVE_TIMEOUT_TICKS(s) ( \
  |  |  973|      0|                                            COAP_NON_RECEIVE_TIMEOUT(s).integer_part * COAP_TICKS_PER_SECOND + \
  |  |  ------------------
  |  |  |  |  886|      0|#define COAP_NON_RECEIVE_TIMEOUT(s) ((s)->non_receive_timeout)
  |  |  ------------------
  |  |                                                           COAP_NON_RECEIVE_TIMEOUT(s).integer_part * COAP_TICKS_PER_SECOND + \
  |  |  ------------------
  |  |  |  |  164|      0|#define COAP_TICKS_PER_SECOND ((coap_tick_t)(1000U))
  |  |  ------------------
  |  |  974|      0|                                            COAP_NON_RECEIVE_TIMEOUT(s).fractional_part * COAP_TICKS_PER_SECOND / 1000)
  |  |  ------------------
  |  |  |  |  886|      0|#define COAP_NON_RECEIVE_TIMEOUT(s) ((s)->non_receive_timeout)
  |  |  ------------------
  |  |                                                           COAP_NON_RECEIVE_TIMEOUT(s).fractional_part * COAP_TICKS_PER_SECOND / 1000)
  |  |  ------------------
  |  |  |  |  164|      0|#define COAP_TICKS_PER_SECOND ((coap_tick_t)(1000U))
  |  |  ------------------
  ------------------
                          if (COAP_NON_RECEIVE_TIMEOUT_TICKS(session) >= COAP_TICKS_PER_SECOND) {
  ------------------
  |  |  164|      0|#define COAP_TICKS_PER_SECOND ((coap_tick_t)(1000U))
  ------------------
  |  Branch (4411:17): [True: 0, False: 0]
  ------------------
 4412|      0|              adjust = COAP_NON_RECEIVE_TIMEOUT_TICKS(session) - COAP_TICKS_PER_SECOND;
  ------------------
  |  |  972|      0|#define COAP_NON_RECEIVE_TIMEOUT_TICKS(s) ( \
  |  |  973|      0|                                            COAP_NON_RECEIVE_TIMEOUT(s).integer_part * COAP_TICKS_PER_SECOND + \
  |  |  ------------------
  |  |  |  |  886|      0|#define COAP_NON_RECEIVE_TIMEOUT(s) ((s)->non_receive_timeout)
  |  |  ------------------
  |  |                                                           COAP_NON_RECEIVE_TIMEOUT(s).integer_part * COAP_TICKS_PER_SECOND + \
  |  |  ------------------
  |  |  |  |  164|      0|#define COAP_TICKS_PER_SECOND ((coap_tick_t)(1000U))
  |  |  ------------------
  |  |  974|      0|                                            COAP_NON_RECEIVE_TIMEOUT(s).fractional_part * COAP_TICKS_PER_SECOND / 1000)
  |  |  ------------------
  |  |  |  |  886|      0|#define COAP_NON_RECEIVE_TIMEOUT(s) ((s)->non_receive_timeout)
  |  |  ------------------
  |  |                                                           COAP_NON_RECEIVE_TIMEOUT(s).fractional_part * COAP_TICKS_PER_SECOND / 1000)
  |  |  ------------------
  |  |  |  |  164|      0|#define COAP_TICKS_PER_SECOND ((coap_tick_t)(1000U))
  |  |  ------------------
  ------------------
                            adjust = COAP_NON_RECEIVE_TIMEOUT_TICKS(session) - COAP_TICKS_PER_SECOND;
  ------------------
  |  |  164|      0|#define COAP_TICKS_PER_SECOND ((coap_tick_t)(1000U))
  ------------------
 4413|      0|            } else {
 4414|      0|              adjust = 0;
 4415|      0|            }
 4416|      0|            coap_ticks(&free_lg_srcv->rec_blocks.last_seen);
 4417|      0|            if (free_lg_srcv->rec_blocks.last_seen > adjust) {
  ------------------
  |  Branch (4417:17): [True: 0, False: 0]
  ------------------
 4418|      0|              free_lg_srcv->rec_blocks.last_seen -= adjust;
 4419|      0|            }
 4420|      0|            free_lg_srcv->dont_timeout = 0;
 4421|      0|            break;
 4422|      0|          }
 4423|      0|#endif /* COAP_Q_BLOCK_SUPPORT */
 4424|      0|          LL_DELETE(session->lg_srcv, free_lg_srcv);
  ------------------
  |  |  391|      0|    LL_DELETE2(head,del,next)
  |  |  ------------------
  |  |  |  |  393|      0|#define LL_DELETE2(head,del,next)                                                              \
  |  |  |  |  394|      0|do {                                                                                           \
  |  |  |  |  395|      0|  LDECLTYPE(head) _tmp;                                                                        \
  |  |  |  |  ------------------
  |  |  |  |  |  |   81|      0|#define LDECLTYPE(x) __typeof(x)
  |  |  |  |  ------------------
  |  |  |  |  396|      0|  if ((head) == (del)) {                                                                       \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (396:7): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  397|      0|    (head)=(head)->next;                                                                       \
  |  |  |  |  398|      0|  } else {                                                                                     \
  |  |  |  |  399|      0|    _tmp = (head);                                                                             \
  |  |  |  |  400|      0|    while (_tmp->next && (_tmp->next != (del))) {                                              \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (400:12): [True: 0, False: 0]
  |  |  |  |  |  Branch (400:26): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  401|      0|      _tmp = _tmp->next;                                                                       \
  |  |  |  |  402|      0|    }                                                                                          \
  |  |  |  |  403|      0|    if (_tmp->next) {                                                                          \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (403:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  404|      0|      _tmp->next = (del)->next;                                                                \
  |  |  |  |  405|      0|    }                                                                                          \
  |  |  |  |  406|      0|  }                                                                                            \
  |  |  |  |  407|      0|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (407:10): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4425|      0|          coap_block_delete_lg_srcv(session, free_lg_srcv);
 4426|      0|          break;
 4427|      0|        }
 4428|      0|      }
 4429|      0|    }
 4430|      0|  }
 4431|     79|  if (added_block && COAP_RESPONSE_CLASS(response->code) == 2) {
  ------------------
  |  |   99|      0|#define COAP_RESPONSE_CLASS(C) (((C) >> 5) & 0xFF)
  ------------------
  |  Branch (4431:7): [True: 0, False: 79]
  |  Branch (4431:22): [True: 0, False: 0]
  ------------------
 4432|       |    /* Just in case, as there are more to go */
 4433|      0|    response->code = COAP_RESPONSE_CODE(231);
  ------------------
  |  |   96|      0|#define COAP_RESPONSE_CODE(N) (((N)/100 << 5) | (N)%100)
  ------------------
 4434|      0|  }
 4435|       |
 4436|    100|skip_handler:
 4437|    100|  respond = no_response(pdu, response, session, resource);
 4438|    100|  if (respond != RESPONSE_DROP) {
  ------------------
  |  Branch (4438:7): [True: 100, False: 0]
  ------------------
 4439|    100|#if (COAP_MAX_LOGGING_LEVEL >= _COAP_LOG_DEBUG)
 4440|    100|    coap_mid_t mid = pdu->mid;
 4441|    100|#endif
 4442|    100|    if (COAP_RESPONSE_CLASS(response->code) != 2) {
  ------------------
  |  |   99|    100|#define COAP_RESPONSE_CLASS(C) (((C) >> 5) & 0xFF)
  ------------------
  |  Branch (4442:9): [True: 22, False: 78]
  ------------------
 4443|     22|      if (observe) {
  ------------------
  |  Branch (4443:11): [True: 0, False: 22]
  ------------------
 4444|      0|        coap_remove_option(response, COAP_OPTION_OBSERVE);
 4445|      0|      }
 4446|     22|    }
 4447|    100|    if (COAP_RESPONSE_CLASS(response->code) > 2) {
  ------------------
  |  |   99|    100|#define COAP_RESPONSE_CLASS(C) (((C) >> 5) & 0xFF)
  ------------------
  |  Branch (4447:9): [True: 21, False: 79]
  ------------------
 4448|     21|      if (observe)
  ------------------
  |  Branch (4448:11): [True: 0, False: 21]
  ------------------
 4449|      0|        coap_delete_observer(resource, session, &pdu->actual_token);
 4450|     21|      if (response->code != COAP_RESPONSE_CODE(413))
  ------------------
  |  |   96|     21|#define COAP_RESPONSE_CODE(N) (((N)/100 << 5) | (N)%100)
  ------------------
  |  Branch (4450:11): [True: 21, False: 0]
  ------------------
 4451|     21|        coap_remove_option(response, COAP_OPTION_BLOCK1);
 4452|     21|    }
 4453|       |
 4454|       |    /* If original request contained a token, and the registered
 4455|       |     * application handler made no changes to the response, then
 4456|       |     * this is an empty ACK with a token, which is a malformed
 4457|       |     * PDU */
 4458|    100|    if ((response->type == COAP_MESSAGE_ACK)
  ------------------
  |  Branch (4458:9): [True: 89, False: 11]
  ------------------
 4459|     89|        && (response->code == 0)) {
  ------------------
  |  Branch (4459:12): [True: 1, False: 88]
  ------------------
 4460|       |      /* Remove token from otherwise-empty acknowledgment PDU */
 4461|      1|      response->actual_token.length = 0;
 4462|      1|      response->e_token_length = 0;
 4463|      1|      response->used_size = 0;
 4464|      1|      response->data = NULL;
 4465|      1|    }
 4466|       |
 4467|    100|    if (!coap_is_mcast(&session->addr_info.local) ||
  ------------------
  |  Branch (4467:9): [True: 100, False: 0]
  ------------------
 4468|      0|        (context->mcast_per_resource &&
  ------------------
  |  Branch (4468:10): [True: 0, False: 0]
  ------------------
 4469|      0|         resource &&
  ------------------
  |  Branch (4469:10): [True: 0, False: 0]
  ------------------
 4470|    100|         (resource->flags & COAP_RESOURCE_FLAGS_LIB_DIS_MCAST_DELAYS))) {
  ------------------
  |  |  100|      0|#define COAP_RESOURCE_FLAGS_LIB_DIS_MCAST_DELAYS 0x10
  ------------------
  |  Branch (4470:10): [True: 0, False: 0]
  ------------------
 4471|       |      /* No delays to response */
 4472|    100|#if COAP_Q_BLOCK_SUPPORT
 4473|    100|      if (session->block_mode & COAP_BLOCK_USE_LIBCOAP &&
  ------------------
  |  |   65|    200|#define COAP_BLOCK_USE_LIBCOAP  0x01 /* Use libcoap to do block requests */
  ------------------
  |  Branch (4473:11): [True: 0, False: 100]
  ------------------
 4474|      0|          !lg_xmit_ctrl && COAP_RESPONSE_CLASS(response->code) == 2 &&
  ------------------
  |  |   99|      0|#define COAP_RESPONSE_CLASS(C) (((C) >> 5) & 0xFF)
  ------------------
  |  Branch (4474:11): [True: 0, False: 0]
  |  Branch (4474:28): [True: 0, False: 0]
  ------------------
 4475|      0|          coap_get_block_b(session, response, COAP_OPTION_Q_BLOCK2, &block) &&
  ------------------
  |  Branch (4475:11): [True: 0, False: 0]
  ------------------
 4476|      0|          block.m) {
  ------------------
  |  Branch (4476:11): [True: 0, False: 0]
  ------------------
 4477|      0|        if (coap_send_q_block2(session, resource, query, pdu->code, block,
  ------------------
  |  Branch (4477:13): [True: 0, False: 0]
  ------------------
 4478|      0|                               response,
 4479|      0|                               COAP_SEND_INC_PDU) == COAP_INVALID_MID)
  ------------------
  |  |  198|      0|#define COAP_INVALID_MID -1
  ------------------
 4480|      0|          coap_log_debug("cannot send response for mid=0x%x\n", mid);
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4481|      0|        response = NULL;
 4482|      0|        goto finish;
 4483|      0|      }
 4484|    100|#endif /* COAP_Q_BLOCK_SUPPORT */
 4485|    100|      if (coap_send_internal(session, response, orig_pdu ? orig_pdu : pdu) == COAP_INVALID_MID) {
  ------------------
  |  |  198|    100|#define COAP_INVALID_MID -1
  ------------------
  |  Branch (4485:11): [True: 48, False: 52]
  |  Branch (4485:49): [True: 0, False: 100]
  ------------------
 4486|     48|        coap_log_debug("cannot send response for mid=0x%04x\n", mid);
  ------------------
  |  |  126|     48|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|     48|#define coap_log(level, ...) do { \
  |  |  |  |  291|     48|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 48]
  |  |  |  |  ------------------
  |  |  |  |  292|     48|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|     48|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 48]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4487|     48|        goto finish;
 4488|     48|      }
 4489|    100|    } else {
 4490|       |      /* Need to delay mcast response */
 4491|      0|      coap_queue_t *node = coap_new_node();
 4492|      0|      uint8_t r;
 4493|      0|      coap_tick_t delay;
 4494|       |
 4495|      0|      if (!node) {
  ------------------
  |  Branch (4495:11): [True: 0, False: 0]
  ------------------
 4496|      0|        coap_log_debug("mcast delay: insufficient memory\n");
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4497|      0|        goto drop_it_no_debug;
 4498|      0|      }
 4499|      0|      if (!coap_pdu_encode_header(response, session->proto)) {
  ------------------
  |  Branch (4499:11): [True: 0, False: 0]
  ------------------
 4500|      0|        coap_delete_node_lkd(node);
 4501|      0|        goto drop_it_no_debug;
 4502|      0|      }
 4503|       |
 4504|      0|      node->id = response->mid;
 4505|      0|      node->pdu = response;
 4506|      0|      node->is_mcast = 1;
 4507|      0|      coap_prng_lkd(&r, sizeof(r));
 4508|      0|      delay = (COAP_DEFAULT_LEISURE_TICKS(session) * r) / 256;
  ------------------
  |  |  897|      0|  (COAP_DEFAULT_LEISURE(s).integer_part * COAP_TICKS_PER_SECOND + \
  |  |  ------------------
  |  |  |  |  877|      0|#define COAP_DEFAULT_LEISURE(s) ((s)->default_leisure)
  |  |  ------------------
  |  |                 (COAP_DEFAULT_LEISURE(s).integer_part * COAP_TICKS_PER_SECOND + \
  |  |  ------------------
  |  |  |  |  164|      0|#define COAP_TICKS_PER_SECOND ((coap_tick_t)(1000U))
  |  |  ------------------
  |  |  898|      0|   COAP_DEFAULT_LEISURE(s).fractional_part * COAP_TICKS_PER_SECOND / 1000)
  |  |  ------------------
  |  |  |  |  877|      0|#define COAP_DEFAULT_LEISURE(s) ((s)->default_leisure)
  |  |  ------------------
  |  |                  COAP_DEFAULT_LEISURE(s).fractional_part * COAP_TICKS_PER_SECOND / 1000)
  |  |  ------------------
  |  |  |  |  164|      0|#define COAP_TICKS_PER_SECOND ((coap_tick_t)(1000U))
  |  |  ------------------
  ------------------
 4509|      0|      coap_log_debug("   %s: mid=0x%04x: mcast response delayed for %u.%03u secs\n",
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4510|      0|                     coap_session_str(session),
 4511|      0|                     response->mid,
 4512|      0|                     (unsigned int)(delay / COAP_TICKS_PER_SECOND),
 4513|      0|                     (unsigned int)((delay % COAP_TICKS_PER_SECOND) *
 4514|      0|                                    1000 / COAP_TICKS_PER_SECOND));
 4515|      0|      node->timeout = (unsigned int)delay;
 4516|       |      /* Use this to delay transmission */
 4517|      0|      coap_wait_ack(session->context, session, node);
 4518|      0|    }
 4519|    100|  } else if (COAP_PDU_IS_EMPTY(response) &&
  ------------------
  |  |   98|      0|#define COAP_PDU_IS_EMPTY(pdu)     ((pdu)->code == 0)
  |  |  ------------------
  |  |  |  Branch (98:36): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 4520|      0|             (response->type == COAP_MESSAGE_NON ||
  ------------------
  |  Branch (4520:15): [True: 0, False: 0]
  ------------------
 4521|      0|              response->type == COAP_MESSAGE_CON ||
  ------------------
  |  Branch (4521:15): [True: 0, False: 0]
  ------------------
 4522|      0|              COAP_PROTO_RELIABLE(session->proto))) {
  ------------------
  |  |   42|      0|#define COAP_PROTO_RELIABLE(p) ((p)==COAP_PROTO_TCP || (p)==COAP_PROTO_TLS || \
  |  |  ------------------
  |  |  |  Branch (42:33): [True: 0, False: 0]
  |  |  |  Branch (42:56): [True: 0, False: 0]
  |  |  ------------------
  |  |   43|      0|                                (p)==COAP_PROTO_WS || (p)==COAP_PROTO_WSS)
  |  |  ------------------
  |  |  |  Branch (43:33): [True: 0, False: 0]
  |  |  |  Branch (43:55): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 4523|      0|    coap_delete_pdu_lkd(response);
 4524|      0|  } else {
 4525|      0|drop_it_debug:
 4526|      0|    coap_log_debug("   %s: mid=0x%04x: response dropped\n",
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4527|      0|                   coap_session_str(session),
 4528|      0|                   response->mid);
 4529|      0|    coap_show_pdu(COAP_LOG_DEBUG, response);
 4530|      0|drop_it_no_debug:
 4531|      0|    coap_delete_pdu_lkd(response);
 4532|      0|  }
 4533|     52|#if COAP_Q_BLOCK_SUPPORT
 4534|     52|  if (coap_get_block_b(session, pdu, COAP_OPTION_Q_BLOCK1, &block)) {
  ------------------
  |  Branch (4534:7): [True: 0, False: 52]
  ------------------
 4535|      0|    if (COAP_PROTO_RELIABLE(session->proto)) {
  ------------------
  |  |   42|      0|#define COAP_PROTO_RELIABLE(p) ((p)==COAP_PROTO_TCP || (p)==COAP_PROTO_TLS || \
  |  |  ------------------
  |  |  |  Branch (42:33): [True: 0, False: 0]
  |  |  |  Branch (42:56): [True: 0, False: 0]
  |  |  ------------------
  |  |   43|      0|                                (p)==COAP_PROTO_WS || (p)==COAP_PROTO_WSS)
  |  |  ------------------
  |  |  |  Branch (43:33): [True: 0, False: 0]
  |  |  |  Branch (43:55): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 4536|      0|      if (block.m) {
  ------------------
  |  Branch (4536:11): [True: 0, False: 0]
  ------------------
 4537|       |        /* All of the sequence not in yet */
 4538|      0|        goto finish;
 4539|      0|      }
 4540|      0|    } else if (pdu->type == COAP_MESSAGE_NON) {
  ------------------
  |  Branch (4540:16): [True: 0, False: 0]
  ------------------
 4541|       |      /* More to go and not at a payload break */
 4542|      0|      if (block.m && ((block.num + 1) % COAP_MAX_PAYLOADS(session))) {
  ------------------
  |  |  880|      0|#define COAP_MAX_PAYLOADS(s) ((s)->max_payloads)
  ------------------
  |  Branch (4542:11): [True: 0, False: 0]
  |  Branch (4542:22): [True: 0, False: 0]
  ------------------
 4543|      0|        goto finish;
 4544|      0|      }
 4545|      0|    }
 4546|      0|  }
 4547|     52|#endif /* COAP_Q_BLOCK_SUPPORT */
 4548|       |
 4549|    100|finish:
 4550|    100|  if (query)
  ------------------
  |  Branch (4550:7): [True: 2, False: 98]
  ------------------
 4551|      2|    coap_delete_string(query);
 4552|    100|  if (resource)
  ------------------
  |  Branch (4552:7): [True: 98, False: 2]
  ------------------
 4553|     98|    coap_resource_release_lkd(resource);
 4554|    100|  coap_delete_string(uri_path);
 4555|    100|  return;
 4556|       |
 4557|     21|fail_response:
 4558|     21|  coap_delete_pdu_lkd(response);
 4559|     21|  response =
 4560|     21|      coap_new_error_response(pdu, COAP_RESPONSE_CODE(resp),
  ------------------
  |  |   96|     21|#define COAP_RESPONSE_CODE(N) (((N)/100 << 5) | (N)%100)
  ------------------
 4561|     21|                              &opt_filter);
 4562|     21|  if (response)
  ------------------
  |  Branch (4562:7): [True: 21, False: 0]
  ------------------
 4563|     21|    goto skip_handler;
 4564|      0|  if (resource)
  ------------------
  |  Branch (4564:7): [True: 0, False: 0]
  ------------------
 4565|      0|    coap_resource_release_lkd(resource);
 4566|      0|  coap_delete_string(uri_path);
 4567|      0|}
coap_net.c:no_response:
 3766|    100|            coap_session_t *session, coap_resource_t *resource) {
 3767|    100|  coap_opt_t *nores;
 3768|    100|  coap_opt_iterator_t opt_iter;
 3769|    100|  unsigned int val = 0;
 3770|       |
 3771|    100|  assert(request);
  ------------------
  |  Branch (3771:3): [True: 100, False: 0]
  ------------------
 3772|    100|  assert(response);
  ------------------
  |  Branch (3772:3): [True: 100, False: 0]
  ------------------
 3773|       |
 3774|    100|  if (COAP_RESPONSE_CLASS(response->code) > 0) {
  ------------------
  |  |   99|    100|#define COAP_RESPONSE_CLASS(C) (((C) >> 5) & 0xFF)
  ------------------
  |  Branch (3774:7): [True: 100, False: 0]
  ------------------
 3775|    100|    nores = coap_check_option(request, COAP_OPTION_NORESPONSE, &opt_iter);
 3776|       |
 3777|    100|    if (nores) {
  ------------------
  |  Branch (3777:9): [True: 1, False: 99]
  ------------------
 3778|      1|      val = coap_decode_var_bytes(coap_opt_value(nores), coap_opt_length(nores));
 3779|       |
 3780|       |      /* The response should be dropped when the bit corresponding to
 3781|       |       * the response class is set (cf. table in function
 3782|       |       * documentation). When a No-Response option is present and the
 3783|       |       * bit is not set, the sender explicitly indicates interest in
 3784|       |       * this response. */
 3785|      1|      if (((1 << (COAP_RESPONSE_CLASS(response->code) - 1)) & val) > 0) {
  ------------------
  |  |   99|      1|#define COAP_RESPONSE_CLASS(C) (((C) >> 5) & 0xFF)
  ------------------
  |  Branch (3785:11): [True: 1, False: 0]
  ------------------
 3786|       |        /* Should be dropping the response */
 3787|      1|        if (response->type == COAP_MESSAGE_ACK &&
  ------------------
  |  Branch (3787:13): [True: 1, False: 0]
  ------------------
 3788|      1|            COAP_PROTO_NOT_RELIABLE(session->proto)) {
  ------------------
  |  |   41|      1|#define COAP_PROTO_NOT_RELIABLE(p) ((p)==COAP_PROTO_UDP || (p)==COAP_PROTO_DTLS)
  |  |  ------------------
  |  |  |  Branch (41:37): [True: 1, False: 0]
  |  |  |  Branch (41:60): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 3789|       |          /* Still need to ACK the request */
 3790|      1|          response->code = 0;
 3791|       |          /* Remove token/data from piggybacked acknowledgment PDU */
 3792|      1|          response->actual_token.length = 0;
 3793|      1|          response->e_token_length = 0;
 3794|      1|          response->used_size = 0;
 3795|      1|          response->data = NULL;
 3796|      1|          return RESPONSE_SEND;
 3797|      1|        } else {
 3798|      0|          return RESPONSE_DROP;
 3799|      0|        }
 3800|      1|      } else {
 3801|       |        /* True for mcast as well RFC7967 2.1 */
 3802|      0|        return RESPONSE_SEND;
 3803|      0|      }
 3804|     99|    } else if (resource && session->context->mcast_per_resource &&
  ------------------
  |  Branch (3804:16): [True: 97, False: 2]
  |  Branch (3804:28): [True: 0, False: 97]
  ------------------
 3805|      0|               coap_is_mcast(&session->addr_info.local)) {
  ------------------
  |  Branch (3805:16): [True: 0, False: 0]
  ------------------
 3806|       |      /* Handle any mcast suppression specifics if no NoResponse option */
 3807|      0|      if ((resource->flags &
  ------------------
  |  Branch (3807:11): [True: 0, False: 0]
  ------------------
 3808|      0|           COAP_RESOURCE_FLAGS_LIB_ENA_MCAST_SUPPRESS_2_XX) &&
  ------------------
  |  |  118|      0|#define COAP_RESOURCE_FLAGS_LIB_ENA_MCAST_SUPPRESS_2_XX 0x40
  ------------------
 3809|      0|          COAP_RESPONSE_CLASS(response->code) == 2) {
  ------------------
  |  |   99|      0|#define COAP_RESPONSE_CLASS(C) (((C) >> 5) & 0xFF)
  ------------------
  |  Branch (3809:11): [True: 0, False: 0]
  ------------------
 3810|      0|        return RESPONSE_DROP;
 3811|      0|      } else if ((resource->flags &
  ------------------
  |  Branch (3811:18): [True: 0, False: 0]
  ------------------
 3812|      0|                  COAP_RESOURCE_FLAGS_LIB_ENA_MCAST_SUPPRESS_2_05) &&
  ------------------
  |  |  109|      0|#define COAP_RESOURCE_FLAGS_LIB_ENA_MCAST_SUPPRESS_2_05 0x20
  ------------------
 3813|      0|                 response->code == COAP_RESPONSE_CODE(205)) {
  ------------------
  |  |   96|      0|#define COAP_RESPONSE_CODE(N) (((N)/100 << 5) | (N)%100)
  ------------------
  |  Branch (3813:18): [True: 0, False: 0]
  ------------------
 3814|      0|        if (response->data == NULL)
  ------------------
  |  Branch (3814:13): [True: 0, False: 0]
  ------------------
 3815|      0|          return RESPONSE_DROP;
 3816|      0|      } else if ((resource->flags &
  ------------------
  |  Branch (3816:18): [True: 0, False: 0]
  ------------------
 3817|      0|                  COAP_RESOURCE_FLAGS_LIB_DIS_MCAST_SUPPRESS_4_XX) == 0 &&
  ------------------
  |  |  127|      0|#define COAP_RESOURCE_FLAGS_LIB_DIS_MCAST_SUPPRESS_4_XX 0x80
  ------------------
 3818|      0|                 COAP_RESPONSE_CLASS(response->code) == 4) {
  ------------------
  |  |   99|      0|#define COAP_RESPONSE_CLASS(C) (((C) >> 5) & 0xFF)
  ------------------
  |  Branch (3818:18): [True: 0, False: 0]
  ------------------
 3819|      0|        return RESPONSE_DROP;
 3820|      0|      } else if ((resource->flags &
  ------------------
  |  Branch (3820:18): [True: 0, False: 0]
  ------------------
 3821|      0|                  COAP_RESOURCE_FLAGS_LIB_DIS_MCAST_SUPPRESS_5_XX) == 0 &&
  ------------------
  |  |  136|      0|#define COAP_RESOURCE_FLAGS_LIB_DIS_MCAST_SUPPRESS_5_XX 0x100
  ------------------
 3822|      0|                 COAP_RESPONSE_CLASS(response->code) == 5) {
  ------------------
  |  |   99|      0|#define COAP_RESPONSE_CLASS(C) (((C) >> 5) & 0xFF)
  ------------------
  |  Branch (3822:18): [True: 0, False: 0]
  ------------------
 3823|      0|        return RESPONSE_DROP;
 3824|      0|      }
 3825|      0|    }
 3826|    100|  } else if (COAP_PDU_IS_EMPTY(response) &&
  ------------------
  |  |   98|      0|#define COAP_PDU_IS_EMPTY(pdu)     ((pdu)->code == 0)
  |  |  ------------------
  |  |  |  Branch (98:36): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 3827|      0|             (response->type == COAP_MESSAGE_NON ||
  ------------------
  |  Branch (3827:15): [True: 0, False: 0]
  ------------------
 3828|      0|              response->type == COAP_MESSAGE_CON ||
  ------------------
  |  Branch (3828:15): [True: 0, False: 0]
  ------------------
 3829|      0|              COAP_PROTO_RELIABLE(session->proto))) {
  ------------------
  |  |   42|      0|#define COAP_PROTO_RELIABLE(p) ((p)==COAP_PROTO_TCP || (p)==COAP_PROTO_TLS || \
  |  |  ------------------
  |  |  |  Branch (42:33): [True: 0, False: 0]
  |  |  |  Branch (42:56): [True: 0, False: 0]
  |  |  ------------------
  |  |   43|      0|                                (p)==COAP_PROTO_WS || (p)==COAP_PROTO_WSS)
  |  |  ------------------
  |  |  |  Branch (43:33): [True: 0, False: 0]
  |  |  |  Branch (43:55): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 3830|       |    /* Response is 0.00, and this is reliable, non-confirmable, or a separate
 3831|       |     * (confirmable) response.  An Empty CON is a ping (RFC 7252 4.2), not a
 3832|       |     * response, and the PDU still has the request's token attached, which
 3833|       |     * RFC 7252 4.1 does not allow.  A CON would then get retransmitted up to
 3834|       |     * MAX_RETRANSMIT times. */
 3835|      0|    return RESPONSE_DROP;
 3836|      0|  }
 3837|       |
 3838|       |  /*
 3839|       |   * Do not send error responses for requests that were received via
 3840|       |   * IP multicast.  RFC7252 8.1
 3841|       |   */
 3842|       |
 3843|     99|  if (coap_is_mcast(&session->addr_info.local)) {
  ------------------
  |  Branch (3843:7): [True: 0, False: 99]
  ------------------
 3844|      0|    if (request->type == COAP_MESSAGE_NON &&
  ------------------
  |  Branch (3844:9): [True: 0, False: 0]
  ------------------
 3845|      0|        response->type == COAP_MESSAGE_RST)
  ------------------
  |  Branch (3845:9): [True: 0, False: 0]
  ------------------
 3846|      0|      return RESPONSE_DROP;
 3847|       |
 3848|      0|    if ((!resource || session->context->mcast_per_resource == 0) &&
  ------------------
  |  Branch (3848:10): [True: 0, False: 0]
  |  Branch (3848:23): [True: 0, False: 0]
  ------------------
 3849|      0|        COAP_RESPONSE_CLASS(response->code) > 2)
  ------------------
  |  |   99|      0|#define COAP_RESPONSE_CLASS(C) (((C) >> 5) & 0xFF)
  ------------------
  |  Branch (3849:9): [True: 0, False: 0]
  ------------------
 3850|      0|      return RESPONSE_DROP;
 3851|      0|  }
 3852|       |
 3853|       |  /* Default behavior applies when we are not dealing with a response
 3854|       |   * (class == 0) or the request did not contain a No-Response option.
 3855|       |   */
 3856|     99|  return RESPONSE_DEFAULT;
 3857|     99|}

coap_netif_available:
   25|    143|coap_netif_available(coap_session_t *session) {
   26|    143|  return session->sock.flags != COAP_SOCKET_EMPTY;
  ------------------
  |  |   74|    143|#define COAP_SOCKET_EMPTY        0x0000  /**< the socket is not used */
  ------------------
   27|    143|}
coap_netif_dgrm_connect:
   54|     35|                        const coap_address_t *server, int default_port) {
   55|     35|  if (!coap_socket_connect_udp(&session->sock, local_if, server,
  ------------------
  |  Branch (55:7): [True: 0, False: 35]
  ------------------
   56|     35|                               default_port,
   57|     35|                               &session->addr_info.local,
   58|     35|                               &session->addr_info.remote)) {
   59|      0|    return 0;
   60|      0|  }
   61|     35|  return 1;
   62|     35|}
coap_netif_dgrm_write:
  143|    216|                      size_t datalen) {
  144|    216|  ssize_t bytes_written;
  145|    216|  int keep_errno;
  146|       |
  147|    216|  coap_socket_t *sock = &session->sock;
  148|    216|#if COAP_SERVER_SUPPORT
  149|    216|  if (sock->flags == COAP_SOCKET_EMPTY) {
  ------------------
  |  |   74|    216|#define COAP_SOCKET_EMPTY        0x0000  /**< the socket is not used */
  ------------------
  |  Branch (149:7): [True: 146, False: 70]
  ------------------
  150|    146|    if (session->endpoint != NULL)
  ------------------
  |  Branch (150:9): [True: 0, False: 146]
  ------------------
  151|      0|      sock = &session->endpoint->sock;
  152|    146|  }
  153|    216|#endif /* COAP_SERVER_SUPPORT */
  154|       |
  155|    216|  bytes_written = coap_socket_send(sock, session, data, datalen);
  156|    216|  keep_errno = errno;
  157|    216|  if (bytes_written <= 0) {
  ------------------
  |  Branch (157:7): [True: 115, False: 101]
  ------------------
  158|    115|    coap_log_debug("*  %s: netif: failed to send % " PRIdS " bytes (%s (%d)) state %d\n",
  ------------------
  |  |  126|    115|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|    115|#define coap_log(level, ...) do { \
  |  |  |  |  291|    115|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 115]
  |  |  |  |  ------------------
  |  |  |  |  292|    115|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|    115|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 115]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  159|    115|                   coap_session_str(session), datalen,
  160|    115|                   coap_socket_strerror(), errno, session->state);
  161|    115|    errno = keep_errno;
  162|    115|  } else {
  163|    101|    coap_ticks(&session->last_rx_tx);
  164|    101|    if (bytes_written == (ssize_t)datalen)
  ------------------
  |  Branch (164:9): [True: 101, False: 0]
  ------------------
  165|    101|      coap_log_debug("*  %s: netif: sent %4" PRIdS " bytes\n",
  ------------------
  |  |  126|    101|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|    101|#define coap_log(level, ...) do { \
  |  |  |  |  291|    101|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 101]
  |  |  |  |  ------------------
  |  |  |  |  292|    101|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|    101|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 101]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  166|      0|                     coap_session_str(session), bytes_written);
  167|      0|    else
  168|    101|      coap_log_debug("*  %s: netif: sent %4" PRIdS " of %4" PRIdS " bytes\n",
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  169|    101|                     coap_session_str(session), bytes_written, datalen);
  170|    101|  }
  171|    216|#ifdef HAVE_LINUX_ERRQUEUE_H
  172|    216|  if (session->type == COAP_SESSION_TYPE_CLIENT) {
  ------------------
  |  Branch (172:7): [True: 216, False: 0]
  ------------------
  173|    216|    coap_delete_str_const(session->last_data_write);
  174|    216|    session->last_data_write = coap_new_str_const(data, datalen);
  175|    216|  }
  176|    216|#endif /* HAVE_LINUX_ERRQUEUE_H */
  177|    216|  return bytes_written;
  178|    216|}
coap_netif_dgrm_close:
  181|    143|coap_netif_dgrm_close(coap_session_t *session) {
  182|    143|  if (coap_netif_available(session))
  ------------------
  |  Branch (182:7): [True: 35, False: 108]
  ------------------
  183|     35|    coap_socket_dgrm_close(&session->sock);
  184|    143|}

coap_dtls_is_supported:
  191|     35|coap_dtls_is_supported(void) {
  192|     35|  if (SSLeay() < 0x10100000L) {
  ------------------
  |  Branch (192:7): [True: 0, False: 35]
  ------------------
  193|      0|    coap_log_warn("OpenSSL version 1.1.0 or later is required\n");
  ------------------
  |  |  108|      0|#define coap_log_warn(...) coap_log(COAP_LOG_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  194|      0|    return 0;
  195|      0|  }
  196|     35|#if OPENSSL_VERSION_NUMBER >= 0x10101000L
  197|       |  /*
  198|       |   * For 1.1.1, we need to use SSL_CTX_set_client_hello_cb()
  199|       |   * which is not in 1.1.0 instead of SSL_CTX_set_tlsext_servername_callback()
  200|       |   *
  201|       |   * However, there could be a runtime undefined external reference error
  202|       |   * as SSL_CTX_set_client_hello_cb() is not there in 1.1.0.
  203|       |   */
  204|     35|  if (SSLeay() < 0x10101000L) {
  ------------------
  |  Branch (204:7): [True: 0, False: 35]
  ------------------
  205|      0|    coap_log_warn("OpenSSL version 1.1.1 or later is required\n");
  ------------------
  |  |  108|      0|#define coap_log_warn(...) coap_log(COAP_LOG_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  206|      0|    return 0;
  207|      0|  }
  208|     35|#endif /* OPENSSL_VERSION_NUMBER >= 0x10101000L */
  209|     35|  return 1;
  210|     35|}
coap_dtls_startup:
  304|     35|coap_dtls_startup(void) {
  305|     35|  SSL_load_error_strings();
  306|     35|  SSL_library_init();
  307|     35|#if OPENSSL_VERSION_NUMBER < 0x40000000L
  308|       |  ENGINE_load_dynamic();
  309|     35|#endif /* OPENSSL_VERSION_NUMBER < 0x40000000L */
  310|     35|}
coap_dtls_shutdown:
  313|     35|coap_dtls_shutdown(void) {
  314|       |#if OPENSSL_VERSION_NUMBER < 0x30000000L
  315|       |  if (pkcs11_engine) {
  316|       |    /* Release the functional reference from ENGINE_init() */
  317|       |    ENGINE_finish(pkcs11_engine);
  318|       |    pkcs11_engine = NULL;
  319|       |  }
  320|       |  if (defined_engine) {
  321|       |    /* Release the functional reference from ENGINE_init() */
  322|       |    ENGINE_finish(defined_engine);
  323|       |    defined_engine = NULL;
  324|       |  }
  325|       |#elif OPENSSL_VERSION_NUMBER < 0x40000000L
  326|     35|  pkcs11_engine = NULL;
  327|     35|  defined_engine = NULL;
  328|     35|#endif /* OPENSSL_VERSION_NUMBER >= 0x30000000L && < 0x40000000L */
  329|       |  ERR_free_strings();
  ------------------
  |  Branch (329:3): [Folded, False: 35]
  ------------------
  330|     35|  coap_dtls_set_log_level(COAP_LOG_EMERG);
  331|     35|}
coap_dtls_set_log_level:
  590|     35|coap_dtls_set_log_level(coap_log_t level) {
  591|     35|  dtls_log_level = level;
  592|     35|}
coap_dtls_new_context:
 1164|     35|coap_dtls_new_context(coap_context_t *coap_context) {
 1165|     35|  coap_openssl_context_t *context;
 1166|     35|  (void)coap_context;
 1167|       |
 1168|     35|  context = (coap_openssl_context_t *)coap_malloc_type(COAP_STRING, sizeof(coap_openssl_context_t));
 1169|     35|  if (context) {
  ------------------
  |  Branch (1169:7): [True: 35, False: 0]
  ------------------
 1170|     35|    uint8_t cookie_secret[32];
 1171|       |
 1172|     35|    memset(context, 0, sizeof(coap_openssl_context_t));
 1173|       |
 1174|       |    /* Set up DTLS context */
 1175|     35|    context->dtls.ctx = SSL_CTX_new(DTLS_method());
 1176|     35|    if (!context->dtls.ctx)
  ------------------
  |  Branch (1176:9): [True: 0, False: 35]
  ------------------
 1177|      0|      goto error;
 1178|     35|    SSL_CTX_set_min_proto_version(context->dtls.ctx, DTLS1_2_VERSION);
 1179|     35|    SSL_CTX_set_app_data(context->dtls.ctx, &context->dtls);
 1180|     35|    SSL_CTX_set_read_ahead(context->dtls.ctx, 1);
 1181|     35|    coap_set_user_prefs(context->dtls.ctx);
 1182|     35|    memset(cookie_secret, 0, sizeof(cookie_secret));
 1183|     35|    if (!RAND_bytes(cookie_secret, (int)sizeof(cookie_secret))) {
  ------------------
  |  Branch (1183:9): [True: 0, False: 35]
  ------------------
 1184|      0|      coap_dtls_log(COAP_LOG_WARN,
  ------------------
  |  |  306|      0|#define coap_dtls_log(level, ...) do { \
  |  |  307|      0|    if ((int)((level))<=(int)coap_dtls_get_log_level()) \
  |  |  ------------------
  |  |  |  Branch (307:9): [True: 0, False: 0]
  |  |  ------------------
  |  |  308|      0|      coap_log_impl((level)+COAP_LOG_DTLS_BASE, __VA_ARGS__); \
  |  |  309|      0|  } while(0)
  |  |  ------------------
  |  |  |  Branch (309:11): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1185|      0|                    "Insufficient entropy for random cookie generation");
 1186|      0|      coap_prng_lkd(cookie_secret, sizeof(cookie_secret));
 1187|      0|    }
 1188|     35|    context->dtls.cookie_hmac = HMAC_CTX_new();
 1189|     35|    if (!context->dtls.cookie_hmac)
  ------------------
  |  Branch (1189:9): [True: 0, False: 35]
  ------------------
 1190|      0|      goto error;
 1191|     35|    if (!HMAC_Init_ex(context->dtls.cookie_hmac, cookie_secret, (int)sizeof(cookie_secret),
  ------------------
  |  Branch (1191:9): [True: 0, False: 35]
  ------------------
 1192|     35|                      EVP_sha256(), NULL))
 1193|      0|      goto error;
 1194|     35|    SSL_CTX_set_cookie_generate_cb(context->dtls.ctx, coap_dtls_generate_cookie);
 1195|     35|    SSL_CTX_set_cookie_verify_cb(context->dtls.ctx, coap_dtls_verify_cookie);
 1196|     35|    SSL_CTX_set_info_callback(context->dtls.ctx, coap_dtls_info_callback);
 1197|     35|    SSL_CTX_set_options(context->dtls.ctx, SSL_OP_NO_QUERY_MTU);
 1198|     35|#if OPENSSL_VERSION_NUMBER >= 0x30000000L
 1199|     35|    SSL_CTX_set_options(context->dtls.ctx, SSL_OP_LEGACY_SERVER_CONNECT);
 1200|     35|#endif /* OPENSSL_VERSION_NUMBER >= 0x30000000L */
 1201|     35|    context->dtls.meth = BIO_meth_new(BIO_TYPE_DGRAM, "coapdgram");
 1202|     35|    if (!context->dtls.meth)
  ------------------
  |  Branch (1202:9): [True: 0, False: 35]
  ------------------
 1203|      0|      goto error;
 1204|     35|    context->dtls.bio_addr = BIO_ADDR_new();
 1205|     35|    if (!context->dtls.bio_addr)
  ------------------
  |  Branch (1205:9): [True: 0, False: 35]
  ------------------
 1206|      0|      goto error;
 1207|     35|    BIO_meth_set_write(context->dtls.meth, coap_dgram_write);
 1208|     35|    BIO_meth_set_read(context->dtls.meth, coap_dgram_read);
 1209|     35|    BIO_meth_set_puts(context->dtls.meth, coap_dgram_puts);
 1210|     35|    BIO_meth_set_ctrl(context->dtls.meth, coap_dgram_ctrl);
 1211|     35|    BIO_meth_set_create(context->dtls.meth, coap_dgram_create);
 1212|     35|    BIO_meth_set_destroy(context->dtls.meth, coap_dgram_destroy);
 1213|       |
 1214|     35|#if !COAP_DISABLE_TCP
 1215|       |    /* Set up TLS context */
 1216|     35|    context->tls.ctx = SSL_CTX_new(TLS_method());
 1217|     35|    if (!context->tls.ctx)
  ------------------
  |  Branch (1217:9): [True: 0, False: 35]
  ------------------
 1218|      0|      goto error;
 1219|     35|    SSL_CTX_set_app_data(context->tls.ctx, &context->tls);
 1220|     35|    SSL_CTX_set_min_proto_version(context->tls.ctx, TLS1_VERSION);
 1221|     35|    coap_set_user_prefs(context->tls.ctx);
 1222|     35|    SSL_CTX_set_info_callback(context->tls.ctx, coap_dtls_info_callback);
 1223|     35|    context->tls.meth = BIO_meth_new(BIO_TYPE_SOCKET, "coapsock");
 1224|     35|    if (!context->tls.meth)
  ------------------
  |  Branch (1224:9): [True: 0, False: 35]
  ------------------
 1225|      0|      goto error;
 1226|     35|    BIO_meth_set_write(context->tls.meth, coap_sock_write);
 1227|     35|    BIO_meth_set_read(context->tls.meth, coap_sock_read);
 1228|     35|    BIO_meth_set_puts(context->tls.meth, coap_sock_puts);
 1229|     35|    BIO_meth_set_ctrl(context->tls.meth, coap_sock_ctrl);
 1230|     35|    BIO_meth_set_create(context->tls.meth, coap_sock_create);
 1231|     35|    BIO_meth_set_destroy(context->tls.meth, coap_sock_destroy);
 1232|     35|#endif /* !COAP_DISABLE_TCP */
 1233|     35|  }
 1234|       |
 1235|     35|  return context;
 1236|       |
 1237|      0|error:
 1238|      0|  coap_dtls_free_context(context);
 1239|       |  return NULL;
 1240|     35|}
coap_dtls_free_context:
 3399|     35|coap_dtls_free_context(void *handle) {
 3400|     35|  size_t i;
 3401|     35|  coap_openssl_context_t *context = (coap_openssl_context_t *)handle;
 3402|       |
 3403|     35|  if (context->dtls.ssl)
  ------------------
  |  Branch (3403:7): [True: 0, False: 35]
  ------------------
 3404|      0|    SSL_free(context->dtls.ssl);
 3405|     35|  if (context->dtls.ctx)
  ------------------
  |  Branch (3405:7): [True: 35, False: 0]
  ------------------
 3406|     35|    SSL_CTX_free(context->dtls.ctx);
 3407|     35|  if (context->dtls.cookie_hmac)
  ------------------
  |  Branch (3407:7): [True: 35, False: 0]
  ------------------
 3408|     35|    HMAC_CTX_free(context->dtls.cookie_hmac);
 3409|     35|  if (context->dtls.meth)
  ------------------
  |  Branch (3409:7): [True: 35, False: 0]
  ------------------
 3410|     35|    BIO_meth_free(context->dtls.meth);
 3411|     35|  if (context->dtls.bio_addr)
  ------------------
  |  Branch (3411:7): [True: 35, False: 0]
  ------------------
 3412|     35|    BIO_ADDR_free(context->dtls.bio_addr);
 3413|     35|#if !COAP_DISABLE_TCP
 3414|     35|  if (context->tls.ctx)
  ------------------
  |  Branch (3414:7): [True: 35, False: 0]
  ------------------
 3415|     35|    SSL_CTX_free(context->tls.ctx);
 3416|     35|  if (context->tls.meth)
  ------------------
  |  Branch (3416:7): [True: 35, False: 0]
  ------------------
 3417|     35|    BIO_meth_free(context->tls.meth);
 3418|     35|#endif /* !COAP_DISABLE_TCP */
 3419|     35|  for (i = 0; i < context->sni_count; i++) {
  ------------------
  |  Branch (3419:15): [True: 0, False: 35]
  ------------------
 3420|      0|    OPENSSL_free(context->sni_entry_list[i].sni);
 3421|       |#if OPENSSL_VERSION_NUMBER < 0x10101000L
 3422|       |    SSL_CTX_free(context->sni_entry_list[i].ctx);
 3423|       |#endif /* OPENSSL_VERSION_NUMBER < 0x10101000L */
 3424|      0|  }
 3425|     35|  if (context->sni_count)
  ------------------
  |  Branch (3425:7): [True: 0, False: 35]
  ------------------
 3426|     35|    OPENSSL_free(context->sni_entry_list);
 3427|       |#if OPENSSL_VERSION_NUMBER < 0x10101000L
 3428|       |  for (i = 0; i < context->psk_sni_count; i++) {
 3429|       |    OPENSSL_free((char *)context->psk_sni_entry_list[i].sni);
 3430|       |    SSL_CTX_free(context->psk_sni_entry_list[i].ctx);
 3431|       |  }
 3432|       |  if (context->psk_sni_count)
 3433|       |    OPENSSL_free(context->psk_sni_entry_list);
 3434|       |#endif /* OPENSSL_VERSION_NUMBER < 0x10101000L */
 3435|     35|  coap_free_type(COAP_STRING, context);
 3436|     35|}
coap_digest_setup:
 4311|    142|coap_digest_setup(void) {
 4312|    142|  EVP_MD_CTX *digest_ctx = EVP_MD_CTX_new();
 4313|       |
 4314|    142|  if (digest_ctx) {
  ------------------
  |  Branch (4314:7): [True: 142, False: 0]
  ------------------
 4315|       |    EVP_DigestInit_ex(digest_ctx, EVP_sha256(), NULL);
 4316|    142|  }
 4317|    142|  return digest_ctx;
 4318|    142|}
coap_digest_free:
 4321|    142|coap_digest_free(coap_digest_ctx_t *digest_ctx) {
 4322|    142|  if (digest_ctx)
  ------------------
  |  Branch (4322:7): [True: 142, False: 0]
  ------------------
 4323|    142|    EVP_MD_CTX_free(digest_ctx);
 4324|    142|}
coap_digest_update:
 4329|    568|                   size_t data_len) {
 4330|    568|  return EVP_DigestUpdate(digest_ctx, data, data_len);
 4331|    568|}
coap_digest_final:
 4335|    142|                  coap_digest_t *digest_buffer) {
 4336|    142|  unsigned int size = sizeof(coap_digest_t);
 4337|    142|  int ret = EVP_DigestFinal_ex(digest_ctx, (uint8_t *)digest_buffer, &size);
 4338|       |
 4339|    142|  coap_digest_free(digest_ctx);
 4340|    142|  return ret;
 4341|    142|}
coap_openssl.c:coap_set_user_prefs:
 1137|     70|coap_set_user_prefs(SSL_CTX *ctx) {
 1138|     70|  SSL_CTX_set_cipher_list(ctx, COAP_OPENSSL_CIPHERS);
  ------------------
  |  |  119|     70|#define COAP_OPENSSL_CIPHERS "TLSv1.3:TLSv1.2:!NULL"
  ------------------
 1139|       |
 1140|       |#ifdef COAP_OPENSSL_SIGALGS
 1141|       |  SSL_CTX_set1_sigalgs_list(ctx, COAP_OPENSSL_SIGALGS);
 1142|       |  SSL_CTX_set1_client_sigalgs_list(ctx, COAP_OPENSSL_SIGALGS);
 1143|       |#endif
 1144|       |
 1145|       |#if OPENSSL_VERSION_NUMBER >= 0x10101000L && defined(COAP_OPENSSL_GROUPS)
 1146|       |  SSL_CTX_set1_groups_list(ctx, COAP_OPENSSL_GROUPS);
 1147|       |#endif
 1148|     70|}

coap_opt_parse:
   41|  8.11k|coap_opt_parse(const coap_opt_t *opt, size_t length, coap_option_t *result) {
   42|       |
   43|  8.11k|  const coap_opt_t *opt_start = opt; /* store where parsing starts  */
   44|  8.11k|  uint32_t delta; /* wider than result->delta to detect overflow */
   45|       |
   46|  8.11k|  assert(opt);
  ------------------
  |  Branch (46:3): [True: 8.11k, False: 0]
  ------------------
   47|  8.11k|  assert(result);
  ------------------
  |  Branch (47:3): [True: 8.11k, False: 0]
  ------------------
   48|       |
   49|  8.11k|  if (length < 1)
  ------------------
  |  Branch (49:7): [True: 1.75k, False: 6.35k]
  ------------------
   50|  1.75k|    return 0;
   51|       |
   52|  6.35k|  result->delta = (*opt & 0xf0) >> 4;
   53|  6.35k|  result->length = *opt & 0x0f;
   54|  6.35k|  delta = result->delta;
   55|       |
   56|  6.35k|  switch (result->delta) {
   57|    276|  case 15:
  ------------------
  |  Branch (57:3): [True: 276, False: 6.08k]
  ------------------
   58|    276|    if (*opt != COAP_PAYLOAD_START) {
  ------------------
  |  |   96|    276|#define COAP_PAYLOAD_START 0xFF /* payload marker */
  ------------------
  |  Branch (58:9): [True: 0, False: 276]
  ------------------
   59|      0|      coap_log_debug("ignored reserved option delta 15\n");
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   60|      0|    }
   61|    276|    return 0;
   62|      0|  case 14:
  ------------------
  |  Branch (62:3): [True: 0, False: 6.35k]
  ------------------
   63|       |    /* Handle two-byte value: First, the MSB + 269 is stored as delta value.
   64|       |     * After that, the option pointer is advanced to the LSB which is handled
   65|       |     * just like case delta == 13. */
   66|      0|    ADVANCE_OPT_CHECK(opt,length,1);
  ------------------
  |  |   34|      0|#define ADVANCE_OPT_CHECK(o,e,step) do { \
  |  |   35|      0|    ADVANCE_OPT(o,e,step);               \
  |  |  ------------------
  |  |  |  |   22|      0|#define ADVANCE_OPT(o,e,step) if ((e) < step) {           \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (22:35): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   23|      0|    coap_log_debug("cannot advance opt past end\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |   24|      0|    return 0;                                             \
  |  |  |  |   25|      0|  } else {                                                \
  |  |  |  |   26|      0|    (e) -= step;                                          \
  |  |  |  |   27|      0|    (o) = ((o)) + step;                                   \
  |  |  |  |   28|      0|  }
  |  |  ------------------
  |  |   36|      0|    if ((e) < 1)                         \
  |  |  ------------------
  |  |  |  Branch (36:9): [True: 0, False: 0]
  |  |  ------------------
  |  |   37|      0|      return 0;                          \
  |  |   38|      0|  } while (0)
  |  |  ------------------
  |  |  |  Branch (38:12): [Folded, False: 0]
  |  |  ------------------
  ------------------
   67|      0|    delta = ((*opt & 0xff) << 8) + 269;
   68|       |  /* fall through */
   69|     64|  case 13:
  ------------------
  |  Branch (69:3): [True: 64, False: 6.29k]
  ------------------
   70|     64|    ADVANCE_OPT_CHECK(opt,length,1);
  ------------------
  |  |   34|     64|#define ADVANCE_OPT_CHECK(o,e,step) do { \
  |  |   35|     64|    ADVANCE_OPT(o,e,step);               \
  |  |  ------------------
  |  |  |  |   22|     64|#define ADVANCE_OPT(o,e,step) if ((e) < step) {           \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (22:35): [True: 0, False: 64]
  |  |  |  |  ------------------
  |  |  |  |   23|      0|    coap_log_debug("cannot advance opt past end\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |   24|      0|    return 0;                                             \
  |  |  |  |   25|     64|  } else {                                                \
  |  |  |  |   26|     64|    (e) -= step;                                          \
  |  |  |  |   27|     64|    (o) = ((o)) + step;                                   \
  |  |  |  |   28|     64|  }
  |  |  ------------------
  |  |   36|     64|    if ((e) < 1)                         \
  |  |  ------------------
  |  |  |  Branch (36:9): [True: 0, False: 64]
  |  |  ------------------
  |  |   37|     64|      return 0;                          \
  |  |   38|     64|  } while (0)
  |  |  ------------------
  |  |  |  Branch (38:12): [Folded, False: 64]
  |  |  ------------------
  ------------------
   71|     64|    delta += *opt & 0xff;
   72|     64|    if (delta > 0xffff) {
  ------------------
  |  Branch (72:9): [True: 0, False: 64]
  ------------------
   73|      0|      coap_log_debug("delta too large\n");
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   74|      0|      return 0;
   75|      0|    }
   76|     64|    result->delta = (uint16_t)delta;
   77|     64|    break;
   78|       |
   79|  6.01k|  default:
  ------------------
  |  Branch (79:3): [True: 6.01k, False: 340]
  ------------------
   80|  6.01k|    ;
   81|  6.35k|  }
   82|       |
   83|  6.08k|  switch (result->length) {
   84|      0|  case 15:
  ------------------
  |  Branch (84:3): [True: 0, False: 6.08k]
  ------------------
   85|      0|    coap_log_debug("found reserved option length 15\n");
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   86|      0|    return 0;
   87|      0|  case 14:
  ------------------
  |  Branch (87:3): [True: 0, False: 6.08k]
  ------------------
   88|       |    /* Handle two-byte value: First, the MSB + 269 is stored as delta value.
   89|       |     * After that, the option pointer is advanced to the LSB which is handled
   90|       |     * just like case delta == 13. */
   91|      0|    ADVANCE_OPT_CHECK(opt,length,1);
  ------------------
  |  |   34|      0|#define ADVANCE_OPT_CHECK(o,e,step) do { \
  |  |   35|      0|    ADVANCE_OPT(o,e,step);               \
  |  |  ------------------
  |  |  |  |   22|      0|#define ADVANCE_OPT(o,e,step) if ((e) < step) {           \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (22:35): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   23|      0|    coap_log_debug("cannot advance opt past end\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |   24|      0|    return 0;                                             \
  |  |  |  |   25|      0|  } else {                                                \
  |  |  |  |   26|      0|    (e) -= step;                                          \
  |  |  |  |   27|      0|    (o) = ((o)) + step;                                   \
  |  |  |  |   28|      0|  }
  |  |  ------------------
  |  |   36|      0|    if ((e) < 1)                         \
  |  |  ------------------
  |  |  |  Branch (36:9): [True: 0, False: 0]
  |  |  ------------------
  |  |   37|      0|      return 0;                          \
  |  |   38|      0|  } while (0)
  |  |  ------------------
  |  |  |  Branch (38:12): [Folded, False: 0]
  |  |  ------------------
  ------------------
   92|      0|    result->length = ((*opt & 0xff) << 8) + 269;
   93|       |  /* fall through */
   94|     11|  case 13:
  ------------------
  |  Branch (94:3): [True: 11, False: 6.07k]
  ------------------
   95|     11|    ADVANCE_OPT_CHECK(opt,length,1);
  ------------------
  |  |   34|     11|#define ADVANCE_OPT_CHECK(o,e,step) do { \
  |  |   35|     11|    ADVANCE_OPT(o,e,step);               \
  |  |  ------------------
  |  |  |  |   22|     11|#define ADVANCE_OPT(o,e,step) if ((e) < step) {           \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (22:35): [True: 0, False: 11]
  |  |  |  |  ------------------
  |  |  |  |   23|      0|    coap_log_debug("cannot advance opt past end\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |   24|      0|    return 0;                                             \
  |  |  |  |   25|     11|  } else {                                                \
  |  |  |  |   26|     11|    (e) -= step;                                          \
  |  |  |  |   27|     11|    (o) = ((o)) + step;                                   \
  |  |  |  |   28|     11|  }
  |  |  ------------------
  |  |   36|     11|    if ((e) < 1)                         \
  |  |  ------------------
  |  |  |  Branch (36:9): [True: 0, False: 11]
  |  |  ------------------
  |  |   37|     11|      return 0;                          \
  |  |   38|     11|  } while (0)
  |  |  ------------------
  |  |  |  Branch (38:12): [Folded, False: 11]
  |  |  ------------------
  ------------------
   96|     11|    result->length += *opt & 0xff;
   97|     11|    break;
   98|       |
   99|  6.07k|  default:
  ------------------
  |  Branch (99:3): [True: 6.07k, False: 11]
  ------------------
  100|  6.07k|    ;
  101|  6.08k|  }
  102|       |
  103|       |  /* ADVANCE_OPT() is correct here */
  104|  6.08k|  ADVANCE_OPT(opt,length,1);
  ------------------
  |  |   22|  6.08k|#define ADVANCE_OPT(o,e,step) if ((e) < step) {           \
  |  |  ------------------
  |  |  |  Branch (22:35): [True: 0, False: 6.08k]
  |  |  ------------------
  |  |   23|      0|    coap_log_debug("cannot advance opt past end\n"); \
  |  |  ------------------
  |  |  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   24|      0|    return 0;                                             \
  |  |   25|  6.08k|  } else {                                                \
  |  |   26|  6.08k|    (e) -= step;                                          \
  |  |   27|  6.08k|    (o) = ((o)) + step;                                   \
  |  |   28|  6.08k|  }
  ------------------
  105|       |  /* opt now points to value, if present */
  106|       |
  107|  6.08k|  result->value = opt;
  108|  6.08k|  if (length < result->length) {
  ------------------
  |  Branch (108:7): [True: 3, False: 6.08k]
  ------------------
  109|      3|    coap_log_debug("invalid option length\n");
  ------------------
  |  |  126|      3|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      3|#define coap_log(level, ...) do { \
  |  |  |  |  291|      3|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 3]
  |  |  |  |  ------------------
  |  |  |  |  292|      3|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      3|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 3]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  110|      3|    return 0;
  111|      3|  }
  112|       |
  113|  6.08k|#undef ADVANCE_OPT
  114|  6.08k|#undef ADVANCE_OPT_CHECK
  115|       |
  116|  6.08k|  return (opt + result->length) - opt_start;
  117|  6.08k|}
coap_option_iterator_init:
  121|  2.66k|                          const coap_opt_filter_t *filter) {
  122|  2.66k|  assert(pdu);
  ------------------
  |  Branch (122:3): [True: 2.66k, False: 0]
  ------------------
  123|  2.66k|  assert(pdu->token);
  ------------------
  |  Branch (123:3): [True: 2.66k, False: 0]
  ------------------
  124|  2.66k|  assert(oi);
  ------------------
  |  Branch (124:3): [True: 2.66k, False: 0]
  ------------------
  125|       |
  126|  2.66k|  memset(oi, 0, sizeof(coap_opt_iterator_t));
  127|       |
  128|  2.66k|  oi->next_option = pdu->token + pdu->e_token_length;
  129|  2.66k|  if (pdu->token + pdu->used_size <= oi->next_option) {
  ------------------
  |  Branch (129:7): [True: 5, False: 2.65k]
  ------------------
  130|      5|    oi->bad = 1;
  131|      5|    return NULL;
  132|      5|  }
  133|       |
  134|  2.65k|  oi->length = pdu->used_size - pdu->e_token_length;
  135|       |
  136|  2.65k|  if (filter) {
  ------------------
  |  Branch (136:7): [True: 2.29k, False: 364]
  ------------------
  137|  2.29k|    memcpy(&oi->filter, filter, sizeof(coap_opt_filter_t));
  138|  2.29k|    oi->filtered = 1;
  139|  2.29k|  }
  140|  2.65k|  return oi;
  141|  2.66k|}
coap_option_next:
  156|  3.56k|coap_option_next(coap_opt_iterator_t *oi) {
  157|  3.56k|  coap_option_t option;
  158|  3.56k|  coap_opt_t *current_opt = NULL;
  159|  3.56k|  size_t optsize;
  160|       |
  161|  3.56k|  assert(oi);
  ------------------
  |  Branch (161:3): [True: 3.56k, False: 0]
  ------------------
  162|       |
  163|  3.56k|  if (opt_finished(oi))
  ------------------
  |  Branch (163:7): [True: 546, False: 3.01k]
  ------------------
  164|    546|    return NULL;
  165|       |
  166|  6.96k|  while (1) {
  ------------------
  |  Branch (166:10): [True: 6.96k, Folded]
  ------------------
  167|       |    /* oi->next_option always points to the next option to deliver; as
  168|       |     * opt_finished() filters out any bad conditions, we can assume that
  169|       |     * oi->next_option is valid. */
  170|  6.96k|    current_opt = oi->next_option;
  171|       |
  172|       |    /*
  173|       |     * Advance internal pointer to next option.
  174|       |     * optsize will be 0 when no more options
  175|       |     */
  176|  6.96k|    optsize = coap_opt_parse(oi->next_option, oi->length, &option);
  177|  6.96k|    if (optsize) {
  ------------------
  |  Branch (177:9): [True: 4.92k, False: 2.03k]
  ------------------
  178|  4.92k|      assert(optsize <= oi->length);
  ------------------
  |  Branch (178:7): [True: 4.92k, False: 0]
  ------------------
  179|       |
  180|  4.92k|      oi->next_option += optsize;
  181|  4.92k|      oi->length -= optsize;
  182|       |
  183|  4.92k|      oi->number += option.delta;
  184|  4.92k|    } else {                        /* current option is malformed */
  185|  2.03k|      oi->bad = 1;
  186|  2.03k|      return NULL;
  187|  2.03k|    }
  188|       |
  189|       |    /* Exit the while loop when:
  190|       |     *   - no filtering is done at all
  191|       |     *   - the filter matches for the current option
  192|       |     */
  193|  4.92k|    if (!oi->filtered ||
  ------------------
  |  Branch (193:9): [True: 701, False: 4.22k]
  ------------------
  194|  4.22k|        coap_option_filter_get(&oi->filter, oi->number) > 0)
  ------------------
  |  Branch (194:9): [True: 280, False: 3.94k]
  ------------------
  195|    981|      break;
  196|  4.92k|  }
  197|       |
  198|    981|  return current_opt;
  199|  3.01k|}
coap_check_option:
  203|  1.91k|                  coap_opt_iterator_t *oi) {
  204|  1.91k|  coap_opt_filter_t f;
  205|       |
  206|  1.91k|  coap_option_filter_clear(&f);
  207|  1.91k|  coap_option_filter_set(&f, number);
  208|       |
  209|  1.91k|  coap_option_iterator_init(pdu, oi, &f);
  210|       |
  211|  1.91k|  return coap_option_next(oi);
  212|  1.91k|}
coap_opt_length:
  215|  1.61k|coap_opt_length(const coap_opt_t *opt) {
  216|  1.61k|  uint32_t length;
  217|       |
  218|  1.61k|  length = *opt & 0x0f;
  219|  1.61k|  switch (*opt & 0xf0) {
  220|      0|  case 0xf0:
  ------------------
  |  Branch (220:3): [True: 0, False: 1.61k]
  ------------------
  221|      0|    coap_log_debug("illegal option delta\n");
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  222|      0|    return 0;
  223|      0|  case 0xe0:
  ------------------
  |  Branch (223:3): [True: 0, False: 1.61k]
  ------------------
  224|      0|    ++opt;
  225|       |  /* fall through */
  226|       |  /* to skip another byte */
  227|      4|  case 0xd0:
  ------------------
  |  Branch (227:3): [True: 4, False: 1.60k]
  ------------------
  228|      4|    ++opt;
  229|       |  /* fall through */
  230|       |  /* to skip another byte */
  231|  1.61k|  default:
  ------------------
  |  Branch (231:3): [True: 1.60k, False: 4]
  ------------------
  232|  1.61k|    ++opt;
  233|  1.61k|  }
  234|       |
  235|  1.61k|  switch (length) {
  236|      0|  case 0x0f:
  ------------------
  |  Branch (236:3): [True: 0, False: 1.61k]
  ------------------
  237|      0|    coap_log_debug("illegal option length\n");
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  238|      0|    return 0;
  239|      0|  case 0x0e:
  ------------------
  |  Branch (239:3): [True: 0, False: 1.61k]
  ------------------
  240|      0|    length = (*opt++ << 8) + 269;
  241|       |  /* fall through */
  242|     10|  case 0x0d:
  ------------------
  |  Branch (242:3): [True: 10, False: 1.60k]
  ------------------
  243|     10|    length += *opt++;
  244|     10|    break;
  245|  1.60k|  default:
  ------------------
  |  Branch (245:3): [True: 1.60k, False: 10]
  ------------------
  246|  1.60k|    ;
  247|  1.61k|  }
  248|  1.61k|  return length;
  249|  1.61k|}
coap_opt_value:
  252|  1.59k|coap_opt_value(const coap_opt_t *opt) {
  253|  1.59k|  size_t ofs = 1;
  254|       |
  255|  1.59k|  switch (*opt & 0xf0) {
  256|      0|  case 0xf0:
  ------------------
  |  Branch (256:3): [True: 0, False: 1.59k]
  ------------------
  257|      0|    coap_log_debug("illegal option delta\n");
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  258|      0|    return 0;
  259|      0|  case 0xe0:
  ------------------
  |  Branch (259:3): [True: 0, False: 1.59k]
  ------------------
  260|      0|    ++ofs;
  261|       |  /* fall through */
  262|      3|  case 0xd0:
  ------------------
  |  Branch (262:3): [True: 3, False: 1.59k]
  ------------------
  263|      3|    ++ofs;
  264|      3|    break;
  265|  1.59k|  default:
  ------------------
  |  Branch (265:3): [True: 1.59k, False: 3]
  ------------------
  266|  1.59k|    ;
  267|  1.59k|  }
  268|       |
  269|  1.59k|  switch (*opt & 0x0f) {
  270|      0|  case 0x0f:
  ------------------
  |  Branch (270:3): [True: 0, False: 1.59k]
  ------------------
  271|      0|    coap_log_debug("illegal option length\n");
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  272|      0|    return 0;
  273|      0|  case 0x0e:
  ------------------
  |  Branch (273:3): [True: 0, False: 1.59k]
  ------------------
  274|      0|    ++ofs;
  275|       |  /* fall through */
  276|     10|  case 0x0d:
  ------------------
  |  Branch (276:3): [True: 10, False: 1.58k]
  ------------------
  277|     10|    ++ofs;
  278|     10|    break;
  279|  1.58k|  default:
  ------------------
  |  Branch (279:3): [True: 1.58k, False: 10]
  ------------------
  280|  1.58k|    ;
  281|  1.59k|  }
  282|       |
  283|  1.59k|  return (const uint8_t *)opt + ofs;
  284|  1.59k|}
coap_opt_setheader:
  296|    539|                   uint16_t delta, size_t length) {
  297|    539|  size_t skip = 0;
  298|       |
  299|    539|  assert(opt);
  ------------------
  |  Branch (299:3): [True: 539, False: 0]
  ------------------
  300|       |
  301|    539|  if (maxlen == 0)                /* need at least one byte */
  ------------------
  |  Branch (301:7): [True: 0, False: 539]
  ------------------
  302|      0|    return 0;
  303|       |
  304|    539|  if (delta < 13) {
  ------------------
  |  Branch (304:7): [True: 536, False: 3]
  ------------------
  305|    536|    opt[0] = (coap_opt_t)(delta << 4);
  306|    536|  } else if (delta < 269) {
  ------------------
  |  Branch (306:14): [True: 3, False: 0]
  ------------------
  307|      3|    if (maxlen < 2) {
  ------------------
  |  Branch (307:9): [True: 0, False: 3]
  ------------------
  308|      0|      coap_log_debug("insufficient space to encode option delta %d\n",
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  309|      0|                     delta);
  310|      0|      return 0;
  311|      0|    }
  312|       |
  313|      3|    opt[0] = 0xd0;
  314|      3|    opt[++skip] = (coap_opt_t)(delta - 13);
  315|      3|  } else {
  316|      0|    if (maxlen < 3) {
  ------------------
  |  Branch (316:9): [True: 0, False: 0]
  ------------------
  317|      0|      coap_log_debug("insufficient space to encode option delta %d\n",
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  318|      0|                     delta);
  319|      0|      return 0;
  320|      0|    }
  321|       |
  322|      0|    opt[0] = 0xe0;
  323|      0|    opt[++skip] = ((delta - 269) >> 8) & 0xff;
  324|      0|    opt[++skip] = (delta - 269) & 0xff;
  325|      0|  }
  326|       |
  327|    539|  if (length < 13) {
  ------------------
  |  Branch (327:7): [True: 539, False: 0]
  ------------------
  328|    539|    opt[0] |= length & 0x0f;
  329|    539|  } else if (length < 269) {
  ------------------
  |  Branch (329:14): [True: 0, False: 0]
  ------------------
  330|      0|    if (maxlen < skip + 2) {
  ------------------
  |  Branch (330:9): [True: 0, False: 0]
  ------------------
  331|      0|      coap_log_debug("insufficient space to encode option length %" PRIuS "\n",
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  332|      0|                     length);
  333|      0|      return 0;
  334|      0|    }
  335|       |
  336|      0|    opt[0] |= 0x0d;
  337|      0|    opt[++skip] = (coap_opt_t)(length - 13);
  338|      0|  } else {
  339|      0|    if (maxlen < skip + 3) {
  ------------------
  |  Branch (339:9): [True: 0, False: 0]
  ------------------
  340|      0|      coap_log_debug("insufficient space to encode option delta %d\n",
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  341|      0|                     delta);
  342|      0|      return 0;
  343|      0|    }
  344|       |
  345|      0|    opt[0] |= 0x0e;
  346|      0|    opt[++skip] = ((length - 269) >> 8) & 0xff;
  347|      0|    opt[++skip] = (length - 269) & 0xff;
  348|      0|  }
  349|       |
  350|    539|  return skip + 1;
  351|    539|}
coap_opt_encode_size:
  354|    539|coap_opt_encode_size(uint16_t delta, size_t length) {
  355|    539|  size_t n = 1;
  356|       |
  357|    539|  if (delta >= 13) {
  ------------------
  |  Branch (357:7): [True: 3, False: 536]
  ------------------
  358|      3|    if (delta < 269)
  ------------------
  |  Branch (358:9): [True: 3, False: 0]
  ------------------
  359|      3|      n += 1;
  360|      0|    else
  361|      0|      n += 2;
  362|      3|  }
  363|       |
  364|    539|  if (length >= 13) {
  ------------------
  |  Branch (364:7): [True: 0, False: 539]
  ------------------
  365|      0|    if (length < 269)
  ------------------
  |  Branch (365:9): [True: 0, False: 0]
  ------------------
  366|      0|      n += 1;
  367|      0|    else
  368|      0|      n += 2;
  369|      0|  }
  370|       |
  371|    539|  return n + length;
  372|    539|}
coap_opt_encode:
  376|    539|                const uint8_t *val, size_t length) {
  377|    539|  size_t l = 1;
  378|       |
  379|    539|  l = coap_opt_setheader(opt, maxlen, delta, length);
  380|    539|  assert(l <= maxlen);
  ------------------
  |  Branch (380:3): [True: 539, False: 0]
  ------------------
  381|       |
  382|    539|  if (!l) {
  ------------------
  |  Branch (382:7): [True: 0, False: 539]
  ------------------
  383|      0|    coap_log_debug("coap_opt_encode: cannot set option header\n");
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  384|      0|    return 0;
  385|      0|  }
  386|       |
  387|    539|  maxlen -= l;
  388|    539|  opt += l;
  389|       |
  390|    539|  if (maxlen < length) {
  ------------------
  |  Branch (390:7): [True: 0, False: 539]
  ------------------
  391|      0|    coap_log_debug("coap_opt_encode: option too large for buffer\n");
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  392|      0|    return 0;
  393|      0|  }
  394|       |
  395|    539|  if (val)                        /* better be safe here */
  ------------------
  |  Branch (395:7): [True: 539, False: 0]
  ------------------
  396|    539|    memcpy(opt, val, length);
  397|       |
  398|    539|  return l + length;
  399|    539|}
coap_option_filter_clear:
  494|  2.43k|coap_option_filter_clear(coap_opt_filter_t *filter) {
  495|  2.43k|  memset(filter, 0, sizeof(coap_opt_filter_t));
  496|  2.43k|}
coap_option_filter_set:
  499|  2.22k|coap_option_filter_set(coap_opt_filter_t *filter, coap_option_num_t option) {
  500|  2.22k|  return coap_option_filter_op(filter, option, FILTER_SET);
  501|  2.22k|}
coap_option_filter_get:
  509|  4.24k|coap_option_filter_get(coap_opt_filter_t *filter, coap_option_num_t option) {
  510|  4.24k|  return coap_option_filter_op(filter, option, FILTER_GET);
  511|  4.24k|}
coap_option.c:opt_finished:
  144|  3.56k|opt_finished(coap_opt_iterator_t *oi) {
  145|  3.56k|  assert(oi);
  ------------------
  |  Branch (145:3): [True: 3.56k, False: 0]
  ------------------
  146|       |
  147|  3.56k|  if (oi->bad || oi->length == 0 ||
  ------------------
  |  Branch (147:7): [True: 5, False: 3.55k]
  |  Branch (147:18): [True: 434, False: 3.12k]
  ------------------
  148|  3.12k|      !oi->next_option || *oi->next_option == COAP_PAYLOAD_START) {
  ------------------
  |  |   96|  3.12k|#define COAP_PAYLOAD_START 0xFF /* payload marker */
  ------------------
  |  Branch (148:7): [True: 0, False: 3.12k]
  |  Branch (148:27): [True: 107, False: 3.01k]
  ------------------
  149|    546|    oi->bad = 1;
  150|    546|  }
  151|       |
  152|  3.56k|  return oi->bad;
  153|  3.56k|}
coap_option.c:coap_option_filter_op:
  436|  6.46k|                      enum filter_op_t op) {
  437|  6.46k|  size_t lindex = 0;
  438|  6.46k|  coap_opt_filter_t *of = filter;
  439|  6.46k|  uint16_t nr, mask = 0;
  440|       |
  441|  6.46k|  if (is_long_option(number)) {
  ------------------
  |  Branch (441:7): [True: 304, False: 6.16k]
  ------------------
  442|    304|    mask = LONG_MASK;
  ------------------
  |  |  401|    304|#define LONG_MASK ((1 << COAP_OPT_FILTER_LONG) - 1)
  |  |  ------------------
  |  |  |  |  208|    304|#define COAP_OPT_FILTER_LONG  2
  |  |  ------------------
  ------------------
  443|       |
  444|    911|    for (nr = 1; lindex < COAP_OPT_FILTER_LONG; nr <<= 1, lindex++) {
  ------------------
  |  |  208|    911|#define COAP_OPT_FILTER_LONG  2
  ------------------
  |  Branch (444:18): [True: 608, False: 303]
  ------------------
  445|       |
  446|    608|      if (((of->mask & nr) > 0) && (of->long_opts[lindex] == number)) {
  ------------------
  |  Branch (446:11): [True: 2, False: 606]
  |  Branch (446:36): [True: 1, False: 1]
  ------------------
  447|      1|        if (op == FILTER_CLEAR) {
  ------------------
  |  Branch (447:13): [True: 0, False: 1]
  ------------------
  448|      0|          of->mask &= ~nr;
  449|      0|        }
  450|       |
  451|      1|        return 1;
  452|      1|      }
  453|    608|    }
  454|  6.16k|  } else {
  455|  6.16k|    mask = SHORT_MASK;
  ------------------
  |  |  403|  6.16k|  (~LONG_MASK & ((1 << (COAP_OPT_FILTER_LONG + COAP_OPT_FILTER_SHORT)) - 1))
  |  |  ------------------
  |  |  |  |  401|  6.16k|#define LONG_MASK ((1 << COAP_OPT_FILTER_LONG) - 1)
  |  |  |  |  ------------------
  |  |  |  |  |  |  208|  6.16k|#define COAP_OPT_FILTER_LONG  2
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                 (~LONG_MASK & ((1 << (COAP_OPT_FILTER_LONG + COAP_OPT_FILTER_SHORT)) - 1))
  |  |  ------------------
  |  |  |  |  208|  6.16k|#define COAP_OPT_FILTER_LONG  2
  |  |  ------------------
  |  |                 (~LONG_MASK & ((1 << (COAP_OPT_FILTER_LONG + COAP_OPT_FILTER_SHORT)) - 1))
  |  |  ------------------
  |  |  |  |  200|  6.16k|#define COAP_OPT_FILTER_SHORT 6
  |  |  ------------------
  ------------------
  456|       |
  457|  42.8k|    for (nr = 1 << COAP_OPT_FILTER_LONG; lindex < COAP_OPT_FILTER_SHORT;
  ------------------
  |  |  208|  6.16k|#define COAP_OPT_FILTER_LONG  2
  ------------------
                  for (nr = 1 << COAP_OPT_FILTER_LONG; lindex < COAP_OPT_FILTER_SHORT;
  ------------------
  |  |  200|  42.8k|#define COAP_OPT_FILTER_SHORT 6
  ------------------
  |  Branch (457:42): [True: 36.9k, False: 5.87k]
  ------------------
  458|  36.9k|         nr <<= 1, lindex++) {
  459|       |
  460|  36.9k|      if (((of->mask & nr) > 0) && (of->short_opts[lindex] == (number & 0xff))) {
  ------------------
  |  Branch (460:11): [True: 3.69k, False: 33.2k]
  |  Branch (460:36): [True: 292, False: 3.40k]
  ------------------
  461|    292|        if (op == FILTER_CLEAR) {
  ------------------
  |  Branch (461:13): [True: 0, False: 292]
  ------------------
  462|      0|          of->mask &= ~nr;
  463|      0|        }
  464|       |
  465|    292|        return 1;
  466|    292|      }
  467|  36.9k|    }
  468|  6.16k|  }
  469|       |
  470|       |  /* number was not found, so there is nothing to do if op is CLEAR or GET */
  471|  6.17k|  if ((op == FILTER_CLEAR) || (op == FILTER_GET)) {
  ------------------
  |  Branch (471:7): [True: 0, False: 6.17k]
  |  Branch (471:31): [True: 3.96k, False: 2.21k]
  ------------------
  472|  3.96k|    return 0;
  473|  3.96k|  }
  474|       |
  475|       |  /* handle FILTER_SET: */
  476|       |
  477|  2.21k|  lindex = coap_fls(~of->mask & mask);
  478|  2.21k|  if (!lindex) {
  ------------------
  |  Branch (478:7): [True: 1, False: 2.21k]
  ------------------
  479|      1|    return 0;
  480|      1|  }
  481|       |
  482|  2.21k|  if (is_long_option(number)) {
  ------------------
  |  Branch (482:7): [True: 286, False: 1.92k]
  ------------------
  483|    286|    of->long_opts[lindex - 1] = number;
  484|  1.92k|  } else {
  485|  1.92k|    of->short_opts[lindex - COAP_OPT_FILTER_LONG - 1] = (uint8_t)number;
  ------------------
  |  |  208|  1.92k|#define COAP_OPT_FILTER_LONG  2
  ------------------
  486|  1.92k|  }
  487|       |
  488|  2.21k|  of->mask |= 1 << (lindex - 1);
  489|       |
  490|  2.21k|  return 1;
  491|  2.21k|}
coap_option.c:is_long_option:
  407|  8.67k|is_long_option(coap_option_num_t number) {
  408|  8.67k|  return number > 255;
  409|  8.67k|}

coap_delete_all_oscore:
 3614|     35|coap_delete_all_oscore(coap_context_t *c_context) {
 3615|     35|  oscore_free_contexts(c_context);
 3616|     35|}
coap_delete_oscore_associations:
 3619|     35|coap_delete_oscore_associations(coap_session_t *session) {
 3620|     35|  oscore_delete_server_associations(session);
 3621|     35|}

coap_pdu_clear:
   47|    582|coap_pdu_clear(coap_pdu_t *pdu, size_t size) {
   48|    582|  assert(pdu);
  ------------------
  |  Branch (48:3): [True: 582, False: 0]
  ------------------
   49|    582|  assert(pdu->token);
  ------------------
  |  Branch (49:3): [True: 582, False: 0]
  ------------------
   50|    582|  assert(pdu->max_hdr_size >= COAP_PDU_MAX_UDP_HEADER_SIZE);
  ------------------
  |  Branch (50:3): [True: 582, False: 0]
  ------------------
   51|    582|  if (pdu->alloc_size > size)
  ------------------
  |  Branch (51:7): [True: 0, False: 582]
  ------------------
   52|      0|    pdu->alloc_size = size;
   53|    582|  pdu->type = 0;
   54|    582|  pdu->code = 0;
   55|    582|  pdu->ref = 0;
   56|    582|  pdu->hdr_size = 0;
   57|    582|  pdu->actual_token.length = 0;
   58|    582|  pdu->e_token_length = 0;
   59|    582|  pdu->crit_opt = 0;
   60|    582|  pdu->mid = 0;
   61|    582|  pdu->max_opt = 0;
   62|    582|  pdu->max_size = size;
   63|    582|  pdu->used_size = 0;
   64|    582|  pdu->data = NULL;
   65|    582|  pdu->body_data = NULL;
   66|    582|  pdu->body_length = 0;
   67|    582|  pdu->body_offset = 0;
   68|    582|  pdu->body_total = 0;
   69|    582|  pdu->lg_xmit = NULL;
   70|    582|  pdu->session = NULL;
   71|       |  pdu->data_free = NULL;
   72|    582|}
coap_pdu_init:
  105|    582|              size_t size) {
  106|    582|  coap_pdu_t *pdu;
  107|       |
  108|    582|#ifndef RIOT_VERSION
  109|    582|  assert(type <= 0x3);
  ------------------
  |  Branch (109:3): [True: 582, False: 0]
  ------------------
  110|    582|  assert(code <= 0xff);
  ------------------
  |  Branch (110:3): [True: 582, False: 0]
  ------------------
  111|    582|  assert(mid >= 0 && mid <= 0xffff);
  ------------------
  |  Branch (111:3): [True: 582, False: 0]
  |  Branch (111:3): [True: 582, False: 0]
  ------------------
  112|    582|#endif /* RIOT_VERSION */
  113|       |
  114|       |#if defined(WITH_LWIP) && MEMP_USE_CUSTOM_POOLS
  115|       |#if MEMP_STATS
  116|       |  /* Reserve 1 PDU for a response packet */
  117|       |  if (memp_pools[MEMP_COAP_PDU]->stats->used + 1 >=
  118|       |      memp_pools[MEMP_COAP_PDU]->stats->avail) {
  119|       |    memp_pools[MEMP_COAP_PDU]->stats->err++;
  120|       |    return NULL;
  121|       |  }
  122|       |#endif /* MEMP_STATS */
  123|       |#endif /* LWIP && MEMP_USE_CUSTOM_POOLS */
  124|    582|  pdu = coap_malloc_type(COAP_PDU, sizeof(coap_pdu_t));
  125|    582|  if (!pdu)
  ------------------
  |  Branch (125:7): [True: 0, False: 582]
  ------------------
  126|      0|    return NULL;
  127|       |
  128|    582|  pdu->max_hdr_size = COAP_PDU_MAX_HEADER_SIZE;
  ------------------
  |  |  115|    582|#define COAP_PDU_MAX_HEADER_SIZE COAP_PDU_MAX_TCP_HEADER_SIZE
  |  |  ------------------
  |  |  |  |  108|    582|#define COAP_PDU_MAX_TCP_HEADER_SIZE 6
  |  |  ------------------
  ------------------
  129|    582|  if (size > ((size_t)COAP_DEFAULT_MAX_PDU_RX_SIZE - pdu->max_hdr_size)) {
  ------------------
  |  |   84|    582|#define COAP_DEFAULT_MAX_PDU_RX_SIZE (8UL*1024*1024+256)
  ------------------
  |  Branch (129:7): [True: 0, False: 582]
  ------------------
  130|      0|    coap_free_type(COAP_PDU, pdu);
  131|      0|    return NULL;
  132|      0|  }
  133|       |
  134|    582|  pdu->alloc_size = min(size, COAP_DEFAULT_MTU);
  ------------------
  |  |   37|    582|#define min(a,b) ((a) < (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (37:19): [True: 582, False: 0]
  |  |  ------------------
  ------------------
  135|       |#ifdef WITH_LWIP
  136|       |  pdu->pbuf = pbuf_alloc(PBUF_TRANSPORT, pdu->alloc_size + pdu->max_hdr_size,
  137|       |                         PBUF_RAM);
  138|       |  if (pdu->pbuf == NULL) {
  139|       |    coap_free_type(COAP_PDU, pdu);
  140|       |    return NULL;
  141|       |  }
  142|       |  pdu->token = (uint8_t *)pdu->pbuf->payload + pdu->max_hdr_size;
  143|       |#else /* ! WITH_LWIP */
  144|    582|  uint8_t *buf;
  145|    582|  buf = coap_malloc_type(COAP_PDU_BUF, pdu->alloc_size + pdu->max_hdr_size);
  146|    582|  if (buf == NULL) {
  ------------------
  |  Branch (146:7): [True: 0, False: 582]
  ------------------
  147|      0|    coap_free_type(COAP_PDU, pdu);
  148|      0|    return NULL;
  149|      0|  }
  150|    582|  pdu->token = buf + pdu->max_hdr_size;
  151|    582|#endif /* ! WITH_LWIP */
  152|    582|  coap_pdu_clear(pdu, size);
  153|    582|  pdu->mid = mid;
  154|    582|  pdu->type = type;
  155|    582|  pdu->code = code;
  156|    582|  return pdu;
  157|    582|}
coap_delete_pdu:
  185|    205|coap_delete_pdu(coap_pdu_t *pdu) {
  186|    205|  coap_lock_lock(return);
  187|    205|  coap_delete_pdu_lkd(pdu);
  188|    205|  coap_lock_unlock();
  189|    205|}
coap_delete_pdu_lkd:
  192|  1.14k|coap_delete_pdu_lkd(coap_pdu_t *pdu) {
  193|  1.14k|  if (pdu != NULL) {
  ------------------
  |  Branch (193:7): [True: 880, False: 262]
  ------------------
  194|    880|    if (pdu->ref) {
  ------------------
  |  Branch (194:9): [True: 298, False: 582]
  ------------------
  195|    298|      pdu->ref--;
  196|    298|      return;
  197|    298|    }
  198|       |#ifdef WITH_LWIP
  199|       |    pbuf_free(pdu->pbuf);
  200|       |#else
  201|    582|    if (pdu->token != NULL)
  ------------------
  |  Branch (201:9): [True: 582, False: 0]
  ------------------
  202|    582|      coap_free_type(COAP_PDU_BUF, pdu->token - pdu->max_hdr_size);
  203|    582|#endif
  204|    582|    coap_delete_binary(pdu->data_free);
  205|    582|    coap_free_type(COAP_PDU, pdu);
  206|    582|  }
  207|  1.14k|}
coap_pdu_duplicate_lkd:
  237|    142|                       coap_bool_t expand_opt_abb) {
  238|    142|#if COAP_CLIENT_SUPPORT
  239|    142|  uint8_t doing_first = session->doing_first;
  240|    142|#endif /* COAP_CLIENT_SUPPORT */
  241|    142|  coap_pdu_t *pdu;
  242|       |
  243|    142|  coap_lock_check_locked();
  ------------------
  |  |  638|    142|#define coap_lock_check_locked() {}
  ------------------
  244|       |  /*
  245|       |   * Need to make sure that coap_session_max_pdu_size_lkd() immediately
  246|       |   * returns, rather than wait for the first CSM response from remote
  247|       |   * that indicates BERT size (TCP/TLS only) as this may be called early
  248|       |   * the OSCORE logic.
  249|       |   */
  250|    142|#if COAP_CLIENT_SUPPORT
  251|    142|  session->doing_first = 0;
  252|    142|#endif /* COAP_CLIENT_SUPPORT */
  253|    142|  pdu = coap_pdu_init(old_pdu->type, old_pdu->code,
  254|    142|                      coap_new_message_id_lkd(session),
  255|    142|                      old_pdu->max_size);
  256|    142|#if COAP_CLIENT_SUPPORT
  257|       |  /* Restore any pending waits */
  258|    142|  session->doing_first = doing_first;
  259|    142|#endif /* COAP_CLIENT_SUPPORT */
  260|    142|  if (pdu == NULL)
  ------------------
  |  Branch (260:7): [True: 0, False: 142]
  ------------------
  261|      0|    return NULL;
  262|       |
  263|    142|  coap_add_token(pdu, token_length, token);
  264|    142|  pdu->lg_xmit = old_pdu->lg_xmit;
  265|       |
  266|    142|  if (drop_options == NULL && expand_opt_abb == COAP_BOOL_FALSE) {
  ------------------
  |  Branch (266:7): [True: 142, False: 0]
  |  Branch (266:31): [True: 142, False: 0]
  ------------------
  267|       |    /* Drop COAP_PAYLOAD_START as well if data */
  268|    142|    size_t length = old_pdu->used_size - old_pdu->e_token_length -
  269|    142|                    (old_pdu->data ?
  ------------------
  |  Branch (269:22): [True: 0, False: 142]
  ------------------
  270|    142|                     old_pdu->used_size - (old_pdu->data - old_pdu->token) +1 : 0);
  271|    142|    if (!coap_pdu_resize(pdu, length + pdu->e_token_length))
  ------------------
  |  Branch (271:9): [True: 0, False: 142]
  ------------------
  272|      0|      goto fail;
  273|       |    /* Copy the options but not any data across */
  274|    142|    memcpy(pdu->token + pdu->e_token_length,
  275|    142|           old_pdu->token + old_pdu->e_token_length, length);
  276|    142|    pdu->used_size += length;
  277|    142|    pdu->max_opt = old_pdu->max_opt;
  278|    142|  } else {
  279|       |    /* Copy across all the options the slow way */
  280|      0|    coap_opt_iterator_t opt_iter;
  281|      0|    coap_opt_t *option;
  282|       |
  283|      0|    coap_option_iterator_init(old_pdu, &opt_iter, COAP_OPT_ALL);
  ------------------
  |  |  230|      0|#define COAP_OPT_ALL NULL
  ------------------
  284|      0|    while ((option = coap_option_next(&opt_iter))) {
  ------------------
  |  Branch (284:12): [True: 0, False: 0]
  ------------------
  285|      0|      if (opt_iter.number == COAP_OPTION_URI_PATH_ABB && expand_opt_abb == COAP_BOOL_TRUE) {
  ------------------
  |  Branch (285:11): [True: 0, False: 0]
  |  Branch (285:58): [True: 0, False: 0]
  ------------------
  286|      0|        uint32_t value;
  287|      0|        const char *exp;
  288|       |
  289|      0|        value = coap_decode_var_bytes(coap_opt_value(option),
  290|      0|                                      coap_opt_length(option));
  291|      0|        exp = coap_map_abbrev_uri_path(coap_upa_server_mapping_chain, value);
  292|      0|        if (exp) {
  ------------------
  |  Branch (292:13): [True: 0, False: 0]
  ------------------
  293|      0|          while (exp) {
  ------------------
  |  Branch (293:18): [True: 0, False: 0]
  ------------------
  294|      0|            const char *next = strchr(exp, '/');
  295|       |
  296|      0|            if (!coap_insert_option(pdu, COAP_OPTION_URI_PATH,
  ------------------
  |  Branch (296:17): [True: 0, False: 0]
  ------------------
  297|      0|                                    next ? (int)(next - exp) : (int)strlen(exp),
  ------------------
  |  Branch (297:37): [True: 0, False: 0]
  ------------------
  298|      0|                                    (const uint8_t *)exp))
  299|      0|              goto fail;
  300|      0|            if (next)
  ------------------
  |  Branch (300:17): [True: 0, False: 0]
  ------------------
  301|      0|              exp = next + 1;
  302|      0|            else
  303|      0|              exp = NULL;
  304|      0|          }
  305|      0|        } else {
  306|      0|          coap_delete_pdu_lkd(pdu);
  307|      0|          coap_log_info("coap_pdu_duplicate: Uri-Path-Abbrev value %" PRIu32 " not known for fallback\n",
  ------------------
  |  |  114|      0|#define coap_log_info(...) coap_log(COAP_LOG_INFO, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  308|      0|                        value);
  309|      0|          return NULL;
  310|      0|        }
  311|      0|      } else {
  312|      0|        if (drop_options) {
  ------------------
  |  Branch (312:13): [True: 0, False: 0]
  ------------------
  313|      0|          if (coap_option_filter_get(drop_options, opt_iter.number))
  ------------------
  |  Branch (313:15): [True: 0, False: 0]
  ------------------
  314|      0|            continue;
  315|      0|        }
  316|      0|        if (!coap_insert_option(pdu, opt_iter.number,
  ------------------
  |  Branch (316:13): [True: 0, False: 0]
  ------------------
  317|      0|                                coap_opt_length(option),
  318|      0|                                coap_opt_value(option)))
  319|      0|          goto fail;
  320|      0|      }
  321|      0|    }
  322|      0|  }
  323|    142|  return pdu;
  324|       |
  325|      0|fail:
  326|      0|  coap_delete_pdu_lkd(pdu);
  327|       |  return NULL;
  328|    142|}
coap_pdu_resize:
  335|    207|coap_pdu_resize(coap_pdu_t *pdu, size_t new_size) {
  336|    207|  if (new_size > pdu->alloc_size) {
  ------------------
  |  Branch (336:7): [True: 6, False: 201]
  ------------------
  337|       |    /* Expanding the PDU usage */
  338|      6|#if !defined(WITH_LWIP)
  339|      6|    uint8_t *new_hdr;
  340|       |#else /* WITH_LWIP */
  341|       |    struct pbuf *new_hdr;
  342|       |#endif /* WITH_LWIP */
  343|      6|    size_t offset;
  344|       |
  345|      6|    if (pdu->max_size && new_size > pdu->max_size) {
  ------------------
  |  Branch (345:9): [True: 6, False: 0]
  |  Branch (345:26): [True: 6, False: 0]
  ------------------
  346|      6|      coap_log_warn("coap_pdu_resize: pdu too big\n");
  ------------------
  |  |  108|      6|#define coap_log_warn(...) coap_log(COAP_LOG_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      6|#define coap_log(level, ...) do { \
  |  |  |  |  291|      6|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 6]
  |  |  |  |  ------------------
  |  |  |  |  292|      6|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      6|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 6]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  347|      6|      return 0;
  348|      6|    }
  349|      0|    if (pdu->data != NULL) {
  ------------------
  |  Branch (349:9): [True: 0, False: 0]
  ------------------
  350|      0|      assert(pdu->data > pdu->token);
  ------------------
  |  Branch (350:7): [True: 0, False: 0]
  ------------------
  351|      0|      offset = pdu->data - pdu->token;
  352|      0|    } else {
  353|      0|      offset = 0;
  354|      0|    }
  355|      0|#if !defined(WITH_LWIP)
  356|      0|    new_hdr = (uint8_t *)coap_realloc_type(COAP_PDU_BUF,
  357|      0|                                           pdu->token - pdu->max_hdr_size,
  358|      0|                                           new_size + pdu->max_hdr_size);
  359|       |#else /* WITH_LWIP */
  360|       |    new_hdr = pbuf_alloc(PBUF_TRANSPORT, new_size + pdu->max_hdr_size, PBUF_RAM);
  361|       |#endif /* WITH_LWIP */
  362|      0|    if (new_hdr == NULL) {
  ------------------
  |  Branch (362:9): [True: 0, False: 0]
  ------------------
  363|      0|      coap_log_warn("coap_pdu_resize: realloc failed\n");
  ------------------
  |  |  108|      0|#define coap_log_warn(...) coap_log(COAP_LOG_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  364|      0|      return 0;
  365|      0|    }
  366|      0|#if !defined(WITH_LWIP)
  367|      0|    pdu->token = new_hdr + pdu->max_hdr_size;
  368|       |#else /* WITH_LWIP */
  369|       |    memcpy(new_hdr->payload, pdu->pbuf->payload, pdu->pbuf->len);
  370|       |    pbuf_free(pdu->pbuf);
  371|       |    pdu->pbuf = new_hdr;
  372|       |    pdu->token = (uint8_t *)pdu->pbuf->payload + pdu->max_hdr_size;
  373|       |#endif /* WITH_LWIP */
  374|      0|    if (offset > 0)
  ------------------
  |  Branch (374:9): [True: 0, False: 0]
  ------------------
  375|      0|      pdu->data = pdu->token + offset;
  376|      0|    else
  377|      0|      pdu->data = NULL;
  378|      0|    if (pdu->actual_token.length < COAP_TOKEN_EXT_1B_BIAS)
  ------------------
  |  |   56|      0|#define COAP_TOKEN_EXT_1B_BIAS 13
  ------------------
  |  Branch (378:9): [True: 0, False: 0]
  ------------------
  379|      0|      pdu->actual_token.s = &pdu->token[0];
  380|      0|    else if (pdu->actual_token.length < COAP_TOKEN_EXT_2B_BIAS)
  ------------------
  |  |   57|      0|#define COAP_TOKEN_EXT_2B_BIAS 269 /* 13 + 256 */
  ------------------
  |  Branch (380:14): [True: 0, False: 0]
  ------------------
  381|      0|      pdu->actual_token.s = &pdu->token[1];
  382|      0|    else
  383|      0|      pdu->actual_token.s = &pdu->token[2];
  384|      0|    pdu->alloc_size = new_size;
  385|      0|  }
  386|    201|  return 1;
  387|    207|}
coap_pdu_check_resize:
  390|  1.00k|coap_pdu_check_resize(coap_pdu_t *pdu, size_t size) {
  391|  1.00k|  if (size > pdu->alloc_size) {
  ------------------
  |  Branch (391:7): [True: 0, False: 1.00k]
  ------------------
  392|       |#if defined WITH_LWIP || defined WITH_CONTIKI || defined RIOT_BERSION || defined __ZEPHYR__
  393|       |    size_t new_size = max(64, pdu->alloc_size * 2);
  394|       |#else /* ! WITH_LWIP && ! WITH_CONTIKI && ! RIOT_BERSION && ! __ZEPHYR__ */
  395|      0|    size_t new_size = max(256, pdu->alloc_size * 2);
  ------------------
  |  |   41|      0|#define max(a,b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (41:19): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  396|      0|#endif /* ! WITH_LWIP && ! WITH_CONTIKI && ! RIOT_BERSION && ! __ZEPHYR__ */
  397|       |
  398|      0|    while (size > new_size)
  ------------------
  |  Branch (398:12): [True: 0, False: 0]
  ------------------
  399|      0|      new_size *= 2;
  400|      0|    if (pdu->max_size && new_size > pdu->max_size) {
  ------------------
  |  Branch (400:9): [True: 0, False: 0]
  |  Branch (400:26): [True: 0, False: 0]
  ------------------
  401|      0|      new_size = pdu->max_size;
  402|      0|      if (new_size < size)
  ------------------
  |  Branch (402:11): [True: 0, False: 0]
  ------------------
  403|      0|        return 0;
  404|      0|    }
  405|      0|    if (!coap_pdu_resize(pdu, new_size))
  ------------------
  |  Branch (405:9): [True: 0, False: 0]
  ------------------
  406|      0|      return 0;
  407|      0|  }
  408|  1.00k|  return 1;
  409|  1.00k|}
coap_add_token:
  412|    462|coap_add_token(coap_pdu_t *pdu, size_t len, const uint8_t *data) {
  413|    462|  size_t bias = 0;
  414|       |
  415|       |  /* must allow for pdu == NULL as callers may rely on this */
  416|    462|  if (!pdu)
  ------------------
  |  Branch (416:7): [True: 0, False: 462]
  ------------------
  417|      0|    return 0;
  418|       |
  419|    462|  if (pdu->used_size) {
  ------------------
  |  Branch (419:7): [True: 0, False: 462]
  ------------------
  420|      0|    coap_log_warn("coap_add_token: The token must defined first. Token ignored\n");
  ------------------
  |  |  108|      0|#define coap_log_warn(...) coap_log(COAP_LOG_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  421|      0|    return 0;
  422|      0|  }
  423|    462|  pdu->actual_token.length = len;
  424|    462|  if (len < COAP_TOKEN_EXT_1B_BIAS) {
  ------------------
  |  |   56|    462|#define COAP_TOKEN_EXT_1B_BIAS 13
  ------------------
  |  Branch (424:7): [True: 462, False: 0]
  ------------------
  425|    462|    bias = 0;
  426|    462|  } else if (len < COAP_TOKEN_EXT_2B_BIAS) {
  ------------------
  |  |   57|      0|#define COAP_TOKEN_EXT_2B_BIAS 269 /* 13 + 256 */
  ------------------
  |  Branch (426:14): [True: 0, False: 0]
  ------------------
  427|      0|    bias = 1;
  428|      0|  } else if (len <= COAP_TOKEN_EXT_MAX) {
  ------------------
  |  |   60|      0|#define COAP_TOKEN_EXT_MAX 65804UL /* 13 + 256 + 65535 */
  ------------------
  |  Branch (428:14): [True: 0, False: 0]
  ------------------
  429|      0|    bias = 2;
  430|      0|  } else {
  431|      0|    coap_log_warn("coap_add_token: Token size too large. Token ignored\n");
  ------------------
  |  |  108|      0|#define coap_log_warn(...) coap_log(COAP_LOG_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  432|      0|    return 0;
  433|      0|  }
  434|    462|  if (!coap_pdu_check_resize(pdu, len + bias)) {
  ------------------
  |  Branch (434:7): [True: 0, False: 462]
  ------------------
  435|      0|    coap_log_warn("coap_add_token: Insufficient space for token. Token ignored\n");
  ------------------
  |  |  108|      0|#define coap_log_warn(...) coap_log(COAP_LOG_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  436|      0|    return 0;
  437|      0|  }
  438|       |
  439|    462|  pdu->actual_token.length = len;
  440|    462|  pdu->actual_token.s = &pdu->token[bias];
  441|    462|  pdu->e_token_length = (uint32_t)(len + bias);
  442|    462|  if (len) {
  ------------------
  |  Branch (442:7): [True: 346, False: 116]
  ------------------
  443|    346|    switch (bias) {
  444|    346|    case 0:
  ------------------
  |  Branch (444:5): [True: 346, False: 0]
  ------------------
  445|    346|      memcpy(pdu->token, data, len);
  446|    346|      break;
  447|      0|    case 1:
  ------------------
  |  Branch (447:5): [True: 0, False: 346]
  ------------------
  448|      0|      pdu->token[0] = (uint8_t)(len - COAP_TOKEN_EXT_1B_BIAS);
  ------------------
  |  |   56|      0|#define COAP_TOKEN_EXT_1B_BIAS 13
  ------------------
  449|      0|      memcpy(&pdu->token[1], data, len);
  450|      0|      break;
  451|      0|    case 2:
  ------------------
  |  Branch (451:5): [True: 0, False: 346]
  ------------------
  452|      0|      pdu->token[0] = (uint8_t)((len - COAP_TOKEN_EXT_2B_BIAS) >> 8);
  ------------------
  |  |   57|      0|#define COAP_TOKEN_EXT_2B_BIAS 269 /* 13 + 256 */
  ------------------
  453|      0|      pdu->token[1] = (uint8_t)((len - COAP_TOKEN_EXT_2B_BIAS) & 0xff);
  ------------------
  |  |   57|      0|#define COAP_TOKEN_EXT_2B_BIAS 269 /* 13 + 256 */
  ------------------
  454|      0|      memcpy(&pdu->token[2], data, len);
  455|      0|      break;
  456|      0|    default:
  ------------------
  |  Branch (456:5): [True: 0, False: 346]
  ------------------
  457|      0|      break;
  458|    346|    }
  459|    346|  }
  460|    462|  pdu->max_opt = 0;
  461|    462|  pdu->used_size = len + bias;
  462|    462|  pdu->data = NULL;
  463|       |
  464|    462|  return 1;
  465|    462|}
coap_remove_option:
  545|     21|coap_remove_option(coap_pdu_t *pdu, coap_option_num_t number) {
  546|     21|  coap_opt_iterator_t opt_iter;
  547|     21|  coap_opt_t *option;
  548|     21|  coap_opt_t *next_option = NULL;
  549|     21|  size_t opt_delta;
  550|     21|  coap_option_t decode_this;
  551|     21|  coap_option_t decode_next;
  552|       |
  553|       |  /* Need to locate where in current options to remove this one */
  554|     21|  coap_option_iterator_init(pdu, &opt_iter, COAP_OPT_ALL);
  ------------------
  |  |  230|     21|#define COAP_OPT_ALL NULL
  ------------------
  555|     21|  while ((option = coap_option_next(&opt_iter))) {
  ------------------
  |  Branch (555:10): [True: 0, False: 21]
  ------------------
  556|      0|    if (opt_iter.number == number) {
  ------------------
  |  Branch (556:9): [True: 0, False: 0]
  ------------------
  557|       |      /* Found option to delete */
  558|      0|      break;
  559|      0|    }
  560|      0|  }
  561|     21|  if (!option)
  ------------------
  |  Branch (561:7): [True: 21, False: 0]
  ------------------
  562|     21|    return 0;
  563|       |
  564|      0|  if (!coap_opt_parse(option, pdu->used_size - (option - pdu->token),
  ------------------
  |  Branch (564:7): [True: 0, False: 0]
  ------------------
  565|      0|                      &decode_this))
  566|      0|    return 0;
  567|       |
  568|      0|  next_option = coap_option_next(&opt_iter);
  569|      0|  if (next_option) {
  ------------------
  |  Branch (569:7): [True: 0, False: 0]
  ------------------
  570|      0|    if (!coap_opt_parse(next_option,
  ------------------
  |  Branch (570:9): [True: 0, False: 0]
  ------------------
  571|      0|                        pdu->used_size - (next_option - pdu->token),
  572|      0|                        &decode_next))
  573|      0|      return 0;
  574|      0|    opt_delta = decode_this.delta + decode_next.delta;
  575|      0|    if (opt_delta < 13) {
  ------------------
  |  Branch (575:9): [True: 0, False: 0]
  ------------------
  576|       |      /* can simply update the delta of next option */
  577|      0|      next_option[0] = (next_option[0] & 0x0f) + (coap_opt_t)(opt_delta << 4);
  578|      0|    } else if (opt_delta < 269 && decode_next.delta < 13) {
  ------------------
  |  Branch (578:16): [True: 0, False: 0]
  |  Branch (578:35): [True: 0, False: 0]
  ------------------
  579|       |      /* next option delta size increase */
  580|      0|      next_option -= 1;
  581|      0|      next_option[0] = (next_option[1] & 0x0f) + (13 << 4);
  582|      0|      next_option[1] = (coap_opt_t)(opt_delta - 13);
  583|      0|    } else if (opt_delta < 269) {
  ------------------
  |  Branch (583:16): [True: 0, False: 0]
  ------------------
  584|       |      /* can simply update the delta of next option */
  585|      0|      next_option[1] = (coap_opt_t)(opt_delta - 13);
  586|      0|    } else if (decode_next.delta < 13) { /* opt_delta >= 269 */
  ------------------
  |  Branch (586:16): [True: 0, False: 0]
  ------------------
  587|       |      /* next option delta size increase */
  588|      0|      if (next_option - option < 2) {
  ------------------
  |  Branch (588:11): [True: 0, False: 0]
  ------------------
  589|       |        /* Need to shuffle everything up by 1 before decrement */
  590|      0|        if (!coap_pdu_check_resize(pdu, pdu->used_size + 1))
  ------------------
  |  Branch (590:13): [True: 0, False: 0]
  ------------------
  591|      0|          return 0;
  592|       |        /* Possible a re-size took place with a realloc() */
  593|       |        /* Need to rediscover this and next options */
  594|      0|        coap_option_iterator_init(pdu, &opt_iter, COAP_OPT_ALL);
  ------------------
  |  |  230|      0|#define COAP_OPT_ALL NULL
  ------------------
  595|      0|        while ((option = coap_option_next(&opt_iter))) {
  ------------------
  |  Branch (595:16): [True: 0, False: 0]
  ------------------
  596|      0|          if (opt_iter.number == number) {
  ------------------
  |  Branch (596:15): [True: 0, False: 0]
  ------------------
  597|       |            /* Found option to delete */
  598|      0|            break;
  599|      0|          }
  600|      0|        }
  601|      0|        next_option = coap_option_next(&opt_iter);
  602|      0|        assert(option != NULL);
  ------------------
  |  Branch (602:9): [True: 0, False: 0]
  ------------------
  603|      0|        assert(next_option != NULL);
  ------------------
  |  Branch (603:9): [True: 0, False: 0]
  ------------------
  604|      0|        memmove(&next_option[1], next_option,
  605|      0|                pdu->used_size - (next_option - pdu->token));
  606|      0|        pdu->used_size++;
  607|      0|        if (pdu->data)
  ------------------
  |  Branch (607:13): [True: 0, False: 0]
  ------------------
  608|      0|          pdu->data++;
  609|      0|        next_option++;
  610|      0|      }
  611|      0|      next_option -= 2;
  612|      0|      next_option[0] = (next_option[2] & 0x0f) + (14 << 4);
  613|      0|      next_option[1] = (coap_opt_t)((opt_delta - 269) >> 8);
  614|      0|      next_option[2] = (opt_delta - 269) & 0xff;
  615|      0|    } else if (decode_next.delta < 269) { /* opt_delta >= 269 */
  ------------------
  |  Branch (615:16): [True: 0, False: 0]
  ------------------
  616|       |      /* next option delta size increase */
  617|      0|      next_option -= 1;
  618|      0|      next_option[0] = (next_option[1] & 0x0f) + (14 << 4);
  619|      0|      next_option[1] = (coap_opt_t)((opt_delta - 269) >> 8);
  620|      0|      next_option[2] = (opt_delta - 269) & 0xff;
  621|      0|    } else { /* decode_next.delta >= 269 && opt_delta >= 269 */
  622|      0|      next_option[1] = (coap_opt_t)((opt_delta - 269) >> 8);
  623|      0|      next_option[2] = (opt_delta - 269) & 0xff;
  624|      0|    }
  625|      0|  } else {
  626|      0|    next_option = option + coap_opt_encode_size(decode_this.delta,
  627|      0|                                                coap_opt_length(option));
  628|      0|    pdu->max_opt -= decode_this.delta;
  629|      0|  }
  630|      0|  if (pdu->used_size - (next_option - pdu->token))
  ------------------
  |  Branch (630:7): [True: 0, False: 0]
  ------------------
  631|      0|    memmove(option, next_option, pdu->used_size - (next_option - pdu->token));
  632|      0|  pdu->used_size -= next_option - option;
  633|      0|  if (pdu->data)
  ------------------
  |  Branch (633:7): [True: 0, False: 0]
  ------------------
  634|      0|    pdu->data -= next_option - option;
  635|      0|  return 1;
  636|      0|}
coap_option_check_repeatable:
  639|     30|coap_option_check_repeatable(coap_pdu_t *pdu, coap_option_num_t number) {
  640|       |  /* Validate that the option is repeatable */
  641|     30|  switch ((coap_code_opt_num_t)number) {
  642|      0|  case COAP_OPTION_ETAG:
  ------------------
  |  Branch (642:3): [True: 0, False: 30]
  ------------------
  643|      0|    if (!COAP_PDU_IS_REQUEST(pdu)) {
  ------------------
  |  |   99|      0|#define COAP_PDU_IS_REQUEST(pdu)   (!COAP_PDU_IS_EMPTY(pdu) && (pdu)->code < 32)
  |  |  ------------------
  |  |  |  |   98|      0|#define COAP_PDU_IS_EMPTY(pdu)     ((pdu)->code == 0)
  |  |  ------------------
  |  |  |  Branch (99:37): [True: 0, False: 0]
  |  |  |  Branch (99:64): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  644|      0|      coap_log_info("Option 'Echo' (4) cannot be repeated on a Response - dropped\n");
  ------------------
  |  |  114|      0|#define coap_log_info(...) coap_log(COAP_LOG_INFO, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  645|      0|      return 0;
  646|      0|    }
  647|      0|    break;
  648|       |  /* Ignore list of genuine repeatable */
  649|      0|  case COAP_OPTION_IF_MATCH:
  ------------------
  |  Branch (649:3): [True: 0, False: 30]
  ------------------
  650|      0|  case COAP_OPTION_LOCATION_PATH:
  ------------------
  |  Branch (650:3): [True: 0, False: 30]
  ------------------
  651|      0|  case COAP_OPTION_URI_PATH:
  ------------------
  |  Branch (651:3): [True: 0, False: 30]
  ------------------
  652|      0|  case COAP_OPTION_URI_QUERY:
  ------------------
  |  Branch (652:3): [True: 0, False: 30]
  ------------------
  653|      1|  case COAP_OPTION_LOCATION_QUERY:
  ------------------
  |  Branch (653:3): [True: 1, False: 29]
  ------------------
  654|      1|  case COAP_OPTION_Q_BLOCK2:
  ------------------
  |  Branch (654:3): [True: 0, False: 30]
  ------------------
  655|      1|  case COAP_OPTION_RTAG:
  ------------------
  |  Branch (655:3): [True: 0, False: 30]
  ------------------
  656|      1|    break;
  657|       |  /* Protest at the known non-repeatable options and ignore them */
  658|      0|  case COAP_OPTION_URI_HOST:
  ------------------
  |  Branch (658:3): [True: 0, False: 30]
  ------------------
  659|      0|  case COAP_OPTION_IF_NONE_MATCH:
  ------------------
  |  Branch (659:3): [True: 0, False: 30]
  ------------------
  660|      0|  case COAP_OPTION_OBSERVE:
  ------------------
  |  Branch (660:3): [True: 0, False: 30]
  ------------------
  661|      0|  case COAP_OPTION_URI_PORT:
  ------------------
  |  Branch (661:3): [True: 0, False: 30]
  ------------------
  662|      0|  case COAP_OPTION_OSCORE:
  ------------------
  |  Branch (662:3): [True: 0, False: 30]
  ------------------
  663|      0|  case COAP_OPTION_CONTENT_FORMAT:
  ------------------
  |  Branch (663:3): [True: 0, False: 30]
  ------------------
  664|      0|  case COAP_OPTION_URI_PATH_ABB:
  ------------------
  |  Branch (664:3): [True: 0, False: 30]
  ------------------
  665|      0|  case COAP_OPTION_MAXAGE:
  ------------------
  |  Branch (665:3): [True: 0, False: 30]
  ------------------
  666|      0|  case COAP_OPTION_HOP_LIMIT:
  ------------------
  |  Branch (666:3): [True: 0, False: 30]
  ------------------
  667|      0|  case COAP_OPTION_ACCEPT:
  ------------------
  |  Branch (667:3): [True: 0, False: 30]
  ------------------
  668|      0|  case COAP_OPTION_Q_BLOCK1:
  ------------------
  |  Branch (668:3): [True: 0, False: 30]
  ------------------
  669|      0|  case COAP_OPTION_EDHOC:
  ------------------
  |  Branch (669:3): [True: 0, False: 30]
  ------------------
  670|      0|  case COAP_OPTION_BLOCK2:
  ------------------
  |  Branch (670:3): [True: 0, False: 30]
  ------------------
  671|      0|  case COAP_OPTION_BLOCK1:
  ------------------
  |  Branch (671:3): [True: 0, False: 30]
  ------------------
  672|      0|  case COAP_OPTION_SIZE2:
  ------------------
  |  Branch (672:3): [True: 0, False: 30]
  ------------------
  673|      0|  case COAP_OPTION_PROXY_URI:
  ------------------
  |  Branch (673:3): [True: 0, False: 30]
  ------------------
  674|      0|  case COAP_OPTION_PROXY_SCHEME:
  ------------------
  |  Branch (674:3): [True: 0, False: 30]
  ------------------
  675|      0|  case COAP_OPTION_SIZE1:
  ------------------
  |  Branch (675:3): [True: 0, False: 30]
  ------------------
  676|      0|  case COAP_OPTION_ECHO:
  ------------------
  |  Branch (676:3): [True: 0, False: 30]
  ------------------
  677|      0|  case COAP_OPTION_NORESPONSE:
  ------------------
  |  Branch (677:3): [True: 0, False: 30]
  ------------------
  678|      0|    coap_log_info("Option '%s' (%d) is not defined as repeatable - dropped\n",
  ------------------
  |  |  114|      0|#define coap_log_info(...) coap_log(COAP_LOG_INFO, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  679|      0|                  coap_option_string(pdu->code, number), number);
  680|      0|    return 0;
  681|     29|  default:
  ------------------
  |  Branch (681:3): [True: 29, False: 1]
  ------------------
  682|     29|    coap_log_info("Option number %d is not defined as repeatable\n",
  ------------------
  |  |  114|     29|#define coap_log_info(...) coap_log(COAP_LOG_INFO, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|     29|#define coap_log(level, ...) do { \
  |  |  |  |  291|     29|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 29]
  |  |  |  |  ------------------
  |  |  |  |  292|     29|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|     29|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 29]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  683|     29|                  number);
  684|       |    /* Accepting it after warning as there may be user definable options */
  685|     29|    break;
  686|     30|  }
  687|     30|  return 1;
  688|     30|}
coap_insert_option:
  692|    142|                   const uint8_t *data) {
  693|    142|  coap_opt_iterator_t opt_iter;
  694|    142|  coap_opt_t *option;
  695|    142|  uint16_t prev_number = 0;
  696|    142|  size_t shift;
  697|    142|  size_t opt_delta;
  698|    142|  coap_option_t decode;
  699|    142|  size_t shrink = 0;
  700|       |
  701|    142|  if (number >= pdu->max_opt)
  ------------------
  |  Branch (701:7): [True: 142, False: 0]
  ------------------
  702|    142|    return coap_add_option_internal(pdu, number, len, data);
  703|       |
  704|      0|  if (COAP_PDU_IS_SIGNALING(pdu) ?
  ------------------
  |  |  102|      0|#define COAP_PDU_IS_SIGNALING(pdu) ((pdu)->code >= 224)
  |  |  ------------------
  |  |  |  Branch (102:36): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (704:7): [True: 0, False: 0]
  ------------------
  705|      0|      !coap_pdu_parse_opt_csm(pdu->code, number, len) :
  706|      0|      !coap_pdu_parse_opt_base(number, len, data)) {
  707|      0|    coap_log_debug("coap_insert_option: Option %u has invalid length %" PRIuS "\n", number, len);
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  708|      0|    return 0;
  709|      0|  }
  710|       |  /* Need to locate where in current options to insert this one */
  711|      0|  coap_option_iterator_init(pdu, &opt_iter, COAP_OPT_ALL);
  ------------------
  |  |  230|      0|#define COAP_OPT_ALL NULL
  ------------------
  712|      0|  while ((option = coap_option_next(&opt_iter))) {
  ------------------
  |  Branch (712:10): [True: 0, False: 0]
  ------------------
  713|      0|    if (opt_iter.number > number) {
  ------------------
  |  Branch (713:9): [True: 0, False: 0]
  ------------------
  714|       |      /* Found where to insert */
  715|      0|      break;
  716|      0|    }
  717|      0|    prev_number = opt_iter.number;
  718|      0|  }
  719|      0|  if (option == NULL) {
  ------------------
  |  Branch (719:7): [True: 0, False: 0]
  ------------------
  720|       |    /* Code is broken somewhere */
  721|      0|    coap_log_warn("coap_insert_option: Broken max_opt\n");
  ------------------
  |  |  108|      0|#define coap_log_warn(...) coap_log(COAP_LOG_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  722|      0|    return 0;
  723|      0|  }
  724|       |
  725|       |  /* size of option inc header to insert */
  726|      0|  shift = coap_opt_encode_size(number - prev_number, len);
  727|       |
  728|       |  /* size of next option (header may shrink in size as delta changes */
  729|      0|  if (!coap_opt_parse(option, pdu->used_size - (option - pdu->token), &decode))
  ------------------
  |  Branch (729:7): [True: 0, False: 0]
  ------------------
  730|      0|    return 0;
  731|      0|  opt_delta = opt_iter.number - number;
  732|      0|  if (opt_delta == 0) {
  ------------------
  |  Branch (732:7): [True: 0, False: 0]
  ------------------
  733|      0|    if (!coap_option_check_repeatable(pdu, number))
  ------------------
  |  Branch (733:9): [True: 0, False: 0]
  ------------------
  734|      0|      return 0;
  735|      0|  }
  736|       |
  737|      0|  if (!coap_pdu_check_resize(pdu,
  ------------------
  |  Branch (737:7): [True: 0, False: 0]
  ------------------
  738|      0|                             pdu->used_size + shift - shrink))
  739|      0|    return 0;
  740|       |
  741|       |  /* Possible a re-size took place with a realloc() */
  742|       |  /* Need to locate where in current options to insert this one */
  743|      0|  coap_option_iterator_init(pdu, &opt_iter, COAP_OPT_ALL);
  ------------------
  |  |  230|      0|#define COAP_OPT_ALL NULL
  ------------------
  744|      0|  while ((option = coap_option_next(&opt_iter))) {
  ------------------
  |  Branch (744:10): [True: 0, False: 0]
  ------------------
  745|      0|    if (opt_iter.number > number) {
  ------------------
  |  Branch (745:9): [True: 0, False: 0]
  ------------------
  746|       |      /* Found where to insert */
  747|      0|      break;
  748|      0|    }
  749|      0|  }
  750|      0|  assert(option != NULL);
  ------------------
  |  Branch (750:3): [True: 0, False: 0]
  ------------------
  751|       |
  752|      0|  if (decode.delta < 13) {
  ------------------
  |  Branch (752:7): [True: 0, False: 0]
  ------------------
  753|       |    /* can simply patch in the new delta of next option */
  754|      0|    option[0] = (option[0] & 0x0f) + (coap_opt_t)(opt_delta << 4);
  755|      0|  } else if (decode.delta < 269 && opt_delta < 13) {
  ------------------
  |  Branch (755:14): [True: 0, False: 0]
  |  Branch (755:36): [True: 0, False: 0]
  ------------------
  756|       |    /* option header is going to shrink by one byte */
  757|      0|    option[1] = (option[0] & 0x0f) + (coap_opt_t)(opt_delta << 4);
  758|      0|    shrink = 1;
  759|      0|  } else if (decode.delta < 269 && opt_delta < 269) {
  ------------------
  |  Branch (759:14): [True: 0, False: 0]
  |  Branch (759:36): [True: 0, False: 0]
  ------------------
  760|       |    /* can simply patch in the new delta of next option */
  761|      0|    option[1] = (coap_opt_t)(opt_delta - 13);
  762|      0|  } else if (opt_delta < 13) {
  ------------------
  |  Branch (762:14): [True: 0, False: 0]
  ------------------
  763|       |    /* option header is going to shrink by two bytes */
  764|      0|    option[2] = (option[0] & 0x0f) + (coap_opt_t)(opt_delta << 4);
  765|      0|    shrink = 2;
  766|      0|  } else if (opt_delta < 269) {
  ------------------
  |  Branch (766:14): [True: 0, False: 0]
  ------------------
  767|       |    /* option header is going to shrink by one bytes */
  768|      0|    option[1] = (option[0] & 0x0f) + 0xd0;
  769|      0|    option[2] = (coap_opt_t)(opt_delta - 13);
  770|      0|    shrink = 1;
  771|      0|  } else {
  772|       |    /* can simply patch in the new delta of next option */
  773|      0|    option[1] = (coap_opt_t)((opt_delta - 269) >> 8);
  774|      0|    option[2] = (opt_delta - 269) & 0xff;
  775|      0|  }
  776|       |
  777|      0|  memmove(&option[shift], &option[shrink],
  778|      0|          pdu->used_size - (option - pdu->token) - shrink);
  779|      0|  if (!coap_opt_encode(option, pdu->alloc_size - pdu->used_size,
  ------------------
  |  Branch (779:7): [True: 0, False: 0]
  ------------------
  780|      0|                       number - prev_number, data, len))
  781|      0|    return 0;
  782|       |
  783|      0|  if (shift >= shrink) {
  ------------------
  |  Branch (783:7): [True: 0, False: 0]
  ------------------
  784|      0|    pdu->used_size += shift - shrink;
  785|      0|    if (pdu->data)
  ------------------
  |  Branch (785:9): [True: 0, False: 0]
  ------------------
  786|      0|      pdu->data += shift - shrink;
  787|      0|  } else {
  788|      0|    pdu->used_size -= shrink - shift;
  789|      0|    if (pdu->data)
  ------------------
  |  Branch (789:9): [True: 0, False: 0]
  ------------------
  790|      0|      pdu->data -= shrink - shift;
  791|      0|  }
  792|      0|  return shift;
  793|      0|}
coap_update_option:
  797|      1|                   const uint8_t *data) {
  798|      1|  coap_opt_iterator_t opt_iter;
  799|      1|  coap_opt_t *option;
  800|      1|  coap_option_t decode;
  801|      1|  size_t new_length = 0;
  802|      1|  size_t old_length = 0;
  803|       |
  804|      1|  option = coap_check_option(pdu, number, &opt_iter);
  805|      1|  if (!option)
  ------------------
  |  Branch (805:7): [True: 0, False: 1]
  ------------------
  806|      0|    return coap_insert_option(pdu, number, len, data);
  807|       |
  808|      1|  if (COAP_PDU_IS_SIGNALING(pdu) ?
  ------------------
  |  |  102|      1|#define COAP_PDU_IS_SIGNALING(pdu) ((pdu)->code >= 224)
  |  |  ------------------
  |  |  |  Branch (102:36): [True: 0, False: 1]
  |  |  ------------------
  ------------------
  |  Branch (808:7): [True: 0, False: 1]
  ------------------
  809|      0|      !coap_pdu_parse_opt_csm(pdu->code, number, len) :
  810|      1|      !coap_pdu_parse_opt_base(number, len, data)) {
  811|      0|    coap_log_debug("coap_update_option: Option %u has invalid length %" PRIuS "\n", number, len);
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  812|      0|    return 0;
  813|      0|  }
  814|      1|  old_length = coap_opt_parse(option, (size_t)-1, &decode);
  815|      1|  if (old_length == 0)
  ------------------
  |  Branch (815:7): [True: 0, False: 1]
  ------------------
  816|      0|    return 0;
  817|      1|  new_length = coap_opt_encode_size(decode.delta, len);
  818|       |
  819|      1|  if (new_length > old_length) {
  ------------------
  |  Branch (819:7): [True: 0, False: 1]
  ------------------
  820|      0|    if (!coap_pdu_check_resize(pdu,
  ------------------
  |  Branch (820:9): [True: 0, False: 0]
  ------------------
  821|      0|                               pdu->used_size + new_length - old_length))
  822|      0|      return 0;
  823|       |    /* Possible a re-size took place with a realloc() */
  824|      0|    option = coap_check_option(pdu, number, &opt_iter);
  825|      0|  }
  826|       |
  827|      1|  if (new_length != old_length)
  ------------------
  |  Branch (827:7): [True: 0, False: 1]
  ------------------
  828|      0|    memmove(&option[new_length], &option[old_length],
  829|      0|            pdu->used_size - (option - pdu->token) - old_length);
  830|       |
  831|      1|  if (!coap_opt_encode(option, new_length,
  ------------------
  |  Branch (831:7): [True: 0, False: 1]
  ------------------
  832|      1|                       decode.delta, data, len))
  833|      0|    return 0;
  834|       |
  835|      1|  if (new_length >= old_length) {
  ------------------
  |  Branch (835:7): [True: 1, False: 0]
  ------------------
  836|      1|    pdu->used_size += new_length - old_length;
  837|      1|    if (pdu->data)
  ------------------
  |  Branch (837:9): [True: 0, False: 1]
  ------------------
  838|      0|      pdu->data += new_length - old_length;
  839|      1|  } else {
  840|      0|    pdu->used_size -= old_length - new_length;
  841|      0|    if (pdu->data)
  ------------------
  |  Branch (841:9): [True: 0, False: 0]
  ------------------
  842|      0|      pdu->data -= old_length - new_length;
  843|      0|  }
  844|      1|  return 1;
  845|      1|}
coap_add_option:
  849|    292|                const uint8_t *data) {
  850|    292|  if (pdu->data) {
  ------------------
  |  Branch (850:7): [True: 0, False: 292]
  ------------------
  851|      0|    coap_log_warn("coap_add_option: PDU already contains data\n");
  ------------------
  |  |  108|      0|#define coap_log_warn(...) coap_log(COAP_LOG_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  852|      0|    return 0;
  853|      0|  }
  854|    292|  return coap_add_option_internal(pdu, number, len, data);
  855|    292|}
coap_add_option_internal:
  859|    542|                         const uint8_t *data) {
  860|    542|  size_t optsize;
  861|    542|  coap_opt_t *opt;
  862|       |
  863|    542|  assert(pdu);
  ------------------
  |  Branch (863:3): [True: 542, False: 0]
  ------------------
  864|       |
  865|    542|  if (COAP_PDU_IS_SIGNALING(pdu) ?
  ------------------
  |  |  102|    542|#define COAP_PDU_IS_SIGNALING(pdu) ((pdu)->code >= 224)
  |  |  ------------------
  |  |  |  Branch (102:36): [True: 0, False: 542]
  |  |  ------------------
  ------------------
  |  Branch (865:7): [True: 4, False: 538]
  ------------------
  866|      0|      !coap_pdu_parse_opt_csm(pdu->code, number, len) :
  867|    542|      !coap_pdu_parse_opt_base(number, len, data)) {
  868|      4|    coap_log_debug("coap_add_option: Option %u has invalid length %" PRIuS "\n", number, len);
  ------------------
  |  |  126|      4|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      4|#define coap_log(level, ...) do { \
  |  |  |  |  291|      4|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 4]
  |  |  |  |  ------------------
  |  |  |  |  292|      4|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      4|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 4]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  869|      4|    return 0;
  870|      4|  }
  871|       |
  872|    538|  if (number == pdu->max_opt) {
  ------------------
  |  Branch (872:7): [True: 0, False: 538]
  ------------------
  873|      0|    if (!coap_option_check_repeatable(pdu, number))
  ------------------
  |  Branch (873:9): [True: 0, False: 0]
  ------------------
  874|      0|      return 0;
  875|      0|  }
  876|       |
  877|    538|  if (COAP_PDU_IS_REQUEST(pdu) &&
  ------------------
  |  |   99|  1.07k|#define COAP_PDU_IS_REQUEST(pdu)   (!COAP_PDU_IS_EMPTY(pdu) && (pdu)->code < 32)
  |  |  ------------------
  |  |  |  |   98|  1.07k|#define COAP_PDU_IS_EMPTY(pdu)     ((pdu)->code == 0)
  |  |  ------------------
  |  |  |  Branch (99:37): [True: 396, False: 142]
  |  |  |  Branch (99:64): [True: 395, False: 1]
  |  |  ------------------
  ------------------
  878|    395|      (number == COAP_OPTION_PROXY_URI ||
  ------------------
  |  Branch (878:8): [True: 0, False: 395]
  ------------------
  879|    395|       number == COAP_OPTION_PROXY_SCHEME)) {
  ------------------
  |  Branch (879:8): [True: 0, False: 395]
  ------------------
  880|       |    /*
  881|       |     * Need to check whether there is a hop-limit option.  If not, it needs
  882|       |     * to be inserted by default (RFC 8768).
  883|       |     */
  884|      0|    coap_opt_iterator_t opt_iter;
  885|       |
  886|      0|    if (coap_check_option(pdu, COAP_OPTION_HOP_LIMIT, &opt_iter) == NULL) {
  ------------------
  |  Branch (886:9): [True: 0, False: 0]
  ------------------
  887|      0|      size_t hop_limit = COAP_OPTION_HOP_LIMIT;
  888|       |
  889|      0|      coap_insert_option(pdu, COAP_OPTION_HOP_LIMIT, 1, (uint8_t *)&hop_limit);
  890|      0|    }
  891|      0|  }
  892|       |
  893|    538|  if (number < pdu->max_opt) {
  ------------------
  |  Branch (893:7): [True: 0, False: 538]
  ------------------
  894|      0|    coap_log_debug("coap_add_option: options are not in correct order\n");
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  895|      0|    return coap_insert_option(pdu, number, len, data);
  896|      0|  }
  897|       |
  898|    538|  optsize = coap_opt_encode_size(number - pdu->max_opt, len);
  899|    538|  if (!coap_pdu_check_resize(pdu,
  ------------------
  |  Branch (899:7): [True: 0, False: 538]
  ------------------
  900|    538|                             pdu->used_size + optsize))
  901|      0|    return 0;
  902|       |
  903|    538|  if (pdu->data) {
  ------------------
  |  Branch (903:7): [True: 0, False: 538]
  ------------------
  904|       |    /* include option delimiter */
  905|      0|    memmove(&pdu->data[optsize-1], &pdu->data[-1],
  906|      0|            pdu->used_size - (pdu->data - pdu->token) + 1);
  907|      0|    opt = pdu->data -1;
  908|      0|    pdu->data += optsize;
  909|    538|  } else {
  910|    538|    opt = pdu->token + pdu->used_size;
  911|    538|  }
  912|       |
  913|       |  /* encode option and check length */
  914|    538|  optsize = coap_opt_encode(opt, pdu->alloc_size - pdu->used_size,
  915|    538|                            number - pdu->max_opt, data, len);
  916|       |
  917|    538|  if (!optsize) {
  ------------------
  |  Branch (917:7): [True: 0, False: 538]
  ------------------
  918|      0|    coap_log_warn("coap_add_option: cannot add option\n");
  ------------------
  |  |  108|      0|#define coap_log_warn(...) coap_log(COAP_LOG_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  919|       |    /* error */
  920|      0|    return 0;
  921|    538|  } else {
  922|    538|    pdu->max_opt = number;
  923|    538|    pdu->used_size += optsize;
  924|    538|  }
  925|       |
  926|    538|  return optsize;
  927|    538|}
coap_add_data:
  930|     46|coap_add_data(coap_pdu_t *pdu, size_t len, const uint8_t *data) {
  931|     46|  if (len == 0) {
  ------------------
  |  Branch (931:7): [True: 0, False: 46]
  ------------------
  932|      0|    return 1;
  933|     46|  } else {
  934|     46|    uint8_t *payload = coap_add_data_after(pdu, len);
  935|     46|    if (payload != NULL)
  ------------------
  |  Branch (935:9): [True: 46, False: 0]
  ------------------
  936|     46|      memcpy(payload, data, len);
  937|       |    return payload != NULL;
  938|     46|  }
  939|     46|}
coap_add_data_after:
  942|     46|coap_add_data_after(coap_pdu_t *pdu, size_t len) {
  943|     46|  assert(pdu);
  ------------------
  |  Branch (943:3): [True: 46, False: 0]
  ------------------
  944|     46|  if (pdu->data) {
  ------------------
  |  Branch (944:7): [True: 0, False: 46]
  ------------------
  945|      0|    coap_log_warn("coap_add_data: PDU already contains data\n");
  ------------------
  |  |  108|      0|#define coap_log_warn(...) coap_log(COAP_LOG_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  946|      0|    return 0;
  947|      0|  }
  948|       |
  949|     46|  if (len == 0)
  ------------------
  |  Branch (949:7): [True: 0, False: 46]
  ------------------
  950|      0|    return NULL;
  951|       |
  952|     46|  if (!coap_pdu_resize(pdu, pdu->used_size + len + 1))
  ------------------
  |  Branch (952:7): [True: 0, False: 46]
  ------------------
  953|      0|    return 0;
  954|     46|  pdu->token[pdu->used_size++] = COAP_PAYLOAD_START;
  ------------------
  |  |   96|     46|#define COAP_PAYLOAD_START 0xFF /* payload marker */
  ------------------
  955|     46|  pdu->data = pdu->token + pdu->used_size;
  956|     46|  pdu->used_size += len;
  957|     46|  return pdu->data;
  958|     46|}
coap_get_data:
  961|    142|coap_get_data(const coap_pdu_t *pdu, size_t *len, const uint8_t **data) {
  962|    142|  size_t offset;
  963|    142|  size_t total;
  964|       |
  965|    142|  return coap_get_data_large(pdu, len, data, &offset, &total);
  966|    142|}
coap_get_data_large:
  970|    142|                    size_t *offset, size_t *total) {
  971|    142|  assert(pdu);
  ------------------
  |  Branch (971:3): [True: 142, False: 0]
  ------------------
  972|    142|  assert(len);
  ------------------
  |  Branch (972:3): [True: 142, False: 0]
  ------------------
  973|    142|  assert(data);
  ------------------
  |  Branch (973:3): [True: 142, False: 0]
  ------------------
  974|       |
  975|    142|  *offset = pdu->body_offset;
  976|    142|  *total = pdu->body_total;
  977|    142|  if (pdu->body_data) {
  ------------------
  |  Branch (977:7): [True: 0, False: 142]
  ------------------
  978|      0|    *data = pdu->body_data;
  979|      0|    *len = pdu->body_length;
  980|      0|    return 1;
  981|      0|  }
  982|    142|  *data = pdu->data;
  983|    142|  if (pdu->data == NULL) {
  ------------------
  |  Branch (983:7): [True: 142, False: 0]
  ------------------
  984|    142|    *len = 0;
  985|    142|    *total = 0;
  986|    142|    return 0;
  987|    142|  }
  988|       |
  989|      0|  *len = pdu->used_size - (pdu->data - pdu->token);
  990|      0|  if (*total == 0)
  ------------------
  |  Branch (990:7): [True: 0, False: 0]
  ------------------
  991|      0|    *total = *len;
  992|       |
  993|      0|  return 1;
  994|    142|}
coap_response_phrase:
 1036|     23|coap_response_phrase(unsigned char code) {
 1037|     23|  int i;
 1038|    266|  for (i = 0; coap_error[i].code; ++i) {
  ------------------
  |  Branch (1038:15): [True: 266, False: 0]
  ------------------
 1039|    266|    if (coap_error[i].code == code)
  ------------------
  |  Branch (1039:9): [True: 23, False: 243]
  ------------------
 1040|     23|      return coap_error[i].phrase;
 1041|    266|  }
 1042|      0|  return NULL;
 1043|     23|}
coap_pdu_parse_header_size:
 1077|     19|                           const uint8_t *data) {
 1078|     19|  assert(data);
  ------------------
  |  Branch (1078:3): [True: 19, False: 0]
  ------------------
 1079|     19|  size_t header_size = 0;
 1080|       |
 1081|     19|  if (proto == COAP_PROTO_TCP || proto==COAP_PROTO_TLS) {
  ------------------
  |  Branch (1081:7): [True: 0, False: 19]
  |  Branch (1081:34): [True: 0, False: 19]
  ------------------
 1082|      0|    uint8_t len = *data >> 4;
 1083|      0|    if (len < 13)
  ------------------
  |  Branch (1083:9): [True: 0, False: 0]
  ------------------
 1084|      0|      header_size = 2;
 1085|      0|    else if (len==13)
  ------------------
  |  Branch (1085:14): [True: 0, False: 0]
  ------------------
 1086|      0|      header_size = 3;
 1087|      0|    else if (len==14)
  ------------------
  |  Branch (1087:14): [True: 0, False: 0]
  ------------------
 1088|      0|      header_size = 4;
 1089|      0|    else
 1090|      0|      header_size = 6;
 1091|     19|  } else if (proto == COAP_PROTO_WS || proto==COAP_PROTO_WSS) {
  ------------------
  |  Branch (1091:14): [True: 0, False: 19]
  |  Branch (1091:40): [True: 0, False: 19]
  ------------------
 1092|      0|    header_size = COAP_PDU_WS_HEADER_SIZE;
  ------------------
  |  |  109|      0|#define COAP_PDU_WS_HEADER_SIZE 2
  ------------------
 1093|     19|  } else if (proto == COAP_PROTO_UDP || proto==COAP_PROTO_DTLS) {
  ------------------
  |  Branch (1093:14): [True: 19, False: 0]
  |  Branch (1093:41): [True: 0, False: 0]
  ------------------
 1094|     19|    header_size = 4;
 1095|     19|  }
 1096|       |
 1097|     19|  return header_size;
 1098|     19|}
coap_pdu_parse_header:
 1173|     13|coap_pdu_parse_header(coap_pdu_t *pdu, coap_proto_t proto) {
 1174|     13|  uint8_t *hdr = pdu->token - pdu->hdr_size;
 1175|     13|  uint8_t e_token_length;
 1176|       |
 1177|     13|  if (proto == COAP_PROTO_UDP || proto == COAP_PROTO_DTLS) {
  ------------------
  |  Branch (1177:7): [True: 13, False: 0]
  |  Branch (1177:34): [True: 0, False: 0]
  ------------------
 1178|     13|    assert(pdu->hdr_size == 4);
  ------------------
  |  Branch (1178:5): [True: 13, False: 0]
  ------------------
 1179|     13|    if ((hdr[0] >> 6) != COAP_DEFAULT_VERSION) {
  ------------------
  |  |   35|     13|#define COAP_DEFAULT_VERSION      1 /* version of CoAP supported */
  ------------------
  |  Branch (1179:9): [True: 0, False: 13]
  ------------------
 1180|      0|      coap_log_debug("coap_pdu_parse: UDP version not supported\n");
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1181|      0|      return 0;
 1182|      0|    }
 1183|     13|    pdu->type = (hdr[0] >> 4) & 0x03;
 1184|     13|    pdu->code = hdr[1];
 1185|     13|    pdu->mid = (uint16_t)hdr[2] << 8 | hdr[3];
 1186|     13|  } else if (proto == COAP_PROTO_TCP || proto == COAP_PROTO_TLS) {
  ------------------
  |  Branch (1186:14): [True: 0, False: 0]
  |  Branch (1186:41): [True: 0, False: 0]
  ------------------
 1187|      0|    assert(pdu->hdr_size >= 2 && pdu->hdr_size <= 6);
  ------------------
  |  Branch (1187:5): [True: 0, False: 0]
  |  Branch (1187:5): [True: 0, False: 0]
  ------------------
 1188|      0|    pdu->type = COAP_MESSAGE_CON;
 1189|      0|    pdu->code = hdr[pdu->hdr_size-1];
 1190|      0|    pdu->mid = 0;
 1191|      0|  } else if (proto == COAP_PROTO_WS || proto == COAP_PROTO_WSS) {
  ------------------
  |  Branch (1191:14): [True: 0, False: 0]
  |  Branch (1191:40): [True: 0, False: 0]
  ------------------
 1192|      0|    assert(pdu->hdr_size == 2);
  ------------------
  |  Branch (1192:5): [True: 0, False: 0]
  ------------------
 1193|      0|    pdu->type = COAP_MESSAGE_CON;
 1194|      0|    pdu->code = hdr[pdu->hdr_size-1];
 1195|      0|    pdu->mid = 0;
 1196|      0|  } else {
 1197|      0|    coap_log_debug("coap_pdu_parse: unsupported protocol\n");
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1198|      0|    return 0;
 1199|      0|  }
 1200|       |
 1201|     13|  e_token_length = hdr[0] & 0x0f;
 1202|     13|  if (e_token_length < COAP_TOKEN_EXT_1B_TKL) {
  ------------------
  |  |   54|     13|#define COAP_TOKEN_EXT_1B_TKL 13
  ------------------
  |  Branch (1202:7): [True: 13, False: 0]
  ------------------
 1203|     13|    pdu->e_token_length = e_token_length;
 1204|     13|    pdu->actual_token.length = pdu->e_token_length;
 1205|     13|    pdu->actual_token.s = &pdu->token[0];
 1206|     13|  } else if (e_token_length == COAP_TOKEN_EXT_1B_TKL) {
  ------------------
  |  |   54|      0|#define COAP_TOKEN_EXT_1B_TKL 13
  ------------------
  |  Branch (1206:14): [True: 0, False: 0]
  ------------------
 1207|      0|    if (pdu->used_size < 1)
  ------------------
  |  Branch (1207:9): [True: 0, False: 0]
  ------------------
 1208|      0|      goto bad_ext_token;
 1209|      0|    pdu->e_token_length = pdu->token[0] + COAP_TOKEN_EXT_1B_BIAS + 1;
  ------------------
  |  |   56|      0|#define COAP_TOKEN_EXT_1B_BIAS 13
  ------------------
 1210|      0|    pdu->actual_token.length = pdu->e_token_length - 1;
 1211|      0|    pdu->actual_token.s = &pdu->token[1];
 1212|      0|  } else if (e_token_length == COAP_TOKEN_EXT_2B_TKL) {
  ------------------
  |  |   55|      0|#define COAP_TOKEN_EXT_2B_TKL 14
  ------------------
  |  Branch (1212:14): [True: 0, False: 0]
  ------------------
 1213|      0|    if (pdu->used_size < 2)
  ------------------
  |  Branch (1213:9): [True: 0, False: 0]
  ------------------
 1214|      0|      goto bad_ext_token;
 1215|      0|    pdu->e_token_length = ((uint16_t)pdu->token[0] << 8) + pdu->token[1] +
 1216|      0|                          COAP_TOKEN_EXT_2B_BIAS + 2;
  ------------------
  |  |   57|      0|#define COAP_TOKEN_EXT_2B_BIAS 269 /* 13 + 256 */
  ------------------
 1217|      0|    pdu->actual_token.length = pdu->e_token_length - 2;
 1218|      0|    pdu->actual_token.s = &pdu->token[2];
 1219|      0|  }
 1220|     13|  if (pdu->e_token_length > pdu->alloc_size || e_token_length == 15) {
  ------------------
  |  Branch (1220:7): [True: 0, False: 13]
  |  Branch (1220:48): [True: 0, False: 13]
  ------------------
 1221|      0|    goto bad_ext_token;
 1222|      0|  }
 1223|     13|  return 1;
 1224|       |
 1225|      0|bad_ext_token:
 1226|       |  /* Invalid PDU provided - not wise to assert here though */
 1227|      0|  coap_log_warn("coap_pdu_parse: PDU header extended token size broken\n");
  ------------------
  |  |  108|      0|#define coap_log_warn(...) coap_log(COAP_LOG_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1228|      0|  pdu->e_token_length = 0;
 1229|      0|  pdu->actual_token.length = 0;
 1230|      0|  return 0;
 1231|     13|}
coap_pdu_parse_opt_base:
 1302|  1.69k|coap_pdu_parse_opt_base(coap_option_num_t number, size_t len, const uint8_t *opt_val) {
 1303|  1.69k|  int res = 1;
 1304|       |
 1305|  1.69k|  switch ((coap_code_opt_num_t)number) {
 1306|      0|  case COAP_OPTION_IF_MATCH:
  ------------------
  |  Branch (1306:3): [True: 0, False: 1.69k]
  ------------------
 1307|      0|    if (len > 8)
  ------------------
  |  Branch (1307:9): [True: 0, False: 0]
  ------------------
 1308|      0|      res = 0;
 1309|      0|    break;
 1310|      3|  case COAP_OPTION_URI_HOST:
  ------------------
  |  Branch (1310:3): [True: 3, False: 1.69k]
  ------------------
 1311|      3|    if (len < 1 || len > 255)
  ------------------
  |  Branch (1311:9): [True: 0, False: 3]
  |  Branch (1311:20): [True: 0, False: 3]
  ------------------
 1312|      0|      res = 0;
 1313|      3|    break;
 1314|      1|  case COAP_OPTION_ETAG:
  ------------------
  |  Branch (1314:3): [True: 1, False: 1.69k]
  ------------------
 1315|      1|    if (len < 1 || len > 8)
  ------------------
  |  Branch (1315:9): [True: 0, False: 1]
  |  Branch (1315:20): [True: 0, False: 1]
  ------------------
 1316|      0|      res = 0;
 1317|      1|    break;
 1318|      0|  case COAP_OPTION_IF_NONE_MATCH:
  ------------------
  |  Branch (1318:3): [True: 0, False: 1.69k]
  ------------------
 1319|      0|    if (len != 0)
  ------------------
  |  Branch (1319:9): [True: 0, False: 0]
  ------------------
 1320|      0|      res = 0;
 1321|      0|    break;
 1322|    319|  case COAP_OPTION_OBSERVE:
  ------------------
  |  Branch (1322:3): [True: 319, False: 1.37k]
  ------------------
 1323|    319|    if (len > 3)
  ------------------
  |  Branch (1323:9): [True: 0, False: 319]
  ------------------
 1324|      0|      res = 0;
 1325|    319|    break;
 1326|     75|  case COAP_OPTION_URI_PORT:
  ------------------
  |  Branch (1326:3): [True: 75, False: 1.62k]
  ------------------
 1327|     75|    if (len > 2)
  ------------------
  |  Branch (1327:9): [True: 0, False: 75]
  ------------------
 1328|      0|      res = 0;
 1329|     75|    break;
 1330|     37|  case COAP_OPTION_LOCATION_PATH:
  ------------------
  |  Branch (1330:3): [True: 37, False: 1.65k]
  ------------------
 1331|    263|  case COAP_OPTION_URI_PATH:
  ------------------
  |  Branch (1331:3): [True: 226, False: 1.46k]
  ------------------
 1332|    263|    if (len > 255)
  ------------------
  |  Branch (1332:9): [True: 0, False: 263]
  ------------------
 1333|      0|      res = 0;
 1334|    263|    if (coap_check_dots(opt_val, len)) {
  ------------------
  |  Branch (1334:9): [True: 0, False: 263]
  ------------------
 1335|      0|      res = 0;
 1336|      0|    }
 1337|    263|    break;
 1338|     36|  case COAP_OPTION_OSCORE:
  ------------------
  |  Branch (1338:3): [True: 36, False: 1.65k]
  ------------------
 1339|     36|    if (len > 255)
  ------------------
  |  Branch (1339:9): [True: 0, False: 36]
  ------------------
 1340|      0|      res = 0;
 1341|     36|    break;
 1342|      9|  case COAP_OPTION_CONTENT_FORMAT:
  ------------------
  |  Branch (1342:3): [True: 9, False: 1.68k]
  ------------------
 1343|      9|    if (len > 2)
  ------------------
  |  Branch (1343:9): [True: 0, False: 9]
  ------------------
 1344|      0|      res = 0;
 1345|      9|    break;
 1346|     64|  case COAP_OPTION_URI_PATH_ABB:
  ------------------
  |  Branch (1346:3): [True: 64, False: 1.63k]
  ------------------
 1347|     64|    if (len > 4)
  ------------------
  |  Branch (1347:9): [True: 0, False: 64]
  ------------------
 1348|      0|      res = 0;
 1349|     64|    break;
 1350|     25|  case COAP_OPTION_MAXAGE:
  ------------------
  |  Branch (1350:3): [True: 25, False: 1.67k]
  ------------------
 1351|     25|    if (len > 4)
  ------------------
  |  Branch (1351:9): [True: 9, False: 16]
  ------------------
 1352|      9|      res = 0;
 1353|     25|    break;
 1354|      2|  case COAP_OPTION_URI_QUERY:
  ------------------
  |  Branch (1354:3): [True: 2, False: 1.69k]
  ------------------
 1355|      2|    if (len > 255)
  ------------------
  |  Branch (1355:9): [True: 0, False: 2]
  ------------------
 1356|      0|      res = 0;
 1357|      2|    break;
 1358|      3|  case COAP_OPTION_HOP_LIMIT:
  ------------------
  |  Branch (1358:3): [True: 3, False: 1.69k]
  ------------------
 1359|      3|    if (len != 1)
  ------------------
  |  Branch (1359:9): [True: 3, False: 0]
  ------------------
 1360|      3|      res = 0;
 1361|      3|    break;
 1362|    184|  case COAP_OPTION_ACCEPT:
  ------------------
  |  Branch (1362:3): [True: 184, False: 1.51k]
  ------------------
 1363|    184|    if (len > 2)
  ------------------
  |  Branch (1363:9): [True: 9, False: 175]
  ------------------
 1364|      9|      res = 0;
 1365|    184|    break;
 1366|    231|  case COAP_OPTION_Q_BLOCK1:
  ------------------
  |  Branch (1366:3): [True: 231, False: 1.46k]
  ------------------
 1367|    231|    if (len > 3)
  ------------------
  |  Branch (1367:9): [True: 3, False: 228]
  ------------------
 1368|      3|      res = 0;
 1369|    231|    break;
 1370|      2|  case COAP_OPTION_LOCATION_QUERY:
  ------------------
  |  Branch (1370:3): [True: 2, False: 1.69k]
  ------------------
 1371|      2|    if (len > 255)
  ------------------
  |  Branch (1371:9): [True: 0, False: 2]
  ------------------
 1372|      0|      res = 0;
 1373|      2|    break;
 1374|     18|  case COAP_OPTION_EDHOC:
  ------------------
  |  Branch (1374:3): [True: 18, False: 1.67k]
  ------------------
 1375|     18|    if (len != 0)
  ------------------
  |  Branch (1375:9): [True: 3, False: 15]
  ------------------
 1376|      3|      res = 0;
 1377|     18|    break;
 1378|     25|  case COAP_OPTION_BLOCK2:
  ------------------
  |  Branch (1378:3): [True: 25, False: 1.67k]
  ------------------
 1379|     25|    if (len > 3)
  ------------------
  |  Branch (1379:9): [True: 4, False: 21]
  ------------------
 1380|      4|      res = 0;
 1381|     25|    break;
 1382|    142|  case COAP_OPTION_BLOCK1:
  ------------------
  |  Branch (1382:3): [True: 142, False: 1.55k]
  ------------------
 1383|    142|    if (len > 3)
  ------------------
  |  Branch (1383:9): [True: 3, False: 139]
  ------------------
 1384|      3|      res = 0;
 1385|    142|    break;
 1386|     54|  case COAP_OPTION_SIZE2:
  ------------------
  |  Branch (1386:3): [True: 54, False: 1.64k]
  ------------------
 1387|     54|    if (len > 4)
  ------------------
  |  Branch (1387:9): [True: 0, False: 54]
  ------------------
 1388|      0|      res = 0;
 1389|     54|    break;
 1390|      0|  case COAP_OPTION_Q_BLOCK2:
  ------------------
  |  Branch (1390:3): [True: 0, False: 1.69k]
  ------------------
 1391|      0|    if (len > 3)
  ------------------
  |  Branch (1391:9): [True: 0, False: 0]
  ------------------
 1392|      0|      res = 0;
 1393|      0|    break;
 1394|     12|  case COAP_OPTION_PROXY_URI:
  ------------------
  |  Branch (1394:3): [True: 12, False: 1.68k]
  ------------------
 1395|     12|    if (len < 1 || len > 1034)
  ------------------
  |  Branch (1395:9): [True: 9, False: 3]
  |  Branch (1395:20): [True: 0, False: 3]
  ------------------
 1396|      9|      res = 0;
 1397|     12|    break;
 1398|      3|  case COAP_OPTION_PROXY_SCHEME:
  ------------------
  |  Branch (1398:3): [True: 3, False: 1.69k]
  ------------------
 1399|      3|    if (len < 1 || len > 255)
  ------------------
  |  Branch (1399:9): [True: 0, False: 3]
  |  Branch (1399:20): [True: 0, False: 3]
  ------------------
 1400|      0|      res = 0;
 1401|      3|    break;
 1402|      1|  case COAP_OPTION_SIZE1:
  ------------------
  |  Branch (1402:3): [True: 1, False: 1.69k]
  ------------------
 1403|      1|    if (len > 4)
  ------------------
  |  Branch (1403:9): [True: 0, False: 1]
  ------------------
 1404|      0|      res = 0;
 1405|      1|    break;
 1406|      0|  case COAP_OPTION_ECHO:
  ------------------
  |  Branch (1406:3): [True: 0, False: 1.69k]
  ------------------
 1407|      0|    if (len > 40)
  ------------------
  |  Branch (1407:9): [True: 0, False: 0]
  ------------------
 1408|      0|      res = 0;
 1409|      0|    break;
 1410|      1|  case COAP_OPTION_NORESPONSE:
  ------------------
  |  Branch (1410:3): [True: 1, False: 1.69k]
  ------------------
 1411|      1|    if (len > 1)
  ------------------
  |  Branch (1411:9): [True: 0, False: 1]
  ------------------
 1412|      0|      res = 0;
 1413|      1|    break;
 1414|      0|  case COAP_OPTION_RTAG:
  ------------------
  |  Branch (1414:3): [True: 0, False: 1.69k]
  ------------------
 1415|      0|    if (len > 8)
  ------------------
  |  Branch (1415:9): [True: 0, False: 0]
  ------------------
 1416|      0|      res = 0;
 1417|      0|    break;
 1418|    222|  default:
  ------------------
  |  Branch (1418:3): [True: 222, False: 1.47k]
  ------------------
 1419|    222|    ;
 1420|  1.69k|  }
 1421|  1.69k|  return res;
 1422|  1.69k|}
coap_pdu_parse_opt:
 1458|     13|coap_pdu_parse_opt(coap_pdu_t *pdu, coap_opt_filter_t *error_opts) {
 1459|     13|  int good = 1;
 1460|       |
 1461|     13|  coap_option_filter_clear(error_opts);
 1462|       |
 1463|       |  /* sanity checks */
 1464|     13|  if (pdu->code == 0) {
  ------------------
  |  Branch (1464:7): [True: 1, False: 12]
  ------------------
 1465|      1|    if (pdu->used_size != 0 || pdu->e_token_length) {
  ------------------
  |  Branch (1465:9): [True: 0, False: 1]
  |  Branch (1465:32): [True: 1, False: 0]
  ------------------
 1466|      1|      coap_log_debug("coap_pdu_parse: empty message is not empty\n");
  ------------------
  |  |  126|      1|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      1|#define coap_log(level, ...) do { \
  |  |  |  |  291|      1|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  292|      1|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      1|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1467|      1|      return 0;
 1468|      1|    }
 1469|      1|  }
 1470|       |
 1471|     12|  if (pdu->e_token_length > pdu->used_size) {
  ------------------
  |  Branch (1471:7): [True: 0, False: 12]
  ------------------
 1472|      0|    coap_log_debug("coap_pdu_parse: invalid Token\n");
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1473|      0|    return 0;
 1474|      0|  }
 1475|       |
 1476|     12|  pdu->max_opt = 0;
 1477|     12|  if (pdu->code == 0) {
  ------------------
  |  Branch (1477:7): [True: 0, False: 12]
  ------------------
 1478|       |    /* empty packet */
 1479|      0|    pdu->used_size = 0;
 1480|      0|    pdu->data = NULL;
 1481|     12|  } else {
 1482|       |    /* skip header + token */
 1483|     12|    coap_opt_t *opt = pdu->token + pdu->e_token_length;
 1484|     12|    size_t length = pdu->used_size - pdu->e_token_length;
 1485|       |
 1486|    468|    while (length > 0 && *opt != COAP_PAYLOAD_START) {
  ------------------
  |  |   96|    460|#define COAP_PAYLOAD_START 0xFF /* payload marker */
  ------------------
  |  Branch (1486:12): [True: 460, False: 8]
  |  Branch (1486:26): [True: 457, False: 3]
  ------------------
 1487|    457|#if (COAP_MAX_LOGGING_LEVEL >= _COAP_LOG_WARN)
 1488|    457|      coap_opt_t *opt_last = opt;
 1489|    457|#endif
 1490|    457|      size_t optsize = next_option_safe(&opt, &length, &pdu->max_opt);
 1491|    457|      uint32_t len;
 1492|    457|      const uint8_t *opt_val;
 1493|       |
 1494|    457|      if (optsize == 0) {
  ------------------
  |  Branch (1494:11): [True: 1, False: 456]
  ------------------
 1495|      1|        coap_log_debug("coap_pdu_parse: %d.%02d: offset %u malformed option\n",
  ------------------
  |  |  126|      1|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      1|#define coap_log(level, ...) do { \
  |  |  |  |  291|      1|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  292|      1|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      1|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1496|      1|                       pdu->code >> 5, pdu->code & 0x1F,
 1497|      1|                       (int)(opt_last - pdu->token - pdu->e_token_length));
 1498|      1|        coap_option_filter_set(error_opts, pdu->max_opt);
 1499|      1|        good = 0;
 1500|      1|        break;
 1501|      1|      }
 1502|    456|      len = coap_opt_length((const uint8_t *)opt - optsize);
 1503|    456|      opt_val = coap_opt_value((const uint8_t *)opt - optsize);
 1504|    456|      if (COAP_PDU_IS_SIGNALING(pdu) ?
  ------------------
  |  |  102|    456|#define COAP_PDU_IS_SIGNALING(pdu) ((pdu)->code >= 224)
  |  |  ------------------
  |  |  |  Branch (102:36): [True: 0, False: 456]
  |  |  ------------------
  ------------------
  |  Branch (1504:11): [True: 13, False: 443]
  ------------------
 1505|      0|          !coap_pdu_parse_opt_csm(pdu->code, pdu->max_opt, len) :
 1506|    456|          !coap_pdu_parse_opt_base(pdu->max_opt, len, opt_val)) {
 1507|     13|        coap_log_warn("coap_pdu_parse: %d.%02d: offset %u option %u has bad length %" PRIu32 " or value\n",
  ------------------
  |  |  108|     13|#define coap_log_warn(...) coap_log(COAP_LOG_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|     13|#define coap_log(level, ...) do { \
  |  |  |  |  291|     13|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 13]
  |  |  |  |  ------------------
  |  |  |  |  292|     13|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|     13|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 13]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1508|     13|                      pdu->code >> 5, pdu->code & 0x1F,
 1509|     13|                      (int)(opt_last - pdu->token - pdu->e_token_length), pdu->max_opt,
 1510|     13|                      len);
 1511|     13|        coap_option_filter_set(error_opts, pdu->max_opt);
 1512|     13|        good = 0;
 1513|     13|      }
 1514|    456|    }
 1515|       |
 1516|     12|    if (!good) {
  ------------------
  |  Branch (1516:9): [True: 7, False: 5]
  ------------------
 1517|       |      /*
 1518|       |       * Dump the options in the PDU for analysis, space separated except
 1519|       |       * error options which are prefixed by *
 1520|       |       * Two rows - hex and ascii (if printable)
 1521|       |       */
 1522|      7|      static char outbuf[COAP_DEBUG_BUF_SIZE];
 1523|      7|      char *obp;
 1524|      7|      size_t tlen;
 1525|      7|      size_t outbuflen;
 1526|      7|      int i;
 1527|      7|      int ok;
 1528|       |
 1529|     21|      for (i = 0; i < 2; i++) {
  ------------------
  |  Branch (1529:19): [True: 14, False: 7]
  ------------------
 1530|     14|        opt = pdu->token + pdu->e_token_length;
 1531|     14|        length = pdu->used_size - pdu->e_token_length;
 1532|     14|        pdu->max_opt = 0;
 1533|       |
 1534|     14|        outbuflen = sizeof(outbuf);
 1535|     14|        obp = outbuf;
 1536|     14|        ok = write_prefix(&obp, &outbuflen, "O: ", 3);
 1537|       |        /*
 1538|       |         * Not safe to check for 'ok' here as a lot of variables may get
 1539|       |         * partially changed due to lack of outbuflen */
 1540|    712|        while (length > 0 && *opt != COAP_PAYLOAD_START) {
  ------------------
  |  |   96|    700|#define COAP_PAYLOAD_START 0xFF /* payload marker */
  ------------------
  |  Branch (1540:16): [True: 700, False: 12]
  |  Branch (1540:30): [True: 698, False: 2]
  ------------------
 1541|    698|          coap_opt_t *opt_last = opt;
 1542|    698|          size_t optsize = next_option_safe(&opt, &length, &pdu->max_opt);
 1543|    698|          const uint32_t len =
 1544|    698|              optsize ? coap_opt_length((const uint8_t *)opt - optsize) : 0;
  ------------------
  |  Branch (1544:15): [True: 696, False: 2]
  ------------------
 1545|    698|          const uint8_t *opt_val =
 1546|    698|              optsize ?  coap_opt_value((const uint8_t *)opt - optsize) : 0;
  ------------------
  |  Branch (1546:15): [True: 696, False: 2]
  ------------------
 1547|       |
 1548|    698|          if (!optsize || (COAP_PDU_IS_SIGNALING(pdu) ?
  ------------------
  |  |  102|    696|#define COAP_PDU_IS_SIGNALING(pdu) ((pdu)->code >= 224)
  |  |  ------------------
  |  |  |  Branch (102:36): [True: 0, False: 696]
  |  |  ------------------
  ------------------
  |  Branch (1548:15): [True: 2, False: 696]
  |  Branch (1548:27): [True: 26, False: 670]
  ------------------
 1549|      0|                           !coap_pdu_parse_opt_csm(pdu->code, pdu->max_opt, len) :
 1550|    696|                           !coap_pdu_parse_opt_base(pdu->max_opt, len, opt_val))) {
 1551|     28|            ok = ok && write_prefix(&obp, &outbuflen, "*", 1);
  ------------------
  |  Branch (1551:18): [True: 28, False: 0]
  |  Branch (1551:24): [True: 28, False: 0]
  ------------------
 1552|     28|            if (!optsize) {
  ------------------
  |  Branch (1552:17): [True: 2, False: 26]
  ------------------
 1553|       |              /* Skip to end of options to output all data */
 1554|      2|              opt = pdu->token + pdu->used_size;
 1555|      2|              length = 0;
 1556|      2|            }
 1557|    670|          } else {
 1558|    670|            ok = ok && write_prefix(&obp, &outbuflen, " ", 1);
  ------------------
  |  Branch (1558:18): [True: 670, False: 0]
  |  Branch (1558:24): [True: 670, False: 0]
  ------------------
 1559|    670|          }
 1560|    698|          tlen = opt - opt_last;
 1561|  1.96k|          while (tlen) {
  ------------------
  |  Branch (1561:18): [True: 1.26k, False: 698]
  ------------------
 1562|  1.26k|            tlen--;
 1563|  1.26k|            ok = ok && write_char(&obp, &outbuflen, *opt_last, i);
  ------------------
  |  Branch (1563:18): [True: 1.26k, False: 0]
  |  Branch (1563:24): [True: 1.26k, False: 0]
  ------------------
 1564|  1.26k|            opt_last++;
 1565|  1.26k|          }
 1566|    698|        }
 1567|     14|        if (length && *opt == COAP_PAYLOAD_START) {
  ------------------
  |  |   96|      2|#define COAP_PAYLOAD_START 0xFF /* payload marker */
  ------------------
  |  Branch (1567:13): [True: 2, False: 12]
  |  Branch (1567:23): [True: 2, False: 0]
  ------------------
 1568|      2|          write_char(&obp, &outbuflen, *opt, i);
 1569|      2|        }
 1570|       |        /* write_*() always leaves a spare byte to null terminate */
 1571|     14|        *obp = '\000';
 1572|     14|        coap_log_debug("%s\n", outbuf);
  ------------------
  |  |  126|     14|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|     14|#define coap_log(level, ...) do { \
  |  |  |  |  291|     14|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 14]
  |  |  |  |  ------------------
  |  |  |  |  292|     14|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|     14|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 14]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1573|     14|      }
 1574|      7|    }
 1575|       |
 1576|     12|    if (length > 0) {
  ------------------
  |  Branch (1576:9): [True: 3, False: 9]
  ------------------
 1577|      3|      assert(*opt == COAP_PAYLOAD_START);
  ------------------
  |  Branch (1577:7): [True: 3, False: 0]
  ------------------
 1578|      3|      opt++;
 1579|      3|      length--;
 1580|       |
 1581|      3|      if (length == 0) {
  ------------------
  |  Branch (1581:11): [True: 0, False: 3]
  ------------------
 1582|      0|        coap_log_debug("coap_pdu_parse: message ending in payload start marker\n");
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1583|      0|        return 0;
 1584|      0|      }
 1585|      3|    }
 1586|     12|    if (length > 0)
  ------------------
  |  Branch (1586:9): [True: 3, False: 9]
  ------------------
 1587|      3|      pdu->data = (uint8_t *)opt;
 1588|      9|    else
 1589|      9|      pdu->data = NULL;
 1590|     12|  }
 1591|       |
 1592|     12|  return good;
 1593|     12|}
coap_pdu_parse2:
 1610|     19|                coap_opt_filter_t *error_opts) {
 1611|     19|  size_t hdr_size;
 1612|       |
 1613|     19|  if (length == 0)
  ------------------
  |  Branch (1613:7): [True: 0, False: 19]
  ------------------
 1614|      0|    return 0;
 1615|     19|  hdr_size = coap_pdu_parse_header_size(proto, data);
 1616|     19|  if (!hdr_size || hdr_size > length)
  ------------------
  |  Branch (1616:7): [True: 0, False: 19]
  |  Branch (1616:20): [True: 0, False: 19]
  ------------------
 1617|      0|    return 0;
 1618|     19|  if (hdr_size > pdu->max_hdr_size)
  ------------------
  |  Branch (1618:7): [True: 0, False: 19]
  ------------------
 1619|      0|    return 0;
 1620|     19|  if (!coap_pdu_resize(pdu, length - hdr_size))
  ------------------
  |  Branch (1620:7): [True: 6, False: 13]
  ------------------
 1621|      6|    return 0;
 1622|     13|  if (pdu->token - hdr_size != data)
  ------------------
  |  Branch (1622:7): [True: 13, False: 0]
  ------------------
 1623|     13|    memcpy(pdu->token - hdr_size, data, length);
 1624|     13|  pdu->hdr_size = (uint8_t)hdr_size;
 1625|     13|  pdu->used_size = length - hdr_size;
 1626|     13|  return coap_pdu_parse_header(pdu, proto) && coap_pdu_parse_opt(pdu, error_opts);
  ------------------
  |  Branch (1626:10): [True: 13, False: 0]
  |  Branch (1626:47): [True: 5, False: 8]
  ------------------
 1627|     19|}
coap_pdu_encode_header:
 1630|    216|coap_pdu_encode_header(coap_pdu_t *pdu, coap_proto_t proto) {
 1631|    216|  uint8_t e_token_length;
 1632|       |
 1633|    216|  if (pdu->actual_token.length < COAP_TOKEN_EXT_1B_BIAS) {
  ------------------
  |  |   56|    216|#define COAP_TOKEN_EXT_1B_BIAS 13
  ------------------
  |  Branch (1633:7): [True: 216, False: 0]
  ------------------
 1634|    216|    e_token_length = (uint8_t)pdu->actual_token.length;
 1635|    216|  } else if (pdu->actual_token.length < COAP_TOKEN_EXT_2B_BIAS) {
  ------------------
  |  |   57|      0|#define COAP_TOKEN_EXT_2B_BIAS 269 /* 13 + 256 */
  ------------------
  |  Branch (1635:14): [True: 0, False: 0]
  ------------------
 1636|      0|    e_token_length = COAP_TOKEN_EXT_1B_TKL;
  ------------------
  |  |   54|      0|#define COAP_TOKEN_EXT_1B_TKL 13
  ------------------
 1637|      0|  } else if (pdu->actual_token.length <= COAP_TOKEN_EXT_MAX) {
  ------------------
  |  |   60|      0|#define COAP_TOKEN_EXT_MAX 65804UL /* 13 + 256 + 65535 */
  ------------------
  |  Branch (1637:14): [True: 0, False: 0]
  ------------------
 1638|      0|    e_token_length = COAP_TOKEN_EXT_2B_TKL;
  ------------------
  |  |   55|      0|#define COAP_TOKEN_EXT_2B_TKL 14
  ------------------
 1639|      0|  } else {
 1640|      0|    coap_log_warn("coap_pdu_encode_header: Token size too large. PDU ignored\n");
  ------------------
  |  |  108|      0|#define coap_log_warn(...) coap_log(COAP_LOG_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1641|      0|    return 0;
 1642|      0|  }
 1643|    216|  if (COAP_PROTO_NOT_RELIABLE(proto)) {
  ------------------
  |  |   41|    216|#define COAP_PROTO_NOT_RELIABLE(p) ((p)==COAP_PROTO_UDP || (p)==COAP_PROTO_DTLS)
  |  |  ------------------
  |  |  |  Branch (41:37): [True: 216, False: 0]
  |  |  |  Branch (41:60): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1644|    216|    assert(pdu->max_hdr_size >= 4);
  ------------------
  |  Branch (1644:5): [True: 216, False: 0]
  ------------------
 1645|    216|    if (pdu->max_hdr_size < 4) {
  ------------------
  |  Branch (1645:9): [True: 0, False: 216]
  ------------------
 1646|      0|      coap_log_warn("coap_pdu_encode_header: not enough space for UDP-style header\n");
  ------------------
  |  |  108|      0|#define coap_log_warn(...) coap_log(COAP_LOG_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1647|      0|      return 0;
 1648|      0|    }
 1649|    216|    pdu->token[-4] = COAP_DEFAULT_VERSION << 6
  ------------------
  |  |   35|    216|#define COAP_DEFAULT_VERSION      1 /* version of CoAP supported */
  ------------------
 1650|    216|                     | pdu->type << 4
 1651|    216|                     | e_token_length;
 1652|    216|    pdu->token[-3] = pdu->code;
 1653|    216|    pdu->token[-2] = (uint8_t)(pdu->mid >> 8);
 1654|    216|    pdu->token[-1] = (uint8_t)(pdu->mid);
 1655|    216|    pdu->hdr_size = 4;
 1656|    216|#if !COAP_DISABLE_TCP
 1657|    216|  } else if (COAP_PROTO_RELIABLE(proto)) {
  ------------------
  |  |   42|      0|#define COAP_PROTO_RELIABLE(p) ((p)==COAP_PROTO_TCP || (p)==COAP_PROTO_TLS || \
  |  |  ------------------
  |  |  |  Branch (42:33): [True: 0, False: 0]
  |  |  |  Branch (42:56): [True: 0, False: 0]
  |  |  ------------------
  |  |   43|      0|                                (p)==COAP_PROTO_WS || (p)==COAP_PROTO_WSS)
  |  |  ------------------
  |  |  |  Branch (43:33): [True: 0, False: 0]
  |  |  |  Branch (43:55): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1658|      0|    size_t len;
 1659|      0|    assert(pdu->used_size >= pdu->e_token_length);
  ------------------
  |  Branch (1659:5): [True: 0, False: 0]
  ------------------
 1660|      0|    if (pdu->used_size < pdu->e_token_length) {
  ------------------
  |  Branch (1660:9): [True: 0, False: 0]
  ------------------
 1661|      0|      coap_log_warn("coap_pdu_encode_header: corrupted PDU\n");
  ------------------
  |  |  108|      0|#define coap_log_warn(...) coap_log(COAP_LOG_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1662|      0|      return 0;
 1663|      0|    }
 1664|       |
 1665|       |    /* A lot of the reliable code assumes type is CON */
 1666|      0|    if (pdu->type != COAP_MESSAGE_CON)
  ------------------
  |  Branch (1666:9): [True: 0, False: 0]
  ------------------
 1667|      0|      pdu->type = COAP_MESSAGE_CON;
 1668|       |
 1669|      0|    if (proto == COAP_PROTO_WS || proto == COAP_PROTO_WSS)
  ------------------
  |  Branch (1669:9): [True: 0, False: 0]
  |  Branch (1669:35): [True: 0, False: 0]
  ------------------
 1670|      0|      len = 0;
 1671|      0|    else
 1672|      0|      len = pdu->used_size - pdu->e_token_length;
 1673|      0|    if (len <= COAP_MAX_MESSAGE_SIZE_TCP0) {
  ------------------
  |  |   43|      0|#define COAP_MAX_MESSAGE_SIZE_TCP0 (COAP_MESSAGE_SIZE_OFFSET_TCP8-1) /* 12 */
  |  |  ------------------
  |  |  |  |   38|      0|#define COAP_MESSAGE_SIZE_OFFSET_TCP8 13
  |  |  ------------------
  ------------------
  |  Branch (1673:9): [True: 0, False: 0]
  ------------------
 1674|      0|      assert(pdu->max_hdr_size >= 2);
  ------------------
  |  Branch (1674:7): [True: 0, False: 0]
  ------------------
 1675|      0|      if (pdu->max_hdr_size < 2) {
  ------------------
  |  Branch (1675:11): [True: 0, False: 0]
  ------------------
 1676|      0|        coap_log_warn("coap_pdu_encode_header: not enough space for TCP0 header\n");
  ------------------
  |  |  108|      0|#define coap_log_warn(...) coap_log(COAP_LOG_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1677|      0|        return 0;
 1678|      0|      }
 1679|      0|      pdu->token[-2] = (uint8_t)len << 4
 1680|      0|                       | e_token_length;
 1681|      0|      pdu->token[-1] = pdu->code;
 1682|      0|      pdu->hdr_size = 2;
 1683|      0|    } else if (len <= COAP_MAX_MESSAGE_SIZE_TCP8) {
  ------------------
  |  |   44|      0|#define COAP_MAX_MESSAGE_SIZE_TCP8 (COAP_MESSAGE_SIZE_OFFSET_TCP16-1) /* 268 */
  |  |  ------------------
  |  |  |  |   39|      0|#define COAP_MESSAGE_SIZE_OFFSET_TCP16 269 /* 13 + 256 */
  |  |  ------------------
  ------------------
  |  Branch (1683:16): [True: 0, False: 0]
  ------------------
 1684|      0|      assert(pdu->max_hdr_size >= 3);
  ------------------
  |  Branch (1684:7): [True: 0, False: 0]
  ------------------
 1685|      0|      if (pdu->max_hdr_size < 3) {
  ------------------
  |  Branch (1685:11): [True: 0, False: 0]
  ------------------
 1686|      0|        coap_log_warn("coap_pdu_encode_header: not enough space for TCP8 header\n");
  ------------------
  |  |  108|      0|#define coap_log_warn(...) coap_log(COAP_LOG_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1687|      0|        return 0;
 1688|      0|      }
 1689|      0|      pdu->token[-3] = 13 << 4 | e_token_length;
 1690|      0|      pdu->token[-2] = (uint8_t)(len - COAP_MESSAGE_SIZE_OFFSET_TCP8);
  ------------------
  |  |   38|      0|#define COAP_MESSAGE_SIZE_OFFSET_TCP8 13
  ------------------
 1691|      0|      pdu->token[-1] = pdu->code;
 1692|      0|      pdu->hdr_size = 3;
 1693|      0|    } else if (len <= COAP_MAX_MESSAGE_SIZE_TCP16) {
  ------------------
  |  |   45|      0|#define COAP_MAX_MESSAGE_SIZE_TCP16 (COAP_MESSAGE_SIZE_OFFSET_TCP32-1) /* 65804 */
  |  |  ------------------
  |  |  |  |   40|      0|#define COAP_MESSAGE_SIZE_OFFSET_TCP32 65805 /* 269 + 65536 */
  |  |  ------------------
  ------------------
  |  Branch (1693:16): [True: 0, False: 0]
  ------------------
 1694|      0|      assert(pdu->max_hdr_size >= 4);
  ------------------
  |  Branch (1694:7): [True: 0, False: 0]
  ------------------
 1695|      0|      if (pdu->max_hdr_size < 4) {
  ------------------
  |  Branch (1695:11): [True: 0, False: 0]
  ------------------
 1696|      0|        coap_log_warn("coap_pdu_encode_header: not enough space for TCP16 header\n");
  ------------------
  |  |  108|      0|#define coap_log_warn(...) coap_log(COAP_LOG_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1697|      0|        return 0;
 1698|      0|      }
 1699|      0|      pdu->token[-4] = 14 << 4 | e_token_length;
 1700|      0|      pdu->token[-3] = (uint8_t)((len - COAP_MESSAGE_SIZE_OFFSET_TCP16) >> 8);
  ------------------
  |  |   39|      0|#define COAP_MESSAGE_SIZE_OFFSET_TCP16 269 /* 13 + 256 */
  ------------------
 1701|      0|      pdu->token[-2] = (uint8_t)(len - COAP_MESSAGE_SIZE_OFFSET_TCP16);
  ------------------
  |  |   39|      0|#define COAP_MESSAGE_SIZE_OFFSET_TCP16 269 /* 13 + 256 */
  ------------------
 1702|      0|      pdu->token[-1] = pdu->code;
 1703|      0|      pdu->hdr_size = 4;
 1704|      0|    } else {
 1705|      0|      assert(pdu->max_hdr_size >= 6);
  ------------------
  |  Branch (1705:7): [True: 0, False: 0]
  ------------------
 1706|      0|      if (pdu->max_hdr_size < 6) {
  ------------------
  |  Branch (1706:11): [True: 0, False: 0]
  ------------------
 1707|      0|        coap_log_warn("coap_pdu_encode_header: not enough space for TCP32 header\n");
  ------------------
  |  |  108|      0|#define coap_log_warn(...) coap_log(COAP_LOG_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1708|      0|        return 0;
 1709|      0|      }
 1710|      0|      pdu->token[-6] = 15 << 4 | e_token_length;
 1711|      0|      pdu->token[-5] = (uint8_t)((len - COAP_MESSAGE_SIZE_OFFSET_TCP32) >> 24);
  ------------------
  |  |   40|      0|#define COAP_MESSAGE_SIZE_OFFSET_TCP32 65805 /* 269 + 65536 */
  ------------------
 1712|      0|      pdu->token[-4] = (uint8_t)((len - COAP_MESSAGE_SIZE_OFFSET_TCP32) >> 16);
  ------------------
  |  |   40|      0|#define COAP_MESSAGE_SIZE_OFFSET_TCP32 65805 /* 269 + 65536 */
  ------------------
 1713|      0|      pdu->token[-3] = (uint8_t)((len - COAP_MESSAGE_SIZE_OFFSET_TCP32) >> 8);
  ------------------
  |  |   40|      0|#define COAP_MESSAGE_SIZE_OFFSET_TCP32 65805 /* 269 + 65536 */
  ------------------
 1714|      0|      pdu->token[-2] = (uint8_t)(len - COAP_MESSAGE_SIZE_OFFSET_TCP32);
  ------------------
  |  |   40|      0|#define COAP_MESSAGE_SIZE_OFFSET_TCP32 65805 /* 269 + 65536 */
  ------------------
 1715|      0|      pdu->token[-1] = pdu->code;
 1716|      0|      pdu->hdr_size = 6;
 1717|      0|    }
 1718|      0|#endif /* ! COAP_DISABLE_TCP */
 1719|      0|  } else {
 1720|      0|    coap_log_warn("coap_pdu_encode_header: unsupported protocol\n");
  ------------------
  |  |  108|      0|#define coap_log_warn(...) coap_log(COAP_LOG_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1721|      0|  }
 1722|    216|  return pdu->hdr_size;
 1723|    216|}
coap_pdu_reference_lkd:
 1768|    298|coap_pdu_reference_lkd(coap_pdu_t *pdu) {
 1769|    298|  if (pdu != NULL) {
  ------------------
  |  Branch (1769:7): [True: 298, False: 0]
  ------------------
 1770|    298|    ++pdu->ref;
 1771|    298|  }
 1772|    298|  return pdu;
 1773|    298|}
coap_pdu.c:next_option_safe:
 1052|  1.15k|next_option_safe(coap_opt_t **optp, size_t *length, uint16_t *max_opt) {
 1053|  1.15k|  coap_option_t option;
 1054|  1.15k|  size_t optsize;
 1055|       |
 1056|  1.15k|  assert(optp);
  ------------------
  |  Branch (1056:3): [True: 1.15k, False: 0]
  ------------------
 1057|  1.15k|  assert(*optp);
  ------------------
  |  Branch (1057:3): [True: 1.15k, False: 0]
  ------------------
 1058|  1.15k|  assert(length);
  ------------------
  |  Branch (1058:3): [True: 1.15k, False: 0]
  ------------------
 1059|       |
 1060|  1.15k|  optsize = coap_opt_parse(*optp, *length, &option);
 1061|  1.15k|  assert(optsize <= *length);
  ------------------
  |  Branch (1061:3): [True: 1.15k, False: 0]
  ------------------
 1062|       |
 1063|       |  /* signal an error if this option would exceed the
 1064|       |   * allowed number space */
 1065|  1.15k|  if ((uint32_t)(*max_opt) + option.delta > COAP_MAX_OPT) {
  ------------------
  |  |  105|  1.15k|#define COAP_MAX_OPT 65535 /**< the highest option number we know */
  ------------------
  |  Branch (1065:7): [True: 0, False: 1.15k]
  ------------------
 1066|      0|    return 0;
 1067|      0|  }
 1068|  1.15k|  *max_opt += option.delta;
 1069|  1.15k|  *optp += optsize;
 1070|  1.15k|  *length -= optsize;
 1071|       |
 1072|  1.15k|  return optsize;
 1073|  1.15k|}
coap_pdu.c:write_prefix:
 1425|    712|write_prefix(char **obp, size_t *len, const char *prf, size_t prflen) {
 1426|       |  /* Make sure space for null terminating byte */
 1427|    712|  if (*len < prflen +1) {
  ------------------
  |  Branch (1427:7): [True: 0, False: 712]
  ------------------
 1428|      0|    return 0;
 1429|      0|  }
 1430|       |
 1431|    712|  memcpy(*obp, prf, prflen);
 1432|    712|  *obp += prflen;
 1433|    712|  *len -= prflen;
 1434|    712|  return 1;
 1435|    712|}
coap_pdu.c:write_char:
 1438|  1.26k|write_char(char **obp, size_t *len, int c, int printable) {
 1439|       |  /* Make sure space for null terminating byte */
 1440|  1.26k|  if (*len < 2 +1) {
  ------------------
  |  Branch (1440:7): [True: 0, False: 1.26k]
  ------------------
 1441|      0|    return 0;
 1442|      0|  }
 1443|       |
 1444|  1.26k|  if (!printable) {
  ------------------
  |  Branch (1444:7): [True: 632, False: 632]
  ------------------
 1445|    632|    const uint8_t hex[] = "0123456789abcdef";
 1446|    632|    (*obp)[0] = hex[(c & 0xf0) >> 4];
 1447|    632|    (*obp)[1] = hex[c & 0x0f];
 1448|    632|  } else {
 1449|    632|    (*obp)[0] = isprint(c) ? c : '.';
  ------------------
  |  Branch (1449:17): [True: 78, False: 554]
  ------------------
 1450|    632|    (*obp)[1] = ' ';
 1451|    632|  }
 1452|  1.26k|  *obp += 2;
 1453|  1.26k|  *len -= 2;
 1454|  1.26k|  return 1;
 1455|  1.26k|}

coap_prng_init_lkd:
  186|     35|coap_prng_init_lkd(unsigned int seed) {
  187|     35|#ifdef HAVE_GETRANDOM
  188|       |  /* No seed to seed the random source if getrandom() is used */
  189|     35|  (void)seed;
  190|       |#elif defined(HAVE_RANDOM)
  191|       |  srandom(seed);
  192|       |#else /* !HAVE_GETRANDOM  && !HAVE_RANDOM */
  193|       |  srand(seed);
  194|       |#endif /* !HAVE_GETRANDOM */
  195|     35|}
coap_prng_lkd:
  198|    436|coap_prng_lkd(void *buf, size_t len) {
  199|    436|  if (!rand_func) {
  ------------------
  |  Branch (199:7): [True: 0, False: 436]
  ------------------
  200|      0|    return 0;
  201|      0|  }
  202|       |
  203|    436|  return rand_func(buf, len);
  204|    436|}
coap_prng.c:coap_prng_default:
  111|    436|coap_prng_default(void *buf, size_t len) {
  112|       |#if defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
  113|       |  /* mbedtls_hardware_poll() returns 0 on success */
  114|       |  return (mbedtls_hardware_poll(NULL, buf, len, NULL) ? 0 : 1);
  115|       |
  116|       |#elif defined(__ZEPHYR__)
  117|       |  /* Use Zephyr's cryptographically secure random number generator */
  118|       |  if (!buf || len == 0) {
  119|       |    return 0;
  120|       |  }
  121|       |
  122|       |  /* sys_csrand_get() returns 0 on success */
  123|       |  return (sys_csrand_get(buf, len) ? 0 : 1);
  124|       |
  125|       |#elif defined(HAVE_GETRANDOM)
  126|    436|  return (getrandom(buf, len, 0) > 0) ? 1 : 0;
  ------------------
  |  Branch (126:10): [True: 436, False: 0]
  ------------------
  127|       |
  128|       |#elif defined(HAVE_GETENTROPY)
  129|       |  return (getentropy(buf, len) == 0) ? 1 : 0;
  130|       |
  131|       |#elif defined(HAVE_RANDOM)
  132|       |#warning "Using random() for crypto randoms is not secure! Multiple CVEs raised."
  133|       |#warning "Please update your C-library and rerun the auto-configuration."
  134|       |#define RAND_BYTES (RAND_MAX >= 0xffffff ? 3 : (RAND_MAX >= 0xffff ? 2 : 1))
  135|       |  unsigned char *dst = (unsigned char *)buf;
  136|       |
  137|       |  if (len) {
  138|       |    uint8_t byte_counter = RAND_BYTES;
  139|       |    uint32_t r_v = random();
  140|       |
  141|       |    while (1) {
  142|       |      *dst++ = r_v & 0xFF;
  143|       |      if (!--len) {
  144|       |        break;
  145|       |      }
  146|       |      if (--byte_counter) {
  147|       |        r_v >>= 8;
  148|       |      } else {
  149|       |        r_v = random();
  150|       |        byte_counter = RAND_BYTES;
  151|       |      }
  152|       |    }
  153|       |  }
  154|       |  return 1;
  155|       |#elif defined(RIOT_VERSION)
  156|       |#include <random.h>
  157|       |  random_bytes(buf, len);
  158|       |  return 1;
  159|       |
  160|       |#elif defined(WITH_CONTIKI)
  161|       |  return csprng_rand(buf, len);
  162|       |
  163|       |#elif defined(_WIN32)
  164|       |  return coap_prng_impl(buf,len);
  165|       |
  166|       |#else /* !MBEDTLS_ENTROPY_HARDWARE_ALT && !HAVE_GETRANDOM &&
  167|       |         !HAVE_RANDOM && !_WIN32 */
  168|       |#error "Using rand() for crypto randoms is not secure! Multiple CVEs raised."
  169|       |#error "Please update your C-library and rerun the auto-configuration."
  170|       |  unsigned char *dst = (unsigned char *)buf;
  171|       |  while (len--)
  172|       |    *dst++ = rand() & 0xFF;
  173|       |  return 1;
  174|       |#endif /* !MBEDTLS_ENTROPY_HARDWARE_ALT && !HAVE_GETRANDOM &&
  175|       |          !HAVE_RANDOM && !_WIN32 */
  176|    436|}

coap_proxy_cleanup:
  155|     35|coap_proxy_cleanup(coap_context_t *context) {
  156|     35|  size_t i;
  157|       |
  158|     35|  for (i = 0; i < context->proxy_list_count; i++) {
  ------------------
  |  Branch (158:15): [True: 0, False: 35]
  ------------------
  159|       |    /* All sessions have now been closed down */
  160|      0|    coap_log_debug("proxy_entry %p cleaned up\n",
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  161|      0|                   (void *)&context->proxy_list[i]);
  162|      0|    coap_proxy_cleanup_entry(&context->proxy_list[i], 0);
  163|      0|  }
  164|     35|  coap_free_type(COAP_STRING, context->proxy_list);
  165|     35|}
coap_delete_proxy_subscriber:
 1828|      2|                             coap_mid_t mid, coap_proxy_subs_delete_t type) {
 1829|       |  /* Need to check is there is a proxy subscription active and delete it */
 1830|      2|  coap_context_t *context = session->context;
 1831|      2|  size_t i;
 1832|       |
 1833|      2|  for (i = 0; i < context->proxy_list_count; i++) {
  ------------------
  |  Branch (1833:15): [True: 0, False: 2]
  ------------------
 1834|      0|    coap_proxy_entry_t *proxy_entry = &context->proxy_list[i];
 1835|      0|    coap_proxy_req_t *proxy_req, *treq;
 1836|       |
 1837|      0|    LL_FOREACH_SAFE(proxy_entry->proxy_req, proxy_req, treq) {
  ------------------
  |  |  425|      0|    LL_FOREACH_SAFE2(head,el,tmp,next)
  |  |  ------------------
  |  |  |  |  428|      0|  for ((el) = (head); (el) && ((tmp) = (el)->next, 1); (el) = (tmp))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (428:23): [True: 0, False: 0]
  |  |  |  |  |  Branch (428:31): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1838|      0|      if (proxy_req->incoming == session) {
  ------------------
  |  Branch (1838:11): [True: 0, False: 0]
  ------------------
 1839|      0|        coap_bin_const_t req_token;
 1840|      0|        int match = 0;
 1841|       |
 1842|      0|        req_token = coap_pdu_get_token(proxy_req->pdu);
 1843|      0|        switch (type) {
 1844|      0|        case COAP_PROXY_SUBS_ALL:
  ------------------
  |  Branch (1844:9): [True: 0, False: 0]
  ------------------
 1845|      0|          match = 1;
 1846|      0|          break;
 1847|      0|        case COAP_PROXY_SUBS_TOKEN:
  ------------------
  |  Branch (1847:9): [True: 0, False: 0]
  ------------------
 1848|      0|          if (token && coap_binary_equal(token, &req_token))
  ------------------
  |  |  223|      0|  ((binary1)->length == (binary2)->length && ((binary1)->length == 0 || \
  |  |  ------------------
  |  |  |  Branch (223:4): [True: 0, False: 0]
  |  |  |  Branch (223:47): [True: 0, False: 0]
  |  |  ------------------
  |  |  224|      0|                                              ((binary1)->s && (binary2)->s && \
  |  |  ------------------
  |  |  |  Branch (224:48): [True: 0, False: 0]
  |  |  |  Branch (224:64): [True: 0, False: 0]
  |  |  ------------------
  |  |  225|      0|                                               memcmp((binary1)->s, (binary2)->s, (binary1)->length) == 0)))
  |  |  ------------------
  |  |  |  Branch (225:48): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (1848:15): [True: 0, False: 0]
  ------------------
 1849|      0|            match = 1;
 1850|      0|          break;
 1851|      0|        case COAP_PROXY_SUBS_MID:
  ------------------
  |  Branch (1851:9): [True: 0, False: 0]
  ------------------
 1852|      0|          if (proxy_req->mid == mid)
  ------------------
  |  Branch (1852:15): [True: 0, False: 0]
  ------------------
 1853|      0|            match = 1;
 1854|      0|          break;
 1855|      0|        default:
  ------------------
  |  Branch (1855:9): [True: 0, False: 0]
  ------------------
 1856|      0|          break;
 1857|      0|        }
 1858|       |
 1859|      0|        if (match && proxy_entry->proxy_req && ! proxy_entry->proxy_req->next &&
  ------------------
  |  Branch (1859:13): [True: 0, False: 0]
  |  Branch (1859:22): [True: 0, False: 0]
  |  Branch (1859:48): [True: 0, False: 0]
  ------------------
 1860|      0|            proxy_req->token_used) {
  ------------------
  |  Branch (1860:13): [True: 0, False: 0]
  ------------------
 1861|      0|          coap_binary_t tmp;
 1862|       |
 1863|      0|          coap_log_debug("coap_delete_proxy_subscriber: Using coap_cancel_observe() to do Proxy OBSERVE cancellation\n");
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1864|       |          /* Unfortunately need to change the ptr type to be r/w */
 1865|      0|          memcpy(&tmp.s, &proxy_req->token_used->s, sizeof(tmp.s));
 1866|      0|          tmp.length = proxy_req->token_used->length;
 1867|      0|          coap_cancel_observe_lkd(proxy_entry->ongoing, &tmp, COAP_MESSAGE_CON);
 1868|      0|        }
 1869|      0|        coap_proxy_del_req(proxy_entry, proxy_req);
 1870|      0|      }
 1871|      0|    }
 1872|      0|  }
 1873|      2|}

coap_resource_init:
  327|     35|coap_resource_init(coap_str_const_t *uri_path, int flags) {
  328|     35|  coap_resource_t *r;
  329|       |
  330|     35|  r = (coap_resource_t *)coap_malloc_type(COAP_RESOURCE, sizeof(coap_resource_t));
  331|     35|  if (r) {
  ------------------
  |  Branch (331:7): [True: 35, False: 0]
  ------------------
  332|     35|    memset(r, 0, sizeof(coap_resource_t));
  333|       |#if COAP_THREAD_SAFE
  334|       |    coap_lock_init(&r->lock);
  335|       |#endif /* COAP_THREAD_SAFE */
  336|       |
  337|     35|    if (!(flags & COAP_RESOURCE_FLAGS_RELEASE_URI)) {
  ------------------
  |  |   55|     35|#define COAP_RESOURCE_FLAGS_RELEASE_URI 0x1
  ------------------
  |  Branch (337:9): [True: 35, False: 0]
  ------------------
  338|       |      /* Need to take a copy if caller is not providing a release request */
  339|     35|      if (uri_path)
  ------------------
  |  Branch (339:11): [True: 35, False: 0]
  ------------------
  340|     35|        uri_path = coap_new_str_const(uri_path->s, uri_path->length);
  341|      0|      else
  342|      0|        uri_path = coap_new_str_const(null_path->s, null_path->length);
  343|     35|    } else if (!uri_path) {
  ------------------
  |  Branch (343:16): [True: 0, False: 0]
  ------------------
  344|       |      /* Do not expect this, but ... */
  345|      0|      uri_path = coap_new_str_const(null_path->s, null_path->length);
  346|      0|    }
  347|       |
  348|     35|    if (uri_path)
  ------------------
  |  Branch (348:9): [True: 35, False: 0]
  ------------------
  349|     35|      r->uri_path = uri_path;
  350|       |
  351|     35|    r->flags = flags;
  352|     35|    r->observe = 2;
  353|     35|  } else {
  354|      0|    coap_log_debug("coap_resource_init: no memory left\n");
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  355|      0|  }
  356|       |
  357|     35|  return r;
  358|     35|}
coap_add_resource:
  605|     35|coap_add_resource(coap_context_t *context, coap_resource_t *resource) {
  606|     35|  coap_lock_lock(return);
  607|     35|  coap_add_resource_lkd(context, resource);
  608|     35|  coap_lock_unlock();
  609|     35|}
coap_add_resource_lkd:
  612|     35|coap_add_resource_lkd(coap_context_t *context, coap_resource_t *resource) {
  613|     35|  coap_lock_check_locked();
  ------------------
  |  |  638|     35|#define coap_lock_check_locked() {}
  ------------------
  614|     35|  if (resource->is_unknown) {
  ------------------
  |  Branch (614:7): [True: 0, False: 35]
  ------------------
  615|      0|    if (context->unknown_resource)
  ------------------
  |  Branch (615:9): [True: 0, False: 0]
  ------------------
  616|      0|      coap_free_resource(context->unknown_resource, COAP_DELETING_RESOURCE);
  617|      0|    context->unknown_resource = resource;
  618|     35|  } else if (resource->is_proxy_uri) {
  ------------------
  |  Branch (618:14): [True: 0, False: 35]
  ------------------
  619|      0|    if (context->proxy_uri_resource)
  ------------------
  |  Branch (619:9): [True: 0, False: 0]
  ------------------
  620|      0|      coap_free_resource(context->proxy_uri_resource, COAP_DELETING_RESOURCE);
  621|      0|    context->proxy_uri_resource = resource;
  622|     35|  } else {
  623|     35|    coap_resource_t *r = coap_get_resource_from_uri_path_lkd(context,
  624|     35|                                                             resource->uri_path);
  625|       |
  626|     35|    if (r) {
  ------------------
  |  Branch (626:9): [True: 0, False: 35]
  ------------------
  627|      0|      coap_log_warn("coap_add_resource: Duplicate uri_path '%*.*s', old resource deleted\n",
  ------------------
  |  |  108|      0|#define coap_log_warn(...) coap_log(COAP_LOG_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  628|      0|                    (int)resource->uri_path->length, (int)resource->uri_path->length,
  629|      0|                    resource->uri_path->s);
  630|      0|      coap_delete_resource_lkd(r);
  631|      0|    }
  632|     35|    RESOURCES_ADD(context->resources, resource);
  ------------------
  |  |  187|     35|  HASH_ADD(hh, (r), uri_path->s[0], (obj)->uri_path->length, (obj))
  |  |  ------------------
  |  |  |  |  442|     35|  HASH_ADD_KEYPTR(hh, head, &((add)->fieldname), keylen_in, add)
  |  |  |  |  ------------------
  |  |  |  |  |  |  431|     35|#define HASH_ADD_KEYPTR(hh,head,keyptr,keylen_in,add)                            \
  |  |  |  |  |  |  432|     35|do {                                                                             \
  |  |  |  |  |  |  433|     35|  uint32_t _ha_hashv;                                                            \
  |  |  |  |  |  |  434|     35|  HASH_VALUE(keyptr, keylen_in, _ha_hashv);                                      \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  162|     35|#define HASH_VALUE(keyptr,keylen,hashv)                                          \
  |  |  |  |  |  |  |  |  163|     35|do {                                                                             \
  |  |  |  |  |  |  |  |  164|     35|  HASH_FUNCTION(keyptr, keylen, hashv);                                          \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  102|     35|#define HASH_FUNCTION(keyptr,keylen,hashv) HASH_JEN(keyptr, keylen, hashv)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  658|     35|#define HASH_JEN(key,keylen,hashv)                                               \
  |  |  |  |  |  |  |  |  |  |  |  |  659|     35|do {                                                                             \
  |  |  |  |  |  |  |  |  |  |  |  |  660|     35|  uint32_t _hj_i,_hj_j,_hj_k;                                                    \
  |  |  |  |  |  |  |  |  |  |  |  |  661|     35|  unsigned const char *_hj_key=(unsigned const char*)(key);                      \
  |  |  |  |  |  |  |  |  |  |  |  |  662|     35|  hashv = 0xfeedbeefu;                                                           \
  |  |  |  |  |  |  |  |  |  |  |  |  663|     35|  _hj_i = _hj_j = 0x9e3779b9u;                                                   \
  |  |  |  |  |  |  |  |  |  |  |  |  664|     35|  _hj_k = (uint32_t)(keylen);                                                    \
  |  |  |  |  |  |  |  |  |  |  |  |  665|     35|  while (_hj_k >= 12U) {                                                         \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (665:10): [True: 0, False: 35]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  666|      0|    _hj_i = (int64_t)_hj_i + (_hj_key[0] + ( (uint32_t)_hj_key[1] << 8 )         \
  |  |  |  |  |  |  |  |  |  |  |  |  667|      0|        + ( (uint32_t)_hj_key[2] << 16 )                                         \
  |  |  |  |  |  |  |  |  |  |  |  |  668|      0|        + ( (uint32_t)_hj_key[3] << 24 ) );                                      \
  |  |  |  |  |  |  |  |  |  |  |  |  669|      0|    _hj_j = (int64_t)_hj_j + (_hj_key[4] + ( (uint32_t)_hj_key[5] << 8 )         \
  |  |  |  |  |  |  |  |  |  |  |  |  670|      0|        + ( (uint32_t)_hj_key[6] << 16 )                                         \
  |  |  |  |  |  |  |  |  |  |  |  |  671|      0|        + ( (uint32_t)_hj_key[7] << 24 ) );                                      \
  |  |  |  |  |  |  |  |  |  |  |  |  672|      0|    hashv = (int64_t)hashv + (_hj_key[8] + ( (uint32_t)_hj_key[9] << 8 )         \
  |  |  |  |  |  |  |  |  |  |  |  |  673|      0|        + ( (uint32_t)_hj_key[10] << 16 )                                        \
  |  |  |  |  |  |  |  |  |  |  |  |  674|      0|        + ( (uint32_t)_hj_key[11] << 24 ) );                                     \
  |  |  |  |  |  |  |  |  |  |  |  |  675|      0|                                                                                 \
  |  |  |  |  |  |  |  |  |  |  |  |  676|      0|     HASH_JEN_MIX(_hj_i, _hj_j, hashv);                                          \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  645|      0|#define HASH_JEN_MIX(a,b,c)                                                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  646|      0|do {                                                                             \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  647|      0|  a = (int64_t)a - b; a = (int64_t)a - c; a ^= ( c >> 13 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  648|      0|  b = (int64_t)b - c; b = (int64_t)b - a; b ^= ( a << 8 );                       \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  649|      0|  c = (int64_t)c - a; c = (int64_t)c - b; c ^= ( b >> 13 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  650|      0|  a = (int64_t)a - b; a = (int64_t)a - c; a ^= ( c >> 12 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  651|      0|  b = (int64_t)b - c; b = (int64_t)b - a; b ^= ( a << 16 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  652|      0|  c = (int64_t)c - a; c = (int64_t)c - b; c ^= ( b >> 5 );                       \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  653|      0|  a = (int64_t)a - b; a = (int64_t)a - c; a ^= ( c >> 3 );                       \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  654|      0|  b = (int64_t)b - c; b = (int64_t)b - a; b ^= ( a << 10 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  655|      0|  c = (int64_t)c - a; c = (int64_t)c - b; c ^= ( b >> 15 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  656|      0|} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (656:10): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  677|      0|                                                                                 \
  |  |  |  |  |  |  |  |  |  |  |  |  678|      0|     _hj_key += 12;                                                              \
  |  |  |  |  |  |  |  |  |  |  |  |  679|      0|     _hj_k -= 12U;                                                               \
  |  |  |  |  |  |  |  |  |  |  |  |  680|      0|  }                                                                              \
  |  |  |  |  |  |  |  |  |  |  |  |  681|     35|  hashv += (uint32_t)(keylen);                                                   \
  |  |  |  |  |  |  |  |  |  |  |  |  682|     35|  switch ( _hj_k ) {                                                             \
  |  |  |  |  |  |  |  |  |  |  |  |  683|      0|    case 11: hashv = (int64_t)hashv + ( (uint32_t)_hj_key[10] << 24 ); /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (683:5): [True: 0, False: 35]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  684|      0|    case 10: hashv = (int64_t)hashv + ( (uint32_t)_hj_key[9] << 16 );  /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (684:5): [True: 0, False: 35]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  685|      0|    case 9:  hashv = (int64_t)hashv + ( (uint32_t)_hj_key[8] << 8 );   /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (685:5): [True: 0, False: 35]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  686|      0|    case 8:  _hj_j = (int64_t)_hj_j + ( (uint32_t)_hj_key[7] << 24 );  /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (686:5): [True: 0, False: 35]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  687|      0|    case 7:  _hj_j = (int64_t)_hj_j + ( (uint32_t)_hj_key[6] << 16 );  /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (687:5): [True: 0, False: 35]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  688|      0|    case 6:  _hj_j = (int64_t)_hj_j + ( (uint32_t)_hj_key[5] << 8 );   /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (688:5): [True: 0, False: 35]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  689|      0|    case 5:  _hj_j = (int64_t)_hj_j + _hj_key[4];                      /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (689:5): [True: 0, False: 35]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  690|      0|    case 4:  _hj_i = (int64_t)_hj_i + ( (uint32_t)_hj_key[3] << 24 );  /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (690:5): [True: 0, False: 35]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  691|     35|    case 3:  _hj_i = (int64_t)_hj_i + ( (uint32_t)_hj_key[2] << 16 );  /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (691:5): [True: 35, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  692|     35|    case 2:  _hj_i = (int64_t)_hj_i + ( (uint32_t)_hj_key[1] << 8 );   /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (692:5): [True: 0, False: 35]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  693|     35|    case 1:  _hj_i = (int64_t)_hj_i + _hj_key[0];                      /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (693:5): [True: 0, False: 35]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  694|     35|    default: ;                                                                   \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (694:5): [True: 0, False: 35]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  695|     35|  }                                                                              \
  |  |  |  |  |  |  |  |  |  |  |  |  696|     35|  HASH_JEN_MIX(_hj_i, _hj_j, hashv);                                             \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  645|     35|#define HASH_JEN_MIX(a,b,c)                                                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  646|     35|do {                                                                             \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  647|     35|  a = (int64_t)a - b; a = (int64_t)a - c; a ^= ( c >> 13 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  648|     35|  b = (int64_t)b - c; b = (int64_t)b - a; b ^= ( a << 8 );                       \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  649|     35|  c = (int64_t)c - a; c = (int64_t)c - b; c ^= ( b >> 13 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  650|     35|  a = (int64_t)a - b; a = (int64_t)a - c; a ^= ( c >> 12 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  651|     35|  b = (int64_t)b - c; b = (int64_t)b - a; b ^= ( a << 16 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  652|     35|  c = (int64_t)c - a; c = (int64_t)c - b; c ^= ( b >> 5 );                       \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  653|     35|  a = (int64_t)a - b; a = (int64_t)a - c; a ^= ( c >> 3 );                       \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  654|     35|  b = (int64_t)b - c; b = (int64_t)b - a; b ^= ( a << 10 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  655|     35|  c = (int64_t)c - a; c = (int64_t)c - b; c ^= ( b >> 15 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  656|     35|} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (656:10): [Folded, False: 35]
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  697|     35|} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (697:10): [Folded, False: 35]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  165|     35|} while (0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (165:10): [Folded, False: 35]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  435|     35|  HASH_ADD_KEYPTR_BYHASHVALUE(hh, head, keyptr, keylen_in, _ha_hashv, add);      \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  410|     35|#define HASH_ADD_KEYPTR_BYHASHVALUE(hh,head,keyptr,keylen_in,hashval,add)        \
  |  |  |  |  |  |  |  |  411|     35|do {                                                                             \
  |  |  |  |  |  |  |  |  412|     35|  IF_HASH_NONFATAL_OOM( int _ha_oomed = 0; )                                     \
  |  |  |  |  |  |  |  |  413|     35|  (add)->hh.hashv = (hashval);                                                   \
  |  |  |  |  |  |  |  |  414|     35|  (add)->hh.key = (const void*) (keyptr);                                        \
  |  |  |  |  |  |  |  |  415|     35|  (add)->hh.keylen = (uint32_t) (keylen_in);                                     \
  |  |  |  |  |  |  |  |  416|     35|  if (!(head)) {                                                                 \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (416:7): [True: 35, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  417|     35|    (add)->hh.next = NULL;                                                       \
  |  |  |  |  |  |  |  |  418|     35|    (add)->hh.prev = NULL;                                                       \
  |  |  |  |  |  |  |  |  419|     35|    HASH_MAKE_TABLE(hh, add, _ha_oomed);                                         \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  226|     35|#define HASH_MAKE_TABLE(hh,head,oomed)                                           \
  |  |  |  |  |  |  |  |  |  |  227|     35|do {                                                                             \
  |  |  |  |  |  |  |  |  |  |  228|     35|  (head)->hh.tbl = (UT_hash_table*)uthash_malloc(sizeof(UT_hash_table));         \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   89|     35|#define uthash_malloc(sz) malloc(sz)      /* malloc fcn                      */
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  229|     35|  if (!(head)->hh.tbl) {                                                         \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (229:7): [True: 0, False: 35]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  230|      0|    HASH_RECORD_OOM(oomed);                                                      \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  137|      0|#define HASH_RECORD_OOM(oomed) uthash_fatal("out of memory")
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  134|      0|#define uthash_fatal(msg) exit(-1)        /* fatal OOM error */
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  231|     35|  } else {                                                                       \
  |  |  |  |  |  |  |  |  |  |  232|     35|    uthash_bzero((head)->hh.tbl, sizeof(UT_hash_table));                         \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   95|     35|#define uthash_bzero(a,n) memset(a,'\0',n)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  233|     35|    (head)->hh.tbl->tail = &((head)->hh);                                        \
  |  |  |  |  |  |  |  |  |  |  234|     35|    (head)->hh.tbl->num_buckets = HASH_INITIAL_NUM_BUCKETS;                      \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  143|     35|#define HASH_INITIAL_NUM_BUCKETS 32U     /* initial number of buckets        */
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  235|     35|    (head)->hh.tbl->log2_num_buckets = HASH_INITIAL_NUM_BUCKETS_LOG2;            \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  144|     35|#define HASH_INITIAL_NUM_BUCKETS_LOG2 5U /* lg2 of initial number of buckets */
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  236|     35|    (head)->hh.tbl->hho = (char*)(&(head)->hh) - (char*)(head);                  \
  |  |  |  |  |  |  |  |  |  |  237|     35|    (head)->hh.tbl->buckets = (UT_hash_bucket*)uthash_malloc(                    \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   89|     35|#define uthash_malloc(sz) malloc(sz)      /* malloc fcn                      */
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  238|     35|        HASH_INITIAL_NUM_BUCKETS * sizeof(struct UT_hash_bucket));               \
  |  |  |  |  |  |  |  |  |  |  239|     35|    (head)->hh.tbl->signature = HASH_SIGNATURE;                                  \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  | 1101|     35|#define HASH_SIGNATURE 0xa0111fe1u
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  240|     35|    if (!(head)->hh.tbl->buckets) {                                              \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (240:9): [True: 0, False: 35]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  241|      0|      HASH_RECORD_OOM(oomed);                                                    \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  137|      0|#define HASH_RECORD_OOM(oomed) uthash_fatal("out of memory")
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  134|      0|#define uthash_fatal(msg) exit(-1)        /* fatal OOM error */
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  242|      0|      uthash_free((head)->hh.tbl, sizeof(UT_hash_table));                        \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   92|      0|#define uthash_free(ptr,sz) free(ptr)     /* free fcn                        */
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  243|     35|    } else {                                                                     \
  |  |  |  |  |  |  |  |  |  |  244|     35|      uthash_bzero((head)->hh.tbl->buckets,                                      \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   95|     35|#define uthash_bzero(a,n) memset(a,'\0',n)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  245|     35|          HASH_INITIAL_NUM_BUCKETS * sizeof(struct UT_hash_bucket));             \
  |  |  |  |  |  |  |  |  |  |  246|     35|      HASH_BLOOM_MAKE((head)->hh.tbl, oomed);                                    \
  |  |  |  |  |  |  |  |  |  |  247|     35|      IF_HASH_NONFATAL_OOM(                                                      \
  |  |  |  |  |  |  |  |  |  |  248|     35|        if (oomed) {                                                             \
  |  |  |  |  |  |  |  |  |  |  249|     35|          uthash_free((head)->hh.tbl->buckets,                                   \
  |  |  |  |  |  |  |  |  |  |  250|     35|              HASH_INITIAL_NUM_BUCKETS*sizeof(struct UT_hash_bucket));           \
  |  |  |  |  |  |  |  |  |  |  251|     35|          uthash_free((head)->hh.tbl, sizeof(UT_hash_table));                    \
  |  |  |  |  |  |  |  |  |  |  252|     35|        }                                                                        \
  |  |  |  |  |  |  |  |  |  |  253|     35|      )                                                                          \
  |  |  |  |  |  |  |  |  |  |  254|     35|    }                                                                            \
  |  |  |  |  |  |  |  |  |  |  255|     35|  }                                                                              \
  |  |  |  |  |  |  |  |  |  |  256|     35|} while (0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (256:10): [Folded, False: 35]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  420|     35|    IF_HASH_NONFATAL_OOM( if (!_ha_oomed) { )                                    \
  |  |  |  |  |  |  |  |  421|     35|      (head) = (add);                                                            \
  |  |  |  |  |  |  |  |  422|     35|    IF_HASH_NONFATAL_OOM( } )                                                    \
  |  |  |  |  |  |  |  |  423|     35|  } else {                                                                       \
  |  |  |  |  |  |  |  |  424|      0|    (add)->hh.tbl = (head)->hh.tbl;                                              \
  |  |  |  |  |  |  |  |  425|      0|    HASH_APPEND_LIST(hh, head, add);                                             \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  292|      0|#define HASH_APPEND_LIST(hh, head, add)                                          \
  |  |  |  |  |  |  |  |  |  |  293|      0|do {                                                                             \
  |  |  |  |  |  |  |  |  |  |  294|      0|  (add)->hh.next = NULL;                                                         \
  |  |  |  |  |  |  |  |  |  |  295|      0|  (add)->hh.prev = ELMT_FROM_HH((head)->hh.tbl, (head)->hh.tbl->tail);           \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  148|      0|#define ELMT_FROM_HH(tbl,hhp) ((void*)(((char*)(hhp)) - ((tbl)->hho)))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  296|      0|  (head)->hh.tbl->tail->next = (add);                                            \
  |  |  |  |  |  |  |  |  |  |  297|      0|  (head)->hh.tbl->tail = &((add)->hh);                                           \
  |  |  |  |  |  |  |  |  |  |  298|      0|} while (0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (298:10): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  426|      0|  }                                                                              \
  |  |  |  |  |  |  |  |  427|     35|  HASH_ADD_TO_TABLE(hh, head, keyptr, keylen_in, hashval, add, _ha_oomed);       \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  351|     35|#define HASH_ADD_TO_TABLE(hh,head,keyptr,keylen_in,hashval,add,oomed)            \
  |  |  |  |  |  |  |  |  |  |  352|     35|do {                                                                             \
  |  |  |  |  |  |  |  |  |  |  353|     35|  uint32_t _ha_bkt;                                                              \
  |  |  |  |  |  |  |  |  |  |  354|     35|  (head)->hh.tbl->num_items++;                                                   \
  |  |  |  |  |  |  |  |  |  |  355|     35|  HASH_TO_BKT(hashval, (head)->hh.tbl->num_buckets, _ha_bkt);                    \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  444|     35|#define HASH_TO_BKT(hashv,num_bkts,bkt)                                          \
  |  |  |  |  |  |  |  |  |  |  |  |  445|     35|do {                                                                             \
  |  |  |  |  |  |  |  |  |  |  |  |  446|     35|  bkt = ((hashv) & ((num_bkts) - 1U));                                           \
  |  |  |  |  |  |  |  |  |  |  |  |  447|     35|} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (447:10): [Folded, False: 35]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  356|     35|  HASH_ADD_TO_BKT((head)->hh.tbl->buckets[_ha_bkt], hh, &(add)->hh, oomed);      \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  778|     35|#define HASH_ADD_TO_BKT(head,hh,addhh,oomed)                                     \
  |  |  |  |  |  |  |  |  |  |  |  |  779|     35|do {                                                                             \
  |  |  |  |  |  |  |  |  |  |  |  |  780|     35|  UT_hash_bucket *_ha_head = &(head);                                            \
  |  |  |  |  |  |  |  |  |  |  |  |  781|     35|  _ha_head->count++;                                                             \
  |  |  |  |  |  |  |  |  |  |  |  |  782|     35|  (addhh)->hh_next = _ha_head->hh_head;                                          \
  |  |  |  |  |  |  |  |  |  |  |  |  783|     35|  (addhh)->hh_prev = NULL;                                                       \
  |  |  |  |  |  |  |  |  |  |  |  |  784|     35|  if (_ha_head->hh_head != NULL) {                                               \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (784:7): [True: 0, False: 35]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  785|      0|    _ha_head->hh_head->hh_prev = (addhh);                                        \
  |  |  |  |  |  |  |  |  |  |  |  |  786|      0|  }                                                                              \
  |  |  |  |  |  |  |  |  |  |  |  |  787|     35|  _ha_head->hh_head = (addhh);                                                   \
  |  |  |  |  |  |  |  |  |  |  |  |  788|     35|  if ((_ha_head->count >= ((_ha_head->expand_mult + 1U) * HASH_BKT_CAPACITY_THRESH)) \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  145|     35|#define HASH_BKT_CAPACITY_THRESH 10U     /* expand when bucket count reaches */
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (788:7): [True: 0, False: 35]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  789|     35|      && !(addhh)->tbl->noexpand) {                                              \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (789:10): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  790|      0|    HASH_EXPAND_BUCKETS(addhh,(addhh)->tbl, oomed);                              \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  844|      0|#define HASH_EXPAND_BUCKETS(hh,tbl,oomed)                                        \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  845|      0|do {                                                                             \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  846|      0|  uint32_t _he_bkt;                                                              \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  847|      0|  uint32_t _he_bkt_i;                                                            \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  848|      0|  struct UT_hash_handle *_he_thh, *_he_hh_nxt;                                   \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  849|      0|  UT_hash_bucket *_he_new_buckets, *_he_newbkt;                                  \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  850|      0|  _he_new_buckets = (UT_hash_bucket*)uthash_malloc(                              \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   89|      0|#define uthash_malloc(sz) malloc(sz)      /* malloc fcn                      */
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  851|      0|           sizeof(struct UT_hash_bucket) * (tbl)->num_buckets * 2U);             \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  852|      0|  if (!_he_new_buckets) {                                                        \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (852:7): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  853|      0|    HASH_RECORD_OOM(oomed);                                                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  137|      0|#define HASH_RECORD_OOM(oomed) uthash_fatal("out of memory")
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  134|      0|#define uthash_fatal(msg) exit(-1)        /* fatal OOM error */
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  854|      0|  } else {                                                                       \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  855|      0|    uthash_bzero(_he_new_buckets,                                                \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   95|      0|#define uthash_bzero(a,n) memset(a,'\0',n)
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  856|      0|        sizeof(struct UT_hash_bucket) * (tbl)->num_buckets * 2U);                \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  857|      0|    (tbl)->ideal_chain_maxlen =                                                  \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  858|      0|       ((tbl)->num_items >> ((tbl)->log2_num_buckets+1U)) +                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  859|      0|       ((((tbl)->num_items & (((tbl)->num_buckets*2U)-1U)) != 0U) ? 1U : 0U);    \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (859:9): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  860|      0|    (tbl)->nonideal_items = 0;                                                   \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  861|      0|    for (_he_bkt_i = 0; _he_bkt_i < (tbl)->num_buckets; _he_bkt_i++) {           \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (861:25): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  862|      0|      _he_thh = (tbl)->buckets[ _he_bkt_i ].hh_head;                             \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  863|      0|      while (_he_thh != NULL) {                                                  \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (863:14): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  864|      0|        _he_hh_nxt = _he_thh->hh_next;                                           \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  865|      0|        HASH_TO_BKT(_he_thh->hashv, (tbl)->num_buckets * 2U, _he_bkt);           \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  444|      0|#define HASH_TO_BKT(hashv,num_bkts,bkt)                                          \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  445|      0|do {                                                                             \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  446|      0|  bkt = ((hashv) & ((num_bkts) - 1U));                                           \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  447|      0|} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (447:10): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  866|      0|        _he_newbkt = &(_he_new_buckets[_he_bkt]);                                \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  867|      0|        if (++(_he_newbkt->count) > (tbl)->ideal_chain_maxlen) {                 \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (867:13): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  868|      0|          (tbl)->nonideal_items++;                                               \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  869|      0|          if (_he_newbkt->count > _he_newbkt->expand_mult * (tbl)->ideal_chain_maxlen) { \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (869:15): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  870|      0|            _he_newbkt->expand_mult++;                                           \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  871|      0|          }                                                                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  872|      0|        }                                                                        \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  873|      0|        _he_thh->hh_prev = NULL;                                                 \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  874|      0|        _he_thh->hh_next = _he_newbkt->hh_head;                                  \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  875|      0|        if (_he_newbkt->hh_head != NULL) {                                       \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (875:13): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  876|      0|          _he_newbkt->hh_head->hh_prev = _he_thh;                                \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  877|      0|        }                                                                        \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  878|      0|        _he_newbkt->hh_head = _he_thh;                                           \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  879|      0|        _he_thh = _he_hh_nxt;                                                    \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  880|      0|      }                                                                          \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  881|      0|    }                                                                            \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  882|      0|    uthash_free((tbl)->buckets, (tbl)->num_buckets * sizeof(struct UT_hash_bucket)); \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   92|      0|#define uthash_free(ptr,sz) free(ptr)     /* free fcn                        */
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  883|      0|    (tbl)->num_buckets *= 2U;                                                    \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  884|      0|    (tbl)->log2_num_buckets++;                                                   \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  885|      0|    (tbl)->buckets = _he_new_buckets;                                            \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  886|      0|    (tbl)->ineff_expands = ((tbl)->nonideal_items > ((tbl)->num_items >> 1)) ?   \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (886:28): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  887|      0|        ((tbl)->ineff_expands+1U) : 0U;                                          \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  888|      0|    if ((tbl)->ineff_expands > 1U) {                                             \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (888:9): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  889|      0|      (tbl)->noexpand = 1;                                                       \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  890|      0|      uthash_noexpand_fyi(tbl);                                                  \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  891|      0|    }                                                                            \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  892|      0|    uthash_expand_fyi(tbl);                                                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  893|      0|  }                                                                              \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  894|      0|} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (894:10): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  791|      0|    IF_HASH_NONFATAL_OOM(                                                        \
  |  |  |  |  |  |  |  |  |  |  |  |  792|      0|      if (oomed) {                                                               \
  |  |  |  |  |  |  |  |  |  |  |  |  793|      0|        HASH_DEL_IN_BKT(head,addhh);                                             \
  |  |  |  |  |  |  |  |  |  |  |  |  794|      0|      }                                                                          \
  |  |  |  |  |  |  |  |  |  |  |  |  795|      0|    )                                                                            \
  |  |  |  |  |  |  |  |  |  |  |  |  796|      0|  }                                                                              \
  |  |  |  |  |  |  |  |  |  |  |  |  797|     35|} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (797:10): [Folded, False: 35]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  357|     35|  HASH_BLOOM_ADD((head)->hh.tbl, hashval);                                       \
  |  |  |  |  |  |  |  |  |  |  358|     35|  HASH_EMIT_KEY(hh, head, keyptr, keylen_in);                                    \
  |  |  |  |  |  |  |  |  |  |  359|     35|} while (0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (359:10): [Folded, False: 35]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  428|     35|  HASH_FSCK(hh, head, "HASH_ADD_KEYPTR_BYHASHVALUE");                            \
  |  |  |  |  |  |  |  |  429|     35|} while (0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (429:10): [Folded, False: 35]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  436|     35|} while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (436:10): [Folded, False: 35]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  633|     35|#if COAP_WITH_OBSERVE_PERSIST
  634|     35|    if (context->unknown_pdu && context->dyn_resource_save_file &&
  ------------------
  |  Branch (634:9): [True: 0, False: 35]
  |  Branch (634:33): [True: 0, False: 0]
  ------------------
  635|      0|        context->dyn_resource_added_cb && resource->observable) {
  ------------------
  |  Branch (635:9): [True: 0, False: 0]
  |  Branch (635:43): [True: 0, False: 0]
  ------------------
  636|      0|      coap_bin_const_t raw_packet;
  637|       |
  638|      0|      raw_packet.s = context->unknown_pdu->token -
  639|      0|                     context->unknown_pdu->hdr_size;
  640|      0|      raw_packet.length = context->unknown_pdu->used_size +
  641|      0|                          context->unknown_pdu->hdr_size;
  642|      0|      coap_lock_callback(context->dyn_resource_added_cb(context->unknown_session,
  ------------------
  |  |  651|      0|#define coap_lock_callback(func) func
  ------------------
  643|      0|                                                        resource->uri_path,
  644|      0|                                                        &raw_packet,
  645|      0|                                                        context->observe_user_data));
  646|      0|    }
  647|     35|#endif /* COAP_WITH_OBSERVE_PERSIST */
  648|     35|  }
  649|     35|  assert(resource->context == NULL);
  ------------------
  |  Branch (649:3): [True: 35, False: 0]
  ------------------
  650|     35|  resource->context = context;
  651|     35|}
coap_delete_resource_lkd:
  671|    254|coap_delete_resource_lkd(coap_resource_t *resource) {
  672|    254|  coap_context_t *context;
  673|    254|  coap_deleting_resource_t deleting;
  674|       |
  675|    254|  if (!resource)
  ------------------
  |  Branch (675:7): [True: 0, False: 254]
  ------------------
  676|      0|    return 0;
  677|       |
  678|    254|  context = resource->context;
  679|    254|  coap_lock_check_locked();
  ------------------
  |  |  638|    254|#define coap_lock_check_locked() {}
  ------------------
  680|       |
  681|    254|  if (resource->ref) {
  ------------------
  |  Branch (681:7): [True: 219, False: 35]
  ------------------
  682|    219|    resource->ref--;
  683|    219|    return 1;
  684|    219|  }
  685|     35|  if (context && context->context_going_away) {
  ------------------
  |  Branch (685:7): [True: 35, False: 0]
  |  Branch (685:18): [True: 35, False: 0]
  ------------------
  686|     35|    deleting = COAP_DELETING_RESOURCE_ON_EXIT;
  687|     35|  } else {
  688|      0|    deleting = COAP_DELETING_RESOURCE;
  689|      0|  }
  690|     35|  if (resource->is_unknown) {
  ------------------
  |  Branch (690:7): [True: 0, False: 35]
  ------------------
  691|      0|    if (context && context->unknown_resource == resource) {
  ------------------
  |  Branch (691:9): [True: 0, False: 0]
  |  Branch (691:20): [True: 0, False: 0]
  ------------------
  692|      0|      context->unknown_resource = NULL;
  693|      0|    }
  694|     35|  } else if (resource->is_proxy_uri) {
  ------------------
  |  Branch (694:14): [True: 0, False: 35]
  ------------------
  695|      0|    if (context && context->proxy_uri_resource == resource) {
  ------------------
  |  Branch (695:9): [True: 0, False: 0]
  |  Branch (695:20): [True: 0, False: 0]
  ------------------
  696|      0|      context->proxy_uri_resource = NULL;
  697|      0|    }
  698|     35|  } else if (context) {
  ------------------
  |  Branch (698:14): [True: 35, False: 0]
  ------------------
  699|       |    /* remove resource from list */
  700|     35|    RESOURCES_DELETE(context->resources, resource);
  ------------------
  |  |  190|     35|  HASH_DELETE(hh, (r), (obj))
  |  |  ------------------
  |  |  |  |  462|     35|    HASH_DELETE_HH(hh, head, &(delptr)->hh)
  |  |  |  |  ------------------
  |  |  |  |  |  |  464|     35|#define HASH_DELETE_HH(hh,head,delptrhh)                                         \
  |  |  |  |  |  |  465|     35|do {                                                                             \
  |  |  |  |  |  |  466|     35|  struct UT_hash_handle *_hd_hh_del = (delptrhh);                                \
  |  |  |  |  |  |  467|     35|  if ((_hd_hh_del->prev == NULL) && (_hd_hh_del->next == NULL)) {                \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (467:7): [True: 35, False: 0]
  |  |  |  |  |  |  |  Branch (467:37): [True: 35, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  468|     35|    HASH_BLOOM_FREE((head)->hh.tbl);                                             \
  |  |  |  |  |  |  469|     35|    uthash_free((head)->hh.tbl->buckets,                                         \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   92|     35|#define uthash_free(ptr,sz) free(ptr)     /* free fcn                        */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  470|     35|                (head)->hh.tbl->num_buckets * sizeof(struct UT_hash_bucket));    \
  |  |  |  |  |  |  471|     35|    uthash_free((head)->hh.tbl, sizeof(UT_hash_table));                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   92|     35|#define uthash_free(ptr,sz) free(ptr)     /* free fcn                        */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  472|     35|    (head) = NULL;                                                               \
  |  |  |  |  |  |  473|     35|  } else {                                                                       \
  |  |  |  |  |  |  474|      0|    uint32_t _hd_bkt;                                                            \
  |  |  |  |  |  |  475|      0|    if (_hd_hh_del == (head)->hh.tbl->tail) {                                    \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (475:9): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  476|      0|      (head)->hh.tbl->tail = HH_FROM_ELMT((head)->hh.tbl, _hd_hh_del->prev);     \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  150|      0|#define HH_FROM_ELMT(tbl,elp) ((UT_hash_handle*)(void*)(((char*)(elp)) + ((tbl)->hho)))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  477|      0|    }                                                                            \
  |  |  |  |  |  |  478|      0|    if (_hd_hh_del->prev != NULL) {                                              \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (478:9): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  479|      0|      HH_FROM_ELMT((head)->hh.tbl, _hd_hh_del->prev)->next = _hd_hh_del->next;   \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  150|      0|#define HH_FROM_ELMT(tbl,elp) ((UT_hash_handle*)(void*)(((char*)(elp)) + ((tbl)->hho)))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  480|      0|    } else {                                                                     \
  |  |  |  |  |  |  481|      0|      DECLTYPE_ASSIGN(head, _hd_hh_del->next);                                   \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   78|      0|#define DECLTYPE_ASSIGN(dst,src)                                                 \
  |  |  |  |  |  |  |  |   79|      0|do {                                                                             \
  |  |  |  |  |  |  |  |   80|      0|  (dst) = DECLTYPE(dst)(src);                                                    \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   66|      0|#define DECLTYPE(x) (__typeof(x))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   81|      0|} while (0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (81:10): [Folded, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  482|      0|    }                                                                            \
  |  |  |  |  |  |  483|      0|    if (_hd_hh_del->next != NULL) {                                              \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (483:9): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  484|      0|      HH_FROM_ELMT((head)->hh.tbl, _hd_hh_del->next)->prev = _hd_hh_del->prev;   \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  150|      0|#define HH_FROM_ELMT(tbl,elp) ((UT_hash_handle*)(void*)(((char*)(elp)) + ((tbl)->hho)))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  485|      0|    }                                                                            \
  |  |  |  |  |  |  486|      0|    HASH_TO_BKT(_hd_hh_del->hashv, (head)->hh.tbl->num_buckets, _hd_bkt);        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  444|      0|#define HASH_TO_BKT(hashv,num_bkts,bkt)                                          \
  |  |  |  |  |  |  |  |  445|      0|do {                                                                             \
  |  |  |  |  |  |  |  |  446|      0|  bkt = ((hashv) & ((num_bkts) - 1U));                                           \
  |  |  |  |  |  |  |  |  447|      0|} while (0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (447:10): [Folded, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  487|      0|    HASH_DEL_IN_BKT((head)->hh.tbl->buckets[_hd_bkt], _hd_hh_del);               \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  800|      0|#define HASH_DEL_IN_BKT(head,delhh)                                              \
  |  |  |  |  |  |  |  |  801|      0|do {                                                                             \
  |  |  |  |  |  |  |  |  802|      0|  UT_hash_bucket *_hd_head = &(head);                                            \
  |  |  |  |  |  |  |  |  803|      0|  _hd_head->count--;                                                             \
  |  |  |  |  |  |  |  |  804|      0|  if (_hd_head->hh_head == (delhh)) {                                            \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (804:7): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  805|      0|    _hd_head->hh_head = (delhh)->hh_next;                                        \
  |  |  |  |  |  |  |  |  806|      0|  }                                                                              \
  |  |  |  |  |  |  |  |  807|      0|  if ((delhh)->hh_prev) {                                                        \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (807:7): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  808|      0|    (delhh)->hh_prev->hh_next = (delhh)->hh_next;                                \
  |  |  |  |  |  |  |  |  809|      0|  }                                                                              \
  |  |  |  |  |  |  |  |  810|      0|  if ((delhh)->hh_next) {                                                        \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (810:7): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  811|      0|    (delhh)->hh_next->hh_prev = (delhh)->hh_prev;                                \
  |  |  |  |  |  |  |  |  812|      0|  }                                                                              \
  |  |  |  |  |  |  |  |  813|      0|} while (0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (813:10): [Folded, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  488|      0|    (head)->hh.tbl->num_items--;                                                 \
  |  |  |  |  |  |  489|      0|  }                                                                              \
  |  |  |  |  |  |  490|     35|  HASH_FSCK(hh, head, "HASH_DELETE_HH");                                         \
  |  |  |  |  |  |  491|     35|} while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (491:10): [Folded, False: 35]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  701|     35|  }
  702|     35|  if (resource->is_dynamic) {
  ------------------
  |  Branch (702:7): [True: 0, False: 35]
  ------------------
  703|      0|    if (context) {
  ------------------
  |  Branch (703:9): [True: 0, False: 0]
  ------------------
  704|      0|      assert(context->dynamic_cur);
  ------------------
  |  Branch (704:7): [True: 0, False: 0]
  ------------------
  705|      0|      context->dynamic_cur--;
  706|      0|    }
  707|      0|  }
  708|       |
  709|       |  /* and free its allocated memory */
  710|     35|  coap_free_resource(resource, deleting);
  711|       |
  712|     35|  return 1;
  713|     35|}
coap_resource_release_lkd:
  716|    219|coap_resource_release_lkd(coap_resource_t *resource) {
  717|    219|  return coap_delete_resource_lkd(resource);
  718|    219|}
coap_delete_all_resources:
  721|     35|coap_delete_all_resources(coap_context_t *context) {
  722|     35|  coap_resource_t *r;
  723|     35|  coap_resource_t *tmp;
  724|       |
  725|     35|  RESOURCE_ITER_SAFE(context->resources, r, tmp) {
  ------------------
  |  |  197|     70|  for ((el) = (e); (el) && ((rtmp) = (el)->hh.next, 1); (el) = (rtmp))
  |  |  ------------------
  |  |  |  Branch (197:20): [True: 35, False: 35]
  |  |  |  Branch (197:28): [True: 35, False: 0]
  |  |  ------------------
  ------------------
  726|     35|    coap_delete_resource_lkd(r);
  727|     35|  }
  728|       |
  729|     35|  context->resources = NULL;
  730|       |
  731|     35|  if (context->unknown_resource) {
  ------------------
  |  Branch (731:7): [True: 0, False: 35]
  ------------------
  732|      0|    coap_delete_resource_lkd(context->unknown_resource);
  733|      0|    context->unknown_resource = NULL;
  734|      0|  }
  735|     35|  if (context->proxy_uri_resource) {
  ------------------
  |  Branch (735:7): [True: 0, False: 35]
  ------------------
  736|      0|    coap_delete_resource_lkd(context->proxy_uri_resource);
  737|       |    context->proxy_uri_resource = NULL;
  738|      0|  }
  739|     35|}
coap_get_resource_from_uri_path_lkd:
  754|    134|                                    coap_str_const_t *uri_path) {
  755|    134|  coap_resource_t *result;
  756|       |
  757|    134|  coap_lock_check_locked();
  ------------------
  |  |  638|    134|#define coap_lock_check_locked() {}
  ------------------
  758|       |
  759|    134|  RESOURCES_FIND(context->resources, uri_path, result);
  ------------------
  |  |  199|    134|#define RESOURCES_FIND(r, k, res) {                     \
  |  |  200|    134|    HASH_FIND(hh, (r), (k)->s, (k)->length, (res)); \
  |  |  ------------------
  |  |  |  |  179|    134|#define HASH_FIND(hh,head,keyptr,keylen,out)                                     \
  |  |  |  |  180|    134|do {                                                                             \
  |  |  |  |  181|    134|  (out) = NULL;                                                                  \
  |  |  |  |  182|    134|  if (head) {                                                                    \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (182:7): [True: 99, False: 35]
  |  |  |  |  ------------------
  |  |  |  |  183|     99|    uint32_t _hf_hashv;                                                          \
  |  |  |  |  184|     99|    HASH_VALUE(keyptr, keylen, _hf_hashv);                                       \
  |  |  |  |  ------------------
  |  |  |  |  |  |  162|     99|#define HASH_VALUE(keyptr,keylen,hashv)                                          \
  |  |  |  |  |  |  163|     99|do {                                                                             \
  |  |  |  |  |  |  164|     99|  HASH_FUNCTION(keyptr, keylen, hashv);                                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  102|     99|#define HASH_FUNCTION(keyptr,keylen,hashv) HASH_JEN(keyptr, keylen, hashv)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  658|     99|#define HASH_JEN(key,keylen,hashv)                                               \
  |  |  |  |  |  |  |  |  |  |  659|     99|do {                                                                             \
  |  |  |  |  |  |  |  |  |  |  660|     99|  uint32_t _hj_i,_hj_j,_hj_k;                                                    \
  |  |  |  |  |  |  |  |  |  |  661|     99|  unsigned const char *_hj_key=(unsigned const char*)(key);                      \
  |  |  |  |  |  |  |  |  |  |  662|     99|  hashv = 0xfeedbeefu;                                                           \
  |  |  |  |  |  |  |  |  |  |  663|     99|  _hj_i = _hj_j = 0x9e3779b9u;                                                   \
  |  |  |  |  |  |  |  |  |  |  664|     99|  _hj_k = (uint32_t)(keylen);                                                    \
  |  |  |  |  |  |  |  |  |  |  665|     99|  while (_hj_k >= 12U) {                                                         \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (665:10): [True: 0, False: 99]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  666|      0|    _hj_i = (int64_t)_hj_i + (_hj_key[0] + ( (uint32_t)_hj_key[1] << 8 )         \
  |  |  |  |  |  |  |  |  |  |  667|      0|        + ( (uint32_t)_hj_key[2] << 16 )                                         \
  |  |  |  |  |  |  |  |  |  |  668|      0|        + ( (uint32_t)_hj_key[3] << 24 ) );                                      \
  |  |  |  |  |  |  |  |  |  |  669|      0|    _hj_j = (int64_t)_hj_j + (_hj_key[4] + ( (uint32_t)_hj_key[5] << 8 )         \
  |  |  |  |  |  |  |  |  |  |  670|      0|        + ( (uint32_t)_hj_key[6] << 16 )                                         \
  |  |  |  |  |  |  |  |  |  |  671|      0|        + ( (uint32_t)_hj_key[7] << 24 ) );                                      \
  |  |  |  |  |  |  |  |  |  |  672|      0|    hashv = (int64_t)hashv + (_hj_key[8] + ( (uint32_t)_hj_key[9] << 8 )         \
  |  |  |  |  |  |  |  |  |  |  673|      0|        + ( (uint32_t)_hj_key[10] << 16 )                                        \
  |  |  |  |  |  |  |  |  |  |  674|      0|        + ( (uint32_t)_hj_key[11] << 24 ) );                                     \
  |  |  |  |  |  |  |  |  |  |  675|      0|                                                                                 \
  |  |  |  |  |  |  |  |  |  |  676|      0|     HASH_JEN_MIX(_hj_i, _hj_j, hashv);                                          \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  645|      0|#define HASH_JEN_MIX(a,b,c)                                                      \
  |  |  |  |  |  |  |  |  |  |  |  |  646|      0|do {                                                                             \
  |  |  |  |  |  |  |  |  |  |  |  |  647|      0|  a = (int64_t)a - b; a = (int64_t)a - c; a ^= ( c >> 13 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  648|      0|  b = (int64_t)b - c; b = (int64_t)b - a; b ^= ( a << 8 );                       \
  |  |  |  |  |  |  |  |  |  |  |  |  649|      0|  c = (int64_t)c - a; c = (int64_t)c - b; c ^= ( b >> 13 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  650|      0|  a = (int64_t)a - b; a = (int64_t)a - c; a ^= ( c >> 12 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  651|      0|  b = (int64_t)b - c; b = (int64_t)b - a; b ^= ( a << 16 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  652|      0|  c = (int64_t)c - a; c = (int64_t)c - b; c ^= ( b >> 5 );                       \
  |  |  |  |  |  |  |  |  |  |  |  |  653|      0|  a = (int64_t)a - b; a = (int64_t)a - c; a ^= ( c >> 3 );                       \
  |  |  |  |  |  |  |  |  |  |  |  |  654|      0|  b = (int64_t)b - c; b = (int64_t)b - a; b ^= ( a << 10 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  655|      0|  c = (int64_t)c - a; c = (int64_t)c - b; c ^= ( b >> 15 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  656|      0|} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (656:10): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  677|      0|                                                                                 \
  |  |  |  |  |  |  |  |  |  |  678|      0|     _hj_key += 12;                                                              \
  |  |  |  |  |  |  |  |  |  |  679|      0|     _hj_k -= 12U;                                                               \
  |  |  |  |  |  |  |  |  |  |  680|      0|  }                                                                              \
  |  |  |  |  |  |  |  |  |  |  681|     99|  hashv += (uint32_t)(keylen);                                                   \
  |  |  |  |  |  |  |  |  |  |  682|     99|  switch ( _hj_k ) {                                                             \
  |  |  |  |  |  |  |  |  |  |  683|      0|    case 11: hashv = (int64_t)hashv + ( (uint32_t)_hj_key[10] << 24 ); /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (683:5): [True: 0, False: 99]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  684|      0|    case 10: hashv = (int64_t)hashv + ( (uint32_t)_hj_key[9] << 16 );  /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (684:5): [True: 0, False: 99]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  685|      0|    case 9:  hashv = (int64_t)hashv + ( (uint32_t)_hj_key[8] << 8 );   /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (685:5): [True: 0, False: 99]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  686|      0|    case 8:  _hj_j = (int64_t)_hj_j + ( (uint32_t)_hj_key[7] << 24 );  /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (686:5): [True: 0, False: 99]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  687|      0|    case 7:  _hj_j = (int64_t)_hj_j + ( (uint32_t)_hj_key[6] << 16 );  /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (687:5): [True: 0, False: 99]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  688|      0|    case 6:  _hj_j = (int64_t)_hj_j + ( (uint32_t)_hj_key[5] << 8 );   /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (688:5): [True: 0, False: 99]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  689|      0|    case 5:  _hj_j = (int64_t)_hj_j + _hj_key[4];                      /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (689:5): [True: 0, False: 99]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  690|      0|    case 4:  _hj_i = (int64_t)_hj_i + ( (uint32_t)_hj_key[3] << 24 );  /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (690:5): [True: 0, False: 99]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  691|     98|    case 3:  _hj_i = (int64_t)_hj_i + ( (uint32_t)_hj_key[2] << 16 );  /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (691:5): [True: 98, False: 1]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  692|     98|    case 2:  _hj_i = (int64_t)_hj_i + ( (uint32_t)_hj_key[1] << 8 );   /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (692:5): [True: 0, False: 99]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  693|     98|    case 1:  _hj_i = (int64_t)_hj_i + _hj_key[0];                      /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (693:5): [True: 0, False: 99]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  694|     99|    default: ;                                                                   \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (694:5): [True: 1, False: 98]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  695|     99|  }                                                                              \
  |  |  |  |  |  |  |  |  |  |  696|     99|  HASH_JEN_MIX(_hj_i, _hj_j, hashv);                                             \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  645|     99|#define HASH_JEN_MIX(a,b,c)                                                      \
  |  |  |  |  |  |  |  |  |  |  |  |  646|     99|do {                                                                             \
  |  |  |  |  |  |  |  |  |  |  |  |  647|     99|  a = (int64_t)a - b; a = (int64_t)a - c; a ^= ( c >> 13 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  648|     99|  b = (int64_t)b - c; b = (int64_t)b - a; b ^= ( a << 8 );                       \
  |  |  |  |  |  |  |  |  |  |  |  |  649|     99|  c = (int64_t)c - a; c = (int64_t)c - b; c ^= ( b >> 13 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  650|     99|  a = (int64_t)a - b; a = (int64_t)a - c; a ^= ( c >> 12 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  651|     99|  b = (int64_t)b - c; b = (int64_t)b - a; b ^= ( a << 16 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  652|     99|  c = (int64_t)c - a; c = (int64_t)c - b; c ^= ( b >> 5 );                       \
  |  |  |  |  |  |  |  |  |  |  |  |  653|     99|  a = (int64_t)a - b; a = (int64_t)a - c; a ^= ( c >> 3 );                       \
  |  |  |  |  |  |  |  |  |  |  |  |  654|     99|  b = (int64_t)b - c; b = (int64_t)b - a; b ^= ( a << 10 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  655|     99|  c = (int64_t)c - a; c = (int64_t)c - b; c ^= ( b >> 15 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  656|     99|} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (656:10): [Folded, False: 99]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  697|     99|} while (0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (697:10): [Folded, False: 99]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  165|     99|} while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (165:10): [Folded, False: 99]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  185|     99|    HASH_FIND_BYHASHVALUE(hh, head, keyptr, keylen, _hf_hashv, out);             \
  |  |  |  |  ------------------
  |  |  |  |  |  |  167|     99|#define HASH_FIND_BYHASHVALUE(hh,head,keyptr,keylen,hashval,out)                 \
  |  |  |  |  |  |  168|     99|do {                                                                             \
  |  |  |  |  |  |  169|     99|  (out) = NULL;                                                                  \
  |  |  |  |  |  |  170|     99|  if (head) {                                                                    \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (170:7): [True: 99, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  171|     99|    uint32_t _hf_bkt;                                                            \
  |  |  |  |  |  |  172|     99|    HASH_TO_BKT(hashval, (head)->hh.tbl->num_buckets, _hf_bkt);                  \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  444|     99|#define HASH_TO_BKT(hashv,num_bkts,bkt)                                          \
  |  |  |  |  |  |  |  |  445|     99|do {                                                                             \
  |  |  |  |  |  |  |  |  446|     99|  bkt = ((hashv) & ((num_bkts) - 1U));                                           \
  |  |  |  |  |  |  |  |  447|     99|} while (0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (447:10): [Folded, False: 99]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  173|     99|    if (HASH_BLOOM_TEST((head)->hh.tbl, hashval) != 0) {                         \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  222|     99|#define HASH_BLOOM_TEST(tbl,hashv) (1)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (173:9): [True: 99, Folded]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  174|     99|      HASH_FIND_IN_BKT((head)->hh.tbl, hh, (head)->hh.tbl->buckets[ _hf_bkt ], keyptr, keylen, hashval, out); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  756|     99|#define HASH_FIND_IN_BKT(tbl,hh,head,keyptr,keylen_in,hashval,out)               \
  |  |  |  |  |  |  |  |  757|     99|do {                                                                             \
  |  |  |  |  |  |  |  |  758|     99|  if ((head).hh_head != NULL) {                                                  \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (758:7): [True: 98, False: 1]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  759|     98|    DECLTYPE_ASSIGN(out, ELMT_FROM_HH(tbl, (head).hh_head));                     \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   78|     98|#define DECLTYPE_ASSIGN(dst,src)                                                 \
  |  |  |  |  |  |  |  |  |  |   79|     98|do {                                                                             \
  |  |  |  |  |  |  |  |  |  |   80|     98|  (dst) = DECLTYPE(dst)(src);                                                    \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   66|     98|#define DECLTYPE(x) (__typeof(x))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   81|     98|} while (0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (81:10): [Folded, False: 98]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  760|     98|  } else {                                                                       \
  |  |  |  |  |  |  |  |  761|      1|    (out) = NULL;                                                                \
  |  |  |  |  |  |  |  |  762|      1|  }                                                                              \
  |  |  |  |  |  |  |  |  763|     99|  while ((out) != NULL) {                                                        \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (763:10): [True: 98, False: 1]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  764|     98|    if ((out)->hh.hashv == (hashval) && (out)->hh.keylen == (keylen_in)) {       \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (764:9): [True: 98, False: 0]
  |  |  |  |  |  |  |  |  |  Branch (764:41): [True: 98, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  765|     98|      if (HASH_KEYCMP((out)->hh.key, keyptr, keylen_in) == 0) {                  \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  106|     98|#define HASH_KEYCMP(a,b,n) memcmp(a,b,n)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (765:11): [True: 98, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  766|     98|        break;                                                                   \
  |  |  |  |  |  |  |  |  767|     98|      }                                                                          \
  |  |  |  |  |  |  |  |  768|     98|    }                                                                            \
  |  |  |  |  |  |  |  |  769|     98|    if ((out)->hh.hh_next != NULL) {                                             \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (769:9): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  770|      0|      DECLTYPE_ASSIGN(out, ELMT_FROM_HH(tbl, (out)->hh.hh_next));                \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   78|      0|#define DECLTYPE_ASSIGN(dst,src)                                                 \
  |  |  |  |  |  |  |  |  |  |   79|      0|do {                                                                             \
  |  |  |  |  |  |  |  |  |  |   80|      0|  (dst) = DECLTYPE(dst)(src);                                                    \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   66|      0|#define DECLTYPE(x) (__typeof(x))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   81|      0|} while (0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (81:10): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  771|      0|    } else {                                                                     \
  |  |  |  |  |  |  |  |  772|      0|      (out) = NULL;                                                              \
  |  |  |  |  |  |  |  |  773|      0|    }                                                                            \
  |  |  |  |  |  |  |  |  774|      0|  }                                                                              \
  |  |  |  |  |  |  |  |  775|     99|} while (0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (775:10): [Folded, False: 99]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  175|     99|    }                                                                            \
  |  |  |  |  |  |  176|     99|  }                                                                              \
  |  |  |  |  |  |  177|     99|} while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (177:10): [Folded, False: 99]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  186|     99|  }                                                                              \
  |  |  |  |  187|    134|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (187:10): [Folded, False: 134]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  201|    134|  }
  ------------------
  760|       |
  761|    134|  return result;
  762|    134|}
coap_register_request_handler:
  838|     35|                              coap_method_handler_t handler) {
  839|     35|  assert(resource);
  ------------------
  |  Branch (839:3): [True: 35, False: 0]
  ------------------
  840|     35|  assert(method > 0 && (size_t)(method-1) <
  ------------------
  |  Branch (840:3): [True: 35, False: 0]
  |  Branch (840:3): [True: 35, False: 0]
  ------------------
  841|     35|         sizeof(resource->handler)/sizeof(coap_method_handler_t));
  842|     35|  resource->handler[method-1] = handler;
  843|     35|}
coap_find_observer:
  847|    533|                   const coap_bin_const_t *token) {
  848|    533|  coap_subscription_t *s;
  849|       |
  850|    533|  assert(resource);
  ------------------
  |  Branch (850:3): [True: 533, False: 0]
  ------------------
  851|    533|  assert(session);
  ------------------
  |  Branch (851:3): [True: 533, False: 0]
  ------------------
  852|       |
  853|    533|  LL_FOREACH(resource->subscribers, s) {
  ------------------
  |  |  419|    533|    LL_FOREACH2(head,el,next)
  |  |  ------------------
  |  |  |  |  422|    533|    for ((el) = (head); el; (el) = (el)->next)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (422:25): [True: 310, False: 223]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  854|    310|    if (s->session == session &&
  ------------------
  |  Branch (854:9): [True: 310, False: 0]
  ------------------
  855|    310|        (!token || coap_binary_equal(token, &s->pdu->actual_token)))
  ------------------
  |  |  223|    310|  ((binary1)->length == (binary2)->length && ((binary1)->length == 0 || \
  |  |  ------------------
  |  |  |  Branch (223:4): [True: 310, False: 0]
  |  |  |  Branch (223:47): [True: 56, False: 254]
  |  |  ------------------
  |  |  224|    310|                                              ((binary1)->s && (binary2)->s && \
  |  |  ------------------
  |  |  |  Branch (224:48): [True: 254, False: 0]
  |  |  |  Branch (224:64): [True: 254, False: 0]
  |  |  ------------------
  |  |  225|    254|                                               memcmp((binary1)->s, (binary2)->s, (binary1)->length) == 0)))
  |  |  ------------------
  |  |  |  Branch (225:48): [True: 254, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (855:10): [True: 0, False: 310]
  ------------------
  856|    310|      return s;
  857|    310|  }
  858|       |
  859|    223|  return NULL;
  860|    533|}
coap_add_observer:
  887|    142|                  const coap_pdu_t *request) {
  888|    142|  coap_subscription_t *s;
  889|    142|  coap_cache_key_t *cache_key = NULL;
  890|    142|  size_t len;
  891|    142|  const uint8_t *data;
  892|       |
  893|    142|  assert(session);
  ------------------
  |  Branch (893:3): [True: 142, False: 0]
  ------------------
  894|       |
  895|       |  /* Check if there is already a subscription for this peer. */
  896|    142|  s = coap_find_observer(resource, session, token);
  897|    142|  if (!s) {
  ------------------
  |  Branch (897:7): [True: 142, False: 0]
  ------------------
  898|       |    /*
  899|       |     * Cannot allow a duplicate to be created for the same query as application
  900|       |     * may not be cleaning up duplicates.  If duplicate found, then original
  901|       |     * observer is deleted and a new one created with the new token
  902|       |     */
  903|    142|    cache_key = coap_cache_derive_key_w_ignore(session, request,
  904|    142|                                               COAP_CACHE_IS_SESSION_BASED,
  905|    142|                                               cache_ignore_options,
  906|    142|                                               sizeof(cache_ignore_options)/sizeof(cache_ignore_options[0]));
  907|    142|    if (cache_key) {
  ------------------
  |  Branch (907:9): [True: 142, False: 0]
  ------------------
  908|    142|      s = coap_find_observer_cache_key(resource, session, cache_key);
  909|    142|      if (s) {
  ------------------
  |  Branch (909:11): [True: 0, False: 142]
  ------------------
  910|       |        /* Delete old entry with old token */
  911|      0|        coap_delete_observer(resource, session, &s->pdu->actual_token);
  912|      0|        s = NULL;
  913|      0|      }
  914|    142|    }
  915|    142|  }
  916|       |
  917|       |  /* Refresh the destination when an existing observation is renewed. */
  918|    142|  if (s) {
  ------------------
  |  Branch (918:7): [True: 0, False: 142]
  ------------------
  919|      0|    coap_address_copy(&s->local_if, &session->addr_info.local);
  920|      0|    return s;
  921|      0|  }
  922|       |
  923|       |  /* Check if there is already maximum number of subscribers present */
  924|       |#if (COAP_RESOURCE_MAX_SUBSCRIBER > 0)
  925|       |  uint32_t subscriber_count = 0;
  926|       |  LL_COUNT(resource->subscribers, s, subscriber_count);
  927|       |  if (subscriber_count >= COAP_RESOURCE_MAX_SUBSCRIBER) {
  928|       |    return NULL; /* Signal error */
  929|       |  }
  930|       |#endif /* COAP_RESOURCE_MAX_SUBSCRIBER */
  931|       |
  932|       |  /* Create a new subscription */
  933|    142|  s = coap_malloc_type(COAP_SUBSCRIPTION, sizeof(coap_subscription_t));
  934|       |
  935|    142|  if (!s) {
  ------------------
  |  Branch (935:7): [True: 0, False: 142]
  ------------------
  936|      0|    coap_delete_cache_key(cache_key);
  937|      0|    return NULL;
  938|      0|  }
  939|       |
  940|    142|  coap_subscription_init(s);
  941|    142|  s->pdu = coap_pdu_duplicate_lkd(request, session, token->length,
  942|    142|                                  token->s, NULL, COAP_BOOL_FALSE);
  943|    142|  if (s->pdu == NULL) {
  ------------------
  |  Branch (943:7): [True: 0, False: 142]
  ------------------
  944|      0|    coap_delete_cache_key(cache_key);
  945|      0|    coap_free_type(COAP_SUBSCRIPTION, s);
  946|      0|    return NULL;
  947|      0|  }
  948|    142|  if (coap_get_data(request, &len, &data)) {
  ------------------
  |  Branch (948:7): [True: 0, False: 142]
  ------------------
  949|       |    /* This could be a large bodied FETCH */
  950|      0|    s->pdu->max_size = 0;
  951|      0|    coap_add_data(s->pdu, len, data);
  952|      0|  }
  953|    142|  if (cache_key == NULL) {
  ------------------
  |  Branch (953:7): [True: 0, False: 142]
  ------------------
  954|      0|    cache_key = coap_cache_derive_key_w_ignore(session, request,
  955|      0|                                               COAP_CACHE_IS_SESSION_BASED,
  956|      0|                                               cache_ignore_options,
  957|      0|                                               sizeof(cache_ignore_options)/sizeof(cache_ignore_options[0]));
  958|      0|    if (cache_key == NULL) {
  ------------------
  |  Branch (958:9): [True: 0, False: 0]
  ------------------
  959|      0|      coap_delete_pdu_lkd(s->pdu);
  960|      0|      coap_delete_cache_key(cache_key);
  961|      0|      coap_free_type(COAP_SUBSCRIPTION, s);
  962|      0|      return NULL;
  963|      0|    }
  964|      0|  }
  965|    142|  s->cache_key = cache_key;
  966|    142|  s->session = coap_session_reference_lkd(session);
  967|    142|  coap_address_copy(&s->local_if, &session->addr_info.local);
  968|    142|  session->ref_subscriptions++;
  969|       |
  970|       |  /* add subscriber to resource */
  971|    142|  LL_PREPEND(resource->subscribers, s);
  ------------------
  |  |  320|    142|    LL_PREPEND2(head,add,next)
  |  |  ------------------
  |  |  |  |  322|    142|#define LL_PREPEND2(head,add,next)                                                             \
  |  |  |  |  323|    142|do {                                                                                           \
  |  |  |  |  324|    142|  (add)->next = (head);                                                                        \
  |  |  |  |  325|    142|  (head) = (add);                                                                              \
  |  |  |  |  326|    142|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (326:10): [Folded, False: 142]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  972|       |
  973|    142|  coap_log_debug("create new subscription %p key 0x%02x%02x%02x%02x\n",
  ------------------
  |  |  126|    142|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|    142|#define coap_log(level, ...) do { \
  |  |  |  |  291|    142|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 142]
  |  |  |  |  ------------------
  |  |  |  |  292|    142|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|    142|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 142]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  974|    142|                 (void *)s, s->cache_key->key[0], s->cache_key->key[1],
  975|    142|                 s->cache_key->key[2], s->cache_key->key[3]);
  976|       |
  977|    142|  if (session->context->observe_added_cb && session->proto == COAP_PROTO_UDP &&
  ------------------
  |  Branch (977:7): [True: 0, False: 142]
  |  Branch (977:45): [True: 0, False: 0]
  ------------------
  978|      0|      !coap_is_af_unix(&session->addr_info.local)) {
  ------------------
  |  Branch (978:7): [True: 0, False: 0]
  ------------------
  979|      0|    coap_bin_const_t raw_packet;
  980|      0|    coap_bin_const_t *oscore_info = NULL;
  981|      0|#if COAP_OSCORE_SUPPORT
  982|      0|    oscore_association_t *association;
  983|       |
  984|      0|    if (session->recipient_ctx && session->recipient_ctx->recipient_id) {
  ------------------
  |  Branch (984:9): [True: 0, False: 0]
  |  Branch (984:35): [True: 0, False: 0]
  ------------------
  985|       |      /*
  986|       |       * Need to track the association used for tracking this observe, done as
  987|       |       * a CBOR array. Read in coap_persist_observe_add().
  988|       |       *
  989|       |       * If an entry is null, then use nil, else a set of bytes
  990|       |       *
  991|       |       * Currently tracking 5 items
  992|       |       *  recipient_id
  993|       |       *  id_context
  994|       |       *  aad        (from oscore_association_t)
  995|       |       *  partial_iv (from oscore_association_t)
  996|       |       *  nonce      (from oscore_association_t)
  997|       |       */
  998|      0|      uint8_t info_buffer[60];
  999|      0|      uint8_t *info_buf = info_buffer;
 1000|      0|      size_t info_len = sizeof(info_buffer);
 1001|      0|      size_t ret = 0;
 1002|      0|      coap_bin_const_t ctoken = { token->length, token->s };
 1003|       |
 1004|      0|      ret += oscore_cbor_put_array(&info_buf, &info_len, 5);
 1005|      0|      ret += oscore_cbor_put_bytes(&info_buf,
 1006|      0|                                   &info_len,
 1007|      0|                                   session->recipient_ctx->recipient_id->s,
 1008|      0|                                   session->recipient_ctx->recipient_id->length);
 1009|      0|      if (session->recipient_ctx->osc_ctx &&
  ------------------
  |  Branch (1009:11): [True: 0, False: 0]
  ------------------
 1010|      0|          session->recipient_ctx->osc_ctx->id_context) {
  ------------------
  |  Branch (1010:11): [True: 0, False: 0]
  ------------------
 1011|      0|        ret += oscore_cbor_put_bytes(&info_buf,
 1012|      0|                                     &info_len,
 1013|      0|                                     session->recipient_ctx->osc_ctx->id_context->s,
 1014|      0|                                     session->recipient_ctx->osc_ctx->id_context->length);
 1015|      0|      } else {
 1016|      0|        ret += oscore_cbor_put_nil(&info_buf, &info_len);
 1017|      0|      }
 1018|      0|      association = oscore_find_association(session, &ctoken);
 1019|      0|      if (association) {
  ------------------
  |  Branch (1019:11): [True: 0, False: 0]
  ------------------
 1020|      0|        if (association->aad) {
  ------------------
  |  Branch (1020:13): [True: 0, False: 0]
  ------------------
 1021|      0|          ret += oscore_cbor_put_bytes(&info_buf,
 1022|      0|                                       &info_len,
 1023|      0|                                       association->aad->s,
 1024|      0|                                       association->aad->length);
 1025|      0|        } else {
 1026|      0|          ret += oscore_cbor_put_nil(&info_buf, &info_len);
 1027|      0|        }
 1028|      0|        if (association->partial_iv) {
  ------------------
  |  Branch (1028:13): [True: 0, False: 0]
  ------------------
 1029|      0|          ret += oscore_cbor_put_bytes(&info_buf,
 1030|      0|                                       &info_len,
 1031|      0|                                       association->partial_iv->s,
 1032|      0|                                       association->partial_iv->length);
 1033|      0|        } else {
 1034|      0|          ret += oscore_cbor_put_nil(&info_buf, &info_len);
 1035|      0|        }
 1036|      0|        if (association->nonce) {
  ------------------
  |  Branch (1036:13): [True: 0, False: 0]
  ------------------
 1037|      0|          ret += oscore_cbor_put_bytes(&info_buf,
 1038|      0|                                       &info_len,
 1039|      0|                                       association->nonce->s,
 1040|      0|                                       association->nonce->length);
 1041|      0|        } else {
 1042|      0|          ret += oscore_cbor_put_nil(&info_buf, &info_len);
 1043|      0|        }
 1044|      0|      } else {
 1045|      0|        ret += oscore_cbor_put_nil(&info_buf, &info_len);
 1046|      0|        ret += oscore_cbor_put_nil(&info_buf, &info_len);
 1047|      0|      }
 1048|      0|      if (ret > sizeof(info_buffer)) {
  ------------------
  |  Branch (1048:11): [True: 0, False: 0]
  ------------------
 1049|       |        /* Should have been caught by assert() inoscborput_* functions */
 1050|      0|        coap_log_warn("coap_add_observer overrun of info_buffer (%" PRIuS ")\n", ret);
  ------------------
  |  |  108|      0|#define coap_log_warn(...) coap_log(COAP_LOG_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1051|      0|        ret = sizeof(info_buffer);
 1052|      0|      }
 1053|      0|      oscore_info = coap_new_bin_const(info_buffer, ret);
 1054|      0|    }
 1055|      0|#endif /* COAP_OSCORE_SUPPORT */
 1056|       |
 1057|       |    /* s->pdu header is not currently encoded */
 1058|      0|    memcpy(s->pdu->token - request->hdr_size,
 1059|      0|           request->token - request->hdr_size, request->hdr_size);
 1060|      0|    raw_packet.s = s->pdu->token - request->hdr_size;
 1061|      0|    raw_packet.length = s->pdu->used_size + request->hdr_size;
 1062|      0|    coap_lock_callback(session->context->observe_added_cb(session, s, session->proto,
  ------------------
  |  |  651|      0|#define coap_lock_callback(func) func
  ------------------
 1063|      0|                                                          &session->endpoint->bind_addr,
 1064|      0|                                                          &session->addr_info,
 1065|      0|                                                          &raw_packet,
 1066|      0|                                                          oscore_info,
 1067|      0|                                                          session->context->observe_user_data));
 1068|      0|#if COAP_OSCORE_SUPPORT
 1069|      0|    coap_delete_bin_const(oscore_info);
 1070|      0|#endif /* COAP_OSCORE_SUPPORT */
 1071|      0|  }
 1072|    142|  if (resource->context->track_observe_value_cb) {
  ------------------
  |  Branch (1072:7): [True: 0, False: 142]
  ------------------
 1073|       |    /* Track last used observe value (as app handler is called) */
 1074|      0|    coap_lock_callback(resource->context->track_observe_value_cb(resource->context,resource->uri_path,
  ------------------
  |  |  651|      0|#define coap_lock_callback(func) func
  ------------------
 1075|      0|                       resource->observe,
 1076|      0|                       resource->context->observe_user_data));
 1077|      0|  }
 1078|       |
 1079|    142|  return s;
 1080|    142|}
coap_touch_observer:
 1084|    142|                    const coap_bin_const_t *token) {
 1085|    142|  coap_subscription_t *s;
 1086|       |
 1087|    142|  RESOURCES_ITER(context->resources, r) {
  ------------------
  |  |  193|    142|  coap_resource_t *tmp, *rtmp; \
  |  |  194|    142|  HASH_ITER(hh, (r), tmp, rtmp)
  |  |  ------------------
  |  |  |  | 1071|    142|#define HASH_ITER(hh,head,el,tmp)                                                \
  |  |  |  | 1072|    142|for(((el)=(head)), ((tmp)=DECLTYPE(el)((head!=NULL)?(head)->hh.next:NULL));      \
  |  |  |  |  ------------------
  |  |  |  |  |  |   66|    142|#define DECLTYPE(x) (__typeof(x))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (1072:40): [True: 142, False: 0]
  |  |  |  |  ------------------
  |  |  |  | 1073|    284|  (el) != NULL; ((el)=(tmp)), ((tmp)=DECLTYPE(el)((tmp!=NULL)?(tmp)->hh.next:NULL)))
  |  |  |  |  ------------------
  |  |  |  |  |  |   66|    142|#define DECLTYPE(x) (__typeof(x))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (1073:3): [True: 142, False: 142]
  |  |  |  |  |  Branch (1073:51): [True: 0, False: 142]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1088|    142|    s = coap_find_observer(r, session, token);
 1089|    142|    if (s) {
  ------------------
  |  Branch (1089:9): [True: 142, False: 0]
  ------------------
 1090|    142|      s->fail_cnt = 0;
 1091|    142|    }
 1092|    142|  }
 1093|    142|}
coap_delete_observer_internal:
 1097|     82|                              coap_subscription_t *s) {
 1098|     82|  if (!s)
  ------------------
  |  Branch (1098:7): [True: 21, False: 61]
  ------------------
 1099|     21|    return;
 1100|       |
 1101|     61|  if (coap_get_log_level() >= COAP_LOG_DEBUG) {
  ------------------
  |  Branch (1101:7): [True: 0, False: 61]
  ------------------
 1102|      0|    char outbuf[2 * 8 + 1] = "";
 1103|      0|    unsigned int i;
 1104|      0|    coap_string_t *uri_path;
 1105|      0|    coap_string_t *uri_query;
 1106|       |
 1107|      0|    for (i = 0; i < s->pdu->actual_token.length; i++) {
  ------------------
  |  Branch (1107:17): [True: 0, False: 0]
  ------------------
 1108|      0|      size_t size = strlen(outbuf);
 1109|       |
 1110|      0|      snprintf(&outbuf[size], sizeof(outbuf)-size, "%02x",
 1111|      0|               s->pdu->actual_token.s[i]);
 1112|      0|    }
 1113|      0|    uri_path = coap_get_uri_path(s->pdu);
 1114|      0|    uri_query = coap_get_query(s->pdu);
 1115|      0|    coap_log_debug("removed subscription '/%*.*s%s%*.*s' (%p) with token '%s' key 0x%02x%02x%02x%02x\n",
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (292:30): [True: 0, False: 0]
  |  |  |  |  |  Branch (292:30): [True: 0, False: 0]
  |  |  |  |  |  Branch (292:30): [True: 0, False: 0]
  |  |  |  |  |  Branch (292:30): [True: 0, False: 0]
  |  |  |  |  |  Branch (292:30): [True: 0, False: 0]
  |  |  |  |  |  Branch (292:30): [True: 0, False: 0]
  |  |  |  |  |  Branch (292:30): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1116|      0|                   uri_path ? (int)uri_path->length : 0, uri_path ? (int)uri_path->length : 0,
 1117|      0|                   uri_path ? (char *)uri_path->s : "",
 1118|      0|                   uri_query ? "?" : "",
 1119|      0|                   uri_query ? (int)uri_query->length : 0, uri_query ? (int)uri_query->length : 0,
 1120|      0|                   uri_query ? (char *)uri_query->s : "",
 1121|      0|                   (void *)s, outbuf, s->cache_key->key[0], s->cache_key->key[1],
 1122|      0|                   s->cache_key->key[2], s-> cache_key->key[3]);
 1123|      0|    coap_delete_string(uri_path);
 1124|      0|    coap_delete_string(uri_query);
 1125|      0|  }
 1126|     61|  if (session->context->observe_deleted_cb)
  ------------------
  |  Branch (1126:7): [True: 0, False: 61]
  ------------------
 1127|      0|    coap_lock_callback(session->context->observe_deleted_cb(session, s,
  ------------------
  |  |  651|     61|#define coap_lock_callback(func) func
  ------------------
 1128|     61|                                                            session->context->observe_user_data));
 1129|       |
 1130|     61|  if (resource->subscribers) {
  ------------------
  |  Branch (1130:7): [True: 61, False: 0]
  ------------------
 1131|     61|    LL_DELETE(resource->subscribers, s);
  ------------------
  |  |  391|     61|    LL_DELETE2(head,del,next)
  |  |  ------------------
  |  |  |  |  393|     61|#define LL_DELETE2(head,del,next)                                                              \
  |  |  |  |  394|     61|do {                                                                                           \
  |  |  |  |  395|     61|  LDECLTYPE(head) _tmp;                                                                        \
  |  |  |  |  ------------------
  |  |  |  |  |  |   81|     61|#define LDECLTYPE(x) __typeof(x)
  |  |  |  |  ------------------
  |  |  |  |  396|     61|  if ((head) == (del)) {                                                                       \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (396:7): [True: 61, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  397|     61|    (head)=(head)->next;                                                                       \
  |  |  |  |  398|     61|  } else {                                                                                     \
  |  |  |  |  399|      0|    _tmp = (head);                                                                             \
  |  |  |  |  400|      0|    while (_tmp->next && (_tmp->next != (del))) {                                              \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (400:12): [True: 0, False: 0]
  |  |  |  |  |  Branch (400:26): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  401|      0|      _tmp = _tmp->next;                                                                       \
  |  |  |  |  402|      0|    }                                                                                          \
  |  |  |  |  403|      0|    if (_tmp->next) {                                                                          \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (403:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  404|      0|      _tmp->next = (del)->next;                                                                \
  |  |  |  |  405|      0|    }                                                                                          \
  |  |  |  |  406|      0|  }                                                                                            \
  |  |  |  |  407|     61|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (407:10): [Folded, False: 61]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1132|     61|    assert(session->ref_subscriptions > 0);
  ------------------
  |  Branch (1132:5): [True: 61, False: 0]
  ------------------
 1133|     61|    session->ref_subscriptions--;
 1134|     61|    coap_session_release_lkd(session);
 1135|     61|    coap_delete_pdu_lkd(s->pdu);
 1136|     61|    coap_delete_cache_key(s->cache_key);
 1137|     61|    coap_free_type(COAP_SUBSCRIPTION, s);
 1138|     61|  }
 1139|       |
 1140|     61|  return;
 1141|     61|}
coap_delete_observer:
 1145|    107|                     const coap_bin_const_t *token) {
 1146|    107|  coap_subscription_t *s;
 1147|       |
 1148|    107|  s = coap_find_observer(resource, session, token);
 1149|    107|  if (s)
  ------------------
  |  Branch (1149:7): [True: 47, False: 60]
  ------------------
 1150|     47|    coap_delete_observer_internal(resource, session, s);
 1151|       |
 1152|       |  return s != NULL;
 1153|    107|}
coap_delete_observer_request:
 1157|     35|                             const coap_bin_const_t *token, coap_pdu_t *request, int large_fetch) {
 1158|     35|  coap_subscription_t *s;
 1159|     35|  int ret = 0;
 1160|       |
 1161|     35|  s = coap_find_observer(resource, session, token);
 1162|     35|  if (!s && large_fetch) {
  ------------------
  |  Branch (1162:7): [True: 21, False: 14]
  |  Branch (1162:13): [True: 0, False: 21]
  ------------------
 1163|       |    /*
 1164|       |     * It is possible that the client is using the wrong token.
 1165|       |     * An example being a large FETCH spanning multiple blocks.
 1166|       |     */
 1167|      0|    coap_cache_key_t *cache_key;
 1168|       |
 1169|      0|    cache_key = coap_cache_derive_key_w_ignore(session, request,
 1170|      0|                                               COAP_CACHE_IS_SESSION_BASED,
 1171|      0|                                               cache_ignore_options,
 1172|      0|                                               sizeof(cache_ignore_options)/sizeof(cache_ignore_options[0]));
 1173|      0|    if (cache_key) {
  ------------------
  |  Branch (1173:9): [True: 0, False: 0]
  ------------------
 1174|      0|      s = coap_find_observer_cache_key(resource, session, cache_key);
 1175|      0|      if (s) {
  ------------------
  |  Branch (1175:11): [True: 0, False: 0]
  ------------------
 1176|       |        /* Delete entry with setup token */
 1177|      0|        ret = coap_delete_observer(resource, session, &s->pdu->actual_token);
 1178|      0|      }
 1179|      0|      coap_delete_cache_key(cache_key);
 1180|      0|    }
 1181|     35|  } else {
 1182|     35|    coap_delete_observer_internal(resource, session, s);
 1183|     35|    ret = 1;
 1184|     35|  }
 1185|     35|  return ret;
 1186|     35|}
coap_delete_observers:
 1189|    108|coap_delete_observers(coap_context_t *context, coap_session_t *session) {
 1190|    108|  RESOURCES_ITER(context->resources, resource) {
  ------------------
  |  |  193|    108|  coap_resource_t *tmp, *rtmp; \
  |  |  194|    108|  HASH_ITER(hh, (r), tmp, rtmp)
  |  |  ------------------
  |  |  |  | 1071|    108|#define HASH_ITER(hh,head,el,tmp)                                                \
  |  |  |  | 1072|    108|for(((el)=(head)), ((tmp)=DECLTYPE(el)((head!=NULL)?(head)->hh.next:NULL));      \
  |  |  |  |  ------------------
  |  |  |  |  |  |   66|    108|#define DECLTYPE(x) (__typeof(x))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (1072:40): [True: 108, False: 0]
  |  |  |  |  ------------------
  |  |  |  | 1073|    216|  (el) != NULL; ((el)=(tmp)), ((tmp)=DECLTYPE(el)((tmp!=NULL)?(tmp)->hh.next:NULL)))
  |  |  |  |  ------------------
  |  |  |  |  |  |   66|    108|#define DECLTYPE(x) (__typeof(x))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (1073:3): [True: 108, False: 108]
  |  |  |  |  |  Branch (1073:51): [True: 0, False: 108]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1191|    108|    coap_subscription_t *s, *tmp;
 1192|    108|    LL_FOREACH_SAFE(resource->subscribers, s, tmp) {
  ------------------
  |  |  425|    108|    LL_FOREACH_SAFE2(head,el,tmp,next)
  |  |  ------------------
  |  |  |  |  428|    189|  for ((el) = (head); (el) && ((tmp) = (el)->next, 1); (el) = (tmp))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (428:23): [True: 81, False: 108]
  |  |  |  |  |  Branch (428:31): [True: 81, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1193|     81|      if (s->session == session) {
  ------------------
  |  Branch (1193:11): [True: 81, False: 0]
  ------------------
 1194|     81|        if (context->observe_deleted_cb)
  ------------------
  |  Branch (1194:13): [True: 0, False: 81]
  ------------------
 1195|      0|          coap_lock_callback(context->observe_deleted_cb(session, s, context->observe_user_data));
  ------------------
  |  |  651|     81|#define coap_lock_callback(func) func
  ------------------
 1196|     81|        assert(resource->subscribers);
  ------------------
  |  Branch (1196:9): [True: 81, False: 0]
  ------------------
 1197|     81|        LL_DELETE(resource->subscribers, s);
  ------------------
  |  |  391|     81|    LL_DELETE2(head,del,next)
  |  |  ------------------
  |  |  |  |  393|     81|#define LL_DELETE2(head,del,next)                                                              \
  |  |  |  |  394|     81|do {                                                                                           \
  |  |  |  |  395|     81|  LDECLTYPE(head) _tmp;                                                                        \
  |  |  |  |  ------------------
  |  |  |  |  |  |   81|     81|#define LDECLTYPE(x) __typeof(x)
  |  |  |  |  ------------------
  |  |  |  |  396|     81|  if ((head) == (del)) {                                                                       \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (396:7): [True: 81, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  397|     81|    (head)=(head)->next;                                                                       \
  |  |  |  |  398|     81|  } else {                                                                                     \
  |  |  |  |  399|      0|    _tmp = (head);                                                                             \
  |  |  |  |  400|      0|    while (_tmp->next && (_tmp->next != (del))) {                                              \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (400:12): [True: 0, False: 0]
  |  |  |  |  |  Branch (400:26): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  401|      0|      _tmp = _tmp->next;                                                                       \
  |  |  |  |  402|      0|    }                                                                                          \
  |  |  |  |  403|      0|    if (_tmp->next) {                                                                          \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (403:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  404|      0|      _tmp->next = (del)->next;                                                                \
  |  |  |  |  405|      0|    }                                                                                          \
  |  |  |  |  406|      0|  }                                                                                            \
  |  |  |  |  407|     81|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (407:10): [Folded, False: 81]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1198|     81|        coap_session_release_lkd(session);
 1199|     81|        coap_delete_pdu_lkd(s->pdu);
 1200|     81|        coap_delete_cache_key(s->cache_key);
 1201|     81|        coap_free_type(COAP_SUBSCRIPTION, s);
 1202|     81|      }
 1203|     81|    }
 1204|    108|  }
 1205|    108|}
coap_resource_notify_observers:
 1533|    107|                               const coap_string_t *query) {
 1534|    107|  int ret;
 1535|       |
 1536|    107|  (void)query;
 1537|    107|  coap_lock_lock(return 0);
 1538|    107|  ret = coap_resource_notify_observers_lkd(r, COAP_NOT_DELETING_RESOURCE);
 1539|    107|  coap_lock_unlock();
 1540|    107|  return ret;
 1541|    107|}
coap_resource_notify_observers_lkd:
 1545|    142|                                   coap_deleting_resource_t deleting) {
 1546|    142|  coap_lock_check_locked();
  ------------------
  |  |  638|    142|#define coap_lock_check_locked() {}
  ------------------
 1547|    142|  if (!r->observable)
  ------------------
  |  Branch (1547:7): [True: 0, False: 142]
  ------------------
 1548|      0|    return 0;
 1549|    142|  if (!r->subscribers)
  ------------------
  |  Branch (1549:7): [True: 35, False: 107]
  ------------------
 1550|     35|    return 0;
 1551|    107|  r->dirty = 1;
 1552|       |
 1553|       |  /* Increment value for next Observe use. Observe value must be < 2^24 */
 1554|    107|  r->observe = (r->observe + 1) & 0xFFFFFF;
 1555|       |
 1556|    107|  assert(r->context);
  ------------------
  |  Branch (1556:3): [True: 107, False: 0]
  ------------------
 1557|       |
 1558|    107|  if (r->context->track_observe_value_cb) {
  ------------------
  |  Branch (1558:7): [True: 0, False: 107]
  ------------------
 1559|       |    /* Track last used observe value */
 1560|      0|    if ((r->observe % r->context->observe_save_freq) == 0)
  ------------------
  |  Branch (1560:9): [True: 0, False: 0]
  ------------------
 1561|      0|      coap_lock_callback(r->context->track_observe_value_cb(r->context, r->uri_path,
  ------------------
  |  |  651|      0|#define coap_lock_callback(func) func
  ------------------
 1562|      0|                                                            r->observe,
 1563|      0|                                                            r->context->observe_user_data));
 1564|      0|  }
 1565|       |
 1566|    107|  coap_notify_observers(r->context, r, deleting);
 1567|    107|  return 1;
 1568|    107|}
coap_resource_reference_lkd:
 1683|    219|coap_resource_reference_lkd(coap_resource_t *resource) {
 1684|    219|  resource->ref++;
 1685|    219|}
coap_resource.c:coap_free_resource:
  558|     35|coap_free_resource(coap_resource_t *resource, coap_deleting_resource_t deleting) {
  559|     35|  coap_attr_t *attr, *tmp;
  560|     35|  coap_subscription_t *obs, *otmp;
  561|     35|  coap_context_t *context;
  562|       |
  563|     35|  assert(resource);
  ------------------
  |  Branch (563:3): [True: 35, False: 0]
  ------------------
  564|       |
  565|     35|  context = resource->context;
  566|     35|  if (context) {
  ------------------
  |  Branch (566:7): [True: 35, False: 0]
  ------------------
  567|     35|    if (!context->observe_no_clear) {
  ------------------
  |  Branch (567:9): [True: 35, False: 0]
  ------------------
  568|     35|      coap_resource_notify_observers_lkd(resource, deleting);
  569|     35|      coap_notify_observers(context, resource, deleting);
  570|     35|    }
  571|       |
  572|     35|    if (context->resource_deleted_cb)
  ------------------
  |  Branch (572:9): [True: 0, False: 35]
  ------------------
  573|      0|      coap_lock_callback(context->resource_deleted_cb(context,
  ------------------
  |  |  651|     35|#define coap_lock_callback(func) func
  ------------------
  574|     35|                                                      resource->uri_path,
  575|     35|                                                      context->observe_user_data));
  576|       |
  577|     35|    if (context->release_userdata_cb && resource->user_data) {
  ------------------
  |  Branch (577:9): [True: 0, False: 35]
  |  Branch (577:41): [True: 0, False: 0]
  ------------------
  578|      0|      coap_lock_callback(context->release_userdata_cb(resource->user_data));
  ------------------
  |  |  651|      0|#define coap_lock_callback(func) func
  ------------------
  579|      0|    }
  580|     35|  }
  581|       |
  582|       |  /* delete registered attributes */
  583|     35|  LL_FOREACH_SAFE(resource->link_attr, attr, tmp) coap_delete_attr(attr);
  ------------------
  |  |  425|     35|    LL_FOREACH_SAFE2(head,el,tmp,next)
  |  |  ------------------
  |  |  |  |  428|     35|  for ((el) = (head); (el) && ((tmp) = (el)->next, 1); (el) = (tmp))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (428:23): [True: 0, False: 35]
  |  |  |  |  |  Branch (428:31): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  584|       |
  585|       |  /* Either the application provided or libcoap copied - need to delete it */
  586|     35|  coap_delete_str_const(resource->uri_path);
  587|       |
  588|       |  /* free all elements from resource->subscribers */
  589|     35|  LL_FOREACH_SAFE(resource->subscribers, obs, otmp) {
  ------------------
  |  |  425|     35|    LL_FOREACH_SAFE2(head,el,tmp,next)
  |  |  ------------------
  |  |  |  |  428|     35|  for ((el) = (head); (el) && ((tmp) = (el)->next, 1); (el) = (tmp))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (428:23): [True: 0, False: 35]
  |  |  |  |  |  Branch (428:31): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  590|      0|    coap_delete_observer_internal(resource, obs->session, obs);
  591|      0|  }
  592|     35|  if (resource->proxy_name_count && resource->proxy_name_list) {
  ------------------
  |  Branch (592:7): [True: 0, False: 35]
  |  Branch (592:37): [True: 0, False: 0]
  ------------------
  593|      0|    size_t i;
  594|       |
  595|      0|    for (i = 0; i < resource->proxy_name_count; i++) {
  ------------------
  |  Branch (595:17): [True: 0, False: 0]
  ------------------
  596|      0|      coap_delete_str_const(resource->proxy_name_list[i]);
  597|      0|    }
  598|      0|    coap_free_type(COAP_STRING, resource->proxy_name_list);
  599|      0|  }
  600|       |
  601|     35|  coap_free_type(COAP_RESOURCE, resource);
  602|     35|}
coap_resource.c:coap_find_observer_cache_key:
  864|    142|                             const coap_cache_key_t *cache_key) {
  865|    142|  coap_subscription_t *s;
  866|       |
  867|    142|  assert(resource);
  ------------------
  |  Branch (867:3): [True: 142, False: 0]
  ------------------
  868|    142|  assert(session);
  ------------------
  |  Branch (868:3): [True: 142, False: 0]
  ------------------
  869|       |
  870|    142|  LL_FOREACH(resource->subscribers, s) {
  ------------------
  |  |  419|    142|    LL_FOREACH2(head,el,next)
  |  |  ------------------
  |  |  |  |  422|    142|    for ((el) = (head); el; (el) = (el)->next)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (422:25): [True: 0, False: 142]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  871|      0|    if (s->session == session
  ------------------
  |  Branch (871:9): [True: 0, False: 0]
  ------------------
  872|      0|        && (memcmp(cache_key, s->cache_key, sizeof(coap_cache_key_t)) == 0))
  ------------------
  |  Branch (872:12): [True: 0, False: 0]
  ------------------
  873|      0|      return s;
  874|      0|  }
  875|       |
  876|    142|  return NULL;
  877|    142|}
coap_resource.c:coap_notify_observers:
 1209|    142|                      coap_deleting_resource_t deleting) {
 1210|    142|  coap_method_handler_t h;
 1211|    142|  coap_subscription_t *obs;
 1212|    142|  coap_pdu_t *response;
 1213|    142|  uint8_t buf[4];
 1214|    142|  coap_string_t *query;
 1215|    142|  coap_block_b_t block;
 1216|    142|  coap_tick_t now;
 1217|       |
 1218|    142|  coap_lock_check_locked();
  ------------------
  |  |  638|    142|#define coap_lock_check_locked() {}
  ------------------
 1219|       |
 1220|    142|  if (r->observable && (r->dirty || r->partiallydirty)) {
  ------------------
  |  Branch (1220:7): [True: 142, False: 0]
  |  Branch (1220:25): [True: 107, False: 35]
  |  Branch (1220:37): [True: 14, False: 21]
  ------------------
 1221|    121|    if (r->list_being_traversed)
  ------------------
  |  Branch (1221:9): [True: 0, False: 121]
  ------------------
 1222|      0|      return;
 1223|    121|    r->list_being_traversed = 1;
 1224|       |
 1225|    121|    coap_resource_reference_lkd(r);
 1226|       |
 1227|    121|    r->partiallydirty = 0;
 1228|       |
 1229|       |    /*
 1230|       |     * Any subscription (not just the one being notified) may get deleted
 1231|       |     * in the callback, by another running thread when executing the
 1232|       |     * callback, or when sending a response (e.g. the session fails and all
 1233|       |     * of its subscriptions are deleted). So no pointer into the list is kept
 1234|       |     * over a notification: the next subscription to visit is looked up again
 1235|       |     * from the head of the list each time.
 1236|       |     */
 1237|    121|    LL_FOREACH(r->subscribers, obs) {
  ------------------
  |  |  419|    121|    LL_FOREACH2(head,el,next)
  |  |  ------------------
  |  |  |  |  422|    228|    for ((el) = (head); el; (el) = (el)->next)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (422:25): [True: 107, False: 121]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1238|    107|      obs->to_visit = 1;
 1239|    107|    }
 1240|    228|    for (;;) {
 1241|    228|      coap_session_t *obs_session;
 1242|    228|      coap_pdu_t *obs_pdu;
 1243|    228|      coap_mid_t mid = COAP_INVALID_MID;
  ------------------
  |  |  198|    228|#define COAP_INVALID_MID -1
  ------------------
 1244|       |
 1245|    228|      LL_FOREACH(r->subscribers, obs) {
  ------------------
  |  |  419|    228|    LL_FOREACH2(head,el,next)
  |  |  ------------------
  |  |  |  |  422|    275|    for ((el) = (head); el; (el) = (el)->next)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (422:25): [True: 154, False: 121]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1246|    154|        if (obs->to_visit)
  ------------------
  |  Branch (1246:13): [True: 107, False: 47]
  ------------------
 1247|    107|          break;
 1248|    154|      }
 1249|    228|      if (obs == NULL)
  ------------------
  |  Branch (1249:11): [True: 121, False: 107]
  ------------------
 1250|    121|        break;
 1251|    107|      obs->to_visit = 0;
 1252|       |
 1253|    107|      if ((r->dirty == 0 && obs->dirty == 0) || obs->session->is_rate_limiting) {
  ------------------
  |  Branch (1253:12): [True: 0, False: 107]
  |  Branch (1253:29): [True: 0, False: 0]
  |  Branch (1253:49): [True: 0, False: 107]
  ------------------
 1254|       |        /*
 1255|       |         * running this resource due to partiallydirty, but this observation's
 1256|       |         * notification was already enqueued
 1257|       |         */
 1258|      0|        context->observe_pending = 1;
 1259|      0|        continue;
 1260|      0|      }
 1261|       |
 1262|       |      /*
 1263|       |       * obs may get deleted in the callback, or by another running
 1264|       |       * thread when executing the callback or when sending a response.
 1265|       |       */
 1266|    107|      obs_session = obs->session;
 1267|    107|      obs_pdu = obs->pdu;
 1268|    107|      coap_session_hold_lkd(obs_session);
 1269|    107|      coap_pdu_reference_lkd(obs_pdu);
 1270|       |
 1271|    107|      if (obs->session->con_active >= COAP_NSTART(obs->session) &&
  ------------------
  |  |  876|    214|#define COAP_NSTART(s) ((s)->nstart)
  ------------------
  |  Branch (1271:11): [True: 0, False: 107]
  ------------------
 1272|      0|          ((r->flags & COAP_RESOURCE_FLAGS_NOTIFY_CON) ||
  ------------------
  |  |   69|      0|#define COAP_RESOURCE_FLAGS_NOTIFY_CON  0x2
  ------------------
  |  Branch (1272:12): [True: 0, False: 0]
  ------------------
 1273|      0|           (obs->non_cnt >= COAP_OBS_MAX_NON))) {
  ------------------
  |  |   39|      0|#define COAP_OBS_MAX_NON   5
  ------------------
  |  Branch (1273:12): [True: 0, False: 0]
  ------------------
 1274|       |        /* Waiting for the previous unsolicited response to finish */
 1275|      0|        goto next_one_fail;
 1276|      0|      }
 1277|    107|      coap_ticks(&now);
 1278|    107|      if (obs->session->lg_xmit && obs->session->lg_xmit->last_all_sent == 0 &&
  ------------------
  |  Branch (1278:11): [True: 0, False: 107]
  |  Branch (1278:36): [True: 0, False: 0]
  ------------------
 1279|      0|          obs->session->lg_xmit->last_obs &&
  ------------------
  |  Branch (1279:11): [True: 0, False: 0]
  ------------------
 1280|      0|          (obs->session->lg_xmit->last_obs + 2*COAP_TICKS_PER_SECOND) > now) {
  ------------------
  |  |  164|      0|#define COAP_TICKS_PER_SECOND ((coap_tick_t)(1000U))
  ------------------
  |  Branch (1280:11): [True: 0, False: 0]
  ------------------
 1281|       |        /* Waiting for the previous blocked unsolicited response to finish */
 1282|      0|        goto next_one_fail;
 1283|      0|      }
 1284|       |
 1285|       |      /* Other packets on this session may have changed the local address,
 1286|       |       * including multicast requests from the same peer and source port.
 1287|       |       * Restore it before the handler can register an async response. */
 1288|    107|      coap_address_copy(&obs_session->addr_info.local, &obs->local_if);
 1289|       |
 1290|    107|      obs->dirty = 0;
 1291|       |      /* initialize response */
 1292|    107|      response = coap_pdu_init(COAP_MESSAGE_CON, 0, 0,
 1293|    107|                               coap_session_max_pdu_size_lkd(obs->session));
 1294|    107|      if (!response) {
  ------------------
  |  Branch (1294:11): [True: 0, False: 107]
  ------------------
 1295|      0|        coap_log_debug("coap_check_notify: pdu init failed, resource stays "
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1296|      0|                       "partially dirty\n");
 1297|      0|        goto next_one_fail_no_pending;
 1298|      0|      }
 1299|       |
 1300|    107|      if (!coap_add_token(response, obs->pdu->actual_token.length,
  ------------------
  |  Branch (1300:11): [True: 0, False: 107]
  ------------------
 1301|    107|                          obs->pdu->actual_token.s)) {
 1302|      0|        coap_log_debug("coap_check_notify: cannot add token, resource stays "
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1303|      0|                       "partially dirty\n");
 1304|      0|        coap_delete_pdu_lkd(response);
 1305|      0|        goto next_one_fail_no_pending;
 1306|      0|      }
 1307|       |
 1308|    107|      obs->pdu->mid = response->mid = coap_new_message_id_lkd(obs->session);
 1309|       |      /* A lot of the reliable code assumes type is CON */
 1310|    107|      if (COAP_PROTO_NOT_RELIABLE(obs->session->proto) &&
  ------------------
  |  |   41|    214|#define COAP_PROTO_NOT_RELIABLE(p) ((p)==COAP_PROTO_UDP || (p)==COAP_PROTO_DTLS)
  |  |  ------------------
  |  |  |  Branch (41:37): [True: 107, False: 0]
  |  |  |  Branch (41:60): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1311|    107|          (r->flags & COAP_RESOURCE_FLAGS_NOTIFY_CON) == 0 &&
  ------------------
  |  |   69|    107|#define COAP_RESOURCE_FLAGS_NOTIFY_CON  0x2
  ------------------
  |  Branch (1311:11): [True: 107, False: 0]
  ------------------
 1312|    107|          ((r->flags & COAP_RESOURCE_FLAGS_NOTIFY_NON_ALWAYS) ||
  ------------------
  |  |   79|    107|#define COAP_RESOURCE_FLAGS_NOTIFY_NON_ALWAYS  0x4
  ------------------
  |  Branch (1312:12): [True: 0, False: 107]
  ------------------
 1313|    107|           obs->non_cnt < COAP_OBS_MAX_NON)) {
  ------------------
  |  |   39|    107|#define COAP_OBS_MAX_NON   5
  ------------------
  |  Branch (1313:12): [True: 107, False: 0]
  ------------------
 1314|    107|        response->type = COAP_MESSAGE_NON;
 1315|    107|      } else {
 1316|      0|        response->type = COAP_MESSAGE_CON;
 1317|      0|      }
 1318|    107|      switch (deleting) {
 1319|    107|      case COAP_NOT_DELETING_RESOURCE:
  ------------------
  |  Branch (1319:7): [True: 107, False: 0]
  ------------------
 1320|       |        /* fill with observer-specific data */
 1321|    107|        coap_add_option_internal(response, COAP_OPTION_OBSERVE,
 1322|    107|                                 coap_encode_var_safe(buf, sizeof(buf),
 1323|    107|                                                      r->observe),
 1324|    107|                                 buf);
 1325|    107|        if (coap_get_block_b(obs->session, obs->pdu, COAP_OPTION_BLOCK2,
  ------------------
  |  Branch (1325:13): [True: 0, False: 107]
  ------------------
 1326|    107|                             &block)) {
 1327|       |          /* Will get updated later (e.g. M bit) if appropriate */
 1328|      0|          coap_add_option_internal(response, COAP_OPTION_BLOCK2,
 1329|      0|                                   coap_encode_var_safe(buf, sizeof(buf),
 1330|      0|                                                        ((0 << 4) |
 1331|      0|                                                         (0 << 3) |
 1332|      0|                                                         block.aszx)),
 1333|      0|                                   buf);
 1334|      0|        }
 1335|    107|#if COAP_Q_BLOCK_SUPPORT
 1336|    107|        else if (coap_get_block_b(obs->session, obs->pdu, COAP_OPTION_Q_BLOCK2,
  ------------------
  |  Branch (1336:18): [True: 0, False: 107]
  ------------------
 1337|    107|                                  &block)) {
 1338|       |          /* Will get updated later (e.g. M bit) if appropriate */
 1339|      0|          coap_add_option_internal(response, COAP_OPTION_Q_BLOCK2,
 1340|      0|                                   coap_encode_var_safe(buf, sizeof(buf),
 1341|      0|                                                        ((0 << 4) |
 1342|      0|                                                         (0 << 3) |
 1343|      0|                                                         block.szx)),
 1344|      0|                                   buf);
 1345|      0|        }
 1346|    107|#endif /* COAP_Q_BLOCK_SUPPORT */
 1347|       |
 1348|    107|        h = r->handler[obs->pdu->code - 1];
 1349|    107|        assert(h);      /* we do not allow subscriptions if no
  ------------------
  |  Branch (1349:9): [True: 107, False: 0]
  ------------------
 1350|       |                         * GET/FETCH handler is defined */
 1351|    107|        query = coap_get_query(obs->pdu);
 1352|    107|        coap_log_debug("Observe PDU presented to app.\n");
  ------------------
  |  |  126|    107|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|    107|#define coap_log(level, ...) do { \
  |  |  |  |  291|    107|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 107]
  |  |  |  |  ------------------
  |  |  |  |  292|    107|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|    107|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 107]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1353|    107|        coap_show_pdu(COAP_LOG_DEBUG, obs->pdu);
 1354|    107|        coap_log_debug("call custom handler for resource '%*.*s' (4)\n",
  ------------------
  |  |  126|    107|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|    107|#define coap_log(level, ...) do { \
  |  |  |  |  291|    107|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 107]
  |  |  |  |  ------------------
  |  |  |  |  292|    107|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|    107|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 107]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1355|    107|                       (int)r->uri_path->length, (int)r->uri_path->length,
 1356|    107|                       r->uri_path->s);
 1357|       |
 1358|       |        /* obs may get deleted during callback (potentially by another thread) */
 1359|    107|        if (r->flags & COAP_RESOURCE_SAFE_REQUEST_HANDLER) {
  ------------------
  |  |  181|    107|#define COAP_RESOURCE_SAFE_REQUEST_HANDLER 0x4000
  ------------------
  |  Branch (1359:13): [True: 0, False: 107]
  ------------------
 1360|      0|          coap_lock_callback_release(h(r, obs->session, obs->pdu, query, response),
  ------------------
  |  |  680|      0|#define coap_lock_callback_release(func,failed) func
  ------------------
 1361|       |                                     /* context is being freed off */
 1362|      0|                                     coap_delete_string(query);
 1363|      0|                                     coap_delete_pdu_lkd(response);
 1364|      0|                                     coap_session_release_lkd(obs_session);
 1365|      0|                                     coap_pdu_release_lkd(obs_pdu);
 1366|      0|                                     r->list_being_traversed = 0;
 1367|      0|                                     coap_resource_release_lkd(r);
 1368|      0|                                     return);
 1369|    107|        } else {
 1370|    107|          coap_lock_specific_callback_release(&r->lock,
  ------------------
  |  |  692|    107|#define coap_lock_specific_callback_release(lock,func,failed) func
  ------------------
 1371|    107|                                              h(r, obs->session, obs->pdu, query, response),
 1372|       |                                              /* context is being freed off */
 1373|    107|                                              coap_delete_string(query);
 1374|    107|                                              coap_delete_pdu_lkd(response);
 1375|    107|                                              coap_session_release_lkd(obs_session);
 1376|    107|                                              coap_pdu_release_lkd(obs_pdu);
 1377|    107|                                              r->list_being_traversed = 0;
 1378|    107|                                              coap_resource_release_lkd(r);
 1379|    107|                                              return);
 1380|    107|        }
 1381|       |
 1382|       |        /* Check validity of response code */
 1383|    107|        if (!coap_check_code_class(obs_session, response)) {
  ------------------
  |  Branch (1383:13): [True: 0, False: 107]
  ------------------
 1384|      0|          coap_log_warn("handle_request: Invalid PDU response code (%d.%02d)\n",
  ------------------
  |  |  108|      0|#define coap_log_warn(...) coap_log(COAP_LOG_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1385|      0|                        COAP_RESPONSE_CLASS(response->code),
 1386|      0|                        response->code & 0x1f);
 1387|      0|          coap_delete_string(query);
 1388|      0|          coap_delete_pdu_lkd(response);
 1389|      0|          coap_session_unhold_lkd(obs_session);
 1390|      0|          coap_pdu_release_lkd(obs_pdu);
 1391|      0|          r->list_being_traversed = 0;
 1392|      0|          coap_resource_release_lkd(r);
 1393|      0|          return;
 1394|      0|        }
 1395|       |
 1396|       |        /* Check if lg_xmit generated and update PDU code if so */
 1397|    107|        coap_check_code_lg_xmit(obs_session, obs_pdu, response, r, query);
 1398|    107|        coap_delete_string(query);
 1399|    107|        if (COAP_RESPONSE_CLASS(response->code) != 2) {
  ------------------
  |  |   99|    107|#define COAP_RESPONSE_CLASS(C) (((C) >> 5) & 0xFF)
  ------------------
  |  Branch (1399:13): [True: 0, False: 107]
  ------------------
 1400|      0|          coap_remove_option(response, COAP_OPTION_OBSERVE);
 1401|      0|        }
 1402|    107|        if (COAP_RESPONSE_CLASS(response->code) > 2) {
  ------------------
  |  |   99|    107|#define COAP_RESPONSE_CLASS(C) (((C) >> 5) & 0xFF)
  ------------------
  |  Branch (1402:13): [True: 0, False: 107]
  ------------------
 1403|      0|          coap_delete_observer(r, obs_session, &obs_pdu->actual_token);
 1404|      0|          obs = NULL;
 1405|      0|        }
 1406|    107|        break;
 1407|      0|      case COAP_DELETING_RESOURCE_ON_EXIT:
  ------------------
  |  Branch (1407:7): [True: 0, False: 107]
  ------------------
 1408|       |        /* Don't worry if it does not get there */
 1409|      0|        response->type = COAP_MESSAGE_NON;
 1410|      0|        response->code = COAP_RESPONSE_CODE(503);
  ------------------
  |  |   96|      0|#define COAP_RESPONSE_CODE(N) (((N)/100 << 5) | (N)%100)
  ------------------
 1411|      0|        coap_add_option_internal(response, COAP_OPTION_MAXAGE,
 1412|      0|                                 coap_encode_var_safe(buf, sizeof(buf),
 1413|      0|                                                      30),
 1414|      0|                                 buf);
 1415|      0|        break;
 1416|      0|      case COAP_DELETING_RESOURCE:
  ------------------
  |  Branch (1416:7): [True: 0, False: 107]
  ------------------
 1417|      0|      default:
  ------------------
  |  Branch (1417:7): [True: 0, False: 107]
  ------------------
 1418|       |        /* Don't worry if it does not get there */
 1419|      0|        response->type = COAP_MESSAGE_NON;
 1420|      0|        response->code = COAP_RESPONSE_CODE(404);
  ------------------
  |  |   96|      0|#define COAP_RESPONSE_CODE(N) (((N)/100 << 5) | (N)%100)
  ------------------
 1421|      0|        break;
 1422|    107|      }
 1423|       |
 1424|    107|      if (obs) {
  ------------------
  |  Branch (1424:11): [True: 107, False: 0]
  ------------------
 1425|    107|        coap_subscription_t *s;
 1426|       |        /*
 1427|       |         * obs may have been deleted in the callback, or by another running
 1428|       |         * thread when executing the callback.
 1429|       |         */
 1430|    107|        LL_FOREACH(r->subscribers, s) {
  ------------------
  |  |  419|    107|    LL_FOREACH2(head,el,next)
  |  |  ------------------
  |  |  |  |  422|    107|    for ((el) = (head); el; (el) = (el)->next)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (422:25): [True: 107, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1431|    107|          if (s == obs) {
  ------------------
  |  Branch (1431:15): [True: 107, False: 0]
  ------------------
 1432|    107|            break;
 1433|    107|          }
 1434|    107|        }
 1435|    107|        if (s == NULL)
  ------------------
  |  Branch (1435:13): [True: 0, False: 107]
  ------------------
 1436|      0|          obs = NULL;
 1437|    107|      }
 1438|    107|      if (obs) {
  ------------------
  |  Branch (1438:11): [True: 107, False: 0]
  ------------------
 1439|    107|        if (response->type == COAP_MESSAGE_CON ||
  ------------------
  |  Branch (1439:13): [True: 0, False: 107]
  ------------------
 1440|    107|            (r->flags & COAP_RESOURCE_FLAGS_NOTIFY_NON_ALWAYS)) {
  ------------------
  |  |   79|    107|#define COAP_RESOURCE_FLAGS_NOTIFY_NON_ALWAYS  0x4
  ------------------
  |  Branch (1440:13): [True: 0, False: 107]
  ------------------
 1441|      0|          obs->non_cnt = 0;
 1442|    107|        } else {
 1443|    107|          obs->non_cnt++;
 1444|    107|        }
 1445|       |
 1446|    107|#if COAP_Q_BLOCK_SUPPORT
 1447|    107|        if (response->code == COAP_RESPONSE_CODE(205) &&
  ------------------
  |  |   96|    214|#define COAP_RESPONSE_CODE(N) (((N)/100 << 5) | (N)%100)
  ------------------
  |  Branch (1447:13): [True: 107, False: 0]
  ------------------
 1448|    107|            coap_get_block_b(obs_session, response, COAP_OPTION_Q_BLOCK2,
  ------------------
  |  Branch (1448:13): [True: 0, False: 107]
  ------------------
 1449|    107|                             &block) &&
 1450|      0|            block.m) {
  ------------------
  |  Branch (1450:13): [True: 0, False: 0]
  ------------------
 1451|      0|          query = coap_get_query(obs_pdu);
 1452|      0|          mid = coap_send_q_block2(obs_session, r, query, obs_pdu->code,
 1453|      0|                                   block, response, 1);
 1454|      0|          coap_delete_string(query);
 1455|      0|          goto finish;
 1456|      0|        }
 1457|    107|#endif /* COAP_Q_BLOCK_SUPPORT */
 1458|    107|      }
 1459|    107|      if (response->code == COAP_EMPTY_CODE &&
  ------------------
  |  Branch (1459:11): [True: 0, False: 107]
  ------------------
 1460|      0|          (response->type == COAP_MESSAGE_NON ||
  ------------------
  |  Branch (1460:12): [True: 0, False: 0]
  ------------------
 1461|      0|           response->type == COAP_MESSAGE_CON) &&
  ------------------
  |  Branch (1461:12): [True: 0, False: 0]
  ------------------
 1462|      0|          response->actual_token.length != 0) {
  ------------------
  |  Branch (1462:11): [True: 0, False: 0]
  ------------------
 1463|       |        /*
 1464|       |         * If a resource has been updated, triggering the sending of an
 1465|       |         * observer response and the request handler does not set a response
 1466|       |         * code (a coding error condition), then this PDU must be dropped as
 1467|       |         * it is illegally formatted.
 1468|       |         */
 1469|      0|        coap_delete_pdu_lkd(response);
 1470|      0|        mid = (coap_mid_t)COAP_DROPPED_RESPONSE;
  ------------------
  |  |   92|      0|#define COAP_DROPPED_RESPONSE -2
  ------------------
 1471|    107|      } else {
 1472|    107|        mid = coap_send_internal(obs_session, response, NULL);
 1473|    107|      }
 1474|       |
 1475|    107|#if COAP_Q_BLOCK_SUPPORT
 1476|    107|finish:
 1477|    107|#endif /* COAP_Q_BLOCK_SUPPORT */
 1478|    107|      if (COAP_INVALID_MID == mid) {
  ------------------
  |  |  198|    107|#define COAP_INVALID_MID -1
  ------------------
  |  Branch (1478:11): [True: 60, False: 47]
  ------------------
 1479|     60|        coap_log_debug("*  %s: coap_check_notify: sending failed, resource stays "
  ------------------
  |  |  126|     60|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|     60|#define coap_log(level, ...) do { \
  |  |  |  |  291|     60|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 60]
  |  |  |  |  ------------------
  |  |  |  |  292|     60|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|     60|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 60]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1480|     60|                       "partially dirty\n", coap_session_str(obs_session));
 1481|     60|        if (obs) {
  ------------------
  |  Branch (1481:13): [True: 60, False: 0]
  ------------------
 1482|     60|          coap_subscription_t *s;
 1483|       |          /*
 1484|       |           * obs may have been deleted in coap_send_internal() or
 1485|       |           * coap_send_q_block2().
 1486|       |           */
 1487|     60|          LL_FOREACH(r->subscribers, s) {
  ------------------
  |  |  419|     60|    LL_FOREACH2(head,el,next)
  |  |  ------------------
  |  |  |  |  422|     60|    for ((el) = (head); el; (el) = (el)->next)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (422:25): [True: 60, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1488|     60|            if (s == obs) {
  ------------------
  |  Branch (1488:17): [True: 60, False: 0]
  ------------------
 1489|     60|              break;
 1490|     60|            }
 1491|     60|          }
 1492|     60|          if (s == NULL)
  ------------------
  |  Branch (1492:15): [True: 0, False: 60]
  ------------------
 1493|      0|            obs = NULL;
 1494|     60|        }
 1495|     60|        if (obs)
  ------------------
  |  Branch (1495:13): [True: 60, False: 0]
  ------------------
 1496|     60|          obs->dirty = 1;
 1497|     60|        r->partiallydirty = 1;
 1498|     60|      }
 1499|    107|      goto cleanup;
 1500|       |
 1501|      0|next_one_fail:
 1502|      0|      context->observe_pending = 1;
 1503|      0|next_one_fail_no_pending:
 1504|      0|      r->partiallydirty = 1;
 1505|      0|      if (obs)
  ------------------
  |  Branch (1505:11): [True: 0, False: 0]
  ------------------
 1506|      0|        obs->dirty = 1;
 1507|    107|cleanup:
 1508|    107|      coap_session_unhold_lkd(obs_session);
 1509|    107|      coap_pdu_release_lkd(obs_pdu);
 1510|    107|    }
 1511|    121|    r->list_being_traversed = 0;
 1512|    121|    r->dirty = 0;
 1513|    121|    coap_resource_release_lkd(r);
 1514|       |    /* r may be no more if elsewhere coap_free_resource() has been called */
 1515|    121|  } else {
 1516|     21|    r->dirty = 0;
 1517|     21|  }
 1518|    142|}

coap_multi_fixed_fixed:
   34|     70|coap_multi_fixed_fixed(coap_fixed_point_t fp1, coap_fixed_point_t fp2) {
   35|     70|  coap_fixed_point_t res;
   36|     70|  uint32_t fr = fp1.fractional_part * fp2.fractional_part;
   37|       |
   38|     70|  res.integer_part = fp1.integer_part * fp2.integer_part + fr/1000;
   39|     70|  res.fractional_part = fr % 1000;
   40|     70|  return res;
   41|     70|}
coap_multi_fixed_uint:
   44|     70|coap_multi_fixed_uint(coap_fixed_point_t fp1, uint32_t u2) {
   45|     70|  coap_fixed_point_t res;
   46|     70|  uint32_t fr = fp1.fractional_part * u2;
   47|       |
   48|     70|  res.integer_part = fp1.integer_part * u2 + fr/1000;
   49|     70|  res.fractional_part = fr % 1000;
   50|     70|  return res;
   51|     70|}
coap_add_fixed_fixed:
   54|     35|coap_add_fixed_fixed(coap_fixed_point_t fp1, coap_fixed_point_t fp2) {
   55|     35|  coap_fixed_point_t res;
   56|     35|  uint32_t fr = fp1.fractional_part + fp2.fractional_part;
   57|       |
   58|     35|  res.integer_part = fp1.integer_part + fp2.integer_part + fr/1000;
   59|     35|  res.fractional_part = fr % 1000;
   60|     35|  return res;
   61|     35|}
coap_add_fixed_uint:
   64|     70|coap_add_fixed_uint(coap_fixed_point_t fp1, uint32_t u2) {
   65|     70|  coap_fixed_point_t res = fp1;
   66|       |
   67|     70|  res.integer_part += u2;
   68|     70|  return res;
   69|     70|}
coap_session_reference_lkd:
  362|    422|coap_session_reference_lkd(coap_session_t *session) {
  363|    422|  ++session->ref;
  364|    422|  return session;
  365|    422|}
coap_session_release_lkd:
  382|    387|coap_session_release_lkd(coap_session_t *session) {
  383|    387|  if (session) {
  ------------------
  |  Branch (383:7): [True: 387, False: 0]
  ------------------
  384|    387|    coap_lock_check_locked();
  ------------------
  |  |  638|    387|#define coap_lock_check_locked() {}
  ------------------
  385|    387|#ifndef __COVERITY__
  386|    387|    assert(session->ref > 0);
  ------------------
  |  Branch (386:5): [True: 387, False: 0]
  ------------------
  387|    387|    if (session->ref > 0)
  ------------------
  |  Branch (387:9): [True: 387, False: 0]
  ------------------
  388|    387|      --session->ref;
  389|    387|    if (session->ref == 0 && session->type == COAP_SESSION_TYPE_CLIENT)
  ------------------
  |  Branch (389:9): [True: 35, False: 352]
  |  Branch (389:30): [True: 35, False: 0]
  ------------------
  390|     35|      coap_session_free(session);
  391|       |#else /* __COVERITY__ */
  392|       |    /* Coverity scan is fooled by the reference counter leading to
  393|       |     * false positives for USE_AFTER_FREE. */
  394|       |    --session->ref;
  395|       |    __coverity_negative_sink__(session->ref);
  396|       |    /* Indicate that resources are released properly. */
  397|       |    if (session->ref == 0 && session->type == COAP_SESSION_TYPE_CLIENT) {
  398|       |      __coverity_free__(session);
  399|       |    }
  400|       |#endif /* __COVERITY__ */
  401|    387|  }
  402|    387|}
coap_session_hold_lkd:
  405|    210|coap_session_hold_lkd(coap_session_t *session) {
  406|    210|  if (session) {
  ------------------
  |  Branch (406:7): [True: 210, False: 0]
  ------------------
  407|    210|    coap_lock_check_locked();
  ------------------
  |  |  638|    210|#define coap_lock_check_locked() {}
  ------------------
  408|    210|    coap_session_reference_lkd(session);
  409|    210|    session->hold_in_use++;
  410|    210|  }
  411|    210|}
coap_session_unhold_lkd:
  414|    210|coap_session_unhold_lkd(coap_session_t *session) {
  415|    210|  if (session) {
  ------------------
  |  Branch (415:7): [True: 210, False: 0]
  ------------------
  416|    210|    coap_lock_check_locked();
  ------------------
  |  |  638|    210|#define coap_lock_check_locked() {}
  ------------------
  417|    210|    assert(session->hold_in_use > 0);
  ------------------
  |  Branch (417:5): [True: 210, False: 0]
  ------------------
  418|    210|    if (session->hold_in_use == 1 && session->disconnect_pending &&
  ------------------
  |  Branch (418:9): [True: 210, False: 0]
  |  Branch (418:38): [True: 108, False: 102]
  ------------------
  419|    108|        !session->disconnecting) {
  ------------------
  |  Branch (419:9): [True: 108, False: 0]
  ------------------
  420|    108|      session->disconnect_pending = 0;
  421|    108|      coap_session_disconnected_do_it_lkd(session, session->disconnect_reason);
  422|    108|    }
  423|    210|    if (session->hold_in_use > 0)
  ------------------
  |  Branch (423:9): [True: 210, False: 0]
  ------------------
  424|    210|      session->hold_in_use--;
  425|    210|    coap_session_release_lkd(session);
  426|    210|  }
  427|    210|}
coap_session_mfree:
  559|     35|coap_session_mfree(coap_session_t *session) {
  560|     35|  coap_queue_t *q;
  561|     35|  coap_lg_xmit_t *lq, *ltmp;
  562|       |
  563|     35|#if COAP_PROXY_SUPPORT
  564|     35|  if (session->ref_proxy_subs)
  ------------------
  |  Branch (564:7): [True: 0, False: 35]
  ------------------
  565|      0|    coap_delete_proxy_subscriber(session, NULL, 0, COAP_PROXY_SUBS_ALL);
  566|     35|#endif /* COAP_PROXY_SUPPORT */
  567|     35|#if COAP_CLIENT_SUPPORT
  568|     35|  coap_lg_crcv_t *lg_crcv, *etmp;
  569|       |
  570|       |  /* Need to do this before (D)TLS and socket is closed down */
  571|     35|  LL_FOREACH_SAFE(session->lg_crcv, lg_crcv, etmp) {
  ------------------
  |  |  425|     35|    LL_FOREACH_SAFE2(head,el,tmp,next)
  |  |  ------------------
  |  |  |  |  428|     35|  for ((el) = (head); (el) && ((tmp) = (el)->next, 1); (el) = (tmp))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (428:23): [True: 0, False: 35]
  |  |  |  |  |  Branch (428:31): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  572|      0|    if (lg_crcv->observe_set && session->no_observe_cancel == 0) {
  ------------------
  |  Branch (572:9): [True: 0, False: 0]
  |  Branch (572:33): [True: 0, False: 0]
  ------------------
  573|       |      /* Need to close down observe */
  574|      0|      if (coap_cancel_observe_lkd(session, lg_crcv->app_token, COAP_MESSAGE_NON)) {
  ------------------
  |  Branch (574:11): [True: 0, False: 0]
  ------------------
  575|       |        /* Need to delete node we set up for NON */
  576|      0|        coap_queue_t *queue = session->context->sendqueue;
  577|       |
  578|      0|        while (queue) {
  ------------------
  |  Branch (578:16): [True: 0, False: 0]
  ------------------
  579|      0|          if (queue->session == session) {
  ------------------
  |  Branch (579:15): [True: 0, False: 0]
  ------------------
  580|      0|            coap_delete_node_lkd(queue);
  581|      0|            break;
  582|      0|          }
  583|      0|          queue = queue->next;
  584|      0|        }
  585|      0|      }
  586|      0|    }
  587|       |    /* In case coap_cancel_observe_lkd() failure, which could clear down lg_crcv */
  588|      0|    if (!session->lg_crcv)
  ------------------
  |  Branch (588:9): [True: 0, False: 0]
  ------------------
  589|      0|      break;
  590|      0|    LL_DELETE(session->lg_crcv, lg_crcv);
  ------------------
  |  |  391|      0|    LL_DELETE2(head,del,next)
  |  |  ------------------
  |  |  |  |  393|      0|#define LL_DELETE2(head,del,next)                                                              \
  |  |  |  |  394|      0|do {                                                                                           \
  |  |  |  |  395|      0|  LDECLTYPE(head) _tmp;                                                                        \
  |  |  |  |  ------------------
  |  |  |  |  |  |   81|      0|#define LDECLTYPE(x) __typeof(x)
  |  |  |  |  ------------------
  |  |  |  |  396|      0|  if ((head) == (del)) {                                                                       \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (396:7): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  397|      0|    (head)=(head)->next;                                                                       \
  |  |  |  |  398|      0|  } else {                                                                                     \
  |  |  |  |  399|      0|    _tmp = (head);                                                                             \
  |  |  |  |  400|      0|    while (_tmp->next && (_tmp->next != (del))) {                                              \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (400:12): [True: 0, False: 0]
  |  |  |  |  |  Branch (400:26): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  401|      0|      _tmp = _tmp->next;                                                                       \
  |  |  |  |  402|      0|    }                                                                                          \
  |  |  |  |  403|      0|    if (_tmp->next) {                                                                          \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (403:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  404|      0|      _tmp->next = (del)->next;                                                                \
  |  |  |  |  405|      0|    }                                                                                          \
  |  |  |  |  406|      0|  }                                                                                            \
  |  |  |  |  407|      0|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (407:10): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  591|      0|    coap_block_delete_lg_crcv(session, lg_crcv);
  592|      0|  }
  593|     35|#endif /* COAP_CLIENT_SUPPORT */
  594|       |
  595|     35|  while ((q = coap_remove_first_from_delayq(session)) != NULL) {
  ------------------
  |  Branch (595:10): [True: 0, False: 35]
  ------------------
  596|      0|    if (q->pdu->type==COAP_MESSAGE_CON) {
  ------------------
  |  Branch (596:9): [True: 0, False: 0]
  ------------------
  597|      0|      coap_handle_nack(session, q->pdu,
  598|      0|                       session->proto == COAP_PROTO_DTLS ?
  ------------------
  |  Branch (598:24): [True: 0, False: 0]
  ------------------
  599|      0|                       COAP_NACK_TLS_FAILED : COAP_NACK_NOT_DELIVERABLE,
  600|      0|                       q->id);
  601|      0|    }
  602|      0|    coap_delete_node_lkd(q);
  603|      0|  }
  604|       |
  605|     35|#if COAP_CLIENT_SUPPORT
  606|     35|  coap_pdu_t *p, *ptmp;
  607|       |
  608|     35|  LL_FOREACH_SAFE(session->doing_first_pdu, p, ptmp) {
  ------------------
  |  |  425|     35|    LL_FOREACH_SAFE2(head,el,tmp,next)
  |  |  ------------------
  |  |  |  |  428|     35|  for ((el) = (head); (el) && ((tmp) = (el)->next, 1); (el) = (tmp))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (428:23): [True: 0, False: 35]
  |  |  |  |  |  Branch (428:31): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  609|      0|    if (p->type==COAP_MESSAGE_CON) {
  ------------------
  |  Branch (609:9): [True: 0, False: 0]
  ------------------
  610|      0|      coap_handle_nack(session, p,
  611|      0|                       session->proto == COAP_PROTO_DTLS ?
  ------------------
  |  Branch (611:24): [True: 0, False: 0]
  ------------------
  612|      0|                       COAP_NACK_TLS_FAILED : COAP_NACK_NOT_DELIVERABLE,
  613|      0|                       p->mid);
  614|      0|    }
  615|      0|    coap_delete_pdu_lkd(p);
  616|      0|  }
  617|     35|#endif /* COAP_CLIENT_SUPPORT */
  618|       |
  619|     35|  if (session->partial_pdu)
  ------------------
  |  Branch (619:7): [True: 0, False: 35]
  ------------------
  620|      0|    coap_delete_pdu_lkd(session->partial_pdu);
  621|     35|  if (session->sock.lfunc[COAP_LAYER_SESSION].l_close)
  ------------------
  |  Branch (621:7): [True: 35, False: 0]
  ------------------
  622|     35|    session->sock.lfunc[COAP_LAYER_SESSION].l_close(session);
  623|     35|  if (session->psk_identity)
  ------------------
  |  Branch (623:7): [True: 0, False: 35]
  ------------------
  624|      0|    coap_delete_bin_const(session->psk_identity);
  625|     35|  if (session->psk_key)
  ------------------
  |  Branch (625:7): [True: 0, False: 35]
  ------------------
  626|      0|    coap_delete_bin_const(session->psk_key);
  627|     35|  if (session->psk_hint)
  ------------------
  |  Branch (627:7): [True: 0, False: 35]
  ------------------
  628|      0|    coap_delete_bin_const(session->psk_hint);
  629|       |
  630|     35|#ifdef HAVE_LINUX_ERRQUEUE_H
  631|     35|  coap_delete_str_const(session->last_data_write);
  632|     35|#endif /* HAVE_LINUX_ERRQUEUE_H */
  633|       |
  634|     35|#if COAP_SERVER_SUPPORT
  635|     35|  coap_cache_entry_t *cp, *ctmp;
  636|     35|  HASH_ITER(hh, session->context->cache, cp, ctmp) {
  ------------------
  |  | 1071|     35|#define HASH_ITER(hh,head,el,tmp)                                                \
  |  | 1072|     35|for(((el)=(head)), ((tmp)=DECLTYPE(el)((head!=NULL)?(head)->hh.next:NULL));      \
  |  |  ------------------
  |  |  |  |   66|     35|#define DECLTYPE(x) (__typeof(x))
  |  |  ------------------
  |  |  |  Branch (1072:40): [True: 0, False: 35]
  |  |  ------------------
  |  | 1073|     35|  (el) != NULL; ((el)=(tmp)), ((tmp)=DECLTYPE(el)((tmp!=NULL)?(tmp)->hh.next:NULL)))
  |  |  ------------------
  |  |  |  |   66|      0|#define DECLTYPE(x) (__typeof(x))
  |  |  ------------------
  |  |  |  Branch (1073:3): [True: 0, False: 35]
  |  |  |  Branch (1073:51): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  637|       |    /* cp->session is NULL if not session based */
  638|      0|    if (cp->session == session) {
  ------------------
  |  Branch (638:9): [True: 0, False: 0]
  ------------------
  639|      0|      coap_delete_cache_entry(session->context, cp);
  640|      0|    }
  641|      0|  }
  642|     35|#endif /* COAP_PROXY_SUPPORT */
  643|     35|  LL_FOREACH_SAFE(session->lg_xmit, lq, ltmp) {
  ------------------
  |  |  425|     35|    LL_FOREACH_SAFE2(head,el,tmp,next)
  |  |  ------------------
  |  |  |  |  428|     35|  for ((el) = (head); (el) && ((tmp) = (el)->next, 1); (el) = (tmp))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (428:23): [True: 0, False: 35]
  |  |  |  |  |  Branch (428:31): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  644|      0|    LL_DELETE(session->lg_xmit, lq);
  ------------------
  |  |  391|      0|    LL_DELETE2(head,del,next)
  |  |  ------------------
  |  |  |  |  393|      0|#define LL_DELETE2(head,del,next)                                                              \
  |  |  |  |  394|      0|do {                                                                                           \
  |  |  |  |  395|      0|  LDECLTYPE(head) _tmp;                                                                        \
  |  |  |  |  ------------------
  |  |  |  |  |  |   81|      0|#define LDECLTYPE(x) __typeof(x)
  |  |  |  |  ------------------
  |  |  |  |  396|      0|  if ((head) == (del)) {                                                                       \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (396:7): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  397|      0|    (head)=(head)->next;                                                                       \
  |  |  |  |  398|      0|  } else {                                                                                     \
  |  |  |  |  399|      0|    _tmp = (head);                                                                             \
  |  |  |  |  400|      0|    while (_tmp->next && (_tmp->next != (del))) {                                              \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (400:12): [True: 0, False: 0]
  |  |  |  |  |  Branch (400:26): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  401|      0|      _tmp = _tmp->next;                                                                       \
  |  |  |  |  402|      0|    }                                                                                          \
  |  |  |  |  403|      0|    if (_tmp->next) {                                                                          \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (403:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  404|      0|      _tmp->next = (del)->next;                                                                \
  |  |  |  |  405|      0|    }                                                                                          \
  |  |  |  |  406|      0|  }                                                                                            \
  |  |  |  |  407|      0|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (407:10): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  645|      0|    coap_block_delete_lg_xmit(session, lq);
  646|      0|  }
  647|     35|#if COAP_SERVER_SUPPORT
  648|     35|  coap_lg_srcv_t *sq, *stmp;
  649|       |
  650|     35|  LL_FOREACH_SAFE(session->lg_srcv, sq, stmp) {
  ------------------
  |  |  425|     35|    LL_FOREACH_SAFE2(head,el,tmp,next)
  |  |  ------------------
  |  |  |  |  428|     35|  for ((el) = (head); (el) && ((tmp) = (el)->next, 1); (el) = (tmp))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (428:23): [True: 0, False: 35]
  |  |  |  |  |  Branch (428:31): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  651|      0|    LL_DELETE(session->lg_srcv, sq);
  ------------------
  |  |  391|      0|    LL_DELETE2(head,del,next)
  |  |  ------------------
  |  |  |  |  393|      0|#define LL_DELETE2(head,del,next)                                                              \
  |  |  |  |  394|      0|do {                                                                                           \
  |  |  |  |  395|      0|  LDECLTYPE(head) _tmp;                                                                        \
  |  |  |  |  ------------------
  |  |  |  |  |  |   81|      0|#define LDECLTYPE(x) __typeof(x)
  |  |  |  |  ------------------
  |  |  |  |  396|      0|  if ((head) == (del)) {                                                                       \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (396:7): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  397|      0|    (head)=(head)->next;                                                                       \
  |  |  |  |  398|      0|  } else {                                                                                     \
  |  |  |  |  399|      0|    _tmp = (head);                                                                             \
  |  |  |  |  400|      0|    while (_tmp->next && (_tmp->next != (del))) {                                              \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (400:12): [True: 0, False: 0]
  |  |  |  |  |  Branch (400:26): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  401|      0|      _tmp = _tmp->next;                                                                       \
  |  |  |  |  402|      0|    }                                                                                          \
  |  |  |  |  403|      0|    if (_tmp->next) {                                                                          \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (403:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  404|      0|      _tmp->next = (del)->next;                                                                \
  |  |  |  |  405|      0|    }                                                                                          \
  |  |  |  |  406|      0|  }                                                                                            \
  |  |  |  |  407|      0|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (407:10): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  652|      0|    coap_block_delete_lg_srcv(session, sq);
  653|      0|  }
  654|     35|#endif /* COAP_SERVER_SUPPORT */
  655|     35|#if COAP_OSCORE_SUPPORT
  656|     35|  coap_delete_oscore_associations(session);
  657|     35|  oscore_release_recipient_ctx(&session->recipient_ctx);
  658|     35|  coap_delete_str_const(session->b_2_retransmit_token);
  659|     35|#endif /* COAP_OSCORE_SUPPORT */
  660|     35|#if COAP_WS_SUPPORT
  661|     35|  if (session->ws)
  ------------------
  |  Branch (661:7): [True: 0, False: 35]
  ------------------
  662|      0|    coap_free_type(COAP_STRING, session->ws->rd_data);
  663|     35|  coap_free_type(COAP_STRING, session->ws);
  664|     35|  coap_delete_str_const(session->ws_host);
  665|     35|#endif /* COAP_WS_SUPPORT */
  666|     35|}
coap_session_free:
  669|     35|coap_session_free(coap_session_t *session) {
  670|     35|  if (!session)
  ------------------
  |  Branch (670:7): [True: 0, False: 35]
  ------------------
  671|      0|    return;
  672|     35|  coap_lock_check_locked();
  ------------------
  |  |  638|     35|#define coap_lock_check_locked() {}
  ------------------
  673|     35|  assert(session->ref == 0);
  ------------------
  |  Branch (673:3): [True: 35, False: 0]
  ------------------
  674|     35|  if (session->ref)
  ------------------
  |  Branch (674:7): [True: 0, False: 35]
  ------------------
  675|      0|    return;
  676|       |  /* Make sure nothing gets deleted under our feet */
  677|     35|  coap_session_reference_lkd(session);
  678|     35|  coap_session_mfree(session);
  679|     35|#if COAP_SERVER_SUPPORT
  680|     35|  coap_delete_bin_const(session->client_cid);
  681|     35|  if (session->endpoint) {
  ------------------
  |  Branch (681:7): [True: 0, False: 35]
  ------------------
  682|      0|    if (session->endpoint->sessions)
  ------------------
  |  Branch (682:9): [True: 0, False: 0]
  ------------------
  683|      0|      SESSIONS_DELETE(session->endpoint->sessions, session);
  ------------------
  |  | 1017|      0|  HASH_DELETE(hh, (e), (obj))
  |  |  ------------------
  |  |  |  |  462|      0|    HASH_DELETE_HH(hh, head, &(delptr)->hh)
  |  |  |  |  ------------------
  |  |  |  |  |  |  464|      0|#define HASH_DELETE_HH(hh,head,delptrhh)                                         \
  |  |  |  |  |  |  465|      0|do {                                                                             \
  |  |  |  |  |  |  466|      0|  struct UT_hash_handle *_hd_hh_del = (delptrhh);                                \
  |  |  |  |  |  |  467|      0|  if ((_hd_hh_del->prev == NULL) && (_hd_hh_del->next == NULL)) {                \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (467:7): [True: 0, False: 0]
  |  |  |  |  |  |  |  Branch (467:37): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  468|      0|    HASH_BLOOM_FREE((head)->hh.tbl);                                             \
  |  |  |  |  |  |  469|      0|    uthash_free((head)->hh.tbl->buckets,                                         \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   92|      0|#define uthash_free(ptr,sz) free(ptr)     /* free fcn                        */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  470|      0|                (head)->hh.tbl->num_buckets * sizeof(struct UT_hash_bucket));    \
  |  |  |  |  |  |  471|      0|    uthash_free((head)->hh.tbl, sizeof(UT_hash_table));                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   92|      0|#define uthash_free(ptr,sz) free(ptr)     /* free fcn                        */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  472|      0|    (head) = NULL;                                                               \
  |  |  |  |  |  |  473|      0|  } else {                                                                       \
  |  |  |  |  |  |  474|      0|    uint32_t _hd_bkt;                                                            \
  |  |  |  |  |  |  475|      0|    if (_hd_hh_del == (head)->hh.tbl->tail) {                                    \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (475:9): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  476|      0|      (head)->hh.tbl->tail = HH_FROM_ELMT((head)->hh.tbl, _hd_hh_del->prev);     \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  150|      0|#define HH_FROM_ELMT(tbl,elp) ((UT_hash_handle*)(void*)(((char*)(elp)) + ((tbl)->hho)))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  477|      0|    }                                                                            \
  |  |  |  |  |  |  478|      0|    if (_hd_hh_del->prev != NULL) {                                              \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (478:9): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  479|      0|      HH_FROM_ELMT((head)->hh.tbl, _hd_hh_del->prev)->next = _hd_hh_del->next;   \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  150|      0|#define HH_FROM_ELMT(tbl,elp) ((UT_hash_handle*)(void*)(((char*)(elp)) + ((tbl)->hho)))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  480|      0|    } else {                                                                     \
  |  |  |  |  |  |  481|      0|      DECLTYPE_ASSIGN(head, _hd_hh_del->next);                                   \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   78|      0|#define DECLTYPE_ASSIGN(dst,src)                                                 \
  |  |  |  |  |  |  |  |   79|      0|do {                                                                             \
  |  |  |  |  |  |  |  |   80|      0|  (dst) = DECLTYPE(dst)(src);                                                    \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   66|      0|#define DECLTYPE(x) (__typeof(x))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   81|      0|} while (0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (81:10): [Folded, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  482|      0|    }                                                                            \
  |  |  |  |  |  |  483|      0|    if (_hd_hh_del->next != NULL) {                                              \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (483:9): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  484|      0|      HH_FROM_ELMT((head)->hh.tbl, _hd_hh_del->next)->prev = _hd_hh_del->prev;   \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  150|      0|#define HH_FROM_ELMT(tbl,elp) ((UT_hash_handle*)(void*)(((char*)(elp)) + ((tbl)->hho)))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  485|      0|    }                                                                            \
  |  |  |  |  |  |  486|      0|    HASH_TO_BKT(_hd_hh_del->hashv, (head)->hh.tbl->num_buckets, _hd_bkt);        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  444|      0|#define HASH_TO_BKT(hashv,num_bkts,bkt)                                          \
  |  |  |  |  |  |  |  |  445|      0|do {                                                                             \
  |  |  |  |  |  |  |  |  446|      0|  bkt = ((hashv) & ((num_bkts) - 1U));                                           \
  |  |  |  |  |  |  |  |  447|      0|} while (0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (447:10): [Folded, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  487|      0|    HASH_DEL_IN_BKT((head)->hh.tbl->buckets[_hd_bkt], _hd_hh_del);               \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  800|      0|#define HASH_DEL_IN_BKT(head,delhh)                                              \
  |  |  |  |  |  |  |  |  801|      0|do {                                                                             \
  |  |  |  |  |  |  |  |  802|      0|  UT_hash_bucket *_hd_head = &(head);                                            \
  |  |  |  |  |  |  |  |  803|      0|  _hd_head->count--;                                                             \
  |  |  |  |  |  |  |  |  804|      0|  if (_hd_head->hh_head == (delhh)) {                                            \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (804:7): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  805|      0|    _hd_head->hh_head = (delhh)->hh_next;                                        \
  |  |  |  |  |  |  |  |  806|      0|  }                                                                              \
  |  |  |  |  |  |  |  |  807|      0|  if ((delhh)->hh_prev) {                                                        \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (807:7): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  808|      0|    (delhh)->hh_prev->hh_next = (delhh)->hh_next;                                \
  |  |  |  |  |  |  |  |  809|      0|  }                                                                              \
  |  |  |  |  |  |  |  |  810|      0|  if ((delhh)->hh_next) {                                                        \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (810:7): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  811|      0|    (delhh)->hh_next->hh_prev = (delhh)->hh_prev;                                \
  |  |  |  |  |  |  |  |  812|      0|  }                                                                              \
  |  |  |  |  |  |  |  |  813|      0|} while (0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (813:10): [Folded, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  488|      0|    (head)->hh.tbl->num_items--;                                                 \
  |  |  |  |  |  |  489|      0|  }                                                                              \
  |  |  |  |  |  |  490|      0|  HASH_FSCK(hh, head, "HASH_DELETE_HH");                                         \
  |  |  |  |  |  |  491|      0|} while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (491:10): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  684|      0|  } else
  685|     35|#endif /* COAP_SERVER_SUPPORT */
  686|     35|#if COAP_CLIENT_SUPPORT
  687|     35|    if (session->context) {
  ------------------
  |  Branch (687:9): [True: 35, False: 0]
  ------------------
  688|     35|      if (session->context->sessions)
  ------------------
  |  Branch (688:11): [True: 35, False: 0]
  ------------------
  689|     35|        SESSIONS_DELETE(session->context->sessions, session);
  ------------------
  |  | 1017|     35|  HASH_DELETE(hh, (e), (obj))
  |  |  ------------------
  |  |  |  |  462|     35|    HASH_DELETE_HH(hh, head, &(delptr)->hh)
  |  |  |  |  ------------------
  |  |  |  |  |  |  464|     35|#define HASH_DELETE_HH(hh,head,delptrhh)                                         \
  |  |  |  |  |  |  465|     35|do {                                                                             \
  |  |  |  |  |  |  466|     35|  struct UT_hash_handle *_hd_hh_del = (delptrhh);                                \
  |  |  |  |  |  |  467|     35|  if ((_hd_hh_del->prev == NULL) && (_hd_hh_del->next == NULL)) {                \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (467:7): [True: 35, False: 0]
  |  |  |  |  |  |  |  Branch (467:37): [True: 35, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  468|     35|    HASH_BLOOM_FREE((head)->hh.tbl);                                             \
  |  |  |  |  |  |  469|     35|    uthash_free((head)->hh.tbl->buckets,                                         \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   92|     35|#define uthash_free(ptr,sz) free(ptr)     /* free fcn                        */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  470|     35|                (head)->hh.tbl->num_buckets * sizeof(struct UT_hash_bucket));    \
  |  |  |  |  |  |  471|     35|    uthash_free((head)->hh.tbl, sizeof(UT_hash_table));                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   92|     35|#define uthash_free(ptr,sz) free(ptr)     /* free fcn                        */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  472|     35|    (head) = NULL;                                                               \
  |  |  |  |  |  |  473|     35|  } else {                                                                       \
  |  |  |  |  |  |  474|      0|    uint32_t _hd_bkt;                                                            \
  |  |  |  |  |  |  475|      0|    if (_hd_hh_del == (head)->hh.tbl->tail) {                                    \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (475:9): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  476|      0|      (head)->hh.tbl->tail = HH_FROM_ELMT((head)->hh.tbl, _hd_hh_del->prev);     \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  150|      0|#define HH_FROM_ELMT(tbl,elp) ((UT_hash_handle*)(void*)(((char*)(elp)) + ((tbl)->hho)))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  477|      0|    }                                                                            \
  |  |  |  |  |  |  478|      0|    if (_hd_hh_del->prev != NULL) {                                              \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (478:9): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  479|      0|      HH_FROM_ELMT((head)->hh.tbl, _hd_hh_del->prev)->next = _hd_hh_del->next;   \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  150|      0|#define HH_FROM_ELMT(tbl,elp) ((UT_hash_handle*)(void*)(((char*)(elp)) + ((tbl)->hho)))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  480|      0|    } else {                                                                     \
  |  |  |  |  |  |  481|      0|      DECLTYPE_ASSIGN(head, _hd_hh_del->next);                                   \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   78|      0|#define DECLTYPE_ASSIGN(dst,src)                                                 \
  |  |  |  |  |  |  |  |   79|      0|do {                                                                             \
  |  |  |  |  |  |  |  |   80|      0|  (dst) = DECLTYPE(dst)(src);                                                    \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   66|      0|#define DECLTYPE(x) (__typeof(x))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   81|      0|} while (0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (81:10): [Folded, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  482|      0|    }                                                                            \
  |  |  |  |  |  |  483|      0|    if (_hd_hh_del->next != NULL) {                                              \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (483:9): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  484|      0|      HH_FROM_ELMT((head)->hh.tbl, _hd_hh_del->next)->prev = _hd_hh_del->prev;   \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  150|      0|#define HH_FROM_ELMT(tbl,elp) ((UT_hash_handle*)(void*)(((char*)(elp)) + ((tbl)->hho)))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  485|      0|    }                                                                            \
  |  |  |  |  |  |  486|      0|    HASH_TO_BKT(_hd_hh_del->hashv, (head)->hh.tbl->num_buckets, _hd_bkt);        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  444|      0|#define HASH_TO_BKT(hashv,num_bkts,bkt)                                          \
  |  |  |  |  |  |  |  |  445|      0|do {                                                                             \
  |  |  |  |  |  |  |  |  446|      0|  bkt = ((hashv) & ((num_bkts) - 1U));                                           \
  |  |  |  |  |  |  |  |  447|      0|} while (0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (447:10): [Folded, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  487|      0|    HASH_DEL_IN_BKT((head)->hh.tbl->buckets[_hd_bkt], _hd_hh_del);               \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  800|      0|#define HASH_DEL_IN_BKT(head,delhh)                                              \
  |  |  |  |  |  |  |  |  801|      0|do {                                                                             \
  |  |  |  |  |  |  |  |  802|      0|  UT_hash_bucket *_hd_head = &(head);                                            \
  |  |  |  |  |  |  |  |  803|      0|  _hd_head->count--;                                                             \
  |  |  |  |  |  |  |  |  804|      0|  if (_hd_head->hh_head == (delhh)) {                                            \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (804:7): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  805|      0|    _hd_head->hh_head = (delhh)->hh_next;                                        \
  |  |  |  |  |  |  |  |  806|      0|  }                                                                              \
  |  |  |  |  |  |  |  |  807|      0|  if ((delhh)->hh_prev) {                                                        \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (807:7): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  808|      0|    (delhh)->hh_prev->hh_next = (delhh)->hh_next;                                \
  |  |  |  |  |  |  |  |  809|      0|  }                                                                              \
  |  |  |  |  |  |  |  |  810|      0|  if ((delhh)->hh_next) {                                                        \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (810:7): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  811|      0|    (delhh)->hh_next->hh_prev = (delhh)->hh_prev;                                \
  |  |  |  |  |  |  |  |  812|      0|  }                                                                              \
  |  |  |  |  |  |  |  |  813|      0|} while (0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (813:10): [Folded, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  488|      0|    (head)->hh.tbl->num_items--;                                                 \
  |  |  |  |  |  |  489|      0|  }                                                                              \
  |  |  |  |  |  |  490|     35|  HASH_FSCK(hh, head, "HASH_DELETE_HH");                                         \
  |  |  |  |  |  |  491|     35|} while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (491:10): [Folded, False: 35]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  690|     35|    }
  691|     35|  coap_delete_bin_const(session->req_token);
  692|     35|#endif /* COAP_CLIENT_SUPPORT */
  693|     35|  coap_delete_bin_const(session->last_token);
  694|     35|  coap_delete_bin_const(session->echo);
  695|     35|#if COAP_SERVER_SUPPORT
  696|     35|  coap_delete_pdu_lkd(session->last_resp_pdu);
  697|     35|#endif /* COAP_SERVER_SUPPORT */
  698|       |
  699|     35|  if (session->app_cb) {
  ------------------
  |  Branch (699:7): [True: 0, False: 35]
  ------------------
  700|      0|    coap_lock_callback(session->app_cb(session->app_data));
  ------------------
  |  |  651|      0|#define coap_lock_callback(func) func
  ------------------
  701|      0|  }
  702|     35|  coap_log_debug("***%s: session %p: closed\n", coap_session_str(session),
  ------------------
  |  |  126|     35|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|     35|#define coap_log(level, ...) do { \
  |  |  |  |  291|     35|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 35]
  |  |  |  |  ------------------
  |  |  |  |  292|     35|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|     35|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 35]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  703|     35|                 (void *)session);
  704|     35|  assert(session->ref == 1);
  ------------------
  |  Branch (704:3): [True: 35, False: 0]
  ------------------
  705|     35|  coap_free_type(COAP_SESSION, session);
  706|     35|}
coap_session_max_pdu_rcv_size:
  777|     19|coap_session_max_pdu_rcv_size(const coap_session_t *session) {
  778|     19|  if (session->csm_rcv_mtu) {
  ------------------
  |  Branch (778:7): [True: 0, False: 19]
  ------------------
  779|      0|#if COAP_WS_SUPPORT
  780|      0|    if (session->proto == COAP_PROTO_WS || session->proto == COAP_PROTO_WSS)
  ------------------
  |  Branch (780:9): [True: 0, False: 0]
  |  Branch (780:44): [True: 0, False: 0]
  ------------------
  781|      0|      return session->csm_rcv_mtu > COAP_PDU_WS_HEADER_SIZE ?
  ------------------
  |  |  109|      0|#define COAP_PDU_WS_HEADER_SIZE 2
  ------------------
  |  Branch (781:14): [True: 0, False: 0]
  ------------------
  782|      0|             session->csm_rcv_mtu - COAP_PDU_WS_HEADER_SIZE : 0;
  ------------------
  |  |  109|      0|#define COAP_PDU_WS_HEADER_SIZE 2
  ------------------
  783|      0|#endif /* COAP_WS_SUPPORT */
  784|      0|    return coap_session_max_pdu_size_internal(session,
  785|      0|                                              (size_t)(session->csm_rcv_mtu));
  786|      0|  }
  787|       |
  788|     19|  return coap_session_max_pdu_size_internal(session,
  789|     19|                                            (size_t)(session->mtu - session->tls_overhead));
  790|     19|}
coap_session_max_pdu_size:
  793|     52|coap_session_max_pdu_size(const coap_session_t *session) {
  794|     52|  size_t size;
  795|     52|  coap_session_t *session_rw;
  796|       |
  797|       |  /*
  798|       |   * Need to do this to not get a compiler warning about const parameters
  799|       |   * but need to maintain source code backward compatibility
  800|       |   */
  801|     52|  memcpy(&session_rw, &session, sizeof(session_rw));
  802|     52|  coap_lock_lock(return 0);
  803|     52|  size = coap_session_max_pdu_size_lkd(session_rw);
  804|     52|  coap_lock_unlock();
  805|     52|  return size;
  806|     52|}
coap_session_max_pdu_size_lkd:
  809|    259|coap_session_max_pdu_size_lkd(const coap_session_t *session) {
  810|    259|  size_t max_with_header;
  811|       |
  812|    259|  coap_lock_check_locked();
  ------------------
  |  |  638|    259|#define coap_lock_check_locked() {}
  ------------------
  813|    259|#if COAP_CLIENT_SUPPORT
  814|    259|  if (COAP_PROTO_RELIABLE(session->proto) &&
  ------------------
  |  |   42|    518|#define COAP_PROTO_RELIABLE(p) ((p)==COAP_PROTO_TCP || (p)==COAP_PROTO_TLS || \
  |  |  ------------------
  |  |  |  Branch (42:33): [True: 0, False: 259]
  |  |  |  Branch (42:56): [True: 0, False: 259]
  |  |  ------------------
  |  |   43|    259|                                (p)==COAP_PROTO_WS || (p)==COAP_PROTO_WSS)
  |  |  ------------------
  |  |  |  Branch (43:33): [True: 0, False: 259]
  |  |  |  Branch (43:55): [True: 0, False: 259]
  |  |  ------------------
  ------------------
  815|      0|      session->type == COAP_SESSION_TYPE_CLIENT &&
  ------------------
  |  Branch (815:7): [True: 0, False: 0]
  ------------------
  816|      0|      session->doing_first) {
  ------------------
  |  Branch (816:7): [True: 0, False: 0]
  ------------------
  817|       |    /*
  818|       |     * Delay if session->doing_first is set.
  819|       |     * E.g. Reliable and CSM not in yet for checking block support
  820|       |     */
  821|      0|    coap_session_t *session_rw;
  822|       |
  823|       |    /*
  824|       |     * Need to do this to not get a compiler warning about const parameters
  825|       |     * but need to maintain source code backward compatibility
  826|       |     */
  827|      0|    memcpy(&session_rw, &session, sizeof(session_rw));
  828|      0|    if (coap_client_delay_first(session_rw) == 0) {
  ------------------
  |  Branch (828:9): [True: 0, False: 0]
  ------------------
  829|      0|      coap_log_debug("coap_client_delay_first: timeout\n");
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  830|       |      /* Have to go with the defaults */
  831|      0|    }
  832|      0|  }
  833|    259|#endif /* COAP_CLIENT_SUPPORT */
  834|       |
  835|    259|  max_with_header = (size_t)(session->mtu - session->tls_overhead);
  836|       |
  837|    259|  return coap_session_max_pdu_size_internal(session, max_with_header);
  838|    259|}
coap_session_set_mtu:
  841|     35|coap_session_set_mtu(coap_session_t *session, unsigned mtu) {
  842|     35|  if (mtu > COAP_DEFAULT_MAX_PDU_RX_SIZE) {
  ------------------
  |  |   84|     35|#define COAP_DEFAULT_MAX_PDU_RX_SIZE (8UL*1024*1024+256)
  ------------------
  |  Branch (842:7): [True: 0, False: 35]
  ------------------
  843|      0|    mtu = COAP_DEFAULT_MAX_PDU_RX_SIZE;
  ------------------
  |  |   84|      0|#define COAP_DEFAULT_MAX_PDU_RX_SIZE (8UL*1024*1024+256)
  ------------------
  844|      0|    coap_log_debug("*  %s: Restricting MTU size to %u\n",
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  845|      0|                   coap_session_str(session), mtu);
  846|      0|  }
  847|     35|  if (mtu < 64)
  ------------------
  |  Branch (847:7): [True: 0, False: 35]
  ------------------
  848|      0|    mtu = 64;
  849|     35|  session->mtu = mtu;
  850|     35|  if (session->tls_overhead >= session->mtu) {
  ------------------
  |  Branch (850:7): [True: 0, False: 35]
  ------------------
  851|      0|    session->tls_overhead = session->mtu;
  852|      0|    coap_log_err("DTLS overhead exceeds MTU\n");
  ------------------
  |  |  102|      0|#define coap_log_err(...) coap_log(COAP_LOG_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  853|      0|  }
  854|     35|}
coap_session_connected:
 1005|     35|coap_session_connected(coap_session_t *session) {
 1006|     35|  if (session->state != COAP_SESSION_STATE_ESTABLISHED) {
  ------------------
  |  Branch (1006:7): [True: 35, False: 0]
  ------------------
 1007|     35|    coap_log_debug("***%s: session connected\n",
  ------------------
  |  |  126|     35|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|     35|#define coap_log(level, ...) do { \
  |  |  |  |  291|     35|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 35]
  |  |  |  |  ------------------
  |  |  |  |  292|     35|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|     35|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 35]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1008|     35|                   coap_session_str(session));
 1009|     35|    if (session->state == COAP_SESSION_STATE_CSM) {
  ------------------
  |  Branch (1009:9): [True: 0, False: 35]
  ------------------
 1010|      0|      coap_handle_event_lkd(session->context, COAP_EVENT_SESSION_CONNECTED, session);
 1011|      0|#if COAP_CLIENT_SUPPORT
 1012|      0|      coap_session_reestablished(session);
 1013|      0|      coap_reset_doing_first(session);
 1014|      0|#endif /* COAP_CLIENT_SUPPORT */
 1015|      0|    }
 1016|     35|  }
 1017|       |
 1018|     35|  session->state = COAP_SESSION_STATE_ESTABLISHED;
 1019|     35|  session->partial_write = 0;
 1020|       |
 1021|     35|  if (session->proto==COAP_PROTO_DTLS) {
  ------------------
  |  Branch (1021:7): [True: 0, False: 35]
  ------------------
 1022|      0|    session->tls_overhead = coap_dtls_get_overhead(session);
 1023|      0|    if (session->tls_overhead >= session->mtu) {
  ------------------
  |  Branch (1023:9): [True: 0, False: 0]
  ------------------
 1024|      0|      session->tls_overhead = session->mtu;
 1025|      0|      coap_log_err("DTLS overhead exceeds MTU\n");
  ------------------
  |  |  102|      0|#define coap_log_err(...) coap_log(COAP_LOG_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1026|      0|    }
 1027|      0|  }
 1028|       |
 1029|     35|  while (session->delayqueue && session->state == COAP_SESSION_STATE_ESTABLISHED &&
  ------------------
  |  Branch (1029:10): [True: 0, False: 35]
  |  Branch (1029:33): [True: 0, False: 0]
  ------------------
 1030|      0|         !session->disconnect_pending) {
  ------------------
  |  Branch (1030:10): [True: 0, False: 0]
  ------------------
 1031|      0|    ssize_t bytes_written;
 1032|      0|    coap_queue_t *q = session->delayqueue;
 1033|      0|    coap_address_t remote;
 1034|       |
 1035|      0|    if (q->pdu->type == COAP_MESSAGE_CON && COAP_PROTO_NOT_RELIABLE(session->proto)) {
  ------------------
  |  |   41|      0|#define COAP_PROTO_NOT_RELIABLE(p) ((p)==COAP_PROTO_UDP || (p)==COAP_PROTO_DTLS)
  |  |  ------------------
  |  |  |  Branch (41:37): [True: 0, False: 0]
  |  |  |  Branch (41:60): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (1035:9): [True: 0, False: 0]
  ------------------
 1036|      0|      if (session->con_active >= COAP_NSTART(session))
  ------------------
  |  |  876|      0|#define COAP_NSTART(s) ((s)->nstart)
  ------------------
  |  Branch (1036:11): [True: 0, False: 0]
  ------------------
 1037|      0|        break;
 1038|      0|      session->con_active++;
 1039|      0|    }
 1040|       |    /* Take entry off the queue */
 1041|      0|    q = coap_remove_first_from_delayq(session);
 1042|       |
 1043|      0|    coap_address_copy(&remote, &session->addr_info.remote);
 1044|      0|    coap_address_copy(&session->addr_info.remote, &q->remote);
 1045|      0|    coap_log_debug("** %s: mid=0x%04x: transmitted after delay (2)\n",
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1046|      0|                   coap_session_str(session), (int)q->id);
 1047|      0|    bytes_written = coap_session_send_pdu(session, q->pdu);
 1048|      0|    if (q->pdu->type == COAP_MESSAGE_CON && COAP_PROTO_NOT_RELIABLE(session->proto)) {
  ------------------
  |  |   41|      0|#define COAP_PROTO_NOT_RELIABLE(p) ((p)==COAP_PROTO_UDP || (p)==COAP_PROTO_DTLS)
  |  |  ------------------
  |  |  |  Branch (41:37): [True: 0, False: 0]
  |  |  |  Branch (41:60): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (1048:9): [True: 0, False: 0]
  ------------------
 1049|      0|      if (coap_wait_ack(session->context, session, q) >= 0)
  ------------------
  |  Branch (1049:11): [True: 0, False: 0]
  ------------------
 1050|      0|        q = NULL;
 1051|      0|    }
 1052|      0|    coap_address_copy(&session->addr_info.remote, &remote);
 1053|      0|    if (COAP_PROTO_NOT_RELIABLE(session->proto)) {
  ------------------
  |  |   41|      0|#define COAP_PROTO_NOT_RELIABLE(p) ((p)==COAP_PROTO_UDP || (p)==COAP_PROTO_DTLS)
  |  |  ------------------
  |  |  |  Branch (41:37): [True: 0, False: 0]
  |  |  |  Branch (41:60): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1054|      0|      if (q)
  ------------------
  |  Branch (1054:11): [True: 0, False: 0]
  ------------------
 1055|      0|        coap_delete_node_lkd(q);
 1056|      0|      if (bytes_written < 0)
  ------------------
  |  Branch (1056:11): [True: 0, False: 0]
  ------------------
 1057|      0|        break;
 1058|      0|    } else if (q) {
  ------------------
  |  Branch (1058:16): [True: 0, False: 0]
  ------------------
 1059|      0|      if (bytes_written <= 0 || (size_t)bytes_written < q->pdu->used_size + q->pdu->hdr_size) {
  ------------------
  |  Branch (1059:11): [True: 0, False: 0]
  |  Branch (1059:33): [True: 0, False: 0]
  ------------------
 1060|      0|        coap_add_to_head_delayq(session, q);
 1061|      0|        if (bytes_written > 0)
  ------------------
  |  Branch (1061:13): [True: 0, False: 0]
  ------------------
 1062|      0|          session->partial_write = (size_t)bytes_written;
 1063|      0|        break;
 1064|      0|      } else {
 1065|      0|        coap_delete_node_lkd(q);
 1066|      0|      }
 1067|      0|    }
 1068|      0|  }
 1069|     35|}
coap_handle_nack:
 1103|    110|                 const coap_mid_t mid) {
 1104|    110|  if (session->context->nack_cb
  ------------------
  |  Branch (1104:7): [True: 0, False: 110]
  ------------------
 1105|      0|#if COAP_CLIENT_SUPPORT
 1106|      0|      && !session->doing_first_pdu
  ------------------
  |  Branch (1106:10): [True: 0, False: 0]
  ------------------
 1107|    110|#endif /* COAP_CLIENT_SUPPORT */
 1108|    110|     ) {
 1109|      0|    coap_bin_const_t token = {0, NULL};
 1110|       |
 1111|      0|    if (sent) {
  ------------------
  |  Branch (1111:9): [True: 0, False: 0]
  ------------------
 1112|      0|      coap_check_update_token(session, sent);
 1113|      0|      token = sent->actual_token;
 1114|      0|    }
 1115|      0|    coap_lock_callback(session->context->nack_cb(session, sent, reason, mid));
  ------------------
  |  |  651|      0|#define coap_lock_callback(func) func
  ------------------
 1116|      0|    if (sent) {
  ------------------
  |  Branch (1116:9): [True: 0, False: 0]
  ------------------
 1117|      0|      coap_update_token(sent, token.length, token.s);
 1118|      0|    }
 1119|      0|  }
 1120|    110|#if COAP_CLIENT_SUPPORT
 1121|    110|  if (reason != COAP_NACK_ICMP_ISSUE) {
  ------------------
  |  Branch (1121:7): [True: 110, False: 0]
  ------------------
 1122|    110|    session->doing_send_recv = 0;
 1123|    110|  }
 1124|    110|#endif /* COAP_CLIENT_SUPPORT */
 1125|    110|}
coap_session_disconnected_lkd:
 1136|    108|                              coap_nack_reason_t reason) {
 1137|    108|  coap_lock_check_locked();
  ------------------
  |  |  638|    108|#define coap_lock_check_locked() {}
  ------------------
 1138|    108|  if (session->hold_in_use == 0 && !session->disconnecting) {
  ------------------
  |  Branch (1138:7): [True: 0, False: 108]
  |  Branch (1138:36): [True: 0, False: 0]
  ------------------
 1139|      0|    coap_session_disconnected_do_it_lkd(session, reason);
 1140|      0|    return;
 1141|      0|  }
 1142|    108|  if (!session->disconnect_pending) {
  ------------------
  |  Branch (1142:7): [True: 108, False: 0]
  ------------------
 1143|    108|    coap_log_debug("***%s: session in use, disconnect deferred\n",
  ------------------
  |  |  126|    108|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|    108|#define coap_log(level, ...) do { \
  |  |  |  |  291|    108|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 108]
  |  |  |  |  ------------------
  |  |  |  |  292|    108|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|    108|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 108]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1144|    108|                   coap_session_str(session));
 1145|    108|    session->disconnect_pending = 1;
 1146|    108|    session->disconnect_reason = reason;
 1147|    108|  }
 1148|    108|#if COAP_CLIENT_SUPPORT
 1149|       |  /* Any coap_send_recv() waiting on this session returns now */
 1150|    108|  session->doing_send_recv = 0;
 1151|    108|#endif /* COAP_CLIENT_SUPPORT */
 1152|    108|}
coap_session_disconnected_do_it_lkd:
 1155|    108|coap_session_disconnected_do_it_lkd(coap_session_t *session, coap_nack_reason_t reason) {
 1156|    108|#if !COAP_DISABLE_TCP
 1157|    108|  coap_session_state_t state = session->state;
 1158|    108|#endif /* !COAP_DISABLE_TCP */
 1159|    108|  coap_lg_xmit_t *lq, *ltmp;
 1160|    108|#if COAP_SERVER_SUPPORT
 1161|    108|  coap_lg_srcv_t *sq, *stmp;
 1162|    108|#endif /* COAP_SERVER_SUPPORT */
 1163|    108|#if COAP_CLIENT_SUPPORT
 1164|    108|  coap_lg_crcv_t *cq, *etmp;
 1165|    108|#endif /* COAP_CLIENT_SUPPORT */
 1166|    108|  int sent_nack = 0;
 1167|    108|  uint8_t disconnecting = session->disconnecting;
 1168|    108|  coap_queue_t *q;
 1169|       |
 1170|    108|  coap_lock_check_locked();
  ------------------
  |  |  638|    108|#define coap_lock_check_locked() {}
  ------------------
 1171|       |  /*
 1172|       |   * A disconnect asked for from within the callbacks below does not
 1173|       |   * disconnect the session again.
 1174|       |   */
 1175|    108|  session->disconnecting = 1;
 1176|    108|#if COAP_CLIENT_SUPPORT
 1177|    108|  coap_session_failed(session);
 1178|    108|#endif /* COAP_CLIENT_SUPPORT */
 1179|       |
 1180|    108|  q = session->context->sendqueue;
 1181|    108|  while (q) {
  ------------------
  |  Branch (1181:10): [True: 0, False: 108]
  ------------------
 1182|      0|    if (q->session == session) {
  ------------------
  |  Branch (1182:9): [True: 0, False: 0]
  ------------------
 1183|       |      /* Take the first one */
 1184|      0|      coap_handle_nack(session, q->pdu, reason, q->id);
 1185|      0|      sent_nack = 1;
 1186|      0|      break;
 1187|      0|    }
 1188|      0|    q = q->next;
 1189|      0|  }
 1190|       |
 1191|    108|  while ((q = coap_remove_first_from_delayq(session)) != NULL) {
  ------------------
  |  Branch (1191:10): [True: 0, False: 108]
  ------------------
 1192|      0|    coap_log_debug("** %s: mid=0x%04x: not transmitted after disconnect\n",
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1193|      0|                   coap_session_str(session), q->id);
 1194|      0|    if (q->pdu->type == COAP_MESSAGE_CON) {
  ------------------
  |  Branch (1194:9): [True: 0, False: 0]
  ------------------
 1195|      0|      coap_handle_nack(session, q->pdu, reason, q->id);
 1196|      0|      sent_nack = 1;
 1197|      0|    }
 1198|       |
 1199|      0|    coap_delete_node_lkd(q);
 1200|      0|  }
 1201|    108|#if COAP_CLIENT_SUPPORT
 1202|    108|  session->doing_send_recv = 0;
 1203|    108|#endif /* COAP_CLIENT_SUPPORT */
 1204|    108|#if COAP_CLIENT_SUPPORT
 1205|    108|  if (!sent_nack && session->lg_crcv) {
  ------------------
  |  Branch (1205:7): [True: 108, False: 0]
  |  Branch (1205:21): [True: 0, False: 108]
  ------------------
 1206|       |    /* Take the first one */
 1207|      0|    coap_handle_nack(session, session->lg_crcv->sent_pdu, reason,
 1208|      0|                     session->lg_crcv->sent_pdu->mid);
 1209|      0|    sent_nack = 1;
 1210|      0|  }
 1211|    108|#endif /* COAP_CLIENT_SUPPORT */
 1212|    108|  if (!sent_nack) {
  ------------------
  |  Branch (1212:7): [True: 108, False: 0]
  ------------------
 1213|       |    /* Unable to determine which request disconnection was for */
 1214|    108|    coap_handle_nack(session, NULL, reason, 0);
 1215|    108|  }
 1216|    108|  coap_log_debug("***%s: session disconnected (%s)\n",
  ------------------
  |  |  126|    108|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|    108|#define coap_log(level, ...) do { \
  |  |  |  |  291|    108|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 108]
  |  |  |  |  ------------------
  |  |  |  |  292|    108|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|    108|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 108]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1217|    108|                 coap_session_str(session), coap_nack_name(reason));
 1218|    108|#if COAP_SERVER_SUPPORT
 1219|    108|  coap_delete_observers(session->context, session);
 1220|    108|#endif /* COAP_SERVER_SUPPORT */
 1221|       |
 1222|    108|  if (session->proto == COAP_PROTO_UDP)
  ------------------
  |  Branch (1222:7): [True: 108, False: 0]
  ------------------
 1223|    108|    session->state = COAP_SESSION_STATE_ESTABLISHED;
 1224|      0|  else
 1225|      0|    session->state = COAP_SESSION_STATE_NONE;
 1226|       |
 1227|    108|  session->con_active = 0;
 1228|       |
 1229|    108|  if (session->partial_pdu) {
  ------------------
  |  Branch (1229:7): [True: 0, False: 108]
  ------------------
 1230|      0|    coap_delete_pdu_lkd(session->partial_pdu);
 1231|      0|    session->partial_pdu = NULL;
 1232|      0|  }
 1233|    108|  session->partial_read = 0;
 1234|       |
 1235|       |  /* Not done if nack handler called above */
 1236|    108|  while ((q = coap_remove_first_from_delayq(session)) != NULL) {
  ------------------
  |  Branch (1236:10): [True: 0, False: 108]
  ------------------
 1237|      0|    coap_log_debug("** %s: mid=0x%04x: not transmitted after disconnect\n",
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1238|      0|                   coap_session_str(session), q->id);
 1239|      0|#if COAP_CLIENT_SUPPORT
 1240|      0|    session->doing_send_recv = 0;
 1241|      0|#endif /* COAP_CLIENT_SUPPORT */
 1242|      0|    coap_delete_node_lkd(q);
 1243|      0|  }
 1244|       |
 1245|    108|#if COAP_CLIENT_SUPPORT
 1246|    108|  if (!session->session_failed) {
  ------------------
  |  Branch (1246:7): [True: 108, False: 0]
  ------------------
 1247|       |    /* Need to do this before (D)TLS and socket is closed down */
 1248|    108|    LL_FOREACH_SAFE(session->lg_crcv, cq, etmp) {
  ------------------
  |  |  425|    108|    LL_FOREACH_SAFE2(head,el,tmp,next)
  |  |  ------------------
  |  |  |  |  428|    108|  for ((el) = (head); (el) && ((tmp) = (el)->next, 1); (el) = (tmp))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (428:23): [True: 0, False: 108]
  |  |  |  |  |  Branch (428:31): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1249|      0|      LL_DELETE(session->lg_crcv, cq);
  ------------------
  |  |  391|      0|    LL_DELETE2(head,del,next)
  |  |  ------------------
  |  |  |  |  393|      0|#define LL_DELETE2(head,del,next)                                                              \
  |  |  |  |  394|      0|do {                                                                                           \
  |  |  |  |  395|      0|  LDECLTYPE(head) _tmp;                                                                        \
  |  |  |  |  ------------------
  |  |  |  |  |  |   81|      0|#define LDECLTYPE(x) __typeof(x)
  |  |  |  |  ------------------
  |  |  |  |  396|      0|  if ((head) == (del)) {                                                                       \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (396:7): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  397|      0|    (head)=(head)->next;                                                                       \
  |  |  |  |  398|      0|  } else {                                                                                     \
  |  |  |  |  399|      0|    _tmp = (head);                                                                             \
  |  |  |  |  400|      0|    while (_tmp->next && (_tmp->next != (del))) {                                              \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (400:12): [True: 0, False: 0]
  |  |  |  |  |  Branch (400:26): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  401|      0|      _tmp = _tmp->next;                                                                       \
  |  |  |  |  402|      0|    }                                                                                          \
  |  |  |  |  403|      0|    if (_tmp->next) {                                                                          \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (403:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  404|      0|      _tmp->next = (del)->next;                                                                \
  |  |  |  |  405|      0|    }                                                                                          \
  |  |  |  |  406|      0|  }                                                                                            \
  |  |  |  |  407|      0|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (407:10): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1250|      0|      coap_block_delete_lg_crcv(session, cq);
 1251|      0|    }
 1252|    108|  }
 1253|    108|#endif /* COAP_CLIENT_SUPPORT */
 1254|    108|  LL_FOREACH_SAFE(session->lg_xmit, lq, ltmp) {
  ------------------
  |  |  425|    108|    LL_FOREACH_SAFE2(head,el,tmp,next)
  |  |  ------------------
  |  |  |  |  428|    108|  for ((el) = (head); (el) && ((tmp) = (el)->next, 1); (el) = (tmp))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (428:23): [True: 0, False: 108]
  |  |  |  |  |  Branch (428:31): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1255|      0|    LL_DELETE(session->lg_xmit, lq);
  ------------------
  |  |  391|      0|    LL_DELETE2(head,del,next)
  |  |  ------------------
  |  |  |  |  393|      0|#define LL_DELETE2(head,del,next)                                                              \
  |  |  |  |  394|      0|do {                                                                                           \
  |  |  |  |  395|      0|  LDECLTYPE(head) _tmp;                                                                        \
  |  |  |  |  ------------------
  |  |  |  |  |  |   81|      0|#define LDECLTYPE(x) __typeof(x)
  |  |  |  |  ------------------
  |  |  |  |  396|      0|  if ((head) == (del)) {                                                                       \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (396:7): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  397|      0|    (head)=(head)->next;                                                                       \
  |  |  |  |  398|      0|  } else {                                                                                     \
  |  |  |  |  399|      0|    _tmp = (head);                                                                             \
  |  |  |  |  400|      0|    while (_tmp->next && (_tmp->next != (del))) {                                              \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (400:12): [True: 0, False: 0]
  |  |  |  |  |  Branch (400:26): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  401|      0|      _tmp = _tmp->next;                                                                       \
  |  |  |  |  402|      0|    }                                                                                          \
  |  |  |  |  403|      0|    if (_tmp->next) {                                                                          \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (403:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  404|      0|      _tmp->next = (del)->next;                                                                \
  |  |  |  |  405|      0|    }                                                                                          \
  |  |  |  |  406|      0|  }                                                                                            \
  |  |  |  |  407|      0|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (407:10): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1256|      0|    coap_block_delete_lg_xmit(session, lq);
 1257|      0|  }
 1258|    108|#if COAP_SERVER_SUPPORT
 1259|    108|  LL_FOREACH_SAFE(session->lg_srcv, sq, stmp) {
  ------------------
  |  |  425|    108|    LL_FOREACH_SAFE2(head,el,tmp,next)
  |  |  ------------------
  |  |  |  |  428|    108|  for ((el) = (head); (el) && ((tmp) = (el)->next, 1); (el) = (tmp))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (428:23): [True: 0, False: 108]
  |  |  |  |  |  Branch (428:31): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1260|      0|    LL_DELETE(session->lg_srcv, sq);
  ------------------
  |  |  391|      0|    LL_DELETE2(head,del,next)
  |  |  ------------------
  |  |  |  |  393|      0|#define LL_DELETE2(head,del,next)                                                              \
  |  |  |  |  394|      0|do {                                                                                           \
  |  |  |  |  395|      0|  LDECLTYPE(head) _tmp;                                                                        \
  |  |  |  |  ------------------
  |  |  |  |  |  |   81|      0|#define LDECLTYPE(x) __typeof(x)
  |  |  |  |  ------------------
  |  |  |  |  396|      0|  if ((head) == (del)) {                                                                       \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (396:7): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  397|      0|    (head)=(head)->next;                                                                       \
  |  |  |  |  398|      0|  } else {                                                                                     \
  |  |  |  |  399|      0|    _tmp = (head);                                                                             \
  |  |  |  |  400|      0|    while (_tmp->next && (_tmp->next != (del))) {                                              \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (400:12): [True: 0, False: 0]
  |  |  |  |  |  Branch (400:26): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  401|      0|      _tmp = _tmp->next;                                                                       \
  |  |  |  |  402|      0|    }                                                                                          \
  |  |  |  |  403|      0|    if (_tmp->next) {                                                                          \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (403:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  404|      0|      _tmp->next = (del)->next;                                                                \
  |  |  |  |  405|      0|    }                                                                                          \
  |  |  |  |  406|      0|  }                                                                                            \
  |  |  |  |  407|      0|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (407:10): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1261|      0|    coap_block_delete_lg_srcv(session, sq);
 1262|      0|  }
 1263|    108|#endif /* COAP_SERVER_SUPPORT */
 1264|    108|  coap_cancel_session_messages(session->context, session, reason);
 1265|       |
 1266|    108|#if !COAP_DISABLE_TCP
 1267|    108|  if (COAP_PROTO_RELIABLE(session->proto)) {
  ------------------
  |  |   42|    108|#define COAP_PROTO_RELIABLE(p) ((p)==COAP_PROTO_TCP || (p)==COAP_PROTO_TLS || \
  |  |  ------------------
  |  |  |  Branch (42:33): [True: 0, False: 108]
  |  |  |  Branch (42:56): [True: 0, False: 108]
  |  |  ------------------
  |  |   43|    108|                                (p)==COAP_PROTO_WS || (p)==COAP_PROTO_WSS)
  |  |  ------------------
  |  |  |  Branch (43:33): [True: 0, False: 108]
  |  |  |  Branch (43:55): [True: 0, False: 108]
  |  |  ------------------
  ------------------
 1268|      0|    if (coap_netif_available(session)) {
  ------------------
  |  Branch (1268:9): [True: 0, False: 0]
  ------------------
 1269|      0|      coap_handle_event_lkd(session->context,
 1270|      0|                            state == COAP_SESSION_STATE_CONNECTING ?
  ------------------
  |  Branch (1270:29): [True: 0, False: 0]
  ------------------
 1271|      0|                            COAP_EVENT_TCP_FAILED : COAP_EVENT_TCP_CLOSED, session);
 1272|      0|    }
 1273|      0|#if COAP_CLIENT_SUPPORT
 1274|      0|    if (state != COAP_SESSION_STATE_NONE && !session->session_failed) {
  ------------------
  |  Branch (1274:9): [True: 0, False: 0]
  |  Branch (1274:45): [True: 0, False: 0]
  ------------------
 1275|      0|      coap_handle_event_lkd(session->context,
 1276|      0|                            state == COAP_SESSION_STATE_ESTABLISHED ?
  ------------------
  |  Branch (1276:29): [True: 0, False: 0]
  ------------------
 1277|      0|                            COAP_EVENT_SESSION_CLOSED : COAP_EVENT_SESSION_FAILED, session);
 1278|      0|    }
 1279|      0|    coap_reset_doing_first(session);
 1280|      0|#endif /* COAP_CLIENT_SUPPORT */
 1281|      0|  }
 1282|    108|#endif /* !COAP_DISABLE_TCP */
 1283|    108|  if (session->sock.lfunc[COAP_LAYER_SESSION].l_close)
  ------------------
  |  Branch (1283:7): [True: 108, False: 0]
  ------------------
 1284|    108|    session->sock.lfunc[COAP_LAYER_SESSION].l_close(session);
 1285|    108|  session->disconnecting = disconnecting;
 1286|    108|  session->disconnect_pending = 0;
 1287|    108|}
coap_session_failed:
 1291|    108|coap_session_failed(coap_session_t *session) {
 1292|    108|  if (session->context->reconnect_time && session->client_initiated) {
  ------------------
  |  Branch (1292:7): [True: 0, False: 108]
  |  Branch (1292:43): [True: 0, False: 0]
  ------------------
 1293|      0|    if (session->sock.lfunc[COAP_LAYER_SESSION].l_close)
  ------------------
  |  Branch (1293:9): [True: 0, False: 0]
  ------------------
 1294|      0|      session->sock.lfunc[COAP_LAYER_SESSION].l_close(session);
 1295|      0|    session->session_failed = 1;
 1296|      0|    coap_handle_event_lkd(session->context, COAP_EVENT_RECONNECT_FAILED, session);
 1297|      0|    session->retry_count++;
 1298|      0|    if (session->context->retry_count && session->retry_count >= session->context->retry_count) {
  ------------------
  |  Branch (1298:9): [True: 0, False: 0]
  |  Branch (1298:42): [True: 0, False: 0]
  ------------------
 1299|      0|      coap_handle_event_lkd(session->context, COAP_EVENT_RECONNECT_NO_MORE, session);
 1300|      0|      if (session->type != COAP_SESSION_TYPE_CLIENT) {
  ------------------
  |  Branch (1300:11): [True: 0, False: 0]
  ------------------
 1301|      0|        coap_session_set_type_client_lkd(session, 0);
 1302|      0|        coap_session_release_lkd(session);
 1303|      0|      }
 1304|      0|    }
 1305|      0|    coap_ticks(&session->last_rx_tx);
 1306|      0|  }
 1307|    108|}
coap_session_cid_update_addr:
 1321|     28|coap_session_cid_update_addr(coap_session_t *session) {
 1322|     28|  if (!session->cid_addr_pending || !session->endpoint)
  ------------------
  |  Branch (1322:7): [True: 28, False: 0]
  |  Branch (1322:37): [True: 0, False: 0]
  ------------------
 1323|     28|    return;
 1324|      0|  session->cid_addr_pending = 0;
 1325|       |  /* Updating IP address */
 1326|      0|  coap_log_info("***%s: CID: Old Client Session\n", coap_session_str(session));
  ------------------
  |  |  114|      0|#define coap_log_info(...) coap_log(COAP_LOG_INFO, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1327|      0|  SESSIONS_DELETE(session->endpoint->sessions, session);
  ------------------
  |  | 1017|      0|  HASH_DELETE(hh, (e), (obj))
  |  |  ------------------
  |  |  |  |  462|      0|    HASH_DELETE_HH(hh, head, &(delptr)->hh)
  |  |  |  |  ------------------
  |  |  |  |  |  |  464|      0|#define HASH_DELETE_HH(hh,head,delptrhh)                                         \
  |  |  |  |  |  |  465|      0|do {                                                                             \
  |  |  |  |  |  |  466|      0|  struct UT_hash_handle *_hd_hh_del = (delptrhh);                                \
  |  |  |  |  |  |  467|      0|  if ((_hd_hh_del->prev == NULL) && (_hd_hh_del->next == NULL)) {                \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (467:7): [True: 0, False: 0]
  |  |  |  |  |  |  |  Branch (467:37): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  468|      0|    HASH_BLOOM_FREE((head)->hh.tbl);                                             \
  |  |  |  |  |  |  469|      0|    uthash_free((head)->hh.tbl->buckets,                                         \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   92|      0|#define uthash_free(ptr,sz) free(ptr)     /* free fcn                        */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  470|      0|                (head)->hh.tbl->num_buckets * sizeof(struct UT_hash_bucket));    \
  |  |  |  |  |  |  471|      0|    uthash_free((head)->hh.tbl, sizeof(UT_hash_table));                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   92|      0|#define uthash_free(ptr,sz) free(ptr)     /* free fcn                        */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  472|      0|    (head) = NULL;                                                               \
  |  |  |  |  |  |  473|      0|  } else {                                                                       \
  |  |  |  |  |  |  474|      0|    uint32_t _hd_bkt;                                                            \
  |  |  |  |  |  |  475|      0|    if (_hd_hh_del == (head)->hh.tbl->tail) {                                    \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (475:9): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  476|      0|      (head)->hh.tbl->tail = HH_FROM_ELMT((head)->hh.tbl, _hd_hh_del->prev);     \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  150|      0|#define HH_FROM_ELMT(tbl,elp) ((UT_hash_handle*)(void*)(((char*)(elp)) + ((tbl)->hho)))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  477|      0|    }                                                                            \
  |  |  |  |  |  |  478|      0|    if (_hd_hh_del->prev != NULL) {                                              \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (478:9): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  479|      0|      HH_FROM_ELMT((head)->hh.tbl, _hd_hh_del->prev)->next = _hd_hh_del->next;   \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  150|      0|#define HH_FROM_ELMT(tbl,elp) ((UT_hash_handle*)(void*)(((char*)(elp)) + ((tbl)->hho)))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  480|      0|    } else {                                                                     \
  |  |  |  |  |  |  481|      0|      DECLTYPE_ASSIGN(head, _hd_hh_del->next);                                   \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   78|      0|#define DECLTYPE_ASSIGN(dst,src)                                                 \
  |  |  |  |  |  |  |  |   79|      0|do {                                                                             \
  |  |  |  |  |  |  |  |   80|      0|  (dst) = DECLTYPE(dst)(src);                                                    \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   66|      0|#define DECLTYPE(x) (__typeof(x))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   81|      0|} while (0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (81:10): [Folded, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  482|      0|    }                                                                            \
  |  |  |  |  |  |  483|      0|    if (_hd_hh_del->next != NULL) {                                              \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (483:9): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  484|      0|      HH_FROM_ELMT((head)->hh.tbl, _hd_hh_del->next)->prev = _hd_hh_del->prev;   \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  150|      0|#define HH_FROM_ELMT(tbl,elp) ((UT_hash_handle*)(void*)(((char*)(elp)) + ((tbl)->hho)))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  485|      0|    }                                                                            \
  |  |  |  |  |  |  486|      0|    HASH_TO_BKT(_hd_hh_del->hashv, (head)->hh.tbl->num_buckets, _hd_bkt);        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  444|      0|#define HASH_TO_BKT(hashv,num_bkts,bkt)                                          \
  |  |  |  |  |  |  |  |  445|      0|do {                                                                             \
  |  |  |  |  |  |  |  |  446|      0|  bkt = ((hashv) & ((num_bkts) - 1U));                                           \
  |  |  |  |  |  |  |  |  447|      0|} while (0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (447:10): [Folded, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  487|      0|    HASH_DEL_IN_BKT((head)->hh.tbl->buckets[_hd_bkt], _hd_hh_del);               \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  800|      0|#define HASH_DEL_IN_BKT(head,delhh)                                              \
  |  |  |  |  |  |  |  |  801|      0|do {                                                                             \
  |  |  |  |  |  |  |  |  802|      0|  UT_hash_bucket *_hd_head = &(head);                                            \
  |  |  |  |  |  |  |  |  803|      0|  _hd_head->count--;                                                             \
  |  |  |  |  |  |  |  |  804|      0|  if (_hd_head->hh_head == (delhh)) {                                            \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (804:7): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  805|      0|    _hd_head->hh_head = (delhh)->hh_next;                                        \
  |  |  |  |  |  |  |  |  806|      0|  }                                                                              \
  |  |  |  |  |  |  |  |  807|      0|  if ((delhh)->hh_prev) {                                                        \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (807:7): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  808|      0|    (delhh)->hh_prev->hh_next = (delhh)->hh_next;                                \
  |  |  |  |  |  |  |  |  809|      0|  }                                                                              \
  |  |  |  |  |  |  |  |  810|      0|  if ((delhh)->hh_next) {                                                        \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (810:7): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  811|      0|    (delhh)->hh_next->hh_prev = (delhh)->hh_prev;                                \
  |  |  |  |  |  |  |  |  812|      0|  }                                                                              \
  |  |  |  |  |  |  |  |  813|      0|} while (0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (813:10): [Folded, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  488|      0|    (head)->hh.tbl->num_items--;                                                 \
  |  |  |  |  |  |  489|      0|  }                                                                              \
  |  |  |  |  |  |  490|      0|  HASH_FSCK(hh, head, "HASH_DELETE_HH");                                         \
  |  |  |  |  |  |  491|      0|} while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (491:10): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1328|      0|  session->addr_info = session->cid_addr_info;
 1329|      0|  coap_make_addr_hash(&session->addr_hash, session->endpoint->proto,
 1330|      0|                      &session->addr_info);
 1331|      0|  SESSIONS_ADD(session->endpoint->sessions, session);
  ------------------
  |  | 1014|      0|  HASH_ADD(hh, (e), addr_hash, sizeof((obj)->addr_hash), (obj))
  |  |  ------------------
  |  |  |  |  442|      0|  HASH_ADD_KEYPTR(hh, head, &((add)->fieldname), keylen_in, add)
  |  |  |  |  ------------------
  |  |  |  |  |  |  431|      0|#define HASH_ADD_KEYPTR(hh,head,keyptr,keylen_in,add)                            \
  |  |  |  |  |  |  432|      0|do {                                                                             \
  |  |  |  |  |  |  433|      0|  uint32_t _ha_hashv;                                                            \
  |  |  |  |  |  |  434|      0|  HASH_VALUE(keyptr, keylen_in, _ha_hashv);                                      \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  162|      0|#define HASH_VALUE(keyptr,keylen,hashv)                                          \
  |  |  |  |  |  |  |  |  163|      0|do {                                                                             \
  |  |  |  |  |  |  |  |  164|      0|  HASH_FUNCTION(keyptr, keylen, hashv);                                          \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  102|      0|#define HASH_FUNCTION(keyptr,keylen,hashv) HASH_JEN(keyptr, keylen, hashv)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  658|      0|#define HASH_JEN(key,keylen,hashv)                                               \
  |  |  |  |  |  |  |  |  |  |  |  |  659|      0|do {                                                                             \
  |  |  |  |  |  |  |  |  |  |  |  |  660|      0|  uint32_t _hj_i,_hj_j,_hj_k;                                                    \
  |  |  |  |  |  |  |  |  |  |  |  |  661|      0|  unsigned const char *_hj_key=(unsigned const char*)(key);                      \
  |  |  |  |  |  |  |  |  |  |  |  |  662|      0|  hashv = 0xfeedbeefu;                                                           \
  |  |  |  |  |  |  |  |  |  |  |  |  663|      0|  _hj_i = _hj_j = 0x9e3779b9u;                                                   \
  |  |  |  |  |  |  |  |  |  |  |  |  664|      0|  _hj_k = (uint32_t)(keylen);                                                    \
  |  |  |  |  |  |  |  |  |  |  |  |  665|      0|  while (_hj_k >= 12U) {                                                         \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (665:10): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  666|      0|    _hj_i = (int64_t)_hj_i + (_hj_key[0] + ( (uint32_t)_hj_key[1] << 8 )         \
  |  |  |  |  |  |  |  |  |  |  |  |  667|      0|        + ( (uint32_t)_hj_key[2] << 16 )                                         \
  |  |  |  |  |  |  |  |  |  |  |  |  668|      0|        + ( (uint32_t)_hj_key[3] << 24 ) );                                      \
  |  |  |  |  |  |  |  |  |  |  |  |  669|      0|    _hj_j = (int64_t)_hj_j + (_hj_key[4] + ( (uint32_t)_hj_key[5] << 8 )         \
  |  |  |  |  |  |  |  |  |  |  |  |  670|      0|        + ( (uint32_t)_hj_key[6] << 16 )                                         \
  |  |  |  |  |  |  |  |  |  |  |  |  671|      0|        + ( (uint32_t)_hj_key[7] << 24 ) );                                      \
  |  |  |  |  |  |  |  |  |  |  |  |  672|      0|    hashv = (int64_t)hashv + (_hj_key[8] + ( (uint32_t)_hj_key[9] << 8 )         \
  |  |  |  |  |  |  |  |  |  |  |  |  673|      0|        + ( (uint32_t)_hj_key[10] << 16 )                                        \
  |  |  |  |  |  |  |  |  |  |  |  |  674|      0|        + ( (uint32_t)_hj_key[11] << 24 ) );                                     \
  |  |  |  |  |  |  |  |  |  |  |  |  675|      0|                                                                                 \
  |  |  |  |  |  |  |  |  |  |  |  |  676|      0|     HASH_JEN_MIX(_hj_i, _hj_j, hashv);                                          \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  645|      0|#define HASH_JEN_MIX(a,b,c)                                                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  646|      0|do {                                                                             \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  647|      0|  a = (int64_t)a - b; a = (int64_t)a - c; a ^= ( c >> 13 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  648|      0|  b = (int64_t)b - c; b = (int64_t)b - a; b ^= ( a << 8 );                       \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  649|      0|  c = (int64_t)c - a; c = (int64_t)c - b; c ^= ( b >> 13 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  650|      0|  a = (int64_t)a - b; a = (int64_t)a - c; a ^= ( c >> 12 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  651|      0|  b = (int64_t)b - c; b = (int64_t)b - a; b ^= ( a << 16 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  652|      0|  c = (int64_t)c - a; c = (int64_t)c - b; c ^= ( b >> 5 );                       \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  653|      0|  a = (int64_t)a - b; a = (int64_t)a - c; a ^= ( c >> 3 );                       \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  654|      0|  b = (int64_t)b - c; b = (int64_t)b - a; b ^= ( a << 10 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  655|      0|  c = (int64_t)c - a; c = (int64_t)c - b; c ^= ( b >> 15 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  656|      0|} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (656:10): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  677|      0|                                                                                 \
  |  |  |  |  |  |  |  |  |  |  |  |  678|      0|     _hj_key += 12;                                                              \
  |  |  |  |  |  |  |  |  |  |  |  |  679|      0|     _hj_k -= 12U;                                                               \
  |  |  |  |  |  |  |  |  |  |  |  |  680|      0|  }                                                                              \
  |  |  |  |  |  |  |  |  |  |  |  |  681|      0|  hashv += (uint32_t)(keylen);                                                   \
  |  |  |  |  |  |  |  |  |  |  |  |  682|      0|  switch ( _hj_k ) {                                                             \
  |  |  |  |  |  |  |  |  |  |  |  |  683|      0|    case 11: hashv = (int64_t)hashv + ( (uint32_t)_hj_key[10] << 24 ); /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (683:5): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  684|      0|    case 10: hashv = (int64_t)hashv + ( (uint32_t)_hj_key[9] << 16 );  /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (684:5): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  685|      0|    case 9:  hashv = (int64_t)hashv + ( (uint32_t)_hj_key[8] << 8 );   /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (685:5): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  686|      0|    case 8:  _hj_j = (int64_t)_hj_j + ( (uint32_t)_hj_key[7] << 24 );  /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (686:5): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  687|      0|    case 7:  _hj_j = (int64_t)_hj_j + ( (uint32_t)_hj_key[6] << 16 );  /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (687:5): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  688|      0|    case 6:  _hj_j = (int64_t)_hj_j + ( (uint32_t)_hj_key[5] << 8 );   /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (688:5): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  689|      0|    case 5:  _hj_j = (int64_t)_hj_j + _hj_key[4];                      /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (689:5): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  690|      0|    case 4:  _hj_i = (int64_t)_hj_i + ( (uint32_t)_hj_key[3] << 24 );  /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (690:5): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  691|      0|    case 3:  _hj_i = (int64_t)_hj_i + ( (uint32_t)_hj_key[2] << 16 );  /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (691:5): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  692|      0|    case 2:  _hj_i = (int64_t)_hj_i + ( (uint32_t)_hj_key[1] << 8 );   /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (692:5): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  693|      0|    case 1:  _hj_i = (int64_t)_hj_i + _hj_key[0];                      /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (693:5): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  694|      0|    default: ;                                                                   \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (694:5): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  695|      0|  }                                                                              \
  |  |  |  |  |  |  |  |  |  |  |  |  696|      0|  HASH_JEN_MIX(_hj_i, _hj_j, hashv);                                             \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  645|      0|#define HASH_JEN_MIX(a,b,c)                                                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  646|      0|do {                                                                             \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  647|      0|  a = (int64_t)a - b; a = (int64_t)a - c; a ^= ( c >> 13 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  648|      0|  b = (int64_t)b - c; b = (int64_t)b - a; b ^= ( a << 8 );                       \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  649|      0|  c = (int64_t)c - a; c = (int64_t)c - b; c ^= ( b >> 13 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  650|      0|  a = (int64_t)a - b; a = (int64_t)a - c; a ^= ( c >> 12 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  651|      0|  b = (int64_t)b - c; b = (int64_t)b - a; b ^= ( a << 16 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  652|      0|  c = (int64_t)c - a; c = (int64_t)c - b; c ^= ( b >> 5 );                       \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  653|      0|  a = (int64_t)a - b; a = (int64_t)a - c; a ^= ( c >> 3 );                       \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  654|      0|  b = (int64_t)b - c; b = (int64_t)b - a; b ^= ( a << 10 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  655|      0|  c = (int64_t)c - a; c = (int64_t)c - b; c ^= ( b >> 15 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  656|      0|} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (656:10): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  697|      0|} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (697:10): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  165|      0|} while (0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (165:10): [Folded, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  435|      0|  HASH_ADD_KEYPTR_BYHASHVALUE(hh, head, keyptr, keylen_in, _ha_hashv, add);      \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  410|      0|#define HASH_ADD_KEYPTR_BYHASHVALUE(hh,head,keyptr,keylen_in,hashval,add)        \
  |  |  |  |  |  |  |  |  411|      0|do {                                                                             \
  |  |  |  |  |  |  |  |  412|      0|  IF_HASH_NONFATAL_OOM( int _ha_oomed = 0; )                                     \
  |  |  |  |  |  |  |  |  413|      0|  (add)->hh.hashv = (hashval);                                                   \
  |  |  |  |  |  |  |  |  414|      0|  (add)->hh.key = (const void*) (keyptr);                                        \
  |  |  |  |  |  |  |  |  415|      0|  (add)->hh.keylen = (uint32_t) (keylen_in);                                     \
  |  |  |  |  |  |  |  |  416|      0|  if (!(head)) {                                                                 \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (416:7): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  417|      0|    (add)->hh.next = NULL;                                                       \
  |  |  |  |  |  |  |  |  418|      0|    (add)->hh.prev = NULL;                                                       \
  |  |  |  |  |  |  |  |  419|      0|    HASH_MAKE_TABLE(hh, add, _ha_oomed);                                         \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  226|      0|#define HASH_MAKE_TABLE(hh,head,oomed)                                           \
  |  |  |  |  |  |  |  |  |  |  227|      0|do {                                                                             \
  |  |  |  |  |  |  |  |  |  |  228|      0|  (head)->hh.tbl = (UT_hash_table*)uthash_malloc(sizeof(UT_hash_table));         \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   89|      0|#define uthash_malloc(sz) malloc(sz)      /* malloc fcn                      */
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  229|      0|  if (!(head)->hh.tbl) {                                                         \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (229:7): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  230|      0|    HASH_RECORD_OOM(oomed);                                                      \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  137|      0|#define HASH_RECORD_OOM(oomed) uthash_fatal("out of memory")
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  134|      0|#define uthash_fatal(msg) exit(-1)        /* fatal OOM error */
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  231|      0|  } else {                                                                       \
  |  |  |  |  |  |  |  |  |  |  232|      0|    uthash_bzero((head)->hh.tbl, sizeof(UT_hash_table));                         \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   95|      0|#define uthash_bzero(a,n) memset(a,'\0',n)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  233|      0|    (head)->hh.tbl->tail = &((head)->hh);                                        \
  |  |  |  |  |  |  |  |  |  |  234|      0|    (head)->hh.tbl->num_buckets = HASH_INITIAL_NUM_BUCKETS;                      \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  143|      0|#define HASH_INITIAL_NUM_BUCKETS 32U     /* initial number of buckets        */
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  235|      0|    (head)->hh.tbl->log2_num_buckets = HASH_INITIAL_NUM_BUCKETS_LOG2;            \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  144|      0|#define HASH_INITIAL_NUM_BUCKETS_LOG2 5U /* lg2 of initial number of buckets */
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  236|      0|    (head)->hh.tbl->hho = (char*)(&(head)->hh) - (char*)(head);                  \
  |  |  |  |  |  |  |  |  |  |  237|      0|    (head)->hh.tbl->buckets = (UT_hash_bucket*)uthash_malloc(                    \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   89|      0|#define uthash_malloc(sz) malloc(sz)      /* malloc fcn                      */
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  238|      0|        HASH_INITIAL_NUM_BUCKETS * sizeof(struct UT_hash_bucket));               \
  |  |  |  |  |  |  |  |  |  |  239|      0|    (head)->hh.tbl->signature = HASH_SIGNATURE;                                  \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  | 1101|      0|#define HASH_SIGNATURE 0xa0111fe1u
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  240|      0|    if (!(head)->hh.tbl->buckets) {                                              \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (240:9): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  241|      0|      HASH_RECORD_OOM(oomed);                                                    \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  137|      0|#define HASH_RECORD_OOM(oomed) uthash_fatal("out of memory")
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  134|      0|#define uthash_fatal(msg) exit(-1)        /* fatal OOM error */
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  242|      0|      uthash_free((head)->hh.tbl, sizeof(UT_hash_table));                        \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   92|      0|#define uthash_free(ptr,sz) free(ptr)     /* free fcn                        */
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  243|      0|    } else {                                                                     \
  |  |  |  |  |  |  |  |  |  |  244|      0|      uthash_bzero((head)->hh.tbl->buckets,                                      \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   95|      0|#define uthash_bzero(a,n) memset(a,'\0',n)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  245|      0|          HASH_INITIAL_NUM_BUCKETS * sizeof(struct UT_hash_bucket));             \
  |  |  |  |  |  |  |  |  |  |  246|      0|      HASH_BLOOM_MAKE((head)->hh.tbl, oomed);                                    \
  |  |  |  |  |  |  |  |  |  |  247|      0|      IF_HASH_NONFATAL_OOM(                                                      \
  |  |  |  |  |  |  |  |  |  |  248|      0|        if (oomed) {                                                             \
  |  |  |  |  |  |  |  |  |  |  249|      0|          uthash_free((head)->hh.tbl->buckets,                                   \
  |  |  |  |  |  |  |  |  |  |  250|      0|              HASH_INITIAL_NUM_BUCKETS*sizeof(struct UT_hash_bucket));           \
  |  |  |  |  |  |  |  |  |  |  251|      0|          uthash_free((head)->hh.tbl, sizeof(UT_hash_table));                    \
  |  |  |  |  |  |  |  |  |  |  252|      0|        }                                                                        \
  |  |  |  |  |  |  |  |  |  |  253|      0|      )                                                                          \
  |  |  |  |  |  |  |  |  |  |  254|      0|    }                                                                            \
  |  |  |  |  |  |  |  |  |  |  255|      0|  }                                                                              \
  |  |  |  |  |  |  |  |  |  |  256|      0|} while (0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (256:10): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  420|      0|    IF_HASH_NONFATAL_OOM( if (!_ha_oomed) { )                                    \
  |  |  |  |  |  |  |  |  421|      0|      (head) = (add);                                                            \
  |  |  |  |  |  |  |  |  422|      0|    IF_HASH_NONFATAL_OOM( } )                                                    \
  |  |  |  |  |  |  |  |  423|      0|  } else {                                                                       \
  |  |  |  |  |  |  |  |  424|      0|    (add)->hh.tbl = (head)->hh.tbl;                                              \
  |  |  |  |  |  |  |  |  425|      0|    HASH_APPEND_LIST(hh, head, add);                                             \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  292|      0|#define HASH_APPEND_LIST(hh, head, add)                                          \
  |  |  |  |  |  |  |  |  |  |  293|      0|do {                                                                             \
  |  |  |  |  |  |  |  |  |  |  294|      0|  (add)->hh.next = NULL;                                                         \
  |  |  |  |  |  |  |  |  |  |  295|      0|  (add)->hh.prev = ELMT_FROM_HH((head)->hh.tbl, (head)->hh.tbl->tail);           \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  148|      0|#define ELMT_FROM_HH(tbl,hhp) ((void*)(((char*)(hhp)) - ((tbl)->hho)))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  296|      0|  (head)->hh.tbl->tail->next = (add);                                            \
  |  |  |  |  |  |  |  |  |  |  297|      0|  (head)->hh.tbl->tail = &((add)->hh);                                           \
  |  |  |  |  |  |  |  |  |  |  298|      0|} while (0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (298:10): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  426|      0|  }                                                                              \
  |  |  |  |  |  |  |  |  427|      0|  HASH_ADD_TO_TABLE(hh, head, keyptr, keylen_in, hashval, add, _ha_oomed);       \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  351|      0|#define HASH_ADD_TO_TABLE(hh,head,keyptr,keylen_in,hashval,add,oomed)            \
  |  |  |  |  |  |  |  |  |  |  352|      0|do {                                                                             \
  |  |  |  |  |  |  |  |  |  |  353|      0|  uint32_t _ha_bkt;                                                              \
  |  |  |  |  |  |  |  |  |  |  354|      0|  (head)->hh.tbl->num_items++;                                                   \
  |  |  |  |  |  |  |  |  |  |  355|      0|  HASH_TO_BKT(hashval, (head)->hh.tbl->num_buckets, _ha_bkt);                    \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  444|      0|#define HASH_TO_BKT(hashv,num_bkts,bkt)                                          \
  |  |  |  |  |  |  |  |  |  |  |  |  445|      0|do {                                                                             \
  |  |  |  |  |  |  |  |  |  |  |  |  446|      0|  bkt = ((hashv) & ((num_bkts) - 1U));                                           \
  |  |  |  |  |  |  |  |  |  |  |  |  447|      0|} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (447:10): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  356|      0|  HASH_ADD_TO_BKT((head)->hh.tbl->buckets[_ha_bkt], hh, &(add)->hh, oomed);      \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  778|      0|#define HASH_ADD_TO_BKT(head,hh,addhh,oomed)                                     \
  |  |  |  |  |  |  |  |  |  |  |  |  779|      0|do {                                                                             \
  |  |  |  |  |  |  |  |  |  |  |  |  780|      0|  UT_hash_bucket *_ha_head = &(head);                                            \
  |  |  |  |  |  |  |  |  |  |  |  |  781|      0|  _ha_head->count++;                                                             \
  |  |  |  |  |  |  |  |  |  |  |  |  782|      0|  (addhh)->hh_next = _ha_head->hh_head;                                          \
  |  |  |  |  |  |  |  |  |  |  |  |  783|      0|  (addhh)->hh_prev = NULL;                                                       \
  |  |  |  |  |  |  |  |  |  |  |  |  784|      0|  if (_ha_head->hh_head != NULL) {                                               \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (784:7): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  785|      0|    _ha_head->hh_head->hh_prev = (addhh);                                        \
  |  |  |  |  |  |  |  |  |  |  |  |  786|      0|  }                                                                              \
  |  |  |  |  |  |  |  |  |  |  |  |  787|      0|  _ha_head->hh_head = (addhh);                                                   \
  |  |  |  |  |  |  |  |  |  |  |  |  788|      0|  if ((_ha_head->count >= ((_ha_head->expand_mult + 1U) * HASH_BKT_CAPACITY_THRESH)) \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  145|      0|#define HASH_BKT_CAPACITY_THRESH 10U     /* expand when bucket count reaches */
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (788:7): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  789|      0|      && !(addhh)->tbl->noexpand) {                                              \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (789:10): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  790|      0|    HASH_EXPAND_BUCKETS(addhh,(addhh)->tbl, oomed);                              \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  844|      0|#define HASH_EXPAND_BUCKETS(hh,tbl,oomed)                                        \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  845|      0|do {                                                                             \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  846|      0|  uint32_t _he_bkt;                                                              \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  847|      0|  uint32_t _he_bkt_i;                                                            \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  848|      0|  struct UT_hash_handle *_he_thh, *_he_hh_nxt;                                   \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  849|      0|  UT_hash_bucket *_he_new_buckets, *_he_newbkt;                                  \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  850|      0|  _he_new_buckets = (UT_hash_bucket*)uthash_malloc(                              \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   89|      0|#define uthash_malloc(sz) malloc(sz)      /* malloc fcn                      */
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  851|      0|           sizeof(struct UT_hash_bucket) * (tbl)->num_buckets * 2U);             \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  852|      0|  if (!_he_new_buckets) {                                                        \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (852:7): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  853|      0|    HASH_RECORD_OOM(oomed);                                                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  137|      0|#define HASH_RECORD_OOM(oomed) uthash_fatal("out of memory")
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  134|      0|#define uthash_fatal(msg) exit(-1)        /* fatal OOM error */
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  854|      0|  } else {                                                                       \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  855|      0|    uthash_bzero(_he_new_buckets,                                                \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   95|      0|#define uthash_bzero(a,n) memset(a,'\0',n)
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  856|      0|        sizeof(struct UT_hash_bucket) * (tbl)->num_buckets * 2U);                \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  857|      0|    (tbl)->ideal_chain_maxlen =                                                  \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  858|      0|       ((tbl)->num_items >> ((tbl)->log2_num_buckets+1U)) +                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  859|      0|       ((((tbl)->num_items & (((tbl)->num_buckets*2U)-1U)) != 0U) ? 1U : 0U);    \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (859:9): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  860|      0|    (tbl)->nonideal_items = 0;                                                   \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  861|      0|    for (_he_bkt_i = 0; _he_bkt_i < (tbl)->num_buckets; _he_bkt_i++) {           \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (861:25): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  862|      0|      _he_thh = (tbl)->buckets[ _he_bkt_i ].hh_head;                             \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  863|      0|      while (_he_thh != NULL) {                                                  \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (863:14): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  864|      0|        _he_hh_nxt = _he_thh->hh_next;                                           \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  865|      0|        HASH_TO_BKT(_he_thh->hashv, (tbl)->num_buckets * 2U, _he_bkt);           \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  444|      0|#define HASH_TO_BKT(hashv,num_bkts,bkt)                                          \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  445|      0|do {                                                                             \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  446|      0|  bkt = ((hashv) & ((num_bkts) - 1U));                                           \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  447|      0|} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (447:10): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  866|      0|        _he_newbkt = &(_he_new_buckets[_he_bkt]);                                \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  867|      0|        if (++(_he_newbkt->count) > (tbl)->ideal_chain_maxlen) {                 \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (867:13): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  868|      0|          (tbl)->nonideal_items++;                                               \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  869|      0|          if (_he_newbkt->count > _he_newbkt->expand_mult * (tbl)->ideal_chain_maxlen) { \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (869:15): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  870|      0|            _he_newbkt->expand_mult++;                                           \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  871|      0|          }                                                                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  872|      0|        }                                                                        \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  873|      0|        _he_thh->hh_prev = NULL;                                                 \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  874|      0|        _he_thh->hh_next = _he_newbkt->hh_head;                                  \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  875|      0|        if (_he_newbkt->hh_head != NULL) {                                       \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (875:13): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  876|      0|          _he_newbkt->hh_head->hh_prev = _he_thh;                                \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  877|      0|        }                                                                        \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  878|      0|        _he_newbkt->hh_head = _he_thh;                                           \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  879|      0|        _he_thh = _he_hh_nxt;                                                    \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  880|      0|      }                                                                          \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  881|      0|    }                                                                            \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  882|      0|    uthash_free((tbl)->buckets, (tbl)->num_buckets * sizeof(struct UT_hash_bucket)); \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   92|      0|#define uthash_free(ptr,sz) free(ptr)     /* free fcn                        */
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  883|      0|    (tbl)->num_buckets *= 2U;                                                    \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  884|      0|    (tbl)->log2_num_buckets++;                                                   \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  885|      0|    (tbl)->buckets = _he_new_buckets;                                            \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  886|      0|    (tbl)->ineff_expands = ((tbl)->nonideal_items > ((tbl)->num_items >> 1)) ?   \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (886:28): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  887|      0|        ((tbl)->ineff_expands+1U) : 0U;                                          \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  888|      0|    if ((tbl)->ineff_expands > 1U) {                                             \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (888:9): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  889|      0|      (tbl)->noexpand = 1;                                                       \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  890|      0|      uthash_noexpand_fyi(tbl);                                                  \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  891|      0|    }                                                                            \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  892|      0|    uthash_expand_fyi(tbl);                                                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  893|      0|  }                                                                              \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  894|      0|} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (894:10): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  791|      0|    IF_HASH_NONFATAL_OOM(                                                        \
  |  |  |  |  |  |  |  |  |  |  |  |  792|      0|      if (oomed) {                                                               \
  |  |  |  |  |  |  |  |  |  |  |  |  793|      0|        HASH_DEL_IN_BKT(head,addhh);                                             \
  |  |  |  |  |  |  |  |  |  |  |  |  794|      0|      }                                                                          \
  |  |  |  |  |  |  |  |  |  |  |  |  795|      0|    )                                                                            \
  |  |  |  |  |  |  |  |  |  |  |  |  796|      0|  }                                                                              \
  |  |  |  |  |  |  |  |  |  |  |  |  797|      0|} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (797:10): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  357|      0|  HASH_BLOOM_ADD((head)->hh.tbl, hashval);                                       \
  |  |  |  |  |  |  |  |  |  |  358|      0|  HASH_EMIT_KEY(hh, head, keyptr, keylen_in);                                    \
  |  |  |  |  |  |  |  |  |  |  359|      0|} while (0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (359:10): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  428|      0|  HASH_FSCK(hh, head, "HASH_ADD_KEYPTR_BYHASHVALUE");                            \
  |  |  |  |  |  |  |  |  429|      0|} while (0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (429:10): [Folded, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  436|      0|} while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (436:10): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1332|      0|  coap_log_info("***%s: CID: New Client Session\n", coap_session_str(session));
  ------------------
  |  |  114|      0|#define coap_log_info(...) coap_log(COAP_LOG_INFO, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1333|      0|}
coap_session_establish:
 1711|     35|coap_session_establish(coap_session_t *session) {
 1712|     35|  if (COAP_PROTO_NOT_RELIABLE(session->proto))
  ------------------
  |  |   41|     35|#define COAP_PROTO_NOT_RELIABLE(p) ((p)==COAP_PROTO_UDP || (p)==COAP_PROTO_DTLS)
  |  |  ------------------
  |  |  |  Branch (41:37): [True: 35, False: 0]
  |  |  |  Branch (41:60): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1713|     35|    coap_session_connected(session);
 1714|     35|#if !COAP_DISABLE_TCP
 1715|     35|  if (COAP_PROTO_RELIABLE(session->proto))
  ------------------
  |  |   42|     35|#define COAP_PROTO_RELIABLE(p) ((p)==COAP_PROTO_TCP || (p)==COAP_PROTO_TLS || \
  |  |  ------------------
  |  |  |  Branch (42:33): [True: 0, False: 35]
  |  |  |  Branch (42:56): [True: 0, False: 35]
  |  |  ------------------
  |  |   43|     35|                                (p)==COAP_PROTO_WS || (p)==COAP_PROTO_WSS)
  |  |  ------------------
  |  |  |  Branch (43:33): [True: 0, False: 35]
  |  |  |  Branch (43:55): [True: 0, False: 35]
  |  |  ------------------
  ------------------
 1716|      0|    coap_session_send_csm(session);
 1717|     35|#endif /* !COAP_DISABLE_TCP */
 1718|     35|}
coap_new_client_session:
 1813|     35|                        coap_proto_t proto) {
 1814|     35|  coap_session_t *session;
 1815|       |
 1816|     35|  coap_lock_lock(return NULL);
 1817|     35|  session = coap_new_client_session3_lkd(ctx, local_if, server, proto, NULL, NULL, NULL);
 1818|     35|  coap_lock_unlock();
 1819|     35|  return session;
 1820|     35|}
coap_new_client_session3_lkd:
 1845|     35|                             coap_str_const_t *ws_host) {
 1846|     35|  coap_session_t *session;
 1847|       |
 1848|     35|  coap_lock_check_locked();
  ------------------
  |  |  638|     35|#define coap_lock_check_locked() {}
  ------------------
 1849|     35|  session = coap_session_create_client(ctx, local_if, server,
 1850|     35|                                       proto, app_data, callback, ws_host);
 1851|     35|  if (session) {
  ------------------
  |  Branch (1851:7): [True: 35, False: 0]
  ------------------
 1852|     35|    coap_log_debug("***%s: session %p: created outgoing session\n",
  ------------------
  |  |  126|     35|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|     35|#define coap_log(level, ...) do { \
  |  |  |  |  291|     35|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 35]
  |  |  |  |  ------------------
  |  |  |  |  292|     35|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|     35|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 35]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1853|     35|                   coap_session_str(session), (void *)session);
 1854|     35|    coap_session_check_connect(session);
 1855|     35|  }
 1856|     35|  return session;
 1857|     35|}
coap_new_message_id:
 2391|     98|coap_new_message_id(coap_session_t *session) {
 2392|     98|  uint16_t mid;
 2393|       |
 2394|     98|  coap_lock_lock(return 0);
 2395|     98|  mid = coap_new_message_id_lkd(session);
 2396|     98|  coap_lock_unlock();
 2397|     98|  return mid;
 2398|     98|}
coap_new_message_id_lkd:
 2401|    350|coap_new_message_id_lkd(coap_session_t *session) {
 2402|    350|  coap_lock_check_locked();
  ------------------
  |  |  638|    350|#define coap_lock_check_locked() {}
  ------------------
 2403|    350|  if (COAP_PROTO_NOT_RELIABLE(session->proto))
  ------------------
  |  |   41|    350|#define COAP_PROTO_NOT_RELIABLE(p) ((p)==COAP_PROTO_UDP || (p)==COAP_PROTO_DTLS)
  |  |  ------------------
  |  |  |  Branch (41:37): [True: 350, False: 0]
  |  |  |  Branch (41:60): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 2404|    350|    return ++session->tx_mid;
 2405|       |  /* TCP/TLS have no notion of mid */
 2406|      0|  return 0;
 2407|    350|}
coap_get_next_session_cl:
 3037|     35|                         coap_session_t **session_next) {
 3038|     35|  coap_session_t *ch;
 3039|       |
 3040|     35|  if (!session_head)
  ------------------
  |  Branch (3040:7): [True: 35, False: 0]
  ------------------
 3041|     35|    return NULL;
 3042|       |
 3043|       |  /* Check session just used is still valid */
 3044|      0|  for (ch = session_head; ch; ch = ch->hh.next) {
  ------------------
  |  Branch (3044:27): [True: 0, False: 0]
  ------------------
 3045|      0|    if (ch == session_curr)
  ------------------
  |  Branch (3045:9): [True: 0, False: 0]
  ------------------
 3046|      0|      break;
 3047|      0|  }
 3048|      0|  if (ch) {
  ------------------
  |  Branch (3048:7): [True: 0, False: 0]
  ------------------
 3049|       |    /* Use the next one */
 3050|      0|    if ((ch = session_curr->hh.next))
  ------------------
  |  Branch (3050:9): [True: 0, False: 0]
  ------------------
 3051|      0|      goto have_valid_next;
 3052|      0|    return NULL;
 3053|      0|  }
 3054|      0|  coap_log_debug("Current session %p no longer exists\n", (void *)session_curr);
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3055|       |
 3056|       |  /* Check session provided for next is still valid */
 3057|      0|  for (ch = session_head; ch; ch = ch->hh.next) {
  ------------------
  |  Branch (3057:27): [True: 0, False: 0]
  ------------------
 3058|      0|    if (ch == *session_next)
  ------------------
  |  Branch (3058:9): [True: 0, False: 0]
  ------------------
 3059|      0|      break;
 3060|      0|  }
 3061|      0|  if (ch) {
  ------------------
  |  Branch (3061:7): [True: 0, False: 0]
  ------------------
 3062|       |    /* Use this one */
 3063|      0|    goto have_valid_next;
 3064|      0|  }
 3065|      0|  coap_log_debug("Next session %p no longer exists\n", (void *)*session_next);
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3066|       |
 3067|       |  /* Go back to the start of the list */
 3068|      0|  ch = session_head;
 3069|      0|  coap_log_debug("Restarting session list with %p\n", (void *)ch);
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3070|       |
 3071|      0|have_valid_next:
 3072|      0|  *session_next = ch->hh.next;
 3073|      0|  return ch;
 3074|      0|}
coap_session.c:coap_session_fix_non_probing_wait_base:
  124|     35|coap_session_fix_non_probing_wait_base(coap_session_t *s) {
  125|     35|  coap_fixed_point_t res;
  126|       |
  127|     35|  res = coap_multi_fixed_uint(COAP_NON_TIMEOUT(s),
  ------------------
  |  |  882|     35|#define COAP_NON_TIMEOUT(s) ((s)->non_timeout)
  ------------------
  128|     35|                              ((1 << (COAP_NON_MAX_RETRANSMIT(s) + 1)) -1));
  ------------------
  |  |  881|     35|#define COAP_NON_MAX_RETRANSMIT(s) ((s)->non_max_retransmit)
  ------------------
  129|     35|  res = coap_multi_fixed_fixed(res, COAP_ACK_RANDOM_FACTOR(s));
  ------------------
  |  |  874|     35|#define COAP_ACK_RANDOM_FACTOR(s) ((s)->ack_random_factor)
  ------------------
  130|     35|  res = coap_add_fixed_uint(res, 2 * COAP_DEFAULT_MAX_LATENCY);
  ------------------
  |  |  782|     35|#define COAP_DEFAULT_MAX_LATENCY (100U)
  ------------------
  131|     35|  COAP_NON_PROBING_WAIT_BASE(s) = res;
  ------------------
  |  |  887|     35|#define COAP_NON_PROBING_WAIT_BASE(s) ((s)->non_probing_wait_base)
  ------------------
  132|     35|}
coap_session.c:coap_session_fix_non_partial_timeout:
  139|     35|coap_session_fix_non_partial_timeout(coap_session_t *s) {
  140|     35|  coap_fixed_point_t res;
  141|       |
  142|     35|  res = coap_multi_fixed_uint(COAP_NON_TIMEOUT(s),
  ------------------
  |  |  882|     35|#define COAP_NON_TIMEOUT(s) ((s)->non_timeout)
  ------------------
  143|     35|                              ((1 << (COAP_NON_MAX_RETRANSMIT(s) + 1)) -1));
  ------------------
  |  |  881|     35|#define COAP_NON_MAX_RETRANSMIT(s) ((s)->non_max_retransmit)
  ------------------
  144|     35|  res = coap_multi_fixed_fixed(res, COAP_ACK_RANDOM_FACTOR(s));
  ------------------
  |  |  874|     35|#define COAP_ACK_RANDOM_FACTOR(s) ((s)->ack_random_factor)
  ------------------
  145|     35|  res = coap_add_fixed_uint(res, 2 * COAP_DEFAULT_MAX_LATENCY);
  ------------------
  |  |  782|     35|#define COAP_DEFAULT_MAX_LATENCY (100U)
  ------------------
  146|     35|  res = coap_add_fixed_fixed(res, COAP_NON_TIMEOUT(s));
  ------------------
  |  |  882|     35|#define COAP_NON_TIMEOUT(s) ((s)->non_timeout)
  ------------------
  147|     35|  COAP_NON_PARTIAL_TIMEOUT(s) = res;
  ------------------
  |  |  888|     35|#define COAP_NON_PARTIAL_TIMEOUT(s) ((s)->non_partial_timeout)
  ------------------
  148|     35|}
coap_session.c:coap_session_max_pdu_size_internal:
  751|    278|                                   size_t max_with_header) {
  752|       |#if COAP_DISABLE_TCP
  753|       |  (void)session;
  754|       |  return max_with_header > COAP_PDU_MAX_UDP_HEADER_SIZE
  755|       |         ? max_with_header - COAP_PDU_MAX_UDP_HEADER_SIZE
  756|       |         : 0;
  757|       |#else /* !COAP_DISABLE_TCP */
  758|    278|  if (COAP_PROTO_NOT_RELIABLE(session->proto))
  ------------------
  |  |   41|    278|#define COAP_PROTO_NOT_RELIABLE(p) ((p)==COAP_PROTO_UDP || (p)==COAP_PROTO_DTLS)
  |  |  ------------------
  |  |  |  Branch (41:37): [True: 278, False: 0]
  |  |  |  Branch (41:60): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  759|    278|    return max_with_header > COAP_PDU_MAX_UDP_HEADER_SIZE
  ------------------
  |  |  107|    278|#define COAP_PDU_MAX_UDP_HEADER_SIZE 4
  ------------------
  |  Branch (759:12): [True: 278, False: 0]
  ------------------
  760|    278|           ? max_with_header - COAP_PDU_MAX_UDP_HEADER_SIZE
  ------------------
  |  |  107|    278|#define COAP_PDU_MAX_UDP_HEADER_SIZE 4
  ------------------
  761|    278|           : 0;
  762|       |  /* we must assume there is no token to be on the safe side */
  763|      0|  if (max_with_header <= 2)
  ------------------
  |  Branch (763:7): [True: 0, False: 0]
  ------------------
  764|      0|    return 0;
  765|      0|  else if (max_with_header <= COAP_MAX_MESSAGE_SIZE_TCP0 + 2)
  ------------------
  |  |   43|      0|#define COAP_MAX_MESSAGE_SIZE_TCP0 (COAP_MESSAGE_SIZE_OFFSET_TCP8-1) /* 12 */
  |  |  ------------------
  |  |  |  |   38|      0|#define COAP_MESSAGE_SIZE_OFFSET_TCP8 13
  |  |  ------------------
  ------------------
  |  Branch (765:12): [True: 0, False: 0]
  ------------------
  766|      0|    return max_with_header - 2;
  767|      0|  else if (max_with_header <= COAP_MAX_MESSAGE_SIZE_TCP8 + 3)
  ------------------
  |  |   44|      0|#define COAP_MAX_MESSAGE_SIZE_TCP8 (COAP_MESSAGE_SIZE_OFFSET_TCP16-1) /* 268 */
  |  |  ------------------
  |  |  |  |   39|      0|#define COAP_MESSAGE_SIZE_OFFSET_TCP16 269 /* 13 + 256 */
  |  |  ------------------
  ------------------
  |  Branch (767:12): [True: 0, False: 0]
  ------------------
  768|      0|    return max_with_header - 3;
  769|      0|  else if (max_with_header <= COAP_MAX_MESSAGE_SIZE_TCP16 + 4)
  ------------------
  |  |   45|      0|#define COAP_MAX_MESSAGE_SIZE_TCP16 (COAP_MESSAGE_SIZE_OFFSET_TCP32-1) /* 65804 */
  |  |  ------------------
  |  |  |  |   40|      0|#define COAP_MESSAGE_SIZE_OFFSET_TCP32 65805 /* 269 + 65536 */
  |  |  ------------------
  ------------------
  |  Branch (769:12): [True: 0, False: 0]
  ------------------
  770|      0|    return max_with_header - 4;
  771|      0|  else
  772|      0|    return max_with_header - COAP_PDU_MAX_TCP_HEADER_SIZE;
  ------------------
  |  |  108|      0|#define COAP_PDU_MAX_TCP_HEADER_SIZE 6
  ------------------
  773|      0|#endif /* !COAP_DISABLE_TCP */
  774|      0|}
coap_session.c:coap_make_session:
  469|     35|                  coap_context_t *context, coap_endpoint_t *endpoint) {
  470|     35|  coap_session_t *session = (coap_session_t *)coap_malloc_type(COAP_SESSION,
  471|     35|                            sizeof(coap_session_t));
  472|       |#if ! COAP_SERVER_SUPPORT
  473|       |  (void)endpoint;
  474|       |#endif /* ! COAP_SERVER_SUPPORT */
  475|     35|  if (!session)
  ------------------
  |  Branch (475:7): [True: 0, False: 35]
  ------------------
  476|      0|    return NULL;
  477|     35|  memset(session, 0, sizeof(*session));
  478|     35|  session->proto = proto;
  479|     35|  session->type = type;
  480|     35|  if (addr_hash)
  ------------------
  |  Branch (480:7): [True: 0, False: 35]
  ------------------
  481|      0|    memcpy(&session->addr_hash, addr_hash, sizeof(session->addr_hash));
  482|     35|  else
  483|     35|    memset(&session->addr_hash, 0, sizeof(session->addr_hash));
  484|     35|  if (local_addr) {
  ------------------
  |  Branch (484:7): [True: 0, False: 35]
  ------------------
  485|      0|    coap_address_copy(&session->addr_info.local, local_addr);
  486|      0|#if COAP_CLIENT_SUPPORT
  487|      0|    coap_address_copy(&session->local_reconnect, local_addr);
  488|      0|#endif /* COAP_CLIENT_SUPPORT */
  489|     35|  } else {
  490|     35|    coap_address_init(&session->addr_info.local);
  491|     35|#if COAP_CLIENT_SUPPORT
  492|     35|    coap_address_init(&session->local_reconnect);
  493|     35|#endif /* COAP_CLIENT_SUPPORT */
  494|     35|  }
  495|     35|  if (remote_addr)
  ------------------
  |  Branch (495:7): [True: 35, False: 0]
  ------------------
  496|     35|    coap_address_copy(&session->addr_info.remote, remote_addr);
  497|      0|  else
  498|      0|    coap_address_init(&session->addr_info.remote);
  499|     35|  session->ifindex = ifindex;
  500|     35|  session->context = context;
  501|     35|#if COAP_CLIENT_SUPPORT
  502|     35|  if (type == COAP_SESSION_TYPE_CLIENT) {
  ------------------
  |  Branch (502:7): [True: 35, False: 0]
  ------------------
  503|     35|    session->client_initiated = 1;
  504|     35|  }
  505|     35|#endif /* COAP_CLIENT_SUPPORT */
  506|     35|#if COAP_SERVER_SUPPORT
  507|     35|  session->endpoint = endpoint;
  508|     35|  if (endpoint)
  ------------------
  |  Branch (508:7): [True: 0, False: 35]
  ------------------
  509|      0|    session->mtu = endpoint->default_mtu;
  510|     35|  else
  511|     35|#endif /* COAP_SERVER_SUPPORT */
  512|     35|    coap_session_set_mtu(session, COAP_DEFAULT_MTU);
  ------------------
  |  |   43|     35|#define COAP_DEFAULT_MTU       1152
  ------------------
  513|     35|  session->block_mode = context->block_mode;
  514|     35|#if COAP_Q_BLOCK_SUPPORT
  515|     35|  if (session->block_mode & COAP_BLOCK_FORCE_Q_BLOCK) {
  ------------------
  |  |   74|     35|#define COAP_BLOCK_FORCE_Q_BLOCK  0x200 /* force Q-Block method without support check */
  ------------------
  |  Branch (515:7): [True: 0, False: 35]
  ------------------
  516|      0|    set_block_mode_has_q(session->block_mode);
  ------------------
  |  |   83|      0|  do { \
  |  |   84|      0|    block_mode |= COAP_BLOCK_HAS_Q_BLOCK; \
  |  |  ------------------
  |  |  |  |   73|      0|#define COAP_BLOCK_HAS_Q_BLOCK   0x40000000 /* Set when Q_BLOCK supported */
  |  |  ------------------
  |  |   85|      0|    block_mode &= ~(COAP_BLOCK_TRY_Q_BLOCK | COAP_BLOCK_PROBE_Q_BLOCK); \
  |  |  ------------------
  |  |  |  |   67|      0|#define COAP_BLOCK_TRY_Q_BLOCK   0x04 /* Try Q-Block method */
  |  |  ------------------
  |  |                   block_mode &= ~(COAP_BLOCK_TRY_Q_BLOCK | COAP_BLOCK_PROBE_Q_BLOCK); \
  |  |  ------------------
  |  |  |  |   74|      0|#define COAP_BLOCK_PROBE_Q_BLOCK 0x80000000 /* Set when Q_BLOCK probing */
  |  |  ------------------
  |  |   86|      0|  } while (0)
  |  |  ------------------
  |  |  |  Branch (86:12): [Folded, False: 0]
  |  |  ------------------
  ------------------
  517|      0|  }
  518|     35|#endif
  519|     35|  if (proto == COAP_PROTO_DTLS) {
  ------------------
  |  Branch (519:7): [True: 0, False: 35]
  ------------------
  520|      0|    session->tls_overhead = 29;
  521|      0|    if (session->tls_overhead >= session->mtu) {
  ------------------
  |  Branch (521:9): [True: 0, False: 0]
  ------------------
  522|      0|      session->tls_overhead = session->mtu;
  523|      0|      coap_log_err("DTLS overhead exceeds MTU\n");
  ------------------
  |  |  102|      0|#define coap_log_err(...) coap_log(COAP_LOG_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  524|      0|    }
  525|      0|  }
  526|     35|  session->rl_ticks_per_packet = context->rl_ticks_per_packet;
  527|     35|  session->ack_timeout = COAP_DEFAULT_ACK_TIMEOUT;
  ------------------
  |  |  697|     35|#define COAP_DEFAULT_ACK_TIMEOUT ((coap_fixed_point_t){2,0})
  ------------------
  528|     35|  session->ack_random_factor = COAP_DEFAULT_ACK_RANDOM_FACTOR;
  ------------------
  |  |  706|     35|#define COAP_DEFAULT_ACK_RANDOM_FACTOR ((coap_fixed_point_t){1,500})
  ------------------
  529|     35|  session->max_retransmit = COAP_DEFAULT_MAX_RETRANSMIT;
  ------------------
  |  |  714|     35|#define COAP_DEFAULT_MAX_RETRANSMIT  (4U)
  ------------------
  530|     35|  session->nstart = COAP_DEFAULT_NSTART;
  ------------------
  |  |  723|     35|#define COAP_DEFAULT_NSTART (1U)
  ------------------
  531|     35|  session->default_leisure = COAP_DEFAULT_DEFAULT_LEISURE;
  ------------------
  |  |  731|     35|#define COAP_DEFAULT_DEFAULT_LEISURE ((coap_fixed_point_t){5,0})
  ------------------
  532|     35|  session->probing_rate = COAP_DEFAULT_PROBING_RATE;
  ------------------
  |  |  739|     35|#define COAP_DEFAULT_PROBING_RATE (1U)
  ------------------
  533|     35|#if COAP_Q_BLOCK_SUPPORT
  534|     35|  session->max_payloads = COAP_DEFAULT_MAX_PAYLOADS;
  ------------------
  |  |  748|     35|#define COAP_DEFAULT_MAX_PAYLOADS (10U)
  ------------------
  535|     35|  session->non_max_retransmit = COAP_DEFAULT_NON_MAX_RETRANSMIT;
  ------------------
  |  |  757|     35|#define COAP_DEFAULT_NON_MAX_RETRANSMIT (4U)
  ------------------
  536|     35|  session->non_timeout = COAP_DEFAULT_NON_TIMEOUT;
  ------------------
  |  |  766|     35|#define COAP_DEFAULT_NON_TIMEOUT ((coap_fixed_point_t){2,0})
  ------------------
  537|     35|  session->non_receive_timeout = COAP_DEFAULT_NON_RECEIVE_TIMEOUT;
  ------------------
  |  |  775|     35|#define COAP_DEFAULT_NON_RECEIVE_TIMEOUT ((coap_fixed_point_t){4,0})
  ------------------
  538|     35|  coap_session_fix_non_probing_wait_base(session);
  539|     35|  coap_session_fix_non_partial_timeout(session);
  540|     35|#endif /* COAP_Q_BLOCK_SUPPORT */
  541|     35|  session->dtls_event = -1;
  542|     35|  session->last_ping_mid = COAP_INVALID_MID;
  ------------------
  |  |  198|     35|#define COAP_INVALID_MID -1
  ------------------
  543|     35|  session->last_resp_mid = COAP_INVALID_MID;
  ------------------
  |  |  198|     35|#define COAP_INVALID_MID -1
  ------------------
  544|     35|  session->last_con_handler_res = COAP_RESPONSE_OK;
  545|     35|  session->max_token_size = context->max_token_size; /* RFC8974 */
  546|     35|  if (session->type != COAP_SESSION_TYPE_CLIENT)
  ------------------
  |  Branch (546:7): [True: 0, False: 35]
  ------------------
  547|      0|    session->max_token_checked = COAP_EXT_T_CHECKED;
  548|       |
  549|       |  /* Randomly initialize */
  550|       |  /* TCP/TLS have no notion of mid */
  551|     35|  if (COAP_PROTO_NOT_RELIABLE(session->proto))
  ------------------
  |  |   41|     35|#define COAP_PROTO_NOT_RELIABLE(p) ((p)==COAP_PROTO_UDP || (p)==COAP_PROTO_DTLS)
  |  |  ------------------
  |  |  |  Branch (41:37): [True: 35, False: 0]
  |  |  |  Branch (41:60): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  552|     35|    coap_prng_lkd((unsigned char *)&session->tx_mid, sizeof(session->tx_mid));
  553|     35|  coap_prng_lkd((unsigned char *)&session->tx_rtag, sizeof(session->tx_rtag));
  554|       |
  555|     35|  return session;
  556|     35|}
coap_session.c:coap_session_check_connect:
 1689|     35|coap_session_check_connect(coap_session_t *session) {
 1690|     35|  if (COAP_PROTO_NOT_RELIABLE(session->proto)) {
  ------------------
  |  |   41|     35|#define COAP_PROTO_NOT_RELIABLE(p) ((p)==COAP_PROTO_UDP || (p)==COAP_PROTO_DTLS)
  |  |  ------------------
  |  |  |  Branch (41:37): [True: 35, False: 0]
  |  |  |  Branch (41:60): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1691|     35|    session->sock.lfunc[COAP_LAYER_SESSION].l_establish(session);
 1692|     35|  }
 1693|     35|#if !COAP_DISABLE_TCP
 1694|     35|  if (COAP_PROTO_RELIABLE(session->proto)) {
  ------------------
  |  |   42|     35|#define COAP_PROTO_RELIABLE(p) ((p)==COAP_PROTO_TCP || (p)==COAP_PROTO_TLS || \
  |  |  ------------------
  |  |  |  Branch (42:33): [True: 0, False: 35]
  |  |  |  Branch (42:56): [True: 0, False: 35]
  |  |  ------------------
  |  |   43|     35|                                (p)==COAP_PROTO_WS || (p)==COAP_PROTO_WSS)
  |  |  ------------------
  |  |  |  Branch (43:33): [True: 0, False: 35]
  |  |  |  Branch (43:55): [True: 0, False: 35]
  |  |  ------------------
  ------------------
 1695|      0|    if (session->sock.flags & COAP_SOCKET_WANT_CONNECT) {
  ------------------
  |  |   82|      0|#define COAP_SOCKET_WANT_CONNECT 0x0080  /**< non blocking client socket is waiting for connect */
  ------------------
  |  Branch (1695:9): [True: 0, False: 0]
  ------------------
 1696|      0|      session->state = COAP_SESSION_STATE_CONNECTING;
 1697|      0|      if (session->client_initiated) {
  ------------------
  |  Branch (1697:11): [True: 0, False: 0]
  ------------------
 1698|      0|        session->doing_first = 1;
 1699|      0|      }
 1700|      0|    } else {
 1701|       |      /* Initial connect worked immediately */
 1702|      0|      session->sock.lfunc[COAP_LAYER_SESSION].l_establish(session);
 1703|      0|    }
 1704|      0|  }
 1705|     35|#endif /* !COAP_DISABLE_TCP */
 1706|     35|  coap_ticks(&session->last_rx_tx);
 1707|     35|}
coap_session.c:coap_session_create_client:
 1559|     35|                           coap_str_const_t *ws_host) {
 1560|     35|  coap_session_t *session = NULL;
 1561|     35|  int default_port = COAP_DEFAULT_PORT;
  ------------------
  |  |   39|     35|#define COAP_DEFAULT_PORT      5683 /* CoAP default UDP/TCP port */
  ------------------
 1562|       |
 1563|     35|  assert(server);
  ------------------
  |  Branch (1563:3): [True: 35, False: 0]
  ------------------
 1564|       |
 1565|     35|  switch (proto) {
 1566|     35|  case COAP_PROTO_UDP:
  ------------------
  |  Branch (1566:3): [True: 35, False: 0]
  ------------------
 1567|     35|    default_port = COAP_DEFAULT_PORT;
  ------------------
  |  |   39|     35|#define COAP_DEFAULT_PORT      5683 /* CoAP default UDP/TCP port */
  ------------------
 1568|     35|    break;
 1569|      0|  case COAP_PROTO_DTLS:
  ------------------
  |  Branch (1569:3): [True: 0, False: 35]
  ------------------
 1570|      0|    if (!coap_dtls_is_supported()) {
  ------------------
  |  Branch (1570:9): [True: 0, False: 0]
  ------------------
 1571|      0|      coap_log_crit("coap_new_client_session*: DTLS not supported\n");
  ------------------
  |  |   96|      0|#define coap_log_crit(...) coap_log(COAP_LOG_CRIT, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1572|      0|      return NULL;
 1573|      0|    }
 1574|      0|    default_port = COAPS_DEFAULT_PORT;
  ------------------
  |  |   40|      0|#define COAPS_DEFAULT_PORT     5684 /* CoAP default UDP/TCP port for secure transmission */
  ------------------
 1575|      0|    break;
 1576|      0|  case COAP_PROTO_TCP:
  ------------------
  |  Branch (1576:3): [True: 0, False: 35]
  ------------------
 1577|      0|    if (!coap_tcp_is_supported()) {
  ------------------
  |  Branch (1577:9): [True: 0, False: 0]
  ------------------
 1578|      0|      coap_log_crit("coap_new_client_session*: TCP not supported\n");
  ------------------
  |  |   96|      0|#define coap_log_crit(...) coap_log(COAP_LOG_CRIT, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1579|      0|      return NULL;
 1580|      0|    }
 1581|      0|    default_port = COAP_DEFAULT_PORT;
  ------------------
  |  |   39|      0|#define COAP_DEFAULT_PORT      5683 /* CoAP default UDP/TCP port */
  ------------------
 1582|      0|    break;
 1583|      0|  case COAP_PROTO_TLS:
  ------------------
  |  Branch (1583:3): [True: 0, False: 35]
  ------------------
 1584|      0|    if (!coap_tls_is_supported()) {
  ------------------
  |  Branch (1584:9): [True: 0, False: 0]
  ------------------
 1585|      0|      coap_log_crit("coap_new_client_session*: TLS not supported\n");
  ------------------
  |  |   96|      0|#define coap_log_crit(...) coap_log(COAP_LOG_CRIT, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1586|      0|      return NULL;
 1587|      0|    }
 1588|      0|    default_port = COAPS_DEFAULT_PORT;
  ------------------
  |  |   40|      0|#define COAPS_DEFAULT_PORT     5684 /* CoAP default UDP/TCP port for secure transmission */
  ------------------
 1589|      0|    break;
 1590|      0|  case COAP_PROTO_WS:
  ------------------
  |  Branch (1590:3): [True: 0, False: 35]
  ------------------
 1591|      0|    if (!coap_ws_is_supported()) {
  ------------------
  |  Branch (1591:9): [True: 0, False: 0]
  ------------------
 1592|      0|      coap_log_crit("coap_new_client_session*: WS not supported\n");
  ------------------
  |  |   96|      0|#define coap_log_crit(...) coap_log(COAP_LOG_CRIT, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1593|      0|      return NULL;
 1594|      0|    }
 1595|      0|    default_port = 80;
 1596|      0|    break;
 1597|      0|  case COAP_PROTO_WSS:
  ------------------
  |  Branch (1597:3): [True: 0, False: 35]
  ------------------
 1598|      0|    if (!coap_wss_is_supported()) {
  ------------------
  |  Branch (1598:9): [True: 0, False: 0]
  ------------------
 1599|      0|      coap_log_crit("coap_new_client_session*: WSS not supported\n");
  ------------------
  |  |   96|      0|#define coap_log_crit(...) coap_log(COAP_LOG_CRIT, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1600|      0|      return NULL;
 1601|      0|    }
 1602|      0|    default_port = 443;
 1603|      0|    break;
 1604|      0|  case COAP_PROTO_NONE:
  ------------------
  |  Branch (1604:3): [True: 0, False: 35]
  ------------------
 1605|      0|  case COAP_PROTO_LAST:
  ------------------
  |  Branch (1605:3): [True: 0, False: 35]
  ------------------
 1606|      0|  default:
  ------------------
  |  Branch (1606:3): [True: 0, False: 35]
  ------------------
 1607|      0|    assert(0);
  ------------------
  |  Branch (1607:5): [Folded, False: 0]
  ------------------
 1608|      0|    return NULL;
 1609|     35|  }
 1610|     35|  session = coap_make_session(proto, COAP_SESSION_TYPE_CLIENT, NULL,
 1611|     35|                              local_if, server, 0, ctx, NULL);
 1612|     35|  if (!session)
  ------------------
  |  Branch (1612:7): [True: 0, False: 35]
  ------------------
 1613|      0|    goto error;
 1614|       |
 1615|     35|  coap_session_reference_lkd(session);
 1616|     35|  session->sock.session = session;
 1617|     35|  memcpy(&session->sock.lfunc, coap_layers_coap[proto],
 1618|     35|         sizeof(session->sock.lfunc));
 1619|       |
 1620|     35|  session->app_data = app_data;
 1621|     35|  session->app_cb = app_data ? callback : NULL;
  ------------------
  |  Branch (1621:21): [True: 0, False: 35]
  ------------------
 1622|     35|#if COAP_WS_SUPPORT
 1623|     35|  if (ws_host) {
  ------------------
  |  Branch (1623:7): [True: 0, False: 35]
  ------------------
 1624|      0|    session->ws_host = coap_new_str_const(ws_host->s, ws_host->length);
 1625|      0|  }
 1626|       |#else /* ! COAP_WS_SUPPORT */
 1627|       |  (void)ws_host;
 1628|       |#endif /* ! COAP_WS_SUPPORT */
 1629|       |
 1630|     35|  if (COAP_PROTO_NOT_RELIABLE(proto)) {
  ------------------
  |  |   41|     35|#define COAP_PROTO_NOT_RELIABLE(p) ((p)==COAP_PROTO_UDP || (p)==COAP_PROTO_DTLS)
  |  |  ------------------
  |  |  |  Branch (41:37): [True: 35, False: 0]
  |  |  |  Branch (41:60): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1631|     35|    coap_session_t *s, *rtmp;
 1632|     35|    if (!coap_netif_dgrm_connect(session, local_if, server, default_port)) {
  ------------------
  |  Branch (1632:9): [True: 0, False: 35]
  ------------------
 1633|      0|      goto error;
 1634|      0|    }
 1635|       |    /* Check that this is not a duplicate 4-tuple */
 1636|     35|    SESSIONS_ITER_CL_SAFE(ctx->sessions, s, rtmp) {
  ------------------
  |  | 1074|     35|  for ((el) = (e),                           \
  |  | 1075|     35|       (rtmp) = (el) ? (el)->hh.next : NULL; \
  |  |  ------------------
  |  |  |  Branch (1075:17): [True: 0, False: 35]
  |  |  ------------------
  |  | 1076|     35|       (el);                                 \
  |  |  ------------------
  |  |  |  Branch (1076:8): [True: 0, False: 35]
  |  |  ------------------
  |  | 1077|     35|       (el) = coap_get_next_session_cl((e), (el), &(rtmp)))
  ------------------
 1637|      0|      if (COAP_PROTO_NOT_RELIABLE(s->proto) &&
  ------------------
  |  |   41|      0|#define COAP_PROTO_NOT_RELIABLE(p) ((p)==COAP_PROTO_UDP || (p)==COAP_PROTO_DTLS)
  |  |  ------------------
  |  |  |  Branch (41:37): [True: 0, False: 0]
  |  |  |  Branch (41:60): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1638|      0|          coap_address_equals(&session->addr_info.local,
  ------------------
  |  Branch (1638:11): [True: 0, False: 0]
  ------------------
 1639|      0|                              &s->addr_info.local) &&
 1640|      0|          coap_address_equals(&session->addr_info.remote,
  ------------------
  |  Branch (1640:11): [True: 0, False: 0]
  ------------------
 1641|      0|                              &s->addr_info.remote)) {
 1642|      0|        coap_log_warn("***%s: session %p: duplicate - already exists\n",
  ------------------
  |  |  108|      0|#define coap_log_warn(...) coap_log(COAP_LOG_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1643|      0|                      coap_session_str(session), (void *)session);
 1644|      0|        goto error;
 1645|      0|      }
 1646|      0|    }
 1647|       |#ifdef WITH_CONTIKI
 1648|       |    session->sock.context = ctx;
 1649|       |#endif /* WITH_CONTIKI */
 1650|     35|#if !COAP_DISABLE_TCP
 1651|     35|  } else if (COAP_PROTO_RELIABLE(proto)) {
  ------------------
  |  |   42|      0|#define COAP_PROTO_RELIABLE(p) ((p)==COAP_PROTO_TCP || (p)==COAP_PROTO_TLS || \
  |  |  ------------------
  |  |  |  Branch (42:33): [True: 0, False: 0]
  |  |  |  Branch (42:56): [True: 0, False: 0]
  |  |  ------------------
  |  |   43|      0|                                (p)==COAP_PROTO_WS || (p)==COAP_PROTO_WSS)
  |  |  ------------------
  |  |  |  Branch (43:33): [True: 0, False: 0]
  |  |  |  Branch (43:55): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1652|      0|    if (!coap_netif_strm_connect1(session, local_if, server, default_port)) {
  ------------------
  |  Branch (1652:9): [True: 0, False: 0]
  ------------------
 1653|      0|      goto error;
 1654|      0|    }
 1655|      0|#endif /* !COAP_DISABLE_TCP */
 1656|      0|  }
 1657|       |
 1658|     35|  session->sock.session = session;
 1659|     35|#ifdef COAP_EPOLL_SUPPORT
 1660|     35|  coap_epoll_ctl_add(&session->sock,
 1661|     35|                     EPOLLIN |
 1662|     35|                     ((session->sock.flags & COAP_SOCKET_WANT_CONNECT) ?
  ------------------
  |  |   82|     35|#define COAP_SOCKET_WANT_CONNECT 0x0080  /**< non blocking client socket is waiting for connect */
  ------------------
  |  Branch (1662:23): [True: 0, False: 35]
  ------------------
 1663|     35|                      EPOLLOUT : 0),
 1664|     35|                     __func__);
 1665|     35|#endif /* COAP_EPOLL_SUPPORT */
 1666|       |
 1667|     35|  session->sock.flags |= COAP_SOCKET_NOT_EMPTY | COAP_SOCKET_WANT_READ;
  ------------------
  |  |   75|     35|#define COAP_SOCKET_NOT_EMPTY    0x0001  /**< the socket is not empty */
  ------------------
                session->sock.flags |= COAP_SOCKET_NOT_EMPTY | COAP_SOCKET_WANT_READ;
  ------------------
  |  |   79|     35|#define COAP_SOCKET_WANT_READ    0x0010  /**< non blocking socket is waiting for reading */
  ------------------
 1668|     35|  if (local_if)
  ------------------
  |  Branch (1668:7): [True: 0, False: 35]
  ------------------
 1669|      0|    session->sock.flags |= COAP_SOCKET_BOUND;
  ------------------
  |  |   76|      0|#define COAP_SOCKET_BOUND        0x0002  /**< the socket is bound */
  ------------------
 1670|     35|#if COAP_SERVER_SUPPORT
 1671|     35|  if (ctx->proxy_uri_resource)
  ------------------
  |  Branch (1671:7): [True: 0, False: 35]
  ------------------
 1672|      0|    session->proxy_session = 1;
 1673|     35|#endif /* COAP_SERVER_SUPPORT */
 1674|     35|  SESSIONS_ADD(ctx->sessions, session);
  ------------------
  |  | 1014|     35|  HASH_ADD(hh, (e), addr_hash, sizeof((obj)->addr_hash), (obj))
  |  |  ------------------
  |  |  |  |  442|     35|  HASH_ADD_KEYPTR(hh, head, &((add)->fieldname), keylen_in, add)
  |  |  |  |  ------------------
  |  |  |  |  |  |  431|     35|#define HASH_ADD_KEYPTR(hh,head,keyptr,keylen_in,add)                            \
  |  |  |  |  |  |  432|     35|do {                                                                             \
  |  |  |  |  |  |  433|     35|  uint32_t _ha_hashv;                                                            \
  |  |  |  |  |  |  434|     35|  HASH_VALUE(keyptr, keylen_in, _ha_hashv);                                      \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  162|     35|#define HASH_VALUE(keyptr,keylen,hashv)                                          \
  |  |  |  |  |  |  |  |  163|     35|do {                                                                             \
  |  |  |  |  |  |  |  |  164|     35|  HASH_FUNCTION(keyptr, keylen, hashv);                                          \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  102|     35|#define HASH_FUNCTION(keyptr,keylen,hashv) HASH_JEN(keyptr, keylen, hashv)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  658|     35|#define HASH_JEN(key,keylen,hashv)                                               \
  |  |  |  |  |  |  |  |  |  |  |  |  659|     35|do {                                                                             \
  |  |  |  |  |  |  |  |  |  |  |  |  660|     35|  uint32_t _hj_i,_hj_j,_hj_k;                                                    \
  |  |  |  |  |  |  |  |  |  |  |  |  661|     35|  unsigned const char *_hj_key=(unsigned const char*)(key);                      \
  |  |  |  |  |  |  |  |  |  |  |  |  662|     35|  hashv = 0xfeedbeefu;                                                           \
  |  |  |  |  |  |  |  |  |  |  |  |  663|     35|  _hj_i = _hj_j = 0x9e3779b9u;                                                   \
  |  |  |  |  |  |  |  |  |  |  |  |  664|     35|  _hj_k = (uint32_t)(keylen);                                                    \
  |  |  |  |  |  |  |  |  |  |  |  |  665|    140|  while (_hj_k >= 12U) {                                                         \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (665:10): [True: 105, False: 35]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  666|    105|    _hj_i = (int64_t)_hj_i + (_hj_key[0] + ( (uint32_t)_hj_key[1] << 8 )         \
  |  |  |  |  |  |  |  |  |  |  |  |  667|    105|        + ( (uint32_t)_hj_key[2] << 16 )                                         \
  |  |  |  |  |  |  |  |  |  |  |  |  668|    105|        + ( (uint32_t)_hj_key[3] << 24 ) );                                      \
  |  |  |  |  |  |  |  |  |  |  |  |  669|    105|    _hj_j = (int64_t)_hj_j + (_hj_key[4] + ( (uint32_t)_hj_key[5] << 8 )         \
  |  |  |  |  |  |  |  |  |  |  |  |  670|    105|        + ( (uint32_t)_hj_key[6] << 16 )                                         \
  |  |  |  |  |  |  |  |  |  |  |  |  671|    105|        + ( (uint32_t)_hj_key[7] << 24 ) );                                      \
  |  |  |  |  |  |  |  |  |  |  |  |  672|    105|    hashv = (int64_t)hashv + (_hj_key[8] + ( (uint32_t)_hj_key[9] << 8 )         \
  |  |  |  |  |  |  |  |  |  |  |  |  673|    105|        + ( (uint32_t)_hj_key[10] << 16 )                                        \
  |  |  |  |  |  |  |  |  |  |  |  |  674|    105|        + ( (uint32_t)_hj_key[11] << 24 ) );                                     \
  |  |  |  |  |  |  |  |  |  |  |  |  675|    105|                                                                                 \
  |  |  |  |  |  |  |  |  |  |  |  |  676|    105|     HASH_JEN_MIX(_hj_i, _hj_j, hashv);                                          \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  645|    105|#define HASH_JEN_MIX(a,b,c)                                                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  646|    105|do {                                                                             \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  647|    105|  a = (int64_t)a - b; a = (int64_t)a - c; a ^= ( c >> 13 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  648|    105|  b = (int64_t)b - c; b = (int64_t)b - a; b ^= ( a << 8 );                       \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  649|    105|  c = (int64_t)c - a; c = (int64_t)c - b; c ^= ( b >> 13 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  650|    105|  a = (int64_t)a - b; a = (int64_t)a - c; a ^= ( c >> 12 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  651|    105|  b = (int64_t)b - c; b = (int64_t)b - a; b ^= ( a << 16 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  652|    105|  c = (int64_t)c - a; c = (int64_t)c - b; c ^= ( b >> 5 );                       \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  653|    105|  a = (int64_t)a - b; a = (int64_t)a - c; a ^= ( c >> 3 );                       \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  654|    105|  b = (int64_t)b - c; b = (int64_t)b - a; b ^= ( a << 10 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  655|    105|  c = (int64_t)c - a; c = (int64_t)c - b; c ^= ( b >> 15 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  656|    105|} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (656:10): [Folded, False: 105]
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  677|    105|                                                                                 \
  |  |  |  |  |  |  |  |  |  |  |  |  678|    105|     _hj_key += 12;                                                              \
  |  |  |  |  |  |  |  |  |  |  |  |  679|    105|     _hj_k -= 12U;                                                               \
  |  |  |  |  |  |  |  |  |  |  |  |  680|    105|  }                                                                              \
  |  |  |  |  |  |  |  |  |  |  |  |  681|     35|  hashv += (uint32_t)(keylen);                                                   \
  |  |  |  |  |  |  |  |  |  |  |  |  682|     35|  switch ( _hj_k ) {                                                             \
  |  |  |  |  |  |  |  |  |  |  |  |  683|      0|    case 11: hashv = (int64_t)hashv + ( (uint32_t)_hj_key[10] << 24 ); /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (683:5): [True: 0, False: 35]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  684|      0|    case 10: hashv = (int64_t)hashv + ( (uint32_t)_hj_key[9] << 16 );  /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (684:5): [True: 0, False: 35]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  685|      0|    case 9:  hashv = (int64_t)hashv + ( (uint32_t)_hj_key[8] << 8 );   /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (685:5): [True: 0, False: 35]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  686|      0|    case 8:  _hj_j = (int64_t)_hj_j + ( (uint32_t)_hj_key[7] << 24 );  /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (686:5): [True: 0, False: 35]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  687|      0|    case 7:  _hj_j = (int64_t)_hj_j + ( (uint32_t)_hj_key[6] << 16 );  /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (687:5): [True: 0, False: 35]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  688|      0|    case 6:  _hj_j = (int64_t)_hj_j + ( (uint32_t)_hj_key[5] << 8 );   /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (688:5): [True: 0, False: 35]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  689|      0|    case 5:  _hj_j = (int64_t)_hj_j + _hj_key[4];                      /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (689:5): [True: 0, False: 35]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  690|     35|    case 4:  _hj_i = (int64_t)_hj_i + ( (uint32_t)_hj_key[3] << 24 );  /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (690:5): [True: 35, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  691|     35|    case 3:  _hj_i = (int64_t)_hj_i + ( (uint32_t)_hj_key[2] << 16 );  /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (691:5): [True: 0, False: 35]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  692|     35|    case 2:  _hj_i = (int64_t)_hj_i + ( (uint32_t)_hj_key[1] << 8 );   /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (692:5): [True: 0, False: 35]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  693|     35|    case 1:  _hj_i = (int64_t)_hj_i + _hj_key[0];                      /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (693:5): [True: 0, False: 35]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  694|     35|    default: ;                                                                   \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (694:5): [True: 0, False: 35]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  695|     35|  }                                                                              \
  |  |  |  |  |  |  |  |  |  |  |  |  696|     35|  HASH_JEN_MIX(_hj_i, _hj_j, hashv);                                             \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  645|     35|#define HASH_JEN_MIX(a,b,c)                                                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  646|     35|do {                                                                             \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  647|     35|  a = (int64_t)a - b; a = (int64_t)a - c; a ^= ( c >> 13 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  648|     35|  b = (int64_t)b - c; b = (int64_t)b - a; b ^= ( a << 8 );                       \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  649|     35|  c = (int64_t)c - a; c = (int64_t)c - b; c ^= ( b >> 13 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  650|     35|  a = (int64_t)a - b; a = (int64_t)a - c; a ^= ( c >> 12 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  651|     35|  b = (int64_t)b - c; b = (int64_t)b - a; b ^= ( a << 16 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  652|     35|  c = (int64_t)c - a; c = (int64_t)c - b; c ^= ( b >> 5 );                       \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  653|     35|  a = (int64_t)a - b; a = (int64_t)a - c; a ^= ( c >> 3 );                       \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  654|     35|  b = (int64_t)b - c; b = (int64_t)b - a; b ^= ( a << 10 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  655|     35|  c = (int64_t)c - a; c = (int64_t)c - b; c ^= ( b >> 15 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  656|     35|} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (656:10): [Folded, False: 35]
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  697|     35|} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (697:10): [Folded, False: 35]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  165|     35|} while (0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (165:10): [Folded, False: 35]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  435|     35|  HASH_ADD_KEYPTR_BYHASHVALUE(hh, head, keyptr, keylen_in, _ha_hashv, add);      \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  410|     35|#define HASH_ADD_KEYPTR_BYHASHVALUE(hh,head,keyptr,keylen_in,hashval,add)        \
  |  |  |  |  |  |  |  |  411|     35|do {                                                                             \
  |  |  |  |  |  |  |  |  412|     35|  IF_HASH_NONFATAL_OOM( int _ha_oomed = 0; )                                     \
  |  |  |  |  |  |  |  |  413|     35|  (add)->hh.hashv = (hashval);                                                   \
  |  |  |  |  |  |  |  |  414|     35|  (add)->hh.key = (const void*) (keyptr);                                        \
  |  |  |  |  |  |  |  |  415|     35|  (add)->hh.keylen = (uint32_t) (keylen_in);                                     \
  |  |  |  |  |  |  |  |  416|     35|  if (!(head)) {                                                                 \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (416:7): [True: 35, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  417|     35|    (add)->hh.next = NULL;                                                       \
  |  |  |  |  |  |  |  |  418|     35|    (add)->hh.prev = NULL;                                                       \
  |  |  |  |  |  |  |  |  419|     35|    HASH_MAKE_TABLE(hh, add, _ha_oomed);                                         \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  226|     35|#define HASH_MAKE_TABLE(hh,head,oomed)                                           \
  |  |  |  |  |  |  |  |  |  |  227|     35|do {                                                                             \
  |  |  |  |  |  |  |  |  |  |  228|     35|  (head)->hh.tbl = (UT_hash_table*)uthash_malloc(sizeof(UT_hash_table));         \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   89|     35|#define uthash_malloc(sz) malloc(sz)      /* malloc fcn                      */
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  229|     35|  if (!(head)->hh.tbl) {                                                         \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (229:7): [True: 0, False: 35]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  230|      0|    HASH_RECORD_OOM(oomed);                                                      \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  137|      0|#define HASH_RECORD_OOM(oomed) uthash_fatal("out of memory")
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  134|      0|#define uthash_fatal(msg) exit(-1)        /* fatal OOM error */
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  231|     35|  } else {                                                                       \
  |  |  |  |  |  |  |  |  |  |  232|     35|    uthash_bzero((head)->hh.tbl, sizeof(UT_hash_table));                         \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   95|     35|#define uthash_bzero(a,n) memset(a,'\0',n)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  233|     35|    (head)->hh.tbl->tail = &((head)->hh);                                        \
  |  |  |  |  |  |  |  |  |  |  234|     35|    (head)->hh.tbl->num_buckets = HASH_INITIAL_NUM_BUCKETS;                      \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  143|     35|#define HASH_INITIAL_NUM_BUCKETS 32U     /* initial number of buckets        */
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  235|     35|    (head)->hh.tbl->log2_num_buckets = HASH_INITIAL_NUM_BUCKETS_LOG2;            \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  144|     35|#define HASH_INITIAL_NUM_BUCKETS_LOG2 5U /* lg2 of initial number of buckets */
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  236|     35|    (head)->hh.tbl->hho = (char*)(&(head)->hh) - (char*)(head);                  \
  |  |  |  |  |  |  |  |  |  |  237|     35|    (head)->hh.tbl->buckets = (UT_hash_bucket*)uthash_malloc(                    \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   89|     35|#define uthash_malloc(sz) malloc(sz)      /* malloc fcn                      */
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  238|     35|        HASH_INITIAL_NUM_BUCKETS * sizeof(struct UT_hash_bucket));               \
  |  |  |  |  |  |  |  |  |  |  239|     35|    (head)->hh.tbl->signature = HASH_SIGNATURE;                                  \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  | 1101|     35|#define HASH_SIGNATURE 0xa0111fe1u
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  240|     35|    if (!(head)->hh.tbl->buckets) {                                              \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (240:9): [True: 0, False: 35]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  241|      0|      HASH_RECORD_OOM(oomed);                                                    \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  137|      0|#define HASH_RECORD_OOM(oomed) uthash_fatal("out of memory")
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  134|      0|#define uthash_fatal(msg) exit(-1)        /* fatal OOM error */
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  242|      0|      uthash_free((head)->hh.tbl, sizeof(UT_hash_table));                        \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   92|      0|#define uthash_free(ptr,sz) free(ptr)     /* free fcn                        */
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  243|     35|    } else {                                                                     \
  |  |  |  |  |  |  |  |  |  |  244|     35|      uthash_bzero((head)->hh.tbl->buckets,                                      \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   95|     35|#define uthash_bzero(a,n) memset(a,'\0',n)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  245|     35|          HASH_INITIAL_NUM_BUCKETS * sizeof(struct UT_hash_bucket));             \
  |  |  |  |  |  |  |  |  |  |  246|     35|      HASH_BLOOM_MAKE((head)->hh.tbl, oomed);                                    \
  |  |  |  |  |  |  |  |  |  |  247|     35|      IF_HASH_NONFATAL_OOM(                                                      \
  |  |  |  |  |  |  |  |  |  |  248|     35|        if (oomed) {                                                             \
  |  |  |  |  |  |  |  |  |  |  249|     35|          uthash_free((head)->hh.tbl->buckets,                                   \
  |  |  |  |  |  |  |  |  |  |  250|     35|              HASH_INITIAL_NUM_BUCKETS*sizeof(struct UT_hash_bucket));           \
  |  |  |  |  |  |  |  |  |  |  251|     35|          uthash_free((head)->hh.tbl, sizeof(UT_hash_table));                    \
  |  |  |  |  |  |  |  |  |  |  252|     35|        }                                                                        \
  |  |  |  |  |  |  |  |  |  |  253|     35|      )                                                                          \
  |  |  |  |  |  |  |  |  |  |  254|     35|    }                                                                            \
  |  |  |  |  |  |  |  |  |  |  255|     35|  }                                                                              \
  |  |  |  |  |  |  |  |  |  |  256|     35|} while (0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (256:10): [Folded, False: 35]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  420|     35|    IF_HASH_NONFATAL_OOM( if (!_ha_oomed) { )                                    \
  |  |  |  |  |  |  |  |  421|     35|      (head) = (add);                                                            \
  |  |  |  |  |  |  |  |  422|     35|    IF_HASH_NONFATAL_OOM( } )                                                    \
  |  |  |  |  |  |  |  |  423|     35|  } else {                                                                       \
  |  |  |  |  |  |  |  |  424|      0|    (add)->hh.tbl = (head)->hh.tbl;                                              \
  |  |  |  |  |  |  |  |  425|      0|    HASH_APPEND_LIST(hh, head, add);                                             \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  292|      0|#define HASH_APPEND_LIST(hh, head, add)                                          \
  |  |  |  |  |  |  |  |  |  |  293|      0|do {                                                                             \
  |  |  |  |  |  |  |  |  |  |  294|      0|  (add)->hh.next = NULL;                                                         \
  |  |  |  |  |  |  |  |  |  |  295|      0|  (add)->hh.prev = ELMT_FROM_HH((head)->hh.tbl, (head)->hh.tbl->tail);           \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  148|      0|#define ELMT_FROM_HH(tbl,hhp) ((void*)(((char*)(hhp)) - ((tbl)->hho)))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  296|      0|  (head)->hh.tbl->tail->next = (add);                                            \
  |  |  |  |  |  |  |  |  |  |  297|      0|  (head)->hh.tbl->tail = &((add)->hh);                                           \
  |  |  |  |  |  |  |  |  |  |  298|      0|} while (0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (298:10): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  426|      0|  }                                                                              \
  |  |  |  |  |  |  |  |  427|     35|  HASH_ADD_TO_TABLE(hh, head, keyptr, keylen_in, hashval, add, _ha_oomed);       \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  351|     35|#define HASH_ADD_TO_TABLE(hh,head,keyptr,keylen_in,hashval,add,oomed)            \
  |  |  |  |  |  |  |  |  |  |  352|     35|do {                                                                             \
  |  |  |  |  |  |  |  |  |  |  353|     35|  uint32_t _ha_bkt;                                                              \
  |  |  |  |  |  |  |  |  |  |  354|     35|  (head)->hh.tbl->num_items++;                                                   \
  |  |  |  |  |  |  |  |  |  |  355|     35|  HASH_TO_BKT(hashval, (head)->hh.tbl->num_buckets, _ha_bkt);                    \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  444|     35|#define HASH_TO_BKT(hashv,num_bkts,bkt)                                          \
  |  |  |  |  |  |  |  |  |  |  |  |  445|     35|do {                                                                             \
  |  |  |  |  |  |  |  |  |  |  |  |  446|     35|  bkt = ((hashv) & ((num_bkts) - 1U));                                           \
  |  |  |  |  |  |  |  |  |  |  |  |  447|     35|} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (447:10): [Folded, False: 35]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  356|     35|  HASH_ADD_TO_BKT((head)->hh.tbl->buckets[_ha_bkt], hh, &(add)->hh, oomed);      \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  778|     35|#define HASH_ADD_TO_BKT(head,hh,addhh,oomed)                                     \
  |  |  |  |  |  |  |  |  |  |  |  |  779|     35|do {                                                                             \
  |  |  |  |  |  |  |  |  |  |  |  |  780|     35|  UT_hash_bucket *_ha_head = &(head);                                            \
  |  |  |  |  |  |  |  |  |  |  |  |  781|     35|  _ha_head->count++;                                                             \
  |  |  |  |  |  |  |  |  |  |  |  |  782|     35|  (addhh)->hh_next = _ha_head->hh_head;                                          \
  |  |  |  |  |  |  |  |  |  |  |  |  783|     35|  (addhh)->hh_prev = NULL;                                                       \
  |  |  |  |  |  |  |  |  |  |  |  |  784|     35|  if (_ha_head->hh_head != NULL) {                                               \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (784:7): [True: 0, False: 35]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  785|      0|    _ha_head->hh_head->hh_prev = (addhh);                                        \
  |  |  |  |  |  |  |  |  |  |  |  |  786|      0|  }                                                                              \
  |  |  |  |  |  |  |  |  |  |  |  |  787|     35|  _ha_head->hh_head = (addhh);                                                   \
  |  |  |  |  |  |  |  |  |  |  |  |  788|     35|  if ((_ha_head->count >= ((_ha_head->expand_mult + 1U) * HASH_BKT_CAPACITY_THRESH)) \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  145|     35|#define HASH_BKT_CAPACITY_THRESH 10U     /* expand when bucket count reaches */
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (788:7): [True: 0, False: 35]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  789|     35|      && !(addhh)->tbl->noexpand) {                                              \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (789:10): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  790|      0|    HASH_EXPAND_BUCKETS(addhh,(addhh)->tbl, oomed);                              \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  844|      0|#define HASH_EXPAND_BUCKETS(hh,tbl,oomed)                                        \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  845|      0|do {                                                                             \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  846|      0|  uint32_t _he_bkt;                                                              \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  847|      0|  uint32_t _he_bkt_i;                                                            \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  848|      0|  struct UT_hash_handle *_he_thh, *_he_hh_nxt;                                   \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  849|      0|  UT_hash_bucket *_he_new_buckets, *_he_newbkt;                                  \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  850|      0|  _he_new_buckets = (UT_hash_bucket*)uthash_malloc(                              \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   89|      0|#define uthash_malloc(sz) malloc(sz)      /* malloc fcn                      */
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  851|      0|           sizeof(struct UT_hash_bucket) * (tbl)->num_buckets * 2U);             \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  852|      0|  if (!_he_new_buckets) {                                                        \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (852:7): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  853|      0|    HASH_RECORD_OOM(oomed);                                                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  137|      0|#define HASH_RECORD_OOM(oomed) uthash_fatal("out of memory")
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  134|      0|#define uthash_fatal(msg) exit(-1)        /* fatal OOM error */
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  854|      0|  } else {                                                                       \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  855|      0|    uthash_bzero(_he_new_buckets,                                                \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   95|      0|#define uthash_bzero(a,n) memset(a,'\0',n)
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  856|      0|        sizeof(struct UT_hash_bucket) * (tbl)->num_buckets * 2U);                \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  857|      0|    (tbl)->ideal_chain_maxlen =                                                  \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  858|      0|       ((tbl)->num_items >> ((tbl)->log2_num_buckets+1U)) +                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  859|      0|       ((((tbl)->num_items & (((tbl)->num_buckets*2U)-1U)) != 0U) ? 1U : 0U);    \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (859:9): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  860|      0|    (tbl)->nonideal_items = 0;                                                   \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  861|      0|    for (_he_bkt_i = 0; _he_bkt_i < (tbl)->num_buckets; _he_bkt_i++) {           \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (861:25): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  862|      0|      _he_thh = (tbl)->buckets[ _he_bkt_i ].hh_head;                             \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  863|      0|      while (_he_thh != NULL) {                                                  \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (863:14): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  864|      0|        _he_hh_nxt = _he_thh->hh_next;                                           \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  865|      0|        HASH_TO_BKT(_he_thh->hashv, (tbl)->num_buckets * 2U, _he_bkt);           \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  444|      0|#define HASH_TO_BKT(hashv,num_bkts,bkt)                                          \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  445|      0|do {                                                                             \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  446|      0|  bkt = ((hashv) & ((num_bkts) - 1U));                                           \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  447|      0|} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (447:10): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  866|      0|        _he_newbkt = &(_he_new_buckets[_he_bkt]);                                \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  867|      0|        if (++(_he_newbkt->count) > (tbl)->ideal_chain_maxlen) {                 \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (867:13): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  868|      0|          (tbl)->nonideal_items++;                                               \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  869|      0|          if (_he_newbkt->count > _he_newbkt->expand_mult * (tbl)->ideal_chain_maxlen) { \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (869:15): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  870|      0|            _he_newbkt->expand_mult++;                                           \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  871|      0|          }                                                                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  872|      0|        }                                                                        \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  873|      0|        _he_thh->hh_prev = NULL;                                                 \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  874|      0|        _he_thh->hh_next = _he_newbkt->hh_head;                                  \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  875|      0|        if (_he_newbkt->hh_head != NULL) {                                       \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (875:13): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  876|      0|          _he_newbkt->hh_head->hh_prev = _he_thh;                                \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  877|      0|        }                                                                        \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  878|      0|        _he_newbkt->hh_head = _he_thh;                                           \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  879|      0|        _he_thh = _he_hh_nxt;                                                    \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  880|      0|      }                                                                          \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  881|      0|    }                                                                            \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  882|      0|    uthash_free((tbl)->buckets, (tbl)->num_buckets * sizeof(struct UT_hash_bucket)); \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   92|      0|#define uthash_free(ptr,sz) free(ptr)     /* free fcn                        */
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  883|      0|    (tbl)->num_buckets *= 2U;                                                    \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  884|      0|    (tbl)->log2_num_buckets++;                                                   \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  885|      0|    (tbl)->buckets = _he_new_buckets;                                            \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  886|      0|    (tbl)->ineff_expands = ((tbl)->nonideal_items > ((tbl)->num_items >> 1)) ?   \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (886:28): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  887|      0|        ((tbl)->ineff_expands+1U) : 0U;                                          \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  888|      0|    if ((tbl)->ineff_expands > 1U) {                                             \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (888:9): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  889|      0|      (tbl)->noexpand = 1;                                                       \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  890|      0|      uthash_noexpand_fyi(tbl);                                                  \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  891|      0|    }                                                                            \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  892|      0|    uthash_expand_fyi(tbl);                                                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  893|      0|  }                                                                              \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  894|      0|} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (894:10): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  791|      0|    IF_HASH_NONFATAL_OOM(                                                        \
  |  |  |  |  |  |  |  |  |  |  |  |  792|      0|      if (oomed) {                                                               \
  |  |  |  |  |  |  |  |  |  |  |  |  793|      0|        HASH_DEL_IN_BKT(head,addhh);                                             \
  |  |  |  |  |  |  |  |  |  |  |  |  794|      0|      }                                                                          \
  |  |  |  |  |  |  |  |  |  |  |  |  795|      0|    )                                                                            \
  |  |  |  |  |  |  |  |  |  |  |  |  796|      0|  }                                                                              \
  |  |  |  |  |  |  |  |  |  |  |  |  797|     35|} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (797:10): [Folded, False: 35]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  357|     35|  HASH_BLOOM_ADD((head)->hh.tbl, hashval);                                       \
  |  |  |  |  |  |  |  |  |  |  358|     35|  HASH_EMIT_KEY(hh, head, keyptr, keylen_in);                                    \
  |  |  |  |  |  |  |  |  |  |  359|     35|} while (0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (359:10): [Folded, False: 35]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  428|     35|  HASH_FSCK(hh, head, "HASH_ADD_KEYPTR_BYHASHVALUE");                            \
  |  |  |  |  |  |  |  |  429|     35|} while (0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (429:10): [Folded, False: 35]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  436|     35|} while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (436:10): [Folded, False: 35]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1675|     35|  return session;
 1676|       |
 1677|      0|error:
 1678|       |  /*
 1679|       |   * Need to add in the session as coap_session_release_lkd()
 1680|       |   * will call SESSIONS_DELETE in coap_session_free().
 1681|       |   */
 1682|      0|  if (session)
  ------------------
  |  Branch (1682:7): [True: 0, False: 0]
  ------------------
 1683|      0|    SESSIONS_ADD(ctx->sessions, session);
  ------------------
  |  | 1014|      0|  HASH_ADD(hh, (e), addr_hash, sizeof((obj)->addr_hash), (obj))
  |  |  ------------------
  |  |  |  |  442|      0|  HASH_ADD_KEYPTR(hh, head, &((add)->fieldname), keylen_in, add)
  |  |  |  |  ------------------
  |  |  |  |  |  |  431|      0|#define HASH_ADD_KEYPTR(hh,head,keyptr,keylen_in,add)                            \
  |  |  |  |  |  |  432|      0|do {                                                                             \
  |  |  |  |  |  |  433|      0|  uint32_t _ha_hashv;                                                            \
  |  |  |  |  |  |  434|      0|  HASH_VALUE(keyptr, keylen_in, _ha_hashv);                                      \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  162|      0|#define HASH_VALUE(keyptr,keylen,hashv)                                          \
  |  |  |  |  |  |  |  |  163|      0|do {                                                                             \
  |  |  |  |  |  |  |  |  164|      0|  HASH_FUNCTION(keyptr, keylen, hashv);                                          \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  102|      0|#define HASH_FUNCTION(keyptr,keylen,hashv) HASH_JEN(keyptr, keylen, hashv)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  658|      0|#define HASH_JEN(key,keylen,hashv)                                               \
  |  |  |  |  |  |  |  |  |  |  |  |  659|      0|do {                                                                             \
  |  |  |  |  |  |  |  |  |  |  |  |  660|      0|  uint32_t _hj_i,_hj_j,_hj_k;                                                    \
  |  |  |  |  |  |  |  |  |  |  |  |  661|      0|  unsigned const char *_hj_key=(unsigned const char*)(key);                      \
  |  |  |  |  |  |  |  |  |  |  |  |  662|      0|  hashv = 0xfeedbeefu;                                                           \
  |  |  |  |  |  |  |  |  |  |  |  |  663|      0|  _hj_i = _hj_j = 0x9e3779b9u;                                                   \
  |  |  |  |  |  |  |  |  |  |  |  |  664|      0|  _hj_k = (uint32_t)(keylen);                                                    \
  |  |  |  |  |  |  |  |  |  |  |  |  665|      0|  while (_hj_k >= 12U) {                                                         \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (665:10): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  666|      0|    _hj_i = (int64_t)_hj_i + (_hj_key[0] + ( (uint32_t)_hj_key[1] << 8 )         \
  |  |  |  |  |  |  |  |  |  |  |  |  667|      0|        + ( (uint32_t)_hj_key[2] << 16 )                                         \
  |  |  |  |  |  |  |  |  |  |  |  |  668|      0|        + ( (uint32_t)_hj_key[3] << 24 ) );                                      \
  |  |  |  |  |  |  |  |  |  |  |  |  669|      0|    _hj_j = (int64_t)_hj_j + (_hj_key[4] + ( (uint32_t)_hj_key[5] << 8 )         \
  |  |  |  |  |  |  |  |  |  |  |  |  670|      0|        + ( (uint32_t)_hj_key[6] << 16 )                                         \
  |  |  |  |  |  |  |  |  |  |  |  |  671|      0|        + ( (uint32_t)_hj_key[7] << 24 ) );                                      \
  |  |  |  |  |  |  |  |  |  |  |  |  672|      0|    hashv = (int64_t)hashv + (_hj_key[8] + ( (uint32_t)_hj_key[9] << 8 )         \
  |  |  |  |  |  |  |  |  |  |  |  |  673|      0|        + ( (uint32_t)_hj_key[10] << 16 )                                        \
  |  |  |  |  |  |  |  |  |  |  |  |  674|      0|        + ( (uint32_t)_hj_key[11] << 24 ) );                                     \
  |  |  |  |  |  |  |  |  |  |  |  |  675|      0|                                                                                 \
  |  |  |  |  |  |  |  |  |  |  |  |  676|      0|     HASH_JEN_MIX(_hj_i, _hj_j, hashv);                                          \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  645|      0|#define HASH_JEN_MIX(a,b,c)                                                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  646|      0|do {                                                                             \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  647|      0|  a = (int64_t)a - b; a = (int64_t)a - c; a ^= ( c >> 13 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  648|      0|  b = (int64_t)b - c; b = (int64_t)b - a; b ^= ( a << 8 );                       \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  649|      0|  c = (int64_t)c - a; c = (int64_t)c - b; c ^= ( b >> 13 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  650|      0|  a = (int64_t)a - b; a = (int64_t)a - c; a ^= ( c >> 12 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  651|      0|  b = (int64_t)b - c; b = (int64_t)b - a; b ^= ( a << 16 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  652|      0|  c = (int64_t)c - a; c = (int64_t)c - b; c ^= ( b >> 5 );                       \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  653|      0|  a = (int64_t)a - b; a = (int64_t)a - c; a ^= ( c >> 3 );                       \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  654|      0|  b = (int64_t)b - c; b = (int64_t)b - a; b ^= ( a << 10 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  655|      0|  c = (int64_t)c - a; c = (int64_t)c - b; c ^= ( b >> 15 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  656|      0|} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (656:10): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  677|      0|                                                                                 \
  |  |  |  |  |  |  |  |  |  |  |  |  678|      0|     _hj_key += 12;                                                              \
  |  |  |  |  |  |  |  |  |  |  |  |  679|      0|     _hj_k -= 12U;                                                               \
  |  |  |  |  |  |  |  |  |  |  |  |  680|      0|  }                                                                              \
  |  |  |  |  |  |  |  |  |  |  |  |  681|      0|  hashv += (uint32_t)(keylen);                                                   \
  |  |  |  |  |  |  |  |  |  |  |  |  682|      0|  switch ( _hj_k ) {                                                             \
  |  |  |  |  |  |  |  |  |  |  |  |  683|      0|    case 11: hashv = (int64_t)hashv + ( (uint32_t)_hj_key[10] << 24 ); /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (683:5): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  684|      0|    case 10: hashv = (int64_t)hashv + ( (uint32_t)_hj_key[9] << 16 );  /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (684:5): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  685|      0|    case 9:  hashv = (int64_t)hashv + ( (uint32_t)_hj_key[8] << 8 );   /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (685:5): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  686|      0|    case 8:  _hj_j = (int64_t)_hj_j + ( (uint32_t)_hj_key[7] << 24 );  /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (686:5): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  687|      0|    case 7:  _hj_j = (int64_t)_hj_j + ( (uint32_t)_hj_key[6] << 16 );  /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (687:5): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  688|      0|    case 6:  _hj_j = (int64_t)_hj_j + ( (uint32_t)_hj_key[5] << 8 );   /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (688:5): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  689|      0|    case 5:  _hj_j = (int64_t)_hj_j + _hj_key[4];                      /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (689:5): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  690|      0|    case 4:  _hj_i = (int64_t)_hj_i + ( (uint32_t)_hj_key[3] << 24 );  /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (690:5): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  691|      0|    case 3:  _hj_i = (int64_t)_hj_i + ( (uint32_t)_hj_key[2] << 16 );  /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (691:5): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  692|      0|    case 2:  _hj_i = (int64_t)_hj_i + ( (uint32_t)_hj_key[1] << 8 );   /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (692:5): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  693|      0|    case 1:  _hj_i = (int64_t)_hj_i + _hj_key[0];                      /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (693:5): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  694|      0|    default: ;                                                                   \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (694:5): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  695|      0|  }                                                                              \
  |  |  |  |  |  |  |  |  |  |  |  |  696|      0|  HASH_JEN_MIX(_hj_i, _hj_j, hashv);                                             \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  645|      0|#define HASH_JEN_MIX(a,b,c)                                                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  646|      0|do {                                                                             \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  647|      0|  a = (int64_t)a - b; a = (int64_t)a - c; a ^= ( c >> 13 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  648|      0|  b = (int64_t)b - c; b = (int64_t)b - a; b ^= ( a << 8 );                       \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  649|      0|  c = (int64_t)c - a; c = (int64_t)c - b; c ^= ( b >> 13 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  650|      0|  a = (int64_t)a - b; a = (int64_t)a - c; a ^= ( c >> 12 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  651|      0|  b = (int64_t)b - c; b = (int64_t)b - a; b ^= ( a << 16 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  652|      0|  c = (int64_t)c - a; c = (int64_t)c - b; c ^= ( b >> 5 );                       \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  653|      0|  a = (int64_t)a - b; a = (int64_t)a - c; a ^= ( c >> 3 );                       \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  654|      0|  b = (int64_t)b - c; b = (int64_t)b - a; b ^= ( a << 10 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  655|      0|  c = (int64_t)c - a; c = (int64_t)c - b; c ^= ( b >> 15 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  656|      0|} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (656:10): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  697|      0|} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (697:10): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  165|      0|} while (0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (165:10): [Folded, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  435|      0|  HASH_ADD_KEYPTR_BYHASHVALUE(hh, head, keyptr, keylen_in, _ha_hashv, add);      \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  410|      0|#define HASH_ADD_KEYPTR_BYHASHVALUE(hh,head,keyptr,keylen_in,hashval,add)        \
  |  |  |  |  |  |  |  |  411|      0|do {                                                                             \
  |  |  |  |  |  |  |  |  412|      0|  IF_HASH_NONFATAL_OOM( int _ha_oomed = 0; )                                     \
  |  |  |  |  |  |  |  |  413|      0|  (add)->hh.hashv = (hashval);                                                   \
  |  |  |  |  |  |  |  |  414|      0|  (add)->hh.key = (const void*) (keyptr);                                        \
  |  |  |  |  |  |  |  |  415|      0|  (add)->hh.keylen = (uint32_t) (keylen_in);                                     \
  |  |  |  |  |  |  |  |  416|      0|  if (!(head)) {                                                                 \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (416:7): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  417|      0|    (add)->hh.next = NULL;                                                       \
  |  |  |  |  |  |  |  |  418|      0|    (add)->hh.prev = NULL;                                                       \
  |  |  |  |  |  |  |  |  419|      0|    HASH_MAKE_TABLE(hh, add, _ha_oomed);                                         \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  226|      0|#define HASH_MAKE_TABLE(hh,head,oomed)                                           \
  |  |  |  |  |  |  |  |  |  |  227|      0|do {                                                                             \
  |  |  |  |  |  |  |  |  |  |  228|      0|  (head)->hh.tbl = (UT_hash_table*)uthash_malloc(sizeof(UT_hash_table));         \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   89|      0|#define uthash_malloc(sz) malloc(sz)      /* malloc fcn                      */
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  229|      0|  if (!(head)->hh.tbl) {                                                         \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (229:7): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  230|      0|    HASH_RECORD_OOM(oomed);                                                      \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  137|      0|#define HASH_RECORD_OOM(oomed) uthash_fatal("out of memory")
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  134|      0|#define uthash_fatal(msg) exit(-1)        /* fatal OOM error */
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  231|      0|  } else {                                                                       \
  |  |  |  |  |  |  |  |  |  |  232|      0|    uthash_bzero((head)->hh.tbl, sizeof(UT_hash_table));                         \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   95|      0|#define uthash_bzero(a,n) memset(a,'\0',n)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  233|      0|    (head)->hh.tbl->tail = &((head)->hh);                                        \
  |  |  |  |  |  |  |  |  |  |  234|      0|    (head)->hh.tbl->num_buckets = HASH_INITIAL_NUM_BUCKETS;                      \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  143|      0|#define HASH_INITIAL_NUM_BUCKETS 32U     /* initial number of buckets        */
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  235|      0|    (head)->hh.tbl->log2_num_buckets = HASH_INITIAL_NUM_BUCKETS_LOG2;            \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  144|      0|#define HASH_INITIAL_NUM_BUCKETS_LOG2 5U /* lg2 of initial number of buckets */
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  236|      0|    (head)->hh.tbl->hho = (char*)(&(head)->hh) - (char*)(head);                  \
  |  |  |  |  |  |  |  |  |  |  237|      0|    (head)->hh.tbl->buckets = (UT_hash_bucket*)uthash_malloc(                    \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   89|      0|#define uthash_malloc(sz) malloc(sz)      /* malloc fcn                      */
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  238|      0|        HASH_INITIAL_NUM_BUCKETS * sizeof(struct UT_hash_bucket));               \
  |  |  |  |  |  |  |  |  |  |  239|      0|    (head)->hh.tbl->signature = HASH_SIGNATURE;                                  \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  | 1101|      0|#define HASH_SIGNATURE 0xa0111fe1u
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  240|      0|    if (!(head)->hh.tbl->buckets) {                                              \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (240:9): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  241|      0|      HASH_RECORD_OOM(oomed);                                                    \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  137|      0|#define HASH_RECORD_OOM(oomed) uthash_fatal("out of memory")
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  134|      0|#define uthash_fatal(msg) exit(-1)        /* fatal OOM error */
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  242|      0|      uthash_free((head)->hh.tbl, sizeof(UT_hash_table));                        \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   92|      0|#define uthash_free(ptr,sz) free(ptr)     /* free fcn                        */
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  243|      0|    } else {                                                                     \
  |  |  |  |  |  |  |  |  |  |  244|      0|      uthash_bzero((head)->hh.tbl->buckets,                                      \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   95|      0|#define uthash_bzero(a,n) memset(a,'\0',n)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  245|      0|          HASH_INITIAL_NUM_BUCKETS * sizeof(struct UT_hash_bucket));             \
  |  |  |  |  |  |  |  |  |  |  246|      0|      HASH_BLOOM_MAKE((head)->hh.tbl, oomed);                                    \
  |  |  |  |  |  |  |  |  |  |  247|      0|      IF_HASH_NONFATAL_OOM(                                                      \
  |  |  |  |  |  |  |  |  |  |  248|      0|        if (oomed) {                                                             \
  |  |  |  |  |  |  |  |  |  |  249|      0|          uthash_free((head)->hh.tbl->buckets,                                   \
  |  |  |  |  |  |  |  |  |  |  250|      0|              HASH_INITIAL_NUM_BUCKETS*sizeof(struct UT_hash_bucket));           \
  |  |  |  |  |  |  |  |  |  |  251|      0|          uthash_free((head)->hh.tbl, sizeof(UT_hash_table));                    \
  |  |  |  |  |  |  |  |  |  |  252|      0|        }                                                                        \
  |  |  |  |  |  |  |  |  |  |  253|      0|      )                                                                          \
  |  |  |  |  |  |  |  |  |  |  254|      0|    }                                                                            \
  |  |  |  |  |  |  |  |  |  |  255|      0|  }                                                                              \
  |  |  |  |  |  |  |  |  |  |  256|      0|} while (0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (256:10): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  420|      0|    IF_HASH_NONFATAL_OOM( if (!_ha_oomed) { )                                    \
  |  |  |  |  |  |  |  |  421|      0|      (head) = (add);                                                            \
  |  |  |  |  |  |  |  |  422|      0|    IF_HASH_NONFATAL_OOM( } )                                                    \
  |  |  |  |  |  |  |  |  423|      0|  } else {                                                                       \
  |  |  |  |  |  |  |  |  424|      0|    (add)->hh.tbl = (head)->hh.tbl;                                              \
  |  |  |  |  |  |  |  |  425|      0|    HASH_APPEND_LIST(hh, head, add);                                             \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  292|      0|#define HASH_APPEND_LIST(hh, head, add)                                          \
  |  |  |  |  |  |  |  |  |  |  293|      0|do {                                                                             \
  |  |  |  |  |  |  |  |  |  |  294|      0|  (add)->hh.next = NULL;                                                         \
  |  |  |  |  |  |  |  |  |  |  295|      0|  (add)->hh.prev = ELMT_FROM_HH((head)->hh.tbl, (head)->hh.tbl->tail);           \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  148|      0|#define ELMT_FROM_HH(tbl,hhp) ((void*)(((char*)(hhp)) - ((tbl)->hho)))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  296|      0|  (head)->hh.tbl->tail->next = (add);                                            \
  |  |  |  |  |  |  |  |  |  |  297|      0|  (head)->hh.tbl->tail = &((add)->hh);                                           \
  |  |  |  |  |  |  |  |  |  |  298|      0|} while (0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (298:10): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  426|      0|  }                                                                              \
  |  |  |  |  |  |  |  |  427|      0|  HASH_ADD_TO_TABLE(hh, head, keyptr, keylen_in, hashval, add, _ha_oomed);       \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  351|      0|#define HASH_ADD_TO_TABLE(hh,head,keyptr,keylen_in,hashval,add,oomed)            \
  |  |  |  |  |  |  |  |  |  |  352|      0|do {                                                                             \
  |  |  |  |  |  |  |  |  |  |  353|      0|  uint32_t _ha_bkt;                                                              \
  |  |  |  |  |  |  |  |  |  |  354|      0|  (head)->hh.tbl->num_items++;                                                   \
  |  |  |  |  |  |  |  |  |  |  355|      0|  HASH_TO_BKT(hashval, (head)->hh.tbl->num_buckets, _ha_bkt);                    \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  444|      0|#define HASH_TO_BKT(hashv,num_bkts,bkt)                                          \
  |  |  |  |  |  |  |  |  |  |  |  |  445|      0|do {                                                                             \
  |  |  |  |  |  |  |  |  |  |  |  |  446|      0|  bkt = ((hashv) & ((num_bkts) - 1U));                                           \
  |  |  |  |  |  |  |  |  |  |  |  |  447|      0|} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (447:10): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  356|      0|  HASH_ADD_TO_BKT((head)->hh.tbl->buckets[_ha_bkt], hh, &(add)->hh, oomed);      \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  778|      0|#define HASH_ADD_TO_BKT(head,hh,addhh,oomed)                                     \
  |  |  |  |  |  |  |  |  |  |  |  |  779|      0|do {                                                                             \
  |  |  |  |  |  |  |  |  |  |  |  |  780|      0|  UT_hash_bucket *_ha_head = &(head);                                            \
  |  |  |  |  |  |  |  |  |  |  |  |  781|      0|  _ha_head->count++;                                                             \
  |  |  |  |  |  |  |  |  |  |  |  |  782|      0|  (addhh)->hh_next = _ha_head->hh_head;                                          \
  |  |  |  |  |  |  |  |  |  |  |  |  783|      0|  (addhh)->hh_prev = NULL;                                                       \
  |  |  |  |  |  |  |  |  |  |  |  |  784|      0|  if (_ha_head->hh_head != NULL) {                                               \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (784:7): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  785|      0|    _ha_head->hh_head->hh_prev = (addhh);                                        \
  |  |  |  |  |  |  |  |  |  |  |  |  786|      0|  }                                                                              \
  |  |  |  |  |  |  |  |  |  |  |  |  787|      0|  _ha_head->hh_head = (addhh);                                                   \
  |  |  |  |  |  |  |  |  |  |  |  |  788|      0|  if ((_ha_head->count >= ((_ha_head->expand_mult + 1U) * HASH_BKT_CAPACITY_THRESH)) \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  145|      0|#define HASH_BKT_CAPACITY_THRESH 10U     /* expand when bucket count reaches */
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (788:7): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  789|      0|      && !(addhh)->tbl->noexpand) {                                              \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (789:10): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  790|      0|    HASH_EXPAND_BUCKETS(addhh,(addhh)->tbl, oomed);                              \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  844|      0|#define HASH_EXPAND_BUCKETS(hh,tbl,oomed)                                        \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  845|      0|do {                                                                             \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  846|      0|  uint32_t _he_bkt;                                                              \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  847|      0|  uint32_t _he_bkt_i;                                                            \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  848|      0|  struct UT_hash_handle *_he_thh, *_he_hh_nxt;                                   \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  849|      0|  UT_hash_bucket *_he_new_buckets, *_he_newbkt;                                  \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  850|      0|  _he_new_buckets = (UT_hash_bucket*)uthash_malloc(                              \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   89|      0|#define uthash_malloc(sz) malloc(sz)      /* malloc fcn                      */
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  851|      0|           sizeof(struct UT_hash_bucket) * (tbl)->num_buckets * 2U);             \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  852|      0|  if (!_he_new_buckets) {                                                        \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (852:7): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  853|      0|    HASH_RECORD_OOM(oomed);                                                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  137|      0|#define HASH_RECORD_OOM(oomed) uthash_fatal("out of memory")
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  134|      0|#define uthash_fatal(msg) exit(-1)        /* fatal OOM error */
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  854|      0|  } else {                                                                       \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  855|      0|    uthash_bzero(_he_new_buckets,                                                \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   95|      0|#define uthash_bzero(a,n) memset(a,'\0',n)
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  856|      0|        sizeof(struct UT_hash_bucket) * (tbl)->num_buckets * 2U);                \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  857|      0|    (tbl)->ideal_chain_maxlen =                                                  \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  858|      0|       ((tbl)->num_items >> ((tbl)->log2_num_buckets+1U)) +                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  859|      0|       ((((tbl)->num_items & (((tbl)->num_buckets*2U)-1U)) != 0U) ? 1U : 0U);    \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (859:9): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  860|      0|    (tbl)->nonideal_items = 0;                                                   \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  861|      0|    for (_he_bkt_i = 0; _he_bkt_i < (tbl)->num_buckets; _he_bkt_i++) {           \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (861:25): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  862|      0|      _he_thh = (tbl)->buckets[ _he_bkt_i ].hh_head;                             \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  863|      0|      while (_he_thh != NULL) {                                                  \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (863:14): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  864|      0|        _he_hh_nxt = _he_thh->hh_next;                                           \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  865|      0|        HASH_TO_BKT(_he_thh->hashv, (tbl)->num_buckets * 2U, _he_bkt);           \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  444|      0|#define HASH_TO_BKT(hashv,num_bkts,bkt)                                          \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  445|      0|do {                                                                             \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  446|      0|  bkt = ((hashv) & ((num_bkts) - 1U));                                           \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  447|      0|} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (447:10): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  866|      0|        _he_newbkt = &(_he_new_buckets[_he_bkt]);                                \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  867|      0|        if (++(_he_newbkt->count) > (tbl)->ideal_chain_maxlen) {                 \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (867:13): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  868|      0|          (tbl)->nonideal_items++;                                               \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  869|      0|          if (_he_newbkt->count > _he_newbkt->expand_mult * (tbl)->ideal_chain_maxlen) { \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (869:15): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  870|      0|            _he_newbkt->expand_mult++;                                           \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  871|      0|          }                                                                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  872|      0|        }                                                                        \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  873|      0|        _he_thh->hh_prev = NULL;                                                 \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  874|      0|        _he_thh->hh_next = _he_newbkt->hh_head;                                  \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  875|      0|        if (_he_newbkt->hh_head != NULL) {                                       \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (875:13): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  876|      0|          _he_newbkt->hh_head->hh_prev = _he_thh;                                \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  877|      0|        }                                                                        \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  878|      0|        _he_newbkt->hh_head = _he_thh;                                           \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  879|      0|        _he_thh = _he_hh_nxt;                                                    \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  880|      0|      }                                                                          \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  881|      0|    }                                                                            \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  882|      0|    uthash_free((tbl)->buckets, (tbl)->num_buckets * sizeof(struct UT_hash_bucket)); \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   92|      0|#define uthash_free(ptr,sz) free(ptr)     /* free fcn                        */
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  883|      0|    (tbl)->num_buckets *= 2U;                                                    \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  884|      0|    (tbl)->log2_num_buckets++;                                                   \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  885|      0|    (tbl)->buckets = _he_new_buckets;                                            \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  886|      0|    (tbl)->ineff_expands = ((tbl)->nonideal_items > ((tbl)->num_items >> 1)) ?   \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (886:28): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  887|      0|        ((tbl)->ineff_expands+1U) : 0U;                                          \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  888|      0|    if ((tbl)->ineff_expands > 1U) {                                             \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (888:9): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  889|      0|      (tbl)->noexpand = 1;                                                       \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  890|      0|      uthash_noexpand_fyi(tbl);                                                  \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  891|      0|    }                                                                            \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  892|      0|    uthash_expand_fyi(tbl);                                                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  893|      0|  }                                                                              \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  894|      0|} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (894:10): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  791|      0|    IF_HASH_NONFATAL_OOM(                                                        \
  |  |  |  |  |  |  |  |  |  |  |  |  792|      0|      if (oomed) {                                                               \
  |  |  |  |  |  |  |  |  |  |  |  |  793|      0|        HASH_DEL_IN_BKT(head,addhh);                                             \
  |  |  |  |  |  |  |  |  |  |  |  |  794|      0|      }                                                                          \
  |  |  |  |  |  |  |  |  |  |  |  |  795|      0|    )                                                                            \
  |  |  |  |  |  |  |  |  |  |  |  |  796|      0|  }                                                                              \
  |  |  |  |  |  |  |  |  |  |  |  |  797|      0|} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (797:10): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  357|      0|  HASH_BLOOM_ADD((head)->hh.tbl, hashval);                                       \
  |  |  |  |  |  |  |  |  |  |  358|      0|  HASH_EMIT_KEY(hh, head, keyptr, keylen_in);                                    \
  |  |  |  |  |  |  |  |  |  |  359|      0|} while (0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (359:10): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  428|      0|  HASH_FSCK(hh, head, "HASH_ADD_KEYPTR_BYHASHVALUE");                            \
  |  |  |  |  |  |  |  |  429|      0|} while (0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (429:10): [Folded, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  436|      0|} while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (436:10): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1684|      0|  coap_session_release_lkd(session);
 1685|       |  return NULL;
 1686|      0|}

coap_new_string:
   21|    352|coap_new_string(size_t size) {
   22|    352|  coap_string_t *s;
   23|       |#if defined(WITH_LWIP) && MEMP_USE_CUSTOM_POOLS && ! MEM_USE_POOLS
   24|       |  if (size >= MEMP_LEN_COAPSTRING) {
   25|       |    coap_log_crit("coap_new_string: size too large (%" PRIuS " +1 > MEMP_LEN_COAPSTRING)\n",
   26|       |                  size);
   27|       |    return NULL;
   28|       |  }
   29|       |#endif /* WITH_LWIP && MEMP_USE_CUSTOM_POOLS */
   30|       |  /* Check no overflow (including a 8 byte small headroom) */
   31|    352|  if (size > SIZE_MAX - sizeof(coap_str_bin_union_t) - 1 - 8) {
  ------------------
  |  Branch (31:7): [True: 0, False: 352]
  ------------------
   32|      0|    return NULL;
   33|      0|  }
   34|       |
   35|    352|  s = (coap_string_t *)coap_malloc_type(COAP_STRING,
   36|    352|                                        sizeof(coap_str_bin_union_t) + size + 1);
   37|    352|  if (!s) {
  ------------------
  |  Branch (37:7): [True: 0, False: 352]
  ------------------
   38|      0|    coap_log_crit("coap_new_string: malloc: failed\n");
  ------------------
  |  |   96|      0|#define coap_log_crit(...) coap_log(COAP_LOG_CRIT, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   39|      0|    return NULL;
   40|      0|  }
   41|       |
   42|    352|  memset(s, 0, sizeof(coap_str_bin_union_t));
   43|    352|  s->s = ((unsigned char *)s) + sizeof(coap_str_bin_union_t);
   44|    352|  s->s[size] = '\000';
   45|    352|  s->length = size;
   46|    352|  return s;
   47|    352|}
coap_delete_string:
   50|    209|coap_delete_string(coap_string_t *s) {
   51|    209|  coap_free_type(COAP_STRING, s);
   52|    209|}
coap_new_str_const:
   55|    251|coap_new_str_const(const uint8_t *data, size_t size) {
   56|    251|  coap_string_t *s = coap_new_string(size);
   57|    251|  if (!s)
  ------------------
  |  Branch (57:7): [True: 0, False: 251]
  ------------------
   58|      0|    return NULL;
   59|    251|  memcpy(s->s, data, size);
   60|    251|  s->length = size;
   61|    251|  return (coap_str_const_t *)s;
   62|    251|}
coap_delete_str_const:
   65|    356|coap_delete_str_const(coap_str_const_t *s) {
   66|    356|  coap_free_type(COAP_STRING, s);
   67|    356|}
coap_make_str_const:
   70|     35|coap_make_str_const(const char *string) {
   71|     35|  static int ofs = 0;
   72|     35|  static coap_str_const_t var[COAP_MAX_STR_CONST_FUNC];
   73|     35|  if (++ofs == COAP_MAX_STR_CONST_FUNC)
  ------------------
  |  |  181|     35|#define COAP_MAX_STR_CONST_FUNC 2
  ------------------
  |  Branch (73:7): [True: 17, False: 18]
  ------------------
   74|     17|    ofs = 0;
   75|     35|  var[ofs].length = strlen(string);
   76|     35|  var[ofs].s = (const uint8_t *)string;
   77|     35|  return &var[ofs];
   78|     35|}
coap_delete_binary:
  114|    582|coap_delete_binary(coap_binary_t *s) {
  115|    582|  coap_free_type(COAP_STRING, s);
  116|    582|}
coap_delete_bin_const:
  130|    245|coap_delete_bin_const(coap_bin_const_t *s) {
  131|    245|  coap_free_type(COAP_STRING, s);
  132|    245|}

coap_subscription_init:
   34|    142|coap_subscription_init(coap_subscription_t *s) {
   35|    142|  assert(s);
  ------------------
  |  Branch (35:3): [True: 142, False: 0]
  ------------------
   36|    142|  memset(s, 0, sizeof(coap_subscription_t));
   37|    142|}
coap_persist_track_funcs:
   47|     35|                         void *user_data) {
   48|     35|  context->observe_added_cb = observe_added;
   49|     35|  context->observe_deleted_cb = observe_deleted;
   50|     35|  context->observe_user_data = user_data;
   51|     35|  context->observe_save_freq = save_freq ? save_freq : 1;
  ------------------
  |  Branch (51:32): [True: 0, False: 35]
  ------------------
   52|     35|  context->track_observe_value_cb = track_observe_value;
   53|     35|  context->dyn_resource_added_cb = dyn_resource_added;
   54|     35|  context->resource_deleted_cb = resource_deleted;
   55|     35|}
coap_persist_cleanup:
 1220|     35|coap_persist_cleanup(coap_context_t *context) {
 1221|     35|  coap_delete_bin_const(context->dyn_resource_save_file);
 1222|     35|  coap_delete_bin_const(context->obs_cnt_save_file);
 1223|     35|  coap_delete_bin_const(context->observe_save_file);
 1224|     35|  context->dyn_resource_save_file = NULL;
 1225|     35|  context->obs_cnt_save_file = NULL;
 1226|     35|  context->observe_save_file = NULL;
 1227|       |
 1228|       |  /* Close down any tracking */
 1229|     35|  coap_persist_track_funcs(context, NULL, NULL, NULL, NULL,
 1230|     35|                           NULL, 0, NULL);
 1231|     35|}

coap_clock_init:
   68|     35|coap_clock_init(void) {
   69|     35|#ifdef COAP_CLOCK
   70|     35|  struct timespec tv;
   71|     35|  clock_gettime(COAP_CLOCK, &tv);
  ------------------
  |  |   43|     35|#define COAP_CLOCK CLOCK_REALTIME
  ------------------
   72|       |#else /* _POSIX_TIMERS */
   73|       |  struct timeval tv;
   74|       |  gettimeofday(&tv, NULL);
   75|       |#endif /* not _POSIX_TIMERS */
   76|       |
   77|     35|  coap_clock_offset = tv.tv_sec;
   78|     35|}
coap_ticks:
   90|    622|coap_ticks(coap_tick_t *t) {
   91|    622|  coap_tick_t tmp;
   92|       |
   93|    622|#ifdef COAP_CLOCK
   94|    622|  struct timespec tv;
   95|    622|  clock_gettime(COAP_CLOCK, &tv);
  ------------------
  |  |   43|    622|#define COAP_CLOCK CLOCK_REALTIME
  ------------------
   96|       |  /* Possible errors are (see clock_gettime(2)):
   97|       |   *  EFAULT tp points outside the accessible address space.
   98|       |   *  EINVAL The clk_id specified is not supported on this system.
   99|       |   * Both cases should not be possible here.
  100|       |   */
  101|       |
  102|    622|  tmp = SHR_FP(tv.tv_nsec * Q(FRAC, (COAP_TICKS_PER_SECOND/1000000000.0)), FRAC);
  ------------------
  |  |   87|    622|#define SHR_FP(val,frac) (((coap_tick_t)((val) + (1 << ((frac) - 1)))) >> (frac))
  ------------------
  103|       |#else /* _POSIX_TIMERS */
  104|       |  /* Fall back to gettimeofday() */
  105|       |
  106|       |  struct timeval tv;
  107|       |  gettimeofday(&tv, NULL);
  108|       |  /* Possible errors are (see gettimeofday(2)):
  109|       |   *  EFAULT One of tv or tz pointed outside the accessible address space.
  110|       |   *  EINVAL Timezone (or something else) is invalid.
  111|       |   * Both cases should not be possible here.
  112|       |   */
  113|       |
  114|       |  tmp = SHR_FP(tv.tv_usec * Q(FRAC, (COAP_TICKS_PER_SECOND/1000000.0)), FRAC);
  115|       |#endif /* not _POSIX_TIMERS */
  116|       |
  117|       |  /* Finally, convert temporary FP representation to multiple of
  118|       |   * COAP_TICKS_PER_SECOND */
  119|    622|  *t = tmp + (tv.tv_sec - coap_clock_offset) * COAP_TICKS_PER_SECOND;
  ------------------
  |  |  164|    622|#define COAP_TICKS_PER_SECOND ((coap_tick_t)(1000U))
  ------------------
  120|    622|}
coap_ticks_to_rt_us:
  128|     35|coap_ticks_to_rt_us(coap_tick_t t) {
  129|     35|  return (uint64_t)coap_clock_offset * 1000000 + (uint64_t)t * 1000000 / COAP_TICKS_PER_SECOND;
  ------------------
  |  |  164|     35|#define COAP_TICKS_PER_SECOND ((coap_tick_t)(1000U))
  ------------------
  130|     35|}

coap_check_dots:
  675|    263|coap_check_dots(const uint8_t *s, size_t len) {
  676|    263|  uint8_t p;
  677|       |
  678|    263|  if (!len)
  ------------------
  |  Branch (678:7): [True: 36, False: 227]
  ------------------
  679|     36|    return 0;
  680|       |
  681|    227|  p = *s;
  682|       |
  683|       |  /* Check 'first' char */
  684|    227|  if (p == '%' && len >=3) {
  ------------------
  |  Branch (684:7): [True: 6, False: 221]
  |  Branch (684:19): [True: 6, False: 0]
  ------------------
  685|      6|    if (s[1] == '2' && (s[2] == 'E' || s[2] == 'e')) {
  ------------------
  |  Branch (685:9): [True: 0, False: 6]
  |  Branch (685:25): [True: 0, False: 0]
  |  Branch (685:40): [True: 0, False: 0]
  ------------------
  686|      0|      s += 2;
  687|      0|      len -= 2;
  688|      0|    }
  689|      6|    p = '.';
  690|      6|  }
  691|    227|  if (p != '.')
  ------------------
  |  Branch (691:7): [True: 221, False: 6]
  ------------------
  692|    221|    return 0;
  693|      6|  if (len == 1)
  ------------------
  |  Branch (693:7): [True: 0, False: 6]
  ------------------
  694|      0|    return 1;
  695|       |
  696|       |  /* Check 'second' char, first is '.' */
  697|      6|  s++;
  698|      6|  len--;
  699|      6|  assert(len);
  ------------------
  |  Branch (699:3): [True: 6, False: 0]
  ------------------
  700|      6|  p = *s;
  701|      6|  if (p == '%' && len >=3) {
  ------------------
  |  Branch (701:7): [True: 3, False: 3]
  |  Branch (701:19): [True: 3, False: 0]
  ------------------
  702|      3|    if (s[1] == '2' && (s[2] == 'E' || s[2] == 'e')) {
  ------------------
  |  Branch (702:9): [True: 0, False: 3]
  |  Branch (702:25): [True: 0, False: 0]
  |  Branch (702:40): [True: 0, False: 0]
  ------------------
  703|      0|      len -= 2;
  704|      0|    }
  705|      3|    p = '.';
  706|      3|  }
  707|      6|  if (p != '.')
  ------------------
  |  Branch (707:7): [True: 3, False: 3]
  ------------------
  708|      3|    return 0;
  709|      3|  if (len == 1)
  ------------------
  |  Branch (709:7): [True: 0, False: 3]
  ------------------
  710|      0|    return 2;
  711|       |
  712|      3|  return 0;
  713|      3|}
coap_get_query:
 1108|    186|coap_get_query(const coap_pdu_t *request) {
 1109|    186|  coap_opt_iterator_t opt_iter;
 1110|    186|  coap_opt_filter_t f;
 1111|    186|  coap_opt_t *q;
 1112|    186|  coap_string_t *query = NULL;
 1113|    186|  size_t length = 0;
 1114|    186|  int have_query = 0;
 1115|    186|  static const uint8_t hex[] = "0123456789ABCDEF";
 1116|       |
 1117|    186|  coap_option_filter_clear(&f);
 1118|    186|  coap_option_filter_set(&f, COAP_OPTION_URI_QUERY);
 1119|    186|  coap_option_iterator_init(request, &opt_iter, &f);
 1120|    188|  while ((q = coap_option_next(&opt_iter))) {
  ------------------
  |  Branch (1120:10): [True: 2, False: 186]
  ------------------
 1121|      2|    uint16_t seg_len = coap_opt_length(q), i;
 1122|      2|    const uint8_t *seg= coap_opt_value(q);
 1123|      2|    have_query = 1;
 1124|      8|    for (i = 0; i < seg_len; i++) {
  ------------------
  |  Branch (1124:17): [True: 6, False: 2]
  ------------------
 1125|      6|      if (is_unescaped_in_query(seg[i]))
  ------------------
  |  Branch (1125:11): [True: 6, False: 0]
  ------------------
 1126|      6|        length += 1;
 1127|      0|      else
 1128|      0|        length += 3;
 1129|      6|    }
 1130|      2|    length += 1;
 1131|      2|  }
 1132|    186|  if (length > 0)
  ------------------
  |  Branch (1132:7): [True: 2, False: 184]
  ------------------
 1133|      2|    length -= 1;
 1134|       |  /* Allocate and return a string whenever at least one Uri-Query option is
 1135|       |     present, even when every option is empty and the encoded length is zero.
 1136|       |     A single empty Uri-Query then yields an empty string rather than NULL,
 1137|       |     which is reserved for "no Uri-Query option at all". */
 1138|    186|  if (have_query) {
  ------------------
  |  Branch (1138:7): [True: 2, False: 184]
  ------------------
 1139|      2|    query = coap_new_string(length);
 1140|      2|    if (query) {
  ------------------
  |  Branch (1140:9): [True: 2, False: 0]
  ------------------
 1141|      2|      unsigned char *s = query->s;
 1142|      2|      int first = 1;
 1143|      2|      query->length = length;
 1144|      2|      coap_option_iterator_init(request, &opt_iter, &f);
 1145|      4|      while ((q = coap_option_next(&opt_iter))) {
  ------------------
  |  Branch (1145:14): [True: 2, False: 2]
  ------------------
 1146|       |        /* Write the '&' separator before every Uri-Query option except the
 1147|       |           first. An empty Uri-Query option is a distinct zero-length segment
 1148|       |           (just as "&&" is not "&"), so the separators around it must still
 1149|       |           be emitted. Keying this off the option index rather than off
 1150|       |           whether any byte has been written yet is what keeps leading empty
 1151|       |           options from being dropped, and keeps the buffer fully written so
 1152|       |           no uninitialised tail is exposed to callers. */
 1153|      2|        if (!first)
  ------------------
  |  Branch (1153:13): [True: 0, False: 2]
  ------------------
 1154|      0|          *s++ = '&';
 1155|      2|        first = 0;
 1156|      2|        uint16_t seg_len = coap_opt_length(q), i;
 1157|      2|        const uint8_t *seg= coap_opt_value(q);
 1158|      8|        for (i = 0; i < seg_len; i++) {
  ------------------
  |  Branch (1158:21): [True: 6, False: 2]
  ------------------
 1159|      6|          if (is_unescaped_in_query(seg[i])) {
  ------------------
  |  Branch (1159:15): [True: 6, False: 0]
  ------------------
 1160|      6|            *s++ = seg[i];
 1161|      6|          } else {
 1162|      0|            *s++ = '%';
 1163|      0|            *s++ = hex[seg[i]>>4];
 1164|      0|            *s++ = hex[seg[i]&0x0F];
 1165|      0|          }
 1166|      6|        }
 1167|      2|      }
 1168|      2|    }
 1169|      2|  }
 1170|    186|  return query;
 1171|    186|}
coap_map_abbrev_uri_path:
 1174|      1|coap_map_abbrev_uri_path(coap_upa_chain_t *chain, uint32_t value) {
 1175|      1|  while (chain) {
  ------------------
  |  Branch (1175:10): [True: 0, False: 1]
  ------------------
 1176|      0|    coap_upa_chain_t *next = chain->next;
 1177|       |
 1178|      0|    if (chain->upa_value == value) {
  ------------------
  |  Branch (1178:9): [True: 0, False: 0]
  ------------------
 1179|      0|      return chain->upa_path;
 1180|      0|    }
 1181|      0|    chain = next;
 1182|      0|  }
 1183|      1|  return NULL;
 1184|      1|}
coap_get_uri_path:
 1202|    100|coap_get_uri_path(const coap_pdu_t *request) {
 1203|    100|  coap_opt_iterator_t opt_iter;
 1204|    100|  coap_opt_filter_t f;
 1205|    100|  coap_opt_t *q;
 1206|    100|  coap_string_t *uri_path = NULL;
 1207|    100|  size_t length = 0;
 1208|    100|  static const uint8_t hex[] = "0123456789ABCDEF";
 1209|       |
 1210|    100|  q = coap_check_option(request, COAP_OPTION_URI_PATH_ABB, &opt_iter);
 1211|    100|  if (q) {
  ------------------
  |  Branch (1211:7): [True: 1, False: 99]
  ------------------
 1212|      1|    uint32_t value;
 1213|      1|    const char *exp;
 1214|      1|    if (coap_check_option(request, COAP_OPTION_PROXY_URI, &opt_iter) ||
  ------------------
  |  Branch (1214:9): [True: 0, False: 1]
  ------------------
 1215|      1|        coap_check_option(request, COAP_OPTION_URI_PATH, &opt_iter)) {
  ------------------
  |  Branch (1215:9): [True: 0, False: 1]
  ------------------
 1216|      0|      return NULL;
 1217|      0|    }
 1218|      1|    value = coap_decode_var_bytes(coap_opt_value(q), coap_opt_length(q));
 1219|      1|    exp = coap_map_abbrev_uri_path(coap_upa_server_mapping_chain, value);
 1220|      1|    if (exp) {
  ------------------
  |  Branch (1220:9): [True: 0, False: 1]
  ------------------
 1221|      0|      uri_path = coap_new_string(strlen(exp));
 1222|      0|      if (uri_path) {
  ------------------
  |  Branch (1222:11): [True: 0, False: 0]
  ------------------
 1223|      0|        memcpy(uri_path->s, exp, strlen(exp));
 1224|      0|      }
 1225|      0|      return uri_path;
 1226|      0|    }
 1227|      1|    return NULL;
 1228|      1|  }
 1229|     99|  q = coap_check_option(request, COAP_OPTION_PROXY_URI, &opt_iter);
 1230|     99|  if (q) {
  ------------------
  |  Branch (1230:7): [True: 0, False: 99]
  ------------------
 1231|      0|    coap_uri_t uri;
 1232|       |
 1233|      0|    if (coap_split_proxy_uri(coap_opt_value(q),
  ------------------
  |  Branch (1233:9): [True: 0, False: 0]
  ------------------
 1234|      0|                             coap_opt_length(q), &uri) < 0) {
 1235|      0|      return NULL;
 1236|      0|    }
 1237|      0|    uri_path = coap_new_string(uri.path.length);
 1238|      0|    if (uri_path && uri.path.length) {
  ------------------
  |  Branch (1238:9): [True: 0, False: 0]
  |  Branch (1238:21): [True: 0, False: 0]
  ------------------
 1239|      0|      memcpy(uri_path->s, uri.path.s, uri.path.length);
 1240|      0|    }
 1241|      0|    return uri_path;
 1242|      0|  }
 1243|       |
 1244|     99|  coap_option_filter_clear(&f);
 1245|     99|  coap_option_filter_set(&f, COAP_OPTION_URI_PATH);
 1246|     99|  coap_option_iterator_init(request, &opt_iter, &f);
 1247|    197|  while ((q = coap_option_next(&opt_iter))) {
  ------------------
  |  Branch (1247:10): [True: 98, False: 99]
  ------------------
 1248|     98|    uint16_t seg_len = coap_opt_length(q), i;
 1249|     98|    const uint8_t *seg = coap_opt_value(q);
 1250|    392|    for (i = 0; i < seg_len; i++) {
  ------------------
  |  Branch (1250:17): [True: 294, False: 98]
  ------------------
 1251|    294|      if (is_unescaped_in_path(seg[i]))
  ------------------
  |  Branch (1251:11): [True: 294, False: 0]
  ------------------
 1252|    294|        length += 1;
 1253|      0|      else
 1254|      0|        length += 3;
 1255|    294|    }
 1256|       |    /* bump for the leading "/" */
 1257|     98|    length += 1;
 1258|     98|  }
 1259|       |  /* The first entry does not have a leading "/" */
 1260|     99|  if (length > 0)
  ------------------
  |  Branch (1260:7): [True: 98, False: 1]
  ------------------
 1261|     98|    length -= 1;
 1262|       |
 1263|       |  /* if 0, either no URI_PATH Option, or the first one was empty */
 1264|     99|  uri_path = coap_new_string(length);
 1265|     99|  if (uri_path) {
  ------------------
  |  Branch (1265:7): [True: 99, False: 0]
  ------------------
 1266|     99|    uri_path->length = length;
 1267|     99|    unsigned char *s = uri_path->s;
 1268|     99|    int n = 0;
 1269|     99|    coap_option_iterator_init(request, &opt_iter, &f);
 1270|    197|    while ((q = coap_option_next(&opt_iter))) {
  ------------------
  |  Branch (1270:12): [True: 98, False: 99]
  ------------------
 1271|     98|      if (n++) {
  ------------------
  |  Branch (1271:11): [True: 0, False: 98]
  ------------------
 1272|      0|        *s++ = '/';
 1273|      0|      }
 1274|     98|      uint16_t seg_len = coap_opt_length(q), i;
 1275|     98|      const uint8_t *seg= coap_opt_value(q);
 1276|    392|      for (i = 0; i < seg_len; i++) {
  ------------------
  |  Branch (1276:19): [True: 294, False: 98]
  ------------------
 1277|    294|        if (is_unescaped_in_path(seg[i])) {
  ------------------
  |  Branch (1277:13): [True: 294, False: 0]
  ------------------
 1278|    294|          *s++ = seg[i];
 1279|    294|        } else {
 1280|      0|          *s++ = '%';
 1281|      0|          *s++ = hex[seg[i]>>4];
 1282|      0|          *s++ = hex[seg[i]&0x0F];
 1283|      0|        }
 1284|    294|      }
 1285|     98|    }
 1286|     99|  }
 1287|     99|  return uri_path;
 1288|     99|}
coap_delete_upa_chain:
 1291|     70|coap_delete_upa_chain(coap_upa_chain_t *chain) {
 1292|     70|  while (chain) {
  ------------------
  |  Branch (1292:10): [True: 0, False: 70]
  ------------------
 1293|      0|    coap_upa_chain_t *next = chain->next;
 1294|       |
 1295|      0|    coap_free_type(COAP_STRING, chain);
 1296|      0|    chain = next;
 1297|      0|  }
 1298|     70|}
coap_uri.c:is_unescaped_in_query:
 1103|     12|is_unescaped_in_query(const uint8_t c) {
 1104|     12|  return c != '&' && (is_unescaped_in_path(c) || c == '/' || c == '?');
  ------------------
  |  Branch (1104:10): [True: 12, False: 0]
  |  Branch (1104:23): [True: 12, False: 0]
  |  Branch (1104:50): [True: 0, False: 0]
  |  Branch (1104:62): [True: 0, False: 0]
  ------------------
 1105|     12|}
coap_uri.c:is_unescaped_in_path:
 1094|    600|is_unescaped_in_path(const uint8_t c) {
 1095|    600|  return (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') ||
  ------------------
  |  Branch (1095:11): [True: 590, False: 10]
  |  Branch (1095:23): [True: 0, False: 590]
  |  Branch (1095:37): [True: 590, False: 10]
  |  Branch (1095:49): [True: 590, False: 0]
  ------------------
 1096|     10|         (c >= '0' && c <= '9') || c == '-' || c == '.' || c == '_' ||
  ------------------
  |  Branch (1096:11): [True: 4, False: 6]
  |  Branch (1096:23): [True: 0, False: 4]
  |  Branch (1096:36): [True: 0, False: 10]
  |  Branch (1096:48): [True: 0, False: 10]
  |  Branch (1096:60): [True: 0, False: 10]
  ------------------
 1097|     10|         c == '~' || c == '!' || c == '$' || c == '\'' || c == '(' ||
  ------------------
  |  Branch (1097:10): [True: 0, False: 10]
  |  Branch (1097:22): [True: 6, False: 4]
  |  Branch (1097:34): [True: 0, False: 4]
  |  Branch (1097:46): [True: 0, False: 4]
  |  Branch (1097:59): [True: 0, False: 4]
  ------------------
 1098|      4|         c == ')' || c == '*' || c == '+' || c == ',' || c == ';' ||
  ------------------
  |  Branch (1098:10): [True: 0, False: 4]
  |  Branch (1098:22): [True: 0, False: 4]
  |  Branch (1098:34): [True: 0, False: 4]
  |  Branch (1098:46): [True: 0, False: 4]
  |  Branch (1098:58): [True: 0, False: 4]
  ------------------
 1099|      4|         c=='=' || c==':' || c=='@' || c == '&';
  ------------------
  |  Branch (1099:10): [True: 4, False: 0]
  |  Branch (1099:20): [True: 0, False: 0]
  |  Branch (1099:30): [True: 0, False: 0]
  |  Branch (1099:40): [True: 0, False: 0]
  ------------------
 1100|    600|}

oscore_free_contexts:
  267|     35|oscore_free_contexts(coap_context_t *c_context) {
  268|     35|  while (c_context->p_osc_ctx) {
  ------------------
  |  Branch (268:10): [True: 0, False: 35]
  ------------------
  269|      0|    oscore_ctx_t *osc_ctx = c_context->p_osc_ctx;
  270|       |
  271|      0|    if (osc_ctx->next == osc_ctx) {
  ------------------
  |  Branch (271:9): [True: 0, False: 0]
  ------------------
  272|      0|      c_context->p_osc_ctx = NULL;
  273|      0|    } else {
  274|      0|      oscore_ctx_t *tail = osc_ctx;
  275|      0|      c_context->p_osc_ctx = osc_ctx->next;
  276|      0|      while (tail->next != osc_ctx) {
  ------------------
  |  Branch (276:14): [True: 0, False: 0]
  ------------------
  277|      0|        tail = tail->next;
  278|      0|      }
  279|      0|      tail->next = c_context->p_osc_ctx;
  280|      0|    }
  281|      0|    osc_ctx->next = NULL;
  282|       |
  283|       |    /*
  284|       |     * Verify if all recipients can be released, if not
  285|       |     * defer freeing of context until later when all recipients are released.
  286|       |     * The oscore context is flagged as ready to be freed by removing
  287|       |     * the oscore context from the coap context.
  288|       |     */
  289|      0|    if (oscore_context_release_recipients(osc_ctx) > 0) {
  ------------------
  |  Branch (289:9): [True: 0, False: 0]
  ------------------
  290|      0|      oscore_free_context(osc_ctx);
  291|      0|    }
  292|      0|  }
  293|     35|}
oscore_release_recipient_ctx:
 1314|     35|oscore_release_recipient_ctx(oscore_recipient_ctx_t **recipient_ctx) {
 1315|     35|  oscore_ctx_t *osc_ctx;
 1316|       |
 1317|     35|  if (recipient_ctx == NULL || *recipient_ctx == NULL)
  ------------------
  |  Branch (1317:7): [True: 0, False: 35]
  |  Branch (1317:32): [True: 35, False: 0]
  ------------------
 1318|     35|    return;
 1319|       |
 1320|       |  /* ensure oscore context is freed if not attached to coap context */
 1321|      0|  osc_ctx = (*recipient_ctx)->osc_ctx;
 1322|      0|  oscore_free_recipient_ctx(*recipient_ctx);
 1323|       |  /*
 1324|       |   * Free temporary oscore context if not attached to a coap context
 1325|       |   * and no recipients attached anymore.
 1326|       |   */
 1327|      0|  if (!oscore_is_context_attached(osc_ctx) && osc_ctx->recipient_chain == NULL) {
  ------------------
  |  Branch (1327:7): [True: 0, False: 0]
  |  Branch (1327:47): [True: 0, False: 0]
  ------------------
 1328|      0|    oscore_free_context(osc_ctx);
 1329|      0|  }
 1330|       |  *recipient_ctx = NULL;
 1331|      0|}
oscore_delete_server_associations:
 1434|     35|oscore_delete_server_associations(coap_session_t *session) {
 1435|     35|  if (session) {
  ------------------
  |  Branch (1435:7): [True: 35, False: 0]
  ------------------
 1436|     35|    oscore_association_t *association;
 1437|     35|    oscore_association_t *tmp;
 1438|       |
 1439|     35|    OSCORE_ASSOCIATIONS_ITER_SAFE(session->associations, association, tmp) {
  ------------------
  |  |  187|     35|  for ((el) = (e); (el) && ((rtmp) = (el)->hh.next, 1); (el) = (rtmp))
  |  |  ------------------
  |  |  |  Branch (187:20): [True: 0, False: 35]
  |  |  |  Branch (187:28): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1440|      0|      OSCORE_ASSOCIATIONS_DELETE(session->associations, association);
  ------------------
  |  |  180|      0|#define OSCORE_ASSOCIATIONS_DELETE(r, obj) HASH_DELETE(hh, (r), (obj))
  |  |  ------------------
  |  |  |  |  462|      0|    HASH_DELETE_HH(hh, head, &(delptr)->hh)
  |  |  |  |  ------------------
  |  |  |  |  |  |  464|      0|#define HASH_DELETE_HH(hh,head,delptrhh)                                         \
  |  |  |  |  |  |  465|      0|do {                                                                             \
  |  |  |  |  |  |  466|      0|  struct UT_hash_handle *_hd_hh_del = (delptrhh);                                \
  |  |  |  |  |  |  467|      0|  if ((_hd_hh_del->prev == NULL) && (_hd_hh_del->next == NULL)) {                \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (467:7): [True: 0, False: 0]
  |  |  |  |  |  |  |  Branch (467:37): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  468|      0|    HASH_BLOOM_FREE((head)->hh.tbl);                                             \
  |  |  |  |  |  |  469|      0|    uthash_free((head)->hh.tbl->buckets,                                         \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   92|      0|#define uthash_free(ptr,sz) free(ptr)     /* free fcn                        */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  470|      0|                (head)->hh.tbl->num_buckets * sizeof(struct UT_hash_bucket));    \
  |  |  |  |  |  |  471|      0|    uthash_free((head)->hh.tbl, sizeof(UT_hash_table));                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   92|      0|#define uthash_free(ptr,sz) free(ptr)     /* free fcn                        */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  472|      0|    (head) = NULL;                                                               \
  |  |  |  |  |  |  473|      0|  } else {                                                                       \
  |  |  |  |  |  |  474|      0|    uint32_t _hd_bkt;                                                            \
  |  |  |  |  |  |  475|      0|    if (_hd_hh_del == (head)->hh.tbl->tail) {                                    \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (475:9): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  476|      0|      (head)->hh.tbl->tail = HH_FROM_ELMT((head)->hh.tbl, _hd_hh_del->prev);     \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  150|      0|#define HH_FROM_ELMT(tbl,elp) ((UT_hash_handle*)(void*)(((char*)(elp)) + ((tbl)->hho)))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  477|      0|    }                                                                            \
  |  |  |  |  |  |  478|      0|    if (_hd_hh_del->prev != NULL) {                                              \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (478:9): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  479|      0|      HH_FROM_ELMT((head)->hh.tbl, _hd_hh_del->prev)->next = _hd_hh_del->next;   \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  150|      0|#define HH_FROM_ELMT(tbl,elp) ((UT_hash_handle*)(void*)(((char*)(elp)) + ((tbl)->hho)))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  480|      0|    } else {                                                                     \
  |  |  |  |  |  |  481|      0|      DECLTYPE_ASSIGN(head, _hd_hh_del->next);                                   \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   78|      0|#define DECLTYPE_ASSIGN(dst,src)                                                 \
  |  |  |  |  |  |  |  |   79|      0|do {                                                                             \
  |  |  |  |  |  |  |  |   80|      0|  (dst) = DECLTYPE(dst)(src);                                                    \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   66|      0|#define DECLTYPE(x) (__typeof(x))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   81|      0|} while (0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (81:10): [Folded, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  482|      0|    }                                                                            \
  |  |  |  |  |  |  483|      0|    if (_hd_hh_del->next != NULL) {                                              \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (483:9): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  484|      0|      HH_FROM_ELMT((head)->hh.tbl, _hd_hh_del->next)->prev = _hd_hh_del->prev;   \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  150|      0|#define HH_FROM_ELMT(tbl,elp) ((UT_hash_handle*)(void*)(((char*)(elp)) + ((tbl)->hho)))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  485|      0|    }                                                                            \
  |  |  |  |  |  |  486|      0|    HASH_TO_BKT(_hd_hh_del->hashv, (head)->hh.tbl->num_buckets, _hd_bkt);        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  444|      0|#define HASH_TO_BKT(hashv,num_bkts,bkt)                                          \
  |  |  |  |  |  |  |  |  445|      0|do {                                                                             \
  |  |  |  |  |  |  |  |  446|      0|  bkt = ((hashv) & ((num_bkts) - 1U));                                           \
  |  |  |  |  |  |  |  |  447|      0|} while (0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (447:10): [Folded, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  487|      0|    HASH_DEL_IN_BKT((head)->hh.tbl->buckets[_hd_bkt], _hd_hh_del);               \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  800|      0|#define HASH_DEL_IN_BKT(head,delhh)                                              \
  |  |  |  |  |  |  |  |  801|      0|do {                                                                             \
  |  |  |  |  |  |  |  |  802|      0|  UT_hash_bucket *_hd_head = &(head);                                            \
  |  |  |  |  |  |  |  |  803|      0|  _hd_head->count--;                                                             \
  |  |  |  |  |  |  |  |  804|      0|  if (_hd_head->hh_head == (delhh)) {                                            \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (804:7): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  805|      0|    _hd_head->hh_head = (delhh)->hh_next;                                        \
  |  |  |  |  |  |  |  |  806|      0|  }                                                                              \
  |  |  |  |  |  |  |  |  807|      0|  if ((delhh)->hh_prev) {                                                        \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (807:7): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  808|      0|    (delhh)->hh_prev->hh_next = (delhh)->hh_next;                                \
  |  |  |  |  |  |  |  |  809|      0|  }                                                                              \
  |  |  |  |  |  |  |  |  810|      0|  if ((delhh)->hh_next) {                                                        \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (810:7): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  811|      0|    (delhh)->hh_next->hh_prev = (delhh)->hh_prev;                                \
  |  |  |  |  |  |  |  |  812|      0|  }                                                                              \
  |  |  |  |  |  |  |  |  813|      0|} while (0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (813:10): [Folded, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  488|      0|    (head)->hh.tbl->num_items--;                                                 \
  |  |  |  |  |  |  489|      0|  }                                                                              \
  |  |  |  |  |  |  490|      0|  HASH_FSCK(hh, head, "HASH_DELETE_HH");                                         \
  |  |  |  |  |  |  491|      0|} while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (491:10): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1441|      0|      coap_log_oscore("Association %p deleted\n", (void *)association);
  ------------------
  |  |  132|      0|#define coap_log_oscore(...) coap_log(COAP_LOG_OSCORE, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1442|      0|      oscore_free_association(association);
 1443|      0|    }
 1444|       |    session->associations = NULL;
 1445|     35|  }
 1446|     35|}

coap_fuzz_dispatch:
   36|     35|                   const uint8_t *fixed_path, size_t fixed_path_len) {
   37|     35|  if (!ctx || !session || !data || size < 4)
  ------------------
  |  Branch (37:7): [True: 0, False: 35]
  |  Branch (37:15): [True: 0, False: 35]
  |  Branch (37:27): [True: 0, False: 35]
  |  Branch (37:36): [True: 7, False: 28]
  ------------------
   38|      7|    return;
   39|       |
   40|       |  /* Programmatic PDU with fixed URI-Path using coap_dispatch() */
   41|     28|  {
   42|     28|    coap_fuzz_cursor_t c = { data, size, 0 };
   43|     28|    coap_pdu_type_t type = coap_fuzz_u8(&c) & 1 ? COAP_MESSAGE_NON : COAP_MESSAGE_CON;
  ------------------
  |  Branch (43:28): [True: 11, False: 17]
  ------------------
   44|     28|    coap_pdu_code_t code = coap_fuzz_req_codes[coap_fuzz_u8(&c) % 7];
   45|     28|    uint8_t tkl = coap_fuzz_u8(&c) % 9, token[8];
   46|     86|    for (uint8_t i = 0; i < tkl; i++)
  ------------------
  |  Branch (46:25): [True: 58, False: 28]
  ------------------
   47|     58|      token[i] = coap_fuzz_u8(&c);
   48|       |
   49|     28|    coap_pdu_t *pdu = coap_pdu_init(type, code, coap_new_message_id(session),
   50|     28|                                    coap_session_max_pdu_size(session));
   51|     28|    if (pdu) {
  ------------------
  |  Branch (51:9): [True: 28, False: 0]
  ------------------
   52|     28|      if (tkl)
  ------------------
  |  Branch (52:11): [True: 16, False: 12]
  ------------------
   53|     16|        coap_add_token(pdu, tkl, token);
   54|       |
   55|     28|      uint16_t last = 0;
   56|     28|      if (fixed_path && fixed_path_len) {
  ------------------
  |  Branch (56:11): [True: 28, False: 0]
  |  Branch (56:25): [True: 28, False: 0]
  ------------------
   57|     28|        coap_add_option(pdu, COAP_OPTION_URI_PATH, fixed_path_len, fixed_path);
   58|     28|        last = COAP_OPTION_URI_PATH;
   59|     28|      }
   60|       |
   61|     28|      uint8_t n = coap_fuzz_u8(&c) % 4;
   62|     58|      for (uint8_t i = 0; i < n; i++) {
  ------------------
  |  Branch (62:27): [True: 30, False: 28]
  ------------------
   63|     30|        uint16_t opt = coap_fuzz_opt_nums[coap_fuzz_u8(&c) % COAP_FUZZ_OPT_N];
  ------------------
  |  |   31|     30|#define COAP_FUZZ_OPT_N 9
  ------------------
   64|     30|        if (opt <= last)
  ------------------
  |  Branch (64:13): [True: 13, False: 17]
  ------------------
   65|     13|          continue;
   66|     17|        uint8_t vlen = coap_fuzz_u8(&c) % 9, vbuf[8];
   67|     56|        for (uint8_t j = 0; j < vlen; j++)
  ------------------
  |  Branch (67:29): [True: 39, False: 17]
  ------------------
   68|     39|          vbuf[j] = coap_fuzz_u8(&c);
   69|     17|        if (coap_add_option(pdu, opt, vlen, vbuf))
  ------------------
  |  Branch (69:13): [True: 13, False: 4]
  ------------------
   70|     13|          last = opt;
   71|     17|      }
   72|       |
   73|     28|      size_t rem = c.pos < size ? size - c.pos : 0;
  ------------------
  |  Branch (73:20): [True: 24, False: 4]
  ------------------
   74|     28|      if (rem) {
  ------------------
  |  Branch (74:11): [True: 24, False: 4]
  ------------------
   75|     24|        size_t avail = coap_session_max_pdu_size(session) - pdu->used_size - 1;
   76|     24|        coap_add_data(pdu, rem < avail ? rem : avail, data + c.pos);
  ------------------
  |  Branch (76:28): [True: 12, False: 12]
  ------------------
   77|     24|      }
   78|       |
   79|     28|      coap_lock_lock(return);
   80|     28|      coap_dispatch(ctx, session, pdu);
   81|     28|      coap_lock_unlock();
   82|     28|      coap_delete_pdu(pdu);
   83|     28|    }
   84|     28|  }
   85|       |
   86|       |  /* Raw wire format using coap_handle_dgram() */
   87|     28|  {
   88|     28|    uint8_t *copy = malloc(size);
   89|     28|    if (copy) {
  ------------------
  |  Branch (89:9): [True: 28, False: 0]
  ------------------
   90|     28|      memcpy(copy, data, size);
   91|     28|      coap_lock_lock(return);
   92|     28|      coap_handle_dgram(ctx, session, copy, size);
   93|     28|      coap_lock_unlock();
   94|     28|      free(copy);
   95|     28|    }
   96|     28|  }
   97|     28|}
coap_fuzz_helper.c:coap_fuzz_u8:
   14|    256|coap_fuzz_u8(coap_fuzz_cursor_t *c) {
   15|    256|  return c->size ? c->data[c->pos++ % c->size] : 0;
  ------------------
  |  Branch (15:10): [True: 256, False: 0]
  ------------------
   16|    256|}

LLVMFuzzerTestOneInput:
   25|     35|LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
   26|     35|  if (size < 1)
  ------------------
  |  Branch (26:7): [True: 0, False: 35]
  ------------------
   27|      0|    return 0;
   28|       |
   29|     35|  coap_startup();
   30|     35|  coap_set_log_level(COAP_LOG_EMERG);
   31|     35|  coap_debug_set_packet_loss("50%");
   32|     35|  coap_debug_set_packet_fail("100%");
   33|       |
   34|     35|  coap_context_t *ctx = coap_new_context(NULL);
   35|     35|  if (!ctx)
  ------------------
  |  Branch (35:7): [True: 0, False: 35]
  ------------------
   36|      0|    goto cleanup;
   37|     35|  coap_register_event_handler(ctx, fuzz_event_handler);
   38|       |
   39|     35|  coap_resource_t *res = coap_resource_init(coap_make_str_const("obs"), 0);
   40|     35|  if (!res)
  ------------------
  |  Branch (40:7): [True: 0, False: 35]
  ------------------
   41|      0|    goto cleanup;
   42|     35|  res->observable = 1;
   43|     35|  coap_register_request_handler(res, COAP_REQUEST_GET, fuzz_handler);
   44|     35|  coap_add_resource(ctx, res);
   45|       |
   46|     35|  coap_address_t addr;
   47|     35|  coap_address_init(&addr);
   48|     35|  addr.addr.sa.sa_family = AF_INET;
   49|     35|  coap_session_t *sess = coap_new_client_session(ctx, NULL, &addr, COAP_PROTO_UDP);
   50|     35|  if (!sess)
  ------------------
  |  Branch (50:7): [True: 0, False: 35]
  ------------------
   51|      0|    goto cleanup;
   52|     35|  sess->state = COAP_SESSION_STATE_ESTABLISHED;
   53|       |
   54|       |  /* Test observer functions with fuzzed data */
   55|     35|  size_t offset = 0;
   56|     35|  int iterations = 0;
   57|    142|  while (offset + 1 < size && iterations++ < 5) {
  ------------------
  |  Branch (57:10): [True: 125, False: 17]
  |  Branch (57:31): [True: 107, False: 18]
  ------------------
   58|    107|    coap_pdu_t *pdu = coap_pdu_init(COAP_MESSAGE_CON, COAP_REQUEST_CODE_GET, 1, 128);
   59|    107|    if (!pdu)
  ------------------
  |  Branch (59:9): [True: 0, False: 107]
  ------------------
   60|      0|      break;
   61|       |
   62|       |    /* Fuzzed token */
   63|    107|    size_t tok_len = (data[offset] % 8) + 1;
   64|    107|    if (offset + tok_len < size) {
  ------------------
  |  Branch (64:9): [True: 104, False: 3]
  ------------------
   65|    104|      coap_add_token(pdu, tok_len, data + offset);
   66|    104|      offset += tok_len;
   67|    104|    }
   68|       |
   69|       |    /* Add Observe option */
   70|    107|    uint8_t obs_val = 0;
   71|    107|    coap_insert_option(pdu, COAP_OPTION_OBSERVE, 1, &obs_val);
   72|    107|    coap_add_option(pdu, COAP_OPTION_URI_PATH, 3, (const uint8_t *)"obs");
   73|       |
   74|       |    /* Test coap_add_observer */
   75|    107|    coap_lock_lock(goto cleanup);
   76|    107|    coap_subscription_t *sub = coap_add_observer(res, sess, &pdu->actual_token, pdu);
   77|    107|    coap_lock_unlock();
   78|       |
   79|    107|    if (sub) {
  ------------------
  |  Branch (79:9): [True: 107, False: 0]
  ------------------
   80|       |      /* Test coap_find_observer */
   81|    107|      coap_find_observer(res, sess, &pdu->actual_token);
   82|       |
   83|       |      /* Test coap_touch_observer */
   84|    107|      coap_touch_observer(ctx, sess, &pdu->actual_token);
   85|       |
   86|       |      /* Test coap_resource_notify_observers*/
   87|    107|      coap_resource_notify_observers(res, NULL);
   88|       |
   89|       |      /* Test coap_delete_observer */
   90|    107|      coap_lock_lock(goto cleanup);
   91|    107|      coap_delete_observer(res, sess, &pdu->actual_token);
   92|    107|      coap_lock_unlock();
   93|    107|    }
   94|       |
   95|    107|    coap_delete_pdu(pdu);
   96|    107|    offset += 8;
   97|    107|  }
   98|       |
   99|       |  /* Dispatch GET+OBSERVE to exercise subscription paths in handle_request */
  100|     35|  {
  101|     35|    uint8_t obs_val;
  102|    105|    for (obs_val = 0; obs_val <= 1; obs_val++) {
  ------------------
  |  Branch (102:23): [True: 70, False: 35]
  ------------------
  103|     70|      coap_pdu_t *op = coap_pdu_init(COAP_MESSAGE_CON, COAP_REQUEST_CODE_GET,
  104|     70|                                     coap_new_message_id(sess), 128);
  105|     70|      if (op) {
  ------------------
  |  Branch (105:11): [True: 70, False: 0]
  ------------------
  106|     70|        coap_add_option(op, COAP_OPTION_OBSERVE, 1, &obs_val);
  107|     70|        coap_add_option(op, COAP_OPTION_URI_PATH, 3, (const uint8_t *)"obs");
  108|     70|        coap_lock_lock(goto cleanup);
  109|     70|        coap_dispatch(ctx, sess, op);
  110|     70|        coap_lock_unlock();
  111|     70|        coap_delete_pdu(op);
  112|     70|      }
  113|     70|    }
  114|     35|  }
  115|       |
  116|       |  /* Dispatch with programmatic PDU and raw wire format */
  117|     35|  coap_fuzz_dispatch(ctx, sess, data, size, (const uint8_t *)"obs", 3);
  118|       |
  119|     35|cleanup:
  120|     35|  if (ctx)
  ------------------
  |  Branch (120:7): [True: 35, False: 0]
  ------------------
  121|     35|    coap_free_context(ctx);
  122|     35|  coap_cleanup();
  123|     35|  return 0;
  124|     35|}
observe_target.c:fuzz_event_handler:
    7|     14|fuzz_event_handler(coap_session_t *session, const coap_event_t event) {
    8|     14|  (void)session;
    9|     14|  (void)event;
   10|     14|  return 0;
   11|     14|}
observe_target.c:fuzz_handler:
   16|    186|             coap_pdu_t *response) {
   17|    186|  (void)resource;
   18|    186|  (void)session;
   19|    186|  (void)request;
   20|    186|  (void)query;
   21|    186|  response->code = COAP_RESPONSE_CODE(205);
  ------------------
  |  |   96|    186|#define COAP_RESPONSE_CODE(N) (((N)/100 << 5) | (N)%100)
  ------------------
   22|    186|}

