coap_proxy.c:coap_pdu_release_lkd:
  428|     26|coap_pdu_release_lkd(coap_pdu_t *pdu) {
  429|     26|  coap_delete_pdu_lkd(pdu);
  430|     26|}

coap_address_set_port:
   87|     78|coap_address_set_port(coap_address_t *addr, uint16_t port) {
   88|     78|  assert(addr != NULL);
  ------------------
  |  Branch (88:3): [True: 78, False: 0]
  ------------------
   89|     78|  switch (addr->addr.sa.sa_family) {
   90|      0|#if COAP_IPV4_SUPPORT
   91|     78|  case AF_INET:
  ------------------
  |  Branch (91:3): [True: 78, False: 0]
  ------------------
   92|     78|    addr->addr.sin.sin_port = htons(port);
   93|     78|    break;
   94|      0|#endif /* COAP_IPV4_SUPPORT */
   95|      0|#if COAP_IPV6_SUPPORT
   96|      0|  case AF_INET6:
  ------------------
  |  Branch (96:3): [True: 0, False: 78]
  ------------------
   97|      0|    addr->addr.sin6.sin6_port = htons(port);
   98|      0|    break;
   99|      0|#endif /* COAP_IPV6_SUPPORT */
  100|      0|#if COAP_AF_LLC_SUPPORT
  101|      0|  case AF_LLC:
  ------------------
  |  Branch (101:3): [True: 0, False: 78]
  ------------------
  102|      0|    addr->addr.llc.sllc_sap = port & 0xFF;
  103|      0|#endif /* COAP_AF_LLC_SUPPORT */
  104|      0|  default: /* undefined */
  ------------------
  |  Branch (104:3): [True: 0, False: 78]
  ------------------
  105|      0|    ;
  106|     78|  }
  107|     78|}
coap_address_equals:
  129|     78|coap_address_equals(const coap_address_t *a, const coap_address_t *b) {
  130|     78|  assert(a);
  ------------------
  |  Branch (130:3): [True: 78, False: 0]
  ------------------
  131|     78|  assert(b);
  ------------------
  |  Branch (131:3): [True: 78, False: 0]
  ------------------
  132|       |
  133|     78|  if (a->size != b->size || a->addr.sa.sa_family != b->addr.sa.sa_family)
  ------------------
  |  Branch (133:7): [True: 0, False: 78]
  |  Branch (133:29): [True: 0, False: 78]
  ------------------
  134|      0|    return 0;
  135|       |
  136|       |  /* need to compare only relevant parts of sockaddr_in6 */
  137|     78|  switch (a->addr.sa.sa_family) {
  138|      0|#if COAP_IPV4_SUPPORT
  139|     78|  case AF_INET:
  ------------------
  |  Branch (139:3): [True: 78, False: 0]
  ------------------
  140|     78|    return a->addr.sin.sin_port == b->addr.sin.sin_port &&
  ------------------
  |  Branch (140:12): [True: 52, False: 26]
  ------------------
  141|     52|           memcmp(&a->addr.sin.sin_addr, &b->addr.sin.sin_addr,
  ------------------
  |  Branch (141:12): [True: 52, False: 0]
  ------------------
  142|     52|                  sizeof(struct in_addr)) == 0;
  143|      0|#endif /* COAP_IPV4_SUPPORT */
  144|      0|#if COAP_IPV6_SUPPORT
  145|      0|  case AF_INET6:
  ------------------
  |  Branch (145:3): [True: 0, False: 78]
  ------------------
  146|      0|    return a->addr.sin6.sin6_port == b->addr.sin6.sin6_port &&
  ------------------
  |  Branch (146:12): [True: 0, False: 0]
  ------------------
  147|      0|           memcmp(&a->addr.sin6.sin6_addr, &b->addr.sin6.sin6_addr,
  ------------------
  |  Branch (147:12): [True: 0, False: 0]
  ------------------
  148|      0|                  sizeof(struct in6_addr)) == 0;
  149|      0|#endif /* COAP_IPV6_SUPPORT */
  150|      0|#if COAP_AF_UNIX_SUPPORT
  151|      0|  case AF_UNIX:
  ------------------
  |  Branch (151:3): [True: 0, False: 78]
  ------------------
  152|      0|    return memcmp(&a->addr.cun.sun_path, &b->addr.cun.sun_path,
  153|      0|                  sizeof(a->addr.cun.sun_path)) == 0;
  154|      0|#endif /* COAP_AF_UNIX_SUPPORT */
  155|      0|  default: /* fall through and signal error */
  ------------------
  |  Branch (155:3): [True: 0, False: 78]
  ------------------
  156|      0|    ;
  157|     78|  }
  158|      0|  return 0;
  159|     78|}
coap_is_af_unix:
  162|     26|coap_is_af_unix(const coap_address_t *a) {
  163|     26|#if COAP_AF_UNIX_SUPPORT
  164|     26|  return a->addr.sa.sa_family == AF_UNIX;
  165|       |#else /* ! COAP_AF_UNIX_SUPPORT */
  166|       |  (void)a;
  167|       |  return 0;
  168|       |#endif /* ! COAP_AF_UNIX_SUPPORT */
  169|     26|}
coap_is_af_llc:
  172|     62|coap_is_af_llc(const coap_address_t *a) {
  173|     62|#if COAP_AF_LLC_SUPPORT
  174|     62|  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|     62|}
coap_is_mcast:
  182|    116|coap_is_mcast(const coap_address_t *a) {
  183|    116|  if (!a)
  ------------------
  |  Branch (183:7): [True: 0, False: 116]
  ------------------
  184|      0|    return 0;
  185|       |
  186|       |  /* Treat broadcast in same way as multicast */
  187|    116|  if (coap_is_bcast(a))
  ------------------
  |  Branch (187:7): [True: 0, False: 116]
  ------------------
  188|      0|    return 1;
  189|       |
  190|    116|  switch (a->addr.sa.sa_family) {
  191|      0|#if COAP_IPV4_SUPPORT
  192|    116|  case AF_INET:
  ------------------
  |  Branch (192:3): [True: 116, False: 0]
  ------------------
  193|    116|    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: 116]
  ------------------
  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: 116]
  ------------------
  206|      0|    ;
  207|    116|  }
  208|      0|  return 0;
  209|    116|}
coap_is_bcast:
  227|    116|coap_is_bcast(const coap_address_t *a) {
  228|    116|#if COAP_IPV4_SUPPORT
  229|    116|  struct in_addr ipv4;
  230|    116|#if defined(HAVE_GETIFADDRS) && !defined(__ZEPHYR__)
  231|    116|  int i;
  232|    116|  coap_tick_t now;
  233|    116|#endif /* HAVE_GETIFADDRS && !defined(__ZEPHYR__) */
  234|    116|#endif /* COAP_IPV4_SUPPORT */
  235|       |
  236|    116|  if (!a)
  ------------------
  |  Branch (236:7): [True: 0, False: 116]
  ------------------
  237|      0|    return 0;
  238|       |
  239|    116|  switch (a->addr.sa.sa_family) {
  240|      0|#if COAP_IPV4_SUPPORT
  241|    116|  case AF_INET:
  ------------------
  |  Branch (241:3): [True: 116, False: 0]
  ------------------
  242|    116|    ipv4.s_addr = a->addr.sin.sin_addr.s_addr;
  243|    116|    break;
  244|      0|#endif /* COAP_IPV4_SUPPORT */
  245|      0|#if COAP_IPV6_SUPPORT
  246|      0|  case  AF_INET6:
  ------------------
  |  Branch (246:3): [True: 0, False: 116]
  ------------------
  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: 116]
  ------------------
  257|      0|    return 0;
  258|    116|  }
  259|    116|#if COAP_IPV4_SUPPORT
  260|       |#ifndef INADDR_BROADCAST
  261|       |#define INADDR_BROADCAST ((uint32_t)0xffffffffUL)
  262|       |#endif /* !INADDR_BROADCAST */
  263|    116|  if (ipv4.s_addr == INADDR_BROADCAST)
  ------------------
  |  Branch (263:7): [True: 0, False: 116]
  ------------------
  264|      0|    return 1;
  265|       |
  266|    116|#if defined(HAVE_GETIFADDRS) && !defined(__ZEPHYR__)
  267|    116|  coap_ticks(&now);
  268|    116|  if (bcst_cnt == -1 ||
  ------------------
  |  Branch (268:7): [True: 1, False: 115]
  ------------------
  269|    115|      (now - last_refresh) > (COAP_BCST_REFRESH_SECS * COAP_TICKS_PER_SECOND)) {
  ------------------
  |  |  217|    115|#define COAP_BCST_REFRESH_SECS 30
  ------------------
                    (now - last_refresh) > (COAP_BCST_REFRESH_SECS * COAP_TICKS_PER_SECOND)) {
  ------------------
  |  |  164|    115|#define COAP_TICKS_PER_SECOND ((coap_tick_t)(1000U))
  ------------------
  |  Branch (269:7): [True: 0, False: 115]
  ------------------
  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|    232|  for (i = 0; i < bcst_cnt; i++) {
  ------------------
  |  Branch (304:15): [True: 116, False: 116]
  ------------------
  305|    116|    if (ipv4.s_addr == b_ipv4[i].s_addr)
  ------------------
  |  Branch (305:9): [True: 0, False: 116]
  ------------------
  306|      0|      return 1;
  307|    116|  }
  308|    116|#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|    116|#endif /* COAP_IPV4_SUPPORT */
  377|    116|  return 0;
  378|    116|}
coap_address_init:
  383|    238|coap_address_init(coap_address_t *addr) {
  384|    238|  assert(addr);
  ------------------
  |  Branch (384:3): [True: 238, False: 0]
  ------------------
  385|    238|  memset(addr, 0, sizeof(coap_address_t));
  386|    238|#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|    238|  addr->size = sizeof(addr->addr);
  389|    238|#endif
  390|    238|}
coap_resolve_address_info_lkd:
  730|     26|                              coap_resolve_type_t type) {
  731|       |
  732|     26|  struct addrinfo *res, *ainfo;
  733|     26|  struct addrinfo hints;
  734|       |#if COAP_CONSTRAINED_STACK
  735|       |  static char addrstr[256];
  736|       |#else /* ! COAP_CONSTRAINED_STACK */
  737|     26|  char addrstr[256];
  738|     26|#endif /* ! COAP_CONSTRAINED_STACK */
  739|     26|  int error;
  740|     26|  coap_addr_info_t *info = NULL;
  741|     26|  coap_addr_info_t *info_prev = NULL;
  742|     26|  coap_addr_info_t *info_list = NULL;
  743|     26|  coap_addr_info_t *info_tmp;
  744|     26|  coap_uri_scheme_t scheme;
  745|       |
  746|     26|  coap_lock_check_locked();
  ------------------
  |  |  638|     26|#define coap_lock_check_locked() {}
  ------------------
  747|       |
  748|     26|#if COAP_AF_UNIX_SUPPORT
  749|     26|  if (address && coap_host_is_unix_domain(address)) {
  ------------------
  |  Branch (749:7): [True: 26, False: 0]
  |  Branch (749:18): [True: 0, False: 26]
  ------------------
  750|       |    /* There can only be one unique filename entry for AF_UNIX */
  751|      0|    if (address->length >= COAP_UNIX_PATH_MAX) {
  ------------------
  |  |  177|      0|#define COAP_UNIX_PATH_MAX   (sizeof(struct sockaddr_in6) - sizeof(sa_family_t))
  ------------------
  |  Branch (751:9): [True: 0, False: 0]
  ------------------
  752|      0|      coap_log_err("Unix Domain host too long\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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  753|      0|      return NULL;
  754|      0|    }
  755|       |    /* Need to chose the first defined one  in scheme_hint_bits */
  756|      0|    for (scheme = 0; scheme < COAP_URI_SCHEME_LAST; scheme++) {
  ------------------
  |  Branch (756:22): [True: 0, False: 0]
  ------------------
  757|      0|      if (scheme_hint_bits & (1 << scheme)) {
  ------------------
  |  Branch (757:11): [True: 0, False: 0]
  ------------------
  758|      0|        break;
  759|      0|      }
  760|      0|    }
  761|      0|    if (scheme == COAP_URI_SCHEME_LAST) {
  ------------------
  |  Branch (761:9): [True: 0, False: 0]
  ------------------
  762|      0|      return NULL;
  763|      0|    }
  764|      0|    info = get_coap_addr_info(scheme);
  765|      0|    if (info == NULL) {
  ------------------
  |  Branch (765:9): [True: 0, False: 0]
  ------------------
  766|      0|      return NULL;
  767|      0|    }
  768|       |
  769|      0|    if (!coap_address_set_unix_domain(&info->addr, address->s,
  ------------------
  |  Branch (769:9): [True: 0, False: 0]
  ------------------
  770|      0|                                      address->length)) {
  771|      0|      coap_free_type(COAP_STRING, info);
  772|      0|      return NULL;
  773|      0|    }
  774|      0|    return info;
  775|      0|  }
  776|     26|#endif /* COAP_AF_UNIX_SUPPORT */
  777|     26|#if COAP_AF_LLC_SUPPORT
  778|     26|  if (address && coap_host_is_llc(address)) {
  ------------------
  |  Branch (778:7): [True: 26, False: 0]
  |  Branch (778:18): [True: 0, False: 26]
  ------------------
  779|      0|    for (scheme = 0; scheme < COAP_URI_SCHEME_LAST; scheme++) {
  ------------------
  |  Branch (779:22): [True: 0, False: 0]
  ------------------
  780|      0|      if (scheme_hint_bits & (1 << scheme)) {
  ------------------
  |  Branch (780:11): [True: 0, False: 0]
  ------------------
  781|      0|        break;
  782|      0|      }
  783|      0|    }
  784|      0|    if (scheme == COAP_URI_SCHEME_LAST) {
  ------------------
  |  Branch (784:9): [True: 0, False: 0]
  ------------------
  785|      0|      return NULL;
  786|      0|    }
  787|      0|    info = get_coap_addr_info(scheme);
  788|      0|    if (info == NULL) {
  ------------------
  |  Branch (788:9): [True: 0, False: 0]
  ------------------
  789|      0|      return NULL;
  790|      0|    }
  791|       |
  792|      0|    if (!coap_address_set_llc(&info->addr, address->s, address->length)) {
  ------------------
  |  Branch (792:9): [True: 0, False: 0]
  ------------------
  793|      0|      coap_free_type(COAP_STRING, info);
  794|      0|      return NULL;
  795|      0|    }
  796|       |
  797|      0|    return info;
  798|      0|  }
  799|     26|#endif /* COAP_AF_LLC_SUPPORT */
  800|       |
  801|     26|  memset(addrstr, 0, sizeof(addrstr));
  802|     26|  if (address && address->length) {
  ------------------
  |  Branch (802:7): [True: 26, False: 0]
  |  Branch (802:18): [True: 26, False: 0]
  ------------------
  803|     26|    if (address->length >= sizeof(addrstr)) {
  ------------------
  |  Branch (803:9): [True: 0, False: 26]
  ------------------
  804|      0|      coap_log_warn("Host name too long (%" PRIuS " > 255)\n", address->length);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  805|      0|      return NULL;
  806|      0|    }
  807|     26|    memcpy(addrstr, address->s, address->length);
  808|     26|  } else {
  809|      0|    memcpy(addrstr, "localhost", 9);
  810|      0|  }
  811|       |
  812|     26|  memset((char *)&hints, 0, sizeof(hints));
  813|     26|  hints.ai_socktype = 0;
  814|     26|  hints.ai_family = AF_UNSPEC;
  815|     26|  hints.ai_flags = ai_hints_flags;
  816|       |
  817|     26|  error = getaddrinfo(addrstr, NULL, &hints, &res);
  818|       |
  819|     26|  if (error != 0) {
  ------------------
  |  Branch (819:7): [True: 0, False: 26]
  ------------------
  820|       |#if defined(WITH_LWIP)
  821|       |    coap_log_warn("getaddrinfo: %s: %d\n", addrstr, error);
  822|       |#else /* ! WITH_LWIP */
  823|      0|    coap_log_warn("getaddrinfo: %s: %s\n", addrstr, gai_strerror(error));
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  824|      0|#endif /* ! WITH_LWIP */
  825|      0|    return NULL;
  826|      0|  }
  827|       |
  828|    104|  for (ainfo = res; ainfo != NULL; ainfo = ainfo->ai_next) {
  ------------------
  |  Branch (828:21): [True: 78, False: 26]
  ------------------
  829|     78|#if !defined(WITH_LWIP)
  830|     78|    if (ainfo->ai_addrlen > (socklen_t)sizeof(info->addr.addr))
  ------------------
  |  Branch (830:9): [True: 0, False: 78]
  ------------------
  831|      0|      continue;
  832|     78|#endif /* ! WITH_LWIP */
  833|       |
  834|     78|    switch (ainfo->ai_family) {
  835|      0|#if COAP_IPV4_SUPPORT
  836|     78|    case AF_INET:
  ------------------
  |  Branch (836:5): [True: 78, False: 0]
  ------------------
  837|     78|#endif /* COAP_IPV4_SUPPORT */
  838|     78|#if COAP_IPV6_SUPPORT
  839|     78|    case AF_INET6:
  ------------------
  |  Branch (839:5): [True: 0, False: 78]
  ------------------
  840|     78|#endif /* COAP_IPV6_SUPPORT */
  841|    702|      for (scheme = 0; scheme < COAP_URI_SCHEME_LAST; scheme++) {
  ------------------
  |  Branch (841:24): [True: 624, False: 78]
  ------------------
  842|    624|        if (scheme_hint_bits & (1 << scheme)) {
  ------------------
  |  Branch (842:13): [True: 78, False: 546]
  ------------------
  843|     78|          info = get_coap_addr_info(scheme);
  844|     78|          if (info == NULL) {
  ------------------
  |  Branch (844:15): [True: 0, False: 78]
  ------------------
  845|      0|            continue;
  846|      0|          }
  847|       |
  848|     78|#if !defined(WITH_LWIP)
  849|     78|          info->addr.size = (socklen_t)ainfo->ai_addrlen;
  850|     78|          memcpy(&info->addr.addr, ainfo->ai_addr, ainfo->ai_addrlen);
  851|       |#else /* WITH_LWIP */
  852|       |          memset(&info->addr, 0, sizeof(info->addr));
  853|       |          switch (ainfo->ai_family) {
  854|       |#if COAP_IPV6_SUPPORT
  855|       |            struct sockaddr_in6 *sock6;
  856|       |#endif /* COAP_IPV6_SUPPORT */
  857|       |#if COAP_IPV4_SUPPORT
  858|       |            struct sockaddr_in *sock4;
  859|       |          case AF_INET:
  860|       |            sock4 = (struct sockaddr_in *)ainfo->ai_addr;
  861|       |            info->addr.port = ntohs(sock4->sin_port);
  862|       |            memcpy(&info->addr.addr, &sock4->sin_addr, 4);
  863|       |#if LWIP_IPV6
  864|       |            info->addr.addr.type = IPADDR_TYPE_V4;
  865|       |#endif /* LWIP_IPV6 */
  866|       |            break;
  867|       |#endif /* COAP_IPV4_SUPPORT */
  868|       |#if COAP_IPV6_SUPPORT
  869|       |          case AF_INET6:
  870|       |            sock6 = (struct sockaddr_in6 *)ainfo->ai_addr;
  871|       |            info->addr.port = ntohs(sock6->sin6_port);
  872|       |            memcpy(&info->addr.addr, &sock6->sin6_addr, 16);
  873|       |#if LWIP_IPV6 && LWIP_IPV4
  874|       |            info->addr.addr.type = IPADDR_TYPE_V6;
  875|       |#endif /* LWIP_IPV6 && LWIP_IPV4 */
  876|       |            break;
  877|       |#endif /* COAP_IPV6_SUPPORT */
  878|       |          default:
  879|       |            ;
  880|       |          }
  881|       |#endif /* WITH_LWIP */
  882|     78|          update_coap_addr_port(scheme, info, port, secure_port, ws_port,
  883|     78|                                ws_secure_port, type);
  884|       |
  885|       |          /* Check there are no duplications */
  886|     78|          info_tmp = info_list;
  887|     78|          while (info_tmp) {
  ------------------
  |  Branch (887:18): [True: 52, False: 26]
  ------------------
  888|     52|            if (info_tmp->proto == info->proto &&
  ------------------
  |  Branch (888:17): [True: 52, False: 0]
  ------------------
  889|     52|                info_tmp->scheme == info->scheme &&
  ------------------
  |  Branch (889:17): [True: 52, False: 0]
  ------------------
  890|     52|                coap_address_equals(&info_tmp->addr, &info->addr)) {
  ------------------
  |  Branch (890:17): [True: 52, False: 0]
  ------------------
  891|     52|              break;
  892|     52|            }
  893|      0|            info_tmp = info_tmp->next;
  894|      0|          }
  895|       |
  896|     78|          if (info_tmp) {
  ------------------
  |  Branch (896:15): [True: 52, False: 26]
  ------------------
  897|       |            /* Duplicate */
  898|     52|            coap_free_type(COAP_STRING, info);
  899|     52|          } else {
  900|       |            /* Need to return in same order as getaddrinfo() */
  901|     26|            if (!info_prev) {
  ------------------
  |  Branch (901:17): [True: 26, False: 0]
  ------------------
  902|     26|              info_list = info;
  903|     26|              info_prev = info;
  904|     26|            } else {
  905|      0|              info_prev->next = info;
  906|      0|              info_prev = info;
  907|      0|            }
  908|     26|          }
  909|     78|        }
  910|    624|      }
  911|     78|      break;
  912|      0|    default:
  ------------------
  |  Branch (912:5): [True: 0, False: 78]
  ------------------
  913|      0|      break;
  914|     78|    }
  915|     78|  }
  916|       |
  917|     26|  freeaddrinfo(res);
  918|     26|  return info_list;
  919|     26|}
coap_free_address_info:
 1123|     26|coap_free_address_info(coap_addr_info_t *info) {
 1124|     52|  while (info) {
  ------------------
  |  Branch (1124:10): [True: 26, False: 26]
  ------------------
 1125|     26|    coap_addr_info_t *info_next = info->next;
 1126|       |
 1127|     26|    coap_free_type(COAP_STRING, info);
 1128|     26|    info = info_next;
 1129|     26|  }
 1130|     26|}
coap_address_copy:
 1134|    135|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|    135|  memset(dst, 0, sizeof(coap_address_t));
 1139|    135|  dst->size = src->size;
 1140|    135|#if COAP_IPV6_SUPPORT
 1141|    135|  if (src->addr.sa.sa_family == AF_INET6) {
  ------------------
  |  Branch (1141:7): [True: 0, False: 135]
  ------------------
 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|    135|#endif /* COAP_IPV6_SUPPORT */
 1148|    135|#if COAP_IPV4_SUPPORT && COAP_IPV6_SUPPORT
 1149|    135|  else
 1150|    135|#endif /* COAP_IPV4_SUPPORT && COAP_IPV6_SUPPORT */
 1151|    135|#if COAP_IPV4_SUPPORT
 1152|    135|    if (src->addr.sa.sa_family == AF_INET) {
  ------------------
  |  Branch (1152:9): [True: 135, False: 0]
  ------------------
 1153|    135|      dst->addr.sin = src->addr.sin;
 1154|    135|    }
 1155|      0|#endif /* COAP_IPV4_SUPPORT */
 1156|      0|    else {
 1157|      0|      memcpy(&dst->addr, &src->addr, src->size);
 1158|      0|    }
 1159|    135|#endif
 1160|    135|}
coap_address.c:get_coap_addr_info:
  564|     78|get_coap_addr_info(coap_uri_scheme_t scheme) {
  565|     78|  coap_addr_info_t *info = NULL;
  566|     78|  coap_proto_t proto = 0;
  567|       |
  568|     78|  switch (scheme) {
  569|     78|  case COAP_URI_SCHEME_COAP:
  ------------------
  |  Branch (569:3): [True: 78, False: 0]
  ------------------
  570|     78|    proto = COAP_PROTO_UDP;
  571|     78|    break;
  572|      0|  case COAP_URI_SCHEME_COAPS:
  ------------------
  |  Branch (572:3): [True: 0, False: 78]
  ------------------
  573|      0|    if (!coap_dtls_is_supported())
  ------------------
  |  Branch (573:9): [True: 0, False: 0]
  ------------------
  574|      0|      return NULL;
  575|      0|    proto = COAP_PROTO_DTLS;
  576|      0|    break;
  577|      0|  case COAP_URI_SCHEME_COAP_TCP:
  ------------------
  |  Branch (577:3): [True: 0, False: 78]
  ------------------
  578|      0|    if (!coap_tcp_is_supported())
  ------------------
  |  Branch (578:9): [True: 0, False: 0]
  ------------------
  579|      0|      return NULL;
  580|      0|    proto = COAP_PROTO_TCP;
  581|      0|    break;
  582|      0|  case COAP_URI_SCHEME_COAPS_TCP:
  ------------------
  |  Branch (582:3): [True: 0, False: 78]
  ------------------
  583|      0|    if (!coap_tls_is_supported())
  ------------------
  |  Branch (583:9): [True: 0, False: 0]
  ------------------
  584|      0|      return NULL;
  585|      0|    proto = COAP_PROTO_TLS;
  586|      0|    break;
  587|      0|  case COAP_URI_SCHEME_HTTP:
  ------------------
  |  Branch (587:3): [True: 0, False: 78]
  ------------------
  588|      0|    if (!coap_tcp_is_supported())
  ------------------
  |  Branch (588:9): [True: 0, False: 0]
  ------------------
  589|      0|      return NULL;
  590|      0|    proto = COAP_PROTO_NONE;
  591|      0|    break;
  592|      0|  case COAP_URI_SCHEME_HTTPS:
  ------------------
  |  Branch (592:3): [True: 0, False: 78]
  ------------------
  593|      0|    if (!coap_tls_is_supported())
  ------------------
  |  Branch (593:9): [True: 0, False: 0]
  ------------------
  594|      0|      return NULL;
  595|      0|    proto = COAP_PROTO_NONE;
  596|      0|    break;
  597|      0|  case COAP_URI_SCHEME_COAP_WS:
  ------------------
  |  Branch (597:3): [True: 0, False: 78]
  ------------------
  598|      0|    if (!coap_ws_is_supported())
  ------------------
  |  Branch (598:9): [True: 0, False: 0]
  ------------------
  599|      0|      return NULL;
  600|      0|    proto = COAP_PROTO_WS;
  601|      0|    break;
  602|      0|  case COAP_URI_SCHEME_COAPS_WS:
  ------------------
  |  Branch (602:3): [True: 0, False: 78]
  ------------------
  603|      0|    if (!coap_wss_is_supported())
  ------------------
  |  Branch (603:9): [True: 0, False: 0]
  ------------------
  604|      0|      return NULL;
  605|      0|    proto = COAP_PROTO_WSS;
  606|      0|    break;
  607|      0|  case COAP_URI_SCHEME_LAST:
  ------------------
  |  Branch (607:3): [True: 0, False: 78]
  ------------------
  608|      0|  default:
  ------------------
  |  Branch (608:3): [True: 0, False: 78]
  ------------------
  609|      0|    return NULL;
  610|     78|  }
  611|     78|  info = coap_malloc_type(COAP_STRING, sizeof(coap_addr_info_t));
  612|     78|  if (info == NULL)
  ------------------
  |  Branch (612:7): [True: 0, False: 78]
  ------------------
  613|      0|    return NULL;
  614|     78|  info->next = NULL;
  615|     78|  info->proto = proto;
  616|     78|  info->scheme = scheme;
  617|       |
  618|     78|  coap_address_init(&info->addr);
  619|     78|  return info;
  620|     78|}
coap_address.c:update_coap_addr_port:
  626|     78|                      coap_resolve_type_t type) {
  627|     78|  switch (scheme) {
  628|     78|  case COAP_URI_SCHEME_COAP:
  ------------------
  |  Branch (628:3): [True: 78, False: 0]
  ------------------
  629|     78|    update_port(&info->addr, port, COAP_DEFAULT_PORT,
  ------------------
  |  |   39|     78|#define COAP_DEFAULT_PORT      5683 /* CoAP default UDP/TCP port */
  ------------------
  630|     78|                type == COAP_RESOLVE_TYPE_LOCAL);
  631|     78|    break;
  632|      0|  case COAP_URI_SCHEME_COAPS:
  ------------------
  |  Branch (632:3): [True: 0, False: 78]
  ------------------
  633|      0|    update_port(&info->addr, secure_port, COAPS_DEFAULT_PORT,
  ------------------
  |  |   40|      0|#define COAPS_DEFAULT_PORT     5684 /* CoAP default UDP/TCP port for secure transmission */
  ------------------
  634|      0|                type == COAP_RESOLVE_TYPE_LOCAL);
  635|      0|    break;
  636|      0|  case COAP_URI_SCHEME_COAP_TCP:
  ------------------
  |  Branch (636:3): [True: 0, False: 78]
  ------------------
  637|      0|    update_port(&info->addr, port, COAP_DEFAULT_PORT,
  ------------------
  |  |   39|      0|#define COAP_DEFAULT_PORT      5683 /* CoAP default UDP/TCP port */
  ------------------
  638|      0|                type == COAP_RESOLVE_TYPE_LOCAL);
  639|      0|    break;
  640|      0|  case COAP_URI_SCHEME_COAPS_TCP:
  ------------------
  |  Branch (640:3): [True: 0, False: 78]
  ------------------
  641|      0|    update_port(&info->addr, secure_port, COAPS_DEFAULT_PORT,
  ------------------
  |  |   40|      0|#define COAPS_DEFAULT_PORT     5684 /* CoAP default UDP/TCP port for secure transmission */
  ------------------
  642|      0|                type == COAP_RESOLVE_TYPE_LOCAL);
  643|      0|    break;
  644|      0|  case COAP_URI_SCHEME_HTTP:
  ------------------
  |  Branch (644:3): [True: 0, False: 78]
  ------------------
  645|      0|    update_port(&info->addr, port, 80,
  646|      0|                type == COAP_RESOLVE_TYPE_LOCAL);
  647|      0|    break;
  648|      0|  case COAP_URI_SCHEME_HTTPS:
  ------------------
  |  Branch (648:3): [True: 0, False: 78]
  ------------------
  649|      0|    update_port(&info->addr, secure_port, 443,
  650|      0|                type == COAP_RESOLVE_TYPE_LOCAL);
  651|      0|    break;
  652|      0|  case COAP_URI_SCHEME_COAP_WS:
  ------------------
  |  Branch (652:3): [True: 0, False: 78]
  ------------------
  653|      0|    update_port(&info->addr, ws_port, 80,
  654|      0|                type == COAP_RESOLVE_TYPE_LOCAL);
  655|      0|    break;
  656|      0|  case COAP_URI_SCHEME_COAPS_WS:
  ------------------
  |  Branch (656:3): [True: 0, False: 78]
  ------------------
  657|      0|    update_port(&info->addr, ws_secure_port, 443,
  658|      0|                type == COAP_RESOLVE_TYPE_LOCAL);
  659|      0|    break;
  660|      0|  case COAP_URI_SCHEME_LAST:
  ------------------
  |  Branch (660:3): [True: 0, False: 78]
  ------------------
  661|      0|  default:
  ------------------
  |  Branch (661:3): [True: 0, False: 78]
  ------------------
  662|      0|    break;
  663|     78|  }
  664|     78|}
coap_address.c:update_port:
  478|     78|            int update_port0) {
  479|       |  /* Client target port must be set if default of 0 */
  480|     78|  if (port == 0 && update_port0)
  ------------------
  |  Branch (480:7): [True: 78, False: 0]
  |  Branch (480:20): [True: 0, False: 78]
  ------------------
  481|      0|    port = default_port;
  482|       |
  483|     78|  coap_address_set_port(addr, port);
  484|     78|  return;
  485|     78|}

coap_delete_all_async:
  213|     36|coap_delete_all_async(coap_context_t *context) {
  214|     36|  coap_async_t *astate, *tmp;
  215|       |
  216|     36|  LL_FOREACH_SAFE(context->async_state, astate, tmp) {
  ------------------
  |  |  425|     36|    LL_FOREACH_SAFE2(head,el,tmp,next)
  |  |  ------------------
  |  |  |  |  428|     36|  for ((el) = (head); (el) && ((tmp) = (el)->next, 1); (el) = (tmp))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (428:23): [True: 0, False: 36]
  |  |  |  |  |  Branch (428:31): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  217|      0|    coap_free_async_sub(context, astate);
  218|      0|  }
  219|       |  context->async_state = NULL;
  220|     36|}

coap_delete_cache_key:
  160|     26|coap_delete_cache_key(coap_cache_key_t *cache_key) {
  161|     26|  coap_free_type(COAP_CACHE_KEY, cache_key);
  162|     26|}

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

coap_socket_connect_udp:
  205|     62|                        coap_address_t *remote_addr) {
  206|     62|  int on = 1;
  207|     62|#if COAP_IPV6_SUPPORT
  208|     62|  int off = 0;
  209|     62|#endif /* COAP_IPV6_SUPPORT */
  210|       |#ifdef _WIN32
  211|       |  u_long u_on = 1;
  212|       |#endif
  213|     62|  coap_address_t connect_addr;
  214|     62|  int is_mcast = coap_is_mcast(server);
  215|     62|  coap_address_copy(&connect_addr, server);
  216|       |
  217|     62|  sock->flags &= ~(COAP_SOCKET_CONNECTED | COAP_SOCKET_MULTICAST);
  ------------------
  |  |   77|     62|#define COAP_SOCKET_CONNECTED    0x0004  /**< the socket is connected */
  ------------------
                sock->flags &= ~(COAP_SOCKET_CONNECTED | COAP_SOCKET_MULTICAST);
  ------------------
  |  |   86|     62|#define COAP_SOCKET_MULTICAST    0x1000  /**< socket is used for multicast communication */
  ------------------
  218|     62|  sock->fd = socket(connect_addr.addr.sa.sa_family, SOCK_DGRAM, 0);
  219|       |
  220|     62|  if (sock->fd == COAP_INVALID_SOCKET) {
  ------------------
  |  |   52|     62|#define COAP_INVALID_SOCKET (-1)
  ------------------
  |  Branch (220:7): [True: 0, False: 62]
  ------------------
  221|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  222|      0|                  coap_socket_strerror());
  223|      0|    goto error;
  224|      0|  }
  225|       |
  226|       |#ifdef _WIN32
  227|       |  if (ioctlsocket(sock->fd, FIONBIO, &u_on) == COAP_SOCKET_ERROR)
  228|       |#else
  229|     62|  if (ioctl(sock->fd, FIONBIO, &on) == COAP_SOCKET_ERROR)
  ------------------
  |  |   51|     62|#define COAP_SOCKET_ERROR (-1)
  ------------------
  |  Branch (229:7): [True: 0, False: 62]
  ------------------
  230|      0|#endif
  231|      0|  {
  232|       |    /* Ignore Zephyr unexpected Success response */
  233|      0|    if (errno != 0) {
  ------------------
  |  Branch (233:9): [True: 0, False: 0]
  ------------------
  234|      0|      int keep_errno = errno;
  235|       |
  236|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  237|      0|                    coap_socket_strerror(), keep_errno);
  238|      0|    }
  239|      0|  }
  240|       |
  241|     62|  switch (connect_addr.addr.sa.sa_family) {
  242|      0|#if COAP_IPV4_SUPPORT
  243|     62|  case AF_INET:
  ------------------
  |  Branch (243:3): [True: 62, False: 0]
  ------------------
  244|     62|    if (connect_addr.addr.sin.sin_port == 0)
  ------------------
  |  Branch (244:9): [True: 26, False: 36]
  ------------------
  245|     26|      connect_addr.addr.sin.sin_port = htons(default_port);
  246|     62|    break;
  247|      0|#endif /* COAP_IPV4_SUPPORT */
  248|      0|#if COAP_IPV6_SUPPORT
  249|      0|  case AF_INET6:
  ------------------
  |  Branch (249:3): [True: 0, False: 62]
  ------------------
  250|      0|    if (connect_addr.addr.sin6.sin6_port == 0)
  ------------------
  |  Branch (250:9): [True: 0, False: 0]
  ------------------
  251|      0|      connect_addr.addr.sin6.sin6_port = htons(default_port);
  252|       |    /* Configure the socket as dual-stacked */
  253|      0|    if (setsockopt(sock->fd, IPPROTO_IPV6, IPV6_V6ONLY, OPTVAL_T(&off),
  ------------------
  |  |   34|      0|# define OPTVAL_T(t)         (t)
  ------------------
  |  Branch (253:9): [True: 0, False: 0]
  ------------------
  254|      0|                   sizeof(off)) == COAP_SOCKET_ERROR)
  ------------------
  |  |   51|      0|#define COAP_SOCKET_ERROR (-1)
  ------------------
  255|      0|      if (errno != ENOSYS) {
  ------------------
  |  Branch (255:11): [True: 0, False: 0]
  ------------------
  256|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  257|      0|                      coap_socket_strerror());
  258|      0|      }
  259|      0|#endif /* COAP_IPV6_SUPPORT */
  260|      0|    break;
  261|      0|#if COAP_AF_UNIX_SUPPORT
  262|      0|  case AF_UNIX:
  ------------------
  |  Branch (262:3): [True: 0, False: 62]
  ------------------
  263|      0|    break;
  264|      0|#endif /* COAP_AF_UNIX_SUPPORT */
  265|      0|#if COAP_AF_LLC_SUPPORT
  266|      0|  case AF_LLC:
  ------------------
  |  Branch (266:3): [True: 0, False: 62]
  ------------------
  267|      0|    break;
  268|      0|#endif /* COAP_AF_LLC_SUPPORT */
  269|      0|  default:
  ------------------
  |  Branch (269:3): [True: 0, False: 62]
  ------------------
  270|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  271|      0|                   connect_addr.addr.sa.sa_family);
  272|      0|    goto error;;
  273|     62|  }
  274|       |
  275|     62|  if (local_if && local_if->addr.sa.sa_family) {
  ------------------
  |  Branch (275:7): [True: 0, False: 62]
  |  Branch (275:19): [True: 0, False: 0]
  ------------------
  276|      0|    if (local_if->addr.sa.sa_family != connect_addr.addr.sa.sa_family) {
  ------------------
  |  Branch (276:9): [True: 0, False: 0]
  ------------------
  277|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  278|      0|                    "remote address family\n");
  279|      0|      goto error;
  280|      0|    }
  281|      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 (281:9): [True: 0, False: 0]
  ------------------
  282|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  283|      0|                    coap_socket_strerror());
  284|      0|    if (bind(sock->fd, &local_if->addr.sa,
  ------------------
  |  Branch (284:9): [True: 0, False: 0]
  ------------------
  285|      0|#if COAP_IPV4_SUPPORT
  286|      0|             local_if->addr.sa.sa_family == AF_INET ?
  ------------------
  |  Branch (286:14): [True: 0, False: 0]
  ------------------
  287|      0|             (socklen_t)sizeof(struct sockaddr_in) :
  288|      0|#endif /* COAP_IPV4_SUPPORT */
  289|      0|             (socklen_t)local_if->size) == COAP_SOCKET_ERROR) {
  ------------------
  |  |   51|      0|#define COAP_SOCKET_ERROR (-1)
  ------------------
  290|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  291|      0|                    coap_socket_strerror());
  292|      0|      goto error;
  293|      0|    }
  294|      0|#if COAP_AF_UNIX_SUPPORT
  295|     62|  } else if (connect_addr.addr.sa.sa_family == AF_UNIX) {
  ------------------
  |  Branch (295:14): [True: 0, False: 62]
  ------------------
  296|       |    /* Need to bind to a local address for clarity over endpoints */
  297|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  298|      0|    goto error;
  299|      0|#endif /* COAP_AF_UNIX_SUPPORT */
  300|      0|  }
  301|       |
  302|       |  /* special treatment for sockets that are used for multicast communication */
  303|     62|  if (is_mcast) {
  ------------------
  |  Branch (303:7): [True: 0, False: 62]
  ------------------
  304|      0|    if (!(local_if && local_if->addr.sa.sa_family)) {
  ------------------
  |  Branch (304:11): [True: 0, False: 0]
  |  Branch (304:23): [True: 0, False: 0]
  ------------------
  305|       |      /* Bind to a (unused) port to simplify logging */
  306|      0|      coap_address_t bind_addr;
  307|       |
  308|      0|      coap_address_init(&bind_addr);
  309|      0|      bind_addr.addr.sa.sa_family = connect_addr.addr.sa.sa_family;
  310|      0|      if (bind(sock->fd, &bind_addr.addr.sa,
  ------------------
  |  Branch (310:11): [True: 0, False: 0]
  ------------------
  311|      0|#if COAP_IPV4_SUPPORT
  312|      0|               bind_addr.addr.sa.sa_family == AF_INET ?
  ------------------
  |  Branch (312:16): [True: 0, False: 0]
  ------------------
  313|      0|               (socklen_t)sizeof(struct sockaddr_in) :
  314|      0|#endif /* COAP_IPV4_SUPPORT */
  315|      0|               (socklen_t)bind_addr.size) == COAP_SOCKET_ERROR) {
  ------------------
  |  |   51|      0|#define COAP_SOCKET_ERROR (-1)
  ------------------
  316|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  317|      0|                      coap_socket_strerror());
  318|      0|        goto error;
  319|      0|      }
  320|      0|    }
  321|      0|    if (getsockname(sock->fd, &local_addr->addr.sa, &local_addr->size) == COAP_SOCKET_ERROR) {
  ------------------
  |  |   51|      0|#define COAP_SOCKET_ERROR (-1)
  ------------------
  |  Branch (321:9): [True: 0, False: 0]
  ------------------
  322|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  323|      0|                    coap_socket_strerror());
  324|      0|    }
  325|      0|    coap_address_copy(remote_addr, &connect_addr);
  326|      0|    coap_address_copy(&sock->mcast_addr, &connect_addr);
  327|      0|    sock->flags |= COAP_SOCKET_MULTICAST;
  ------------------
  |  |   86|      0|#define COAP_SOCKET_MULTICAST    0x1000  /**< socket is used for multicast communication */
  ------------------
  328|      0|    if (coap_is_bcast(server) &&
  ------------------
  |  Branch (328:9): [True: 0, False: 0]
  ------------------
  329|      0|        setsockopt(sock->fd, SOL_SOCKET, SO_BROADCAST, OPTVAL_T(&on),
  ------------------
  |  |   34|      0|# define OPTVAL_T(t)         (t)
  ------------------
  |  Branch (329:9): [True: 0, False: 0]
  ------------------
  330|      0|                   sizeof(on)) == COAP_SOCKET_ERROR)
  ------------------
  |  |   51|      0|#define COAP_SOCKET_ERROR (-1)
  ------------------
  331|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  332|      0|                    coap_socket_strerror());
  333|      0|    return 1;
  334|      0|  }
  335|       |
  336|     62|  switch (connect_addr.addr.sa.sa_family) {
  337|      0|#if COAP_AF_LLC_SUPPORT
  338|       |  /* Only SOCK_STREAM type AF_LLC sockets can be connect()ed. */
  339|      0|  case AF_LLC:
  ------------------
  |  Branch (339:3): [True: 0, False: 62]
  ------------------
  340|      0|    break;
  341|      0|#endif /* COAP_AF_LLC_SUPPORT */
  342|      0|#if COAP_AF_UNIX_SUPPORT
  343|      0|  case AF_UNIX:
  ------------------
  |  Branch (343:3): [True: 0, False: 62]
  ------------------
  344|      0|#endif /* COAP_AF_UNIX_SUPPORT */
  345|     62|  default:
  ------------------
  |  Branch (345:3): [True: 62, False: 0]
  ------------------
  346|     62|    if (connect(sock->fd, &connect_addr.addr.sa, connect_addr.size) == COAP_SOCKET_ERROR) {
  ------------------
  |  |   51|     62|#define COAP_SOCKET_ERROR (-1)
  ------------------
  |  Branch (346:9): [True: 0, False: 62]
  ------------------
  347|      0|#if COAP_AF_UNIX_SUPPORT
  348|      0|      if (connect_addr.addr.sa.sa_family == AF_UNIX) {
  ------------------
  |  Branch (348:11): [True: 0, False: 0]
  ------------------
  349|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  350|      0|                      connect_addr.addr.cun.sun_path, coap_socket_strerror());
  351|      0|      } else
  352|      0|#endif /* COAP_AF_UNIX_SUPPORT */
  353|      0|      {
  354|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  355|      0|                      coap_socket_strerror(), connect_addr.addr.sa.sa_family);
  356|      0|      }
  357|      0|      goto error;
  358|      0|    }
  359|       |
  360|     62|    if (getpeername(sock->fd, &remote_addr->addr.sa, &remote_addr->size) == COAP_SOCKET_ERROR) {
  ------------------
  |  |   51|     62|#define COAP_SOCKET_ERROR (-1)
  ------------------
  |  Branch (360:9): [True: 0, False: 62]
  ------------------
  361|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  362|      0|                    coap_socket_strerror());
  363|      0|    }
  364|     62|    break;
  365|     62|  }
  366|       |
  367|     62|  if (getsockname(sock->fd, &local_addr->addr.sa, &local_addr->size) == COAP_SOCKET_ERROR) {
  ------------------
  |  |   51|     62|#define COAP_SOCKET_ERROR (-1)
  ------------------
  |  Branch (367:7): [True: 0, False: 62]
  ------------------
  368|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  369|      0|                  coap_socket_strerror());
  370|      0|  }
  371|       |
  372|     62|#if COAP_AF_LLC_SUPPORT
  373|       |  /* AF_LLC sockets send to the local address without an explicit destination. */
  374|     62|  if (coap_is_af_llc(&connect_addr))
  ------------------
  |  Branch (374:7): [True: 0, False: 62]
  ------------------
  375|      0|    sock->flags |= COAP_SOCKET_WANT_SENDTO;
  ------------------
  |  |   88|      0|#define COAP_SOCKET_WANT_SENDTO  0x4000  /**< socket requires a destination address for sending */
  ------------------
  376|     62|#endif /* COAP_AF_LLC_SUPPORT */
  377|       |
  378|     62|  sock->flags |= COAP_SOCKET_CONNECTED;
  ------------------
  |  |   77|     62|#define COAP_SOCKET_CONNECTED    0x0004  /**< the socket is connected */
  ------------------
  379|     62|  return 1;
  380|       |
  381|      0|error:
  382|      0|  coap_socket_dgrm_close(sock);
  383|      0|  return 0;
  384|     62|}
coap_socket_send:
  505|     19|                 const uint8_t *data, size_t datalen) {
  506|     19|  ssize_t bytes_written = 0;
  507|     19|  int r;
  508|       |
  509|     19|#if COAP_CLIENT_SUPPORT
  510|     19|  coap_test_cid_tuple_change(session);
  511|     19|#endif /* COAP_CLIENT_SUPPORT */
  512|       |
  513|     19|  if ((r = coap_debug_send_packet()) != 1) {
  ------------------
  |  Branch (513:7): [True: 19, False: 0]
  ------------------
  514|     19|    if (r)
  ------------------
  |  Branch (514:9): [True: 0, False: 19]
  ------------------
  515|      0|      bytes_written = -1;
  516|     19|    else
  517|     19|      bytes_written = (ssize_t)datalen;
  518|     19|  } else if (sock->flags & COAP_SOCKET_CONNECTED &&
  ------------------
  |  |   77|      0|#define COAP_SOCKET_CONNECTED    0x0004  /**< the socket is connected */
  ------------------
  |  Branch (518:14): [True: 0, False: 0]
  ------------------
  519|      0|             !(sock->flags & COAP_SOCKET_WANT_SENDTO)) {
  ------------------
  |  |   88|      0|#define COAP_SOCKET_WANT_SENDTO  0x4000  /**< socket requires a destination address for sending */
  ------------------
  |  Branch (519:14): [True: 0, False: 0]
  ------------------
  520|       |#ifdef _WIN32
  521|       |    bytes_written = send(sock->fd, (const char *)data, (int)datalen, 0);
  522|       |#else
  523|      0|    bytes_written = send(sock->fd, data, datalen, 0);
  524|      0|#endif
  525|      0|  } else {
  526|       |#if defined(_WIN32)
  527|       |    DWORD dwNumberOfBytesSent = 0;
  528|       |#endif /* _WIN32 */
  529|      0|#ifdef HAVE_STRUCT_CMSGHDR
  530|       |    /* a buffer large enough to hold all packet info types, ipv6 is the largest */
  531|      0|    char buf[CMSG_SPACE(sizeof(struct in6_pktinfo))];
  532|      0|    struct msghdr mhdr;
  533|      0|    struct iovec iov[1];
  534|      0|    const void *addr = &session->addr_info.remote.addr;
  535|       |
  536|      0|    assert(session);
  ------------------
  |  Branch (536:5): [True: 0, False: 0]
  ------------------
  537|       |
  538|      0|    memcpy(&iov[0].iov_base, &data, sizeof(iov[0].iov_base));
  539|      0|    iov[0].iov_len = (iov_len_t)datalen;
  540|       |
  541|      0|    memset(buf, 0, sizeof(buf));
  542|       |
  543|      0|    memset(&mhdr, 0, sizeof(struct msghdr));
  544|      0|    memcpy(&mhdr.msg_name, &addr, sizeof(mhdr.msg_name));
  545|      0|    mhdr.msg_namelen = session->addr_info.remote.addr.sa.sa_family == AF_INET ?
  ------------------
  |  Branch (545:24): [True: 0, False: 0]
  ------------------
  546|      0|                       (socklen_t)sizeof(struct sockaddr_in) :
  547|      0|                       session->addr_info.remote.size;
  548|       |
  549|      0|    mhdr.msg_iov = iov;
  550|      0|    mhdr.msg_iovlen = 1;
  551|       |
  552|      0|    if (!coap_address_isany(&session->addr_info.local) &&
  ------------------
  |  Branch (552:9): [True: 0, False: 0]
  ------------------
  553|      0|        !coap_is_mcast(&session->addr_info.local)) {
  ------------------
  |  Branch (553:9): [True: 0, False: 0]
  ------------------
  554|      0|      switch (session->addr_info.local.addr.sa.sa_family) {
  555|      0|#if COAP_IPV6_SUPPORT
  556|      0|      case AF_INET6: {
  ------------------
  |  Branch (556:7): [True: 0, False: 0]
  ------------------
  557|      0|        struct cmsghdr *cmsg;
  558|       |
  559|      0|#if COAP_IPV4_SUPPORT
  560|      0|        if (IN6_IS_ADDR_V4MAPPED(&session->addr_info.local.addr.sin6.sin6_addr)) {
  ------------------
  |  Branch (560:13): [True: 0, False: 0]
  ------------------
  561|      0|#if defined(IP_PKTINFO)
  562|      0|          struct in_pktinfo *pktinfo;
  563|      0|          mhdr.msg_control = buf;
  564|      0|          mhdr.msg_controllen = CMSG_SPACE(sizeof(struct in_pktinfo));
  565|       |
  566|      0|          cmsg = CMSG_FIRSTHDR(&mhdr);
  ------------------
  |  Branch (566:18): [True: 0, False: 0]
  ------------------
  567|      0|          cmsg->cmsg_level = COAP_SOL_IP;
  ------------------
  |  |  414|      0|#define COAP_SOL_IP SOL_IP
  ------------------
  568|      0|          cmsg->cmsg_type = IP_PKTINFO;
  569|      0|          cmsg->cmsg_len = CMSG_LEN(sizeof(struct in_pktinfo));
  570|       |
  571|      0|          pktinfo = (struct in_pktinfo *)CMSG_DATA(cmsg);
  572|       |
  573|      0|          pktinfo->ipi_ifindex = session->ifindex;
  574|      0|          memcpy(&pktinfo->ipi_spec_dst,
  575|      0|                 session->addr_info.local.addr.sin6.sin6_addr.s6_addr + 12,
  576|      0|                 sizeof(pktinfo->ipi_spec_dst));
  577|       |#elif defined(IP_SENDSRCADDR)
  578|       |          mhdr.msg_control = buf;
  579|       |          mhdr.msg_controllen = CMSG_SPACE(sizeof(struct in_addr));
  580|       |
  581|       |          cmsg = CMSG_FIRSTHDR(&mhdr);
  582|       |          cmsg->cmsg_level = IPPROTO_IP;
  583|       |          cmsg->cmsg_type = IP_SENDSRCADDR;
  584|       |          cmsg->cmsg_len = CMSG_LEN(sizeof(struct in_addr));
  585|       |
  586|       |          memcpy(CMSG_DATA(cmsg),
  587|       |                 session->addr_info.local.addr.sin6.sin6_addr.s6_addr + 12,
  588|       |                 sizeof(struct in_addr));
  589|       |#endif /* IP_PKTINFO */
  590|      0|        } else {
  591|      0|#endif /* COAP_IPV4_SUPPORT */
  592|      0|          struct in6_pktinfo *pktinfo;
  593|      0|          mhdr.msg_control = buf;
  594|      0|          mhdr.msg_controllen = CMSG_SPACE(sizeof(struct in6_pktinfo));
  595|       |
  596|      0|          cmsg = CMSG_FIRSTHDR(&mhdr);
  ------------------
  |  Branch (596:18): [True: 0, False: 0]
  ------------------
  597|      0|          cmsg->cmsg_level = IPPROTO_IPV6;
  598|      0|          cmsg->cmsg_type = IPV6_PKTINFO;
  599|      0|          cmsg->cmsg_len = CMSG_LEN(sizeof(struct in6_pktinfo));
  600|       |
  601|      0|          pktinfo = (struct in6_pktinfo *)CMSG_DATA(cmsg);
  602|       |
  603|      0|          if (coap_is_mcast(&session->addr_info.remote)) {
  ------------------
  |  Branch (603:15): [True: 0, False: 0]
  ------------------
  604|      0|            pktinfo->ipi6_ifindex = session->addr_info.remote.addr.sin6.sin6_scope_id;
  605|      0|          } else {
  606|      0|            pktinfo->ipi6_ifindex = session->ifindex;
  607|      0|          }
  608|      0|          memcpy(&pktinfo->ipi6_addr,
  609|      0|                 &session->addr_info.local.addr.sin6.sin6_addr,
  610|      0|                 sizeof(pktinfo->ipi6_addr));
  611|      0|#if COAP_IPV4_SUPPORT
  612|      0|        }
  613|      0|#endif /* COAP_IPV4_SUPPORT */
  614|      0|        break;
  615|      0|      }
  616|      0|#endif /* COAP_IPV6_SUPPORT */
  617|      0|#if COAP_IPV4_SUPPORT
  618|      0|      case AF_INET: {
  ------------------
  |  Branch (618:7): [True: 0, False: 0]
  ------------------
  619|      0|#if defined(IP_PKTINFO)
  620|      0|        struct cmsghdr *cmsg;
  621|      0|        struct in_pktinfo *pktinfo;
  622|       |
  623|      0|        mhdr.msg_control = buf;
  624|      0|        mhdr.msg_controllen = CMSG_SPACE(sizeof(struct in_pktinfo));
  625|       |
  626|      0|        cmsg = CMSG_FIRSTHDR(&mhdr);
  ------------------
  |  Branch (626:16): [True: 0, False: 0]
  ------------------
  627|      0|        cmsg->cmsg_level = COAP_SOL_IP;
  ------------------
  |  |  414|      0|#define COAP_SOL_IP SOL_IP
  ------------------
  628|      0|        cmsg->cmsg_type = IP_PKTINFO;
  629|      0|        cmsg->cmsg_len = CMSG_LEN(sizeof(struct in_pktinfo));
  630|       |
  631|      0|        pktinfo = (struct in_pktinfo *)CMSG_DATA(cmsg);
  632|       |
  633|      0|        pktinfo->ipi_ifindex = session->ifindex;
  634|      0|        memcpy(&pktinfo->ipi_spec_dst,
  635|      0|               &session->addr_info.local.addr.sin.sin_addr,
  636|      0|               sizeof(pktinfo->ipi_spec_dst));
  637|       |#elif defined(IP_SENDSRCADDR)
  638|       |        struct cmsghdr *cmsg;
  639|       |        mhdr.msg_control = buf;
  640|       |        mhdr.msg_controllen = CMSG_SPACE(sizeof(struct in_addr));
  641|       |
  642|       |        cmsg = CMSG_FIRSTHDR(&mhdr);
  643|       |        cmsg->cmsg_level = IPPROTO_IP;
  644|       |        cmsg->cmsg_type = IP_SENDSRCADDR;
  645|       |        cmsg->cmsg_len = CMSG_LEN(sizeof(struct in_addr));
  646|       |
  647|       |        memcpy(CMSG_DATA(cmsg),
  648|       |               &session->addr_info.local.addr.sin.sin_addr,
  649|       |               sizeof(struct in_addr));
  650|       |#endif /* IP_PKTINFO */
  651|      0|        break;
  652|      0|      }
  653|      0|#endif /* COAP_IPV4_SUPPORT */
  654|      0|#if COAP_AF_UNIX_SUPPORT
  655|      0|      case AF_UNIX:
  ------------------
  |  Branch (655:7): [True: 0, False: 0]
  ------------------
  656|      0|        break;
  657|      0|#endif /* COAP_AF_UNIX_SUPPORT */
  658|      0|#if COAP_AF_LLC_SUPPORT
  659|      0|      case AF_LLC:
  ------------------
  |  Branch (659:7): [True: 0, False: 0]
  ------------------
  660|      0|        break;
  661|      0|#endif /* COAP_AF_LLC_SUPPORT */
  662|      0|      default:
  ------------------
  |  Branch (662:7): [True: 0, False: 0]
  ------------------
  663|       |        /* error */
  664|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  665|      0|        return -1;
  666|      0|      }
  667|      0|    }
  668|      0|#endif /* HAVE_STRUCT_CMSGHDR */
  669|       |
  670|       |#if defined(_WIN32)
  671|       |    r = WSASendMsg(sock->fd, &mhdr, 0 /*dwFlags*/, &dwNumberOfBytesSent, NULL /*lpOverlapped*/,
  672|       |                   NULL /*lpCompletionRoutine*/);
  673|       |    if (r == 0)
  674|       |      bytes_written = (ssize_t)dwNumberOfBytesSent;
  675|       |    else {
  676|       |      bytes_written = -1;
  677|       |      coap_win_error_to_errno();
  678|       |    }
  679|       |#else /* !_WIN32 */
  680|      0|#ifdef HAVE_STRUCT_CMSGHDR
  681|      0|    bytes_written = sendmsg(sock->fd, &mhdr, 0);
  682|       |#else /* ! HAVE_STRUCT_CMSGHDR */
  683|       |    bytes_written = sendto(sock->fd, (const void *)data, datalen, 0,
  684|       |                           &session->addr_info.remote.addr.sa,
  685|       |                           session->addr_info.remote.size);
  686|       |#endif /* ! HAVE_STRUCT_CMSGHDR */
  687|      0|#endif /* !_WIN32 */
  688|      0|  }
  689|       |
  690|     19|  if (bytes_written < 0)
  ------------------
  |  Branch (690:7): [True: 0, False: 19]
  ------------------
  691|     19|    coap_log_warn("coap_socket_send: %s\n", coap_socket_strerror());
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  692|       |
  693|     19|  return bytes_written;
  694|     19|}
coap_socket_dgrm_close:
  925|     62|coap_socket_dgrm_close(coap_socket_t *sock) {
  926|     62|  if (sock->fd != COAP_INVALID_SOCKET && !(sock->flags & COAP_SOCKET_SLAVE)) {
  ------------------
  |  |   52|    124|#define COAP_INVALID_SOCKET (-1)
  ------------------
                if (sock->fd != COAP_INVALID_SOCKET && !(sock->flags & COAP_SOCKET_SLAVE)) {
  ------------------
  |  |   87|     62|#define COAP_SOCKET_SLAVE        0x2000  /**< socket is a slave socket - do not close */
  ------------------
  |  Branch (926:7): [True: 62, False: 0]
  |  Branch (926:42): [True: 62, False: 0]
  ------------------
  927|     62|#ifdef COAP_EPOLL_SUPPORT
  928|     62|#if COAP_SERVER_SUPPORT
  929|     62|    coap_context_t *context = sock->session ? sock->session->context :
  ------------------
  |  Branch (929:31): [True: 62, False: 0]
  ------------------
  930|     62|                              sock->endpoint ? sock->endpoint->context : NULL;
  ------------------
  |  Branch (930:31): [True: 0, False: 0]
  ------------------
  931|       |#else /* COAP_SERVER_SUPPORT */
  932|       |    coap_context_t *context = sock->session ? sock->session->context : NULL;
  933|       |#endif /* COAP_SERVER_SUPPORT */
  934|     62|    if (context != NULL) {
  ------------------
  |  Branch (934:9): [True: 62, False: 0]
  ------------------
  935|     62|      int ret;
  936|     62|      struct epoll_event event;
  937|       |
  938|       |      /* Kernels prior to 2.6.9 expect non NULL event parameter */
  939|     62|      ret = epoll_ctl(context->epfd, EPOLL_CTL_DEL, sock->fd, &event);
  940|     62|      if (ret == -1 && errno != ENOENT) {
  ------------------
  |  Branch (940:11): [True: 0, False: 62]
  |  Branch (940:24): [True: 0, False: 0]
  ------------------
  941|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  942|      0|                     "coap_socket_close",
  943|      0|                     sock->fd,
  944|      0|                     coap_socket_strerror(), errno);
  945|      0|      }
  946|     62|    }
  947|     62|#endif /* COAP_EPOLL_SUPPORT */
  948|     62|#if COAP_SERVER_SUPPORT
  949|     62|#if COAP_AF_UNIX_SUPPORT
  950|     62|    if (sock->endpoint &&
  ------------------
  |  Branch (950:9): [True: 0, False: 62]
  ------------------
  951|      0|        sock->endpoint->bind_addr.addr.sa.sa_family == AF_UNIX) {
  ------------------
  |  Branch (951:9): [True: 0, False: 0]
  ------------------
  952|       |      /* Clean up Unix endpoint */
  953|       |#ifdef _WIN32
  954|       |      _unlink(sock->endpoint->bind_addr.addr.cun.sun_path);
  955|       |#else /* ! _WIN32 */
  956|      0|      unlink(sock->endpoint->bind_addr.addr.cun.sun_path);
  957|      0|#endif /* ! _WIN32 */
  958|      0|    }
  959|     62|#endif /* COAP_AF_UNIX_SUPPORT */
  960|     62|    sock->endpoint = NULL;
  961|     62|#endif /* COAP_SERVER_SUPPORT */
  962|     62|#if COAP_CLIENT_SUPPORT
  963|     62|#if COAP_AF_UNIX_SUPPORT
  964|     62|    if (sock->session && sock->session->type == COAP_SESSION_TYPE_CLIENT &&
  ------------------
  |  Branch (964:9): [True: 62, False: 0]
  |  Branch (964:26): [True: 62, False: 0]
  ------------------
  965|     62|        sock->session->addr_info.local.addr.sa.sa_family == AF_UNIX) {
  ------------------
  |  Branch (965:9): [True: 0, False: 62]
  ------------------
  966|       |      /* Clean up Unix endpoint */
  967|       |#ifdef _WIN32
  968|       |      _unlink(sock->session->addr_info.local.addr.cun.sun_path);
  969|       |#else /* ! _WIN32 */
  970|      0|      unlink(sock->session->addr_info.local.addr.cun.sun_path);
  971|      0|#endif /* ! _WIN32 */
  972|      0|    }
  973|     62|#endif /* COAP_AF_UNIX_SUPPORT */
  974|     62|#endif /* COAP_CLIENT_SUPPORT */
  975|     62|    sock->session = NULL;
  976|     62|    coap_closesocket(sock->fd);
  ------------------
  |  |   50|     62|#define coap_closesocket close
  ------------------
  977|     62|    sock->fd = COAP_INVALID_SOCKET;
  ------------------
  |  |   52|     62|#define COAP_INVALID_SOCKET (-1)
  ------------------
  978|     62|    sock->flags = COAP_SOCKET_EMPTY;
  ------------------
  |  |   74|     62|#define COAP_SOCKET_EMPTY        0x0000  /**< the socket is not used */
  ------------------
  979|     62|  }
  980|     62|}
coap_dgrm_posix.c:coap_test_cid_tuple_change:
  463|     19|coap_test_cid_tuple_change(coap_session_t *session) {
  464|     19|  if (session->type == COAP_SESSION_TYPE_CLIENT &&
  ------------------
  |  Branch (464:7): [True: 19, False: 0]
  ------------------
  465|     19|      session->negotiated_cid &&
  ------------------
  |  Branch (465:7): [True: 0, False: 19]
  ------------------
  466|      0|      session->state == COAP_SESSION_STATE_ESTABLISHED &&
  ------------------
  |  Branch (466:7): [True: 0, False: 0]
  ------------------
  467|      0|      session->proto == COAP_PROTO_DTLS && session->context->testing_cids) {
  ------------------
  |  Branch (467:7): [True: 0, False: 0]
  |  Branch (467:44): [True: 0, False: 0]
  ------------------
  468|      0|    if ((++cid_track_counter) % session->context->testing_cids == 0) {
  ------------------
  |  Branch (468:9): [True: 0, False: 0]
  ------------------
  469|      0|      coap_address_t local_if = session->addr_info.local;
  470|      0|      uint16_t port = coap_address_get_port(&local_if);
  471|       |
  472|      0|      port++;
  473|      0|      coap_address_set_port(&local_if, port);
  474|       |
  475|      0|      coap_socket_dgrm_close(&session->sock);
  476|      0|      session->sock.session = session;
  477|      0|      if (!coap_socket_connect_udp(&session->sock, &local_if, &session->addr_info.remote,
  ------------------
  |  Branch (477:11): [True: 0, False: 0]
  ------------------
  478|      0|                                   port,
  479|      0|                                   &session->addr_info.local,
  480|      0|                                   &session->addr_info.remote)) {
  481|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  482|      0|        return;
  483|      0|#ifdef COAP_EPOLL_SUPPORT
  484|      0|      } else {
  485|      0|        coap_epoll_ctl_add(&session->sock,
  486|      0|                           EPOLLIN |
  487|      0|                           ((session->sock.flags & COAP_SOCKET_WANT_CONNECT) ?
  ------------------
  |  |   81|      0|#define COAP_SOCKET_WANT_CONNECT 0x0080  /**< non blocking client socket is waiting for connect */
  ------------------
  |  Branch (487:29): [True: 0, False: 0]
  ------------------
  488|      0|                            EPOLLOUT : 0),
  489|      0|                           __func__);
  490|      0|#endif /* COAP_EPOLL_SUPPORT */
  491|      0|      }
  492|      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;
  ------------------
  |  |   78|      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 */
  ------------------
  493|      0|    }
  494|      0|  }
  495|     19|}

coap_fls:
   21|     76|coap_fls(unsigned int i) {
   22|     76|  return coap_flsll(i);
   23|     76|}
coap_flsll:
   28|     76|coap_flsll(long long j) {
   29|     76|  unsigned long long i = (unsigned long long)j;
   30|     76|  int n;
   31|    684|  for (n = 0; i; n++)
  ------------------
  |  Branch (31:15): [True: 608, False: 76]
  ------------------
   32|    608|    i >>= 1;
   33|     76|  return n;
   34|     76|}
coap_encode_var_safe8:
   81|     26|coap_encode_var_safe8(uint8_t *buf, size_t length, uint64_t val) {
   82|     26|  unsigned int n, i;
   83|     26|  uint64_t tval = val;
   84|       |
   85|     26|  if (val == 0)
  ------------------
  |  Branch (85:7): [True: 0, False: 26]
  ------------------
   86|      0|    return 0;
   87|       |
   88|     52|  for (n = 0; tval && n < sizeof(val); ++n)
  ------------------
  |  Branch (88:15): [True: 26, False: 26]
  |  Branch (88:23): [True: 26, False: 0]
  ------------------
   89|     26|    tval >>= 8;
   90|       |
   91|     26|  if (n > length) {
  ------------------
  |  Branch (91:7): [True: 0, False: 26]
  ------------------
   92|      0|    assert(n <= length);
  ------------------
  |  Branch (92:5): [True: 0, False: 0]
  ------------------
   93|      0|    return 0;
   94|      0|  }
   95|     26|  i = n;
   96|     52|  while (i) {
  ------------------
  |  Branch (96:10): [True: 26, False: 26]
  ------------------
   97|     26|    i--;
   98|     26|    buf[i] = val & 0xff;
   99|     26|    val >>= 8;
  100|     26|  }
  101|       |
  102|     26|  return n;
  103|     26|}

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

coap_update_io_timer:
   70|     11|coap_update_io_timer(coap_context_t *context, coap_tick_t delay) {
   71|     11|#if COAP_EPOLL_SUPPORT
   72|     11|  if (context->eptimerfd != -1) {
  ------------------
  |  Branch (72:7): [True: 11, False: 0]
  ------------------
   73|     11|    coap_tick_t now;
   74|       |
   75|     11|    coap_ticks(&now);
   76|     11|    if (context->next_timeout == 0 || context->next_timeout > now + delay) {
  ------------------
  |  Branch (76:9): [True: 11, False: 0]
  |  Branch (76:39): [True: 0, False: 0]
  ------------------
   77|     11|      struct itimerspec new_value;
   78|     11|      int ret;
   79|       |
   80|     11|      context->next_timeout = now + delay;
   81|     11|      memset(&new_value, 0, sizeof(new_value));
   82|     11|      if (delay == 0) {
  ------------------
  |  Branch (82:11): [True: 0, False: 11]
  ------------------
   83|      0|        new_value.it_value.tv_nsec = 1; /* small but not zero */
   84|     11|      } else {
   85|     11|        new_value.it_value.tv_sec = delay / COAP_TICKS_PER_SECOND;
  ------------------
  |  |  164|     11|#define COAP_TICKS_PER_SECOND ((coap_tick_t)(1000U))
  ------------------
   86|     11|        new_value.it_value.tv_nsec = (delay % COAP_TICKS_PER_SECOND) *
  ------------------
  |  |  164|     11|#define COAP_TICKS_PER_SECOND ((coap_tick_t)(1000U))
  ------------------
   87|     11|                                     1000000;
   88|     11|      }
   89|     11|      ret = timerfd_settime(context->eptimerfd, 0, &new_value, NULL);
   90|     11|      if (ret == -1) {
  ------------------
  |  Branch (90:11): [True: 0, False: 11]
  ------------------
   91|      0|        coap_log_err("%s: timerfd_settime 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   92|      0|                     "coap_update_io_timer",
   93|      0|                     coap_socket_strerror(), errno);
   94|      0|      }
   95|       |#ifdef COAP_DEBUG_WAKEUP_TIMES
   96|       |      else {
   97|       |        coap_log_debug("****** Next wakeup time %3ld.%09ld\n",
   98|       |                       new_value.it_value.tv_sec, new_value.it_value.tv_nsec);
   99|       |      }
  100|       |#endif /* COAP_DEBUG_WAKEUP_TIMES */
  101|     11|    }
  102|     11|  }
  103|       |#else /* ! COAP_EPOLL_SUPPORT */
  104|       |  coap_tick_t now;
  105|       |
  106|       |  coap_ticks(&now);
  107|       |  if (context->next_timeout == 0 || context->next_timeout > now + delay) {
  108|       |    context->next_timeout = now + delay;
  109|       |  }
  110|       |#endif /* ! COAP_EPOLL_SUPPORT */
  111|     11|}

coap_epoll_ctl_add:
   62|     62|                   const char *func) {
   63|     62|  int ret;
   64|     62|  struct epoll_event event;
   65|     62|  coap_context_t *context;
   66|       |
   67|       |#if COAP_MAX_LOGGING_LEVEL < _COAP_LOG_ERR
   68|       |  (void)func;
   69|       |#endif
   70|       |
   71|     62|  if (sock == NULL)
  ------------------
  |  Branch (71:7): [True: 0, False: 62]
  ------------------
   72|      0|    return;
   73|       |
   74|     62|#if COAP_SERVER_SUPPORT
   75|     62|  context = sock->session ? sock->session->context :
  ------------------
  |  Branch (75:13): [True: 62, False: 0]
  ------------------
   76|     62|            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|     62|  if (context == NULL)
  ------------------
  |  Branch (80:7): [True: 0, False: 62]
  ------------------
   81|      0|    return;
   82|       |
   83|       |  /* Needed if running 32bit as ptr is only 32bit */
   84|     62|  memset(&event, 0, sizeof(event));
   85|     62|  event.events = events;
   86|     62|  event.data.ptr = sock;
   87|       |
   88|     62|  ret = epoll_ctl(context->epfd, EPOLL_CTL_ADD, sock->fd, &event);
   89|     62|  if (ret == -1) {
  ------------------
  |  Branch (89:7): [True: 0, False: 62]
  ------------------
   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|     62|}

coap_memory_init:
  554|     36|coap_memory_init(void) {
  555|     36|}
coap_malloc_type:
  558|    612|coap_malloc_type(coap_memory_tag_t type, size_t size) {
  559|    612|  void *ptr;
  560|       |
  561|    612|  (void)type;
  562|    612|  ptr = malloc(size);
  563|       |#if COAP_MEMORY_TYPE_TRACK
  564|       |  assert(type < COAP_MEM_TAG_LAST);
  565|       |  if (ptr) {
  566|       |    track_counts[type]++;
  567|       |    if (track_counts[type] > peak_counts[type])
  568|       |      peak_counts[type] = track_counts[type];
  569|       |  } else {
  570|       |    fail_counts[type]++;
  571|       |  }
  572|       |#endif /* COAP_MEMORY_TYPE_TRACK */
  573|    612|  return ptr;
  574|    612|}
coap_realloc_type:
  577|     26|coap_realloc_type(coap_memory_tag_t type, void *p, size_t size) {
  578|     26|  void *ptr;
  579|       |
  580|     26|  (void)type;
  581|     26|  ptr = realloc(p, size);
  582|       |#if COAP_MEMORY_TYPE_TRACK
  583|       |  if (ptr) {
  584|       |    assert(type < COAP_MEM_TAG_LAST);
  585|       |    if (!p)
  586|       |      track_counts[type]++;
  587|       |    if (track_counts[type] > peak_counts[type])
  588|       |      peak_counts[type] = track_counts[type];
  589|       |  } else {
  590|       |    fail_counts[type]++;
  591|       |  }
  592|       |#endif /* COAP_MEMORY_TYPE_TRACK */
  593|     26|  return ptr;
  594|     26|}
coap_free_type:
  597|  1.34k|coap_free_type(coap_memory_tag_t type, void *p) {
  598|  1.34k|  (void)type;
  599|       |#if COAP_MEMORY_TYPE_TRACK
  600|       |  assert(type < COAP_MEM_TAG_LAST);
  601|       |  if (p)
  602|       |    track_counts[type]--;
  603|       |#endif /* COAP_MEMORY_TYPE_TRACK */
  604|  1.34k|  free(p);
  605|  1.34k|}
coap_dump_memory_type_counts:
  666|     36|coap_dump_memory_type_counts(coap_log_t level) {
  667|       |#if COAP_MEMORY_TYPE_TRACK
  668|       |  int i;
  669|       |
  670|       |  coap_log(level, "*  Memory type counts\n");
  671|       |  for (i = 0; i < COAP_MEM_TAG_LAST; i++) {
  672|       |    const char *name = "?";
  673|       |
  674|       |
  675|       |    switch (i) {
  676|       |      MAKE_CASE(COAP_STRING);
  677|       |      MAKE_CASE(COAP_ATTRIBUTE_NAME);
  678|       |      MAKE_CASE(COAP_ATTRIBUTE_VALUE);
  679|       |      MAKE_CASE(COAP_PACKET);
  680|       |      MAKE_CASE(COAP_NODE);
  681|       |      MAKE_CASE(COAP_CONTEXT);
  682|       |      MAKE_CASE(COAP_ENDPOINT);
  683|       |      MAKE_CASE(COAP_PDU);
  684|       |      MAKE_CASE(COAP_PDU_BUF);
  685|       |      MAKE_CASE(COAP_RESOURCE);
  686|       |      MAKE_CASE(COAP_RESOURCEATTR);
  687|       |      MAKE_CASE(COAP_DTLS_SESSION);
  688|       |      MAKE_CASE(COAP_SESSION);
  689|       |      MAKE_CASE(COAP_OPTLIST);
  690|       |      MAKE_CASE(COAP_CACHE_KEY);
  691|       |      MAKE_CASE(COAP_CACHE_ENTRY);
  692|       |      MAKE_CASE(COAP_LG_XMIT);
  693|       |      MAKE_CASE(COAP_LG_CRCV);
  694|       |      MAKE_CASE(COAP_LG_SRCV);
  695|       |      MAKE_CASE(COAP_DIGEST_CTX);
  696|       |      MAKE_CASE(COAP_SUBSCRIPTION);
  697|       |      MAKE_CASE(COAP_DTLS_CONTEXT);
  698|       |      MAKE_CASE(COAP_OSCORE_COM);
  699|       |      MAKE_CASE(COAP_OSCORE_SEN);
  700|       |      MAKE_CASE(COAP_OSCORE_REC);
  701|       |      MAKE_CASE(COAP_OSCORE_EX);
  702|       |      MAKE_CASE(COAP_OSCORE_EP);
  703|       |      MAKE_CASE(COAP_OSCORE_BUF);
  704|       |      MAKE_CASE(COAP_COSE);
  705|       |    case COAP_MEM_TAG_LAST:
  706|       |    default:
  707|       |      break;
  708|       |    }
  709|       |    coap_log(level, "*    %-20s in-use %3d peak %3d failed %2d\n",
  710|       |             name, track_counts[i], peak_counts[i], fail_counts[i]);
  711|       |  }
  712|       |#else /* COAP_MEMORY_TYPE_TRACK */
  713|     36|  (void)level;
  714|     36|#endif /* COAP_MEMORY_TYPE_TRACK */
  715|     36|}

coap_insert_node:
  160|     11|coap_insert_node(coap_queue_t **queue, coap_queue_t *node) {
  161|     11|  coap_queue_t *p, *q;
  162|     11|  if (!queue || !node)
  ------------------
  |  Branch (162:7): [True: 0, False: 11]
  |  Branch (162:17): [True: 0, False: 11]
  ------------------
  163|      0|    return 0;
  164|       |
  165|       |  /* set queue head if empty */
  166|     11|  if (!*queue) {
  ------------------
  |  Branch (166:7): [True: 11, False: 0]
  ------------------
  167|     11|    *queue = node;
  168|     11|    return 1;
  169|     11|  }
  170|       |
  171|       |  /* replace queue head if PDU's time is less than head's time */
  172|      0|  q = *queue;
  173|      0|  if (node->t < q->t) {
  ------------------
  |  Branch (173:7): [True: 0, False: 0]
  ------------------
  174|      0|    node->next = q;
  175|      0|    *queue = node;
  176|      0|    q->t -= node->t;                /* make q->t relative to node->t */
  177|      0|    return 1;
  178|      0|  }
  179|       |
  180|       |  /* search for right place to insert */
  181|      0|  do {
  182|      0|    node->t -= q->t;                /* make node-> relative to q->t */
  183|      0|    p = q;
  184|      0|    q = q->next;
  185|      0|  } while (q && q->t <= node->t);
  ------------------
  |  Branch (185:12): [True: 0, False: 0]
  |  Branch (185:17): [True: 0, False: 0]
  ------------------
  186|       |
  187|       |  /* insert new item */
  188|      0|  if (q) {
  ------------------
  |  Branch (188:7): [True: 0, False: 0]
  ------------------
  189|      0|    q->t -= node->t;                /* make q->t relative to node->t */
  190|      0|  }
  191|      0|  node->next = q;
  192|      0|  p->next = node;
  193|      0|  return 1;
  194|      0|}
coap_delete_node_lkd:
  210|     11|coap_delete_node_lkd(coap_queue_t *node) {
  211|     11|  if (!node)
  ------------------
  |  Branch (211:7): [True: 0, False: 11]
  ------------------
  212|      0|    return 0;
  213|       |
  214|     11|  coap_delete_pdu_lkd(node->pdu);
  215|     11|  if (node->session) {
  ------------------
  |  Branch (215:7): [True: 11, False: 0]
  ------------------
  216|       |    /*
  217|       |     * Need to remove out of context->sendqueue as added in by coap_wait_ack()
  218|       |     */
  219|     11|    if (node->session->context->sendqueue) {
  ------------------
  |  Branch (219:9): [True: 11, False: 0]
  ------------------
  220|     11|      LL_DELETE(node->session->context->sendqueue, node);
  ------------------
  |  |  391|     11|    LL_DELETE2(head,del,next)
  |  |  ------------------
  |  |  |  |  393|     11|#define LL_DELETE2(head,del,next)                                                              \
  |  |  |  |  394|     11|do {                                                                                           \
  |  |  |  |  395|     11|  LDECLTYPE(head) _tmp;                                                                        \
  |  |  |  |  ------------------
  |  |  |  |  |  |   81|     11|#define LDECLTYPE(x) __typeof(x)
  |  |  |  |  ------------------
  |  |  |  |  396|     11|  if ((head) == (del)) {                                                                       \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (396:7): [True: 11, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  397|     11|    (head)=(head)->next;                                                                       \
  |  |  |  |  398|     11|  } 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|     11|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (407:10): [Folded, False: 11]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  221|     11|    }
  222|     11|    coap_session_release_lkd(node->session);
  223|     11|  }
  224|     11|  coap_free_node(node);
  225|       |
  226|     11|  return 1;
  227|     11|}
coap_delete_all:
  230|     47|coap_delete_all(coap_queue_t *queue) {
  231|     47|  if (!queue)
  ------------------
  |  Branch (231:7): [True: 36, False: 11]
  ------------------
  232|     36|    return;
  233|       |
  234|     11|  coap_delete_all(queue->next);
  235|     11|  coap_delete_node_lkd(queue);
  236|     11|}
coap_new_node:
  239|     11|coap_new_node(void) {
  240|     11|  coap_queue_t *node;
  241|     11|  node = coap_malloc_node();
  242|       |
  243|     11|  if (!node) {
  ------------------
  |  Branch (243:7): [True: 0, False: 11]
  ------------------
  244|      0|    coap_log_warn("coap_new_node: malloc 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  245|      0|    return NULL;
  246|      0|  }
  247|       |
  248|     11|  memset(node, 0, sizeof(*node));
  249|     11|  return node;
  250|     11|}
coap_new_context:
  724|     36|coap_new_context(const coap_address_t *listen_addr) {
  725|     36|  coap_context_t *c;
  726|       |
  727|       |#if ! COAP_SERVER_SUPPORT
  728|       |  (void)listen_addr;
  729|       |#endif /* COAP_SERVER_SUPPORT */
  730|       |
  731|     36|  if (!coap_started) {
  ------------------
  |  Branch (731:7): [True: 0, False: 36]
  ------------------
  732|      0|    coap_startup();
  733|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  734|      0|                  "coap_*() functions are called\n");
  735|      0|  }
  736|       |
  737|     36|  c = coap_malloc_type(COAP_CONTEXT, sizeof(coap_context_t));
  738|     36|  if (!c) {
  ------------------
  |  Branch (738:7): [True: 0, False: 36]
  ------------------
  739|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  740|      0|    return NULL;
  741|      0|  }
  742|     36|  memset(c, 0, sizeof(coap_context_t));
  743|       |
  744|     36|  coap_lock_lock(coap_free_type(COAP_CONTEXT, c); return NULL);
  745|     36|#ifdef COAP_EPOLL_SUPPORT
  746|     36|  c->epfd = epoll_create1(0);
  747|     36|  if (c->epfd == -1) {
  ------------------
  |  Branch (747:7): [True: 0, False: 36]
  ------------------
  748|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  749|      0|                 coap_socket_strerror(),
  750|      0|                 errno);
  751|      0|    goto onerror;
  752|      0|  }
  753|     36|  if (c->epfd != -1) {
  ------------------
  |  Branch (753:7): [True: 36, False: 0]
  ------------------
  754|     36|    c->eptimerfd = timerfd_create(CLOCK_REALTIME, TFD_NONBLOCK);
  755|     36|    if (c->eptimerfd == -1) {
  ------------------
  |  Branch (755:9): [True: 0, False: 36]
  ------------------
  756|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  757|      0|                   coap_socket_strerror(),
  758|      0|                   errno);
  759|      0|      goto onerror;
  760|     36|    } else {
  761|     36|      int ret;
  762|     36|      struct epoll_event event;
  763|       |
  764|       |      /* Needed if running 32bit as ptr is only 32bit */
  765|     36|      memset(&event, 0, sizeof(event));
  766|     36|      event.events = EPOLLIN;
  767|       |      /* We special case this event by setting to NULL */
  768|     36|      event.data.ptr = NULL;
  769|       |
  770|     36|      ret = epoll_ctl(c->epfd, EPOLL_CTL_ADD, c->eptimerfd, &event);
  771|     36|      if (ret == -1) {
  ------------------
  |  Branch (771:11): [True: 0, False: 36]
  ------------------
  772|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  773|      0|                     "coap_new_context",
  774|      0|                     coap_socket_strerror(), errno);
  775|      0|        goto onerror;
  776|      0|      }
  777|     36|    }
  778|     36|  }
  779|     36|#endif /* COAP_EPOLL_SUPPORT */
  780|       |
  781|     36|  if (coap_dtls_is_supported() || coap_tls_is_supported()) {
  ------------------
  |  Branch (781:7): [True: 36, False: 0]
  |  Branch (781:35): [True: 0, False: 0]
  ------------------
  782|     36|    c->dtls_context = coap_dtls_new_context(c);
  783|     36|    if (!c->dtls_context) {
  ------------------
  |  Branch (783:9): [True: 0, False: 36]
  ------------------
  784|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  785|      0|      goto onerror;
  786|      0|    }
  787|     36|  }
  788|       |
  789|       |  /* set default CSM values */
  790|     36|  c->csm_timeout_ms = 1000;
  791|     36|  c->csm_max_message_size = COAP_DEFAULT_MAX_PDU_RX_SIZE;
  ------------------
  |  |   84|     36|#define COAP_DEFAULT_MAX_PDU_RX_SIZE (8UL*1024*1024+256)
  ------------------
  792|       |
  793|     36|#if COAP_SERVER_SUPPORT
  794|     36|  if (listen_addr) {
  ------------------
  |  Branch (794:7): [True: 0, False: 36]
  ------------------
  795|      0|    coap_endpoint_t *endpoint = coap_new_endpoint_lkd(c, listen_addr, COAP_PROTO_UDP);
  796|      0|    if (endpoint == NULL) {
  ------------------
  |  Branch (796:9): [True: 0, False: 0]
  ------------------
  797|      0|      goto onerror;
  798|      0|    }
  799|      0|  }
  800|     36|#endif /* COAP_SERVER_SUPPORT */
  801|       |
  802|     36|  c->max_token_size = COAP_TOKEN_DEFAULT_MAX; /* RFC8974 */
  ------------------
  |  |   58|     36|#define COAP_TOKEN_DEFAULT_MAX 8
  ------------------
  803|       |
  804|       |#if defined(WITH_LWIP)
  805|       |#if NO_SYS == 0
  806|       |  if (sys_sem_new(&c->coap_io_timeout_sem, 0) != ERR_OK)
  807|       |    coap_log_warn("coap_new_context: Failed to set up semaphore\n");
  808|       |#endif /* NO_SYS == 0 */
  809|       |#endif /* ! WITH_LWIP */
  810|     36|  coap_lock_unlock();
  811|     36|  return c;
  812|       |
  813|      0|onerror:
  814|      0|  coap_lock_unlock();
  815|      0|  coap_free_type(COAP_CONTEXT, c);
  816|       |  return NULL;
  817|     36|}
coap_free_context:
  834|     36|coap_free_context(coap_context_t *context) {
  835|     36|  if (!context)
  ------------------
  |  Branch (835:7): [True: 0, False: 36]
  ------------------
  836|      0|    return;
  837|     36|  coap_lock_lock(return);
  838|     36|  coap_free_context_lkd(context);
  839|     36|  coap_lock_unlock();
  840|     36|}
coap_free_context_lkd:
  843|     36|coap_free_context_lkd(coap_context_t *context) {
  844|     36|  if (!context)
  ------------------
  |  Branch (844:7): [True: 0, False: 36]
  ------------------
  845|      0|    return;
  846|       |
  847|     36|  coap_lock_check_locked();
  ------------------
  |  |  638|     36|#define coap_lock_check_locked() {}
  ------------------
  848|     36|#if COAP_SERVER_SUPPORT
  849|       |  /* Removing a resource may cause a NON unsolicited observe to be sent */
  850|     36|  context->context_going_away = 1;
  851|     36|  if (context->shutdown_no_send_observe)
  ------------------
  |  Branch (851:7): [True: 0, False: 36]
  ------------------
  852|      0|    context->observe_no_clear = 1;
  853|     36|  coap_delete_all_resources(context);
  854|     36|#endif /* COAP_SERVER_SUPPORT */
  855|     36|#if COAP_CLIENT_SUPPORT
  856|       |  /* Stop any attempts at reconnection */
  857|     36|  context->reconnect_time = 0;
  858|     36|#endif /* COAP_CLIENT_SUPPORT */
  859|       |
  860|     36|  coap_delete_all(context->sendqueue);
  861|     36|  context->sendqueue = NULL;
  862|       |
  863|       |#ifdef WITH_LWIP
  864|       |  if (context->timer_configured) {
  865|       |    LOCK_TCPIP_CORE();
  866|       |    sys_untimeout(coap_io_process_timeout, (void *)context);
  867|       |    UNLOCK_TCPIP_CORE();
  868|       |    context->timer_configured = 0;
  869|       |  }
  870|       |#endif /* WITH_LWIP */
  871|       |
  872|     36|#if COAP_ASYNC_SUPPORT
  873|     36|  coap_delete_all_async(context);
  874|     36|#endif /* COAP_ASYNC_SUPPORT */
  875|       |
  876|     36|#if COAP_SERVER_SUPPORT
  877|     36|  coap_cache_entry_t *cp, *ctmp;
  878|     36|  coap_endpoint_t *ep, *tmp;
  879|       |
  880|     36|  HASH_ITER(hh, context->cache, cp, ctmp) {
  ------------------
  |  | 1071|     36|#define HASH_ITER(hh,head,el,tmp)                                                \
  |  | 1072|     36|for(((el)=(head)), ((tmp)=DECLTYPE(el)((head!=NULL)?(head)->hh.next:NULL));      \
  |  |  ------------------
  |  |  |  |   66|     36|#define DECLTYPE(x) (__typeof(x))
  |  |  ------------------
  |  |  |  Branch (1072:40): [True: 0, False: 36]
  |  |  ------------------
  |  | 1073|     36|  (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: 36]
  |  |  |  Branch (1073:51): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  881|      0|    coap_delete_cache_entry(context, cp);
  882|      0|  }
  883|     36|  if (context->cache_ignore_count) {
  ------------------
  |  Branch (883:7): [True: 0, False: 36]
  ------------------
  884|      0|    coap_free_type(COAP_STRING, context->cache_ignore_options);
  885|      0|  }
  886|       |
  887|     36|  LL_FOREACH_SAFE(context->endpoint, ep, tmp) {
  ------------------
  |  |  425|     36|    LL_FOREACH_SAFE2(head,el,tmp,next)
  |  |  ------------------
  |  |  |  |  428|     36|  for ((el) = (head); (el) && ((tmp) = (el)->next, 1); (el) = (tmp))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (428:23): [True: 0, False: 36]
  |  |  |  |  |  Branch (428:31): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  888|      0|    coap_free_endpoint_lkd(ep);
  889|      0|  }
  890|     36|#endif /* COAP_SERVER_SUPPORT */
  891|       |
  892|     36|#if COAP_CLIENT_SUPPORT
  893|     36|  coap_session_t *sp, *rtmp;
  894|       |
  895|     62|  SESSIONS_ITER_SAFE(context->sessions, sp, rtmp) {
  ------------------
  |  |  945|     98|  for ((el) = (e); (el) && ((rtmp) = (el)->hh.next, 1); (el) = (rtmp))
  |  |  ------------------
  |  |  |  Branch (945:20): [True: 62, False: 36]
  |  |  |  Branch (945:28): [True: 62, False: 0]
  |  |  ------------------
  ------------------
  896|     62|    coap_session_release_lkd(sp);
  897|     62|  }
  898|     36|#endif /* COAP_CLIENT_SUPPORT */
  899|       |
  900|     36|#if COAP_OSCORE_SUPPORT
  901|     36|  coap_delete_all_oscore(context);
  902|     36|#endif /* COAP_OSCORE_SUPPORT */
  903|       |
  904|     36|  if (context->dtls_context)
  ------------------
  |  Branch (904:7): [True: 36, False: 0]
  ------------------
  905|     36|    coap_dtls_free_context(context->dtls_context);
  906|     36|#ifdef COAP_EPOLL_SUPPORT
  907|     36|  if (context->eptimerfd != -1) {
  ------------------
  |  Branch (907:7): [True: 36, False: 0]
  ------------------
  908|     36|    int ret;
  909|     36|    struct epoll_event event;
  910|       |
  911|       |    /* Kernels prior to 2.6.9 expect non NULL event parameter */
  912|     36|    ret = epoll_ctl(context->epfd, EPOLL_CTL_DEL, context->eptimerfd, &event);
  913|     36|    if (ret == -1) {
  ------------------
  |  Branch (913:9): [True: 0, False: 36]
  ------------------
  914|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  915|      0|                   "coap_free_context",
  916|      0|                   coap_socket_strerror(), errno);
  917|      0|    }
  918|     36|    close(context->eptimerfd);
  919|     36|    context->eptimerfd = -1;
  920|     36|  }
  921|     36|  if (context->epfd != -1) {
  ------------------
  |  Branch (921:7): [True: 36, False: 0]
  ------------------
  922|     36|    close(context->epfd);
  923|     36|    context->epfd = -1;
  924|     36|  }
  925|     36|#endif /* COAP_EPOLL_SUPPORT */
  926|     36|#if COAP_SERVER_SUPPORT
  927|     36|#if COAP_WITH_OBSERVE_PERSIST
  928|     36|  coap_persist_cleanup(context);
  929|     36|#endif /* COAP_WITH_OBSERVE_PERSIST */
  930|     36|#endif /* COAP_SERVER_SUPPORT */
  931|     36|#if COAP_PROXY_SUPPORT
  932|     36|  coap_proxy_cleanup(context);
  933|     36|#endif /* COAP_PROXY_SUPPORT */
  934|       |
  935|     36|  if (context->app_cb) {
  ------------------
  |  Branch (935:7): [True: 0, False: 36]
  ------------------
  936|      0|    coap_lock_callback(context->app_cb(context->app_data));
  ------------------
  |  |  651|      0|#define coap_lock_callback(func) func
  ------------------
  937|      0|  }
  938|       |#if defined(WITH_LWIP)
  939|       |#if NO_SYS == 0
  940|       |  sys_sem_free(&context->coap_io_timeout_sem);
  941|       |#endif /* NO_SYS == 0 */
  942|       |#endif /* ! WITH_LWIP */
  943|       |#if COAP_THREAD_SAFE && !WITH_LWIP
  944|       |  coap_io_process_remove_threads_lkd(context);
  945|       |#endif /* COAP_THREAD_SAFE && !WITH_LWIP */
  946|     36|  coap_free_type(COAP_CONTEXT, context);
  947|     36|  coap_dump_memory_type_counts(COAP_LOG_DEBUG);
  948|     36|}
coap_session_send_pdu:
 1239|     19|coap_session_send_pdu(coap_session_t *session, coap_pdu_t *pdu) {
 1240|     19|  ssize_t bytes_written = -1;
 1241|     19|  assert(pdu->hdr_size > 0);
  ------------------
  |  Branch (1241:3): [True: 19, False: 0]
  ------------------
 1242|       |
 1243|       |  /* Caller handles partial writes */
 1244|     19|  bytes_written = session->sock.lfunc[COAP_LAYER_SESSION].l_write(session,
 1245|     19|                  pdu->token - pdu->hdr_size,
 1246|     19|                  pdu->used_size + pdu->hdr_size);
 1247|     19|  coap_show_pdu(COAP_LOG_DEBUG, pdu);
 1248|     19|  return bytes_written;
 1249|     19|}
coap_calc_timeout:
 1362|     11|coap_calc_timeout(coap_session_t *session, unsigned char r) {
 1363|     11|  unsigned int result;
 1364|       |
 1365|       |  /* The integer 1.0 as a Qx.FRAC_BITS */
 1366|     11|#define FP1 Q(FRAC_BITS, ((coap_fixed_point_t){1,0}))
 1367|       |
 1368|       |  /* rounds val up and right shifts by frac positions */
 1369|     11|#define SHR_FP(val,frac) (((val) + (1 << ((frac) - 1))) >> (frac))
 1370|       |
 1371|       |  /* Inner term: multiply ACK_RANDOM_FACTOR by Q0.MAX_BITS[r] and
 1372|       |   * make the result a rounded Qx.FRAC_BITS */
 1373|     11|  result = SHR_FP((ACK_RANDOM_FACTOR - FP1) * r, MAX_BITS);
  ------------------
  |  | 1369|     11|#define SHR_FP(val,frac) (((val) + (1 << ((frac) - 1))) >> (frac))
  ------------------
 1374|       |
 1375|       |  /* Add 1 to the inner term and multiply with ACK_TIMEOUT, then
 1376|       |   * make the result a rounded Qx.FRAC_BITS */
 1377|     11|  result = SHR_FP(((result + FP1) * ACK_TIMEOUT), FRAC_BITS);
  ------------------
  |  | 1369|     11|#define SHR_FP(val,frac) (((val) + (1 << ((frac) - 1))) >> (frac))
  ------------------
 1378|       |
 1379|       |  /* Multiply with COAP_TICKS_PER_SECOND to yield system ticks
 1380|       |   * (yields a Qx.FRAC_BITS) and shift to get an integer */
 1381|     11|  return SHR_FP((COAP_TICKS_PER_SECOND * result), FRAC_BITS);
  ------------------
  |  | 1369|     11|#define SHR_FP(val,frac) (((val) + (1 << ((frac) - 1))) >> (frac))
  ------------------
 1382|       |
 1383|     11|#undef FP1
 1384|     11|#undef SHR_FP
 1385|     11|}
coap_wait_ack:
 1389|     11|              coap_queue_t *node) {
 1390|     11|  coap_tick_t now;
 1391|       |
 1392|     11|  node->session = coap_session_reference_lkd(session);
 1393|       |
 1394|       |  /* Set timer for pdu retransmission. If this is the first element in
 1395|       |  * the retransmission queue, the base time is set to the current
 1396|       |  * time and the retransmission time is node->timeout. If there is
 1397|       |  * already an entry in the sendqueue, we must check if this node is
 1398|       |  * to be retransmitted earlier. Therefore, node->timeout is first
 1399|       |  * normalized to the base time and then inserted into the queue with
 1400|       |  * an adjusted relative time.
 1401|       |  */
 1402|     11|  coap_ticks(&now);
 1403|     11|  if (context->sendqueue == NULL) {
  ------------------
  |  Branch (1403:7): [True: 11, False: 0]
  ------------------
 1404|     11|    node->t = node->timeout << node->retransmit_cnt;
 1405|     11|    context->sendqueue_basetime = now;
 1406|     11|  } else {
 1407|       |    /* make node->t relative to context->sendqueue_basetime */
 1408|      0|    node->t = (now - context->sendqueue_basetime) +
 1409|      0|              (node->timeout << node->retransmit_cnt);
 1410|      0|  }
 1411|     11|  coap_address_copy(&node->remote, &session->addr_info.remote);
 1412|       |
 1413|     11|  coap_insert_node(&context->sendqueue, node);
 1414|       |
 1415|     11|  coap_log_debug("** %s: mid=0x%04x: added to retransmit queue (%ums)\n",
  ------------------
  |  |  126|     11|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|     11|#define coap_log(level, ...) do { \
  |  |  |  |  291|     11|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 11]
  |  |  |  |  ------------------
  |  |  |  |  292|     11|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|     11|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 11]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1416|     11|                 coap_session_str(node->session), node->id,
 1417|     11|                 (unsigned)((node->timeout << node->retransmit_cnt) * 1000 /
 1418|     11|                            COAP_TICKS_PER_SECOND));
 1419|       |
 1420|     11|  coap_update_io_timer(context, node->t);
 1421|       |
 1422|     11|  return node->id;
 1423|     11|}
coap_check_code_class:
 1549|     19|coap_check_code_class(coap_session_t *session, coap_pdu_t *pdu) {
 1550|       |
 1551|       |  /* Check validity of sending code */
 1552|     19|  switch (COAP_RESPONSE_CLASS(pdu->code)) {
  ------------------
  |  |   99|     19|#define COAP_RESPONSE_CLASS(C) (((C) >> 5) & 0xFF)
  ------------------
 1553|     19|  case 0: /* Empty or request */
  ------------------
  |  Branch (1553:3): [True: 19, False: 0]
  ------------------
 1554|     19|  case 2: /* Success */
  ------------------
  |  Branch (1554:3): [True: 0, False: 19]
  ------------------
 1555|     19|  case 3: /* Reserved for future use */
  ------------------
  |  Branch (1555:3): [True: 0, False: 19]
  ------------------
 1556|     19|  case 4: /* Client error */
  ------------------
  |  Branch (1556:3): [True: 0, False: 19]
  ------------------
 1557|     19|  case 5: /* Server error */
  ------------------
  |  Branch (1557:3): [True: 0, False: 19]
  ------------------
 1558|     19|    break;
 1559|      0|  case 7: /* Reliable signalling */
  ------------------
  |  Branch (1559:3): [True: 0, False: 19]
  ------------------
 1560|      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]
  |  |  ------------------
  ------------------
 1561|      0|      break;
 1562|       |  /* Not valid if UDP */
 1563|       |  /* Fall through */
 1564|      0|  case 1: /* Invalid */
  ------------------
  |  Branch (1564:3): [True: 0, False: 19]
  ------------------
 1565|      0|  case 6: /* Invalid */
  ------------------
  |  Branch (1565:3): [True: 0, False: 19]
  ------------------
 1566|      0|  default:
  ------------------
  |  Branch (1566:3): [True: 0, False: 19]
  ------------------
 1567|      0|    return 0;
 1568|     19|  }
 1569|     19|  return 1;
 1570|     19|}
coap_send_lkd:
 1614|     19|coap_send_lkd(coap_session_t *session, coap_pdu_t *pdu) {
 1615|     19|  coap_mid_t mid = COAP_INVALID_MID;
  ------------------
  |  |  187|     19|#define COAP_INVALID_MID -1
  ------------------
 1616|     19|#if COAP_CLIENT_SUPPORT
 1617|     19|  coap_lg_crcv_t *lg_crcv = NULL;
 1618|     19|  coap_opt_iterator_t opt_iter;
 1619|     19|  coap_block_b_t block;
 1620|     19|  int observe_action = -1;
 1621|     19|  int have_block1 = 0;
 1622|     19|  coap_opt_t *opt;
 1623|     19|#endif /* COAP_CLIENT_SUPPORT */
 1624|       |
 1625|     19|  assert(pdu);
  ------------------
  |  Branch (1625:3): [True: 19, False: 0]
  ------------------
 1626|       |
 1627|     19|  coap_lock_check_locked();
  ------------------
  |  |  638|     19|#define coap_lock_check_locked() {}
  ------------------
 1628|       |
 1629|       |  /* Check validity of sending code */
 1630|     19|  if (!coap_check_code_class(session, pdu)) {
  ------------------
  |  Branch (1630:7): [True: 0, False: 19]
  ------------------
 1631|      0|    coap_log_err("coap_send: Invalid PDU code (%d.%02d)\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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1632|      0|                 COAP_RESPONSE_CLASS(pdu->code),
 1633|      0|                 pdu->code & 0x1f);
 1634|      0|    goto error;
 1635|      0|  }
 1636|     19|  pdu->session = session;
 1637|     19|#if COAP_CLIENT_SUPPORT
 1638|     19|  if (session->type == COAP_SESSION_TYPE_CLIENT &&
  ------------------
  |  Branch (1638:7): [True: 19, False: 0]
  ------------------
 1639|     19|      !coap_netif_available(session) && !session->session_failed) {
  ------------------
  |  Branch (1639:7): [True: 0, False: 19]
  |  Branch (1639:41): [True: 0, False: 0]
  ------------------
 1640|      0|    coap_log_debug("coap_send: Socket closed\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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1641|      0|    goto error;
 1642|      0|  }
 1643|       |
 1644|     19|  if (session->doing_first) {
  ------------------
  |  Branch (1644:7): [True: 0, False: 19]
  ------------------
 1645|      0|    LL_APPEND(session->doing_first_pdu, pdu);
  ------------------
  |  |  344|      0|    LL_APPEND2(head,add,next)
  |  |  ------------------
  |  |  |  |  346|      0|#define LL_APPEND2(head,add,next)                                                              \
  |  |  |  |  347|      0|do {                                                                                           \
  |  |  |  |  348|      0|  LDECLTYPE(head) _tmp;                                                                        \
  |  |  |  |  ------------------
  |  |  |  |  |  |   81|      0|#define LDECLTYPE(x) __typeof(x)
  |  |  |  |  ------------------
  |  |  |  |  349|      0|  (add)->next=NULL;                                                                            \
  |  |  |  |  350|      0|  if (head) {                                                                                  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (350:7): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  351|      0|    _tmp = (head);                                                                             \
  |  |  |  |  352|      0|    while (_tmp->next) { _tmp = _tmp->next; }                                                  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (352:12): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  353|      0|    _tmp->next=(add);                                                                          \
  |  |  |  |  354|      0|  } else {                                                                                     \
  |  |  |  |  355|      0|    (head)=(add);                                                                              \
  |  |  |  |  356|      0|  }                                                                                            \
  |  |  |  |  357|      0|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (357:10): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1646|      0|    coap_show_pdu(COAP_LOG_DEBUG, pdu);
 1647|      0|    coap_log_debug("** %s: mid=0x%04x: queued\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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1648|      0|                   coap_session_str(session), pdu->mid);
 1649|      0|    return  pdu->mid;
 1650|      0|  }
 1651|       |
 1652|       |  /* Indicate support for Extended Tokens if appropriate */
 1653|     19|  if (session->max_token_checked == COAP_EXT_T_NOT_CHECKED &&
  ------------------
  |  Branch (1653:7): [True: 19, False: 0]
  ------------------
 1654|     19|      session->max_token_size > COAP_TOKEN_DEFAULT_MAX &&
  ------------------
  |  |   58|     38|#define COAP_TOKEN_DEFAULT_MAX 8
  ------------------
  |  Branch (1654:7): [True: 0, False: 19]
  ------------------
 1655|      0|      session->type == COAP_SESSION_TYPE_CLIENT &&
  ------------------
  |  Branch (1655:7): [True: 0, False: 0]
  ------------------
 1656|      0|      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]
  |  |  ------------------
  ------------------
 1657|      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]
  |  |  ------------------
  ------------------
 1658|       |      /*
 1659|       |       * When the pass / fail response for Extended Token is received, this PDU
 1660|       |       * will get transmitted.
 1661|       |       */
 1662|      0|      if (coap_send_test_extended_token(session) == COAP_INVALID_MID) {
  ------------------
  |  |  187|      0|#define COAP_INVALID_MID -1
  ------------------
  |  Branch (1662:11): [True: 0, False: 0]
  ------------------
 1663|      0|        goto error;
 1664|      0|      }
 1665|      0|    }
 1666|       |    /*
 1667|       |     * For reliable protocols, this will get cleared after CSM exchanged
 1668|       |     * in coap_session_connected() where Token size support is indicated in the CSM.
 1669|       |     */
 1670|      0|    session->doing_first = 1;
 1671|      0|    coap_ticks(&session->doing_first_timeout);
 1672|      0|    LL_PREPEND(session->doing_first_pdu, pdu);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1673|      0|    if (session->proto != COAP_PROTO_UDP) {
  ------------------
  |  Branch (1673:9): [True: 0, False: 0]
  ------------------
 1674|       |      /* In case the next handshake / CSM is already in */
 1675|      0|      coap_io_process_lkd(session->context, COAP_IO_NO_WAIT);
  ------------------
  |  |  841|      0|#define COAP_IO_NO_WAIT ((uint32_t)-1)
  ------------------
 1676|      0|    }
 1677|       |    /*
 1678|       |     * Once Extended Token support size is determined, coap_send_lkd(session, pdu)
 1679|       |     * will get called again.
 1680|       |     */
 1681|      0|    coap_show_pdu(COAP_LOG_DEBUG, pdu);
 1682|      0|    coap_log_debug("** %s: mid=0x%04x: queued\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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1683|      0|                   coap_session_str(session), pdu->mid);
 1684|      0|    return pdu->mid;
 1685|      0|  }
 1686|     19|#if COAP_Q_BLOCK_SUPPORT
 1687|       |  /* Indicate support for Q-Block if appropriate */
 1688|     19|  if (session->block_mode & COAP_BLOCK_TRY_Q_BLOCK &&
  ------------------
  |  |   67|     38|#define COAP_BLOCK_TRY_Q_BLOCK   0x04 /* Try Q-Block method */
  ------------------
  |  Branch (1688:7): [True: 0, False: 19]
  ------------------
 1689|      0|      session->type == COAP_SESSION_TYPE_CLIENT &&
  ------------------
  |  Branch (1689:7): [True: 0, False: 0]
  ------------------
 1690|      0|      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]
  |  |  ------------------
  ------------------
 1691|      0|    if (coap_block_test_q_block(session, pdu) == COAP_INVALID_MID) {
  ------------------
  |  |  187|      0|#define COAP_INVALID_MID -1
  ------------------
  |  Branch (1691:9): [True: 0, False: 0]
  ------------------
 1692|      0|      goto error;
 1693|      0|    }
 1694|      0|    session->doing_first = 1;
 1695|      0|    coap_ticks(&session->doing_first_timeout);
 1696|      0|    LL_PREPEND(session->doing_first_pdu, pdu);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1697|      0|    if (session->proto != COAP_PROTO_UDP) {
  ------------------
  |  Branch (1697:9): [True: 0, False: 0]
  ------------------
 1698|       |      /* In case the next handshake / CSM is already in */
 1699|      0|      coap_io_process_lkd(session->context, COAP_IO_NO_WAIT);
  ------------------
  |  |  841|      0|#define COAP_IO_NO_WAIT ((uint32_t)-1)
  ------------------
 1700|      0|    }
 1701|       |    /*
 1702|       |     * Once Extended Token support size is determined, coap_send_lkd(session, pdu)
 1703|       |     * will get called again.
 1704|       |     */
 1705|      0|    coap_show_pdu(COAP_LOG_DEBUG, pdu);
 1706|      0|    coap_log_debug("** %s: mid=0x%04x: queued\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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1707|      0|                   coap_session_str(session), pdu->mid);
 1708|      0|    return pdu->mid;
 1709|      0|  }
 1710|     19|#endif /* COAP_Q_BLOCK_SUPPORT */
 1711|       |
 1712|       |  /*
 1713|       |   * Check validity of token length
 1714|       |   */
 1715|     19|  if (COAP_PDU_IS_REQUEST(pdu) &&
  ------------------
  |  |   99|     38|#define COAP_PDU_IS_REQUEST(pdu)   (!COAP_PDU_IS_EMPTY(pdu) && (pdu)->code < 32)
  |  |  ------------------
  |  |  |  |   98|     38|#define COAP_PDU_IS_EMPTY(pdu)     ((pdu)->code == 0)
  |  |  ------------------
  |  |  |  Branch (99:37): [True: 19, False: 0]
  |  |  |  Branch (99:64): [True: 19, False: 0]
  |  |  ------------------
  ------------------
 1716|     19|      pdu->actual_token.length > session->max_token_size) {
  ------------------
  |  Branch (1716:7): [True: 0, False: 19]
  ------------------
 1717|      0|    coap_log_warn("coap_send: PDU dropped as token too long (%" PRIuS " > %" PRIu32 ")\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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1718|      0|                  pdu->actual_token.length, session->max_token_size);
 1719|      0|    goto error;
 1720|      0|  }
 1721|       |
 1722|       |  /* A lot of the reliable code assumes type is CON */
 1723|     19|  if (COAP_PROTO_RELIABLE(session->proto) && pdu->type != COAP_MESSAGE_CON)
  ------------------
  |  |   42|     38|#define COAP_PROTO_RELIABLE(p) ((p)==COAP_PROTO_TCP || (p)==COAP_PROTO_TLS || \
  |  |  ------------------
  |  |  |  Branch (42:33): [True: 0, False: 19]
  |  |  |  Branch (42:56): [True: 0, False: 19]
  |  |  ------------------
  |  |   43|     19|                                (p)==COAP_PROTO_WS || (p)==COAP_PROTO_WSS)
  |  |  ------------------
  |  |  |  Branch (43:33): [True: 0, False: 19]
  |  |  |  Branch (43:55): [True: 0, False: 19]
  |  |  ------------------
  ------------------
  |  Branch (1723:46): [True: 0, False: 0]
  ------------------
 1724|      0|    pdu->type = COAP_MESSAGE_CON;
 1725|       |
 1726|     19|#if COAP_OSCORE_SUPPORT
 1727|     19|  if (session->oscore_encryption) {
  ------------------
  |  Branch (1727:7): [True: 0, False: 19]
  ------------------
 1728|      0|    if (session->recipient_ctx->initial_state == 1 &&
  ------------------
  |  Branch (1728:9): [True: 0, False: 0]
  ------------------
 1729|      0|        !session->recipient_ctx->silent_server) {
  ------------------
  |  Branch (1729:9): [True: 0, False: 0]
  ------------------
 1730|       |      /*
 1731|       |       * Not sure if remote supports OSCORE, or is going to send us a
 1732|       |       * "4.01 + ECHO" etc. so need to hold off future coap_send()s until all
 1733|       |       * is OK. Continue sending current pdu to test things.
 1734|       |       */
 1735|      0|      session->doing_first = 1;
 1736|      0|    }
 1737|       |    /* Need to convert Proxy-Uri to Proxy-Scheme option if needed */
 1738|      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 (1738:37): [True: 0, False: 0]
  ------------------
 1739|      0|      goto error;
 1740|      0|    }
 1741|      0|  }
 1742|     19|#endif /* COAP_OSCORE_SUPPORT */
 1743|       |
 1744|     19|  if (!(session->block_mode & COAP_BLOCK_USE_LIBCOAP)) {
  ------------------
  |  |   65|     19|#define COAP_BLOCK_USE_LIBCOAP  0x01 /* Use libcoap to do block requests */
  ------------------
  |  Branch (1744:7): [True: 19, False: 0]
  ------------------
 1745|     19|    return coap_send_internal(session, pdu, NULL);
 1746|     19|  }
 1747|       |
 1748|      0|  if (session->no_path_abbrev) {
  ------------------
  |  Branch (1748:7): [True: 0, False: 0]
  ------------------
 1749|      0|    opt = coap_check_option(pdu, COAP_OPTION_URI_PATH_ABB, &opt_iter);
 1750|      0|    if (opt) {
  ------------------
  |  Branch (1750:9): [True: 0, False: 0]
  ------------------
 1751|       |      /* Server cannot handle Uri-Path-Abbrev */
 1752|      0|      coap_pdu_t *new;
 1753|      0|      size_t data_len;
 1754|      0|      const uint8_t *data;
 1755|       |
 1756|      0|      new = coap_pdu_duplicate_lkd(pdu, session, pdu->actual_token.length,
 1757|      0|                                   pdu->actual_token.s, NULL, COAP_BOOL_TRUE);
 1758|      0|      if (new) {
  ------------------
  |  Branch (1758:11): [True: 0, False: 0]
  ------------------
 1759|      0|        if (coap_get_data(pdu, &data_len, &data)) {
  ------------------
  |  Branch (1759:13): [True: 0, False: 0]
  ------------------
 1760|      0|          coap_add_data(pdu, data_len, data);
 1761|      0|        }
 1762|      0|        coap_log_debug("*  Retransmitting PDU with Uri-Path-Abbrev replaced (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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1763|      0|        coap_delete_pdu_lkd(pdu);
 1764|      0|        pdu = new;
 1765|      0|      }
 1766|      0|    }
 1767|      0|  }
 1768|       |
 1769|      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]
  |  |  ------------------
  ------------------
 1770|      0|    uint8_t buf[4];
 1771|       |
 1772|      0|    opt = coap_check_option(pdu, COAP_OPTION_OBSERVE, &opt_iter);
 1773|       |
 1774|      0|    if (opt) {
  ------------------
  |  Branch (1774:9): [True: 0, False: 0]
  ------------------
 1775|      0|      observe_action = coap_decode_var_bytes(coap_opt_value(opt),
 1776|      0|                                             coap_opt_length(opt));
 1777|      0|    }
 1778|       |
 1779|      0|    if (coap_get_block_b(session, pdu, COAP_OPTION_BLOCK1, &block) &&
  ------------------
  |  Branch (1779:9): [True: 0, False: 0]
  ------------------
 1780|      0|        (block.m == 1 || block.bert == 1)) {
  ------------------
  |  Branch (1780:10): [True: 0, False: 0]
  |  Branch (1780:26): [True: 0, False: 0]
  ------------------
 1781|      0|      have_block1 = 1;
 1782|      0|    }
 1783|      0|#if COAP_Q_BLOCK_SUPPORT
 1784|      0|    if (coap_get_block_b(session, pdu, COAP_OPTION_Q_BLOCK1, &block) &&
  ------------------
  |  Branch (1784:9): [True: 0, False: 0]
  ------------------
 1785|      0|        (block.m == 1 || block.bert == 1)) {
  ------------------
  |  Branch (1785:10): [True: 0, False: 0]
  |  Branch (1785:26): [True: 0, False: 0]
  ------------------
 1786|      0|      if (have_block1) {
  ------------------
  |  Branch (1786:11): [True: 0, False: 0]
  ------------------
 1787|      0|        coap_log_warn("Block1 and Q-Block1 cannot be in the same request\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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1788|      0|        coap_remove_option(pdu, COAP_OPTION_BLOCK1);
 1789|      0|      }
 1790|      0|      have_block1 = 1;
 1791|      0|    }
 1792|      0|#endif /* COAP_Q_BLOCK_SUPPORT */
 1793|      0|    if (observe_action != COAP_OBSERVE_CANCEL) {
  ------------------
  |  |   44|      0|#define COAP_OBSERVE_CANCEL 1
  ------------------
  |  Branch (1793:9): [True: 0, False: 0]
  ------------------
 1794|       |      /* Warn about re-use of tokens */
 1795|      0|      if (session->last_token &&
  ------------------
  |  Branch (1795:11): [True: 0, False: 0]
  ------------------
 1796|      0|          coap_binary_equal(&pdu->actual_token, session->last_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]
  |  |  ------------------
  ------------------
 1797|      0|        if (coap_get_log_level() >= COAP_LOG_DEBUG) {
  ------------------
  |  Branch (1797:13): [True: 0, False: 0]
  ------------------
 1798|      0|          char scratch[24];
 1799|      0|          size_t size;
 1800|      0|          size_t i;
 1801|       |
 1802|      0|          scratch[0] = '\000';
 1803|      0|          for (i = 0; i < pdu->actual_token.length; i++) {
  ------------------
  |  Branch (1803:23): [True: 0, False: 0]
  ------------------
 1804|      0|            size = strlen(scratch);
 1805|      0|            snprintf(&scratch[size], sizeof(scratch)-size,
 1806|      0|                     "%02x", pdu->actual_token.s[i]);
 1807|      0|          }
 1808|      0|          coap_log_debug("Token {%s} reused - see https://rfc-editor.org/rfc/rfc9175.html#section-4.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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1809|      0|                         scratch);
 1810|      0|        }
 1811|      0|      }
 1812|      0|      coap_delete_bin_const(session->last_token);
 1813|      0|      session->last_token = coap_new_bin_const(pdu->actual_token.s,
 1814|      0|                                               pdu->actual_token.length);
 1815|      0|    } else {
 1816|       |      /* observe_action == COAP_OBSERVE_CANCEL */
 1817|      0|      coap_binary_t tmp;
 1818|      0|      int ret;
 1819|       |
 1820|      0|      coap_log_debug("coap_send: Using coap_cancel_observe() to do 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1821|       |      /* Unfortunately need to change the ptr type to be r/w */
 1822|      0|      memcpy(&tmp.s, &pdu->actual_token.s, sizeof(tmp.s));
 1823|      0|      tmp.length = pdu->actual_token.length;
 1824|      0|      ret = coap_cancel_observe_lkd(session, &tmp, pdu->type);
 1825|      0|      if (ret == 1) {
  ------------------
  |  Branch (1825:11): [True: 0, False: 0]
  ------------------
 1826|       |        /* Observe Cancel successfully sent */
 1827|      0|        coap_delete_pdu_lkd(pdu);
 1828|      0|        return ret;
 1829|      0|      }
 1830|       |      /* Some mismatch somewhere - continue to send original packet */
 1831|      0|    }
 1832|      0|    if (!coap_check_option(pdu, COAP_OPTION_RTAG, &opt_iter) &&
  ------------------
  |  Branch (1832:9): [True: 0, False: 0]
  ------------------
 1833|      0|        (session->block_mode & COAP_BLOCK_NO_PREEMPTIVE_RTAG) == 0 &&
  ------------------
  |  |   69|      0|#define COAP_BLOCK_NO_PREEMPTIVE_RTAG 0x10 /* (cl) Don't use pre-emptive Request-Tags */
  ------------------
  |  Branch (1833:9): [True: 0, False: 0]
  ------------------
 1834|      0|        pdu->code != COAP_REQUEST_CODE_DELETE)
  ------------------
  |  Branch (1834:9): [True: 0, False: 0]
  ------------------
 1835|      0|      coap_insert_option(pdu,
 1836|      0|                         COAP_OPTION_RTAG,
 1837|      0|                         coap_encode_var_safe(buf, sizeof(buf),
 1838|      0|                                              ++session->tx_rtag),
 1839|      0|                         buf);
 1840|      0|  } else {
 1841|      0|    memset(&block, 0, sizeof(block));
 1842|      0|  }
 1843|       |
 1844|      0|#if COAP_Q_BLOCK_SUPPORT
 1845|      0|  if (!(session->block_mode & COAP_BLOCK_HAS_Q_BLOCK))
  ------------------
  |  |   73|      0|#define COAP_BLOCK_HAS_Q_BLOCK   0x40000000 /* Set when Q_BLOCK supported */
  ------------------
  |  Branch (1845:7): [True: 0, False: 0]
  ------------------
 1846|      0|#endif /* COAP_Q_BLOCK_SUPPORT */
 1847|      0|  {
 1848|       |    /* Need to check if we need to reset Q-Block to Block */
 1849|      0|    uint8_t buf[4];
 1850|       |
 1851|      0|    if (coap_get_block_b(session, pdu, COAP_OPTION_Q_BLOCK2, &block)) {
  ------------------
  |  Branch (1851:9): [True: 0, False: 0]
  ------------------
 1852|      0|      coap_remove_option(pdu, COAP_OPTION_Q_BLOCK2);
 1853|      0|      coap_insert_option(pdu, COAP_OPTION_BLOCK2,
 1854|      0|                         coap_encode_var_safe(buf, sizeof(buf),
 1855|      0|                                              (block.num << 4) | (0 << 3) | block.szx),
 1856|      0|                         buf);
 1857|      0|      coap_log_debug("Replaced option Q-Block2 with 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1858|       |      /* Need to update associated lg_xmit */
 1859|      0|      coap_lg_xmit_t *lg_xmit;
 1860|       |
 1861|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1862|      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]
  |  |  ------------------
  ------------------
 1863|      0|            lg_xmit->b.b1.app_token &&
  ------------------
  |  Branch (1863:13): [True: 0, False: 0]
  ------------------
 1864|      0|            coap_binary_equal(&pdu->actual_token, lg_xmit->b.b1.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]
  |  |  ------------------
  ------------------
 1865|       |          /* Update the skeletal PDU with the block1 option */
 1866|      0|          coap_remove_option(lg_xmit->sent_pdu, COAP_OPTION_Q_BLOCK2);
 1867|      0|          coap_update_option(lg_xmit->sent_pdu, COAP_OPTION_BLOCK2,
 1868|      0|                             coap_encode_var_safe(buf, sizeof(buf),
 1869|      0|                                                  (block.num << 4) | (0 << 3) | block.szx),
 1870|      0|                             buf);
 1871|      0|          break;
 1872|      0|        }
 1873|      0|      }
 1874|      0|    }
 1875|      0|    if (coap_get_block_b(session, pdu, COAP_OPTION_Q_BLOCK1, &block)) {
  ------------------
  |  Branch (1875:9): [True: 0, False: 0]
  ------------------
 1876|      0|      coap_remove_option(pdu, COAP_OPTION_Q_BLOCK1);
 1877|      0|      coap_insert_option(pdu, COAP_OPTION_BLOCK1,
 1878|      0|                         coap_encode_var_safe(buf, sizeof(buf),
 1879|      0|                                              (block.num << 4) | (block.m << 3) | block.szx),
 1880|      0|                         buf);
 1881|      0|      coap_log_debug("Replaced option Q-Block1 with 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1882|       |      /* Need to update associated lg_xmit */
 1883|      0|      coap_lg_xmit_t *lg_xmit;
 1884|       |
 1885|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1886|      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]
  |  |  ------------------
  ------------------
 1887|      0|            lg_xmit->b.b1.app_token &&
  ------------------
  |  Branch (1887:13): [True: 0, False: 0]
  ------------------
 1888|      0|            coap_binary_equal(&pdu->actual_token, lg_xmit->b.b1.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]
  |  |  ------------------
  ------------------
 1889|       |          /* Update the skeletal PDU with the block1 option */
 1890|      0|          coap_remove_option(lg_xmit->sent_pdu, COAP_OPTION_Q_BLOCK1);
 1891|      0|          coap_update_option(lg_xmit->sent_pdu, COAP_OPTION_BLOCK1,
 1892|      0|                             coap_encode_var_safe(buf, sizeof(buf),
 1893|      0|                                                  (block.num << 4) |
 1894|      0|                                                  (block.m << 3) |
 1895|      0|                                                  block.szx),
 1896|      0|                             buf);
 1897|       |          /* Update as this is a Request */
 1898|      0|          lg_xmit->option = COAP_OPTION_BLOCK1;
 1899|      0|          break;
 1900|      0|        }
 1901|      0|      }
 1902|      0|    }
 1903|      0|  }
 1904|       |
 1905|      0|#if COAP_Q_BLOCK_SUPPORT
 1906|      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]
  |  |  ------------------
  ------------------
 1907|      0|      coap_get_block_b(session, pdu, COAP_OPTION_Q_BLOCK2, &block)) {
  ------------------
  |  Branch (1907:7): [True: 0, False: 0]
  ------------------
 1908|      0|    if (block.num == 0 && block.m == 0) {
  ------------------
  |  Branch (1908:9): [True: 0, False: 0]
  |  Branch (1908:27): [True: 0, False: 0]
  ------------------
 1909|      0|      uint8_t buf[4];
 1910|       |
 1911|       |      /* M needs to be set as asking for all the blocks */
 1912|      0|      coap_update_option(pdu, COAP_OPTION_Q_BLOCK2,
 1913|      0|                         coap_encode_var_safe(buf, sizeof(buf),
 1914|      0|                                              (0 << 4) | (1 << 3) | block.szx),
 1915|      0|                         buf);
 1916|      0|    }
 1917|      0|  }
 1918|      0|#endif /* COAP_Q_BLOCK_SUPPORT */
 1919|       |
 1920|       |  /*
 1921|       |   * If type is CON and protocol is not reliable, there is no need to set up
 1922|       |   * lg_crcv here as it can be built up based on sent PDU if there is a
 1923|       |   * (Q-)Block2 in the response.  However, still need it for Observe, Oscore and
 1924|       |   * (Q-)Block1.
 1925|       |   */
 1926|      0|  if (coap_check_send_need_lg_crcv(session, pdu)) {
  ------------------
  |  Branch (1926:7): [True: 0, False: 0]
  ------------------
 1927|      0|    coap_lg_xmit_t *lg_xmit = NULL;
 1928|       |
 1929|      0|    if (!session->lg_xmit && have_block1) {
  ------------------
  |  Branch (1929:9): [True: 0, False: 0]
  |  Branch (1929:30): [True: 0, False: 0]
  ------------------
 1930|      0|      coap_log_debug("PDU presented by app\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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1931|      0|      coap_show_pdu(COAP_LOG_DEBUG, pdu);
 1932|      0|    }
 1933|       |    /* See if this token is already in use for large body responses */
 1934|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1935|      0|      if (coap_binary_equal(&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]
  |  |  ------------------
  ------------------
 1936|       |        /* Need to terminate and clean up previous response setup */
 1937|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1938|      0|        coap_block_delete_lg_crcv(session, lg_crcv);
 1939|      0|        break;
 1940|      0|      }
 1941|      0|    }
 1942|       |
 1943|      0|    if (have_block1 && session->lg_xmit) {
  ------------------
  |  Branch (1943:9): [True: 0, False: 0]
  |  Branch (1943:24): [True: 0, False: 0]
  ------------------
 1944|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1945|      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]
  |  |  ------------------
  ------------------
 1946|      0|            lg_xmit->b.b1.app_token &&
  ------------------
  |  Branch (1946:13): [True: 0, False: 0]
  ------------------
 1947|      0|            coap_binary_equal(&pdu->actual_token, lg_xmit->b.b1.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]
  |  |  ------------------
  ------------------
 1948|      0|          break;
 1949|      0|        }
 1950|      0|      }
 1951|      0|    }
 1952|      0|    lg_crcv = coap_block_new_lg_crcv(session, pdu, lg_xmit);
 1953|      0|    if (lg_crcv == NULL) {
  ------------------
  |  Branch (1953:9): [True: 0, False: 0]
  ------------------
 1954|      0|      goto error;
 1955|      0|    }
 1956|      0|    if (lg_xmit) {
  ------------------
  |  Branch (1956:9): [True: 0, False: 0]
  ------------------
 1957|       |      /* Need to update the token as set up in the session->lg_xmit */
 1958|      0|      lg_xmit->b.b1.state_token = lg_crcv->state_token;
 1959|      0|    }
 1960|      0|  }
 1961|      0|  if (session->sock.flags & COAP_SOCKET_MULTICAST)
  ------------------
  |  |   86|      0|#define COAP_SOCKET_MULTICAST    0x1000  /**< socket is used for multicast communication */
  ------------------
  |  Branch (1961:7): [True: 0, False: 0]
  ------------------
 1962|      0|    coap_address_copy(&session->addr_info.remote, &session->sock.mcast_addr);
 1963|       |
 1964|      0|#if COAP_Q_BLOCK_SUPPORT
 1965|       |  /* See if large xmit using Q-Block1 (but not testing Q-Block1) */
 1966|      0|  if (coap_get_block_b(session, pdu, COAP_OPTION_Q_BLOCK1, &block)) {
  ------------------
  |  Branch (1966:7): [True: 0, False: 0]
  ------------------
 1967|      0|    mid = coap_send_q_block1(session, block, pdu, COAP_SEND_INC_PDU);
 1968|      0|  } else
 1969|      0|#endif /* COAP_Q_BLOCK_SUPPORT */
 1970|      0|    mid = coap_send_internal(session, pdu, NULL);
 1971|       |#else /* !COAP_CLIENT_SUPPORT */
 1972|       |  mid = coap_send_internal(session, pdu, NULL);
 1973|       |#endif /* !COAP_CLIENT_SUPPORT */
 1974|      0|#if COAP_CLIENT_SUPPORT
 1975|      0|  if (lg_crcv) {
  ------------------
  |  Branch (1975:7): [True: 0, False: 0]
  ------------------
 1976|      0|    if (mid != COAP_INVALID_MID) {
  ------------------
  |  |  187|      0|#define COAP_INVALID_MID -1
  ------------------
  |  Branch (1976:9): [True: 0, False: 0]
  ------------------
 1977|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1978|      0|    } else {
 1979|      0|      coap_block_delete_lg_crcv(session, lg_crcv);
 1980|      0|    }
 1981|      0|  }
 1982|      0|#endif /* COAP_CLIENT_SUPPORT */
 1983|      0|  return mid;
 1984|       |
 1985|      0|error:
 1986|      0|  coap_delete_pdu_lkd(pdu);
 1987|      0|  return COAP_INVALID_MID;
  ------------------
  |  |  187|      0|#define COAP_INVALID_MID -1
  ------------------
 1988|      0|}
coap_send_internal:
 2134|     19|coap_send_internal(coap_session_t *session, coap_pdu_t *pdu, coap_pdu_t *request_pdu) {
 2135|     19|  uint8_t r;
 2136|     19|  ssize_t bytes_written;
 2137|       |
 2138|       |#if ! COAP_SERVER_SUPPORT
 2139|       |  (void)request_pdu;
 2140|       |#endif /* COAP_SERVER_SUPPORT */
 2141|     19|  pdu->session = session;
 2142|     19|#if COAP_CLIENT_SUPPORT
 2143|     19|  if (session->session_failed) {
  ------------------
  |  Branch (2143:7): [True: 0, False: 19]
  ------------------
 2144|      0|    coap_session_reconnect(session);
 2145|      0|    if (session->session_failed)
  ------------------
  |  Branch (2145:9): [True: 0, False: 0]
  ------------------
 2146|      0|      goto error;
 2147|      0|  }
 2148|     19|#endif /* COAP_CLIENT_SUPPORT */
 2149|     19|  if (pdu->type == COAP_MESSAGE_NON && session->rl_ticks_per_packet) {
  ------------------
  |  Branch (2149:7): [True: 8, False: 11]
  |  Branch (2149:40): [True: 0, False: 8]
  ------------------
 2150|      0|    coap_tick_t now;
 2151|       |
 2152|      0|    if (!session->is_rate_limiting) {
  ------------------
  |  Branch (2152:9): [True: 0, False: 0]
  ------------------
 2153|      0|      coap_ticks(&now);
 2154|      0|#if (COAP_MAX_LOGGING_LEVEL >= _COAP_LOG_DEBUG)
 2155|      0|      if (now - session->last_tx < session->rl_ticks_per_packet) {
  ------------------
  |  Branch (2155:11): [True: 0, False: 0]
  ------------------
 2156|      0|        uint32_t rem = (uint32_t)(session->rl_ticks_per_packet -
 2157|      0|                                  (now - session->last_tx)) * 1000 / COAP_TICKS_PER_SECOND;
  ------------------
  |  |  164|      0|#define COAP_TICKS_PER_SECOND ((coap_tick_t)(1000U))
  ------------------
 2158|      0|        coap_log_debug("** %s: mid 0x%04x: delaying transmission (%d.%03ds)\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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2159|      0|                       coap_session_str(session), pdu->mid, rem / 1000, rem %1000);
 2160|      0|        coap_show_pdu(COAP_LOG_DEBUG, pdu);
 2161|      0|      }
 2162|      0|#endif /* COAP_MAX_LOGGING_LEVEL >= _COAP_LOG_DEBUG */
 2163|      0|      while (1) {
  ------------------
  |  Branch (2163:14): [True: 0, Folded]
  ------------------
 2164|      0|        uint32_t timeout_ms;
 2165|       |
 2166|      0|        if (send_recv_terminate) {
  ------------------
  |  Branch (2166:13): [True: 0, False: 0]
  ------------------
 2167|      0|          goto error;
 2168|      0|        }
 2169|       |
 2170|      0|        if (now - session->last_tx >= session->rl_ticks_per_packet) {
  ------------------
  |  Branch (2170:13): [True: 0, False: 0]
  ------------------
 2171|      0|          break;
 2172|      0|        }
 2173|      0|        timeout_ms = (uint32_t)((session->rl_ticks_per_packet - (now - session->last_tx)) /
 2174|      0|                                (COAP_TICKS_PER_SECOND / 1000));
  ------------------
  |  |  164|      0|#define COAP_TICKS_PER_SECOND ((coap_tick_t)(1000U))
  ------------------
 2175|       |
 2176|      0|        if (timeout_ms == 0) {
  ------------------
  |  Branch (2176:13): [True: 0, False: 0]
  ------------------
 2177|      0|          timeout_ms = COAP_IO_NO_WAIT;
  ------------------
  |  |  841|      0|#define COAP_IO_NO_WAIT ((uint32_t)-1)
  ------------------
 2178|      0|        }
 2179|       |
 2180|      0|        session->is_rate_limiting = 1;
 2181|      0|        coap_io_process_lkd(session->context, timeout_ms);
 2182|      0|        session->is_rate_limiting = 0;
 2183|      0|        coap_ticks(&now);
 2184|      0|      }
 2185|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2186|      0|                     coap_session_str(session), pdu->mid);
 2187|      0|      session->last_tx = now;
 2188|      0|    }
 2189|      0|  }
 2190|     19|#if COAP_PROXY_SUPPORT
 2191|     19|  if (session->server_list) {
  ------------------
  |  Branch (2191:7): [True: 0, False: 19]
  ------------------
 2192|       |    /* Local session wanting to use proxy logic */
 2193|      0|    return coap_proxy_local_write(session, pdu);
 2194|      0|  }
 2195|     19|#endif /* COAP_PROXY_SUPPORT */
 2196|     19|  if (pdu->code == COAP_RESPONSE_CODE(508)) {
  ------------------
  |  |   96|     19|#define COAP_RESPONSE_CODE(N) (((N)/100 << 5) | (N)%100)
  ------------------
  |  Branch (2196:7): [True: 0, False: 19]
  ------------------
 2197|       |    /*
 2198|       |     * Need to prepend our IP identifier to the data as per
 2199|       |     * https://rfc-editor.org/rfc/rfc8768.html#section-4
 2200|       |     */
 2201|      0|    if (!prepend_508_ip(session, pdu)) {
  ------------------
  |  Branch (2201:9): [True: 0, False: 0]
  ------------------
 2202|      0|      return (coap_mid_t)COAP_DROPPED_RESPONSE;
  ------------------
  |  |   92|      0|#define COAP_DROPPED_RESPONSE -2
  ------------------
 2203|      0|    }
 2204|      0|  }
 2205|       |
 2206|     19|  if (session->echo) {
  ------------------
  |  Branch (2206:7): [True: 0, False: 19]
  ------------------
 2207|      0|    if (!coap_insert_option(pdu, COAP_OPTION_ECHO, session->echo->length,
  ------------------
  |  Branch (2207:9): [True: 0, False: 0]
  ------------------
 2208|      0|                            session->echo->s))
 2209|      0|      goto error;
 2210|      0|    coap_delete_bin_const(session->echo);
 2211|      0|    session->echo = NULL;
 2212|      0|  }
 2213|     19|#if COAP_OSCORE_SUPPORT
 2214|     19|  if (session->oscore_encryption) {
  ------------------
  |  Branch (2214:7): [True: 0, False: 19]
  ------------------
 2215|       |    /* Need to convert Proxy-Uri to Proxy-Scheme option if needed */
 2216|      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 (2216:37): [True: 0, False: 0]
  ------------------
 2217|      0|      goto error;
 2218|      0|  }
 2219|     19|#endif /* COAP_OSCORE_SUPPORT */
 2220|       |
 2221|     19|  if (!coap_pdu_encode_header(pdu, session->proto)) {
  ------------------
  |  Branch (2221:7): [True: 0, False: 19]
  ------------------
 2222|      0|    goto error;
 2223|      0|  }
 2224|       |
 2225|     19|#if !COAP_DISABLE_TCP
 2226|     19|  if (COAP_PROTO_RELIABLE(session->proto) &&
  ------------------
  |  |   42|     38|#define COAP_PROTO_RELIABLE(p) ((p)==COAP_PROTO_TCP || (p)==COAP_PROTO_TLS || \
  |  |  ------------------
  |  |  |  Branch (42:33): [True: 0, False: 19]
  |  |  |  Branch (42:56): [True: 0, False: 19]
  |  |  ------------------
  |  |   43|     19|                                (p)==COAP_PROTO_WS || (p)==COAP_PROTO_WSS)
  |  |  ------------------
  |  |  |  Branch (43:33): [True: 0, False: 19]
  |  |  |  Branch (43:55): [True: 0, False: 19]
  |  |  ------------------
  ------------------
 2227|      0|      session->state == COAP_SESSION_STATE_ESTABLISHED) {
  ------------------
  |  Branch (2227:7): [True: 0, False: 0]
  ------------------
 2228|      0|    coap_opt_iterator_t opt_iter;
 2229|       |
 2230|      0|    if (!session->csm_block_supported) {
  ------------------
  |  Branch (2230:9): [True: 0, False: 0]
  ------------------
 2231|       |      /*
 2232|       |       * Need to check that this instance is not sending any block options as
 2233|       |       * the remote end via CSM has not informed us that there is support
 2234|       |       * https://rfc-editor.org/rfc/rfc8323#section-5.3.2
 2235|       |       * This includes potential BERT blocks.
 2236|       |       */
 2237|      0|      if (coap_check_option(pdu, COAP_OPTION_BLOCK1, &opt_iter) != NULL) {
  ------------------
  |  Branch (2237:11): [True: 0, False: 0]
  ------------------
 2238|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2239|      0|      }
 2240|      0|      if (coap_check_option(pdu, COAP_OPTION_BLOCK2, &opt_iter) != NULL) {
  ------------------
  |  Branch (2240:11): [True: 0, False: 0]
  ------------------
 2241|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2242|      0|      }
 2243|      0|    } else if (!session->csm_bert_rem_support) {
  ------------------
  |  Branch (2243:16): [True: 0, False: 0]
  ------------------
 2244|      0|      coap_opt_t *opt;
 2245|       |
 2246|      0|      opt = coap_check_option(pdu, COAP_OPTION_BLOCK1, &opt_iter);
 2247|      0|      if (opt && COAP_OPT_BLOCK_SZX(opt) == 7) {
  ------------------
  |  |   97|      0|  (coap_opt_length(opt) ? (COAP_OPT_BLOCK_END_BYTE(opt) & 0x07) : 0)
  |  |  ------------------
  |  |  |  |   88|      0|  ((coap_opt_length(opt) && coap_opt_value(opt)) ? \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (88:5): [True: 0, False: 0]
  |  |  |  |  |  Branch (88:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   89|      0|   *(coap_opt_value(opt) + (coap_opt_length(opt)-1)) : 0)
  |  |  ------------------
  |  |  |  Branch (97:4): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (2247:11): [True: 0, False: 0]
  |  Branch (2247:18): [True: 0, False: 0]
  ------------------
 2248|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2249|      0|      }
 2250|      0|      opt = coap_check_option(pdu, COAP_OPTION_BLOCK2, &opt_iter);
 2251|      0|      if (opt && COAP_OPT_BLOCK_SZX(opt) == 7) {
  ------------------
  |  |   97|      0|  (coap_opt_length(opt) ? (COAP_OPT_BLOCK_END_BYTE(opt) & 0x07) : 0)
  |  |  ------------------
  |  |  |  |   88|      0|  ((coap_opt_length(opt) && coap_opt_value(opt)) ? \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (88:5): [True: 0, False: 0]
  |  |  |  |  |  Branch (88:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   89|      0|   *(coap_opt_value(opt) + (coap_opt_length(opt)-1)) : 0)
  |  |  ------------------
  |  |  |  Branch (97:4): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (2251:11): [True: 0, False: 0]
  |  Branch (2251:18): [True: 0, False: 0]
  ------------------
 2252|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2253|      0|      }
 2254|      0|    }
 2255|      0|  }
 2256|     19|#endif /* !COAP_DISABLE_TCP */
 2257|       |
 2258|     19|#if COAP_OSCORE_SUPPORT
 2259|     19|  if (session->oscore_encryption &&
  ------------------
  |  Branch (2259:7): [True: 0, False: 19]
  ------------------
 2260|      0|      pdu->type != COAP_MESSAGE_RST &&
  ------------------
  |  Branch (2260:7): [True: 0, False: 0]
  ------------------
 2261|      0|      !(pdu->type == COAP_MESSAGE_ACK && pdu->code == COAP_EMPTY_CODE) &&
  ------------------
  |  Branch (2261:9): [True: 0, False: 0]
  |  Branch (2261:42): [True: 0, False: 0]
  ------------------
 2262|      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 (2262:48): [True: 0, False: 0]
  ------------------
 2263|       |    /* Refactor PDU as appropriate RFC8613 */
 2264|      0|    coap_pdu_t *osc_pdu = coap_oscore_new_pdu_encrypted_lkd(session, pdu, NULL, 0);
 2265|       |
 2266|      0|    if (osc_pdu == NULL) {
  ------------------
  |  Branch (2266:9): [True: 0, False: 0]
  ------------------
 2267|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2268|      0|      if (coap_get_log_level() < COAP_LOG_DEBUG)
  ------------------
  |  Branch (2268:11): [True: 0, False: 0]
  ------------------
 2269|      0|        coap_show_pdu(COAP_LOG_WARN, pdu);
 2270|      0|      goto error;
 2271|      0|    }
 2272|      0|    bytes_written = coap_send_pdu(session, osc_pdu, NULL);
 2273|      0|    coap_delete_pdu_lkd(pdu);
 2274|      0|    pdu = osc_pdu;
 2275|      0|  } else
 2276|     19|#endif /* COAP_OSCORE_SUPPORT */
 2277|     19|    bytes_written = coap_send_pdu(session, pdu, NULL);
 2278|       |
 2279|     19|#if COAP_SERVER_SUPPORT
 2280|     19|  if ((session->block_mode & COAP_BLOCK_CACHE_RESPONSE) &&
  ------------------
  |  |   74|     19|#define COAP_BLOCK_CACHE_RESPONSE 0x100 /* (svr)Cache CON request's response */
  ------------------
  |  Branch (2280:7): [True: 0, False: 19]
  ------------------
 2281|      0|      session->cached_pdu != pdu &&
  ------------------
  |  Branch (2281:7): [True: 0, False: 0]
  ------------------
 2282|      0|      request_pdu && COAP_PROTO_NOT_RELIABLE(session->proto) &&
  ------------------
  |  |   41|     19|#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 (2282:7): [True: 0, False: 0]
  ------------------
 2283|      0|      COAP_PDU_IS_REQUEST(request_pdu) &&
  ------------------
  |  |   99|     19|#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]
  |  |  ------------------
  ------------------
 2284|      0|      COAP_PDU_IS_RESPONSE(pdu) && pdu->type == COAP_MESSAGE_ACK) {
  ------------------
  |  |  101|     19|#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 (2284:36): [True: 0, False: 0]
  ------------------
 2285|      0|    coap_delete_pdu_lkd(session->cached_pdu);
 2286|      0|    session->cached_pdu = pdu;
 2287|      0|    coap_pdu_reference_lkd(session->cached_pdu);
 2288|      0|    coap_pdu_cksum(request_pdu, &session->cached_pdu_cksum);
 2289|      0|  }
 2290|     19|#endif /* COAP_SERVER_SUPPORT */
 2291|       |
 2292|     19|  if (bytes_written == COAP_PDU_DELAYED) {
  ------------------
  |  |   94|     19|#define COAP_PDU_DELAYED -3
  ------------------
  |  Branch (2292:7): [True: 0, False: 19]
  ------------------
 2293|       |    /* do not free pdu as it is stored with session for later use */
 2294|      0|    return pdu->mid;
 2295|      0|  }
 2296|     19|  if (bytes_written < 0) {
  ------------------
  |  Branch (2296:7): [True: 0, False: 19]
  ------------------
 2297|      0|    if (pdu->code != 0)
  ------------------
  |  Branch (2297:9): [True: 0, False: 0]
  ------------------
 2298|      0|      coap_session_disconnected_lkd(session, COAP_NACK_NOT_DELIVERABLE);
 2299|      0|    goto error;
 2300|      0|  }
 2301|       |
 2302|     19|#if !COAP_DISABLE_TCP
 2303|     19|  if (COAP_PROTO_RELIABLE(session->proto) &&
  ------------------
  |  |   42|     38|#define COAP_PROTO_RELIABLE(p) ((p)==COAP_PROTO_TCP || (p)==COAP_PROTO_TLS || \
  |  |  ------------------
  |  |  |  Branch (42:33): [True: 0, False: 19]
  |  |  |  Branch (42:56): [True: 0, False: 19]
  |  |  ------------------
  |  |   43|     19|                                (p)==COAP_PROTO_WS || (p)==COAP_PROTO_WSS)
  |  |  ------------------
  |  |  |  Branch (43:33): [True: 0, False: 19]
  |  |  |  Branch (43:55): [True: 0, False: 19]
  |  |  ------------------
  ------------------
 2304|      0|      (size_t)bytes_written < pdu->used_size + pdu->hdr_size) {
  ------------------
  |  Branch (2304:7): [True: 0, False: 0]
  ------------------
 2305|      0|    if (coap_session_delay_pdu(session, pdu, NULL) == COAP_PDU_DELAYED) {
  ------------------
  |  |   94|      0|#define COAP_PDU_DELAYED -3
  ------------------
  |  Branch (2305:9): [True: 0, False: 0]
  ------------------
 2306|      0|      session->partial_write = (size_t)bytes_written;
 2307|       |      /* do not free pdu as it is stored with session for later use */
 2308|      0|      return pdu->mid;
 2309|      0|    } else {
 2310|      0|      goto error;
 2311|      0|    }
 2312|      0|  }
 2313|     19|#endif /* !COAP_DISABLE_TCP */
 2314|       |
 2315|     19|  if (pdu->type != COAP_MESSAGE_CON
  ------------------
  |  Branch (2315:7): [True: 8, False: 11]
  ------------------
 2316|     11|      || COAP_PROTO_RELIABLE(session->proto)) {
  ------------------
  |  |   42|     11|#define COAP_PROTO_RELIABLE(p) ((p)==COAP_PROTO_TCP || (p)==COAP_PROTO_TLS || \
  |  |  ------------------
  |  |  |  Branch (42:33): [True: 0, False: 11]
  |  |  |  Branch (42:56): [True: 0, False: 11]
  |  |  ------------------
  |  |   43|     11|                                (p)==COAP_PROTO_WS || (p)==COAP_PROTO_WSS)
  |  |  ------------------
  |  |  |  Branch (43:33): [True: 0, False: 11]
  |  |  |  Branch (43:55): [True: 0, False: 11]
  |  |  ------------------
  ------------------
 2317|      8|    coap_mid_t id = pdu->mid;
 2318|      8|    coap_delete_pdu_lkd(pdu);
 2319|      8|    return id;
 2320|      8|  }
 2321|       |
 2322|     11|  coap_queue_t *node = coap_new_node();
 2323|     11|  if (!node) {
  ------------------
  |  Branch (2323:7): [True: 0, False: 11]
  ------------------
 2324|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2325|      0|    goto error;
 2326|      0|  }
 2327|       |
 2328|     11|  node->id = pdu->mid;
 2329|     11|  node->pdu = pdu;
 2330|     11|  coap_prng_lkd(&r, sizeof(r));
 2331|       |  /* add timeout in range [ACK_TIMEOUT...ACK_TIMEOUT * ACK_RANDOM_FACTOR] */
 2332|     11|  node->timeout = coap_calc_timeout(session, r);
 2333|     11|  return coap_wait_ack(session->context, session, node);
 2334|      0|error:
 2335|      0|  coap_delete_pdu_lkd(pdu);
 2336|      0|  return COAP_INVALID_MID;
  ------------------
  |  |  187|      0|#define COAP_INVALID_MID -1
  ------------------
 2337|     11|}
coap_startup:
 5455|     36|coap_startup(void) {
 5456|     36|  coap_tick_t now;
 5457|     36|#ifndef WITH_CONTIKI
 5458|     36|  uint64_t us;
 5459|     36|#endif /* !WITH_CONTIKI */
 5460|       |
 5461|     36|  if (coap_started)
  ------------------
  |  Branch (5461:7): [True: 0, False: 36]
  ------------------
 5462|      0|    return;
 5463|     36|  coap_started = 1;
 5464|       |
 5465|       |#if COAP_THREAD_SAFE
 5466|       |  coap_lock_init(&global_lock);
 5467|       |  coap_mutex_init(&m_show_pdu);
 5468|       |  coap_mutex_init(&m_log_impl);
 5469|       |  coap_mutex_init(&m_io_threads);
 5470|       |#endif /* COAP_THREAD_SAFE */
 5471|       |
 5472|       |#if defined(HAVE_WINSOCK2_H)
 5473|       |  WORD wVersionRequested = MAKEWORD(2, 2);
 5474|       |  WSADATA wsaData;
 5475|       |  WSAStartup(wVersionRequested, &wsaData);
 5476|       |#endif
 5477|     36|  coap_clock_init();
 5478|     36|  coap_ticks(&now);
 5479|     36|#ifndef WITH_CONTIKI
 5480|     36|  us = coap_ticks_to_rt_us(now);
 5481|       |  /* Be accurate to the nearest (approx) us */
 5482|     36|  coap_prng_init_lkd((unsigned int)us);
 5483|       |#else /* WITH_CONTIKI */
 5484|       |  coap_start_io_process();
 5485|       |#endif /* WITH_CONTIKI */
 5486|     36|  coap_memory_init();
 5487|     36|  coap_dtls_startup();
 5488|       |#ifdef WITH_LWIP
 5489|       |  coap_io_lwip_init();
 5490|       |#endif /* WITH_LWIP */
 5491|     36|#if COAP_SERVER_SUPPORT
 5492|     36|  static coap_str_const_t well_known = { sizeof(".well-known/core")-1,
 5493|     36|                                         (const uint8_t *)".well-known/core"
 5494|     36|                                       };
 5495|     36|  memset(&resource_uri_wellknown, 0, sizeof(resource_uri_wellknown));
 5496|     36|  resource_uri_wellknown.ref = 1;
 5497|     36|  resource_uri_wellknown.handler[COAP_REQUEST_GET-1] = hnd_get_wellknown_lkd;
 5498|     36|  resource_uri_wellknown.flags = COAP_RESOURCE_FLAGS_HAS_MCAST_SUPPORT;
  ------------------
  |  |   89|     36|#define COAP_RESOURCE_FLAGS_HAS_MCAST_SUPPORT 0x8
  ------------------
 5499|     36|  resource_uri_wellknown.uri_path = &well_known;
 5500|     36|#endif /* COAP_SERVER_SUPPORT */
 5501|     36|  send_recv_terminate = 0;
 5502|     36|  coap_prng_lkd(&coap_unique_id, sizeof(coap_unique_id));
 5503|     36|}
coap_cleanup:
 5506|     36|coap_cleanup(void) {
 5507|     36|  if (!coap_started)
  ------------------
  |  Branch (5507:7): [True: 0, False: 36]
  ------------------
 5508|      0|    return;
 5509|     36|  coap_started = 0;
 5510|       |#if defined(HAVE_WINSOCK2_H)
 5511|       |  WSACleanup();
 5512|       |#elif defined(WITH_CONTIKI)
 5513|       |  coap_stop_io_process();
 5514|       |#endif
 5515|       |#ifdef WITH_LWIP
 5516|       |  coap_io_lwip_cleanup();
 5517|       |#endif /* WITH_LWIP */
 5518|     36|  coap_dtls_shutdown();
 5519|       |
 5520|     36|  coap_delete_upa_chain(coap_upa_client_fallback_chain);
 5521|     36|  coap_upa_client_fallback_chain = NULL;
 5522|     36|  coap_delete_upa_chain(coap_upa_server_mapping_chain);
 5523|     36|  coap_upa_server_mapping_chain = NULL;
 5524|       |#if COAP_THREAD_SAFE
 5525|       |  coap_mutex_destroy(&m_show_pdu);
 5526|       |  coap_mutex_destroy(&m_log_impl);
 5527|       |  coap_mutex_destroy(&m_io_threads);
 5528|       |#endif /* COAP_THREAD_SAFE */
 5529|       |
 5530|     36|  coap_debug_reset();
 5531|     36|}
coap_net.c:coap_free_node:
  118|     11|coap_free_node(coap_queue_t *node) {
  119|     11|  coap_free_type(COAP_NODE, node);
  120|     11|}
coap_net.c:coap_malloc_node:
  113|     11|coap_malloc_node(void) {
  114|     11|  return (coap_queue_t *)coap_malloc_type(COAP_NODE, sizeof(coap_queue_t));
  115|     11|}
coap_net.c:coap_send_pdu:
 1252|     19|coap_send_pdu(coap_session_t *session, coap_pdu_t *pdu, coap_queue_t *node) {
 1253|     19|  ssize_t bytes_written;
 1254|       |
 1255|     19|  if (session->state == COAP_SESSION_STATE_NONE) {
  ------------------
  |  Branch (1255:7): [True: 0, False: 19]
  ------------------
 1256|       |#if ! COAP_CLIENT_SUPPORT
 1257|       |    return -1;
 1258|       |#else /* COAP_CLIENT_SUPPORT */
 1259|      0|    if (session->type != COAP_SESSION_TYPE_CLIENT)
  ------------------
  |  Branch (1259:9): [True: 0, False: 0]
  ------------------
 1260|      0|      return -1;
 1261|      0|#endif /* COAP_CLIENT_SUPPORT */
 1262|      0|  }
 1263|       |
 1264|     19|  if (pdu->type == COAP_MESSAGE_CON &&
  ------------------
  |  Branch (1264:7): [True: 11, False: 8]
  ------------------
 1265|     11|      (session->sock.flags & COAP_SOCKET_NOT_EMPTY) &&
  ------------------
  |  |   75|     11|#define COAP_SOCKET_NOT_EMPTY    0x0001  /**< the socket is not empty */
  ------------------
  |  Branch (1265:7): [True: 11, False: 0]
  ------------------
 1266|     11|      coap_is_mcast(&session->addr_info.remote)) {
  ------------------
  |  Branch (1266:7): [True: 0, False: 11]
  ------------------
 1267|       |    /* Violates RFC72522 8.1 */
 1268|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1269|      0|    return -1;
 1270|      0|  }
 1271|       |
 1272|     19|  if (session->state != COAP_SESSION_STATE_ESTABLISHED ||
  ------------------
  |  Branch (1272:7): [True: 0, False: 19]
  ------------------
 1273|     19|      (pdu->type == COAP_MESSAGE_CON &&
  ------------------
  |  Branch (1273:8): [True: 11, False: 8]
  ------------------
 1274|     11|       session->con_active >= COAP_NSTART(session))) {
  ------------------
  |  |  798|     11|#define COAP_NSTART(s) ((s)->nstart)
  ------------------
  |  Branch (1274:8): [True: 0, False: 11]
  ------------------
 1275|      0|    return coap_session_delay_pdu(session, pdu, node);
 1276|      0|  }
 1277|       |
 1278|     19|  if ((session->sock.flags & COAP_SOCKET_NOT_EMPTY) &&
  ------------------
  |  |   75|     19|#define COAP_SOCKET_NOT_EMPTY    0x0001  /**< the socket is not empty */
  ------------------
  |  Branch (1278:7): [True: 19, False: 0]
  ------------------
 1279|     19|      (session->sock.flags & COAP_SOCKET_WANT_WRITE))
  ------------------
  |  |   79|     19|#define COAP_SOCKET_WANT_WRITE   0x0020  /**< non blocking socket is waiting for writing */
  ------------------
  |  Branch (1279:7): [True: 0, False: 19]
  ------------------
 1280|      0|    return coap_session_delay_pdu(session, pdu, node);
 1281|       |
 1282|     19|  bytes_written = coap_session_send_pdu(session, pdu);
 1283|     19|  if (bytes_written >= 0 && pdu->type == COAP_MESSAGE_CON &&
  ------------------
  |  Branch (1283:7): [True: 19, False: 0]
  |  Branch (1283:29): [True: 11, False: 8]
  ------------------
 1284|     11|      COAP_PROTO_NOT_RELIABLE(session->proto))
  ------------------
  |  |   41|     11|#define COAP_PROTO_NOT_RELIABLE(p) ((p)==COAP_PROTO_UDP || (p)==COAP_PROTO_DTLS)
  |  |  ------------------
  |  |  |  Branch (41:37): [True: 11, False: 0]
  |  |  |  Branch (41:60): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1285|     11|    session->con_active++;
 1286|       |
 1287|     19|  return bytes_written;
 1288|     19|}

coap_netif_available:
   25|     81|coap_netif_available(coap_session_t *session) {
   26|     81|  return session->sock.flags != COAP_SOCKET_EMPTY;
  ------------------
  |  |   74|     81|#define COAP_SOCKET_EMPTY        0x0000  /**< the socket is not used */
  ------------------
   27|     81|}
coap_netif_dgrm_connect:
   54|     62|                        const coap_address_t *server, int default_port) {
   55|     62|  if (!coap_socket_connect_udp(&session->sock, local_if, server,
  ------------------
  |  Branch (55:7): [True: 0, False: 62]
  ------------------
   56|     62|                               default_port,
   57|     62|                               &session->addr_info.local,
   58|     62|                               &session->addr_info.remote)) {
   59|      0|    return 0;
   60|      0|  }
   61|     62|  return 1;
   62|     62|}
coap_netif_dgrm_write:
  128|     19|                      size_t datalen) {
  129|     19|  ssize_t bytes_written;
  130|     19|  int keep_errno;
  131|       |
  132|     19|  coap_socket_t *sock = &session->sock;
  133|     19|#if COAP_SERVER_SUPPORT
  134|     19|  if (sock->flags == COAP_SOCKET_EMPTY) {
  ------------------
  |  |   74|     19|#define COAP_SOCKET_EMPTY        0x0000  /**< the socket is not used */
  ------------------
  |  Branch (134:7): [True: 0, False: 19]
  ------------------
  135|      0|    if (session->endpoint != NULL)
  ------------------
  |  Branch (135:9): [True: 0, False: 0]
  ------------------
  136|      0|      sock = &session->endpoint->sock;
  137|      0|  }
  138|     19|#endif /* COAP_SERVER_SUPPORT */
  139|       |
  140|     19|  bytes_written = coap_socket_send(sock, session, data, datalen);
  141|     19|  keep_errno = errno;
  142|     19|  if (bytes_written <= 0) {
  ------------------
  |  Branch (142:7): [True: 0, False: 19]
  ------------------
  143|      0|    coap_log_debug("*  %s: netif: failed to send % " PRIdS " bytes (%s (%d)) state %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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  144|      0|                   coap_session_str(session), datalen,
  145|      0|                   coap_socket_strerror(), errno, session->state);
  146|      0|    errno = keep_errno;
  147|     19|  } else {
  148|     19|    coap_ticks(&session->last_rx_tx);
  149|     19|    if (bytes_written == (ssize_t)datalen)
  ------------------
  |  Branch (149:9): [True: 19, False: 0]
  ------------------
  150|     19|      coap_log_debug("*  %s: netif: sent %4" PRIdS " bytes\n",
  ------------------
  |  |  126|     19|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|     19|#define coap_log(level, ...) do { \
  |  |  |  |  291|     19|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 19]
  |  |  |  |  ------------------
  |  |  |  |  292|     19|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|     19|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 19]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  151|      0|                     coap_session_str(session), bytes_written);
  152|      0|    else
  153|     19|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  154|     19|                     coap_session_str(session), bytes_written, datalen);
  155|     19|  }
  156|     19|  return bytes_written;
  157|     19|}
coap_netif_dgrm_close:
  160|     62|coap_netif_dgrm_close(coap_session_t *session) {
  161|     62|  if (coap_netif_available(session))
  ------------------
  |  Branch (161:7): [True: 62, False: 0]
  ------------------
  162|     62|    coap_socket_dgrm_close(&session->sock);
  163|     62|}

coap_dtls_is_supported:
  191|     37|coap_dtls_is_supported(void) {
  192|     37|  if (SSLeay() < 0x10100000L) {
  ------------------
  |  Branch (192:7): [True: 0, False: 37]
  ------------------
  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|     37|#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|     37|  if (SSLeay() < 0x10101000L) {
  ------------------
  |  Branch (204:7): [True: 0, False: 37]
  ------------------
  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|     37|#endif /* OPENSSL_VERSION_NUMBER >= 0x10101000L */
  209|     37|  return 1;
  210|     37|}
coap_tls_is_supported:
  213|      5|coap_tls_is_supported(void) {
  214|      5|#if !COAP_DISABLE_TCP
  215|      5|  if (SSLeay() < 0x10100000L) {
  ------------------
  |  Branch (215:7): [True: 0, False: 5]
  ------------------
  216|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  217|      0|    return 0;
  218|      0|  }
  219|      5|#if OPENSSL_VERSION_NUMBER >= 0x10101000L
  220|      5|  if (SSLeay() < 0x10101000L) {
  ------------------
  |  Branch (220:7): [True: 0, False: 5]
  ------------------
  221|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  222|      0|    return 0;
  223|      0|  }
  224|      5|#endif /* OPENSSL_VERSION_NUMBER >= 0x10101000L */
  225|      5|  return 1;
  226|       |#else /* COAP_DISABLE_TCP */
  227|       |  return 0;
  228|       |#endif /* COAP_DISABLE_TCP */
  229|      5|}
coap_dtls_startup:
  304|     36|coap_dtls_startup(void) {
  305|     36|  SSL_load_error_strings();
  306|     36|  SSL_library_init();
  307|     36|#if OPENSSL_VERSION_NUMBER < 0x40000000L
  308|       |  ENGINE_load_dynamic();
  309|     36|#endif /* OPENSSL_VERSION_NUMBER < 0x40000000L */
  310|     36|}
coap_dtls_shutdown:
  313|     36|coap_dtls_shutdown(void) {
  314|     36|#if OPENSSL_VERSION_NUMBER < 0x30000000L
  315|     36|  if (pkcs11_engine) {
  ------------------
  |  Branch (315:7): [True: 0, False: 36]
  ------------------
  316|       |    /* Release the functional reference from ENGINE_init() */
  317|      0|    ENGINE_finish(pkcs11_engine);
  318|      0|    pkcs11_engine = NULL;
  319|      0|  }
  320|     36|  if (defined_engine) {
  ------------------
  |  Branch (320:7): [True: 0, False: 36]
  ------------------
  321|       |    /* Release the functional reference from ENGINE_init() */
  322|      0|    ENGINE_finish(defined_engine);
  323|      0|    defined_engine = NULL;
  324|      0|  }
  325|       |#elif OPENSSL_VERSION_NUMBER < 0x40000000L
  326|       |  pkcs11_engine = NULL;
  327|       |  defined_engine = NULL;
  328|       |#endif /* OPENSSL_VERSION_NUMBER >= 0x30000000L && < 0x40000000L */
  329|       |  ERR_free_strings();
  ------------------
  |  Branch (329:3): [Folded, False: 36]
  ------------------
  330|     36|  coap_dtls_set_log_level(COAP_LOG_EMERG);
  331|     36|}
coap_dtls_set_log_level:
  590|     72|coap_dtls_set_log_level(coap_log_t level) {
  591|     72|  dtls_log_level = level;
  592|     72|}
coap_dtls_new_context:
 1159|     36|coap_dtls_new_context(coap_context_t *coap_context) {
 1160|     36|  coap_openssl_context_t *context;
 1161|     36|  (void)coap_context;
 1162|       |
 1163|     36|  context = (coap_openssl_context_t *)coap_malloc_type(COAP_STRING, sizeof(coap_openssl_context_t));
 1164|     36|  if (context) {
  ------------------
  |  Branch (1164:7): [True: 36, False: 0]
  ------------------
 1165|     36|    uint8_t cookie_secret[32];
 1166|       |
 1167|     36|    memset(context, 0, sizeof(coap_openssl_context_t));
 1168|       |
 1169|       |    /* Set up DTLS context */
 1170|     36|    context->dtls.ctx = SSL_CTX_new(DTLS_method());
 1171|     36|    if (!context->dtls.ctx)
  ------------------
  |  Branch (1171:9): [True: 0, False: 36]
  ------------------
 1172|      0|      goto error;
 1173|     36|    SSL_CTX_set_min_proto_version(context->dtls.ctx, DTLS1_2_VERSION);
 1174|     36|    SSL_CTX_set_app_data(context->dtls.ctx, &context->dtls);
 1175|     36|    SSL_CTX_set_read_ahead(context->dtls.ctx, 1);
 1176|     36|    coap_set_user_prefs(context->dtls.ctx);
 1177|     36|    memset(cookie_secret, 0, sizeof(cookie_secret));
 1178|     36|    if (!RAND_bytes(cookie_secret, (int)sizeof(cookie_secret))) {
  ------------------
  |  Branch (1178:9): [True: 0, False: 36]
  ------------------
 1179|      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]
  |  |  ------------------
  ------------------
 1180|      0|                    "Insufficient entropy for random cookie generation");
 1181|      0|      coap_prng_lkd(cookie_secret, sizeof(cookie_secret));
 1182|      0|    }
 1183|     36|    context->dtls.cookie_hmac = HMAC_CTX_new();
 1184|     36|    if (!context->dtls.cookie_hmac)
  ------------------
  |  Branch (1184:9): [True: 0, False: 36]
  ------------------
 1185|      0|      goto error;
 1186|     36|    if (!HMAC_Init_ex(context->dtls.cookie_hmac, cookie_secret, (int)sizeof(cookie_secret),
  ------------------
  |  Branch (1186:9): [True: 0, False: 36]
  ------------------
 1187|     36|                      EVP_sha256(), NULL))
 1188|      0|      goto error;
 1189|     36|    SSL_CTX_set_cookie_generate_cb(context->dtls.ctx, coap_dtls_generate_cookie);
 1190|     36|    SSL_CTX_set_cookie_verify_cb(context->dtls.ctx, coap_dtls_verify_cookie);
 1191|     36|    SSL_CTX_set_info_callback(context->dtls.ctx, coap_dtls_info_callback);
 1192|     36|    SSL_CTX_set_options(context->dtls.ctx, SSL_OP_NO_QUERY_MTU);
 1193|       |#if OPENSSL_VERSION_NUMBER >= 0x30000000L
 1194|       |    SSL_CTX_set_options(context->dtls.ctx, SSL_OP_LEGACY_SERVER_CONNECT);
 1195|       |#endif /* OPENSSL_VERSION_NUMBER >= 0x30000000L */
 1196|     36|    context->dtls.meth = BIO_meth_new(BIO_TYPE_DGRAM, "coapdgram");
 1197|     36|    if (!context->dtls.meth)
  ------------------
  |  Branch (1197:9): [True: 0, False: 36]
  ------------------
 1198|      0|      goto error;
 1199|     36|    context->dtls.bio_addr = BIO_ADDR_new();
 1200|     36|    if (!context->dtls.bio_addr)
  ------------------
  |  Branch (1200:9): [True: 0, False: 36]
  ------------------
 1201|      0|      goto error;
 1202|     36|    BIO_meth_set_write(context->dtls.meth, coap_dgram_write);
 1203|     36|    BIO_meth_set_read(context->dtls.meth, coap_dgram_read);
 1204|     36|    BIO_meth_set_puts(context->dtls.meth, coap_dgram_puts);
 1205|     36|    BIO_meth_set_ctrl(context->dtls.meth, coap_dgram_ctrl);
 1206|     36|    BIO_meth_set_create(context->dtls.meth, coap_dgram_create);
 1207|     36|    BIO_meth_set_destroy(context->dtls.meth, coap_dgram_destroy);
 1208|       |
 1209|     36|#if !COAP_DISABLE_TCP
 1210|       |    /* Set up TLS context */
 1211|     36|    context->tls.ctx = SSL_CTX_new(TLS_method());
 1212|     36|    if (!context->tls.ctx)
  ------------------
  |  Branch (1212:9): [True: 0, False: 36]
  ------------------
 1213|      0|      goto error;
 1214|     36|    SSL_CTX_set_app_data(context->tls.ctx, &context->tls);
 1215|     36|    SSL_CTX_set_min_proto_version(context->tls.ctx, TLS1_VERSION);
 1216|     36|    coap_set_user_prefs(context->tls.ctx);
 1217|     36|    SSL_CTX_set_info_callback(context->tls.ctx, coap_dtls_info_callback);
 1218|     36|    context->tls.meth = BIO_meth_new(BIO_TYPE_SOCKET, "coapsock");
 1219|     36|    if (!context->tls.meth)
  ------------------
  |  Branch (1219:9): [True: 0, False: 36]
  ------------------
 1220|      0|      goto error;
 1221|     36|    BIO_meth_set_write(context->tls.meth, coap_sock_write);
 1222|     36|    BIO_meth_set_read(context->tls.meth, coap_sock_read);
 1223|     36|    BIO_meth_set_puts(context->tls.meth, coap_sock_puts);
 1224|     36|    BIO_meth_set_ctrl(context->tls.meth, coap_sock_ctrl);
 1225|     36|    BIO_meth_set_create(context->tls.meth, coap_sock_create);
 1226|     36|    BIO_meth_set_destroy(context->tls.meth, coap_sock_destroy);
 1227|     36|#endif /* !COAP_DISABLE_TCP */
 1228|     36|  }
 1229|       |
 1230|     36|  return context;
 1231|       |
 1232|      0|error:
 1233|      0|  coap_dtls_free_context(context);
 1234|       |  return NULL;
 1235|     36|}
coap_dtls_free_context:
 3366|     36|coap_dtls_free_context(void *handle) {
 3367|     36|  size_t i;
 3368|     36|  coap_openssl_context_t *context = (coap_openssl_context_t *)handle;
 3369|       |
 3370|     36|  if (context->dtls.ssl)
  ------------------
  |  Branch (3370:7): [True: 0, False: 36]
  ------------------
 3371|      0|    SSL_free(context->dtls.ssl);
 3372|     36|  if (context->dtls.ctx)
  ------------------
  |  Branch (3372:7): [True: 36, False: 0]
  ------------------
 3373|     36|    SSL_CTX_free(context->dtls.ctx);
 3374|     36|  if (context->dtls.cookie_hmac)
  ------------------
  |  Branch (3374:7): [True: 36, False: 0]
  ------------------
 3375|     36|    HMAC_CTX_free(context->dtls.cookie_hmac);
 3376|     36|  if (context->dtls.meth)
  ------------------
  |  Branch (3376:7): [True: 36, False: 0]
  ------------------
 3377|     36|    BIO_meth_free(context->dtls.meth);
 3378|     36|  if (context->dtls.bio_addr)
  ------------------
  |  Branch (3378:7): [True: 36, False: 0]
  ------------------
 3379|     36|    BIO_ADDR_free(context->dtls.bio_addr);
 3380|     36|#if !COAP_DISABLE_TCP
 3381|     36|  if (context->tls.ctx)
  ------------------
  |  Branch (3381:7): [True: 36, False: 0]
  ------------------
 3382|     36|    SSL_CTX_free(context->tls.ctx);
 3383|     36|  if (context->tls.meth)
  ------------------
  |  Branch (3383:7): [True: 36, False: 0]
  ------------------
 3384|     36|    BIO_meth_free(context->tls.meth);
 3385|     36|#endif /* !COAP_DISABLE_TCP */
 3386|     36|  for (i = 0; i < context->sni_count; i++) {
  ------------------
  |  Branch (3386:15): [True: 0, False: 36]
  ------------------
 3387|      0|    OPENSSL_free(context->sni_entry_list[i].sni);
 3388|       |#if OPENSSL_VERSION_NUMBER < 0x10101000L
 3389|       |    SSL_CTX_free(context->sni_entry_list[i].ctx);
 3390|       |#endif /* OPENSSL_VERSION_NUMBER < 0x10101000L */
 3391|      0|  }
 3392|     36|  if (context->sni_count)
  ------------------
  |  Branch (3392:7): [True: 0, False: 36]
  ------------------
 3393|     36|    OPENSSL_free(context->sni_entry_list);
 3394|       |#if OPENSSL_VERSION_NUMBER < 0x10101000L
 3395|       |  for (i = 0; i < context->psk_sni_count; i++) {
 3396|       |    OPENSSL_free((char *)context->psk_sni_entry_list[i].sni);
 3397|       |    SSL_CTX_free(context->psk_sni_entry_list[i].ctx);
 3398|       |  }
 3399|       |  if (context->psk_sni_count)
 3400|       |    OPENSSL_free(context->psk_sni_entry_list);
 3401|       |#endif /* OPENSSL_VERSION_NUMBER < 0x10101000L */
 3402|     36|  coap_free_type(COAP_STRING, context);
 3403|     36|}
coap_openssl.c:coap_set_user_prefs:
 1132|     72|coap_set_user_prefs(SSL_CTX *ctx) {
 1133|     72|  SSL_CTX_set_cipher_list(ctx, COAP_OPENSSL_CIPHERS);
  ------------------
  |  |  119|     72|#define COAP_OPENSSL_CIPHERS "TLSv1.3:TLSv1.2:!NULL"
  ------------------
 1134|       |
 1135|       |#ifdef COAP_OPENSSL_SIGALGS
 1136|       |  SSL_CTX_set1_sigalgs_list(ctx, COAP_OPENSSL_SIGALGS);
 1137|       |  SSL_CTX_set1_client_sigalgs_list(ctx, COAP_OPENSSL_SIGALGS);
 1138|       |#endif
 1139|       |
 1140|       |#if OPENSSL_VERSION_NUMBER >= 0x10101000L && defined(COAP_OPENSSL_GROUPS)
 1141|       |  SSL_CTX_set1_groups_list(ctx, COAP_OPENSSL_GROUPS);
 1142|       |#endif
 1143|     72|}

coap_opt_parse:
   41|    490|coap_opt_parse(const coap_opt_t *opt, size_t length, coap_option_t *result) {
   42|       |
   43|    490|  const coap_opt_t *opt_start = opt; /* store where parsing starts  */
   44|       |
   45|    490|  assert(opt);
  ------------------
  |  Branch (45:3): [True: 490, False: 0]
  ------------------
   46|    490|  assert(result);
  ------------------
  |  Branch (46:3): [True: 490, False: 0]
  ------------------
   47|       |
   48|    490|  if (length < 1)
  ------------------
  |  Branch (48:7): [True: 64, False: 426]
  ------------------
   49|     64|    return 0;
   50|       |
   51|    426|  result->delta = (*opt & 0xf0) >> 4;
   52|    426|  result->length = *opt & 0x0f;
   53|       |
   54|    426|  switch (result->delta) {
   55|      2|  case 15:
  ------------------
  |  Branch (55:3): [True: 2, False: 424]
  ------------------
   56|      2|    if (*opt != COAP_PAYLOAD_START) {
  ------------------
  |  |   96|      2|#define COAP_PAYLOAD_START 0xFF /* payload marker */
  ------------------
  |  Branch (56:9): [True: 0, False: 2]
  ------------------
   57|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   58|      0|    }
   59|      2|    return 0;
   60|      0|  case 14:
  ------------------
  |  Branch (60:3): [True: 0, False: 426]
  ------------------
   61|       |    /* Handle two-byte value: First, the MSB + 269 is stored as delta value.
   62|       |     * After that, the option pointer is advanced to the LSB which is handled
   63|       |     * just like case delta == 13. */
   64|      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]
  |  |  ------------------
  ------------------
   65|      0|    result->delta = ((*opt & 0xff) << 8) + 269;
   66|      0|    if (result->delta < 269) {
  ------------------
  |  Branch (66:9): [True: 0, False: 0]
  ------------------
   67|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   68|      0|      return 0;
   69|      0|    }
   70|       |  /* fall through */
   71|     49|  case 13:
  ------------------
  |  Branch (71:3): [True: 49, False: 377]
  ------------------
   72|     49|    ADVANCE_OPT_CHECK(opt,length,1);
  ------------------
  |  |   34|     49|#define ADVANCE_OPT_CHECK(o,e,step) do { \
  |  |   35|     49|    ADVANCE_OPT(o,e,step);               \
  |  |  ------------------
  |  |  |  |   22|     49|#define ADVANCE_OPT(o,e,step) if ((e) < step) {           \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (22:35): [True: 0, False: 49]
  |  |  |  |  ------------------
  |  |  |  |   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|     49|  } else {                                                \
  |  |  |  |   26|     49|    (e) -= step;                                          \
  |  |  |  |   27|     49|    (o) = ((o)) + step;                                   \
  |  |  |  |   28|     49|  }
  |  |  ------------------
  |  |   36|     49|    if ((e) < 1)                         \
  |  |  ------------------
  |  |  |  Branch (36:9): [True: 0, False: 49]
  |  |  ------------------
  |  |   37|     49|      return 0;                          \
  |  |   38|     49|  } while (0)
  |  |  ------------------
  |  |  |  Branch (38:12): [Folded, False: 49]
  |  |  ------------------
  ------------------
   73|     49|    result->delta += *opt & 0xff;
   74|     49|    break;
   75|       |
   76|    375|  default:
  ------------------
  |  Branch (76:3): [True: 375, False: 51]
  ------------------
   77|    375|    ;
   78|    426|  }
   79|       |
   80|    424|  switch (result->length) {
   81|      0|  case 15:
  ------------------
  |  Branch (81:3): [True: 0, False: 424]
  ------------------
   82|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   83|      0|    return 0;
   84|      0|  case 14:
  ------------------
  |  Branch (84:3): [True: 0, False: 424]
  ------------------
   85|       |    /* Handle two-byte value: First, the MSB + 269 is stored as delta value.
   86|       |     * After that, the option pointer is advanced to the LSB which is handled
   87|       |     * just like case delta == 13. */
   88|      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]
  |  |  ------------------
  ------------------
   89|      0|    result->length = ((*opt & 0xff) << 8) + 269;
   90|       |  /* fall through */
   91|    243|  case 13:
  ------------------
  |  Branch (91:3): [True: 243, False: 181]
  ------------------
   92|    243|    ADVANCE_OPT_CHECK(opt,length,1);
  ------------------
  |  |   34|    243|#define ADVANCE_OPT_CHECK(o,e,step) do { \
  |  |   35|    243|    ADVANCE_OPT(o,e,step);               \
  |  |  ------------------
  |  |  |  |   22|    243|#define ADVANCE_OPT(o,e,step) if ((e) < step) {           \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (22:35): [True: 0, False: 243]
  |  |  |  |  ------------------
  |  |  |  |   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|    243|  } else {                                                \
  |  |  |  |   26|    243|    (e) -= step;                                          \
  |  |  |  |   27|    243|    (o) = ((o)) + step;                                   \
  |  |  |  |   28|    243|  }
  |  |  ------------------
  |  |   36|    243|    if ((e) < 1)                         \
  |  |  ------------------
  |  |  |  Branch (36:9): [True: 0, False: 243]
  |  |  ------------------
  |  |   37|    243|      return 0;                          \
  |  |   38|    243|  } while (0)
  |  |  ------------------
  |  |  |  Branch (38:12): [Folded, False: 243]
  |  |  ------------------
  ------------------
   93|    243|    result->length += *opt & 0xff;
   94|    243|    break;
   95|       |
   96|    181|  default:
  ------------------
  |  Branch (96:3): [True: 181, False: 243]
  ------------------
   97|    181|    ;
   98|    424|  }
   99|       |
  100|       |  /* ADVANCE_OPT() is correct here */
  101|    424|  ADVANCE_OPT(opt,length,1);
  ------------------
  |  |   22|    424|#define ADVANCE_OPT(o,e,step) if ((e) < step) {           \
  |  |  ------------------
  |  |  |  Branch (22:35): [True: 0, False: 424]
  |  |  ------------------
  |  |   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|    424|  } else {                                                \
  |  |   26|    424|    (e) -= step;                                          \
  |  |   27|    424|    (o) = ((o)) + step;                                   \
  |  |   28|    424|  }
  ------------------
  102|       |  /* opt now points to value, if present */
  103|       |
  104|    424|  result->value = opt;
  105|    424|  if (length < result->length) {
  ------------------
  |  Branch (105:7): [True: 0, False: 424]
  ------------------
  106|      0|    coap_log_debug("invalid 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  107|      0|    return 0;
  108|      0|  }
  109|       |
  110|    424|#undef ADVANCE_OPT
  111|    424|#undef ADVANCE_OPT_CHECK
  112|       |
  113|    424|  return (opt + result->length) - opt_start;
  114|    424|}
coap_option_iterator_init:
  118|    103|                          const coap_opt_filter_t *filter) {
  119|    103|  assert(pdu);
  ------------------
  |  Branch (119:3): [True: 103, False: 0]
  ------------------
  120|    103|  assert(pdu->token);
  ------------------
  |  Branch (120:3): [True: 103, False: 0]
  ------------------
  121|    103|  assert(oi);
  ------------------
  |  Branch (121:3): [True: 103, False: 0]
  ------------------
  122|       |
  123|    103|  memset(oi, 0, sizeof(coap_opt_iterator_t));
  124|       |
  125|    103|  oi->next_option = pdu->token + pdu->e_token_length;
  126|    103|  if (pdu->token + pdu->used_size <= oi->next_option) {
  ------------------
  |  Branch (126:7): [True: 0, False: 103]
  ------------------
  127|      0|    oi->bad = 1;
  128|      0|    return NULL;
  129|      0|  }
  130|       |
  131|    103|  oi->length = pdu->used_size - pdu->e_token_length;
  132|       |
  133|    103|  if (filter) {
  ------------------
  |  Branch (133:7): [True: 76, False: 27]
  ------------------
  134|     76|    memcpy(&oi->filter, filter, sizeof(coap_opt_filter_t));
  135|     76|    oi->filtered = 1;
  136|     76|  }
  137|    103|  return oi;
  138|    103|}
coap_option_next:
  153|    211|coap_option_next(coap_opt_iterator_t *oi) {
  154|    211|  coap_option_t option;
  155|    211|  coap_opt_t *current_opt = NULL;
  156|    211|  size_t optsize;
  157|       |
  158|    211|  assert(oi);
  ------------------
  |  Branch (158:3): [True: 211, False: 0]
  ------------------
  159|       |
  160|    211|  if (opt_finished(oi))
  ------------------
  |  Branch (160:7): [True: 10, False: 201]
  ------------------
  161|     10|    return NULL;
  162|       |
  163|    485|  while (1) {
  ------------------
  |  Branch (163:10): [True: 485, Folded]
  ------------------
  164|       |    /* oi->next_option always points to the next option to deliver; as
  165|       |     * opt_finished() filters out any bad conditions, we can assume that
  166|       |     * oi->next_option is valid. */
  167|    485|    current_opt = oi->next_option;
  168|       |
  169|       |    /*
  170|       |     * Advance internal pointer to next option.
  171|       |     * optsize will be 0 when no more options
  172|       |     */
  173|    485|    optsize = coap_opt_parse(oi->next_option, oi->length, &option);
  174|    485|    if (optsize) {
  ------------------
  |  Branch (174:9): [True: 419, False: 66]
  ------------------
  175|    419|      assert(optsize <= oi->length);
  ------------------
  |  Branch (175:7): [True: 419, False: 0]
  ------------------
  176|       |
  177|    419|      oi->next_option += optsize;
  178|    419|      oi->length -= optsize;
  179|       |
  180|    419|      oi->number += option.delta;
  181|    419|    } else {                        /* current option is malformed */
  182|     66|      oi->bad = 1;
  183|     66|      return NULL;
  184|     66|    }
  185|       |
  186|       |    /* Exit the while loop when:
  187|       |     *   - no filtering is done at all
  188|       |     *   - the filter matches for the current option
  189|       |     */
  190|    419|    if (!oi->filtered ||
  ------------------
  |  Branch (190:9): [True: 125, False: 294]
  ------------------
  191|    294|        coap_option_filter_get(&oi->filter, oi->number) > 0)
  ------------------
  |  Branch (191:9): [True: 10, False: 284]
  ------------------
  192|    135|      break;
  193|    419|  }
  194|       |
  195|    135|  return current_opt;
  196|    201|}
coap_check_option:
  200|     76|                  coap_opt_iterator_t *oi) {
  201|     76|  coap_opt_filter_t f;
  202|       |
  203|     76|  coap_option_filter_clear(&f);
  204|     76|  coap_option_filter_set(&f, number);
  205|       |
  206|     76|  coap_option_iterator_init(pdu, oi, &f);
  207|       |
  208|     76|  return coap_option_next(oi);
  209|     76|}
coap_opt_length:
  212|     43|coap_opt_length(const coap_opt_t *opt) {
  213|     43|  uint32_t length;
  214|       |
  215|     43|  length = *opt & 0x0f;
  216|     43|  switch (*opt & 0xf0) {
  217|      0|  case 0xf0:
  ------------------
  |  Branch (217:3): [True: 0, False: 43]
  ------------------
  218|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  219|      0|    return 0;
  220|      0|  case 0xe0:
  ------------------
  |  Branch (220:3): [True: 0, False: 43]
  ------------------
  221|      0|    ++opt;
  222|       |  /* fall through */
  223|       |  /* to skip another byte */
  224|     12|  case 0xd0:
  ------------------
  |  Branch (224:3): [True: 12, False: 31]
  ------------------
  225|     12|    ++opt;
  226|       |  /* fall through */
  227|       |  /* to skip another byte */
  228|     43|  default:
  ------------------
  |  Branch (228:3): [True: 31, False: 12]
  ------------------
  229|     43|    ++opt;
  230|     43|  }
  231|       |
  232|     43|  switch (length) {
  233|      0|  case 0x0f:
  ------------------
  |  Branch (233:3): [True: 0, False: 43]
  ------------------
  234|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  235|      0|    return 0;
  236|      0|  case 0x0e:
  ------------------
  |  Branch (236:3): [True: 0, False: 43]
  ------------------
  237|      0|    length = (*opt++ << 8) + 269;
  238|       |  /* fall through */
  239|     29|  case 0x0d:
  ------------------
  |  Branch (239:3): [True: 29, False: 14]
  ------------------
  240|     29|    length += *opt++;
  241|     29|    break;
  242|     14|  default:
  ------------------
  |  Branch (242:3): [True: 14, False: 29]
  ------------------
  243|     14|    ;
  244|     43|  }
  245|     43|  return length;
  246|     43|}
coap_opt_value:
  249|     43|coap_opt_value(const coap_opt_t *opt) {
  250|     43|  size_t ofs = 1;
  251|       |
  252|     43|  switch (*opt & 0xf0) {
  253|      0|  case 0xf0:
  ------------------
  |  Branch (253:3): [True: 0, False: 43]
  ------------------
  254|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  255|      0|    return 0;
  256|      0|  case 0xe0:
  ------------------
  |  Branch (256:3): [True: 0, False: 43]
  ------------------
  257|      0|    ++ofs;
  258|       |  /* fall through */
  259|     12|  case 0xd0:
  ------------------
  |  Branch (259:3): [True: 12, False: 31]
  ------------------
  260|     12|    ++ofs;
  261|     12|    break;
  262|     31|  default:
  ------------------
  |  Branch (262:3): [True: 31, False: 12]
  ------------------
  263|     31|    ;
  264|     43|  }
  265|       |
  266|     43|  switch (*opt & 0x0f) {
  267|      0|  case 0x0f:
  ------------------
  |  Branch (267:3): [True: 0, False: 43]
  ------------------
  268|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  269|      0|    return 0;
  270|      0|  case 0x0e:
  ------------------
  |  Branch (270:3): [True: 0, False: 43]
  ------------------
  271|      0|    ++ofs;
  272|       |  /* fall through */
  273|     29|  case 0x0d:
  ------------------
  |  Branch (273:3): [True: 29, False: 14]
  ------------------
  274|     29|    ++ofs;
  275|     29|    break;
  276|     14|  default:
  ------------------
  |  Branch (276:3): [True: 14, False: 29]
  ------------------
  277|     14|    ;
  278|     43|  }
  279|       |
  280|     43|  return (const uint8_t *)opt + ofs;
  281|     43|}
coap_opt_setheader:
  293|    160|                   uint16_t delta, size_t length) {
  294|    160|  size_t skip = 0;
  295|       |
  296|    160|  assert(opt);
  ------------------
  |  Branch (296:3): [True: 160, False: 0]
  ------------------
  297|       |
  298|    160|  if (maxlen == 0)                /* need at least one byte */
  ------------------
  |  Branch (298:7): [True: 0, False: 160]
  ------------------
  299|      0|    return 0;
  300|       |
  301|    160|  if (delta < 13) {
  ------------------
  |  Branch (301:7): [True: 136, False: 24]
  ------------------
  302|    136|    opt[0] = (coap_opt_t)(delta << 4);
  303|    136|  } else if (delta < 269) {
  ------------------
  |  Branch (303:14): [True: 24, False: 0]
  ------------------
  304|     24|    if (maxlen < 2) {
  ------------------
  |  Branch (304:9): [True: 0, False: 24]
  ------------------
  305|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  306|      0|                     delta);
  307|      0|      return 0;
  308|      0|    }
  309|       |
  310|     24|    opt[0] = 0xd0;
  311|     24|    opt[++skip] = (coap_opt_t)(delta - 13);
  312|     24|  } else {
  313|      0|    if (maxlen < 3) {
  ------------------
  |  Branch (313:9): [True: 0, False: 0]
  ------------------
  314|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  315|      0|                     delta);
  316|      0|      return 0;
  317|      0|    }
  318|       |
  319|      0|    opt[0] = 0xe0;
  320|      0|    opt[++skip] = ((delta - 269) >> 8) & 0xff;
  321|      0|    opt[++skip] = (delta - 269) & 0xff;
  322|      0|  }
  323|       |
  324|    160|  if (length < 13) {
  ------------------
  |  Branch (324:7): [True: 75, False: 85]
  ------------------
  325|     75|    opt[0] |= length & 0x0f;
  326|     85|  } else if (length < 269) {
  ------------------
  |  Branch (326:14): [True: 85, False: 0]
  ------------------
  327|     85|    if (maxlen < skip + 2) {
  ------------------
  |  Branch (327:9): [True: 0, False: 85]
  ------------------
  328|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  329|      0|                     length);
  330|      0|      return 0;
  331|      0|    }
  332|       |
  333|     85|    opt[0] |= 0x0d;
  334|     85|    opt[++skip] = (coap_opt_t)(length - 13);
  335|     85|  } else {
  336|      0|    if (maxlen < skip + 3) {
  ------------------
  |  Branch (336:9): [True: 0, False: 0]
  ------------------
  337|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  338|      0|                     delta);
  339|      0|      return 0;
  340|      0|    }
  341|       |
  342|      0|    opt[0] |= 0x0e;
  343|      0|    opt[++skip] = ((length - 269) >> 8) & 0xff;
  344|      0|    opt[++skip] = (length - 269) & 0xff;
  345|      0|  }
  346|       |
  347|    160|  return skip + 1;
  348|    160|}
coap_opt_encode_size:
  351|    160|coap_opt_encode_size(uint16_t delta, size_t length) {
  352|    160|  size_t n = 1;
  353|       |
  354|    160|  if (delta >= 13) {
  ------------------
  |  Branch (354:7): [True: 24, False: 136]
  ------------------
  355|     24|    if (delta < 269)
  ------------------
  |  Branch (355:9): [True: 24, False: 0]
  ------------------
  356|     24|      n += 1;
  357|      0|    else
  358|      0|      n += 2;
  359|     24|  }
  360|       |
  361|    160|  if (length >= 13) {
  ------------------
  |  Branch (361:7): [True: 85, False: 75]
  ------------------
  362|     85|    if (length < 269)
  ------------------
  |  Branch (362:9): [True: 85, False: 0]
  ------------------
  363|     85|      n += 1;
  364|      0|    else
  365|      0|      n += 2;
  366|     85|  }
  367|       |
  368|    160|  return n + length;
  369|    160|}
coap_opt_encode:
  373|    160|                const uint8_t *val, size_t length) {
  374|    160|  size_t l = 1;
  375|       |
  376|    160|  l = coap_opt_setheader(opt, maxlen, delta, length);
  377|    160|  assert(l <= maxlen);
  ------------------
  |  Branch (377:3): [True: 160, False: 0]
  ------------------
  378|       |
  379|    160|  if (!l) {
  ------------------
  |  Branch (379:7): [True: 0, False: 160]
  ------------------
  380|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  381|      0|    return 0;
  382|      0|  }
  383|       |
  384|    160|  maxlen -= l;
  385|    160|  opt += l;
  386|       |
  387|    160|  if (maxlen < length) {
  ------------------
  |  Branch (387:7): [True: 0, False: 160]
  ------------------
  388|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  389|      0|    return 0;
  390|      0|  }
  391|       |
  392|    160|  if (val)                        /* better be safe here */
  ------------------
  |  Branch (392:7): [True: 160, False: 0]
  ------------------
  393|    160|    memcpy(opt, val, length);
  394|       |
  395|    160|  return l + length;
  396|    160|}
coap_option_filter_clear:
  491|     76|coap_option_filter_clear(coap_opt_filter_t *filter) {
  492|     76|  memset(filter, 0, sizeof(coap_opt_filter_t));
  493|     76|}
coap_option_filter_set:
  496|     76|coap_option_filter_set(coap_opt_filter_t *filter, coap_option_num_t option) {
  497|     76|  return coap_option_filter_op(filter, option, FILTER_SET);
  498|     76|}
coap_option_filter_get:
  506|    294|coap_option_filter_get(coap_opt_filter_t *filter, coap_option_num_t option) {
  507|    294|  return coap_option_filter_op(filter, option, FILTER_GET);
  508|    294|}
coap_new_optlist:
  513|     43|                 const uint8_t *data) {
  514|     43|  coap_optlist_t *node;
  515|       |
  516|     43|  if (!coap_pdu_parse_opt_base(number, length, data)) {
  ------------------
  |  Branch (516:7): [True: 0, False: 43]
  ------------------
  517|      0|    coap_log_warn("coap_new_optlist: %d: Invalid option length / data\n", number);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  518|      0|    return NULL;
  519|      0|  }
  520|       |#if defined(WITH_LWIP) && MEMP_USE_CUSTOM_POOLS
  521|       |  if (length > MEMP_LEN_COAPOPTLIST) {
  522|       |    coap_log_crit("coap_new_optlist: size too large (%" PRIuS " > MEMP_LEN_COAPOPTLIST)\n",
  523|       |                  length);
  524|       |    return NULL;
  525|       |  }
  526|       |#endif /* WITH_LWIP && MEMP_USE_CUSTOM_POOLS */
  527|     43|  node = coap_malloc_type(COAP_OPTLIST, sizeof(coap_optlist_t) + length);
  528|       |
  529|     43|  if (node) {
  ------------------
  |  Branch (529:7): [True: 43, False: 0]
  ------------------
  530|     43|    memset(node, 0, (sizeof(coap_optlist_t) + length));
  531|     43|    node->number = number;
  532|     43|    node->length = length;
  533|     43|    node->data = (uint8_t *)&node[1];
  534|     43|    memcpy(node->data, data, length);
  535|     43|  } else {
  536|      0|    coap_log_warn("coap_new_optlist: malloc failure\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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  537|      0|  }
  538|       |
  539|     43|  return node;
  540|     43|}
coap_add_optlist_pdu:
  554|     10|coap_add_optlist_pdu(coap_pdu_t *pdu, coap_optlist_t **options) {
  555|     10|  coap_optlist_t *opt;
  556|       |
  557|     10|  if (options && *options) {
  ------------------
  |  Branch (557:7): [True: 10, False: 0]
  |  Branch (557:18): [True: 3, False: 7]
  ------------------
  558|      3|    if (pdu->data) {
  ------------------
  |  Branch (558:9): [True: 0, False: 3]
  ------------------
  559|      0|      coap_log_warn("coap_add_optlist_pdu: 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  560|      0|      return 0;
  561|      0|    }
  562|       |    /* sort options for delta encoding */
  563|      3|    LL_SORT((*options), order_opts);
  ------------------
  |  |  114|      3|    LL_SORT2(list, cmp, next)
  |  |  ------------------
  |  |  |  |  116|      3|#define LL_SORT2(list, cmp, next)                                                              \
  |  |  |  |  117|      3|do {                                                                                           \
  |  |  |  |  118|      3|  LDECLTYPE(list) _ls_p;                                                                       \
  |  |  |  |  ------------------
  |  |  |  |  |  |   81|      3|#define LDECLTYPE(x) __typeof(x)
  |  |  |  |  ------------------
  |  |  |  |  119|      3|  LDECLTYPE(list) _ls_q;                                                                       \
  |  |  |  |  ------------------
  |  |  |  |  |  |   81|      3|#define LDECLTYPE(x) __typeof(x)
  |  |  |  |  ------------------
  |  |  |  |  120|      3|  LDECLTYPE(list) _ls_e;                                                                       \
  |  |  |  |  ------------------
  |  |  |  |  |  |   81|      3|#define LDECLTYPE(x) __typeof(x)
  |  |  |  |  ------------------
  |  |  |  |  121|      3|  LDECLTYPE(list) _ls_tail;                                                                    \
  |  |  |  |  ------------------
  |  |  |  |  |  |   81|      3|#define LDECLTYPE(x) __typeof(x)
  |  |  |  |  ------------------
  |  |  |  |  122|      3|  IF_NO_DECLTYPE(LDECLTYPE(list) _tmp;)                                                        \
  |  |  |  |  123|      3|  int _ls_insize, _ls_nmerges, _ls_psize, _ls_qsize, _ls_i, _ls_looping;                       \
  |  |  |  |  124|      3|  if (list) {                                                                                  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (124:7): [True: 3, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  125|      3|    _ls_insize = 1;                                                                            \
  |  |  |  |  126|      3|    _ls_looping = 1;                                                                           \
  |  |  |  |  127|     11|    while (_ls_looping) {                                                                      \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (127:12): [True: 8, False: 3]
  |  |  |  |  ------------------
  |  |  |  |  128|      8|      UTLIST_CASTASGN(_ls_p,list);                                                             \
  |  |  |  |  ------------------
  |  |  |  |  |  |  106|      8|#define UTLIST_CASTASGN(a,b) (a)=(b)
  |  |  |  |  ------------------
  |  |  |  |  129|      8|      (list) = NULL;                                                                           \
  |  |  |  |  130|      8|      _ls_tail = NULL;                                                                         \
  |  |  |  |  131|      8|      _ls_nmerges = 0;                                                                         \
  |  |  |  |  132|     27|      while (_ls_p) {                                                                          \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (132:14): [True: 19, False: 8]
  |  |  |  |  ------------------
  |  |  |  |  133|     19|        _ls_nmerges++;                                                                         \
  |  |  |  |  134|     19|        _ls_q = _ls_p;                                                                         \
  |  |  |  |  135|     19|        _ls_psize = 0;                                                                         \
  |  |  |  |  136|     54|        for (_ls_i = 0; _ls_i < _ls_insize; _ls_i++) {                                         \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (136:25): [True: 38, False: 16]
  |  |  |  |  ------------------
  |  |  |  |  137|     38|          _ls_psize++;                                                                         \
  |  |  |  |  138|     38|          UTLIST_SV(_ls_q,list); _ls_q = UTLIST_NEXT(_ls_q,list,next); UTLIST_RS(list);        \
  |  |  |  |  ------------------
  |  |  |  |  |  |  101|     38|#define UTLIST_NEXT(elt,list,next) ((elt)->next)
  |  |  |  |  ------------------
  |  |  |  |  139|     38|          if (!_ls_q) break;                                                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (139:15): [True: 3, False: 35]
  |  |  |  |  ------------------
  |  |  |  |  140|     38|        }                                                                                      \
  |  |  |  |  141|     19|        _ls_qsize = _ls_insize;                                                                \
  |  |  |  |  142|     82|        while (_ls_psize > 0 || (_ls_qsize > 0 && _ls_q)) {                                    \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (142:16): [True: 49, False: 33]
  |  |  |  |  |  Branch (142:34): [True: 20, False: 13]
  |  |  |  |  |  Branch (142:51): [True: 14, False: 6]
  |  |  |  |  ------------------
  |  |  |  |  143|     63|          if (_ls_psize == 0) {                                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (143:15): [True: 14, False: 49]
  |  |  |  |  ------------------
  |  |  |  |  144|     14|            _ls_e = _ls_q; UTLIST_SV(_ls_q,list); _ls_q =                                      \
  |  |  |  |  145|     14|              UTLIST_NEXT(_ls_q,list,next); UTLIST_RS(list); _ls_qsize--;                      \
  |  |  |  |  ------------------
  |  |  |  |  |  |  101|     14|#define UTLIST_NEXT(elt,list,next) ((elt)->next)
  |  |  |  |  ------------------
  |  |  |  |  146|     49|          } else if (_ls_qsize == 0 || !_ls_q) {                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:22): [True: 3, False: 46]
  |  |  |  |  |  Branch (146:40): [True: 7, False: 39]
  |  |  |  |  ------------------
  |  |  |  |  147|     10|            _ls_e = _ls_p; UTLIST_SV(_ls_p,list); _ls_p =                                      \
  |  |  |  |  148|     10|              UTLIST_NEXT(_ls_p,list,next); UTLIST_RS(list); _ls_psize--;                      \
  |  |  |  |  ------------------
  |  |  |  |  |  |  101|     10|#define UTLIST_NEXT(elt,list,next) ((elt)->next)
  |  |  |  |  ------------------
  |  |  |  |  149|     39|          } else if (cmp(_ls_p,_ls_q) <= 0) {                                                  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (149:22): [True: 28, False: 11]
  |  |  |  |  ------------------
  |  |  |  |  150|     28|            _ls_e = _ls_p; UTLIST_SV(_ls_p,list); _ls_p =                                      \
  |  |  |  |  151|     28|              UTLIST_NEXT(_ls_p,list,next); UTLIST_RS(list); _ls_psize--;                      \
  |  |  |  |  ------------------
  |  |  |  |  |  |  101|     28|#define UTLIST_NEXT(elt,list,next) ((elt)->next)
  |  |  |  |  ------------------
  |  |  |  |  152|     28|          } else {                                                                             \
  |  |  |  |  153|     11|            _ls_e = _ls_q; UTLIST_SV(_ls_q,list); _ls_q =                                      \
  |  |  |  |  154|     11|              UTLIST_NEXT(_ls_q,list,next); UTLIST_RS(list); _ls_qsize--;                      \
  |  |  |  |  ------------------
  |  |  |  |  |  |  101|     11|#define UTLIST_NEXT(elt,list,next) ((elt)->next)
  |  |  |  |  ------------------
  |  |  |  |  155|     11|          }                                                                                    \
  |  |  |  |  156|     63|          if (_ls_tail) {                                                                      \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:15): [True: 55, False: 8]
  |  |  |  |  ------------------
  |  |  |  |  157|     55|            UTLIST_SV(_ls_tail,list); UTLIST_NEXTASGN(_ls_tail,list,_ls_e,next); UTLIST_RS(list); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  102|     55|#define UTLIST_NEXTASGN(elt,list,to,next) ((elt)->next)=(to)
  |  |  |  |  ------------------
  |  |  |  |  158|     55|          } else {                                                                             \
  |  |  |  |  159|      8|            UTLIST_CASTASGN(list,_ls_e);                                                       \
  |  |  |  |  ------------------
  |  |  |  |  |  |  106|      8|#define UTLIST_CASTASGN(a,b) (a)=(b)
  |  |  |  |  ------------------
  |  |  |  |  160|      8|          }                                                                                    \
  |  |  |  |  161|     63|          _ls_tail = _ls_e;                                                                    \
  |  |  |  |  162|     63|        }                                                                                      \
  |  |  |  |  163|     19|        _ls_p = _ls_q;                                                                         \
  |  |  |  |  164|     19|      }                                                                                        \
  |  |  |  |  165|      8|      if (_ls_tail) {                                                                          \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (165:11): [True: 8, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  166|      8|        UTLIST_SV(_ls_tail,list); UTLIST_NEXTASGN(_ls_tail,list,NULL,next); UTLIST_RS(list);   \
  |  |  |  |  ------------------
  |  |  |  |  |  |  102|      8|#define UTLIST_NEXTASGN(elt,list,to,next) ((elt)->next)=(to)
  |  |  |  |  ------------------
  |  |  |  |  167|      8|      }                                                                                        \
  |  |  |  |  168|      8|      if (_ls_nmerges <= 1) {                                                                  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:11): [True: 3, False: 5]
  |  |  |  |  ------------------
  |  |  |  |  169|      3|        _ls_looping=0;                                                                         \
  |  |  |  |  170|      3|      }                                                                                        \
  |  |  |  |  171|      8|      _ls_insize *= 2;                                                                         \
  |  |  |  |  172|      8|    }                                                                                          \
  |  |  |  |  173|      3|  }                                                                                            \
  |  |  |  |  174|      3|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (174:10): [Folded, False: 3]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  564|       |
  565|     19|    LL_FOREACH((*options), opt) {
  ------------------
  |  |  419|      3|    LL_FOREACH2(head,el,next)
  |  |  ------------------
  |  |  |  |  422|     22|    for ((el) = (head); el; (el) = (el)->next)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (422:25): [True: 19, False: 3]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  566|     19|      if (!coap_add_option_internal(pdu, opt->number, opt->length, opt->data))
  ------------------
  |  Branch (566:11): [True: 0, False: 19]
  ------------------
  567|      0|        return 0;
  568|     19|    }
  569|      3|  }
  570|     10|  return 1;
  571|     10|}
coap_insert_optlist:
  584|     43|coap_insert_optlist(coap_optlist_t **head, coap_optlist_t *node) {
  585|     43|  if (!node) {
  ------------------
  |  Branch (585:7): [True: 0, False: 43]
  ------------------
  586|      0|    coap_log_debug("optlist not provided\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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  587|     43|  } else {
  588|       |    /* must append at the list end to avoid re-ordering of
  589|       |     * options during sort */
  590|     43|    LL_APPEND((*head), node);
  ------------------
  |  |  344|     43|    LL_APPEND2(head,add,next)
  |  |  ------------------
  |  |  |  |  346|     43|#define LL_APPEND2(head,add,next)                                                              \
  |  |  |  |  347|     43|do {                                                                                           \
  |  |  |  |  348|     43|  LDECLTYPE(head) _tmp;                                                                        \
  |  |  |  |  ------------------
  |  |  |  |  |  |   81|     43|#define LDECLTYPE(x) __typeof(x)
  |  |  |  |  ------------------
  |  |  |  |  349|     43|  (add)->next=NULL;                                                                            \
  |  |  |  |  350|     43|  if (head) {                                                                                  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (350:7): [True: 33, False: 10]
  |  |  |  |  ------------------
  |  |  |  |  351|     33|    _tmp = (head);                                                                             \
  |  |  |  |  352|    107|    while (_tmp->next) { _tmp = _tmp->next; }                                                  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (352:12): [True: 74, False: 33]
  |  |  |  |  ------------------
  |  |  |  |  353|     33|    _tmp->next=(add);                                                                          \
  |  |  |  |  354|     33|  } else {                                                                                     \
  |  |  |  |  355|     10|    (head)=(add);                                                                              \
  |  |  |  |  356|     10|  }                                                                                            \
  |  |  |  |  357|     43|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (357:10): [Folded, False: 43]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  591|     43|  }
  592|       |
  593|       |  return node != NULL;
  594|     43|}
coap_delete_optlist:
  605|     20|coap_delete_optlist(coap_optlist_t *queue) {
  606|     20|  coap_optlist_t *elt, *tmp;
  607|       |
  608|     20|  if (!queue)
  ------------------
  |  Branch (608:7): [True: 7, False: 13]
  ------------------
  609|      7|    return;
  610|       |
  611|     43|  LL_FOREACH_SAFE(queue, elt, tmp) {
  ------------------
  |  |  425|     13|    LL_FOREACH_SAFE2(head,el,tmp,next)
  |  |  ------------------
  |  |  |  |  428|     56|  for ((el) = (head); (el) && ((tmp) = (el)->next, 1); (el) = (tmp))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (428:23): [True: 43, False: 13]
  |  |  |  |  |  Branch (428:31): [True: 43, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  612|     43|    coap_internal_delete(elt);
  613|     43|  }
  614|     13|}
coap_option.c:opt_finished:
  141|    211|opt_finished(coap_opt_iterator_t *oi) {
  142|    211|  assert(oi);
  ------------------
  |  Branch (142:3): [True: 211, False: 0]
  ------------------
  143|       |
  144|    211|  if (oi->bad || oi->length == 0 ||
  ------------------
  |  Branch (144:7): [True: 0, False: 211]
  |  Branch (144:18): [True: 10, False: 201]
  ------------------
  145|    201|      !oi->next_option || *oi->next_option == COAP_PAYLOAD_START) {
  ------------------
  |  |   96|    201|#define COAP_PAYLOAD_START 0xFF /* payload marker */
  ------------------
  |  Branch (145:7): [True: 0, False: 201]
  |  Branch (145:27): [True: 0, False: 201]
  ------------------
  146|     10|    oi->bad = 1;
  147|     10|  }
  148|       |
  149|    211|  return oi->bad;
  150|    211|}
coap_option.c:coap_option_filter_op:
  433|    370|                      enum filter_op_t op) {
  434|    370|  size_t lindex = 0;
  435|    370|  coap_opt_filter_t *of = filter;
  436|    370|  uint16_t nr, mask = 0;
  437|       |
  438|    370|  if (is_long_option(number)) {
  ------------------
  |  Branch (438:7): [True: 0, False: 370]
  ------------------
  439|      0|    mask = LONG_MASK;
  ------------------
  |  |  398|      0|#define LONG_MASK ((1 << COAP_OPT_FILTER_LONG) - 1)
  |  |  ------------------
  |  |  |  |  208|      0|#define COAP_OPT_FILTER_LONG  2
  |  |  ------------------
  ------------------
  440|       |
  441|      0|    for (nr = 1; lindex < COAP_OPT_FILTER_LONG; nr <<= 1, lindex++) {
  ------------------
  |  |  208|      0|#define COAP_OPT_FILTER_LONG  2
  ------------------
  |  Branch (441:18): [True: 0, False: 0]
  ------------------
  442|       |
  443|      0|      if (((of->mask & nr) > 0) && (of->long_opts[lindex] == number)) {
  ------------------
  |  Branch (443:11): [True: 0, False: 0]
  |  Branch (443:36): [True: 0, False: 0]
  ------------------
  444|      0|        if (op == FILTER_CLEAR) {
  ------------------
  |  Branch (444:13): [True: 0, False: 0]
  ------------------
  445|      0|          of->mask &= ~nr;
  446|      0|        }
  447|       |
  448|      0|        return 1;
  449|      0|      }
  450|      0|    }
  451|    370|  } else {
  452|    370|    mask = SHORT_MASK;
  ------------------
  |  |  400|    370|  (~LONG_MASK & ((1 << (COAP_OPT_FILTER_LONG + COAP_OPT_FILTER_SHORT)) - 1))
  |  |  ------------------
  |  |  |  |  398|    370|#define LONG_MASK ((1 << COAP_OPT_FILTER_LONG) - 1)
  |  |  |  |  ------------------
  |  |  |  |  |  |  208|    370|#define COAP_OPT_FILTER_LONG  2
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                 (~LONG_MASK & ((1 << (COAP_OPT_FILTER_LONG + COAP_OPT_FILTER_SHORT)) - 1))
  |  |  ------------------
  |  |  |  |  208|    370|#define COAP_OPT_FILTER_LONG  2
  |  |  ------------------
  |  |                 (~LONG_MASK & ((1 << (COAP_OPT_FILTER_LONG + COAP_OPT_FILTER_SHORT)) - 1))
  |  |  ------------------
  |  |  |  |  200|    370|#define COAP_OPT_FILTER_SHORT 6
  |  |  ------------------
  ------------------
  453|       |
  454|  2.58k|    for (nr = 1 << COAP_OPT_FILTER_LONG; lindex < COAP_OPT_FILTER_SHORT;
  ------------------
  |  |  208|    370|#define COAP_OPT_FILTER_LONG  2
  ------------------
                  for (nr = 1 << COAP_OPT_FILTER_LONG; lindex < COAP_OPT_FILTER_SHORT;
  ------------------
  |  |  200|  2.58k|#define COAP_OPT_FILTER_SHORT 6
  ------------------
  |  Branch (454:42): [True: 2.22k, False: 360]
  ------------------
  455|  2.22k|         nr <<= 1, lindex++) {
  456|       |
  457|  2.22k|      if (((of->mask & nr) > 0) && (of->short_opts[lindex] == (number & 0xff))) {
  ------------------
  |  Branch (457:11): [True: 294, False: 1.92k]
  |  Branch (457:36): [True: 10, False: 284]
  ------------------
  458|     10|        if (op == FILTER_CLEAR) {
  ------------------
  |  Branch (458:13): [True: 0, False: 10]
  ------------------
  459|      0|          of->mask &= ~nr;
  460|      0|        }
  461|       |
  462|     10|        return 1;
  463|     10|      }
  464|  2.22k|    }
  465|    370|  }
  466|       |
  467|       |  /* number was not found, so there is nothing to do if op is CLEAR or GET */
  468|    360|  if ((op == FILTER_CLEAR) || (op == FILTER_GET)) {
  ------------------
  |  Branch (468:7): [True: 0, False: 360]
  |  Branch (468:31): [True: 284, False: 76]
  ------------------
  469|    284|    return 0;
  470|    284|  }
  471|       |
  472|       |  /* handle FILTER_SET: */
  473|       |
  474|     76|  lindex = coap_fls(~of->mask & mask);
  475|     76|  if (!lindex) {
  ------------------
  |  Branch (475:7): [True: 0, False: 76]
  ------------------
  476|      0|    return 0;
  477|      0|  }
  478|       |
  479|     76|  if (is_long_option(number)) {
  ------------------
  |  Branch (479:7): [True: 0, False: 76]
  ------------------
  480|      0|    of->long_opts[lindex - 1] = number;
  481|     76|  } else {
  482|     76|    of->short_opts[lindex - COAP_OPT_FILTER_LONG - 1] = (uint8_t)number;
  ------------------
  |  |  208|     76|#define COAP_OPT_FILTER_LONG  2
  ------------------
  483|     76|  }
  484|       |
  485|     76|  of->mask |= 1 << (lindex - 1);
  486|       |
  487|     76|  return 1;
  488|     76|}
coap_option.c:is_long_option:
  404|    446|is_long_option(coap_option_num_t number) {
  405|    446|  return number > 255;
  406|    446|}
coap_option.c:order_opts:
  543|     39|order_opts(void *a, void *b) {
  544|     39|  coap_optlist_t *o1 = (coap_optlist_t *)a;
  545|     39|  coap_optlist_t *o2 = (coap_optlist_t *)b;
  546|       |
  547|     39|  if (!a || !b)
  ------------------
  |  Branch (547:7): [True: 0, False: 39]
  |  Branch (547:13): [True: 0, False: 39]
  ------------------
  548|      0|    return a < b ? -1 : 1;
  ------------------
  |  Branch (548:12): [True: 0, False: 0]
  ------------------
  549|       |
  550|     39|  return (int)(o1->number - o2->number);
  551|     39|}
coap_option.c:coap_internal_delete:
  597|     43|coap_internal_delete(coap_optlist_t *node) {
  598|     43|  if (node) {
  ------------------
  |  Branch (598:7): [True: 43, False: 0]
  ------------------
  599|     43|    coap_free_type(COAP_OPTLIST, node);
  600|     43|  }
  601|     43|  return 1;
  602|     43|}

coap_delete_all_oscore:
 2648|     36|coap_delete_all_oscore(coap_context_t *c_context) {
 2649|     36|  oscore_free_contexts(c_context);
 2650|     36|}
coap_delete_oscore_associations:
 2653|     62|coap_delete_oscore_associations(coap_session_t *session) {
 2654|     62|  oscore_delete_server_associations(session);
 2655|     62|}

coap_pdu_clear:
   47|     98|coap_pdu_clear(coap_pdu_t *pdu, size_t size) {
   48|     98|  assert(pdu);
  ------------------
  |  Branch (48:3): [True: 98, False: 0]
  ------------------
   49|     98|  assert(pdu->token);
  ------------------
  |  Branch (49:3): [True: 98, False: 0]
  ------------------
   50|     98|  assert(pdu->max_hdr_size >= COAP_PDU_MAX_UDP_HEADER_SIZE);
  ------------------
  |  Branch (50:3): [True: 98, False: 0]
  ------------------
   51|     98|  if (pdu->alloc_size > size)
  ------------------
  |  Branch (51:7): [True: 0, False: 98]
  ------------------
   52|      0|    pdu->alloc_size = size;
   53|     98|  pdu->type = 0;
   54|     98|  pdu->code = 0;
   55|     98|  pdu->ref = 0;
   56|     98|  pdu->hdr_size = 0;
   57|     98|  pdu->actual_token.length = 0;
   58|     98|  pdu->e_token_length = 0;
   59|     98|  pdu->crit_opt = 0;
   60|     98|  pdu->mid = 0;
   61|     98|  pdu->max_opt = 0;
   62|     98|  pdu->max_size = size;
   63|     98|  pdu->used_size = 0;
   64|     98|  pdu->data = NULL;
   65|     98|  pdu->body_data = NULL;
   66|     98|  pdu->body_length = 0;
   67|     98|  pdu->body_offset = 0;
   68|     98|  pdu->body_total = 0;
   69|     98|  pdu->lg_xmit = NULL;
   70|     98|  pdu->session = NULL;
   71|       |  pdu->data_free = NULL;
   72|     98|}
coap_pdu_init:
  105|     98|              size_t size) {
  106|     98|  coap_pdu_t *pdu;
  107|       |
  108|     98|#ifndef RIOT_VERSION
  109|     98|  assert(type <= 0x3);
  ------------------
  |  Branch (109:3): [True: 98, False: 0]
  ------------------
  110|     98|  assert(code <= 0xff);
  ------------------
  |  Branch (110:3): [True: 98, False: 0]
  ------------------
  111|     98|  assert(mid >= 0 && mid <= 0xffff);
  ------------------
  |  Branch (111:3): [True: 98, False: 0]
  |  Branch (111:3): [True: 98, False: 0]
  ------------------
  112|     98|#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|     98|  pdu = coap_malloc_type(COAP_PDU, sizeof(coap_pdu_t));
  125|     98|  if (!pdu)
  ------------------
  |  Branch (125:7): [True: 0, False: 98]
  ------------------
  126|      0|    return NULL;
  127|       |
  128|       |#if COAP_DEFAULT_MAX_PDU_RX_SIZE <= COAP_MAX_MESSAGE_SIZE_TCP16
  129|       |  /* on TCP, the CoAP header will also have a maximum length of 4 bytes */
  130|       |  pdu->max_hdr_size = COAP_PDU_MAX_UDP_HEADER_SIZE;
  131|       |#else
  132|     98|  pdu->max_hdr_size = COAP_PDU_MAX_TCP_HEADER_SIZE;
  ------------------
  |  |  108|     98|#define COAP_PDU_MAX_TCP_HEADER_SIZE 6
  ------------------
  133|     98|#endif
  134|     98|  if (size > ((size_t)COAP_DEFAULT_MAX_PDU_RX_SIZE - pdu->max_hdr_size)) {
  ------------------
  |  |   84|     98|#define COAP_DEFAULT_MAX_PDU_RX_SIZE (8UL*1024*1024+256)
  ------------------
  |  Branch (134:7): [True: 0, False: 98]
  ------------------
  135|      0|    coap_free_type(COAP_PDU, pdu);
  136|      0|    return NULL;
  137|      0|  }
  138|       |
  139|     98|  pdu->alloc_size = min(size, COAP_DEFAULT_MTU);
  ------------------
  |  |   37|     98|#define min(a,b) ((a) < (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (37:19): [True: 98, False: 0]
  |  |  ------------------
  ------------------
  140|       |#ifdef WITH_LWIP
  141|       |  pdu->pbuf = pbuf_alloc(PBUF_TRANSPORT, max(size, COAP_DEFAULT_MTU) + pdu->max_hdr_size,
  142|       |                         PBUF_RAM);
  143|       |  if (pdu->pbuf == NULL) {
  144|       |    coap_free_type(COAP_PDU, pdu);
  145|       |    return NULL;
  146|       |  }
  147|       |  pdu->token = (uint8_t *)pdu->pbuf->payload + pdu->max_hdr_size;
  148|       |#else /* ! WITH_LWIP */
  149|     98|  uint8_t *buf;
  150|     98|  buf = coap_malloc_type(COAP_PDU_BUF, pdu->alloc_size + pdu->max_hdr_size);
  151|     98|  if (buf == NULL) {
  ------------------
  |  Branch (151:7): [True: 0, False: 98]
  ------------------
  152|      0|    coap_free_type(COAP_PDU, pdu);
  153|      0|    return NULL;
  154|      0|  }
  155|     98|  pdu->token = buf + pdu->max_hdr_size;
  156|     98|#endif /* ! WITH_LWIP */
  157|     98|  coap_pdu_clear(pdu, size);
  158|     98|  pdu->mid = mid;
  159|     98|  pdu->type = type;
  160|     98|  pdu->code = code;
  161|     98|  return pdu;
  162|     98|}
coap_delete_pdu:
  190|     72|coap_delete_pdu(coap_pdu_t *pdu) {
  191|     72|  coap_lock_lock(return);
  192|     72|  coap_delete_pdu_lkd(pdu);
  193|     72|  coap_lock_unlock();
  194|     72|}
coap_delete_pdu_lkd:
  197|    212|coap_delete_pdu_lkd(coap_pdu_t *pdu) {
  198|    212|  if (pdu != NULL) {
  ------------------
  |  Branch (198:7): [True: 150, False: 62]
  ------------------
  199|    150|    if (pdu->ref) {
  ------------------
  |  Branch (199:9): [True: 52, False: 98]
  ------------------
  200|     52|      pdu->ref--;
  201|     52|      return;
  202|     52|    }
  203|       |#ifdef WITH_LWIP
  204|       |    pbuf_free(pdu->pbuf);
  205|       |#else
  206|     98|    if (pdu->token != NULL)
  ------------------
  |  Branch (206:9): [True: 98, False: 0]
  ------------------
  207|     98|      coap_free_type(COAP_PDU_BUF, pdu->token - pdu->max_hdr_size);
  208|     98|#endif
  209|     98|    coap_delete_binary(pdu->data_free);
  210|     98|    coap_free_type(COAP_PDU, pdu);
  211|     98|  }
  212|    212|}
coap_pdu_duplicate_lkd:
  242|      9|                       coap_bool_t expand_opt_abb) {
  243|      9|#if COAP_CLIENT_SUPPORT
  244|      9|  uint8_t doing_first = session->doing_first;
  245|      9|#endif /* COAP_CLIENT_SUPPORT */
  246|      9|  coap_pdu_t *pdu;
  247|       |
  248|      9|  coap_lock_check_locked();
  ------------------
  |  |  638|      9|#define coap_lock_check_locked() {}
  ------------------
  249|       |  /*
  250|       |   * Need to make sure that coap_session_max_pdu_size_lkd() immediately
  251|       |   * returns, rather than wait for the first CSM response from remote
  252|       |   * that indicates BERT size (TCP/TLS only) as this may be called early
  253|       |   * the OSCORE logic.
  254|       |   */
  255|      9|#if COAP_CLIENT_SUPPORT
  256|      9|  session->doing_first = 0;
  257|      9|#endif /* COAP_CLIENT_SUPPORT */
  258|      9|  pdu = coap_pdu_init(old_pdu->type, old_pdu->code,
  259|      9|                      coap_new_message_id_lkd(session),
  260|      9|                      max(old_pdu->max_size,
  ------------------
  |  |   41|      9|#define max(a,b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (41:19): [True: 0, False: 9]
  |  |  ------------------
  ------------------
  261|      9|                          coap_session_max_pdu_size_lkd(session)));
  262|      9|#if COAP_CLIENT_SUPPORT
  263|       |  /* Restore any pending waits */
  264|      9|  session->doing_first = doing_first;
  265|      9|#endif /* COAP_CLIENT_SUPPORT */
  266|      9|  if (pdu == NULL)
  ------------------
  |  Branch (266:7): [True: 0, False: 9]
  ------------------
  267|      0|    return NULL;
  268|       |
  269|      9|  coap_add_token(pdu, token_length, token);
  270|      9|  pdu->lg_xmit = old_pdu->lg_xmit;
  271|       |
  272|      9|  if (drop_options == NULL && expand_opt_abb == COAP_BOOL_FALSE) {
  ------------------
  |  Branch (272:7): [True: 9, False: 0]
  |  Branch (272:31): [True: 9, False: 0]
  ------------------
  273|       |    /* Drop COAP_PAYLOAD_START as well if data */
  274|      9|    size_t length = old_pdu->used_size - old_pdu->e_token_length -
  275|      9|                    (old_pdu->data ?
  ------------------
  |  Branch (275:22): [True: 0, False: 9]
  ------------------
  276|      9|                     old_pdu->used_size - (old_pdu->data - old_pdu->token) +1 : 0);
  277|      9|    if (!coap_pdu_resize(pdu, length + pdu->e_token_length))
  ------------------
  |  Branch (277:9): [True: 0, False: 9]
  ------------------
  278|      0|      goto fail;
  279|       |    /* Copy the options but not any data across */
  280|      9|    memcpy(pdu->token + pdu->e_token_length,
  281|      9|           old_pdu->token + old_pdu->e_token_length, length);
  282|      9|    pdu->used_size += length;
  283|      9|    pdu->max_opt = old_pdu->max_opt;
  284|      9|  } else {
  285|       |    /* Copy across all the options the slow way */
  286|      0|    coap_opt_iterator_t opt_iter;
  287|      0|    coap_opt_t *option;
  288|       |
  289|      0|    coap_option_iterator_init(old_pdu, &opt_iter, COAP_OPT_ALL);
  ------------------
  |  |  230|      0|#define COAP_OPT_ALL NULL
  ------------------
  290|      0|    while ((option = coap_option_next(&opt_iter))) {
  ------------------
  |  Branch (290:12): [True: 0, False: 0]
  ------------------
  291|      0|      if (opt_iter.number == COAP_OPTION_URI_PATH_ABB && expand_opt_abb == COAP_BOOL_TRUE) {
  ------------------
  |  Branch (291:11): [True: 0, False: 0]
  |  Branch (291:58): [True: 0, False: 0]
  ------------------
  292|      0|        uint32_t value;
  293|      0|        const char *exp;
  294|       |
  295|      0|        value = coap_decode_var_bytes(coap_opt_value(option),
  296|      0|                                      coap_opt_length(option));
  297|      0|        exp = coap_map_abbrev_uri_path(coap_upa_server_mapping_chain, value);
  298|      0|        if (exp) {
  ------------------
  |  Branch (298:13): [True: 0, False: 0]
  ------------------
  299|      0|          while (exp) {
  ------------------
  |  Branch (299:18): [True: 0, False: 0]
  ------------------
  300|      0|            const char *next = strchr(exp, '/');
  301|       |
  302|      0|            if (!coap_insert_option(pdu, COAP_OPTION_URI_PATH,
  ------------------
  |  Branch (302:17): [True: 0, False: 0]
  ------------------
  303|      0|                                    next ? (int)(next - exp) : (int)strlen(exp),
  ------------------
  |  Branch (303:37): [True: 0, False: 0]
  ------------------
  304|      0|                                    (const uint8_t *)exp))
  305|      0|              goto fail;
  306|      0|            if (next)
  ------------------
  |  Branch (306:17): [True: 0, False: 0]
  ------------------
  307|      0|              exp = next + 1;
  308|      0|            else
  309|      0|              exp = NULL;
  310|      0|          }
  311|      0|        } else {
  312|      0|          coap_delete_pdu_lkd(pdu);
  313|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  314|      0|                        value);
  315|      0|          return NULL;
  316|      0|        }
  317|      0|      } else {
  318|      0|        if (drop_options) {
  ------------------
  |  Branch (318:13): [True: 0, False: 0]
  ------------------
  319|      0|          if (coap_option_filter_get(drop_options, opt_iter.number))
  ------------------
  |  Branch (319:15): [True: 0, False: 0]
  ------------------
  320|      0|            continue;
  321|      0|        }
  322|      0|        if (!coap_insert_option(pdu, opt_iter.number,
  ------------------
  |  Branch (322:13): [True: 0, False: 0]
  ------------------
  323|      0|                                coap_opt_length(option),
  324|      0|                                coap_opt_value(option)))
  325|      0|          goto fail;
  326|      0|      }
  327|      0|    }
  328|      0|  }
  329|      9|  return pdu;
  330|       |
  331|      0|fail:
  332|      0|  coap_delete_pdu_lkd(pdu);
  333|       |  return NULL;
  334|      9|}
coap_pdu_resize:
  341|     23|coap_pdu_resize(coap_pdu_t *pdu, size_t new_size) {
  342|     23|  if (new_size > pdu->alloc_size) {
  ------------------
  |  Branch (342:7): [True: 12, False: 11]
  ------------------
  343|       |    /* Expanding the PDU usage */
  344|     12|#if !defined(WITH_LWIP)
  345|     12|    uint8_t *new_hdr;
  346|       |#else /* WITH_LWIP */
  347|       |    struct pbuf *new_hdr;
  348|       |#endif /* WITH_LWIP */
  349|     12|    size_t offset;
  350|       |
  351|     12|    if (pdu->max_size && new_size > pdu->max_size) {
  ------------------
  |  Branch (351:9): [True: 12, False: 0]
  |  Branch (351:26): [True: 12, False: 0]
  ------------------
  352|     12|      coap_log_warn("coap_pdu_resize: pdu too big\n");
  ------------------
  |  |  108|     12|#define coap_log_warn(...) coap_log(COAP_LOG_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|     12|#define coap_log(level, ...) do { \
  |  |  |  |  291|     12|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 12]
  |  |  |  |  ------------------
  |  |  |  |  292|     12|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|     12|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 12]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  353|     12|      return 0;
  354|     12|    }
  355|      0|    if (pdu->data != NULL) {
  ------------------
  |  Branch (355:9): [True: 0, False: 0]
  ------------------
  356|      0|      assert(pdu->data > pdu->token);
  ------------------
  |  Branch (356:7): [True: 0, False: 0]
  ------------------
  357|      0|      offset = pdu->data - pdu->token;
  358|      0|    } else {
  359|      0|      offset = 0;
  360|      0|    }
  361|      0|#if !defined(WITH_LWIP)
  362|      0|    new_hdr = (uint8_t *)coap_realloc_type(COAP_PDU_BUF,
  363|      0|                                           pdu->token - pdu->max_hdr_size,
  364|      0|                                           new_size + pdu->max_hdr_size);
  365|       |#else /* WITH_LWIP */
  366|       |    new_hdr = pbuf_alloc(PBUF_TRANSPORT, new_size + pdu->max_hdr_size, PBUF_RAM);
  367|       |#endif /* WITH_LWIP */
  368|      0|    if (new_hdr == NULL) {
  ------------------
  |  Branch (368:9): [True: 0, False: 0]
  ------------------
  369|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  370|      0|      return 0;
  371|      0|    }
  372|      0|#if !defined(WITH_LWIP)
  373|      0|    pdu->token = new_hdr + pdu->max_hdr_size;
  374|       |#else /* WITH_LWIP */
  375|       |    memcpy(new_hdr->payload, pdu->pbuf->payload, pdu->pbuf->len);
  376|       |    pbuf_free(pdu->pbuf);
  377|       |    pdu->pbuf = new_hdr;
  378|       |    pdu->token = (uint8_t *)pdu->pbuf->payload + pdu->max_hdr_size;
  379|       |#endif /* WITH_LWIP */
  380|      0|    if (offset > 0)
  ------------------
  |  Branch (380:9): [True: 0, False: 0]
  ------------------
  381|      0|      pdu->data = pdu->token + offset;
  382|      0|    else
  383|      0|      pdu->data = NULL;
  384|      0|    if (pdu->actual_token.length < COAP_TOKEN_EXT_1B_BIAS)
  ------------------
  |  |   56|      0|#define COAP_TOKEN_EXT_1B_BIAS 13
  ------------------
  |  Branch (384:9): [True: 0, False: 0]
  ------------------
  385|      0|      pdu->actual_token.s = &pdu->token[0];
  386|      0|    else if (pdu->actual_token.length < COAP_TOKEN_EXT_2B_BIAS)
  ------------------
  |  |   57|      0|#define COAP_TOKEN_EXT_2B_BIAS 269 /* 13 + 256 */
  ------------------
  |  Branch (386:14): [True: 0, False: 0]
  ------------------
  387|      0|      pdu->actual_token.s = &pdu->token[1];
  388|      0|    else
  389|      0|      pdu->actual_token.s = &pdu->token[2];
  390|      0|    pdu->alloc_size = new_size;
  391|      0|  }
  392|     11|  return 1;
  393|     23|}
coap_pdu_check_resize:
  396|    222|coap_pdu_check_resize(coap_pdu_t *pdu, size_t size) {
  397|    222|  if (size > pdu->alloc_size) {
  ------------------
  |  Branch (397:7): [True: 0, False: 222]
  ------------------
  398|      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]
  |  |  ------------------
  ------------------
  399|      0|    while (size > new_size)
  ------------------
  |  Branch (399:12): [True: 0, False: 0]
  ------------------
  400|      0|      new_size *= 2;
  401|      0|    if (pdu->max_size && new_size > pdu->max_size) {
  ------------------
  |  Branch (401:9): [True: 0, False: 0]
  |  Branch (401:26): [True: 0, False: 0]
  ------------------
  402|      0|      new_size = pdu->max_size;
  403|      0|      if (new_size < size)
  ------------------
  |  Branch (403:11): [True: 0, False: 0]
  ------------------
  404|      0|        return 0;
  405|      0|    }
  406|      0|    if (!coap_pdu_resize(pdu, new_size))
  ------------------
  |  Branch (406:9): [True: 0, False: 0]
  ------------------
  407|      0|      return 0;
  408|      0|  }
  409|    222|  return 1;
  410|    222|}
coap_add_token:
  413|     62|coap_add_token(coap_pdu_t *pdu, size_t len, const uint8_t *data) {
  414|     62|  size_t bias = 0;
  415|       |
  416|       |  /* must allow for pdu == NULL as callers may rely on this */
  417|     62|  if (!pdu)
  ------------------
  |  Branch (417:7): [True: 0, False: 62]
  ------------------
  418|      0|    return 0;
  419|       |
  420|     62|  if (pdu->used_size) {
  ------------------
  |  Branch (420:7): [True: 0, False: 62]
  ------------------
  421|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  422|      0|    return 0;
  423|      0|  }
  424|     62|  pdu->actual_token.length = len;
  425|     62|  if (len < COAP_TOKEN_EXT_1B_BIAS) {
  ------------------
  |  |   56|     62|#define COAP_TOKEN_EXT_1B_BIAS 13
  ------------------
  |  Branch (425:7): [True: 62, False: 0]
  ------------------
  426|     62|    bias = 0;
  427|     62|  } else if (len < COAP_TOKEN_EXT_2B_BIAS) {
  ------------------
  |  |   57|      0|#define COAP_TOKEN_EXT_2B_BIAS 269 /* 13 + 256 */
  ------------------
  |  Branch (427:14): [True: 0, False: 0]
  ------------------
  428|      0|    bias = 1;
  429|      0|  } else if (len <= COAP_TOKEN_EXT_MAX) {
  ------------------
  |  |   60|      0|#define COAP_TOKEN_EXT_MAX 65804UL /* 13 + 256 + 65535 */
  ------------------
  |  Branch (429:14): [True: 0, False: 0]
  ------------------
  430|      0|    bias = 2;
  431|      0|  } else {
  432|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  433|      0|    return 0;
  434|      0|  }
  435|     62|  if (!coap_pdu_check_resize(pdu, len + bias)) {
  ------------------
  |  Branch (435:7): [True: 0, False: 62]
  ------------------
  436|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  437|      0|    return 0;
  438|      0|  }
  439|       |
  440|     62|  pdu->actual_token.length = len;
  441|     62|  pdu->actual_token.s = &pdu->token[bias];
  442|     62|  pdu->e_token_length = (uint32_t)(len + bias);
  443|     62|  if (len) {
  ------------------
  |  Branch (443:7): [True: 62, False: 0]
  ------------------
  444|     62|    switch (bias) {
  445|     62|    case 0:
  ------------------
  |  Branch (445:5): [True: 62, False: 0]
  ------------------
  446|     62|      memcpy(pdu->token, data, len);
  447|     62|      break;
  448|      0|    case 1:
  ------------------
  |  Branch (448:5): [True: 0, False: 62]
  ------------------
  449|      0|      pdu->token[0] = (uint8_t)(len - COAP_TOKEN_EXT_1B_BIAS);
  ------------------
  |  |   56|      0|#define COAP_TOKEN_EXT_1B_BIAS 13
  ------------------
  450|      0|      memcpy(&pdu->token[1], data, len);
  451|      0|      break;
  452|      0|    case 2:
  ------------------
  |  Branch (452:5): [True: 0, False: 62]
  ------------------
  453|      0|      pdu->token[0] = (uint8_t)((len - COAP_TOKEN_EXT_2B_BIAS) >> 8);
  ------------------
  |  |   57|      0|#define COAP_TOKEN_EXT_2B_BIAS 269 /* 13 + 256 */
  ------------------
  454|      0|      pdu->token[1] = (uint8_t)((len - COAP_TOKEN_EXT_2B_BIAS) & 0xff);
  ------------------
  |  |   57|      0|#define COAP_TOKEN_EXT_2B_BIAS 269 /* 13 + 256 */
  ------------------
  455|      0|      memcpy(&pdu->token[2], data, len);
  456|      0|      break;
  457|      0|    default:
  ------------------
  |  Branch (457:5): [True: 0, False: 62]
  ------------------
  458|      0|      break;
  459|     62|    }
  460|     62|  }
  461|     62|  pdu->max_opt = 0;
  462|     62|  pdu->used_size = len + bias;
  463|     62|  pdu->data = NULL;
  464|       |
  465|     62|  return 1;
  466|     62|}
coap_option_check_repeatable:
  640|     34|coap_option_check_repeatable(coap_pdu_t *pdu, coap_option_num_t number) {
  641|       |  /* Validate that the option is repeatable */
  642|     34|  switch ((coap_code_opt_num_t)number) {
  643|      0|  case COAP_OPTION_ETAG:
  ------------------
  |  Branch (643:3): [True: 0, False: 34]
  ------------------
  644|      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]
  |  |  ------------------
  ------------------
  645|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  646|      0|      return 0;
  647|      0|    }
  648|      0|    break;
  649|       |  /* Ignore list of genuine repeatable */
  650|      0|  case COAP_OPTION_IF_MATCH:
  ------------------
  |  Branch (650:3): [True: 0, False: 34]
  ------------------
  651|      0|  case COAP_OPTION_LOCATION_PATH:
  ------------------
  |  Branch (651:3): [True: 0, False: 34]
  ------------------
  652|     34|  case COAP_OPTION_URI_PATH:
  ------------------
  |  Branch (652:3): [True: 34, False: 0]
  ------------------
  653|     34|  case COAP_OPTION_URI_QUERY:
  ------------------
  |  Branch (653:3): [True: 0, False: 34]
  ------------------
  654|     34|  case COAP_OPTION_LOCATION_QUERY:
  ------------------
  |  Branch (654:3): [True: 0, False: 34]
  ------------------
  655|     34|  case COAP_OPTION_Q_BLOCK2:
  ------------------
  |  Branch (655:3): [True: 0, False: 34]
  ------------------
  656|     34|  case COAP_OPTION_RTAG:
  ------------------
  |  Branch (656:3): [True: 0, False: 34]
  ------------------
  657|     34|    break;
  658|       |  /* Protest at the known non-repeatable options and ignore them */
  659|      0|  case COAP_OPTION_URI_HOST:
  ------------------
  |  Branch (659:3): [True: 0, False: 34]
  ------------------
  660|      0|  case COAP_OPTION_IF_NONE_MATCH:
  ------------------
  |  Branch (660:3): [True: 0, False: 34]
  ------------------
  661|      0|  case COAP_OPTION_OBSERVE:
  ------------------
  |  Branch (661:3): [True: 0, False: 34]
  ------------------
  662|      0|  case COAP_OPTION_URI_PORT:
  ------------------
  |  Branch (662:3): [True: 0, False: 34]
  ------------------
  663|      0|  case COAP_OPTION_OSCORE:
  ------------------
  |  Branch (663:3): [True: 0, False: 34]
  ------------------
  664|      0|  case COAP_OPTION_CONTENT_FORMAT:
  ------------------
  |  Branch (664:3): [True: 0, False: 34]
  ------------------
  665|      0|  case COAP_OPTION_URI_PATH_ABB:
  ------------------
  |  Branch (665:3): [True: 0, False: 34]
  ------------------
  666|      0|  case COAP_OPTION_MAXAGE:
  ------------------
  |  Branch (666:3): [True: 0, False: 34]
  ------------------
  667|      0|  case COAP_OPTION_HOP_LIMIT:
  ------------------
  |  Branch (667:3): [True: 0, False: 34]
  ------------------
  668|      0|  case COAP_OPTION_ACCEPT:
  ------------------
  |  Branch (668:3): [True: 0, False: 34]
  ------------------
  669|      0|  case COAP_OPTION_Q_BLOCK1:
  ------------------
  |  Branch (669:3): [True: 0, False: 34]
  ------------------
  670|      0|  case COAP_OPTION_EDHOC:
  ------------------
  |  Branch (670:3): [True: 0, False: 34]
  ------------------
  671|      0|  case COAP_OPTION_BLOCK2:
  ------------------
  |  Branch (671:3): [True: 0, False: 34]
  ------------------
  672|      0|  case COAP_OPTION_BLOCK1:
  ------------------
  |  Branch (672:3): [True: 0, False: 34]
  ------------------
  673|      0|  case COAP_OPTION_SIZE2:
  ------------------
  |  Branch (673:3): [True: 0, False: 34]
  ------------------
  674|      0|  case COAP_OPTION_PROXY_URI:
  ------------------
  |  Branch (674:3): [True: 0, False: 34]
  ------------------
  675|      0|  case COAP_OPTION_PROXY_SCHEME:
  ------------------
  |  Branch (675:3): [True: 0, False: 34]
  ------------------
  676|      0|  case COAP_OPTION_SIZE1:
  ------------------
  |  Branch (676:3): [True: 0, False: 34]
  ------------------
  677|      0|  case COAP_OPTION_ECHO:
  ------------------
  |  Branch (677:3): [True: 0, False: 34]
  ------------------
  678|      0|  case COAP_OPTION_NORESPONSE:
  ------------------
  |  Branch (678:3): [True: 0, False: 34]
  ------------------
  679|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  680|      0|                  coap_option_string(pdu->code, number), number);
  681|      0|    return 0;
  682|      0|  default:
  ------------------
  |  Branch (682:3): [True: 0, False: 34]
  ------------------
  683|      0|    coap_log_info("Option number %d is not defined as repeatable\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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  684|      0|                  number);
  685|       |    /* Accepting it after warning as there may be user defineable options */
  686|      0|    break;
  687|     34|  }
  688|     34|  return 1;
  689|     34|}
coap_insert_option:
  693|     24|                   const uint8_t *data) {
  694|     24|  coap_opt_iterator_t opt_iter;
  695|     24|  coap_opt_t *option;
  696|     24|  uint16_t prev_number = 0;
  697|     24|  size_t shift;
  698|     24|  size_t opt_delta;
  699|     24|  coap_option_t decode;
  700|     24|  size_t shrink = 0;
  701|       |
  702|     24|  if (number >= pdu->max_opt)
  ------------------
  |  Branch (702:7): [True: 19, False: 5]
  ------------------
  703|     19|    return coap_add_option_internal(pdu, number, len, data);
  704|       |
  705|       |  /* Need to locate where in current options to insert this one */
  706|      5|  coap_option_iterator_init(pdu, &opt_iter, COAP_OPT_ALL);
  ------------------
  |  |  230|      5|#define COAP_OPT_ALL NULL
  ------------------
  707|     30|  while ((option = coap_option_next(&opt_iter))) {
  ------------------
  |  Branch (707:10): [True: 30, False: 0]
  ------------------
  708|     30|    if (opt_iter.number > number) {
  ------------------
  |  Branch (708:9): [True: 5, False: 25]
  ------------------
  709|       |      /* Found where to insert */
  710|      5|      break;
  711|      5|    }
  712|     25|    prev_number = opt_iter.number;
  713|     25|  }
  714|      5|  if (option == NULL) {
  ------------------
  |  Branch (714:7): [True: 0, False: 5]
  ------------------
  715|       |    /* Code is broken somewhere */
  716|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  717|      0|    return 0;
  718|      0|  }
  719|       |
  720|       |  /* size of option inc header to insert */
  721|      5|  shift = coap_opt_encode_size(number - prev_number, len);
  722|       |
  723|       |  /* size of next option (header may shrink in size as delta changes */
  724|      5|  if (!coap_opt_parse(option, pdu->used_size - (option - pdu->token), &decode))
  ------------------
  |  Branch (724:7): [True: 0, False: 5]
  ------------------
  725|      0|    return 0;
  726|      5|  opt_delta = opt_iter.number - number;
  727|      5|  if (opt_delta == 0) {
  ------------------
  |  Branch (727:7): [True: 0, False: 5]
  ------------------
  728|      0|    if (!coap_option_check_repeatable(pdu, number))
  ------------------
  |  Branch (728:9): [True: 0, False: 0]
  ------------------
  729|      0|      return 0;
  730|      0|  }
  731|       |
  732|      5|  if (!coap_pdu_check_resize(pdu,
  ------------------
  |  Branch (732:7): [True: 0, False: 5]
  ------------------
  733|      5|                             pdu->used_size + shift - shrink))
  734|      0|    return 0;
  735|       |
  736|       |  /* Possible a re-size took place with a realloc() */
  737|       |  /* Need to locate where in current options to insert this one */
  738|      5|  coap_option_iterator_init(pdu, &opt_iter, COAP_OPT_ALL);
  ------------------
  |  |  230|      5|#define COAP_OPT_ALL NULL
  ------------------
  739|     30|  while ((option = coap_option_next(&opt_iter))) {
  ------------------
  |  Branch (739:10): [True: 30, False: 0]
  ------------------
  740|     30|    if (opt_iter.number > number) {
  ------------------
  |  Branch (740:9): [True: 5, False: 25]
  ------------------
  741|       |      /* Found where to insert */
  742|      5|      break;
  743|      5|    }
  744|     30|  }
  745|      5|  assert(option != NULL);
  ------------------
  |  Branch (745:3): [True: 5, False: 0]
  ------------------
  746|       |
  747|      5|  if (decode.delta < 13) {
  ------------------
  |  Branch (747:7): [True: 0, False: 5]
  ------------------
  748|       |    /* can simply patch in the new delta of next option */
  749|      0|    option[0] = (option[0] & 0x0f) + (coap_opt_t)(opt_delta << 4);
  750|      5|  } else if (decode.delta < 269 && opt_delta < 13) {
  ------------------
  |  Branch (750:14): [True: 5, False: 0]
  |  Branch (750:36): [True: 5, False: 0]
  ------------------
  751|       |    /* option header is going to shrink by one byte */
  752|      5|    option[1] = (option[0] & 0x0f) + (coap_opt_t)(opt_delta << 4);
  753|      5|    shrink = 1;
  754|      5|  } else if (decode.delta < 269 && opt_delta < 269) {
  ------------------
  |  Branch (754:14): [True: 0, False: 0]
  |  Branch (754:36): [True: 0, False: 0]
  ------------------
  755|       |    /* can simply patch in the new delta of next option */
  756|      0|    option[1] = (coap_opt_t)(opt_delta - 13);
  757|      0|  } else if (opt_delta < 13) {
  ------------------
  |  Branch (757:14): [True: 0, False: 0]
  ------------------
  758|       |    /* option header is going to shrink by two bytes */
  759|      0|    option[2] = (option[0] & 0x0f) + (coap_opt_t)(opt_delta << 4);
  760|      0|    shrink = 2;
  761|      0|  } else if (opt_delta < 269) {
  ------------------
  |  Branch (761:14): [True: 0, False: 0]
  ------------------
  762|       |    /* option header is going to shrink by one bytes */
  763|      0|    option[1] = (option[0] & 0x0f) + 0xd0;
  764|      0|    option[2] = (coap_opt_t)(opt_delta - 13);
  765|      0|    shrink = 1;
  766|      0|  } else {
  767|       |    /* can simply patch in the new delta of next option */
  768|      0|    option[1] = (coap_opt_t)((opt_delta - 269) >> 8);
  769|      0|    option[2] = (opt_delta - 269) & 0xff;
  770|      0|  }
  771|       |
  772|      5|  memmove(&option[shift], &option[shrink],
  773|      5|          pdu->used_size - (option - pdu->token) - shrink);
  774|      5|  if (!coap_opt_encode(option, pdu->alloc_size - pdu->used_size,
  ------------------
  |  Branch (774:7): [True: 0, False: 5]
  ------------------
  775|      5|                       number - prev_number, data, len))
  776|      0|    return 0;
  777|       |
  778|      5|  if (shift >= shrink) {
  ------------------
  |  Branch (778:7): [True: 5, False: 0]
  ------------------
  779|      5|    pdu->used_size += shift - shrink;
  780|      5|    if (pdu->data)
  ------------------
  |  Branch (780:9): [True: 0, False: 5]
  ------------------
  781|      0|      pdu->data += shift - shrink;
  782|      5|  } else {
  783|      0|    pdu->used_size -= shrink - shift;
  784|      0|    if (pdu->data)
  ------------------
  |  Branch (784:9): [True: 0, False: 0]
  ------------------
  785|      0|      pdu->data -= shrink - shift;
  786|      0|  }
  787|      5|  return shift;
  788|      5|}
coap_add_option:
  838|    126|                const uint8_t *data) {
  839|    126|  if (pdu->data) {
  ------------------
  |  Branch (839:7): [True: 0, False: 126]
  ------------------
  840|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  841|      0|    return 0;
  842|      0|  }
  843|    126|  if (!coap_pdu_parse_opt_base(number, len, data)) {
  ------------------
  |  Branch (843:7): [True: 4, False: 122]
  ------------------
  844|      4|    coap_log_warn("qcoap_add_option: %d: Invalid option length / data\n", number);
  ------------------
  |  |  108|      4|#define coap_log_warn(...) coap_log(COAP_LOG_WARN, __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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  845|      4|    return 0;
  846|      4|  }
  847|    122|  return coap_add_option_internal(pdu, number, len, data);
  848|    126|}
coap_add_option_internal:
  852|    160|                         const uint8_t *data) {
  853|    160|  size_t optsize;
  854|    160|  coap_opt_t *opt;
  855|       |
  856|    160|  assert(pdu);
  ------------------
  |  Branch (856:3): [True: 160, False: 0]
  ------------------
  857|       |
  858|    160|  if (number == pdu->max_opt) {
  ------------------
  |  Branch (858:7): [True: 34, False: 126]
  ------------------
  859|     34|    if (!coap_option_check_repeatable(pdu, number))
  ------------------
  |  Branch (859:9): [True: 0, False: 34]
  ------------------
  860|      0|      return 0;
  861|     34|  }
  862|       |
  863|    160|  if (COAP_PDU_IS_REQUEST(pdu) &&
  ------------------
  |  |   99|    320|#define COAP_PDU_IS_REQUEST(pdu)   (!COAP_PDU_IS_EMPTY(pdu) && (pdu)->code < 32)
  |  |  ------------------
  |  |  |  |   98|    320|#define COAP_PDU_IS_EMPTY(pdu)     ((pdu)->code == 0)
  |  |  ------------------
  |  |  |  Branch (99:37): [True: 160, False: 0]
  |  |  |  Branch (99:64): [True: 160, False: 0]
  |  |  ------------------
  ------------------
  864|    160|      (number == COAP_OPTION_PROXY_URI ||
  ------------------
  |  Branch (864:8): [True: 14, False: 146]
  ------------------
  865|    146|       number == COAP_OPTION_PROXY_SCHEME)) {
  ------------------
  |  Branch (865:8): [True: 10, False: 136]
  ------------------
  866|       |    /*
  867|       |     * Need to check whether there is a hop-limit option.  If not, it needs
  868|       |     * to be inserted by default (RFC 8768).
  869|       |     */
  870|     24|    coap_opt_iterator_t opt_iter;
  871|       |
  872|     24|    if (coap_check_option(pdu, COAP_OPTION_HOP_LIMIT, &opt_iter) == NULL) {
  ------------------
  |  Branch (872:9): [True: 19, False: 5]
  ------------------
  873|     19|      size_t hop_limit = COAP_OPTION_HOP_LIMIT;
  874|       |
  875|     19|      coap_insert_option(pdu, COAP_OPTION_HOP_LIMIT, 1, (uint8_t *)&hop_limit);
  876|     19|    }
  877|     24|  }
  878|       |
  879|    160|  if (number < pdu->max_opt) {
  ------------------
  |  Branch (879:7): [True: 5, False: 155]
  ------------------
  880|      5|    coap_log_debug("coap_add_option: options are not in correct order\n");
  ------------------
  |  |  126|      5|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      5|#define coap_log(level, ...) do { \
  |  |  |  |  291|      5|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 5]
  |  |  |  |  ------------------
  |  |  |  |  292|      5|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      5|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 5]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  881|      5|    return coap_insert_option(pdu, number, len, data);
  882|      5|  }
  883|       |
  884|    155|  optsize = coap_opt_encode_size(number - pdu->max_opt, len);
  885|    155|  if (!coap_pdu_check_resize(pdu,
  ------------------
  |  Branch (885:7): [True: 0, False: 155]
  ------------------
  886|    155|                             pdu->used_size + optsize))
  887|      0|    return 0;
  888|       |
  889|    155|  if (pdu->data) {
  ------------------
  |  Branch (889:7): [True: 0, False: 155]
  ------------------
  890|       |    /* include option delimiter */
  891|      0|    memmove(&pdu->data[optsize-1], &pdu->data[-1],
  892|      0|            pdu->used_size - (pdu->data - pdu->token) + 1);
  893|      0|    opt = pdu->data -1;
  894|      0|    pdu->data += optsize;
  895|    155|  } else {
  896|    155|    opt = pdu->token + pdu->used_size;
  897|    155|  }
  898|       |
  899|       |  /* encode option and check length */
  900|    155|  optsize = coap_opt_encode(opt, pdu->alloc_size - pdu->used_size,
  901|    155|                            number - pdu->max_opt, data, len);
  902|       |
  903|    155|  if (!optsize) {
  ------------------
  |  Branch (903:7): [True: 0, False: 155]
  ------------------
  904|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  905|       |    /* error */
  906|      0|    return 0;
  907|    155|  } else {
  908|    155|    pdu->max_opt = number;
  909|    155|    pdu->used_size += optsize;
  910|    155|  }
  911|       |
  912|    155|  return optsize;
  913|    155|}
coap_add_data:
  916|     14|coap_add_data(coap_pdu_t *pdu, size_t len, const uint8_t *data) {
  917|     14|  if (len == 0) {
  ------------------
  |  Branch (917:7): [True: 0, False: 14]
  ------------------
  918|      0|    return 1;
  919|     14|  } else {
  920|     14|    uint8_t *payload = coap_add_data_after(pdu, len);
  921|     14|    if (payload != NULL)
  ------------------
  |  Branch (921:9): [True: 2, False: 12]
  ------------------
  922|      2|      memcpy(payload, data, len);
  923|       |    return payload != NULL;
  924|     14|  }
  925|     14|}
coap_add_data_after:
  928|     14|coap_add_data_after(coap_pdu_t *pdu, size_t len) {
  929|     14|  assert(pdu);
  ------------------
  |  Branch (929:3): [True: 14, False: 0]
  ------------------
  930|     14|  if (pdu->data) {
  ------------------
  |  Branch (930:7): [True: 0, False: 14]
  ------------------
  931|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  932|      0|    return 0;
  933|      0|  }
  934|       |
  935|     14|  if (len == 0)
  ------------------
  |  Branch (935:7): [True: 0, False: 14]
  ------------------
  936|      0|    return NULL;
  937|       |
  938|     14|  if (!coap_pdu_resize(pdu, pdu->used_size + len + 1))
  ------------------
  |  Branch (938:7): [True: 12, False: 2]
  ------------------
  939|     12|    return 0;
  940|      2|  pdu->token[pdu->used_size++] = COAP_PAYLOAD_START;
  ------------------
  |  |   96|      2|#define COAP_PAYLOAD_START 0xFF /* payload marker */
  ------------------
  941|      2|  pdu->data = pdu->token + pdu->used_size;
  942|      2|  pdu->used_size += len;
  943|      2|  return pdu->data;
  944|     14|}
coap_get_data_large:
  956|     19|                    size_t *offset, size_t *total) {
  957|     19|  assert(pdu);
  ------------------
  |  Branch (957:3): [True: 19, False: 0]
  ------------------
  958|     19|  assert(len);
  ------------------
  |  Branch (958:3): [True: 19, False: 0]
  ------------------
  959|     19|  assert(data);
  ------------------
  |  Branch (959:3): [True: 19, False: 0]
  ------------------
  960|       |
  961|     19|  *offset = pdu->body_offset;
  962|     19|  *total = pdu->body_total;
  963|     19|  if (pdu->body_data) {
  ------------------
  |  Branch (963:7): [True: 0, False: 19]
  ------------------
  964|      0|    *data = pdu->body_data;
  965|      0|    *len = pdu->body_length;
  966|      0|    return 1;
  967|      0|  }
  968|     19|  *data = pdu->data;
  969|     19|  if (pdu->data == NULL) {
  ------------------
  |  Branch (969:7): [True: 19, False: 0]
  ------------------
  970|     19|    *len = 0;
  971|     19|    *total = 0;
  972|     19|    return 0;
  973|     19|  }
  974|       |
  975|      0|  *len = pdu->used_size - (pdu->data - pdu->token);
  976|      0|  if (*total == 0)
  ------------------
  |  Branch (976:7): [True: 0, False: 0]
  ------------------
  977|      0|    *total = *len;
  978|       |
  979|      0|  return 1;
  980|     19|}
coap_pdu_parse_opt_base:
 1275|    169|coap_pdu_parse_opt_base(coap_option_num_t number, size_t len, const uint8_t *opt_val) {
 1276|    169|  int res = 1;
 1277|       |
 1278|    169|  switch ((coap_code_opt_num_t)number) {
 1279|      0|  case COAP_OPTION_IF_MATCH:
  ------------------
  |  Branch (1279:3): [True: 0, False: 169]
  ------------------
 1280|      0|    if (len > 8)
  ------------------
  |  Branch (1280:9): [True: 0, False: 0]
  ------------------
 1281|      0|      res = 0;
 1282|      0|    break;
 1283|     36|  case COAP_OPTION_URI_HOST:
  ------------------
  |  Branch (1283:3): [True: 36, False: 133]
  ------------------
 1284|     36|    if (len < 1 || len > 255)
  ------------------
  |  Branch (1284:9): [True: 0, False: 36]
  |  Branch (1284:20): [True: 0, False: 36]
  ------------------
 1285|      0|      res = 0;
 1286|     36|    break;
 1287|      0|  case COAP_OPTION_ETAG:
  ------------------
  |  Branch (1287:3): [True: 0, False: 169]
  ------------------
 1288|      0|    if (len < 1 || len > 8)
  ------------------
  |  Branch (1288:9): [True: 0, False: 0]
  |  Branch (1288:20): [True: 0, False: 0]
  ------------------
 1289|      0|      res = 0;
 1290|      0|    break;
 1291|      0|  case COAP_OPTION_IF_NONE_MATCH:
  ------------------
  |  Branch (1291:3): [True: 0, False: 169]
  ------------------
 1292|      0|    if (len != 0)
  ------------------
  |  Branch (1292:9): [True: 0, False: 0]
  ------------------
 1293|      0|      res = 0;
 1294|      0|    break;
 1295|      4|  case COAP_OPTION_OBSERVE:
  ------------------
  |  Branch (1295:3): [True: 4, False: 165]
  ------------------
 1296|      4|    if (len > 3)
  ------------------
  |  Branch (1296:9): [True: 4, False: 0]
  ------------------
 1297|      4|      res = 0;
 1298|      4|    break;
 1299|     21|  case COAP_OPTION_URI_PORT:
  ------------------
  |  Branch (1299:3): [True: 21, False: 148]
  ------------------
 1300|     21|    if (len > 2)
  ------------------
  |  Branch (1300:9): [True: 0, False: 21]
  ------------------
 1301|      0|      res = 0;
 1302|     21|    break;
 1303|      0|  case COAP_OPTION_LOCATION_PATH:
  ------------------
  |  Branch (1303:3): [True: 0, False: 169]
  ------------------
 1304|     75|  case COAP_OPTION_URI_PATH:
  ------------------
  |  Branch (1304:3): [True: 75, False: 94]
  ------------------
 1305|     75|    if (len > 255)
  ------------------
  |  Branch (1305:9): [True: 0, False: 75]
  ------------------
 1306|      0|      res = 0;
 1307|     75|    if (coap_check_dots(opt_val, len)) {
  ------------------
  |  Branch (1307:9): [True: 0, False: 75]
  ------------------
 1308|      0|      res = 0;
 1309|      0|    }
 1310|     75|    break;
 1311|      0|  case COAP_OPTION_OSCORE:
  ------------------
  |  Branch (1311:3): [True: 0, False: 169]
  ------------------
 1312|      0|    if (len > 255)
  ------------------
  |  Branch (1312:9): [True: 0, False: 0]
  ------------------
 1313|      0|      res = 0;
 1314|      0|    break;
 1315|      0|  case COAP_OPTION_CONTENT_FORMAT:
  ------------------
  |  Branch (1315:3): [True: 0, False: 169]
  ------------------
 1316|      0|    if (len > 2)
  ------------------
  |  Branch (1316:9): [True: 0, False: 0]
  ------------------
 1317|      0|      res = 0;
 1318|      0|    break;
 1319|      0|  case COAP_OPTION_URI_PATH_ABB:
  ------------------
  |  Branch (1319:3): [True: 0, False: 169]
  ------------------
 1320|      0|    if (len > 4)
  ------------------
  |  Branch (1320:9): [True: 0, False: 0]
  ------------------
 1321|      0|      res = 0;
 1322|      0|    break;
 1323|      0|  case COAP_OPTION_MAXAGE:
  ------------------
  |  Branch (1323:3): [True: 0, False: 169]
  ------------------
 1324|      0|    if (len > 4)
  ------------------
  |  Branch (1324:9): [True: 0, False: 0]
  ------------------
 1325|      0|      res = 0;
 1326|      0|    break;
 1327|      0|  case COAP_OPTION_URI_QUERY:
  ------------------
  |  Branch (1327:3): [True: 0, False: 169]
  ------------------
 1328|      0|    if (len < 1 || len > 255)
  ------------------
  |  Branch (1328:9): [True: 0, False: 0]
  |  Branch (1328:20): [True: 0, False: 0]
  ------------------
 1329|      0|      res = 0;
 1330|      0|    break;
 1331|      9|  case COAP_OPTION_HOP_LIMIT:
  ------------------
  |  Branch (1331:3): [True: 9, False: 160]
  ------------------
 1332|      9|    if (len != 1)
  ------------------
  |  Branch (1332:9): [True: 0, False: 9]
  ------------------
 1333|      0|      res = 0;
 1334|      9|    break;
 1335|      0|  case COAP_OPTION_ACCEPT:
  ------------------
  |  Branch (1335:3): [True: 0, False: 169]
  ------------------
 1336|      0|    if (len > 2)
  ------------------
  |  Branch (1336:9): [True: 0, False: 0]
  ------------------
 1337|      0|      res = 0;
 1338|      0|    break;
 1339|      0|  case COAP_OPTION_Q_BLOCK1:
  ------------------
  |  Branch (1339:3): [True: 0, False: 169]
  ------------------
 1340|      0|    if (len > 3)
  ------------------
  |  Branch (1340:9): [True: 0, False: 0]
  ------------------
 1341|      0|      res = 0;
 1342|      0|    break;
 1343|      0|  case COAP_OPTION_LOCATION_QUERY:
  ------------------
  |  Branch (1343:3): [True: 0, False: 169]
  ------------------
 1344|      0|    if (len > 255)
  ------------------
  |  Branch (1344:9): [True: 0, False: 0]
  ------------------
 1345|      0|      res = 0;
 1346|      0|    break;
 1347|      0|  case COAP_OPTION_EDHOC:
  ------------------
  |  Branch (1347:3): [True: 0, False: 169]
  ------------------
 1348|      0|    if (len != 0)
  ------------------
  |  Branch (1348:9): [True: 0, False: 0]
  ------------------
 1349|      0|      res = 0;
 1350|      0|    break;
 1351|      0|  case COAP_OPTION_BLOCK2:
  ------------------
  |  Branch (1351:3): [True: 0, False: 169]
  ------------------
 1352|      0|    if (len > 3)
  ------------------
  |  Branch (1352:9): [True: 0, False: 0]
  ------------------
 1353|      0|      res = 0;
 1354|      0|    break;
 1355|      0|  case COAP_OPTION_BLOCK1:
  ------------------
  |  Branch (1355:3): [True: 0, False: 169]
  ------------------
 1356|      0|    if (len > 3)
  ------------------
  |  Branch (1356:9): [True: 0, False: 0]
  ------------------
 1357|      0|      res = 0;
 1358|      0|    break;
 1359|      0|  case COAP_OPTION_SIZE2:
  ------------------
  |  Branch (1359:3): [True: 0, False: 169]
  ------------------
 1360|      0|    if (len > 4)
  ------------------
  |  Branch (1360:9): [True: 0, False: 0]
  ------------------
 1361|      0|      res = 0;
 1362|      0|    break;
 1363|      0|  case COAP_OPTION_Q_BLOCK2:
  ------------------
  |  Branch (1363:3): [True: 0, False: 169]
  ------------------
 1364|      0|    if (len > 3)
  ------------------
  |  Branch (1364:9): [True: 0, False: 0]
  ------------------
 1365|      0|      res = 0;
 1366|      0|    break;
 1367|     14|  case COAP_OPTION_PROXY_URI:
  ------------------
  |  Branch (1367:3): [True: 14, False: 155]
  ------------------
 1368|     14|    if (len < 1 || len > 1034)
  ------------------
  |  Branch (1368:9): [True: 0, False: 14]
  |  Branch (1368:20): [True: 0, False: 14]
  ------------------
 1369|      0|      res = 0;
 1370|     14|    break;
 1371|     10|  case COAP_OPTION_PROXY_SCHEME:
  ------------------
  |  Branch (1371:3): [True: 10, False: 159]
  ------------------
 1372|     10|    if (len < 1 || len > 255)
  ------------------
  |  Branch (1372:9): [True: 0, False: 10]
  |  Branch (1372:20): [True: 0, False: 10]
  ------------------
 1373|      0|      res = 0;
 1374|     10|    break;
 1375|      0|  case COAP_OPTION_SIZE1:
  ------------------
  |  Branch (1375:3): [True: 0, False: 169]
  ------------------
 1376|      0|    if (len > 4)
  ------------------
  |  Branch (1376:9): [True: 0, False: 0]
  ------------------
 1377|      0|      res = 0;
 1378|      0|    break;
 1379|      0|  case COAP_OPTION_ECHO:
  ------------------
  |  Branch (1379:3): [True: 0, False: 169]
  ------------------
 1380|      0|    if (len > 40)
  ------------------
  |  Branch (1380:9): [True: 0, False: 0]
  ------------------
 1381|      0|      res = 0;
 1382|      0|    break;
 1383|      0|  case COAP_OPTION_NORESPONSE:
  ------------------
  |  Branch (1383:3): [True: 0, False: 169]
  ------------------
 1384|      0|    if (len > 1)
  ------------------
  |  Branch (1384:9): [True: 0, False: 0]
  ------------------
 1385|      0|      res = 0;
 1386|      0|    break;
 1387|      0|  case COAP_OPTION_RTAG:
  ------------------
  |  Branch (1387:3): [True: 0, False: 169]
  ------------------
 1388|      0|    if (len > 8)
  ------------------
  |  Branch (1388:9): [True: 0, False: 0]
  ------------------
 1389|      0|      res = 0;
 1390|      0|    break;
 1391|      0|  default:
  ------------------
  |  Branch (1391:3): [True: 0, False: 169]
  ------------------
 1392|      0|    ;
 1393|    169|  }
 1394|    169|  return res;
 1395|    169|}
coap_pdu_encode_header:
 1603|     19|coap_pdu_encode_header(coap_pdu_t *pdu, coap_proto_t proto) {
 1604|     19|  uint8_t e_token_length;
 1605|       |
 1606|     19|  if (pdu->actual_token.length < COAP_TOKEN_EXT_1B_BIAS) {
  ------------------
  |  |   56|     19|#define COAP_TOKEN_EXT_1B_BIAS 13
  ------------------
  |  Branch (1606:7): [True: 19, False: 0]
  ------------------
 1607|     19|    e_token_length = (uint8_t)pdu->actual_token.length;
 1608|     19|  } else if (pdu->actual_token.length < COAP_TOKEN_EXT_2B_BIAS) {
  ------------------
  |  |   57|      0|#define COAP_TOKEN_EXT_2B_BIAS 269 /* 13 + 256 */
  ------------------
  |  Branch (1608:14): [True: 0, False: 0]
  ------------------
 1609|      0|    e_token_length = COAP_TOKEN_EXT_1B_TKL;
  ------------------
  |  |   54|      0|#define COAP_TOKEN_EXT_1B_TKL 13
  ------------------
 1610|      0|  } else if (pdu->actual_token.length <= COAP_TOKEN_EXT_MAX) {
  ------------------
  |  |   60|      0|#define COAP_TOKEN_EXT_MAX 65804UL /* 13 + 256 + 65535 */
  ------------------
  |  Branch (1610:14): [True: 0, False: 0]
  ------------------
 1611|      0|    e_token_length = COAP_TOKEN_EXT_2B_TKL;
  ------------------
  |  |   55|      0|#define COAP_TOKEN_EXT_2B_TKL 14
  ------------------
 1612|      0|  } else {
 1613|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1614|      0|    return 0;
 1615|      0|  }
 1616|     19|  if (COAP_PROTO_NOT_RELIABLE(proto)) {
  ------------------
  |  |   41|     19|#define COAP_PROTO_NOT_RELIABLE(p) ((p)==COAP_PROTO_UDP || (p)==COAP_PROTO_DTLS)
  |  |  ------------------
  |  |  |  Branch (41:37): [True: 19, False: 0]
  |  |  |  Branch (41:60): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1617|     19|    assert(pdu->max_hdr_size >= 4);
  ------------------
  |  Branch (1617:5): [True: 19, False: 0]
  ------------------
 1618|     19|    if (pdu->max_hdr_size < 4) {
  ------------------
  |  Branch (1618:9): [True: 0, False: 19]
  ------------------
 1619|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1620|      0|      return 0;
 1621|      0|    }
 1622|     19|    pdu->token[-4] = COAP_DEFAULT_VERSION << 6
  ------------------
  |  |   35|     19|#define COAP_DEFAULT_VERSION      1 /* version of CoAP supported */
  ------------------
 1623|     19|                     | pdu->type << 4
 1624|     19|                     | e_token_length;
 1625|     19|    pdu->token[-3] = pdu->code;
 1626|     19|    pdu->token[-2] = (uint8_t)(pdu->mid >> 8);
 1627|     19|    pdu->token[-1] = (uint8_t)(pdu->mid);
 1628|     19|    pdu->hdr_size = 4;
 1629|     19|#if !COAP_DISABLE_TCP
 1630|     19|  } 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]
  |  |  ------------------
  ------------------
 1631|      0|    size_t len;
 1632|      0|    assert(pdu->used_size >= pdu->e_token_length);
  ------------------
  |  Branch (1632:5): [True: 0, False: 0]
  ------------------
 1633|      0|    if (pdu->used_size < pdu->e_token_length) {
  ------------------
  |  Branch (1633:9): [True: 0, False: 0]
  ------------------
 1634|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1635|      0|      return 0;
 1636|      0|    }
 1637|       |
 1638|       |    /* A lot of the reliable code assumes type is CON */
 1639|      0|    if (pdu->type != COAP_MESSAGE_CON)
  ------------------
  |  Branch (1639:9): [True: 0, False: 0]
  ------------------
 1640|      0|      pdu->type = COAP_MESSAGE_CON;
 1641|       |
 1642|      0|    if (proto == COAP_PROTO_WS || proto == COAP_PROTO_WSS)
  ------------------
  |  Branch (1642:9): [True: 0, False: 0]
  |  Branch (1642:35): [True: 0, False: 0]
  ------------------
 1643|      0|      len = 0;
 1644|      0|    else
 1645|      0|      len = pdu->used_size - pdu->e_token_length;
 1646|      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 (1646:9): [True: 0, False: 0]
  ------------------
 1647|      0|      assert(pdu->max_hdr_size >= 2);
  ------------------
  |  Branch (1647:7): [True: 0, False: 0]
  ------------------
 1648|      0|      if (pdu->max_hdr_size < 2) {
  ------------------
  |  Branch (1648:11): [True: 0, False: 0]
  ------------------
 1649|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1650|      0|        return 0;
 1651|      0|      }
 1652|      0|      pdu->token[-2] = (uint8_t)len << 4
 1653|      0|                       | e_token_length;
 1654|      0|      pdu->token[-1] = pdu->code;
 1655|      0|      pdu->hdr_size = 2;
 1656|      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 (1656:16): [True: 0, False: 0]
  ------------------
 1657|      0|      assert(pdu->max_hdr_size >= 3);
  ------------------
  |  Branch (1657:7): [True: 0, False: 0]
  ------------------
 1658|      0|      if (pdu->max_hdr_size < 3) {
  ------------------
  |  Branch (1658:11): [True: 0, False: 0]
  ------------------
 1659|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1660|      0|        return 0;
 1661|      0|      }
 1662|      0|      pdu->token[-3] = 13 << 4 | e_token_length;
 1663|      0|      pdu->token[-2] = (uint8_t)(len - COAP_MESSAGE_SIZE_OFFSET_TCP8);
  ------------------
  |  |   38|      0|#define COAP_MESSAGE_SIZE_OFFSET_TCP8 13
  ------------------
 1664|      0|      pdu->token[-1] = pdu->code;
 1665|      0|      pdu->hdr_size = 3;
 1666|      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 (1666:16): [True: 0, False: 0]
  ------------------
 1667|      0|      assert(pdu->max_hdr_size >= 4);
  ------------------
  |  Branch (1667:7): [True: 0, False: 0]
  ------------------
 1668|      0|      if (pdu->max_hdr_size < 4) {
  ------------------
  |  Branch (1668:11): [True: 0, False: 0]
  ------------------
 1669|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1670|      0|        return 0;
 1671|      0|      }
 1672|      0|      pdu->token[-4] = 14 << 4 | e_token_length;
 1673|      0|      pdu->token[-3] = (uint8_t)((len - COAP_MESSAGE_SIZE_OFFSET_TCP16) >> 8);
  ------------------
  |  |   39|      0|#define COAP_MESSAGE_SIZE_OFFSET_TCP16 269 /* 13 + 256 */
  ------------------
 1674|      0|      pdu->token[-2] = (uint8_t)(len - COAP_MESSAGE_SIZE_OFFSET_TCP16);
  ------------------
  |  |   39|      0|#define COAP_MESSAGE_SIZE_OFFSET_TCP16 269 /* 13 + 256 */
  ------------------
 1675|      0|      pdu->token[-1] = pdu->code;
 1676|      0|      pdu->hdr_size = 4;
 1677|      0|    } else {
 1678|      0|      assert(pdu->max_hdr_size >= 6);
  ------------------
  |  Branch (1678:7): [True: 0, False: 0]
  ------------------
 1679|      0|      if (pdu->max_hdr_size < 6) {
  ------------------
  |  Branch (1679:11): [True: 0, False: 0]
  ------------------
 1680|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1681|      0|        return 0;
 1682|      0|      }
 1683|      0|      pdu->token[-6] = 15 << 4 | e_token_length;
 1684|      0|      pdu->token[-5] = (uint8_t)((len - COAP_MESSAGE_SIZE_OFFSET_TCP32) >> 24);
  ------------------
  |  |   40|      0|#define COAP_MESSAGE_SIZE_OFFSET_TCP32 65805 /* 269 + 65536 */
  ------------------
 1685|      0|      pdu->token[-4] = (uint8_t)((len - COAP_MESSAGE_SIZE_OFFSET_TCP32) >> 16);
  ------------------
  |  |   40|      0|#define COAP_MESSAGE_SIZE_OFFSET_TCP32 65805 /* 269 + 65536 */
  ------------------
 1686|      0|      pdu->token[-3] = (uint8_t)((len - COAP_MESSAGE_SIZE_OFFSET_TCP32) >> 8);
  ------------------
  |  |   40|      0|#define COAP_MESSAGE_SIZE_OFFSET_TCP32 65805 /* 269 + 65536 */
  ------------------
 1687|      0|      pdu->token[-2] = (uint8_t)(len - COAP_MESSAGE_SIZE_OFFSET_TCP32);
  ------------------
  |  |   40|      0|#define COAP_MESSAGE_SIZE_OFFSET_TCP32 65805 /* 269 + 65536 */
  ------------------
 1688|      0|      pdu->token[-1] = pdu->code;
 1689|      0|      pdu->hdr_size = 6;
 1690|      0|    }
 1691|      0|#endif /* ! COAP_DISABLE_TCP */
 1692|      0|  } else {
 1693|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1694|      0|  }
 1695|     19|  return pdu->hdr_size;
 1696|     19|}
coap_pdu_get_token:
 1723|     36|coap_pdu_get_token(const coap_pdu_t *pdu) {
 1724|     36|  return pdu->actual_token;
 1725|     36|}
coap_const_pdu_reference_lkd:
 1749|     52|coap_const_pdu_reference_lkd(const coap_pdu_t *pdu) {
 1750|     52|  coap_pdu_t *pdu_rw = NULL;
 1751|       |
 1752|     52|  if (pdu != NULL) {
  ------------------
  |  Branch (1752:7): [True: 52, False: 0]
  ------------------
 1753|       |
 1754|       |    /* Need to do this to not get a compiler warning about const parameters */
 1755|     52|    memcpy(&pdu_rw, &pdu, sizeof(pdu_rw));
 1756|     52|    ++pdu_rw->ref;
 1757|     52|  }
 1758|     52|  return pdu_rw;
 1759|     52|}

coap_prng_init_lkd:
  178|     36|coap_prng_init_lkd(unsigned int seed) {
  179|     36|#ifdef HAVE_GETRANDOM
  180|       |  /* No seed to seed the random source if getrandom() is used */
  181|     36|  (void)seed;
  182|       |#elif defined(HAVE_RANDOM)
  183|       |  srandom(seed);
  184|       |#else /* !HAVE_GETRANDOM  && !HAVE_RANDOM */
  185|       |  srand(seed);
  186|       |#endif /* !HAVE_GETRANDOM */
  187|     36|}
coap_prng_lkd:
  190|    190|coap_prng_lkd(void *buf, size_t len) {
  191|    190|  if (!rand_func) {
  ------------------
  |  Branch (191:7): [True: 0, False: 190]
  ------------------
  192|      0|    return 0;
  193|      0|  }
  194|       |
  195|    190|  return rand_func(buf, len);
  196|    190|}
coap_prng.c:coap_prng_default:
  108|    190|coap_prng_default(void *buf, size_t len) {
  109|       |#if defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
  110|       |  /* mbedtls_hardware_poll() returns 0 on success */
  111|       |  return (mbedtls_hardware_poll(NULL, buf, len, NULL) ? 0 : 1);
  112|       |
  113|       |#elif defined(__ZEPHYR__)
  114|       |  /* Use Zephyr's cryptographically secure random number generator */
  115|       |  if (!buf || len == 0) {
  116|       |    return 0;
  117|       |  }
  118|       |
  119|       |  sys_rand_get(buf, len);
  120|       |  return 1;
  121|       |
  122|       |#elif defined(HAVE_GETRANDOM)
  123|    190|  return (getrandom(buf, len, 0) > 0) ? 1 : 0;
  ------------------
  |  Branch (123:10): [True: 190, False: 0]
  ------------------
  124|       |
  125|       |#elif defined(HAVE_RANDOM)
  126|       |#define RAND_BYTES (RAND_MAX >= 0xffffff ? 3 : (RAND_MAX >= 0xffff ? 2 : 1))
  127|       |  unsigned char *dst = (unsigned char *)buf;
  128|       |
  129|       |  if (len) {
  130|       |    uint8_t byte_counter = RAND_BYTES;
  131|       |    uint32_t r_v = random();
  132|       |
  133|       |    while (1) {
  134|       |      *dst++ = r_v & 0xFF;
  135|       |      if (!--len) {
  136|       |        break;
  137|       |      }
  138|       |      if (--byte_counter) {
  139|       |        r_v >>= 8;
  140|       |      } else {
  141|       |        r_v = random();
  142|       |        byte_counter = RAND_BYTES;
  143|       |      }
  144|       |    }
  145|       |  }
  146|       |  return 1;
  147|       |#elif defined(RIOT_VERSION)
  148|       |#include <random.h>
  149|       |  random_bytes(buf, len);
  150|       |  return 1;
  151|       |
  152|       |#elif defined(WITH_CONTIKI)
  153|       |  return csprng_rand(buf, len);
  154|       |
  155|       |#elif defined(_WIN32)
  156|       |  return coap_prng_impl(buf,len);
  157|       |
  158|       |#else /* !MBEDTLS_ENTROPY_HARDWARE_ALT && !HAVE_GETRANDOM &&
  159|       |         !HAVE_RANDOM && !_WIN32 */
  160|       |#error "CVE-2021-34430: using rand() for crypto randoms is not secure!"
  161|       |#error "Please update you C-library and rerun the auto-configuration."
  162|       |  unsigned char *dst = (unsigned char *)buf;
  163|       |  while (len--)
  164|       |    *dst++ = rand() & 0xFF;
  165|       |  return 1;
  166|       |#endif /* !MBEDTLS_ENTROPY_HARDWARE_ALT && !HAVE_GETRANDOM &&
  167|       |          !HAVE_RANDOM && !_WIN32 */
  168|    190|}

coap_proxy_log_entry:
   43|     97|                     coap_bin_const_t *upstream_token, const char *type) {
   44|     97|  if (coap_get_log_level() >= COAP_LOG_DEBUG) {
  ------------------
  |  Branch (44:7): [True: 0, False: 97]
  ------------------
   45|      0|    coap_string_t *url;
   46|       |
   47|      0|    url = coap_get_uri_path(pdu);
   48|      0|    if (url) {
  ------------------
  |  Branch (48:9): [True: 0, False: 0]
  ------------------
   49|      0|      coap_opt_iterator_t opt_iter;
   50|      0|      uint8_t addr[INET6_ADDRSTRLEN + 8];
   51|      0|      char scratch_d[24];
   52|      0|      char scratch_u[24];
   53|      0|      size_t size;
   54|      0|      size_t i;
   55|       |
   56|      0|      scratch_d[0] = '\000';
   57|      0|      for (i = 0; i < pdu->actual_token.length; i++) {
  ------------------
  |  Branch (57:19): [True: 0, False: 0]
  ------------------
   58|      0|        size = strlen(scratch_d);
   59|      0|        snprintf(&scratch_d[size], sizeof(scratch_d)-size,
   60|      0|                 "%02x", pdu->actual_token.s[i]);
   61|      0|      }
   62|      0|      scratch_u[0] = '\000';
   63|      0|      if (upstream_token) {
  ------------------
  |  Branch (63:11): [True: 0, False: 0]
  ------------------
   64|      0|        for (i = 0; i < upstream_token->length; i++) {
  ------------------
  |  Branch (64:21): [True: 0, False: 0]
  ------------------
   65|      0|          size = strlen(scratch_u);
   66|      0|          snprintf(&scratch_u[size], sizeof(scratch_u)-size,
   67|      0|                   "%02x", upstream_token->s[i]);
   68|      0|        }
   69|      0|      }
   70|      0|      (void)coap_print_addr(coap_session_get_addr_remote(incoming), addr, sizeof(addr));
   71|      0|      coap_log_debug("   proxy %-4s %s {%s}-{%s} \"%s\"%s\n", type, addr, scratch_u, scratch_d,
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   72|      0|                     url->s, coap_check_option(pdu, COAP_OPTION_OBSERVE, &opt_iter) ? " Observe" : "");
   73|      0|      coap_delete_string(url);
   74|      0|    }
   75|      0|  }
   76|     97|}
coap_proxy_del_req:
   79|     26|coap_proxy_del_req(coap_proxy_entry_t *proxy_entry, coap_proxy_req_t *proxy_req) {
   80|     26|  coap_proxy_log_entry(proxy_req->incoming, proxy_req->pdu,  proxy_req->token_used, "del");
   81|       |
   82|     26|  coap_delete_pdu_lkd(proxy_req->pdu);
   83|     26|  coap_delete_bin_const(proxy_req->token_used);
   84|     26|  coap_delete_cache_key(proxy_req->cache_key);
   85|     26|  if (proxy_req->proxy_cache) {
  ------------------
  |  Branch (85:7): [True: 0, False: 26]
  ------------------
   86|      0|    if (coap_get_log_level() >= COAP_LOG_DEBUG) {
  ------------------
  |  Branch (86:9): [True: 0, False: 0]
  ------------------
   87|      0|      coap_string_t *url;
   88|       |
   89|      0|      url = coap_get_uri_path(proxy_req->proxy_cache->req_pdu);
   90|      0|      coap_log_debug("***%s: Removing Proxy Cache \"%s\" (Active %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__); \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (292:30): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   91|      0|                     coap_session_str(proxy_req->incoming),
   92|      0|                     url ? (char *)url->s : "???",
   93|      0|                     proxy_req->proxy_cache->ref);
   94|      0|      coap_delete_string(url);
   95|      0|    }
   96|      0|    assert(proxy_req->proxy_cache->ref);
  ------------------
  |  Branch (96:5): [True: 0, False: 0]
  ------------------
   97|      0|    proxy_req->proxy_cache->ref--;
   98|      0|    if (proxy_req->proxy_cache->ref == 0) {
  ------------------
  |  Branch (98:9): [True: 0, False: 0]
  ------------------
   99|      0|      PROXY_CACHE_DELETE(proxy_entry->rsp_cache, proxy_req->proxy_cache);
  ------------------
  |  |  287|      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]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  100|      0|      coap_delete_pdu_lkd(proxy_req->proxy_cache->req_pdu);
  101|      0|      coap_delete_pdu_lkd(proxy_req->proxy_cache->rsp_pdu);
  102|      0|      coap_free_type(COAP_STRING, proxy_req->proxy_cache);
  103|      0|      proxy_req->proxy_cache = NULL;
  104|      0|    }
  105|      0|    if (proxy_req->doing_observe) {
  ------------------
  |  Branch (105:9): [True: 0, False: 0]
  ------------------
  106|      0|      assert(proxy_req->incoming->ref_proxy_subs);
  ------------------
  |  Branch (106:7): [True: 0, False: 0]
  ------------------
  107|      0|      proxy_req->incoming->ref_proxy_subs--;
  108|      0|      proxy_req->doing_observe = 0;
  109|      0|    }
  110|      0|  }
  111|       |  /* To prevent potential loops */
  112|     26|  proxy_req->incoming = NULL;
  113|       |
  114|     26|  LL_DELETE(proxy_entry->proxy_req, proxy_req);
  ------------------
  |  |  391|     26|    LL_DELETE2(head,del,next)
  |  |  ------------------
  |  |  |  |  393|     26|#define LL_DELETE2(head,del,next)                                                              \
  |  |  |  |  394|     26|do {                                                                                           \
  |  |  |  |  395|     26|  LDECLTYPE(head) _tmp;                                                                        \
  |  |  |  |  ------------------
  |  |  |  |  |  |   81|     26|#define LDECLTYPE(x) __typeof(x)
  |  |  |  |  ------------------
  |  |  |  |  396|     26|  if ((head) == (del)) {                                                                       \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (396:7): [True: 26, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  397|     26|    (head)=(head)->next;                                                                       \
  |  |  |  |  398|     26|  } 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|     26|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (407:10): [Folded, False: 26]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  115|     26|  coap_free_type(COAP_STRING, proxy_req);
  116|     26|}
coap_proxy_cleanup:
  154|     36|coap_proxy_cleanup(coap_context_t *context) {
  155|     36|  size_t i;
  156|       |
  157|     62|  for (i = 0; i < context->proxy_list_count; i++) {
  ------------------
  |  Branch (157:15): [True: 26, False: 36]
  ------------------
  158|       |    /* All sessions have now been closed down */
  159|     26|    coap_log_debug("proxy_entry %p cleaned up\n",
  ------------------
  |  |  126|     26|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|     26|#define coap_log(level, ...) do { \
  |  |  |  |  291|     26|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 26]
  |  |  |  |  ------------------
  |  |  |  |  292|     26|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|     26|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 26]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  160|     26|                   (void *)&context->proxy_list[i]);
  161|     26|    coap_proxy_cleanup_entry(&context->proxy_list[i], 0);
  162|     26|  }
  163|     36|  coap_free_type(COAP_STRING, context->proxy_list);
  164|     36|}
coap_verify_proxy_scheme_supported:
  272|     26|coap_verify_proxy_scheme_supported(coap_uri_scheme_t scheme) {
  273|       |
  274|       |  /* Sanity check that the connection can be forwarded on */
  275|     26|  switch (scheme) {
  276|      0|  case COAP_URI_SCHEME_HTTP:
  ------------------
  |  Branch (276:3): [True: 0, False: 26]
  ------------------
  277|      0|  case COAP_URI_SCHEME_HTTPS:
  ------------------
  |  Branch (277:3): [True: 0, False: 26]
  ------------------
  278|      0|    coap_log_warn("Proxy URI http or https 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  279|      0|    return 0;
  280|     26|  case COAP_URI_SCHEME_COAP:
  ------------------
  |  Branch (280:3): [True: 26, False: 0]
  ------------------
  281|     26|    break;
  282|      0|  case COAP_URI_SCHEME_COAPS:
  ------------------
  |  Branch (282:3): [True: 0, False: 26]
  ------------------
  283|      0|    if (!coap_dtls_is_supported()) {
  ------------------
  |  Branch (283:9): [True: 0, False: 0]
  ------------------
  284|      0|      coap_log_warn("coaps URI scheme not supported for proxy\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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  285|      0|      return 0;
  286|      0|    }
  287|      0|    break;
  288|      0|  case COAP_URI_SCHEME_COAP_TCP:
  ------------------
  |  Branch (288:3): [True: 0, False: 26]
  ------------------
  289|      0|    if (!coap_tcp_is_supported()) {
  ------------------
  |  Branch (289:9): [True: 0, False: 0]
  ------------------
  290|      0|      coap_log_warn("coap+tcp URI scheme not supported for proxy\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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  291|      0|      return 0;
  292|      0|    }
  293|      0|    break;
  294|      0|  case COAP_URI_SCHEME_COAPS_TCP:
  ------------------
  |  Branch (294:3): [True: 0, False: 26]
  ------------------
  295|      0|    if (!coap_tls_is_supported()) {
  ------------------
  |  Branch (295:9): [True: 0, False: 0]
  ------------------
  296|      0|      coap_log_warn("coaps+tcp URI scheme not supported for proxy\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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  297|      0|      return 0;
  298|      0|    }
  299|      0|    break;
  300|      0|  case COAP_URI_SCHEME_COAP_WS:
  ------------------
  |  Branch (300:3): [True: 0, False: 26]
  ------------------
  301|      0|    if (!coap_ws_is_supported()) {
  ------------------
  |  Branch (301:9): [True: 0, False: 0]
  ------------------
  302|      0|      coap_log_warn("coap+ws URI scheme not supported for proxy\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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  303|      0|      return 0;
  304|      0|    }
  305|      0|    break;
  306|      0|  case COAP_URI_SCHEME_COAPS_WS:
  ------------------
  |  Branch (306:3): [True: 0, False: 26]
  ------------------
  307|      0|    if (!coap_wss_is_supported()) {
  ------------------
  |  Branch (307:9): [True: 0, False: 0]
  ------------------
  308|      0|      coap_log_warn("coaps+ws URI scheme not supported for proxy\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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  309|      0|      return 0;
  310|      0|    }
  311|      0|    break;
  312|      0|  case COAP_URI_SCHEME_LAST:
  ------------------
  |  Branch (312:3): [True: 0, False: 26]
  ------------------
  313|      0|  default:
  ------------------
  |  Branch (313:3): [True: 0, False: 26]
  ------------------
  314|      0|    coap_log_warn("%d URI scheme not supported\n", scheme);
  ------------------
  |  |  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|    return 0;
  316|     26|  }
  317|     26|  return 1;
  318|     26|}
coap_proxy_forward_request:
  919|     36|                           coap_proxy_server_list_t *server_list) {
  920|     36|  int ret;
  921|       |
  922|     36|  coap_lock_lock(return 0);
  923|     36|  ret = coap_proxy_forward_request_lkd(session,
  924|     36|                                       request,
  925|     36|                                       response,
  926|     36|                                       resource,
  927|     36|                                       cache_key,
  928|     36|                                       server_list);
  929|     36|  coap_lock_unlock();
  930|     36|  return ret;
  931|     36|}
coap_proxy_forward_request_lkd:
  947|     36|                               coap_proxy_server_list_t *server_list) {
  948|     36|  coap_proxy_entry_t *proxy_entry;
  949|     36|  size_t size;
  950|     36|  size_t offset;
  951|     36|  size_t total;
  952|     36|  coap_binary_t *body_data = NULL;
  953|     36|  const uint8_t *data;
  954|     36|  coap_pdu_t *pdu = NULL;
  955|     36|  coap_bin_const_t r_token = coap_pdu_get_token(request);
  956|     36|  uint8_t token[8];
  957|     36|  size_t token_len;
  958|     36|  coap_proxy_req_t *proxy_req = NULL;
  959|     36|  coap_optlist_t *optlist = NULL;
  960|     36|  coap_opt_t *option;
  961|     36|  coap_opt_iterator_t opt_iter;
  962|     36|  coap_uri_t uri;
  963|     36|  coap_opt_t *obs_opt = coap_check_option(request,
  964|     36|                                          COAP_OPTION_OBSERVE,
  965|     36|                                          &opt_iter);
  966|     36|  coap_proxy_cache_t *proxy_cache = NULL;
  967|     36|  coap_proxy_t proxy_type;
  968|     36|  coap_tick_t now;
  969|     36|  uint32_t new_maxage;
  970|     36|  uint8_t buf[4];
  971|       |
  972|     36|  coap_ticks(&now);
  973|       |
  974|       |  /* Set up ongoing session (if not already done) */
  975|     36|  proxy_entry = coap_proxy_get_ongoing_session(session, request, response,
  976|     36|                                               server_list);
  977|     36|  if (!proxy_entry) {
  ------------------
  |  Branch (977:7): [True: 10, False: 26]
  ------------------
  978|       |    /* Error response code already set */
  979|     10|    return 0;
  980|     10|  }
  981|     26|  coap_proxy_log_entry(session, request, NULL, "req");
  982|       |
  983|       |  /* Is this a observe cached request? */
  984|     26|  if (obs_opt && session->context->proxy_response_cb) {
  ------------------
  |  Branch (984:7): [True: 0, False: 26]
  |  Branch (984:18): [True: 0, False: 0]
  ------------------
  985|      0|    coap_cache_key_t *cache_key_l;
  986|       |
  987|      0|    cache_key_l = coap_cache_derive_key_w_ignore(session, request,
  988|      0|                                                 COAP_CACHE_NOT_SESSION_BASED,
  989|      0|                                                 coap_proxy_ignore_options,
  990|      0|                                                 sizeof(coap_proxy_ignore_options)/sizeof(coap_proxy_ignore_options[0]));
  991|      0|    if (!cache_key_l) {
  ------------------
  |  Branch (991:9): [True: 0, False: 0]
  ------------------
  992|      0|      response->code = COAP_RESPONSE_CODE(505);
  ------------------
  |  |   96|      0|#define COAP_RESPONSE_CODE(N) (((N)/100 << 5) | (N)%100)
  ------------------
  993|      0|      return 0;
  994|      0|    }
  995|      0|    PROXY_CACHE_FIND(proxy_entry->rsp_cache, cache_key_l, proxy_cache);
  ------------------
  |  |  295|      0|#define PROXY_CACHE_FIND(e, k, res) {                     \
  |  |  296|      0|    HASH_FIND(hh, (e), (k), sizeof(*k), (res)); \
  |  |  ------------------
  |  |  |  |  179|      0|#define HASH_FIND(hh,head,keyptr,keylen,out)                                     \
  |  |  |  |  180|      0|do {                                                                             \
  |  |  |  |  181|      0|  (out) = NULL;                                                                  \
  |  |  |  |  182|      0|  if (head) {                                                                    \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (182:7): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  183|      0|    uint32_t _hf_hashv;                                                          \
  |  |  |  |  184|      0|    HASH_VALUE(keyptr, keylen, _hf_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]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  185|      0|    HASH_FIND_BYHASHVALUE(hh, head, keyptr, keylen, _hf_hashv, out);             \
  |  |  |  |  ------------------
  |  |  |  |  |  |  167|      0|#define HASH_FIND_BYHASHVALUE(hh,head,keyptr,keylen,hashval,out)                 \
  |  |  |  |  |  |  168|      0|do {                                                                             \
  |  |  |  |  |  |  169|      0|  (out) = NULL;                                                                  \
  |  |  |  |  |  |  170|      0|  if (head) {                                                                    \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (170:7): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  171|      0|    uint32_t _hf_bkt;                                                            \
  |  |  |  |  |  |  172|      0|    HASH_TO_BKT(hashval, (head)->hh.tbl->num_buckets, _hf_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]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  173|      0|    if (HASH_BLOOM_TEST((head)->hh.tbl, hashval) != 0) {                         \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  222|      0|#define HASH_BLOOM_TEST(tbl,hashv) (1)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (173:9): [True: 0, Folded]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  174|      0|      HASH_FIND_IN_BKT((head)->hh.tbl, hh, (head)->hh.tbl->buckets[ _hf_bkt ], keyptr, keylen, hashval, out); \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  756|      0|#define HASH_FIND_IN_BKT(tbl,hh,head,keyptr,keylen_in,hashval,out)               \
  |  |  |  |  |  |  |  |  757|      0|do {                                                                             \
  |  |  |  |  |  |  |  |  758|      0|  if ((head).hh_head != NULL) {                                                  \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (758:7): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  759|      0|    DECLTYPE_ASSIGN(out, ELMT_FROM_HH(tbl, (head).hh_head));                     \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   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]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  760|      0|  } else {                                                                       \
  |  |  |  |  |  |  |  |  761|      0|    (out) = NULL;                                                                \
  |  |  |  |  |  |  |  |  762|      0|  }                                                                              \
  |  |  |  |  |  |  |  |  763|      0|  while ((out) != NULL) {                                                        \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (763:10): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  764|      0|    if ((out)->hh.hashv == (hashval) && (out)->hh.keylen == (keylen_in)) {       \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (764:9): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  Branch (764:41): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  765|      0|      if (HASH_KEYCMP((out)->hh.key, keyptr, keylen_in) == 0) {                  \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  106|      0|#define HASH_KEYCMP(a,b,n) memcmp(a,b,n)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (765:11): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  766|      0|        break;                                                                   \
  |  |  |  |  |  |  |  |  767|      0|      }                                                                          \
  |  |  |  |  |  |  |  |  768|      0|    }                                                                            \
  |  |  |  |  |  |  |  |  769|      0|    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|      0|} while (0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (775:10): [Folded, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  175|      0|    }                                                                            \
  |  |  |  |  |  |  176|      0|  }                                                                              \
  |  |  |  |  |  |  177|      0|} while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (177:10): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  186|      0|  }                                                                              \
  |  |  |  |  187|      0|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (187:10): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  297|      0|  }
  ------------------
  996|      0|    coap_delete_cache_key(cache_key_l);
  997|      0|  }
  998|       |
  999|     26|  if (proxy_cache) {
  ------------------
  |  Branch (999:7): [True: 0, False: 26]
  ------------------
 1000|      0|    proxy_req = coap_proxy_get_req(proxy_entry, proxy_cache, session);
 1001|      0|    if (proxy_req) {
  ------------------
  |  Branch (1001:9): [True: 0, False: 0]
  ------------------
 1002|      0|      if (obs_opt) {
  ------------------
  |  Branch (1002:11): [True: 0, False: 0]
  ------------------
 1003|      0|        int observe_action;
 1004|       |
 1005|      0|        observe_action = coap_decode_var_bytes(coap_opt_value(obs_opt),
 1006|      0|                                               coap_opt_length(obs_opt));
 1007|       |
 1008|      0|        if (observe_action == COAP_OBSERVE_CANCEL) {
  ------------------
  |  |   44|      0|#define COAP_OBSERVE_CANCEL 1
  ------------------
  |  Branch (1008:13): [True: 0, False: 0]
  ------------------
 1009|      0|          if (proxy_req->doing_observe) {
  ------------------
  |  Branch (1009:15): [True: 0, False: 0]
  ------------------
 1010|      0|            assert(proxy_req->incoming->ref_proxy_subs);
  ------------------
  |  Branch (1010:13): [True: 0, False: 0]
  ------------------
 1011|      0|            proxy_req->incoming->ref_proxy_subs--;
 1012|      0|            proxy_req->doing_observe = 0;
 1013|      0|          }
 1014|      0|          if (proxy_entry->proxy_req && !proxy_entry->proxy_req->next &&
  ------------------
  |  Branch (1014:15): [True: 0, False: 0]
  |  Branch (1014:41): [True: 0, False: 0]
  ------------------
 1015|      0|              proxy_req->token_used) {
  ------------------
  |  Branch (1015:15): [True: 0, False: 0]
  ------------------
 1016|      0|            coap_binary_t tmp;
 1017|       |
 1018|      0|            coap_log_debug("coap_proxy_forward_request: 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1019|       |            /* Unfortunately need to change the ptr type to be r/w */
 1020|      0|            memcpy(&tmp.s, &proxy_req->token_used->s, sizeof(tmp.s));
 1021|      0|            tmp.length = proxy_req->token_used->length;
 1022|      0|            coap_cancel_observe_lkd(proxy_entry->ongoing, &tmp, COAP_MESSAGE_CON);
 1023|       |            /* Let the upstream cancellation be the response */
 1024|      0|            return 1;
 1025|      0|          } else {
 1026|      0|            obs_opt = 0;
 1027|      0|            goto return_cached_info;
 1028|      0|          }
 1029|      0|        } else if (observe_action == COAP_OBSERVE_ESTABLISH) {
  ------------------
  |  |   37|      0|#define COAP_OBSERVE_ESTABLISH 0
  ------------------
  |  Branch (1029:20): [True: 0, False: 0]
  ------------------
 1030|       |          /* Client must be re-registering */
 1031|      0|          if (proxy_cache && (proxy_cache->expire + COAP_TICKS_PER_SECOND) < now) {
  ------------------
  |  |  164|      0|#define COAP_TICKS_PER_SECOND ((coap_tick_t)(1000U))
  ------------------
  |  Branch (1031:15): [True: 0, False: 0]
  |  Branch (1031:30): [True: 0, False: 0]
  ------------------
 1032|       |            /* Need to get an updated rsp_pdu */
 1033|      0|            coap_proxy_del_req(proxy_entry, proxy_req);
 1034|      0|            proxy_req = NULL;
 1035|      0|            proxy_cache = NULL;
 1036|      0|          } else {
 1037|      0|            goto return_cached_info;
 1038|      0|          }
 1039|      0|        }
 1040|      0|      } else {
 1041|      0|        if (proxy_cache && (proxy_cache->expire + COAP_TICKS_PER_SECOND) < now) {
  ------------------
  |  |  164|      0|#define COAP_TICKS_PER_SECOND ((coap_tick_t)(1000U))
  ------------------
  |  Branch (1041:13): [True: 0, False: 0]
  |  Branch (1041:28): [True: 0, False: 0]
  ------------------
 1042|       |          /* Need to get an updated rsp_pdu */
 1043|      0|          coap_proxy_del_req(proxy_entry, proxy_req);
 1044|      0|          proxy_req = NULL;
 1045|      0|          proxy_cache = NULL;
 1046|      0|        } else {
 1047|      0|          goto return_cached_info;
 1048|      0|        }
 1049|      0|      }
 1050|      0|    }
 1051|      0|  }
 1052|       |
 1053|     26|  if (!proxy_req) {
  ------------------
  |  Branch (1053:7): [True: 26, False: 0]
  ------------------
 1054|     26|    proxy_req = coap_malloc_type(COAP_STRING, sizeof(coap_proxy_req_t));
 1055|     26|    if (proxy_req == NULL) {
  ------------------
  |  Branch (1055:9): [True: 0, False: 26]
  ------------------
 1056|      0|      goto failed;
 1057|      0|    }
 1058|     26|    memset(proxy_req, 0, sizeof(coap_proxy_req_t));
 1059|     26|    LL_PREPEND(proxy_entry->proxy_req, proxy_req);
  ------------------
  |  |  320|     26|    LL_PREPEND2(head,add,next)
  |  |  ------------------
  |  |  |  |  322|     26|#define LL_PREPEND2(head,add,next)                                                             \
  |  |  |  |  323|     26|do {                                                                                           \
  |  |  |  |  324|     26|  (add)->next = (head);                                                                        \
  |  |  |  |  325|     26|  (head) = (add);                                                                              \
  |  |  |  |  326|     26|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (326:10): [Folded, False: 26]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1060|       |
 1061|     26|    proxy_req->pdu = coap_const_pdu_reference_lkd(request);
 1062|     26|    proxy_req->resource = resource;
 1063|     26|    proxy_req->incoming = session;
 1064|     26|    proxy_req->cache_key = cache_key;
 1065|     26|    proxy_req->proxy_cache = proxy_cache;
 1066|       |
 1067|     26|    coap_proxy_log_entry(proxy_req->incoming, proxy_req->pdu, proxy_req->token_used,  "add");
 1068|     26|  }
 1069|       |
 1070|     26|  if (proxy_cache) {
  ------------------
  |  Branch (1070:7): [True: 0, False: 26]
  ------------------
 1071|      0|    coap_bin_const_t j_token;
 1072|       |
 1073|      0|    if (obs_opt)
  ------------------
  |  Branch (1073:9): [True: 0, False: 0]
  ------------------
 1074|      0|      proxy_cache->ref++;
 1075|      0|    coap_delete_bin_const(proxy_req->token_used);
 1076|      0|    j_token = coap_pdu_get_token(proxy_cache->rsp_pdu);
 1077|      0|    proxy_req->token_used = coap_new_bin_const(j_token.s, j_token.length);
 1078|      0|    if (proxy_req->token_used == NULL) {
  ------------------
  |  Branch (1078:9): [True: 0, False: 0]
  ------------------
 1079|      0|      goto failed;
 1080|      0|    }
 1081|      0|    goto return_cached_info;
 1082|      0|  }
 1083|       |
 1084|       |  /* Get a new token for ongoing session */
 1085|     26|  coap_session_new_token(proxy_entry->ongoing, &token_len, token);
 1086|     26|  coap_delete_bin_const(proxy_req->token_used);
 1087|     26|  proxy_req->token_used = coap_new_bin_const(token, token_len);
 1088|     26|  if (proxy_req->token_used == NULL) {
  ------------------
  |  Branch (1088:7): [True: 0, False: 26]
  ------------------
 1089|      0|    goto failed;
 1090|      0|  }
 1091|     26|  coap_pdu_release_lkd(proxy_req->pdu);
 1092|     26|  proxy_req->pdu = coap_const_pdu_reference_lkd(request);
 1093|       |
 1094|       |  /* Need to create the ongoing request pdu entry */
 1095|     26|  proxy_type = coap_proxy_map_type(server_list->type);
 1096|     26|  if (proxy_type & COAP_PROXY_BIT_STRIP) {
  ------------------
  |  Branch (1096:7): [True: 17, False: 9]
  ------------------
 1097|       |    /*
 1098|       |     * Need to replace Proxy-Uri with Uri-Host (and Uri-Port)
 1099|       |     * and strip out Proxy-Scheme.
 1100|       |     */
 1101|       |
 1102|       |    /*
 1103|       |     * Build up the ongoing PDU that we are going to send
 1104|       |     */
 1105|     17|    pdu = coap_pdu_init(request->type, request->code,
 1106|     17|                        coap_new_message_id_lkd(proxy_entry->ongoing),
 1107|     17|                        coap_session_max_pdu_size_lkd(proxy_entry->ongoing));
 1108|     17|    if (!pdu) {
  ------------------
  |  Branch (1108:9): [True: 0, False: 17]
  ------------------
 1109|      0|      goto failed;
 1110|      0|    }
 1111|       |
 1112|     17|    if (coap_is_mcast(&proxy_entry->ongoing->addr_info.remote)) {
  ------------------
  |  Branch (1112:9): [True: 0, False: 17]
  ------------------
 1113|      0|      pdu->type = COAP_MESSAGE_NON;
 1114|      0|    }
 1115|       |
 1116|     17|    if (!coap_add_token(pdu, token_len, token)) {
  ------------------
  |  Branch (1116:9): [True: 0, False: 17]
  ------------------
 1117|      0|      goto failed;
 1118|      0|    }
 1119|       |
 1120|       |    /* Copy the remaining options across */
 1121|     17|    coap_option_iterator_init(request, &opt_iter, COAP_OPT_ALL);
  ------------------
  |  |  230|     17|#define COAP_OPT_ALL NULL
  ------------------
 1122|     75|    while ((option = coap_option_next(&opt_iter))) {
  ------------------
  |  Branch (1122:12): [True: 65, False: 10]
  ------------------
 1123|     65|      switch (opt_iter.number) {
 1124|      9|      case COAP_OPTION_PROXY_URI:
  ------------------
  |  Branch (1124:7): [True: 9, False: 56]
  ------------------
 1125|      9|        if (coap_split_proxy_uri(coap_opt_value(option),
  ------------------
  |  Branch (1125:13): [True: 7, False: 2]
  ------------------
 1126|      9|                                 coap_opt_length(option),
 1127|      9|                                 &uri) < 0) {
 1128|       |          /* Need to return a 5.05 RFC7252 Section 5.7.2 */
 1129|      7|          coap_log_warn("Proxy URI not decodable\n");
  ------------------
  |  |  108|      7|#define coap_log_warn(...) coap_log(COAP_LOG_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      7|#define coap_log(level, ...) do { \
  |  |  |  |  291|      7|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 7]
  |  |  |  |  ------------------
  |  |  |  |  292|      7|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      7|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 7]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1130|      7|          goto failed;
 1131|      7|        }
 1132|      2|        if (!coap_uri_into_optlist(&uri, NULL, &optlist, 0)) {
  ------------------
  |  Branch (1132:13): [True: 0, False: 2]
  ------------------
 1133|      0|          coap_log_err("Failed to create options for URI\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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1134|      0|          goto failed;
 1135|      0|        }
 1136|      2|        break;
 1137|      2|      case COAP_OPTION_PROXY_SCHEME:
  ------------------
  |  Branch (1137:7): [True: 0, False: 65]
  ------------------
 1138|      0|        break;
 1139|      0|      case COAP_OPTION_BLOCK1:
  ------------------
  |  Branch (1139:7): [True: 0, False: 65]
  ------------------
 1140|      0|      case COAP_OPTION_BLOCK2:
  ------------------
  |  Branch (1140:7): [True: 0, False: 65]
  ------------------
 1141|      0|      case COAP_OPTION_Q_BLOCK1:
  ------------------
  |  Branch (1141:7): [True: 0, False: 65]
  ------------------
 1142|      0|      case COAP_OPTION_Q_BLOCK2:
  ------------------
  |  Branch (1142:7): [True: 0, False: 65]
  ------------------
 1143|       |        /* These are not passed on */
 1144|      0|        break;
 1145|     17|      case COAP_OPTION_URI_HOST:
  ------------------
  |  Branch (1145:7): [True: 17, False: 48]
  ------------------
 1146|     27|      case COAP_OPTION_URI_PORT:
  ------------------
  |  Branch (1146:7): [True: 10, False: 55]
  ------------------
 1147|     27|        break;
 1148|     29|      default:
  ------------------
  |  Branch (1148:7): [True: 29, False: 36]
  ------------------
 1149|     29|        coap_insert_optlist(&optlist,
 1150|     29|                            coap_new_optlist(opt_iter.number,
 1151|     29|                                             coap_opt_length(option),
 1152|     29|                                             coap_opt_value(option)));
 1153|     29|        break;
 1154|     65|      }
 1155|     65|    }
 1156|       |
 1157|       |    /* Update pdu with options */
 1158|     10|    coap_add_optlist_pdu(pdu, &optlist);
 1159|     10|    coap_delete_optlist(optlist);
 1160|     10|    optlist = NULL;
 1161|     10|  } else {
 1162|       |    /*
 1163|       |     * Duplicate request PDU for onward transmission (with new token).
 1164|       |     */
 1165|      9|    pdu = coap_pdu_duplicate_lkd(request, proxy_entry->ongoing, token_len,
 1166|      9|                                 token, NULL, COAP_BOOL_FALSE);
 1167|      9|    if (!pdu) {
  ------------------
  |  Branch (1167:9): [True: 0, False: 9]
  ------------------
 1168|      0|      coap_log_debug("proxy: PDU generation error\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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1169|      0|      goto failed;
 1170|      0|    }
 1171|      9|    if (COAP_PROTO_NOT_RELIABLE(session->proto))
  ------------------
  |  |   41|      9|#define COAP_PROTO_NOT_RELIABLE(p) ((p)==COAP_PROTO_UDP || (p)==COAP_PROTO_DTLS)
  |  |  ------------------
  |  |  |  Branch (41:37): [True: 9, False: 0]
  |  |  |  Branch (41:60): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1172|      9|      pdu->max_size = coap_session_max_pdu_size_lkd(proxy_entry->ongoing);
 1173|      9|  }
 1174|       |
 1175|     19|  if (coap_get_data_large(request, &size, &data, &offset, &total)) {
  ------------------
  |  Branch (1175:7): [True: 0, False: 19]
  ------------------
 1176|       |    /* COAP_BLOCK_SINGLE_BODY is set, so single body should be given */
 1177|      0|    assert(size == total);
  ------------------
  |  Branch (1177:5): [True: 0, False: 0]
  ------------------
 1178|       |    /*
 1179|       |     * Need to take a copy of the data as request PDU may go away before
 1180|       |     * all data is transmitted.
 1181|       |     */
 1182|      0|    body_data = coap_new_binary(total);
 1183|      0|    if (!body_data) {
  ------------------
  |  Branch (1183:9): [True: 0, False: 0]
  ------------------
 1184|      0|      coap_log_debug("proxy: body build memory error\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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1185|      0|      goto failed;
 1186|      0|    }
 1187|      0|    memcpy(body_data->s, data, size);
 1188|      0|    if (!coap_add_data_large_request_lkd(proxy_entry->ongoing, pdu, total, data,
  ------------------
  |  Branch (1188:9): [True: 0, False: 0]
  ------------------
 1189|      0|                                         coap_proxy_release_body_data, body_data)) {
 1190|      0|      coap_log_debug("proxy: add data error\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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1191|      0|      goto failed;
 1192|      0|    }
 1193|      0|  }
 1194|       |
 1195|     19|  coap_proxy_log_entry(proxy_req->incoming, proxy_req->pdu, proxy_req->token_used,  "fwd");
 1196|     19|  if (coap_send_lkd(proxy_entry->ongoing, pdu) == COAP_INVALID_MID) {
  ------------------
  |  |  187|     19|#define COAP_INVALID_MID -1
  ------------------
  |  Branch (1196:7): [True: 0, False: 19]
  ------------------
 1197|      0|    pdu = NULL;
 1198|      0|    coap_log_debug("proxy: upstream PDU send error\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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1199|      0|    goto failed;
 1200|      0|  }
 1201|       |
 1202|       |  /*
 1203|       |   * Do not update the response code (hence empty ACK) as will be sending
 1204|       |   * separate response when response comes back from upstream server
 1205|       |   */
 1206|       |
 1207|     19|  return 1;
 1208|       |
 1209|      7|failed:
 1210|      7|  response->code = COAP_RESPONSE_CODE(500);
  ------------------
  |  |   96|      7|#define COAP_RESPONSE_CODE(N) (((N)/100 << 5) | (N)%100)
  ------------------
 1211|      7|  coap_delete_optlist(optlist);
 1212|      7|  coap_delete_pdu_lkd(pdu);
 1213|      7|  return 0;
 1214|       |
 1215|      0|return_cached_info:
 1216|      0|  if (obs_opt && !proxy_req->doing_observe) {
  ------------------
  |  Branch (1216:7): [True: 0, False: 0]
  |  Branch (1216:18): [True: 0, False: 0]
  ------------------
 1217|      0|    int observe_action;
 1218|       |
 1219|      0|    observe_action = coap_decode_var_bytes(coap_opt_value(obs_opt),
 1220|      0|                                           coap_opt_length(obs_opt));
 1221|       |
 1222|      0|    if (observe_action == COAP_OBSERVE_ESTABLISH) {
  ------------------
  |  |   37|      0|#define COAP_OBSERVE_ESTABLISH 0
  ------------------
  |  Branch (1222:9): [True: 0, False: 0]
  ------------------
 1223|      0|      proxy_req->doing_observe = 1;
 1224|      0|      proxy_req->incoming->ref_proxy_subs++;
 1225|      0|    }
 1226|      0|  }
 1227|      0|  coap_log_debug("*  %s: Using Proxy Cache (Active %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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1228|      0|                 coap_session_str(session),
 1229|      0|                 proxy_cache->ref);
 1230|      0|  coap_proxy_log_entry(session, request, &proxy_cache->rsp_pdu->actual_token,  "rspc");
 1231|      0|  if (now < proxy_cache->expire) {
  ------------------
  |  Branch (1231:7): [True: 0, False: 0]
  ------------------
 1232|      0|    new_maxage = (uint32_t)((proxy_cache->expire - now) / COAP_TICKS_PER_SECOND);
  ------------------
  |  |  164|      0|#define COAP_TICKS_PER_SECOND ((coap_tick_t)(1000U))
  ------------------
 1233|      0|    if (new_maxage == 0)
  ------------------
  |  Branch (1233:9): [True: 0, False: 0]
  ------------------
 1234|      0|      new_maxage = 1;
 1235|      0|  } else {
 1236|      0|    new_maxage = 1;
 1237|      0|  }
 1238|      0|  coap_update_option(proxy_cache->rsp_pdu,
 1239|      0|                     COAP_OPTION_MAXAGE,
 1240|      0|                     coap_encode_var_safe(buf, sizeof(buf), new_maxage), buf);
 1241|      0|  coap_proxy_call_response_handler(session, request, proxy_cache->rsp_pdu,
 1242|      0|                                   &r_token, proxy_req, 1, obs_opt ? 0 : 1);
  ------------------
  |  Branch (1242:60): [True: 0, False: 0]
  ------------------
 1243|      0|  if (!obs_opt)
  ------------------
  |  Branch (1243:7): [True: 0, False: 0]
  ------------------
 1244|      0|    coap_proxy_del_req(proxy_entry, proxy_req);
 1245|      0|  return 1;
 1246|     19|}
coap_proxy.c:coap_proxy_cleanup_entry:
  119|     26|coap_proxy_cleanup_entry(coap_proxy_entry_t *proxy_entry, int send_failure) {
  120|     26|  coap_proxy_req_t *proxy_req, *treq;
  121|       |
  122|     26|  LL_FOREACH_SAFE(proxy_entry->proxy_req, proxy_req, treq) {
  ------------------
  |  |  425|     26|    LL_FOREACH_SAFE2(head,el,tmp,next)
  |  |  ------------------
  |  |  |  |  428|     52|  for ((el) = (head); (el) && ((tmp) = (el)->next, 1); (el) = (tmp))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (428:23): [True: 26, False: 26]
  |  |  |  |  |  Branch (428:31): [True: 26, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  123|     26|    if (send_failure) {
  ------------------
  |  Branch (123:9): [True: 0, False: 26]
  ------------------
  124|      0|      coap_pdu_t *response;
  125|      0|      coap_bin_const_t l_token;
  126|       |
  127|       |      /* Need to send back a gateway failure */
  128|      0|      response = coap_pdu_init(proxy_req->pdu->type,
  129|      0|                               COAP_RESPONSE_CODE(502),
  ------------------
  |  |   96|      0|#define COAP_RESPONSE_CODE(N) (((N)/100 << 5) | (N)%100)
  ------------------
  130|      0|                               coap_new_message_id_lkd(proxy_entry->incoming),
  131|      0|                               coap_session_max_pdu_size_lkd(proxy_entry->incoming));
  132|      0|      if (!response) {
  ------------------
  |  Branch (132:11): [True: 0, False: 0]
  ------------------
  133|      0|        coap_log_info("PDU creation issue\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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  134|      0|        goto cleanup;
  135|      0|      }
  136|       |
  137|      0|      l_token = coap_pdu_get_token(proxy_req->pdu);
  138|      0|      if (!coap_add_token(response, l_token.length,
  ------------------
  |  Branch (138:11): [True: 0, False: 0]
  ------------------
  139|      0|                          l_token.s)) {
  140|      0|        coap_log_debug("Cannot add token to incoming proxy response 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  141|      0|      }
  142|       |
  143|      0|      if (coap_send_lkd(proxy_entry->incoming, response) == COAP_INVALID_MID) {
  ------------------
  |  |  187|      0|#define COAP_INVALID_MID -1
  ------------------
  |  Branch (143:11): [True: 0, False: 0]
  ------------------
  144|      0|        coap_log_info("Failed to send PDU with 5.02 gateway issue\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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  145|      0|      }
  146|      0|    }
  147|     26|cleanup:
  148|     26|    coap_proxy_del_req(proxy_entry, proxy_req);
  149|     26|  }
  150|     26|  coap_free_type(COAP_STRING, proxy_entry->uri_host_keep);
  151|     26|}
coap_proxy.c:coap_proxy_get_ongoing_session:
  582|     36|                               coap_proxy_server_list_t *server_list) {
  583|       |
  584|     36|  coap_address_t dst;
  585|     36|  coap_proto_t proto;
  586|     36|  coap_addr_info_t *info_list = NULL;
  587|     36|  coap_proxy_entry_t *proxy_entry;
  588|     36|  coap_context_t *context = session->context;
  589|     36|  static char client_sni[256];
  590|     36|  coap_proxy_server_t server_use;
  591|     36|  int proxy_entry_created;
  592|       |
  593|     36|  proxy_entry = coap_proxy_get_session(session, request, response, server_list,
  594|     36|                                       &server_use, &proxy_entry_created);
  595|     36|  if (!proxy_entry) {
  ------------------
  |  Branch (595:7): [True: 10, False: 26]
  ------------------
  596|       |    /* Error response code already set */
  597|     10|    return NULL;
  598|     10|  }
  599|       |
  600|     26|  if (!proxy_entry->ongoing) {
  ------------------
  |  Branch (600:7): [True: 26, False: 0]
  ------------------
  601|       |    /* Need to create a new session */
  602|     26|    coap_address_t *local_addr = NULL;
  603|       |
  604|       |    /* resolve destination address where data should be sent */
  605|     26|    info_list = coap_resolve_address_info_lkd(&server_use.uri.host,
  606|     26|                                              server_use.uri.port,
  607|     26|                                              server_use.uri.port,
  608|     26|                                              server_use.uri.port,
  609|     26|                                              server_use.uri.port,
  610|     26|                                              0,
  611|     26|                                              1 << server_use.uri.scheme,
  612|     26|                                              COAP_RESOLVE_TYPE_REMOTE);
  613|       |
  614|     26|    if (info_list == NULL) {
  ------------------
  |  Branch (614:9): [True: 0, False: 26]
  ------------------
  615|      0|      response->code = COAP_RESPONSE_CODE(502);
  ------------------
  |  |   96|      0|#define COAP_RESPONSE_CODE(N) (((N)/100 << 5) | (N)%100)
  ------------------
  616|      0|      coap_proxy_remove_association(session, 0);
  617|      0|      return NULL;
  618|      0|    }
  619|     26|    proto = info_list->proto;
  620|     26|    memcpy(&dst, &info_list->addr, sizeof(dst));
  621|     26|    coap_free_address_info(info_list);
  622|     26|    if (coap_is_mcast(&dst)) {
  ------------------
  |  Branch (622:9): [True: 0, False: 26]
  ------------------
  623|      0|      coap_proxy_t proxy_type = coap_proxy_map_type(server_list->type);
  624|       |
  625|      0|      if ((proxy_type & COAP_PROXY_NEW_MASK) == COAP_PROXY_FWD_DYNAMIC &&
  ------------------
  |  |   92|      0|#define COAP_PROXY_NEW_MASK 0x38 /**< Space used in coap_proxy_t for new types */
  ------------------
  |  Branch (625:11): [True: 0, False: 0]
  ------------------
  626|      0|          (proxy_type & COAP_PROXY_BIT_MCAST) == 0) {
  ------------------
  |  Branch (626:11): [True: 0, False: 0]
  ------------------
  627|      0|        response->code = COAP_RESPONSE_CODE(501);
  ------------------
  |  |   96|      0|#define COAP_RESPONSE_CODE(N) (((N)/100 << 5) | (N)%100)
  ------------------
  628|      0|        coap_proxy_remove_association(session, 0);
  629|      0|        coap_log_debug("*  %s: mcast proxy forwarding not 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  630|      0|                       coap_session_str(session));
  631|      0|        return NULL;
  632|      0|      }
  633|      0|      if (server_use.uri.scheme != COAP_URI_SCHEME_COAP) {
  ------------------
  |  Branch (633:11): [True: 0, False: 0]
  ------------------
  634|      0|        response->code = COAP_RESPONSE_CODE(501);
  ------------------
  |  |   96|      0|#define COAP_RESPONSE_CODE(N) (((N)/100 << 5) | (N)%100)
  ------------------
  635|      0|        coap_proxy_remove_association(session, 0);
  636|      0|        coap_log_debug("*  %s: mcast proxy forwarding only supported for 'coap'\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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  637|      0|                       coap_session_str(session));
  638|      0|        return NULL;
  639|      0|      }
  640|      0|    }
  641|       |
  642|     26|#if COAP_AF_UNIX_SUPPORT
  643|     26|    coap_address_t bind_addr;
  644|     26|    if (coap_is_af_unix(&dst)) {
  ------------------
  |  Branch (644:9): [True: 0, False: 26]
  ------------------
  645|      0|      char buf[COAP_UNIX_PATH_MAX];
  646|      0|      coap_tick_t now;
  647|       |
  648|       |      /* Need a unique 'client' address */
  649|      0|      coap_ticks(&now);
  650|      0|      snprintf(buf, COAP_UNIX_PATH_MAX,
  ------------------
  |  |  177|      0|#define COAP_UNIX_PATH_MAX   (sizeof(struct sockaddr_in6) - sizeof(sa_family_t))
  ------------------
  651|      0|               "/tmp/coap-pr-cl-%" PRIu64, (uint64_t)now);
  652|      0|      if (!coap_address_set_unix_domain(&bind_addr, (const uint8_t *)buf,
  ------------------
  |  Branch (652:11): [True: 0, False: 0]
  ------------------
  653|      0|                                        strlen(buf))) {
  654|      0|        fprintf(stderr, "coap_address_set_unix_domain: %s: failed\n",
  655|      0|                buf);
  656|      0|        remove(buf);
  657|      0|        return NULL;
  658|      0|      }
  659|      0|      (void)remove(buf);
  660|      0|      local_addr = &bind_addr;
  661|      0|    }
  662|     26|#endif /* COAP_AF_UNIX_SUPPORT */
  663|       |
  664|     26|    snprintf(client_sni, sizeof(client_sni), "%*.*s", (int)server_use.uri.host.length,
  665|     26|             (int)server_use.uri.host.length, server_use.uri.host.s);
  666|       |
  667|     26|    switch (server_use.uri.scheme) {
  668|     26|    case COAP_URI_SCHEME_COAP:
  ------------------
  |  Branch (668:5): [True: 26, False: 0]
  ------------------
  669|     26|    case COAP_URI_SCHEME_COAP_TCP:
  ------------------
  |  Branch (669:5): [True: 0, False: 26]
  ------------------
  670|     26|    case COAP_URI_SCHEME_COAP_WS:
  ------------------
  |  Branch (670:5): [True: 0, False: 26]
  ------------------
  671|     26|#if COAP_OSCORE_SUPPORT
  672|     26|      if (server_use.oscore_conf) {
  ------------------
  |  Branch (672:11): [True: 0, False: 26]
  ------------------
  673|      0|        proxy_entry->ongoing =
  674|      0|            coap_new_client_session_oscore3_lkd(context, local_addr, &dst,
  675|      0|                                                proto, server_use.oscore_conf,
  676|      0|                                                NULL, NULL, NULL);
  677|     26|      } else {
  678|     26|#endif /* COAP_OSCORE_SUPPORT */
  679|     26|        proxy_entry->ongoing =
  680|     26|            coap_new_client_session3_lkd(context, local_addr, &dst, proto,
  681|     26|                                         NULL, NULL, NULL);
  682|     26|#if COAP_OSCORE_SUPPORT
  683|     26|      }
  684|     26|#endif /* COAP_OSCORE_SUPPORT */
  685|     26|      break;
  686|      0|    case COAP_URI_SCHEME_COAPS:
  ------------------
  |  Branch (686:5): [True: 0, False: 26]
  ------------------
  687|      0|    case COAP_URI_SCHEME_COAPS_TCP:
  ------------------
  |  Branch (687:5): [True: 0, False: 26]
  ------------------
  688|      0|    case COAP_URI_SCHEME_COAPS_WS:
  ------------------
  |  Branch (688:5): [True: 0, False: 26]
  ------------------
  689|      0|#if COAP_OSCORE_SUPPORT
  690|      0|      if (server_use.oscore_conf) {
  ------------------
  |  Branch (690:11): [True: 0, False: 0]
  ------------------
  691|      0|        if (server_use.dtls_pki) {
  ------------------
  |  Branch (691:13): [True: 0, False: 0]
  ------------------
  692|      0|          server_use.dtls_pki->client_sni = client_sni;
  693|      0|          proxy_entry->ongoing =
  694|      0|              coap_new_client_session_oscore_pki3_lkd(context, local_addr, &dst,
  695|      0|                                                      proto, server_use.dtls_pki,
  696|      0|                                                      server_use.oscore_conf,
  697|      0|                                                      NULL, NULL, NULL);
  698|      0|        } else if (server_use.dtls_cpsk) {
  ------------------
  |  Branch (698:20): [True: 0, False: 0]
  ------------------
  699|      0|          server_use.dtls_cpsk->client_sni = client_sni;
  700|      0|          proxy_entry->ongoing =
  701|      0|              coap_new_client_session_oscore_psk3_lkd(context, local_addr, &dst,
  702|      0|                                                      proto, server_use.dtls_cpsk,
  703|      0|                                                      server_use.oscore_conf,
  704|      0|                                                      NULL, NULL, NULL);
  705|      0|        } else {
  706|      0|          coap_log_warn("Proxy: (D)TLS not configured for secure session\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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  707|      0|        }
  708|      0|      } else {
  709|      0|#endif /* COAP_OSCORE_SUPPORT */
  710|       |        /* Not doing OSCORE */
  711|      0|        if (server_use.dtls_pki) {
  ------------------
  |  Branch (711:13): [True: 0, False: 0]
  ------------------
  712|      0|          server_use.dtls_pki->client_sni = client_sni;
  713|      0|          proxy_entry->ongoing =
  714|      0|              coap_new_client_session_pki3_lkd(context, local_addr, &dst,
  715|      0|                                               proto, server_use.dtls_pki,
  716|      0|                                               NULL, NULL, NULL);
  717|      0|        } else if (server_use.dtls_cpsk) {
  ------------------
  |  Branch (717:20): [True: 0, False: 0]
  ------------------
  718|      0|          server_use.dtls_cpsk->client_sni = client_sni;
  719|      0|          proxy_entry->ongoing =
  720|      0|              coap_new_client_session_psk3_lkd(context, local_addr, &dst,
  721|      0|                                               proto, server_use.dtls_cpsk,
  722|      0|                                               NULL, NULL, NULL);
  723|      0|        } else {
  724|       |          /* Using client anonymous PKI */
  725|      0|          proxy_entry->ongoing =
  726|      0|              coap_new_client_session3_lkd(context, local_addr, &dst, proto,
  727|      0|                                           NULL, NULL, NULL);
  728|      0|        }
  729|      0|#if COAP_OSCORE_SUPPORT
  730|      0|      }
  731|      0|#endif /* COAP_OSCORE_SUPPORT */
  732|      0|      break;
  733|      0|    case COAP_URI_SCHEME_HTTP:
  ------------------
  |  Branch (733:5): [True: 0, False: 26]
  ------------------
  734|      0|    case COAP_URI_SCHEME_HTTPS:
  ------------------
  |  Branch (734:5): [True: 0, False: 26]
  ------------------
  735|      0|    case COAP_URI_SCHEME_LAST:
  ------------------
  |  Branch (735:5): [True: 0, False: 26]
  ------------------
  736|      0|    default:
  ------------------
  |  Branch (736:5): [True: 0, False: 26]
  ------------------
  737|      0|      assert(0);
  ------------------
  |  Branch (737:7): [Folded, False: 0]
  ------------------
  738|      0|      break;
  739|     26|    }
  740|     26|    if (proxy_entry->ongoing == NULL) {
  ------------------
  |  Branch (740:9): [True: 0, False: 26]
  ------------------
  741|      0|      response->code = COAP_RESPONSE_CODE(505);
  ------------------
  |  |   96|      0|#define COAP_RESPONSE_CODE(N) (((N)/100 << 5) | (N)%100)
  ------------------
  742|      0|      coap_proxy_remove_association(session, 0);
  743|      0|      return NULL;
  744|      0|    }
  745|     26|    if (proxy_entry_created) {
  ------------------
  |  Branch (745:9): [True: 26, False: 0]
  ------------------
  746|     26|      coap_log_debug("*  %s: proxy_entry %.*s:%d %p created (tot count = % " PRIdS ")\n",
  ------------------
  |  |  126|     26|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|     26|#define coap_log(level, ...) do { \
  |  |  |  |  291|     26|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 26]
  |  |  |  |  ------------------
  |  |  |  |  292|     26|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|     26|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 26]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  747|     26|                     coap_session_str(proxy_entry->ongoing),
  748|     26|                     (int)proxy_entry->uri.host.length, proxy_entry->uri.host.s,
  749|     26|                     proxy_entry->uri.port,
  750|     26|                     (void *)proxy_entry,
  751|     26|                     session->context->proxy_list_count);
  752|     26|    }
  753|     26|  } else if (proxy_entry->ongoing->session_failed) {
  ------------------
  |  Branch (753:14): [True: 0, False: 0]
  ------------------
  754|      0|    if (!coap_session_reconnect(proxy_entry->ongoing)) {
  ------------------
  |  Branch (754:9): [True: 0, False: 0]
  ------------------
  755|       |      /* Server is not yet back up */
  756|      0|      return NULL;
  757|      0|    }
  758|      0|  }
  759|       |
  760|     26|  return proxy_entry;
  761|     26|}
coap_proxy.c:coap_proxy_get_session:
  428|     36|                       coap_proxy_server_t *server_use, int *proxy_entry_created) {
  429|     36|  size_t i;
  430|     36|  coap_proxy_entry_t *proxy_entry;
  431|     36|  coap_proxy_entry_t *proxy_list = session->context->proxy_list;
  432|     36|  size_t proxy_list_count = session->context->proxy_list_count;
  433|     36|  coap_opt_iterator_t opt_iter;
  434|     36|  coap_opt_t *proxy_scheme;
  435|     36|  coap_opt_t *proxy_uri;
  436|     36|  coap_proxy_t proxy_type;
  437|       |
  438|     36|  *proxy_entry_created = 0;
  439|       |
  440|       |  /*
  441|       |   * Maintain server stickability. server_use not needed as there is
  442|       |   * ongoing session in place.
  443|       |   */
  444|     36|  if (session->proxy_entry) {
  ------------------
  |  Branch (444:7): [True: 0, False: 36]
  ------------------
  445|      0|    for (i = 0; i < proxy_list_count; i++) {
  ------------------
  |  Branch (445:17): [True: 0, False: 0]
  ------------------
  446|      0|      if (&proxy_list[i] == session->proxy_entry) {
  ------------------
  |  Branch (446:11): [True: 0, False: 0]
  ------------------
  447|      0|        if (session->proxy_entry->ongoing) {
  ------------------
  |  Branch (447:13): [True: 0, False: 0]
  ------------------
  448|      0|          memset(server_use, 0, sizeof(*server_use));
  449|      0|          return session->proxy_entry;
  450|      0|        }
  451|      0|      }
  452|      0|    }
  453|      0|  }
  454|       |
  455|       |  /* Round robin the defined next server list (which usually is just one */
  456|     36|  server_list->next_entry++;
  457|     36|  if (server_list->next_entry >= server_list->entry_count)
  ------------------
  |  Branch (457:7): [True: 36, False: 0]
  ------------------
  458|     36|    server_list->next_entry = 0;
  459|       |
  460|     36|  if (server_list->entry_count) {
  ------------------
  |  Branch (460:7): [True: 26, False: 10]
  ------------------
  461|     26|    memcpy(server_use, &server_list->entry[server_list->next_entry], sizeof(*server_use));
  462|     26|  } else {
  463|     10|    memset(server_use, 0, sizeof(*server_use));
  464|     10|  }
  465|       |
  466|     36|  proxy_type = coap_proxy_map_type(server_list->type);
  467|       |
  468|     36|  if ((proxy_type & COAP_PROXY_NEW_MASK) == COAP_PROXY_FWD_DYNAMIC) {
  ------------------
  |  |   92|     36|#define COAP_PROXY_NEW_MASK 0x38 /**< Space used in coap_proxy_t for new types */
  ------------------
  |  Branch (468:7): [True: 10, False: 26]
  ------------------
  469|       |    /* Need to get actual server from CoAP Proxy-Uri or Proxy-Scheme options */
  470|       |    /*
  471|       |     * See if Proxy-Scheme
  472|       |     */
  473|     10|    proxy_scheme = coap_check_option(request, COAP_OPTION_PROXY_SCHEME, &opt_iter);
  474|     10|    if (proxy_scheme) {
  ------------------
  |  Branch (474:9): [True: 4, False: 6]
  ------------------
  475|      4|      if (!coap_get_uri_proxy_scheme_info(request, proxy_scheme, &server_use->uri)) {
  ------------------
  |  Branch (475:11): [True: 4, False: 0]
  ------------------
  476|      4|        response->code = COAP_RESPONSE_CODE(505);
  ------------------
  |  |   96|      4|#define COAP_RESPONSE_CODE(N) (((N)/100 << 5) | (N)%100)
  ------------------
  477|      4|        return NULL;
  478|      4|      }
  479|      4|    }
  480|       |    /*
  481|       |     * See if Proxy-Uri
  482|       |     */
  483|      6|    proxy_uri = coap_check_option(request, COAP_OPTION_PROXY_URI, &opt_iter);
  484|      6|    if (proxy_uri) {
  ------------------
  |  Branch (484:9): [True: 1, False: 5]
  ------------------
  485|      1|      coap_log_info("Proxy URI '%.*s'\n",
  ------------------
  |  |  114|      1|#define coap_log_info(...) coap_log(COAP_LOG_INFO, __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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  486|      1|                    (int)coap_opt_length(proxy_uri),
  487|      1|                    (const char *)coap_opt_value(proxy_uri));
  488|      1|      if (coap_split_proxy_uri(coap_opt_value(proxy_uri),
  ------------------
  |  Branch (488:11): [True: 1, False: 0]
  ------------------
  489|      1|                               coap_opt_length(proxy_uri),
  490|      1|                               &server_use->uri) < 0) {
  491|       |        /* Need to return a 5.05 RFC7252 Section 5.7.2 */
  492|      1|        coap_log_warn("Proxy URI not decodable\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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  493|      1|        response->code = COAP_RESPONSE_CODE(505);
  ------------------
  |  |   96|      1|#define COAP_RESPONSE_CODE(N) (((N)/100 << 5) | (N)%100)
  ------------------
  494|      1|        return NULL;
  495|      1|      }
  496|      1|    }
  497|       |
  498|      5|    if (!(proxy_scheme || proxy_uri)) {
  ------------------
  |  Branch (498:11): [True: 0, False: 5]
  |  Branch (498:27): [True: 0, False: 5]
  ------------------
  499|      5|      response->code = COAP_RESPONSE_CODE(404);
  ------------------
  |  |   96|      5|#define COAP_RESPONSE_CODE(N) (((N)/100 << 5) | (N)%100)
  ------------------
  500|      5|      return NULL;
  501|      5|    }
  502|      5|  }
  503|       |
  504|     26|  if (server_use->uri.host.length == 0) {
  ------------------
  |  Branch (504:7): [True: 0, False: 26]
  ------------------
  505|       |    /* Ongoing connection not well formed */
  506|      0|    response->code = COAP_RESPONSE_CODE(505);
  ------------------
  |  |   96|      0|#define COAP_RESPONSE_CODE(N) (((N)/100 << 5) | (N)%100)
  ------------------
  507|      0|    return NULL;
  508|      0|  }
  509|       |
  510|     26|  if (!coap_verify_proxy_scheme_supported(server_use->uri.scheme)) {
  ------------------
  |  Branch (510:7): [True: 0, False: 26]
  ------------------
  511|      0|    response->code = COAP_RESPONSE_CODE(505);
  ------------------
  |  |   96|      0|#define COAP_RESPONSE_CODE(N) (((N)/100 << 5) | (N)%100)
  ------------------
  512|      0|    return NULL;
  513|      0|  }
  514|       |
  515|       |  /* Check if need to create a new forwarding mapping */
  516|     26|  proxy_entry = coap_proxy_get_add_list_entry(session, NULL, server_use->uri, server_list, 0);
  517|       |
  518|     26|  if (proxy_entry == NULL) {
  ------------------
  |  Branch (518:7): [True: 0, False: 26]
  ------------------
  519|      0|    response->code = COAP_RESPONSE_CODE(500);
  ------------------
  |  |   96|      0|#define COAP_RESPONSE_CODE(N) (((N)/100 << 5) | (N)%100)
  ------------------
  520|      0|    return NULL;
  521|      0|  }
  522|       |
  523|     26|  *proxy_entry_created = 1;
  524|     26|  return proxy_entry;
  525|     26|}
coap_proxy.c:coap_get_uri_proxy_scheme_info:
  217|      4|                               coap_uri_t *uri) {
  218|      4|  const char *opt_val = (const char *)coap_opt_value(opt);
  219|      4|  int opt_len = coap_opt_length(opt);
  220|      4|  coap_opt_iterator_t opt_iter;
  221|       |
  222|      4|  if (opt_len == 9 &&
  ------------------
  |  Branch (222:7): [True: 4, False: 0]
  ------------------
  223|      4|      strncasecmp(opt_val, "coaps+tcp", 9) == 0) {
  ------------------
  |  Branch (223:7): [True: 0, False: 4]
  ------------------
  224|      0|    uri->scheme = COAP_URI_SCHEME_COAPS_TCP;
  225|      0|    uri->port = COAPS_DEFAULT_PORT;
  ------------------
  |  |   40|      0|#define COAPS_DEFAULT_PORT     5684 /* CoAP default UDP/TCP port for secure transmission */
  ------------------
  226|      4|  } else if (opt_len == 8 &&
  ------------------
  |  Branch (226:14): [True: 0, False: 4]
  ------------------
  227|      0|             strncasecmp(opt_val, "coap+tcp", 8) == 0) {
  ------------------
  |  Branch (227:14): [True: 0, False: 0]
  ------------------
  228|      0|    uri->scheme = COAP_URI_SCHEME_COAP_TCP;
  229|      0|    uri->port = COAP_DEFAULT_PORT;
  ------------------
  |  |   39|      0|#define COAP_DEFAULT_PORT      5683 /* CoAP default UDP/TCP port */
  ------------------
  230|      4|  } else if (opt_len == 5 &&
  ------------------
  |  Branch (230:14): [True: 0, False: 4]
  ------------------
  231|      0|             strncasecmp(opt_val, "coaps", 5) == 0) {
  ------------------
  |  Branch (231:14): [True: 0, False: 0]
  ------------------
  232|      0|    uri->scheme = COAP_URI_SCHEME_COAPS;
  233|      0|    uri->port = COAPS_DEFAULT_PORT;
  ------------------
  |  |   40|      0|#define COAPS_DEFAULT_PORT     5684 /* CoAP default UDP/TCP port for secure transmission */
  ------------------
  234|      4|  } else if (opt_len == 4 &&
  ------------------
  |  Branch (234:14): [True: 0, False: 4]
  ------------------
  235|      0|             strncasecmp(opt_val, "coap", 4) == 0) {
  ------------------
  |  Branch (235:14): [True: 0, False: 0]
  ------------------
  236|      0|    uri->scheme = COAP_URI_SCHEME_COAP;
  237|      0|    uri->port = COAP_DEFAULT_PORT;
  ------------------
  |  |   39|      0|#define COAP_DEFAULT_PORT      5683 /* CoAP default UDP/TCP port */
  ------------------
  238|      4|  } else if (opt_len == 7 &&
  ------------------
  |  Branch (238:14): [True: 0, False: 4]
  ------------------
  239|      0|             strncasecmp(opt_val, "coap+ws", 7) == 0) {
  ------------------
  |  Branch (239:14): [True: 0, False: 0]
  ------------------
  240|      0|    uri->scheme = COAP_URI_SCHEME_COAP_WS;
  241|      0|    uri->port = 80;
  242|      4|  } else if (opt_len == 8 &&
  ------------------
  |  Branch (242:14): [True: 0, False: 4]
  ------------------
  243|      0|             strncasecmp(opt_val, "coaps+ws", 8) == 0) {
  ------------------
  |  Branch (243:14): [True: 0, False: 0]
  ------------------
  244|      0|    uri->scheme = COAP_URI_SCHEME_COAPS_WS;
  245|      0|    uri->port = 443;
  246|      4|  } else {
  247|      4|    coap_log_warn("Unsupported Proxy Scheme '%*.*s'\n",
  ------------------
  |  |  108|      4|#define coap_log_warn(...) coap_log(COAP_LOG_WARN, __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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  248|      4|                  opt_len, opt_len, opt_val);
  249|      4|    return 0;
  250|      4|  }
  251|       |
  252|      0|  opt = coap_check_option(request, COAP_OPTION_URI_HOST, &opt_iter);
  253|      0|  if (opt) {
  ------------------
  |  Branch (253:7): [True: 0, False: 0]
  ------------------
  254|      0|    uri->host.length = coap_opt_length(opt);
  255|      0|    uri->host.s = coap_opt_value(opt);
  256|      0|  } else {
  257|      0|    uri->host.s = NULL;
  258|      0|    uri->host.length = 0;
  259|      0|    coap_log_warn("Proxy Scheme requires Uri-Host\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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  260|      0|    return 0;
  261|      0|  }
  262|      0|  opt = coap_check_option(request, COAP_OPTION_URI_PORT, &opt_iter);
  263|      0|  if (opt) {
  ------------------
  |  Branch (263:7): [True: 0, False: 0]
  ------------------
  264|      0|    uri->port =
  265|      0|        coap_decode_var_bytes(coap_opt_value(opt),
  266|      0|                              coap_opt_length(opt));
  267|      0|  }
  268|      0|  return 1;
  269|      0|}
coap_proxy.c:coap_proxy_map_type:
  321|     62|coap_proxy_map_type(coap_proxy_t proxy_type) {
  322|     62|  if ((proxy_type & COAP_PROXY_NEW_MASK) == 0) {
  ------------------
  |  |   92|     62|#define COAP_PROXY_NEW_MASK 0x38 /**< Space used in coap_proxy_t for new types */
  ------------------
  |  Branch (322:7): [True: 0, False: 62]
  ------------------
  323|       |    /* Old version - update to bitwise version */
  324|      0|    switch ((int)proxy_type) {
  325|      0|    case COAP_PROXY_REVERSE:
  ------------------
  |  Branch (325:5): [True: 0, False: 0]
  ------------------
  326|      0|      proxy_type = COAP_PROXY_REV;
  327|      0|      break;
  328|      0|    case COAP_PROXY_REVERSE_STRIP:
  ------------------
  |  Branch (328:5): [True: 0, False: 0]
  ------------------
  329|      0|      proxy_type = COAP_PROXY_REV | COAP_PROXY_BIT_STRIP;
  330|      0|      break;
  331|      0|    case COAP_PROXY_FORWARD:
  ------------------
  |  Branch (331:5): [True: 0, False: 0]
  ------------------
  332|      0|      proxy_type = COAP_PROXY_FWD_STATIC;
  333|      0|      break;
  334|      0|    case COAP_PROXY_FORWARD_STRIP:
  ------------------
  |  Branch (334:5): [True: 0, False: 0]
  ------------------
  335|      0|      proxy_type = COAP_PROXY_FWD_STATIC | COAP_PROXY_BIT_STRIP;
  336|      0|      break;
  337|      0|    case COAP_PROXY_DIRECT:
  ------------------
  |  Branch (337:5): [True: 0, False: 0]
  ------------------
  338|       |      /* Mcast was always let through */
  339|      0|      proxy_type = COAP_PROXY_FWD_DYNAMIC | COAP_PROXY_BIT_MCAST;
  340|      0|      break;
  341|      0|    case COAP_PROXY_DIRECT_STRIP:
  ------------------
  |  Branch (341:5): [True: 0, False: 0]
  ------------------
  342|       |      /* Mcast was always let through */
  343|      0|      proxy_type = COAP_PROXY_FWD_DYNAMIC | COAP_PROXY_BIT_MCAST | COAP_PROXY_BIT_STRIP;
  344|      0|      break;
  345|      0|    default:
  ------------------
  |  Branch (345:5): [True: 0, False: 0]
  ------------------
  346|      0|      coap_log_warn("Proxy old proxy_type 0x%u unknow\n", proxy_type);
  ------------------
  |  |  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|      proxy_type = COAP_PROXY_FWD_DYNAMIC;
  348|      0|      break;
  349|      0|    }
  350|      0|  }
  351|     62|  return proxy_type;
  352|     62|}
coap_proxy.c:coap_proxy_get_add_list_entry:
  357|     26|                              int allow_add) {
  358|     26|  coap_context_t *context = incoming ? incoming->context : ongoing->context;
  ------------------
  |  Branch (358:29): [True: 26, False: 0]
  ------------------
  359|     26|  coap_proxy_entry_t *proxy_list = context->proxy_list;
  360|     26|  size_t proxy_list_count = context->proxy_list_count;
  361|     26|  coap_proxy_entry_t *new_proxy_list;
  362|     26|  size_t i;
  363|       |
  364|       |  /* See if we are already connected to the Server */
  365|     26|  for (i = 0; i < proxy_list_count; i++) {
  ------------------
  |  Branch (365:15): [True: 0, False: 26]
  ------------------
  366|      0|    if (coap_string_equal(&proxy_list[i].uri.host, &uri.host) &&
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  367|      0|        proxy_list[i].uri.port == uri.port &&
  ------------------
  |  Branch (367:9): [True: 0, False: 0]
  ------------------
  368|      0|        proxy_list[i].uri.scheme == uri.scheme) {
  ------------------
  |  Branch (368:9): [True: 0, False: 0]
  ------------------
  369|      0|      if (!proxy_list[i].track_client_session && context->proxy_response_cb) {
  ------------------
  |  Branch (369:11): [True: 0, False: 0]
  |  Branch (369:50): [True: 0, False: 0]
  ------------------
  370|      0|        coap_ticks(&proxy_list[i].last_used);
  371|      0|        return &proxy_list[i];
  372|      0|      } else {
  373|      0|        if (proxy_list[i].incoming == incoming) {
  ------------------
  |  Branch (373:13): [True: 0, False: 0]
  ------------------
  374|      0|          coap_ticks(&proxy_list[i].last_used);
  375|      0|          return &proxy_list[i];
  376|      0|        }
  377|      0|      }
  378|      0|    }
  379|      0|  }
  380|     26|  if ((server_list->type & COAP_PROXY_DYN_DEFINED) && !allow_add)
  ------------------
  |  Branch (380:7): [True: 0, False: 26]
  |  Branch (380:55): [True: 0, False: 0]
  ------------------
  381|      0|    return NULL;
  382|       |
  383|       |  /* Need to create a new forwarding mapping */
  384|     26|  new_proxy_list = coap_realloc_type(COAP_STRING, proxy_list,
  385|     26|                                     (proxy_list_count+1)*sizeof(proxy_list[0]));
  386|       |
  387|     26|  if (new_proxy_list == NULL) {
  ------------------
  |  Branch (387:7): [True: 0, False: 26]
  ------------------
  388|      0|    return NULL;
  389|      0|  }
  390|     26|  context->proxy_list = proxy_list = new_proxy_list;
  391|     26|  memset(&proxy_list[proxy_list_count], 0, sizeof(proxy_list[proxy_list_count]));
  392|       |
  393|       |  /* Keep a copy of the host as server_use->uri pointed to will be going away */
  394|     26|  proxy_list[proxy_list_count].uri = uri;
  395|     26|  proxy_list[proxy_list_count].uri_host_keep = coap_malloc_type(COAP_STRING,
  396|     26|                                               uri.host.length);
  397|     26|  if (!proxy_list[proxy_list_count].uri_host_keep) {
  ------------------
  |  Branch (397:7): [True: 0, False: 26]
  ------------------
  398|      0|    return NULL;
  399|      0|  }
  400|     26|  memcpy(proxy_list[proxy_list_count].uri_host_keep, uri.host.s, uri.host.length);
  401|     26|  proxy_list[proxy_list_count].uri.host.s = proxy_list[proxy_list_count].uri_host_keep;
  402|       |  /* Unset uri parts which point to going away information */
  403|     26|  proxy_list[proxy_list_count].uri.path.s = NULL;
  404|     26|  proxy_list[proxy_list_count].uri.path.length = 0;
  405|     26|  proxy_list[proxy_list_count].uri.query.s = NULL;
  406|     26|  proxy_list[proxy_list_count].uri.query.length = 0;
  407|       |
  408|     26|  proxy_list[proxy_list_count].ongoing = ongoing;
  409|     26|  proxy_list[proxy_list_count].idle_timeout_ticks = server_list->idle_timeout_secs *
  410|     26|                                                    COAP_TICKS_PER_SECOND;
  ------------------
  |  |  164|     26|#define COAP_TICKS_PER_SECOND ((coap_tick_t)(1000U))
  ------------------
  411|     26|  proxy_list[proxy_list_count].track_client_session = server_list->track_client_session;
  412|     26|  coap_ticks(&proxy_list[proxy_list_count].last_used);
  413|     26|  if (incoming) {
  ------------------
  |  Branch (413:7): [True: 26, False: 0]
  ------------------
  414|     26|    incoming->proxy_entry = &proxy_list[proxy_list_count];
  415|     26|    if (server_list->track_client_session)
  ------------------
  |  Branch (415:9): [True: 0, False: 26]
  ------------------
  416|      0|      proxy_list[proxy_list_count].incoming = incoming;
  417|     26|    incoming->proxy_entry = &proxy_list[proxy_list_count];
  418|     26|  }
  419|       |
  420|     26|  context->proxy_list_count++;
  421|     26|  return &proxy_list[proxy_list_count];
  422|     26|}

coap_resource_proxy_uri_init2:
  335|     36|                              const char *host_name_list[], int flags) {
  336|     36|  coap_resource_t *r;
  337|       |
  338|     36|  r = (coap_resource_t *)coap_malloc_type(COAP_RESOURCE, sizeof(coap_resource_t));
  339|     36|  if (r) {
  ------------------
  |  Branch (339:7): [True: 36, False: 0]
  ------------------
  340|     36|    size_t i;
  341|     36|    memset(r, 0, sizeof(coap_resource_t));
  342|       |#if COAP_THREAD_SAFE
  343|       |    coap_lock_init(&r->lock);
  344|       |#endif /* COAP_THREAD_SAFE */
  345|     36|    r->is_proxy_uri = 1;
  346|       |    /* Something unlikely to be used, but it shows up in the logs */
  347|     36|    r->uri_path = coap_new_str_const(coap_proxy_resource_uri, sizeof(coap_proxy_resource_uri)-1);
  348|       |    /* Preset all the handlers */
  349|    288|    for (i = 0; i < (sizeof(r->handler) / sizeof(r->handler[0])); i++) {
  ------------------
  |  Branch (349:17): [True: 252, False: 36]
  ------------------
  350|    252|      r->handler[i] = handler;
  351|    252|    }
  352|     36|    if (host_name_count) {
  ------------------
  |  Branch (352:9): [True: 0, False: 36]
  ------------------
  353|      0|      r->proxy_name_list = coap_malloc_type(COAP_STRING, host_name_count *
  354|      0|                                            sizeof(coap_str_const_t *));
  355|      0|      if (r->proxy_name_list) {
  ------------------
  |  Branch (355:11): [True: 0, False: 0]
  ------------------
  356|      0|        for (i = 0; i < host_name_count; i++) {
  ------------------
  |  Branch (356:21): [True: 0, False: 0]
  ------------------
  357|      0|          r->proxy_name_list[i] =
  358|      0|              coap_new_str_const((const uint8_t *)host_name_list[i],
  359|      0|                                 strlen(host_name_list[i]));
  360|      0|          if (!r->proxy_name_list[i]) {
  ------------------
  |  Branch (360:15): [True: 0, False: 0]
  ------------------
  361|      0|            coap_log_err("coap_resource_proxy_uri_init: unable to add host name\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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  362|      0|            if (i == 0) {
  ------------------
  |  Branch (362:17): [True: 0, False: 0]
  ------------------
  363|      0|              coap_free_type(COAP_STRING, r->proxy_name_list);
  364|      0|              r->proxy_name_list = NULL;
  365|      0|            }
  366|      0|            break;
  367|      0|          }
  368|      0|        }
  369|      0|        r->proxy_name_count = i;
  370|      0|      }
  371|      0|    }
  372|     36|    r->flags = flags & ~COAP_RESOURCE_FLAGS_RELEASE_URI;
  ------------------
  |  |   55|     36|#define COAP_RESOURCE_FLAGS_RELEASE_URI 0x1
  ------------------
  373|     36|  } else {
  374|      0|    coap_log_debug("coap_resource_proxy_uri_init2: 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  375|      0|  }
  376|       |
  377|     36|  return r;
  378|     36|}
coap_add_resource:
  544|     36|coap_add_resource(coap_context_t *context, coap_resource_t *resource) {
  545|     36|  coap_lock_lock(return);
  546|     36|  coap_add_resource_lkd(context, resource);
  547|     36|  coap_lock_unlock();
  548|     36|}
coap_add_resource_lkd:
  551|     36|coap_add_resource_lkd(coap_context_t *context, coap_resource_t *resource) {
  552|     36|  coap_lock_check_locked();
  ------------------
  |  |  638|     36|#define coap_lock_check_locked() {}
  ------------------
  553|     36|  if (resource->is_unknown) {
  ------------------
  |  Branch (553:7): [True: 0, False: 36]
  ------------------
  554|      0|    if (context->unknown_resource)
  ------------------
  |  Branch (554:9): [True: 0, False: 0]
  ------------------
  555|      0|      coap_free_resource(context->unknown_resource, COAP_DELETING_RESOURCE);
  556|      0|    context->unknown_resource = resource;
  557|     36|  } else if (resource->is_proxy_uri) {
  ------------------
  |  Branch (557:14): [True: 36, False: 0]
  ------------------
  558|     36|    if (context->proxy_uri_resource)
  ------------------
  |  Branch (558:9): [True: 0, False: 36]
  ------------------
  559|      0|      coap_free_resource(context->proxy_uri_resource, COAP_DELETING_RESOURCE);
  560|     36|    context->proxy_uri_resource = resource;
  561|     36|  } else {
  562|      0|    coap_resource_t *r = coap_get_resource_from_uri_path_lkd(context,
  563|      0|                                                             resource->uri_path);
  564|       |
  565|      0|    if (r) {
  ------------------
  |  Branch (565:9): [True: 0, False: 0]
  ------------------
  566|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  567|      0|                    (int)resource->uri_path->length, (int)resource->uri_path->length,
  568|      0|                    resource->uri_path->s);
  569|      0|      coap_delete_resource_lkd(r);
  570|      0|    }
  571|      0|    RESOURCES_ADD(context->resources, resource);
  ------------------
  |  |  187|      0|  HASH_ADD(hh, (r), uri_path->s[0], (obj)->uri_path->length, (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]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  572|      0|#if COAP_WITH_OBSERVE_PERSIST
  573|      0|    if (context->unknown_pdu && context->dyn_resource_save_file &&
  ------------------
  |  Branch (573:9): [True: 0, False: 0]
  |  Branch (573:33): [True: 0, False: 0]
  ------------------
  574|      0|        context->dyn_resource_added_cb && resource->observable) {
  ------------------
  |  Branch (574:9): [True: 0, False: 0]
  |  Branch (574:43): [True: 0, False: 0]
  ------------------
  575|      0|      coap_bin_const_t raw_packet;
  576|       |
  577|      0|      raw_packet.s = context->unknown_pdu->token -
  578|      0|                     context->unknown_pdu->hdr_size;
  579|      0|      raw_packet.length = context->unknown_pdu->used_size +
  580|      0|                          context->unknown_pdu->hdr_size;
  581|      0|      coap_lock_callback(context->dyn_resource_added_cb(context->unknown_session,
  ------------------
  |  |  651|      0|#define coap_lock_callback(func) func
  ------------------
  582|      0|                                                        resource->uri_path,
  583|      0|                                                        &raw_packet,
  584|      0|                                                        context->observe_user_data));
  585|      0|    }
  586|      0|#endif /* COAP_WITH_OBSERVE_PERSIST */
  587|      0|  }
  588|     36|  assert(resource->context == NULL);
  ------------------
  |  Branch (588:3): [True: 36, False: 0]
  ------------------
  589|     36|  resource->context = context;
  590|     36|}
coap_delete_resource_lkd:
  610|     36|coap_delete_resource_lkd(coap_resource_t *resource) {
  611|     36|  coap_context_t *context;
  612|     36|  coap_deleting_resource_t deleting;
  613|       |
  614|     36|  if (!resource)
  ------------------
  |  Branch (614:7): [True: 0, False: 36]
  ------------------
  615|      0|    return 0;
  616|       |
  617|     36|  context = resource->context;
  618|     36|  coap_lock_check_locked();
  ------------------
  |  |  638|     36|#define coap_lock_check_locked() {}
  ------------------
  619|       |
  620|     36|  if (resource->ref) {
  ------------------
  |  Branch (620:7): [True: 0, False: 36]
  ------------------
  621|      0|    resource->ref--;
  622|      0|    return 1;
  623|      0|  }
  624|     36|  if (context && context->context_going_away) {
  ------------------
  |  Branch (624:7): [True: 36, False: 0]
  |  Branch (624:18): [True: 36, False: 0]
  ------------------
  625|     36|    deleting = COAP_DELETING_RESOURCE_ON_EXIT;
  626|     36|  } else {
  627|      0|    deleting = COAP_DELETING_RESOURCE;
  628|      0|  }
  629|     36|  if (resource->is_unknown) {
  ------------------
  |  Branch (629:7): [True: 0, False: 36]
  ------------------
  630|      0|    if (context && context->unknown_resource == resource) {
  ------------------
  |  Branch (630:9): [True: 0, False: 0]
  |  Branch (630:20): [True: 0, False: 0]
  ------------------
  631|      0|      context->unknown_resource = NULL;
  632|      0|    }
  633|     36|  } else if (resource->is_proxy_uri) {
  ------------------
  |  Branch (633:14): [True: 36, False: 0]
  ------------------
  634|     36|    if (context && context->proxy_uri_resource == resource) {
  ------------------
  |  Branch (634:9): [True: 36, False: 0]
  |  Branch (634:20): [True: 36, False: 0]
  ------------------
  635|     36|      context->proxy_uri_resource = NULL;
  636|     36|    }
  637|     36|  } else if (context) {
  ------------------
  |  Branch (637:14): [True: 0, False: 0]
  ------------------
  638|       |    /* remove resource from list */
  639|      0|    RESOURCES_DELETE(context->resources, resource);
  ------------------
  |  |  190|      0|  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]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  640|      0|  }
  641|     36|  if (resource->is_dynamic) {
  ------------------
  |  Branch (641:7): [True: 0, False: 36]
  ------------------
  642|      0|    if (context) {
  ------------------
  |  Branch (642:9): [True: 0, False: 0]
  ------------------
  643|      0|      assert(context->dynamic_cur);
  ------------------
  |  Branch (643:7): [True: 0, False: 0]
  ------------------
  644|      0|      context->dynamic_cur--;
  645|      0|    }
  646|      0|  }
  647|       |
  648|       |  /* and free its allocated memory */
  649|     36|  coap_free_resource(resource, deleting);
  650|       |
  651|     36|  return 1;
  652|     36|}
coap_delete_all_resources:
  655|     36|coap_delete_all_resources(coap_context_t *context) {
  656|     36|  coap_resource_t *r;
  657|     36|  coap_resource_t *tmp;
  658|       |
  659|     36|  RESOURCE_ITER_SAFE(context->resources, r, tmp) {
  ------------------
  |  |  197|     36|  for ((el) = (e); (el) && ((rtmp) = (el)->hh.next, 1); (el) = (rtmp))
  |  |  ------------------
  |  |  |  Branch (197:20): [True: 0, False: 36]
  |  |  |  Branch (197:28): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  660|      0|    coap_delete_resource_lkd(r);
  661|      0|  }
  662|       |
  663|     36|  context->resources = NULL;
  664|       |
  665|     36|  if (context->unknown_resource) {
  ------------------
  |  Branch (665:7): [True: 0, False: 36]
  ------------------
  666|      0|    coap_delete_resource_lkd(context->unknown_resource);
  667|      0|    context->unknown_resource = NULL;
  668|      0|  }
  669|     36|  if (context->proxy_uri_resource) {
  ------------------
  |  Branch (669:7): [True: 36, False: 0]
  ------------------
  670|     36|    coap_delete_resource_lkd(context->proxy_uri_resource);
  671|       |    context->proxy_uri_resource = NULL;
  672|     36|  }
  673|     36|}
coap_resource_notify_observers_lkd:
 1434|     36|                                   coap_deleting_resource_t deleting) {
 1435|     36|  coap_lock_check_locked();
  ------------------
  |  |  638|     36|#define coap_lock_check_locked() {}
  ------------------
 1436|     36|  if (!r->observable)
  ------------------
  |  Branch (1436:7): [True: 36, False: 0]
  ------------------
 1437|     36|    return 0;
 1438|      0|  if (!r->subscribers)
  ------------------
  |  Branch (1438:7): [True: 0, False: 0]
  ------------------
 1439|      0|    return 0;
 1440|      0|  r->dirty = 1;
 1441|       |
 1442|       |  /* Increment value for next Observe use. Observe value must be < 2^24 */
 1443|      0|  r->observe = (r->observe + 1) & 0xFFFFFF;
 1444|       |
 1445|      0|  assert(r->context);
  ------------------
  |  Branch (1445:3): [True: 0, False: 0]
  ------------------
 1446|       |
 1447|      0|  if (r->context->track_observe_value_cb) {
  ------------------
  |  Branch (1447:7): [True: 0, False: 0]
  ------------------
 1448|       |    /* Track last used observe value */
 1449|      0|    if ((r->observe % r->context->observe_save_freq) == 0)
  ------------------
  |  Branch (1449:9): [True: 0, False: 0]
  ------------------
 1450|      0|      coap_lock_callback(r->context->track_observe_value_cb(r->context, r->uri_path,
  ------------------
  |  |  651|      0|#define coap_lock_callback(func) func
  ------------------
 1451|      0|                                                            r->observe,
 1452|      0|                                                            r->context->observe_user_data));
 1453|      0|  }
 1454|       |
 1455|      0|  coap_notify_observers(r->context, r, deleting);
 1456|      0|  return 1;
 1457|      0|}
coap_resource.c:coap_free_resource:
  497|     36|coap_free_resource(coap_resource_t *resource, coap_deleting_resource_t deleting) {
  498|     36|  coap_attr_t *attr, *tmp;
  499|     36|  coap_subscription_t *obs, *otmp;
  500|     36|  coap_context_t *context;
  501|       |
  502|     36|  assert(resource);
  ------------------
  |  Branch (502:3): [True: 36, False: 0]
  ------------------
  503|       |
  504|     36|  context = resource->context;
  505|     36|  if (context) {
  ------------------
  |  Branch (505:7): [True: 36, False: 0]
  ------------------
  506|     36|    if (!context->observe_no_clear) {
  ------------------
  |  Branch (506:9): [True: 36, False: 0]
  ------------------
  507|     36|      coap_resource_notify_observers_lkd(resource, deleting);
  508|     36|      coap_notify_observers(context, resource, deleting);
  509|     36|    }
  510|       |
  511|     36|    if (context->resource_deleted_cb)
  ------------------
  |  Branch (511:9): [True: 0, False: 36]
  ------------------
  512|      0|      coap_lock_callback(context->resource_deleted_cb(context,
  ------------------
  |  |  651|     36|#define coap_lock_callback(func) func
  ------------------
  513|     36|                                                      resource->uri_path,
  514|     36|                                                      context->observe_user_data));
  515|       |
  516|     36|    if (context->release_userdata_cb && resource->user_data) {
  ------------------
  |  Branch (516:9): [True: 0, False: 36]
  |  Branch (516:41): [True: 0, False: 0]
  ------------------
  517|      0|      coap_lock_callback(context->release_userdata_cb(resource->user_data));
  ------------------
  |  |  651|      0|#define coap_lock_callback(func) func
  ------------------
  518|      0|    }
  519|     36|  }
  520|       |
  521|       |  /* delete registered attributes */
  522|     36|  LL_FOREACH_SAFE(resource->link_attr, attr, tmp) coap_delete_attr(attr);
  ------------------
  |  |  425|     36|    LL_FOREACH_SAFE2(head,el,tmp,next)
  |  |  ------------------
  |  |  |  |  428|     36|  for ((el) = (head); (el) && ((tmp) = (el)->next, 1); (el) = (tmp))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (428:23): [True: 0, False: 36]
  |  |  |  |  |  Branch (428:31): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  523|       |
  524|       |  /* Either the application provided or libcoap copied - need to delete it */
  525|     36|  coap_delete_str_const(resource->uri_path);
  526|       |
  527|       |  /* free all elements from resource->subscribers */
  528|     36|  LL_FOREACH_SAFE(resource->subscribers, obs, otmp) {
  ------------------
  |  |  425|     36|    LL_FOREACH_SAFE2(head,el,tmp,next)
  |  |  ------------------
  |  |  |  |  428|     36|  for ((el) = (head); (el) && ((tmp) = (el)->next, 1); (el) = (tmp))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (428:23): [True: 0, False: 36]
  |  |  |  |  |  Branch (428:31): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  529|      0|    coap_delete_observer_internal(resource, obs->session, obs);
  530|      0|  }
  531|     36|  if (resource->proxy_name_count && resource->proxy_name_list) {
  ------------------
  |  Branch (531:7): [True: 0, False: 36]
  |  Branch (531:37): [True: 0, False: 0]
  ------------------
  532|      0|    size_t i;
  533|       |
  534|      0|    for (i = 0; i < resource->proxy_name_count; i++) {
  ------------------
  |  Branch (534:17): [True: 0, False: 0]
  ------------------
  535|      0|      coap_delete_str_const(resource->proxy_name_list[i]);
  536|      0|    }
  537|      0|    coap_free_type(COAP_STRING, resource->proxy_name_list);
  538|      0|  }
  539|       |
  540|     36|  coap_free_type(COAP_RESOURCE, resource);
  541|     36|}
coap_resource.c:coap_notify_observers:
 1136|     36|                      coap_deleting_resource_t deleting) {
 1137|     36|  coap_method_handler_t h;
 1138|     36|  coap_subscription_t *obs, *otmp;
 1139|     36|  coap_pdu_t *response;
 1140|     36|  uint8_t buf[4];
 1141|     36|  coap_string_t *query;
 1142|     36|  coap_block_b_t block;
 1143|     36|  coap_tick_t now;
 1144|       |
 1145|     36|  coap_lock_check_locked();
  ------------------
  |  |  638|     36|#define coap_lock_check_locked() {}
  ------------------
 1146|       |
 1147|     36|  if (r->observable && (r->dirty || r->partiallydirty)) {
  ------------------
  |  Branch (1147:7): [True: 0, False: 36]
  |  Branch (1147:25): [True: 0, False: 0]
  |  Branch (1147:37): [True: 0, False: 0]
  ------------------
 1148|      0|    if (r->list_being_traversed)
  ------------------
  |  Branch (1148:9): [True: 0, False: 0]
  ------------------
 1149|      0|      return;
 1150|      0|    r->list_being_traversed = 1;
 1151|       |
 1152|      0|    coap_resource_reference_lkd(r);
 1153|       |
 1154|      0|    r->partiallydirty = 0;
 1155|       |
 1156|      0|    LL_FOREACH_SAFE(r->subscribers, obs, otmp) {
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1157|      0|      coap_session_t *obs_session;
 1158|      0|      coap_pdu_t *obs_pdu;
 1159|      0|      coap_mid_t mid = COAP_INVALID_MID;
  ------------------
  |  |  187|      0|#define COAP_INVALID_MID -1
  ------------------
 1160|       |
 1161|      0|      if ((r->dirty == 0 && obs->dirty == 0) || obs->session->is_rate_limiting) {
  ------------------
  |  Branch (1161:12): [True: 0, False: 0]
  |  Branch (1161:29): [True: 0, False: 0]
  |  Branch (1161:49): [True: 0, False: 0]
  ------------------
 1162|       |        /*
 1163|       |         * running this resource due to partiallydirty, but this observation's
 1164|       |         * notification was already enqueued
 1165|       |         */
 1166|      0|        context->observe_pending = 1;
 1167|      0|        continue;
 1168|      0|      }
 1169|       |
 1170|       |      /*
 1171|       |       * obs may get deleted in the callback, or by another running
 1172|       |       * thread when executing the callback or when sending a response.
 1173|       |       */
 1174|      0|      obs_session = obs->session;
 1175|      0|      obs_pdu = obs->pdu;
 1176|      0|      coap_session_reference_lkd(obs_session);
 1177|      0|      coap_pdu_reference_lkd(obs_pdu);
 1178|       |
 1179|      0|      if (obs->session->con_active >= COAP_NSTART(obs->session) &&
  ------------------
  |  |  798|      0|#define COAP_NSTART(s) ((s)->nstart)
  ------------------
  |  Branch (1179:11): [True: 0, False: 0]
  ------------------
 1180|      0|          ((r->flags & COAP_RESOURCE_FLAGS_NOTIFY_CON) ||
  ------------------
  |  |   69|      0|#define COAP_RESOURCE_FLAGS_NOTIFY_CON  0x2
  ------------------
  |  Branch (1180:12): [True: 0, False: 0]
  ------------------
 1181|      0|           (obs->non_cnt >= COAP_OBS_MAX_NON))) {
  ------------------
  |  |   39|      0|#define COAP_OBS_MAX_NON   5
  ------------------
  |  Branch (1181:12): [True: 0, False: 0]
  ------------------
 1182|       |        /* Waiting for the previous unsolicited response to finish */
 1183|      0|        goto next_one_fail;
 1184|      0|      }
 1185|      0|      coap_ticks(&now);
 1186|      0|      if (obs->session->lg_xmit && obs->session->lg_xmit->last_all_sent == 0 &&
  ------------------
  |  Branch (1186:11): [True: 0, False: 0]
  |  Branch (1186:36): [True: 0, False: 0]
  ------------------
 1187|      0|          obs->session->lg_xmit->last_obs &&
  ------------------
  |  Branch (1187:11): [True: 0, False: 0]
  ------------------
 1188|      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 (1188:11): [True: 0, False: 0]
  ------------------
 1189|       |        /* Waiting for the previous blocked unsolicited response to finish */
 1190|      0|        goto next_one_fail;
 1191|      0|      }
 1192|       |
 1193|      0|      obs->dirty = 0;
 1194|       |      /* initialize response */
 1195|      0|      response = coap_pdu_init(COAP_MESSAGE_CON, 0, 0,
 1196|      0|                               coap_session_max_pdu_size_lkd(obs->session));
 1197|      0|      if (!response) {
  ------------------
  |  Branch (1197:11): [True: 0, False: 0]
  ------------------
 1198|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1199|      0|                       "partially dirty\n");
 1200|      0|        goto next_one_fail_no_pending;
 1201|      0|      }
 1202|       |
 1203|      0|      if (!coap_add_token(response, obs->pdu->actual_token.length,
  ------------------
  |  Branch (1203:11): [True: 0, False: 0]
  ------------------
 1204|      0|                          obs->pdu->actual_token.s)) {
 1205|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1206|      0|                       "partially dirty\n");
 1207|      0|        coap_delete_pdu_lkd(response);
 1208|      0|        goto next_one_fail_no_pending;
 1209|      0|      }
 1210|       |
 1211|      0|      obs->pdu->mid = response->mid = coap_new_message_id_lkd(obs->session);
 1212|       |      /* A lot of the reliable code assumes type is CON */
 1213|      0|      if (COAP_PROTO_NOT_RELIABLE(obs->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]
  |  |  ------------------
  ------------------
 1214|      0|          (r->flags & COAP_RESOURCE_FLAGS_NOTIFY_CON) == 0 &&
  ------------------
  |  |   69|      0|#define COAP_RESOURCE_FLAGS_NOTIFY_CON  0x2
  ------------------
  |  Branch (1214:11): [True: 0, False: 0]
  ------------------
 1215|      0|          ((r->flags & COAP_RESOURCE_FLAGS_NOTIFY_NON_ALWAYS) ||
  ------------------
  |  |   79|      0|#define COAP_RESOURCE_FLAGS_NOTIFY_NON_ALWAYS  0x4
  ------------------
  |  Branch (1215:12): [True: 0, False: 0]
  ------------------
 1216|      0|           obs->non_cnt < COAP_OBS_MAX_NON)) {
  ------------------
  |  |   39|      0|#define COAP_OBS_MAX_NON   5
  ------------------
  |  Branch (1216:12): [True: 0, False: 0]
  ------------------
 1217|      0|        response->type = COAP_MESSAGE_NON;
 1218|      0|      } else {
 1219|      0|        response->type = COAP_MESSAGE_CON;
 1220|      0|      }
 1221|      0|      switch (deleting) {
 1222|      0|      case COAP_NOT_DELETING_RESOURCE:
  ------------------
  |  Branch (1222:7): [True: 0, False: 0]
  ------------------
 1223|       |        /* fill with observer-specific data */
 1224|      0|        coap_add_option_internal(response, COAP_OPTION_OBSERVE,
 1225|      0|                                 coap_encode_var_safe(buf, sizeof(buf),
 1226|      0|                                                      r->observe),
 1227|      0|                                 buf);
 1228|      0|        if (coap_get_block_b(obs->session, obs->pdu, COAP_OPTION_BLOCK2,
  ------------------
  |  Branch (1228:13): [True: 0, False: 0]
  ------------------
 1229|      0|                             &block)) {
 1230|       |          /* Will get updated later (e.g. M bit) if appropriate */
 1231|      0|          coap_add_option_internal(response, COAP_OPTION_BLOCK2,
 1232|      0|                                   coap_encode_var_safe(buf, sizeof(buf),
 1233|      0|                                                        ((0 << 4) |
 1234|      0|                                                         (0 << 3) |
 1235|      0|                                                         block.aszx)),
 1236|      0|                                   buf);
 1237|      0|        }
 1238|      0|#if COAP_Q_BLOCK_SUPPORT
 1239|      0|        else if (coap_get_block_b(obs->session, obs->pdu, COAP_OPTION_Q_BLOCK2,
  ------------------
  |  Branch (1239:18): [True: 0, False: 0]
  ------------------
 1240|      0|                                  &block)) {
 1241|       |          /* Will get updated later (e.g. M bit) if appropriate */
 1242|      0|          coap_add_option_internal(response, COAP_OPTION_Q_BLOCK2,
 1243|      0|                                   coap_encode_var_safe(buf, sizeof(buf),
 1244|      0|                                                        ((0 << 4) |
 1245|      0|                                                         (0 << 3) |
 1246|      0|                                                         block.szx)),
 1247|      0|                                   buf);
 1248|      0|        }
 1249|      0|#endif /* COAP_Q_BLOCK_SUPPORT */
 1250|       |
 1251|      0|        h = r->handler[obs->pdu->code - 1];
 1252|      0|        assert(h);      /* we do not allow subscriptions if no
  ------------------
  |  Branch (1252:9): [True: 0, False: 0]
  ------------------
 1253|       |                         * GET/FETCH handler is defined */
 1254|      0|        query = coap_get_query(obs->pdu);
 1255|      0|        coap_log_debug("Observe PDU presented to app.\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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1256|      0|        coap_show_pdu(COAP_LOG_DEBUG, obs->pdu);
 1257|      0|        coap_log_debug("call custom handler for resource '%*.*s' (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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1258|      0|                       (int)r->uri_path->length, (int)r->uri_path->length,
 1259|      0|                       r->uri_path->s);
 1260|       |
 1261|       |        /* obs may get deleted during callback (potentially by another thread) */
 1262|      0|        if (r->flags & COAP_RESOURCE_SAFE_REQUEST_HANDLER) {
  ------------------
  |  |  181|      0|#define COAP_RESOURCE_SAFE_REQUEST_HANDLER 0x4000
  ------------------
  |  Branch (1262:13): [True: 0, False: 0]
  ------------------
 1263|      0|          coap_lock_callback_release(h(r, obs->session, obs->pdu, query, response),
  ------------------
  |  |  680|      0|#define coap_lock_callback_release(func,failed) func
  ------------------
 1264|       |                                     /* context is being freed off */
 1265|      0|                                     coap_delete_string(query);
 1266|      0|                                     coap_delete_pdu_lkd(response);
 1267|      0|                                     coap_session_release_lkd(obs_session);
 1268|      0|                                     coap_pdu_release_lkd(obs_pdu);
 1269|      0|                                     r->list_being_traversed = 0;
 1270|      0|                                     coap_resource_release_lkd(r);
 1271|      0|                                     return);
 1272|      0|        } else {
 1273|      0|          coap_lock_specific_callback_release(&r->lock,
  ------------------
  |  |  692|      0|#define coap_lock_specific_callback_release(lock,func,failed) func
  ------------------
 1274|      0|                                              h(r, obs->session, obs->pdu, query, response),
 1275|       |                                              /* context is being freed off */
 1276|      0|                                              coap_delete_string(query);
 1277|      0|                                              coap_delete_pdu_lkd(response);
 1278|      0|                                              coap_session_release_lkd(obs_session);
 1279|      0|                                              coap_pdu_release_lkd(obs_pdu);
 1280|      0|                                              r->list_being_traversed = 0;
 1281|      0|                                              coap_resource_release_lkd(r);
 1282|      0|                                              return);
 1283|      0|        }
 1284|       |
 1285|       |        /* Check validity of response code */
 1286|      0|        if (!coap_check_code_class(obs_session, response)) {
  ------------------
  |  Branch (1286:13): [True: 0, False: 0]
  ------------------
 1287|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1288|      0|                        COAP_RESPONSE_CLASS(response->code),
 1289|      0|                        response->code & 0x1f);
 1290|      0|          coap_delete_string(query);
 1291|      0|          coap_delete_pdu_lkd(response);
 1292|      0|          coap_session_release_lkd(obs_session);
 1293|      0|          coap_pdu_release_lkd(obs_pdu);
 1294|      0|          r->list_being_traversed = 0;
 1295|      0|          coap_resource_release_lkd(r);
 1296|      0|          return;
 1297|      0|        }
 1298|       |
 1299|       |        /* Check if lg_xmit generated and update PDU code if so */
 1300|      0|        coap_check_code_lg_xmit(obs_session, obs_pdu, response, r, query);
 1301|      0|        coap_delete_string(query);
 1302|      0|        if (COAP_RESPONSE_CLASS(response->code) != 2) {
  ------------------
  |  |   99|      0|#define COAP_RESPONSE_CLASS(C) (((C) >> 5) & 0xFF)
  ------------------
  |  Branch (1302:13): [True: 0, False: 0]
  ------------------
 1303|      0|          coap_remove_option(response, COAP_OPTION_OBSERVE);
 1304|      0|        }
 1305|      0|        if (COAP_RESPONSE_CLASS(response->code) > 2) {
  ------------------
  |  |   99|      0|#define COAP_RESPONSE_CLASS(C) (((C) >> 5) & 0xFF)
  ------------------
  |  Branch (1305:13): [True: 0, False: 0]
  ------------------
 1306|      0|          coap_delete_observer(r, obs_session, &obs_pdu->actual_token);
 1307|      0|          obs = NULL;
 1308|      0|        }
 1309|      0|        break;
 1310|      0|      case COAP_DELETING_RESOURCE_ON_EXIT:
  ------------------
  |  Branch (1310:7): [True: 0, False: 0]
  ------------------
 1311|       |        /* Don't worry if it does not get there */
 1312|      0|        response->type = COAP_MESSAGE_NON;
 1313|      0|        response->code = COAP_RESPONSE_CODE(503);
  ------------------
  |  |   96|      0|#define COAP_RESPONSE_CODE(N) (((N)/100 << 5) | (N)%100)
  ------------------
 1314|      0|        coap_add_option_internal(response, COAP_OPTION_MAXAGE,
 1315|      0|                                 coap_encode_var_safe(buf, sizeof(buf),
 1316|      0|                                                      30),
 1317|      0|                                 buf);
 1318|      0|        break;
 1319|      0|      case COAP_DELETING_RESOURCE:
  ------------------
  |  Branch (1319:7): [True: 0, False: 0]
  ------------------
 1320|      0|      default:
  ------------------
  |  Branch (1320:7): [True: 0, False: 0]
  ------------------
 1321|       |        /* Don't worry if it does not get there */
 1322|      0|        response->type = COAP_MESSAGE_NON;
 1323|      0|        response->code = COAP_RESPONSE_CODE(404);
  ------------------
  |  |   96|      0|#define COAP_RESPONSE_CODE(N) (((N)/100 << 5) | (N)%100)
  ------------------
 1324|      0|        break;
 1325|      0|      }
 1326|       |
 1327|      0|      if (obs) {
  ------------------
  |  Branch (1327:11): [True: 0, False: 0]
  ------------------
 1328|      0|        coap_subscription_t *s;
 1329|       |        /*
 1330|       |         * obs may have been deleted in the callback, or by another running
 1331|       |         * thread when executing the callback.
 1332|       |         */
 1333|      0|        LL_FOREACH(r->subscribers, s) {
  ------------------
  |  |  419|      0|    LL_FOREACH2(head,el,next)
  |  |  ------------------
  |  |  |  |  422|      0|    for ((el) = (head); el; (el) = (el)->next)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (422:25): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1334|      0|          if (s == obs) {
  ------------------
  |  Branch (1334:15): [True: 0, False: 0]
  ------------------
 1335|      0|            break;
 1336|      0|          }
 1337|      0|        }
 1338|      0|        if (s == NULL)
  ------------------
  |  Branch (1338:13): [True: 0, False: 0]
  ------------------
 1339|      0|          obs = NULL;
 1340|      0|      }
 1341|      0|      if (obs) {
  ------------------
  |  Branch (1341:11): [True: 0, False: 0]
  ------------------
 1342|      0|        if (response->type == COAP_MESSAGE_CON ||
  ------------------
  |  Branch (1342:13): [True: 0, False: 0]
  ------------------
 1343|      0|            (r->flags & COAP_RESOURCE_FLAGS_NOTIFY_NON_ALWAYS)) {
  ------------------
  |  |   79|      0|#define COAP_RESOURCE_FLAGS_NOTIFY_NON_ALWAYS  0x4
  ------------------
  |  Branch (1343:13): [True: 0, False: 0]
  ------------------
 1344|      0|          obs->non_cnt = 0;
 1345|      0|        } else {
 1346|      0|          obs->non_cnt++;
 1347|      0|        }
 1348|       |
 1349|      0|#if COAP_Q_BLOCK_SUPPORT
 1350|      0|        if (response->code == COAP_RESPONSE_CODE(205) &&
  ------------------
  |  |   96|      0|#define COAP_RESPONSE_CODE(N) (((N)/100 << 5) | (N)%100)
  ------------------
  |  Branch (1350:13): [True: 0, False: 0]
  ------------------
 1351|      0|            coap_get_block_b(obs_session, response, COAP_OPTION_Q_BLOCK2,
  ------------------
  |  Branch (1351:13): [True: 0, False: 0]
  ------------------
 1352|      0|                             &block) &&
 1353|      0|            block.m) {
  ------------------
  |  Branch (1353:13): [True: 0, False: 0]
  ------------------
 1354|      0|          query = coap_get_query(obs_pdu);
 1355|      0|          mid = coap_send_q_block2(obs_session, r, query, obs_pdu->code,
 1356|      0|                                   block, response, 1);
 1357|      0|          coap_delete_string(query);
 1358|      0|          goto finish;
 1359|      0|        }
 1360|      0|#endif /* COAP_Q_BLOCK_SUPPORT */
 1361|      0|      }
 1362|      0|      mid = coap_send_internal(obs_session, response, NULL);
 1363|       |
 1364|      0|#if COAP_Q_BLOCK_SUPPORT
 1365|      0|finish:
 1366|      0|#endif /* COAP_Q_BLOCK_SUPPORT */
 1367|      0|      if (COAP_INVALID_MID == mid) {
  ------------------
  |  |  187|      0|#define COAP_INVALID_MID -1
  ------------------
  |  Branch (1367:11): [True: 0, False: 0]
  ------------------
 1368|      0|        coap_log_debug("*  %s: coap_check_notify: sending 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1369|      0|                       "partially dirty\n", coap_session_str(obs_session));
 1370|      0|        if (obs) {
  ------------------
  |  Branch (1370:13): [True: 0, False: 0]
  ------------------
 1371|      0|          coap_subscription_t *s;
 1372|       |          /*
 1373|       |           * obs may have been deleted in coap_send_internal() or
 1374|       |           * coap_send_q_block2().
 1375|       |           */
 1376|      0|          LL_FOREACH(r->subscribers, s) {
  ------------------
  |  |  419|      0|    LL_FOREACH2(head,el,next)
  |  |  ------------------
  |  |  |  |  422|      0|    for ((el) = (head); el; (el) = (el)->next)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (422:25): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1377|      0|            if (s == obs) {
  ------------------
  |  Branch (1377:17): [True: 0, False: 0]
  ------------------
 1378|      0|              break;
 1379|      0|            }
 1380|      0|          }
 1381|      0|          if (s == NULL)
  ------------------
  |  Branch (1381:15): [True: 0, False: 0]
  ------------------
 1382|      0|            obs = NULL;
 1383|      0|        }
 1384|      0|        if (obs)
  ------------------
  |  Branch (1384:13): [True: 0, False: 0]
  ------------------
 1385|      0|          obs->dirty = 1;
 1386|      0|        r->partiallydirty = 1;
 1387|      0|      }
 1388|      0|      goto cleanup;
 1389|       |
 1390|      0|next_one_fail:
 1391|      0|      context->observe_pending = 1;
 1392|      0|next_one_fail_no_pending:
 1393|      0|      r->partiallydirty = 1;
 1394|      0|      if (obs)
  ------------------
  |  Branch (1394:11): [True: 0, False: 0]
  ------------------
 1395|      0|        obs->dirty = 1;
 1396|      0|cleanup:
 1397|      0|      coap_session_release_lkd(obs_session);
 1398|      0|      coap_pdu_release_lkd(obs_pdu);
 1399|      0|    }
 1400|      0|    r->list_being_traversed = 0;
 1401|      0|    r->dirty = 0;
 1402|      0|    coap_resource_release_lkd(r);
 1403|       |    /* r may be no more if elsewhere coap_free_resource() has been called */
 1404|     36|  } else {
 1405|     36|    r->dirty = 0;
 1406|     36|  }
 1407|     36|}

coap_multi_fixed_fixed:
   30|    124|coap_multi_fixed_fixed(coap_fixed_point_t fp1, coap_fixed_point_t fp2) {
   31|    124|  coap_fixed_point_t res;
   32|    124|  uint32_t fr = fp1.fractional_part * fp2.fractional_part;
   33|       |
   34|    124|  res.integer_part = fp1.integer_part * fp2.integer_part + fr/1000;
   35|    124|  res.fractional_part = fr % 1000;
   36|    124|  return res;
   37|    124|}
coap_multi_fixed_uint:
   40|    124|coap_multi_fixed_uint(coap_fixed_point_t fp1, uint32_t u2) {
   41|    124|  coap_fixed_point_t res;
   42|    124|  uint32_t fr = fp1.fractional_part * u2;
   43|       |
   44|    124|  res.integer_part = fp1.integer_part * u2 + fr/1000;
   45|    124|  res.fractional_part = fr % 1000;
   46|    124|  return res;
   47|    124|}
coap_add_fixed_fixed:
   50|     62|coap_add_fixed_fixed(coap_fixed_point_t fp1, coap_fixed_point_t fp2) {
   51|     62|  coap_fixed_point_t res;
   52|     62|  uint32_t fr = fp1.fractional_part + fp2.fractional_part;
   53|       |
   54|     62|  res.integer_part = fp1.integer_part + fp2.integer_part + fr/1000;
   55|     62|  res.fractional_part = fr % 1000;
   56|     62|  return res;
   57|     62|}
coap_add_fixed_uint:
   60|    124|coap_add_fixed_uint(coap_fixed_point_t fp1, uint32_t u2) {
   61|    124|  coap_fixed_point_t res = fp1;
   62|       |
   63|    124|  res.integer_part += u2;
   64|    124|  return res;
   65|    124|}
coap_session_reference_lkd:
  358|    135|coap_session_reference_lkd(coap_session_t *session) {
  359|    135|  ++session->ref;
  360|    135|  return session;
  361|    135|}
coap_session_release_lkd:
  378|     73|coap_session_release_lkd(coap_session_t *session) {
  379|     73|  if (session) {
  ------------------
  |  Branch (379:7): [True: 73, False: 0]
  ------------------
  380|     73|    coap_lock_check_locked();
  ------------------
  |  |  638|     73|#define coap_lock_check_locked() {}
  ------------------
  381|     73|#ifndef __COVERITY__
  382|     73|    assert(session->ref > 0);
  ------------------
  |  Branch (382:5): [True: 73, False: 0]
  ------------------
  383|     73|    if (session->ref > 0)
  ------------------
  |  Branch (383:9): [True: 73, False: 0]
  ------------------
  384|     73|      --session->ref;
  385|     73|    if (session->ref == 0 && session->type == COAP_SESSION_TYPE_CLIENT)
  ------------------
  |  Branch (385:9): [True: 62, False: 11]
  |  Branch (385:30): [True: 62, False: 0]
  ------------------
  386|     62|      coap_session_free(session);
  387|       |#else /* __COVERITY__ */
  388|       |    /* Coverity scan is fooled by the reference counter leading to
  389|       |     * false positives for USE_AFTER_FREE. */
  390|       |    --session->ref;
  391|       |    __coverity_negative_sink__(session->ref);
  392|       |    /* Indicate that resources are released properly. */
  393|       |    if (session->ref == 0 && session->type == COAP_SESSION_TYPE_CLIENT) {
  394|       |      __coverity_free__(session);
  395|       |    }
  396|       |#endif /* __COVERITY__ */
  397|     73|  }
  398|     73|}
coap_session_mfree:
  531|     62|coap_session_mfree(coap_session_t *session) {
  532|     62|  coap_queue_t *q, *tmp;
  533|     62|  coap_lg_xmit_t *lq, *ltmp;
  534|       |
  535|     62|#if COAP_PROXY_SUPPORT
  536|     62|  if (session->ref_proxy_subs)
  ------------------
  |  Branch (536:7): [True: 0, False: 62]
  ------------------
  537|      0|    coap_delete_proxy_subscriber(session, NULL, 0, COAP_PROXY_SUBS_ALL);
  538|     62|#endif /* COAP_PROXY_SUPPORT */
  539|     62|#if COAP_CLIENT_SUPPORT
  540|     62|  coap_lg_crcv_t *lg_crcv, *etmp;
  541|       |
  542|       |  /* Need to do this before (D)TLS and socket is closed down */
  543|     62|  LL_FOREACH_SAFE(session->lg_crcv, lg_crcv, etmp) {
  ------------------
  |  |  425|     62|    LL_FOREACH_SAFE2(head,el,tmp,next)
  |  |  ------------------
  |  |  |  |  428|     62|  for ((el) = (head); (el) && ((tmp) = (el)->next, 1); (el) = (tmp))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (428:23): [True: 0, False: 62]
  |  |  |  |  |  Branch (428:31): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  544|      0|    if (lg_crcv->observe_set && session->no_observe_cancel == 0) {
  ------------------
  |  Branch (544:9): [True: 0, False: 0]
  |  Branch (544:33): [True: 0, False: 0]
  ------------------
  545|       |      /* Need to close down observe */
  546|      0|      if (coap_cancel_observe_lkd(session, lg_crcv->app_token, COAP_MESSAGE_NON)) {
  ------------------
  |  Branch (546:11): [True: 0, False: 0]
  ------------------
  547|       |        /* Need to delete node we set up for NON */
  548|      0|        coap_queue_t *queue = session->context->sendqueue;
  549|       |
  550|      0|        while (queue) {
  ------------------
  |  Branch (550:16): [True: 0, False: 0]
  ------------------
  551|      0|          if (queue->session == session) {
  ------------------
  |  Branch (551:15): [True: 0, False: 0]
  ------------------
  552|      0|            coap_delete_node_lkd(queue);
  553|      0|            break;
  554|      0|          }
  555|      0|          queue = queue->next;
  556|      0|        }
  557|      0|      }
  558|      0|    }
  559|       |    /* In case coap_cancel_observe_lkd() failure, which could clear down lg_crcv */
  560|      0|    if (!session->lg_crcv)
  ------------------
  |  Branch (560:9): [True: 0, False: 0]
  ------------------
  561|      0|      break;
  562|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  563|      0|    coap_block_delete_lg_crcv(session, lg_crcv);
  564|      0|  }
  565|     62|#endif /* COAP_CLIENT_SUPPORT */
  566|       |
  567|     62|  LL_FOREACH_SAFE(session->delayqueue, q, tmp) {
  ------------------
  |  |  425|     62|    LL_FOREACH_SAFE2(head,el,tmp,next)
  |  |  ------------------
  |  |  |  |  428|     62|  for ((el) = (head); (el) && ((tmp) = (el)->next, 1); (el) = (tmp))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (428:23): [True: 0, False: 62]
  |  |  |  |  |  Branch (428:31): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  568|      0|    if (q->pdu->type==COAP_MESSAGE_CON) {
  ------------------
  |  Branch (568:9): [True: 0, False: 0]
  ------------------
  569|      0|      coap_handle_nack(session, q->pdu,
  570|      0|                       session->proto == COAP_PROTO_DTLS ?
  ------------------
  |  Branch (570:24): [True: 0, False: 0]
  ------------------
  571|      0|                       COAP_NACK_TLS_FAILED : COAP_NACK_NOT_DELIVERABLE,
  572|      0|                       q->id);
  573|      0|    }
  574|      0|    coap_delete_node_lkd(q);
  575|      0|  }
  576|       |
  577|     62|#if COAP_CLIENT_SUPPORT
  578|     62|  coap_pdu_t *p, *ptmp;
  579|       |
  580|     62|  LL_FOREACH_SAFE(session->doing_first_pdu, p, ptmp) {
  ------------------
  |  |  425|     62|    LL_FOREACH_SAFE2(head,el,tmp,next)
  |  |  ------------------
  |  |  |  |  428|     62|  for ((el) = (head); (el) && ((tmp) = (el)->next, 1); (el) = (tmp))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (428:23): [True: 0, False: 62]
  |  |  |  |  |  Branch (428:31): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  581|      0|    if (p->type==COAP_MESSAGE_CON) {
  ------------------
  |  Branch (581:9): [True: 0, False: 0]
  ------------------
  582|      0|      coap_handle_nack(session, p,
  583|      0|                       session->proto == COAP_PROTO_DTLS ?
  ------------------
  |  Branch (583:24): [True: 0, False: 0]
  ------------------
  584|      0|                       COAP_NACK_TLS_FAILED : COAP_NACK_NOT_DELIVERABLE,
  585|      0|                       p->mid);
  586|      0|    }
  587|      0|    coap_delete_pdu_lkd(p);
  588|      0|  }
  589|     62|#endif /* COAP_CLIENT_SUPPORT */
  590|       |
  591|     62|  if (session->partial_pdu)
  ------------------
  |  Branch (591:7): [True: 0, False: 62]
  ------------------
  592|      0|    coap_delete_pdu_lkd(session->partial_pdu);
  593|     62|  if (session->sock.lfunc[COAP_LAYER_SESSION].l_close)
  ------------------
  |  Branch (593:7): [True: 62, False: 0]
  ------------------
  594|     62|    session->sock.lfunc[COAP_LAYER_SESSION].l_close(session);
  595|     62|  if (session->psk_identity)
  ------------------
  |  Branch (595:7): [True: 0, False: 62]
  ------------------
  596|      0|    coap_delete_bin_const(session->psk_identity);
  597|     62|  if (session->psk_key)
  ------------------
  |  Branch (597:7): [True: 0, False: 62]
  ------------------
  598|      0|    coap_delete_bin_const(session->psk_key);
  599|     62|  if (session->psk_hint)
  ------------------
  |  Branch (599:7): [True: 0, False: 62]
  ------------------
  600|      0|    coap_delete_bin_const(session->psk_hint);
  601|       |
  602|     62|#if COAP_SERVER_SUPPORT
  603|     62|  coap_cache_entry_t *cp, *ctmp;
  604|     62|  HASH_ITER(hh, session->context->cache, cp, ctmp) {
  ------------------
  |  | 1071|     62|#define HASH_ITER(hh,head,el,tmp)                                                \
  |  | 1072|     62|for(((el)=(head)), ((tmp)=DECLTYPE(el)((head!=NULL)?(head)->hh.next:NULL));      \
  |  |  ------------------
  |  |  |  |   66|     62|#define DECLTYPE(x) (__typeof(x))
  |  |  ------------------
  |  |  |  Branch (1072:40): [True: 0, False: 62]
  |  |  ------------------
  |  | 1073|     62|  (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: 62]
  |  |  |  Branch (1073:51): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  605|       |    /* cp->session is NULL if not session based */
  606|      0|    if (cp->session == session) {
  ------------------
  |  Branch (606:9): [True: 0, False: 0]
  ------------------
  607|      0|      coap_delete_cache_entry(session->context, cp);
  608|      0|    }
  609|      0|  }
  610|     62|#endif /* COAP_PROXY_SUPPORT */
  611|     62|  LL_FOREACH_SAFE(session->lg_xmit, lq, ltmp) {
  ------------------
  |  |  425|     62|    LL_FOREACH_SAFE2(head,el,tmp,next)
  |  |  ------------------
  |  |  |  |  428|     62|  for ((el) = (head); (el) && ((tmp) = (el)->next, 1); (el) = (tmp))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (428:23): [True: 0, False: 62]
  |  |  |  |  |  Branch (428:31): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  612|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  613|      0|    coap_block_delete_lg_xmit(session, lq);
  614|      0|  }
  615|     62|#if COAP_SERVER_SUPPORT
  616|     62|  coap_lg_srcv_t *sq, *stmp;
  617|       |
  618|     62|  LL_FOREACH_SAFE(session->lg_srcv, sq, stmp) {
  ------------------
  |  |  425|     62|    LL_FOREACH_SAFE2(head,el,tmp,next)
  |  |  ------------------
  |  |  |  |  428|     62|  for ((el) = (head); (el) && ((tmp) = (el)->next, 1); (el) = (tmp))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (428:23): [True: 0, False: 62]
  |  |  |  |  |  Branch (428:31): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  619|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  620|      0|    coap_block_delete_lg_srcv(session, sq);
  621|      0|  }
  622|     62|#endif /* COAP_SERVER_SUPPORT */
  623|     62|#if COAP_OSCORE_SUPPORT
  624|     62|  coap_delete_oscore_associations(session);
  625|     62|  oscore_release_recipient_ctx(&session->recipient_ctx);
  626|     62|  coap_delete_str_const(session->b_2_retransmit_token);
  627|     62|#endif /* COAP_OSCORE_SUPPORT */
  628|     62|#if COAP_WS_SUPPORT
  629|     62|  coap_free_type(COAP_STRING, session->ws);
  630|     62|  coap_delete_str_const(session->ws_host);
  631|     62|#endif /* COAP_WS_SUPPORT */
  632|     62|}
coap_session_free:
  635|     62|coap_session_free(coap_session_t *session) {
  636|     62|  if (!session)
  ------------------
  |  Branch (636:7): [True: 0, False: 62]
  ------------------
  637|      0|    return;
  638|     62|  coap_lock_check_locked();
  ------------------
  |  |  638|     62|#define coap_lock_check_locked() {}
  ------------------
  639|     62|  assert(session->ref == 0);
  ------------------
  |  Branch (639:3): [True: 62, False: 0]
  ------------------
  640|     62|  if (session->ref)
  ------------------
  |  Branch (640:7): [True: 0, False: 62]
  ------------------
  641|      0|    return;
  642|       |  /* Make sure nothing gets deleted under our feet */
  643|     62|  coap_session_reference_lkd(session);
  644|     62|  coap_session_mfree(session);
  645|     62|#if COAP_SERVER_SUPPORT
  646|     62|  coap_delete_bin_const(session->client_cid);
  647|     62|  if (session->endpoint) {
  ------------------
  |  Branch (647:7): [True: 0, False: 62]
  ------------------
  648|      0|    if (session->endpoint->sessions)
  ------------------
  |  Branch (648:9): [True: 0, False: 0]
  ------------------
  649|      0|      SESSIONS_DELETE(session->endpoint->sessions, session);
  ------------------
  |  |  939|      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]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  650|      0|  } else
  651|     62|#endif /* COAP_SERVER_SUPPORT */
  652|     62|#if COAP_CLIENT_SUPPORT
  653|     62|    if (session->context) {
  ------------------
  |  Branch (653:9): [True: 62, False: 0]
  ------------------
  654|     62|      if (session->context->sessions)
  ------------------
  |  Branch (654:11): [True: 62, False: 0]
  ------------------
  655|     62|        SESSIONS_DELETE(session->context->sessions, session);
  ------------------
  |  |  939|     62|  HASH_DELETE(hh, (e), (obj))
  |  |  ------------------
  |  |  |  |  462|     62|    HASH_DELETE_HH(hh, head, &(delptr)->hh)
  |  |  |  |  ------------------
  |  |  |  |  |  |  464|     62|#define HASH_DELETE_HH(hh,head,delptrhh)                                         \
  |  |  |  |  |  |  465|     62|do {                                                                             \
  |  |  |  |  |  |  466|     62|  struct UT_hash_handle *_hd_hh_del = (delptrhh);                                \
  |  |  |  |  |  |  467|     62|  if ((_hd_hh_del->prev == NULL) && (_hd_hh_del->next == NULL)) {                \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (467:7): [True: 62, False: 0]
  |  |  |  |  |  |  |  Branch (467:37): [True: 36, False: 26]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  468|     36|    HASH_BLOOM_FREE((head)->hh.tbl);                                             \
  |  |  |  |  |  |  469|     36|    uthash_free((head)->hh.tbl->buckets,                                         \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   92|     36|#define uthash_free(ptr,sz) free(ptr)     /* free fcn                        */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  470|     36|                (head)->hh.tbl->num_buckets * sizeof(struct UT_hash_bucket));    \
  |  |  |  |  |  |  471|     36|    uthash_free((head)->hh.tbl, sizeof(UT_hash_table));                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   92|     36|#define uthash_free(ptr,sz) free(ptr)     /* free fcn                        */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  472|     36|    (head) = NULL;                                                               \
  |  |  |  |  |  |  473|     36|  } else {                                                                       \
  |  |  |  |  |  |  474|     26|    uint32_t _hd_bkt;                                                            \
  |  |  |  |  |  |  475|     26|    if (_hd_hh_del == (head)->hh.tbl->tail) {                                    \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (475:9): [True: 0, False: 26]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  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|     26|    if (_hd_hh_del->prev != NULL) {                                              \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (478:9): [True: 0, False: 26]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  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|     26|    } else {                                                                     \
  |  |  |  |  |  |  481|     26|      DECLTYPE_ASSIGN(head, _hd_hh_del->next);                                   \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   78|     26|#define DECLTYPE_ASSIGN(dst,src)                                                 \
  |  |  |  |  |  |  |  |   79|     26|do {                                                                             \
  |  |  |  |  |  |  |  |   80|     26|  (dst) = DECLTYPE(dst)(src);                                                    \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   66|     26|#define DECLTYPE(x) (__typeof(x))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   81|     26|} while (0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (81:10): [Folded, False: 26]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  482|     26|    }                                                                            \
  |  |  |  |  |  |  483|     26|    if (_hd_hh_del->next != NULL) {                                              \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (483:9): [True: 26, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  484|     26|      HH_FROM_ELMT((head)->hh.tbl, _hd_hh_del->next)->prev = _hd_hh_del->prev;   \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  150|     26|#define HH_FROM_ELMT(tbl,elp) ((UT_hash_handle*)(void*)(((char*)(elp)) + ((tbl)->hho)))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  485|     26|    }                                                                            \
  |  |  |  |  |  |  486|     26|    HASH_TO_BKT(_hd_hh_del->hashv, (head)->hh.tbl->num_buckets, _hd_bkt);        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  444|     26|#define HASH_TO_BKT(hashv,num_bkts,bkt)                                          \
  |  |  |  |  |  |  |  |  445|     26|do {                                                                             \
  |  |  |  |  |  |  |  |  446|     26|  bkt = ((hashv) & ((num_bkts) - 1U));                                           \
  |  |  |  |  |  |  |  |  447|     26|} while (0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (447:10): [Folded, False: 26]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  487|     26|    HASH_DEL_IN_BKT((head)->hh.tbl->buckets[_hd_bkt], _hd_hh_del);               \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  800|     26|#define HASH_DEL_IN_BKT(head,delhh)                                              \
  |  |  |  |  |  |  |  |  801|     26|do {                                                                             \
  |  |  |  |  |  |  |  |  802|     26|  UT_hash_bucket *_hd_head = &(head);                                            \
  |  |  |  |  |  |  |  |  803|     26|  _hd_head->count--;                                                             \
  |  |  |  |  |  |  |  |  804|     26|  if (_hd_head->hh_head == (delhh)) {                                            \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (804:7): [True: 0, False: 26]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  805|      0|    _hd_head->hh_head = (delhh)->hh_next;                                        \
  |  |  |  |  |  |  |  |  806|      0|  }                                                                              \
  |  |  |  |  |  |  |  |  807|     26|  if ((delhh)->hh_prev) {                                                        \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (807:7): [True: 26, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  808|     26|    (delhh)->hh_prev->hh_next = (delhh)->hh_next;                                \
  |  |  |  |  |  |  |  |  809|     26|  }                                                                              \
  |  |  |  |  |  |  |  |  810|     26|  if ((delhh)->hh_next) {                                                        \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (810:7): [True: 0, False: 26]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  811|      0|    (delhh)->hh_next->hh_prev = (delhh)->hh_prev;                                \
  |  |  |  |  |  |  |  |  812|      0|  }                                                                              \
  |  |  |  |  |  |  |  |  813|     26|} while (0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (813:10): [Folded, False: 26]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  488|     26|    (head)->hh.tbl->num_items--;                                                 \
  |  |  |  |  |  |  489|     26|  }                                                                              \
  |  |  |  |  |  |  490|     62|  HASH_FSCK(hh, head, "HASH_DELETE_HH");                                         \
  |  |  |  |  |  |  491|     62|} while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (491:10): [Folded, False: 62]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  656|     62|    }
  657|     62|  coap_delete_bin_const(session->req_token);
  658|     62|#endif /* COAP_CLIENT_SUPPORT */
  659|     62|  coap_delete_bin_const(session->last_token);
  660|     62|  coap_delete_bin_const(session->echo);
  661|     62|#if COAP_SERVER_SUPPORT
  662|     62|  coap_delete_pdu_lkd(session->cached_pdu);
  663|     62|#endif /* COAP_SERVER_SUPPORT */
  664|       |
  665|     62|  if (session->app_cb) {
  ------------------
  |  Branch (665:7): [True: 0, False: 62]
  ------------------
  666|      0|    coap_lock_callback(session->app_cb(session->app_data));
  ------------------
  |  |  651|      0|#define coap_lock_callback(func) func
  ------------------
  667|      0|  }
  668|     62|  coap_log_debug("***%s: session %p: closed\n", coap_session_str(session),
  ------------------
  |  |  126|     62|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|     62|#define coap_log(level, ...) do { \
  |  |  |  |  291|     62|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 62]
  |  |  |  |  ------------------
  |  |  |  |  292|     62|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|     62|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 62]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  669|     62|                 (void *)session);
  670|     62|  assert(session->ref == 1);
  ------------------
  |  Branch (670:3): [True: 62, False: 0]
  ------------------
  671|     62|  coap_free_type(COAP_SESSION, session);
  672|     62|}
coap_session_max_pdu_size:
  755|     36|coap_session_max_pdu_size(const coap_session_t *session) {
  756|     36|  size_t size;
  757|     36|  coap_session_t *session_rw;
  758|       |
  759|       |  /*
  760|       |   * Need to do this to not get a compiler warning about const parameters
  761|       |   * but need to maintain source code backward compatibility
  762|       |   */
  763|     36|  memcpy(&session_rw, &session, sizeof(session_rw));
  764|     36|  coap_lock_lock(return 0);
  765|     36|  size = coap_session_max_pdu_size_lkd(session_rw);
  766|     36|  coap_lock_unlock();
  767|     36|  return size;
  768|     36|}
coap_session_max_pdu_size_lkd:
  771|     80|coap_session_max_pdu_size_lkd(const coap_session_t *session) {
  772|     80|  size_t max_with_header;
  773|       |
  774|     80|  coap_lock_check_locked();
  ------------------
  |  |  638|     80|#define coap_lock_check_locked() {}
  ------------------
  775|     80|#if COAP_CLIENT_SUPPORT
  776|     80|  if (COAP_PROTO_RELIABLE(session->proto) &&
  ------------------
  |  |   42|    160|#define COAP_PROTO_RELIABLE(p) ((p)==COAP_PROTO_TCP || (p)==COAP_PROTO_TLS || \
  |  |  ------------------
  |  |  |  Branch (42:33): [True: 0, False: 80]
  |  |  |  Branch (42:56): [True: 0, False: 80]
  |  |  ------------------
  |  |   43|     80|                                (p)==COAP_PROTO_WS || (p)==COAP_PROTO_WSS)
  |  |  ------------------
  |  |  |  Branch (43:33): [True: 0, False: 80]
  |  |  |  Branch (43:55): [True: 0, False: 80]
  |  |  ------------------
  ------------------
  777|      0|      session->type == COAP_SESSION_TYPE_CLIENT &&
  ------------------
  |  Branch (777:7): [True: 0, False: 0]
  ------------------
  778|      0|      session->doing_first) {
  ------------------
  |  Branch (778:7): [True: 0, False: 0]
  ------------------
  779|       |    /*
  780|       |     * Delay if session->doing_first is set.
  781|       |     * E.g. Reliable and CSM not in yet for checking block support
  782|       |     */
  783|      0|    coap_session_t *session_rw;
  784|       |
  785|       |    /*
  786|       |     * Need to do this to not get a compiler warning about const parameters
  787|       |     * but need to maintain source code backward compatibility
  788|       |     */
  789|      0|    memcpy(&session_rw, &session, sizeof(session_rw));
  790|      0|    if (coap_client_delay_first(session_rw) == 0) {
  ------------------
  |  Branch (790:9): [True: 0, False: 0]
  ------------------
  791|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  792|       |      /* Have to go with the defaults */
  793|      0|    }
  794|      0|  }
  795|     80|#endif /* COAP_CLIENT_SUPPORT */
  796|       |
  797|     80|  max_with_header = (size_t)(session->mtu - session->tls_overhead);
  798|       |
  799|     80|  return coap_session_max_pdu_size_internal(session, max_with_header);
  800|     80|}
coap_session_set_mtu:
  803|     62|coap_session_set_mtu(coap_session_t *session, unsigned mtu) {
  804|     62|  if (mtu > COAP_DEFAULT_MAX_PDU_RX_SIZE) {
  ------------------
  |  |   84|     62|#define COAP_DEFAULT_MAX_PDU_RX_SIZE (8UL*1024*1024+256)
  ------------------
  |  Branch (804:7): [True: 0, False: 62]
  ------------------
  805|      0|    mtu = COAP_DEFAULT_MAX_PDU_RX_SIZE;
  ------------------
  |  |   84|      0|#define COAP_DEFAULT_MAX_PDU_RX_SIZE (8UL*1024*1024+256)
  ------------------
  806|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  807|      0|                   coap_session_str(session), mtu);
  808|      0|  }
  809|     62|  if (mtu < 64)
  ------------------
  |  Branch (809:7): [True: 0, False: 62]
  ------------------
  810|      0|    mtu = 64;
  811|     62|  session->mtu = mtu;
  812|     62|  if (session->tls_overhead >= session->mtu) {
  ------------------
  |  Branch (812:7): [True: 0, False: 62]
  ------------------
  813|      0|    session->tls_overhead = session->mtu;
  814|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  815|      0|  }
  816|     62|}
coap_session_connected:
  952|     62|coap_session_connected(coap_session_t *session) {
  953|     62|  if (session->state != COAP_SESSION_STATE_ESTABLISHED) {
  ------------------
  |  Branch (953:7): [True: 62, False: 0]
  ------------------
  954|     62|    coap_log_debug("***%s: session connected\n",
  ------------------
  |  |  126|     62|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|     62|#define coap_log(level, ...) do { \
  |  |  |  |  291|     62|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 62]
  |  |  |  |  ------------------
  |  |  |  |  292|     62|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|     62|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 62]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  955|     62|                   coap_session_str(session));
  956|     62|    if (session->state == COAP_SESSION_STATE_CSM) {
  ------------------
  |  Branch (956:9): [True: 0, False: 62]
  ------------------
  957|      0|      coap_handle_event_lkd(session->context, COAP_EVENT_SESSION_CONNECTED, session);
  958|      0|#if COAP_CLIENT_SUPPORT
  959|      0|      coap_session_reestablished(session);
  960|      0|      coap_reset_doing_first(session);
  961|      0|#endif /* COAP_CLIENT_SUPPORT */
  962|      0|    }
  963|     62|  }
  964|       |
  965|     62|  session->state = COAP_SESSION_STATE_ESTABLISHED;
  966|     62|  session->partial_write = 0;
  967|       |
  968|     62|  if (session->proto==COAP_PROTO_DTLS) {
  ------------------
  |  Branch (968:7): [True: 0, False: 62]
  ------------------
  969|      0|    session->tls_overhead = coap_dtls_get_overhead(session);
  970|      0|    if (session->tls_overhead >= session->mtu) {
  ------------------
  |  Branch (970:9): [True: 0, False: 0]
  ------------------
  971|      0|      session->tls_overhead = session->mtu;
  972|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  973|      0|    }
  974|      0|  }
  975|       |
  976|     62|  while (session->delayqueue && session->state == COAP_SESSION_STATE_ESTABLISHED) {
  ------------------
  |  Branch (976:10): [True: 0, False: 62]
  |  Branch (976:33): [True: 0, False: 0]
  ------------------
  977|      0|    ssize_t bytes_written;
  978|      0|    coap_queue_t *q = session->delayqueue;
  979|      0|    coap_address_t remote;
  980|       |
  981|      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 (981:9): [True: 0, False: 0]
  ------------------
  982|      0|      if (session->con_active >= COAP_NSTART(session))
  ------------------
  |  |  798|      0|#define COAP_NSTART(s) ((s)->nstart)
  ------------------
  |  Branch (982:11): [True: 0, False: 0]
  ------------------
  983|      0|        break;
  984|      0|      session->con_active++;
  985|      0|    }
  986|       |    /* Take entry off the queue */
  987|      0|    session->delayqueue = q->next;
  988|      0|    q->next = NULL;
  989|       |
  990|      0|    coap_address_copy(&remote, &session->addr_info.remote);
  991|      0|    coap_address_copy(&session->addr_info.remote, &q->remote);
  992|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  993|      0|                   coap_session_str(session), (int)q->id);
  994|      0|    bytes_written = coap_session_send_pdu(session, q->pdu);
  995|      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 (995:9): [True: 0, False: 0]
  ------------------
  996|      0|      if (coap_wait_ack(session->context, session, q) >= 0)
  ------------------
  |  Branch (996:11): [True: 0, False: 0]
  ------------------
  997|      0|        q = NULL;
  998|      0|    }
  999|      0|    coap_address_copy(&session->addr_info.remote, &remote);
 1000|      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]
  |  |  ------------------
  ------------------
 1001|      0|      if (q)
  ------------------
  |  Branch (1001:11): [True: 0, False: 0]
  ------------------
 1002|      0|        coap_delete_node_lkd(q);
 1003|      0|      if (bytes_written < 0)
  ------------------
  |  Branch (1003:11): [True: 0, False: 0]
  ------------------
 1004|      0|        break;
 1005|      0|    } else if (q) {
  ------------------
  |  Branch (1005:16): [True: 0, False: 0]
  ------------------
 1006|      0|      if (bytes_written <= 0 || (size_t)bytes_written < q->pdu->used_size + q->pdu->hdr_size) {
  ------------------
  |  Branch (1006:11): [True: 0, False: 0]
  |  Branch (1006:33): [True: 0, False: 0]
  ------------------
 1007|      0|        q->next = session->delayqueue;
 1008|      0|        session->delayqueue = q;
 1009|      0|        if (bytes_written > 0)
  ------------------
  |  Branch (1009:13): [True: 0, False: 0]
  ------------------
 1010|      0|          session->partial_write = (size_t)bytes_written;
 1011|      0|        break;
 1012|      0|      } else {
 1013|      0|        coap_delete_node_lkd(q);
 1014|      0|      }
 1015|      0|    }
 1016|      0|  }
 1017|     62|}
coap_session_establish:
 1628|     62|coap_session_establish(coap_session_t *session) {
 1629|     62|  if (COAP_PROTO_NOT_RELIABLE(session->proto))
  ------------------
  |  |   41|     62|#define COAP_PROTO_NOT_RELIABLE(p) ((p)==COAP_PROTO_UDP || (p)==COAP_PROTO_DTLS)
  |  |  ------------------
  |  |  |  Branch (41:37): [True: 62, False: 0]
  |  |  |  Branch (41:60): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1630|     62|    coap_session_connected(session);
 1631|     62|#if !COAP_DISABLE_TCP
 1632|     62|  if (COAP_PROTO_RELIABLE(session->proto))
  ------------------
  |  |   42|     62|#define COAP_PROTO_RELIABLE(p) ((p)==COAP_PROTO_TCP || (p)==COAP_PROTO_TLS || \
  |  |  ------------------
  |  |  |  Branch (42:33): [True: 0, False: 62]
  |  |  |  Branch (42:56): [True: 0, False: 62]
  |  |  ------------------
  |  |   43|     62|                                (p)==COAP_PROTO_WS || (p)==COAP_PROTO_WSS)
  |  |  ------------------
  |  |  |  Branch (43:33): [True: 0, False: 62]
  |  |  |  Branch (43:55): [True: 0, False: 62]
  |  |  ------------------
  ------------------
 1633|      0|    coap_session_send_csm(session);
 1634|     62|#endif /* !COAP_DISABLE_TCP */
 1635|     62|}
coap_new_client_session:
 1730|     36|                        coap_proto_t proto) {
 1731|     36|  coap_session_t *session;
 1732|       |
 1733|     36|  coap_lock_lock(return NULL);
 1734|     36|  session = coap_new_client_session3_lkd(ctx, local_if, server, proto, NULL, NULL, NULL);
 1735|     36|  coap_lock_unlock();
 1736|     36|  return session;
 1737|     36|}
coap_new_client_session3_lkd:
 1762|     62|                             coap_str_const_t *ws_host) {
 1763|     62|  coap_session_t *session;
 1764|       |
 1765|     62|  coap_lock_check_locked();
  ------------------
  |  |  638|     62|#define coap_lock_check_locked() {}
  ------------------
 1766|     62|  session = coap_session_create_client(ctx, local_if, server,
 1767|     62|                                       proto, app_data, callback, ws_host);
 1768|     62|  if (session) {
  ------------------
  |  Branch (1768:7): [True: 62, False: 0]
  ------------------
 1769|     62|    coap_log_debug("***%s: session %p: created outgoing session\n",
  ------------------
  |  |  126|     62|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|     62|#define coap_log(level, ...) do { \
  |  |  |  |  291|     62|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 62]
  |  |  |  |  ------------------
  |  |  |  |  292|     62|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|     62|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 62]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1770|     62|                   coap_session_str(session), (void *)session);
 1771|     62|    coap_session_check_connect(session);
 1772|     62|  }
 1773|     62|  return session;
 1774|     62|}
coap_session_new_token:
 2281|     26|                       uint8_t *data) {
 2282|     26|  *len = coap_encode_var_safe8(data,
 2283|     26|                               sizeof(session->tx_token), ++session->tx_token);
 2284|     26|}
coap_new_message_id:
 2287|     72|coap_new_message_id(coap_session_t *session) {
 2288|     72|  uint16_t mid;
 2289|       |
 2290|     72|  coap_lock_lock(return 0);
 2291|     72|  mid = coap_new_message_id_lkd(session);
 2292|     72|  coap_lock_unlock();
 2293|     72|  return mid;
 2294|     72|}
coap_new_message_id_lkd:
 2297|     98|coap_new_message_id_lkd(coap_session_t *session) {
 2298|     98|  coap_lock_check_locked();
  ------------------
  |  |  638|     98|#define coap_lock_check_locked() {}
  ------------------
 2299|     98|  if (COAP_PROTO_NOT_RELIABLE(session->proto))
  ------------------
  |  |   41|     98|#define COAP_PROTO_NOT_RELIABLE(p) ((p)==COAP_PROTO_UDP || (p)==COAP_PROTO_DTLS)
  |  |  ------------------
  |  |  |  Branch (41:37): [True: 98, False: 0]
  |  |  |  Branch (41:60): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 2300|     98|    return ++session->tx_mid;
 2301|       |  /* TCP/TLS have no notion of mid */
 2302|      0|  return 0;
 2303|     98|}
coap_session.c:coap_session_fix_non_probing_wait_base:
  120|     62|coap_session_fix_non_probing_wait_base(coap_session_t *s) {
  121|     62|  coap_fixed_point_t res;
  122|       |
  123|     62|  res = coap_multi_fixed_uint(COAP_NON_TIMEOUT(s),
  ------------------
  |  |  804|     62|#define COAP_NON_TIMEOUT(s) ((s)->non_timeout)
  ------------------
  124|     62|                              ((1 << (COAP_NON_MAX_RETRANSMIT(s) + 1)) -1));
  ------------------
  |  |  803|     62|#define COAP_NON_MAX_RETRANSMIT(s) ((s)->non_max_retransmit)
  ------------------
  125|     62|  res = coap_multi_fixed_fixed(res, COAP_ACK_RANDOM_FACTOR(s));
  ------------------
  |  |  796|     62|#define COAP_ACK_RANDOM_FACTOR(s) ((s)->ack_random_factor)
  ------------------
  126|     62|  res = coap_add_fixed_uint(res, 2 * COAP_DEFAULT_MAX_LATENCY);
  ------------------
  |  |  781|     62|#define COAP_DEFAULT_MAX_LATENCY (100U)
  ------------------
  127|     62|  COAP_NON_PROBING_WAIT_BASE(s) = res;
  ------------------
  |  |  809|     62|#define COAP_NON_PROBING_WAIT_BASE(s) ((s)->non_probing_wait_base)
  ------------------
  128|     62|}
coap_session.c:coap_session_fix_non_partial_timeout:
  135|     62|coap_session_fix_non_partial_timeout(coap_session_t *s) {
  136|     62|  coap_fixed_point_t res;
  137|       |
  138|     62|  res = coap_multi_fixed_uint(COAP_NON_TIMEOUT(s),
  ------------------
  |  |  804|     62|#define COAP_NON_TIMEOUT(s) ((s)->non_timeout)
  ------------------
  139|     62|                              ((1 << (COAP_NON_MAX_RETRANSMIT(s) + 1)) -1));
  ------------------
  |  |  803|     62|#define COAP_NON_MAX_RETRANSMIT(s) ((s)->non_max_retransmit)
  ------------------
  140|     62|  res = coap_multi_fixed_fixed(res, COAP_ACK_RANDOM_FACTOR(s));
  ------------------
  |  |  796|     62|#define COAP_ACK_RANDOM_FACTOR(s) ((s)->ack_random_factor)
  ------------------
  141|     62|  res = coap_add_fixed_uint(res, 2 * COAP_DEFAULT_MAX_LATENCY);
  ------------------
  |  |  781|     62|#define COAP_DEFAULT_MAX_LATENCY (100U)
  ------------------
  142|     62|  res = coap_add_fixed_fixed(res, COAP_NON_TIMEOUT(s));
  ------------------
  |  |  804|     62|#define COAP_NON_TIMEOUT(s) ((s)->non_timeout)
  ------------------
  143|     62|  COAP_NON_PARTIAL_TIMEOUT(s) = res;
  ------------------
  |  |  810|     62|#define COAP_NON_PARTIAL_TIMEOUT(s) ((s)->non_partial_timeout)
  ------------------
  144|     62|}
coap_session.c:coap_session_max_pdu_size_internal:
  719|     80|                                   size_t max_with_header) {
  720|       |#if COAP_DISABLE_TCP
  721|       |  (void)session;
  722|       |  return max_with_header > COAP_PDU_MAX_UDP_HEADER_SIZE
  723|       |         ? max_with_header - COAP_PDU_MAX_UDP_HEADER_SIZE
  724|       |         : 0;
  725|       |#else /* !COAP_DISABLE_TCP */
  726|     80|  if (COAP_PROTO_NOT_RELIABLE(session->proto))
  ------------------
  |  |   41|     80|#define COAP_PROTO_NOT_RELIABLE(p) ((p)==COAP_PROTO_UDP || (p)==COAP_PROTO_DTLS)
  |  |  ------------------
  |  |  |  Branch (41:37): [True: 80, False: 0]
  |  |  |  Branch (41:60): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  727|     80|    return max_with_header > COAP_PDU_MAX_UDP_HEADER_SIZE
  ------------------
  |  |  107|     80|#define COAP_PDU_MAX_UDP_HEADER_SIZE 4
  ------------------
  |  Branch (727:12): [True: 80, False: 0]
  ------------------
  728|     80|           ? max_with_header - COAP_PDU_MAX_UDP_HEADER_SIZE
  ------------------
  |  |  107|     80|#define COAP_PDU_MAX_UDP_HEADER_SIZE 4
  ------------------
  729|     80|           : 0;
  730|       |  /* we must assume there is no token to be on the safe side */
  731|      0|  if (max_with_header <= 2)
  ------------------
  |  Branch (731:7): [True: 0, False: 0]
  ------------------
  732|      0|    return 0;
  733|      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 (733:12): [True: 0, False: 0]
  ------------------
  734|      0|    return max_with_header - 2;
  735|      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 (735:12): [True: 0, False: 0]
  ------------------
  736|      0|    return max_with_header - 3;
  737|      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 (737:12): [True: 0, False: 0]
  ------------------
  738|      0|    return max_with_header - 4;
  739|      0|  else
  740|      0|    return max_with_header - COAP_PDU_MAX_TCP_HEADER_SIZE;
  ------------------
  |  |  108|      0|#define COAP_PDU_MAX_TCP_HEADER_SIZE 6
  ------------------
  741|      0|#endif /* !COAP_DISABLE_TCP */
  742|      0|}
coap_session.c:coap_make_session:
  440|     62|                  coap_context_t *context, coap_endpoint_t *endpoint) {
  441|     62|  coap_session_t *session = (coap_session_t *)coap_malloc_type(COAP_SESSION,
  442|     62|                            sizeof(coap_session_t));
  443|       |#if ! COAP_SERVER_SUPPORT
  444|       |  (void)endpoint;
  445|       |#endif /* ! COAP_SERVER_SUPPORT */
  446|     62|  if (!session)
  ------------------
  |  Branch (446:7): [True: 0, False: 62]
  ------------------
  447|      0|    return NULL;
  448|     62|  memset(session, 0, sizeof(*session));
  449|     62|  session->proto = proto;
  450|     62|  session->type = type;
  451|     62|  if (addr_hash)
  ------------------
  |  Branch (451:7): [True: 0, False: 62]
  ------------------
  452|      0|    memcpy(&session->addr_hash, addr_hash, sizeof(session->addr_hash));
  453|     62|  else
  454|     62|    memset(&session->addr_hash, 0, sizeof(session->addr_hash));
  455|     62|  if (local_addr) {
  ------------------
  |  Branch (455:7): [True: 0, False: 62]
  ------------------
  456|      0|    coap_address_copy(&session->addr_info.local, local_addr);
  457|      0|#if COAP_CLIENT_SUPPORT
  458|      0|    coap_address_copy(&session->local_reconnect, local_addr);
  459|      0|#endif /* COAP_CLIENT_SUPPORT */
  460|     62|  } else {
  461|     62|    coap_address_init(&session->addr_info.local);
  462|     62|#if COAP_CLIENT_SUPPORT
  463|     62|    coap_address_init(&session->local_reconnect);
  464|     62|#endif /* COAP_CLIENT_SUPPORT */
  465|     62|  }
  466|     62|  if (remote_addr)
  ------------------
  |  Branch (466:7): [True: 62, False: 0]
  ------------------
  467|     62|    coap_address_copy(&session->addr_info.remote, remote_addr);
  468|      0|  else
  469|      0|    coap_address_init(&session->addr_info.remote);
  470|     62|  session->ifindex = ifindex;
  471|     62|  session->context = context;
  472|     62|#if COAP_CLIENT_SUPPORT
  473|     62|  if (type == COAP_SESSION_TYPE_CLIENT) {
  ------------------
  |  Branch (473:7): [True: 62, False: 0]
  ------------------
  474|     62|    session->client_initiated = 1;
  475|     62|  }
  476|     62|#endif /* COAP_CLIENT_SUPPORT */
  477|     62|#if COAP_SERVER_SUPPORT
  478|     62|  session->endpoint = endpoint;
  479|     62|  if (endpoint)
  ------------------
  |  Branch (479:7): [True: 0, False: 62]
  ------------------
  480|      0|    session->mtu = endpoint->default_mtu;
  481|     62|  else
  482|     62|#endif /* COAP_SERVER_SUPPORT */
  483|     62|    coap_session_set_mtu(session, COAP_DEFAULT_MTU);
  ------------------
  |  |   43|     62|#define COAP_DEFAULT_MTU       1152
  ------------------
  484|     62|  session->block_mode = context->block_mode;
  485|     62|#if COAP_Q_BLOCK_SUPPORT
  486|     62|  if (session->block_mode & COAP_BLOCK_FORCE_Q_BLOCK) {
  ------------------
  |  |   75|     62|#define COAP_BLOCK_FORCE_Q_BLOCK  0x200 /* force Q-Block method without support check */
  ------------------
  |  Branch (486:7): [True: 0, False: 62]
  ------------------
  487|      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]
  |  |  ------------------
  ------------------
  488|      0|  }
  489|     62|#endif
  490|     62|  if (proto == COAP_PROTO_DTLS) {
  ------------------
  |  Branch (490:7): [True: 0, False: 62]
  ------------------
  491|      0|    session->tls_overhead = 29;
  492|      0|    if (session->tls_overhead >= session->mtu) {
  ------------------
  |  Branch (492:9): [True: 0, False: 0]
  ------------------
  493|      0|      session->tls_overhead = session->mtu;
  494|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  495|      0|    }
  496|      0|  }
  497|     62|  session->rl_ticks_per_packet = context->rl_ticks_per_packet;
  498|     62|  session->ack_timeout = COAP_DEFAULT_ACK_TIMEOUT;
  ------------------
  |  |  697|     62|#define COAP_DEFAULT_ACK_TIMEOUT ((coap_fixed_point_t){2,0})
  ------------------
  499|     62|  session->ack_random_factor = COAP_DEFAULT_ACK_RANDOM_FACTOR;
  ------------------
  |  |  706|     62|#define COAP_DEFAULT_ACK_RANDOM_FACTOR ((coap_fixed_point_t){1,500})
  ------------------
  500|     62|  session->max_retransmit = COAP_DEFAULT_MAX_RETRANSMIT;
  ------------------
  |  |  714|     62|#define COAP_DEFAULT_MAX_RETRANSMIT  (4U)
  ------------------
  501|     62|  session->nstart = COAP_DEFAULT_NSTART;
  ------------------
  |  |  723|     62|#define COAP_DEFAULT_NSTART (1U)
  ------------------
  502|     62|  session->default_leisure = COAP_DEFAULT_DEFAULT_LEISURE;
  ------------------
  |  |  731|     62|#define COAP_DEFAULT_DEFAULT_LEISURE ((coap_fixed_point_t){5,0})
  ------------------
  503|     62|  session->probing_rate = COAP_DEFAULT_PROBING_RATE;
  ------------------
  |  |  739|     62|#define COAP_DEFAULT_PROBING_RATE (1U)
  ------------------
  504|     62|#if COAP_Q_BLOCK_SUPPORT
  505|     62|  session->max_payloads = COAP_DEFAULT_MAX_PAYLOADS;
  ------------------
  |  |  748|     62|#define COAP_DEFAULT_MAX_PAYLOADS (10U)
  ------------------
  506|     62|  session->non_max_retransmit = COAP_DEFAULT_NON_MAX_RETRANSMIT;
  ------------------
  |  |  757|     62|#define COAP_DEFAULT_NON_MAX_RETRANSMIT (4U)
  ------------------
  507|     62|  session->non_timeout = COAP_DEFAULT_NON_TIMEOUT;
  ------------------
  |  |  766|     62|#define COAP_DEFAULT_NON_TIMEOUT ((coap_fixed_point_t){2,0})
  ------------------
  508|     62|  session->non_receive_timeout = COAP_DEFAULT_NON_RECEIVE_TIMEOUT;
  ------------------
  |  |  775|     62|#define COAP_DEFAULT_NON_RECEIVE_TIMEOUT ((coap_fixed_point_t){4,0})
  ------------------
  509|     62|  coap_session_fix_non_probing_wait_base(session);
  510|     62|  coap_session_fix_non_partial_timeout(session);
  511|     62|#endif /* COAP_Q_BLOCK_SUPPORT */
  512|     62|  session->dtls_event = -1;
  513|     62|  session->last_ping_mid = COAP_INVALID_MID;
  ------------------
  |  |  187|     62|#define COAP_INVALID_MID -1
  ------------------
  514|     62|  session->last_ack_mid = COAP_INVALID_MID;
  ------------------
  |  |  187|     62|#define COAP_INVALID_MID -1
  ------------------
  515|     62|  session->last_con_mid = COAP_INVALID_MID;
  ------------------
  |  |  187|     62|#define COAP_INVALID_MID -1
  ------------------
  516|     62|  session->last_con_handler_res = COAP_RESPONSE_OK;
  517|     62|  session->max_token_size = context->max_token_size; /* RFC8974 */
  518|     62|  if (session->type != COAP_SESSION_TYPE_CLIENT)
  ------------------
  |  Branch (518:7): [True: 0, False: 62]
  ------------------
  519|      0|    session->max_token_checked = COAP_EXT_T_CHECKED;
  520|       |
  521|       |  /* Randomly initialize */
  522|       |  /* TCP/TLS have no notion of mid */
  523|     62|  if (COAP_PROTO_NOT_RELIABLE(session->proto))
  ------------------
  |  |   41|     62|#define COAP_PROTO_NOT_RELIABLE(p) ((p)==COAP_PROTO_UDP || (p)==COAP_PROTO_DTLS)
  |  |  ------------------
  |  |  |  Branch (41:37): [True: 62, False: 0]
  |  |  |  Branch (41:60): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  524|     62|    coap_prng_lkd((unsigned char *)&session->tx_mid, sizeof(session->tx_mid));
  525|     62|  coap_prng_lkd((unsigned char *)&session->tx_rtag, sizeof(session->tx_rtag));
  526|       |
  527|     62|  return session;
  528|     62|}
coap_session.c:coap_session_check_connect:
 1606|     62|coap_session_check_connect(coap_session_t *session) {
 1607|     62|  if (COAP_PROTO_NOT_RELIABLE(session->proto)) {
  ------------------
  |  |   41|     62|#define COAP_PROTO_NOT_RELIABLE(p) ((p)==COAP_PROTO_UDP || (p)==COAP_PROTO_DTLS)
  |  |  ------------------
  |  |  |  Branch (41:37): [True: 62, False: 0]
  |  |  |  Branch (41:60): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1608|     62|    session->sock.lfunc[COAP_LAYER_SESSION].l_establish(session);
 1609|     62|  }
 1610|     62|#if !COAP_DISABLE_TCP
 1611|     62|  if (COAP_PROTO_RELIABLE(session->proto)) {
  ------------------
  |  |   42|     62|#define COAP_PROTO_RELIABLE(p) ((p)==COAP_PROTO_TCP || (p)==COAP_PROTO_TLS || \
  |  |  ------------------
  |  |  |  Branch (42:33): [True: 0, False: 62]
  |  |  |  Branch (42:56): [True: 0, False: 62]
  |  |  ------------------
  |  |   43|     62|                                (p)==COAP_PROTO_WS || (p)==COAP_PROTO_WSS)
  |  |  ------------------
  |  |  |  Branch (43:33): [True: 0, False: 62]
  |  |  |  Branch (43:55): [True: 0, False: 62]
  |  |  ------------------
  ------------------
 1612|      0|    if (session->sock.flags & COAP_SOCKET_WANT_CONNECT) {
  ------------------
  |  |   81|      0|#define COAP_SOCKET_WANT_CONNECT 0x0080  /**< non blocking client socket is waiting for connect */
  ------------------
  |  Branch (1612:9): [True: 0, False: 0]
  ------------------
 1613|      0|      session->state = COAP_SESSION_STATE_CONNECTING;
 1614|      0|      if (session->client_initiated) {
  ------------------
  |  Branch (1614:11): [True: 0, False: 0]
  ------------------
 1615|      0|        session->doing_first = 1;
 1616|      0|      }
 1617|      0|    } else {
 1618|       |      /* Initial connect worked immediately */
 1619|      0|      session->sock.lfunc[COAP_LAYER_SESSION].l_establish(session);
 1620|      0|    }
 1621|      0|  }
 1622|     62|#endif /* !COAP_DISABLE_TCP */
 1623|     62|  coap_ticks(&session->last_rx_tx);
 1624|     62|}
coap_session.c:coap_session_create_client:
 1476|     62|                           coap_str_const_t *ws_host) {
 1477|     62|  coap_session_t *session = NULL;
 1478|     62|  int default_port = COAP_DEFAULT_PORT;
  ------------------
  |  |   39|     62|#define COAP_DEFAULT_PORT      5683 /* CoAP default UDP/TCP port */
  ------------------
 1479|       |
 1480|     62|  assert(server);
  ------------------
  |  Branch (1480:3): [True: 62, False: 0]
  ------------------
 1481|       |
 1482|     62|  switch (proto) {
 1483|     62|  case COAP_PROTO_UDP:
  ------------------
  |  Branch (1483:3): [True: 62, False: 0]
  ------------------
 1484|     62|    default_port = COAP_DEFAULT_PORT;
  ------------------
  |  |   39|     62|#define COAP_DEFAULT_PORT      5683 /* CoAP default UDP/TCP port */
  ------------------
 1485|     62|    break;
 1486|      0|  case COAP_PROTO_DTLS:
  ------------------
  |  Branch (1486:3): [True: 0, False: 62]
  ------------------
 1487|      0|    if (!coap_dtls_is_supported()) {
  ------------------
  |  Branch (1487:9): [True: 0, False: 0]
  ------------------
 1488|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1489|      0|      return NULL;
 1490|      0|    }
 1491|      0|    default_port = COAPS_DEFAULT_PORT;
  ------------------
  |  |   40|      0|#define COAPS_DEFAULT_PORT     5684 /* CoAP default UDP/TCP port for secure transmission */
  ------------------
 1492|      0|    break;
 1493|      0|  case COAP_PROTO_TCP:
  ------------------
  |  Branch (1493:3): [True: 0, False: 62]
  ------------------
 1494|      0|    if (!coap_tcp_is_supported()) {
  ------------------
  |  Branch (1494:9): [True: 0, False: 0]
  ------------------
 1495|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1496|      0|      return NULL;
 1497|      0|    }
 1498|      0|    default_port = COAP_DEFAULT_PORT;
  ------------------
  |  |   39|      0|#define COAP_DEFAULT_PORT      5683 /* CoAP default UDP/TCP port */
  ------------------
 1499|      0|    break;
 1500|      0|  case COAP_PROTO_TLS:
  ------------------
  |  Branch (1500:3): [True: 0, False: 62]
  ------------------
 1501|      0|    if (!coap_tls_is_supported()) {
  ------------------
  |  Branch (1501:9): [True: 0, False: 0]
  ------------------
 1502|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1503|      0|      return NULL;
 1504|      0|    }
 1505|      0|    default_port = COAPS_DEFAULT_PORT;
  ------------------
  |  |   40|      0|#define COAPS_DEFAULT_PORT     5684 /* CoAP default UDP/TCP port for secure transmission */
  ------------------
 1506|      0|    break;
 1507|      0|  case COAP_PROTO_WS:
  ------------------
  |  Branch (1507:3): [True: 0, False: 62]
  ------------------
 1508|      0|    if (!coap_ws_is_supported()) {
  ------------------
  |  Branch (1508:9): [True: 0, False: 0]
  ------------------
 1509|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1510|      0|      return NULL;
 1511|      0|    }
 1512|      0|    default_port = 80;
 1513|      0|    break;
 1514|      0|  case COAP_PROTO_WSS:
  ------------------
  |  Branch (1514:3): [True: 0, False: 62]
  ------------------
 1515|      0|    if (!coap_wss_is_supported()) {
  ------------------
  |  Branch (1515:9): [True: 0, False: 0]
  ------------------
 1516|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1517|      0|      return NULL;
 1518|      0|    }
 1519|      0|    default_port = 443;
 1520|      0|    break;
 1521|      0|  case COAP_PROTO_NONE:
  ------------------
  |  Branch (1521:3): [True: 0, False: 62]
  ------------------
 1522|      0|  case COAP_PROTO_LAST:
  ------------------
  |  Branch (1522:3): [True: 0, False: 62]
  ------------------
 1523|      0|  default:
  ------------------
  |  Branch (1523:3): [True: 0, False: 62]
  ------------------
 1524|      0|    assert(0);
  ------------------
  |  Branch (1524:5): [Folded, False: 0]
  ------------------
 1525|      0|    return NULL;
 1526|     62|  }
 1527|     62|  session = coap_make_session(proto, COAP_SESSION_TYPE_CLIENT, NULL,
 1528|     62|                              local_if, server, 0, ctx, NULL);
 1529|     62|  if (!session)
  ------------------
  |  Branch (1529:7): [True: 0, False: 62]
  ------------------
 1530|      0|    goto error;
 1531|       |
 1532|     62|  coap_session_reference_lkd(session);
 1533|     62|  session->sock.session = session;
 1534|     62|  memcpy(&session->sock.lfunc, coap_layers_coap[proto],
 1535|     62|         sizeof(session->sock.lfunc));
 1536|       |
 1537|     62|  session->app_data = app_data;
 1538|     62|  session->app_cb = app_data ? callback : NULL;
  ------------------
  |  Branch (1538:21): [True: 0, False: 62]
  ------------------
 1539|     62|#if COAP_WS_SUPPORT
 1540|     62|  if (ws_host) {
  ------------------
  |  Branch (1540:7): [True: 0, False: 62]
  ------------------
 1541|      0|    session->ws_host = coap_new_str_const(ws_host->s, ws_host->length);
 1542|      0|  }
 1543|       |#else /* ! COAP_WS_SUPPORT */
 1544|       |  (void)ws_host;
 1545|       |#endif /* ! COAP_WS_SUPPORT */
 1546|       |
 1547|     62|  if (COAP_PROTO_NOT_RELIABLE(proto)) {
  ------------------
  |  |   41|     62|#define COAP_PROTO_NOT_RELIABLE(p) ((p)==COAP_PROTO_UDP || (p)==COAP_PROTO_DTLS)
  |  |  ------------------
  |  |  |  Branch (41:37): [True: 62, False: 0]
  |  |  |  Branch (41:60): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1548|     62|    coap_session_t *s, *rtmp;
 1549|     62|    if (!coap_netif_dgrm_connect(session, local_if, server, default_port)) {
  ------------------
  |  Branch (1549:9): [True: 0, False: 62]
  ------------------
 1550|      0|      goto error;
 1551|      0|    }
 1552|       |    /* Check that this is not a duplicate 4-tuple */
 1553|     62|    SESSIONS_ITER_SAFE(ctx->sessions, s, rtmp) {
  ------------------
  |  |  945|     88|  for ((el) = (e); (el) && ((rtmp) = (el)->hh.next, 1); (el) = (rtmp))
  |  |  ------------------
  |  |  |  Branch (945:20): [True: 26, False: 62]
  |  |  |  Branch (945:28): [True: 26, False: 0]
  |  |  ------------------
  ------------------
 1554|     26|      if (COAP_PROTO_NOT_RELIABLE(s->proto) &&
  ------------------
  |  |   41|     52|#define COAP_PROTO_NOT_RELIABLE(p) ((p)==COAP_PROTO_UDP || (p)==COAP_PROTO_DTLS)
  |  |  ------------------
  |  |  |  Branch (41:37): [True: 26, False: 0]
  |  |  |  Branch (41:60): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1555|     26|          coap_address_equals(&session->addr_info.local,
  ------------------
  |  Branch (1555:11): [True: 0, False: 26]
  ------------------
 1556|     26|                              &s->addr_info.local) &&
 1557|      0|          coap_address_equals(&session->addr_info.remote,
  ------------------
  |  Branch (1557:11): [True: 0, False: 0]
  ------------------
 1558|      0|                              &s->addr_info.remote)) {
 1559|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1560|      0|                      coap_session_str(session), (void *)session);
 1561|      0|        goto error;
 1562|      0|      }
 1563|     26|    }
 1564|       |#ifdef WITH_CONTIKI
 1565|       |    session->sock.context = ctx;
 1566|       |#endif /* WITH_CONTIKI */
 1567|     62|#if !COAP_DISABLE_TCP
 1568|     62|  } 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]
  |  |  ------------------
  ------------------
 1569|      0|    if (!coap_netif_strm_connect1(session, local_if, server, default_port)) {
  ------------------
  |  Branch (1569:9): [True: 0, False: 0]
  ------------------
 1570|      0|      goto error;
 1571|      0|    }
 1572|      0|#endif /* !COAP_DISABLE_TCP */
 1573|      0|  }
 1574|       |
 1575|     62|  session->sock.session = session;
 1576|     62|#ifdef COAP_EPOLL_SUPPORT
 1577|     62|  coap_epoll_ctl_add(&session->sock,
 1578|     62|                     EPOLLIN |
 1579|     62|                     ((session->sock.flags & COAP_SOCKET_WANT_CONNECT) ?
  ------------------
  |  |   81|     62|#define COAP_SOCKET_WANT_CONNECT 0x0080  /**< non blocking client socket is waiting for connect */
  ------------------
  |  Branch (1579:23): [True: 0, False: 62]
  ------------------
 1580|     62|                      EPOLLOUT : 0),
 1581|     62|                     __func__);
 1582|     62|#endif /* COAP_EPOLL_SUPPORT */
 1583|       |
 1584|     62|  session->sock.flags |= COAP_SOCKET_NOT_EMPTY | COAP_SOCKET_WANT_READ;
  ------------------
  |  |   75|     62|#define COAP_SOCKET_NOT_EMPTY    0x0001  /**< the socket is not empty */
  ------------------
                session->sock.flags |= COAP_SOCKET_NOT_EMPTY | COAP_SOCKET_WANT_READ;
  ------------------
  |  |   78|     62|#define COAP_SOCKET_WANT_READ    0x0010  /**< non blocking socket is waiting for reading */
  ------------------
 1585|     62|  if (local_if)
  ------------------
  |  Branch (1585:7): [True: 0, False: 62]
  ------------------
 1586|      0|    session->sock.flags |= COAP_SOCKET_BOUND;
  ------------------
  |  |   76|      0|#define COAP_SOCKET_BOUND        0x0002  /**< the socket is bound */
  ------------------
 1587|     62|#if COAP_SERVER_SUPPORT
 1588|     62|  if (ctx->proxy_uri_resource)
  ------------------
  |  Branch (1588:7): [True: 26, False: 36]
  ------------------
 1589|     26|    session->proxy_session = 1;
 1590|     62|#endif /* COAP_SERVER_SUPPORT */
 1591|     62|  SESSIONS_ADD(ctx->sessions, session);
  ------------------
  |  |  936|     62|  HASH_ADD(hh, (e), addr_hash, sizeof((obj)->addr_hash), (obj))
  |  |  ------------------
  |  |  |  |  442|     62|  HASH_ADD_KEYPTR(hh, head, &((add)->fieldname), keylen_in, add)
  |  |  |  |  ------------------
  |  |  |  |  |  |  431|     62|#define HASH_ADD_KEYPTR(hh,head,keyptr,keylen_in,add)                            \
  |  |  |  |  |  |  432|     62|do {                                                                             \
  |  |  |  |  |  |  433|     62|  uint32_t _ha_hashv;                                                            \
  |  |  |  |  |  |  434|     62|  HASH_VALUE(keyptr, keylen_in, _ha_hashv);                                      \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  162|     62|#define HASH_VALUE(keyptr,keylen,hashv)                                          \
  |  |  |  |  |  |  |  |  163|     62|do {                                                                             \
  |  |  |  |  |  |  |  |  164|     62|  HASH_FUNCTION(keyptr, keylen, hashv);                                          \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  102|     62|#define HASH_FUNCTION(keyptr,keylen,hashv) HASH_JEN(keyptr, keylen, hashv)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  658|     62|#define HASH_JEN(key,keylen,hashv)                                               \
  |  |  |  |  |  |  |  |  |  |  |  |  659|     62|do {                                                                             \
  |  |  |  |  |  |  |  |  |  |  |  |  660|     62|  uint32_t _hj_i,_hj_j,_hj_k;                                                    \
  |  |  |  |  |  |  |  |  |  |  |  |  661|     62|  unsigned const char *_hj_key=(unsigned const char*)(key);                      \
  |  |  |  |  |  |  |  |  |  |  |  |  662|     62|  hashv = 0xfeedbeefu;                                                           \
  |  |  |  |  |  |  |  |  |  |  |  |  663|     62|  _hj_i = _hj_j = 0x9e3779b9u;                                                   \
  |  |  |  |  |  |  |  |  |  |  |  |  664|     62|  _hj_k = (uint32_t)(keylen);                                                    \
  |  |  |  |  |  |  |  |  |  |  |  |  665|    248|  while (_hj_k >= 12U) {                                                         \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (665:10): [True: 186, False: 62]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  666|    186|    _hj_i = (int64_t)_hj_i + (_hj_key[0] + ( (uint32_t)_hj_key[1] << 8 )         \
  |  |  |  |  |  |  |  |  |  |  |  |  667|    186|        + ( (uint32_t)_hj_key[2] << 16 )                                         \
  |  |  |  |  |  |  |  |  |  |  |  |  668|    186|        + ( (uint32_t)_hj_key[3] << 24 ) );                                      \
  |  |  |  |  |  |  |  |  |  |  |  |  669|    186|    _hj_j = (int64_t)_hj_j + (_hj_key[4] + ( (uint32_t)_hj_key[5] << 8 )         \
  |  |  |  |  |  |  |  |  |  |  |  |  670|    186|        + ( (uint32_t)_hj_key[6] << 16 )                                         \
  |  |  |  |  |  |  |  |  |  |  |  |  671|    186|        + ( (uint32_t)_hj_key[7] << 24 ) );                                      \
  |  |  |  |  |  |  |  |  |  |  |  |  672|    186|    hashv = (int64_t)hashv + (_hj_key[8] + ( (uint32_t)_hj_key[9] << 8 )         \
  |  |  |  |  |  |  |  |  |  |  |  |  673|    186|        + ( (uint32_t)_hj_key[10] << 16 )                                        \
  |  |  |  |  |  |  |  |  |  |  |  |  674|    186|        + ( (uint32_t)_hj_key[11] << 24 ) );                                     \
  |  |  |  |  |  |  |  |  |  |  |  |  675|    186|                                                                                 \
  |  |  |  |  |  |  |  |  |  |  |  |  676|    186|     HASH_JEN_MIX(_hj_i, _hj_j, hashv);                                          \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  645|    186|#define HASH_JEN_MIX(a,b,c)                                                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  646|    186|do {                                                                             \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  647|    186|  a = (int64_t)a - b; a = (int64_t)a - c; a ^= ( c >> 13 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  648|    186|  b = (int64_t)b - c; b = (int64_t)b - a; b ^= ( a << 8 );                       \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  649|    186|  c = (int64_t)c - a; c = (int64_t)c - b; c ^= ( b >> 13 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  650|    186|  a = (int64_t)a - b; a = (int64_t)a - c; a ^= ( c >> 12 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  651|    186|  b = (int64_t)b - c; b = (int64_t)b - a; b ^= ( a << 16 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  652|    186|  c = (int64_t)c - a; c = (int64_t)c - b; c ^= ( b >> 5 );                       \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  653|    186|  a = (int64_t)a - b; a = (int64_t)a - c; a ^= ( c >> 3 );                       \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  654|    186|  b = (int64_t)b - c; b = (int64_t)b - a; b ^= ( a << 10 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  655|    186|  c = (int64_t)c - a; c = (int64_t)c - b; c ^= ( b >> 15 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  656|    186|} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (656:10): [Folded, False: 186]
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  677|    186|                                                                                 \
  |  |  |  |  |  |  |  |  |  |  |  |  678|    186|     _hj_key += 12;                                                              \
  |  |  |  |  |  |  |  |  |  |  |  |  679|    186|     _hj_k -= 12U;                                                               \
  |  |  |  |  |  |  |  |  |  |  |  |  680|    186|  }                                                                              \
  |  |  |  |  |  |  |  |  |  |  |  |  681|     62|  hashv += (uint32_t)(keylen);                                                   \
  |  |  |  |  |  |  |  |  |  |  |  |  682|     62|  switch ( _hj_k ) {                                                             \
  |  |  |  |  |  |  |  |  |  |  |  |  683|      0|    case 11: hashv = (int64_t)hashv + ( (uint32_t)_hj_key[10] << 24 ); /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (683:5): [True: 0, False: 62]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  684|      0|    case 10: hashv = (int64_t)hashv + ( (uint32_t)_hj_key[9] << 16 );  /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (684:5): [True: 0, False: 62]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  685|      0|    case 9:  hashv = (int64_t)hashv + ( (uint32_t)_hj_key[8] << 8 );   /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (685:5): [True: 0, False: 62]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  686|      0|    case 8:  _hj_j = (int64_t)_hj_j + ( (uint32_t)_hj_key[7] << 24 );  /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (686:5): [True: 0, False: 62]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  687|      0|    case 7:  _hj_j = (int64_t)_hj_j + ( (uint32_t)_hj_key[6] << 16 );  /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (687:5): [True: 0, False: 62]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  688|      0|    case 6:  _hj_j = (int64_t)_hj_j + ( (uint32_t)_hj_key[5] << 8 );   /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (688:5): [True: 0, False: 62]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  689|      0|    case 5:  _hj_j = (int64_t)_hj_j + _hj_key[4];                      /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (689:5): [True: 0, False: 62]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  690|     62|    case 4:  _hj_i = (int64_t)_hj_i + ( (uint32_t)_hj_key[3] << 24 );  /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (690:5): [True: 62, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  691|     62|    case 3:  _hj_i = (int64_t)_hj_i + ( (uint32_t)_hj_key[2] << 16 );  /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (691:5): [True: 0, False: 62]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  692|     62|    case 2:  _hj_i = (int64_t)_hj_i + ( (uint32_t)_hj_key[1] << 8 );   /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (692:5): [True: 0, False: 62]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  693|     62|    case 1:  _hj_i = (int64_t)_hj_i + _hj_key[0];                      /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (693:5): [True: 0, False: 62]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  694|     62|    default: ;                                                                   \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (694:5): [True: 0, False: 62]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  695|     62|  }                                                                              \
  |  |  |  |  |  |  |  |  |  |  |  |  696|     62|  HASH_JEN_MIX(_hj_i, _hj_j, hashv);                                             \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  645|     62|#define HASH_JEN_MIX(a,b,c)                                                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  646|     62|do {                                                                             \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  647|     62|  a = (int64_t)a - b; a = (int64_t)a - c; a ^= ( c >> 13 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  648|     62|  b = (int64_t)b - c; b = (int64_t)b - a; b ^= ( a << 8 );                       \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  649|     62|  c = (int64_t)c - a; c = (int64_t)c - b; c ^= ( b >> 13 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  650|     62|  a = (int64_t)a - b; a = (int64_t)a - c; a ^= ( c >> 12 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  651|     62|  b = (int64_t)b - c; b = (int64_t)b - a; b ^= ( a << 16 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  652|     62|  c = (int64_t)c - a; c = (int64_t)c - b; c ^= ( b >> 5 );                       \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  653|     62|  a = (int64_t)a - b; a = (int64_t)a - c; a ^= ( c >> 3 );                       \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  654|     62|  b = (int64_t)b - c; b = (int64_t)b - a; b ^= ( a << 10 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  655|     62|  c = (int64_t)c - a; c = (int64_t)c - b; c ^= ( b >> 15 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  656|     62|} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (656:10): [Folded, False: 62]
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  697|     62|} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (697:10): [Folded, False: 62]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  165|     62|} while (0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (165:10): [Folded, False: 62]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  435|     62|  HASH_ADD_KEYPTR_BYHASHVALUE(hh, head, keyptr, keylen_in, _ha_hashv, add);      \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  410|     62|#define HASH_ADD_KEYPTR_BYHASHVALUE(hh,head,keyptr,keylen_in,hashval,add)        \
  |  |  |  |  |  |  |  |  411|     62|do {                                                                             \
  |  |  |  |  |  |  |  |  412|     62|  IF_HASH_NONFATAL_OOM( int _ha_oomed = 0; )                                     \
  |  |  |  |  |  |  |  |  413|     62|  (add)->hh.hashv = (hashval);                                                   \
  |  |  |  |  |  |  |  |  414|     62|  (add)->hh.key = (const void*) (keyptr);                                        \
  |  |  |  |  |  |  |  |  415|     62|  (add)->hh.keylen = (uint32_t) (keylen_in);                                     \
  |  |  |  |  |  |  |  |  416|     62|  if (!(head)) {                                                                 \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (416:7): [True: 36, False: 26]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  417|     36|    (add)->hh.next = NULL;                                                       \
  |  |  |  |  |  |  |  |  418|     36|    (add)->hh.prev = NULL;                                                       \
  |  |  |  |  |  |  |  |  419|     36|    HASH_MAKE_TABLE(hh, add, _ha_oomed);                                         \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  226|     36|#define HASH_MAKE_TABLE(hh,head,oomed)                                           \
  |  |  |  |  |  |  |  |  |  |  227|     36|do {                                                                             \
  |  |  |  |  |  |  |  |  |  |  228|     36|  (head)->hh.tbl = (UT_hash_table*)uthash_malloc(sizeof(UT_hash_table));         \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   89|     36|#define uthash_malloc(sz) malloc(sz)      /* malloc fcn                      */
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  229|     36|  if (!(head)->hh.tbl) {                                                         \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (229:7): [True: 0, False: 36]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  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|     36|  } else {                                                                       \
  |  |  |  |  |  |  |  |  |  |  232|     36|    uthash_bzero((head)->hh.tbl, sizeof(UT_hash_table));                         \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   95|     36|#define uthash_bzero(a,n) memset(a,'\0',n)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  233|     36|    (head)->hh.tbl->tail = &((head)->hh);                                        \
  |  |  |  |  |  |  |  |  |  |  234|     36|    (head)->hh.tbl->num_buckets = HASH_INITIAL_NUM_BUCKETS;                      \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  143|     36|#define HASH_INITIAL_NUM_BUCKETS 32U     /* initial number of buckets        */
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  235|     36|    (head)->hh.tbl->log2_num_buckets = HASH_INITIAL_NUM_BUCKETS_LOG2;            \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  144|     36|#define HASH_INITIAL_NUM_BUCKETS_LOG2 5U /* lg2 of initial number of buckets */
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  236|     36|    (head)->hh.tbl->hho = (char*)(&(head)->hh) - (char*)(head);                  \
  |  |  |  |  |  |  |  |  |  |  237|     36|    (head)->hh.tbl->buckets = (UT_hash_bucket*)uthash_malloc(                    \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   89|     36|#define uthash_malloc(sz) malloc(sz)      /* malloc fcn                      */
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  238|     36|        HASH_INITIAL_NUM_BUCKETS * sizeof(struct UT_hash_bucket));               \
  |  |  |  |  |  |  |  |  |  |  239|     36|    (head)->hh.tbl->signature = HASH_SIGNATURE;                                  \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  | 1101|     36|#define HASH_SIGNATURE 0xa0111fe1u
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  240|     36|    if (!(head)->hh.tbl->buckets) {                                              \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (240:9): [True: 0, False: 36]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  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|     36|    } else {                                                                     \
  |  |  |  |  |  |  |  |  |  |  244|     36|      uthash_bzero((head)->hh.tbl->buckets,                                      \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   95|     36|#define uthash_bzero(a,n) memset(a,'\0',n)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  245|     36|          HASH_INITIAL_NUM_BUCKETS * sizeof(struct UT_hash_bucket));             \
  |  |  |  |  |  |  |  |  |  |  246|     36|      HASH_BLOOM_MAKE((head)->hh.tbl, oomed);                                    \
  |  |  |  |  |  |  |  |  |  |  247|     36|      IF_HASH_NONFATAL_OOM(                                                      \
  |  |  |  |  |  |  |  |  |  |  248|     36|        if (oomed) {                                                             \
  |  |  |  |  |  |  |  |  |  |  249|     36|          uthash_free((head)->hh.tbl->buckets,                                   \
  |  |  |  |  |  |  |  |  |  |  250|     36|              HASH_INITIAL_NUM_BUCKETS*sizeof(struct UT_hash_bucket));           \
  |  |  |  |  |  |  |  |  |  |  251|     36|          uthash_free((head)->hh.tbl, sizeof(UT_hash_table));                    \
  |  |  |  |  |  |  |  |  |  |  252|     36|        }                                                                        \
  |  |  |  |  |  |  |  |  |  |  253|     36|      )                                                                          \
  |  |  |  |  |  |  |  |  |  |  254|     36|    }                                                                            \
  |  |  |  |  |  |  |  |  |  |  255|     36|  }                                                                              \
  |  |  |  |  |  |  |  |  |  |  256|     36|} while (0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (256:10): [Folded, False: 36]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  420|     36|    IF_HASH_NONFATAL_OOM( if (!_ha_oomed) { )                                    \
  |  |  |  |  |  |  |  |  421|     36|      (head) = (add);                                                            \
  |  |  |  |  |  |  |  |  422|     36|    IF_HASH_NONFATAL_OOM( } )                                                    \
  |  |  |  |  |  |  |  |  423|     36|  } else {                                                                       \
  |  |  |  |  |  |  |  |  424|     26|    (add)->hh.tbl = (head)->hh.tbl;                                              \
  |  |  |  |  |  |  |  |  425|     26|    HASH_APPEND_LIST(hh, head, add);                                             \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  292|     26|#define HASH_APPEND_LIST(hh, head, add)                                          \
  |  |  |  |  |  |  |  |  |  |  293|     26|do {                                                                             \
  |  |  |  |  |  |  |  |  |  |  294|     26|  (add)->hh.next = NULL;                                                         \
  |  |  |  |  |  |  |  |  |  |  295|     26|  (add)->hh.prev = ELMT_FROM_HH((head)->hh.tbl, (head)->hh.tbl->tail);           \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  148|     26|#define ELMT_FROM_HH(tbl,hhp) ((void*)(((char*)(hhp)) - ((tbl)->hho)))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  296|     26|  (head)->hh.tbl->tail->next = (add);                                            \
  |  |  |  |  |  |  |  |  |  |  297|     26|  (head)->hh.tbl->tail = &((add)->hh);                                           \
  |  |  |  |  |  |  |  |  |  |  298|     26|} while (0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (298:10): [Folded, False: 26]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  426|     26|  }                                                                              \
  |  |  |  |  |  |  |  |  427|     62|  HASH_ADD_TO_TABLE(hh, head, keyptr, keylen_in, hashval, add, _ha_oomed);       \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  351|     62|#define HASH_ADD_TO_TABLE(hh,head,keyptr,keylen_in,hashval,add,oomed)            \
  |  |  |  |  |  |  |  |  |  |  352|     62|do {                                                                             \
  |  |  |  |  |  |  |  |  |  |  353|     62|  uint32_t _ha_bkt;                                                              \
  |  |  |  |  |  |  |  |  |  |  354|     62|  (head)->hh.tbl->num_items++;                                                   \
  |  |  |  |  |  |  |  |  |  |  355|     62|  HASH_TO_BKT(hashval, (head)->hh.tbl->num_buckets, _ha_bkt);                    \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  444|     62|#define HASH_TO_BKT(hashv,num_bkts,bkt)                                          \
  |  |  |  |  |  |  |  |  |  |  |  |  445|     62|do {                                                                             \
  |  |  |  |  |  |  |  |  |  |  |  |  446|     62|  bkt = ((hashv) & ((num_bkts) - 1U));                                           \
  |  |  |  |  |  |  |  |  |  |  |  |  447|     62|} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (447:10): [Folded, False: 62]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  356|     62|  HASH_ADD_TO_BKT((head)->hh.tbl->buckets[_ha_bkt], hh, &(add)->hh, oomed);      \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  778|     62|#define HASH_ADD_TO_BKT(head,hh,addhh,oomed)                                     \
  |  |  |  |  |  |  |  |  |  |  |  |  779|     62|do {                                                                             \
  |  |  |  |  |  |  |  |  |  |  |  |  780|     62|  UT_hash_bucket *_ha_head = &(head);                                            \
  |  |  |  |  |  |  |  |  |  |  |  |  781|     62|  _ha_head->count++;                                                             \
  |  |  |  |  |  |  |  |  |  |  |  |  782|     62|  (addhh)->hh_next = _ha_head->hh_head;                                          \
  |  |  |  |  |  |  |  |  |  |  |  |  783|     62|  (addhh)->hh_prev = NULL;                                                       \
  |  |  |  |  |  |  |  |  |  |  |  |  784|     62|  if (_ha_head->hh_head != NULL) {                                               \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (784:7): [True: 26, False: 36]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  785|     26|    _ha_head->hh_head->hh_prev = (addhh);                                        \
  |  |  |  |  |  |  |  |  |  |  |  |  786|     26|  }                                                                              \
  |  |  |  |  |  |  |  |  |  |  |  |  787|     62|  _ha_head->hh_head = (addhh);                                                   \
  |  |  |  |  |  |  |  |  |  |  |  |  788|     62|  if ((_ha_head->count >= ((_ha_head->expand_mult + 1U) * HASH_BKT_CAPACITY_THRESH)) \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  145|     62|#define HASH_BKT_CAPACITY_THRESH 10U     /* expand when bucket count reaches */
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (788:7): [True: 0, False: 62]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  789|     62|      && !(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|     62|} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (797:10): [Folded, False: 62]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  357|     62|  HASH_BLOOM_ADD((head)->hh.tbl, hashval);                                       \
  |  |  |  |  |  |  |  |  |  |  358|     62|  HASH_EMIT_KEY(hh, head, keyptr, keylen_in);                                    \
  |  |  |  |  |  |  |  |  |  |  359|     62|} while (0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (359:10): [Folded, False: 62]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  428|     62|  HASH_FSCK(hh, head, "HASH_ADD_KEYPTR_BYHASHVALUE");                            \
  |  |  |  |  |  |  |  |  429|     62|} while (0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (429:10): [Folded, False: 62]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  436|     62|} while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (436:10): [Folded, False: 62]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1592|     62|  return session;
 1593|       |
 1594|      0|error:
 1595|       |  /*
 1596|       |   * Need to add in the session as coap_session_release_lkd()
 1597|       |   * will call SESSIONS_DELETE in coap_session_free().
 1598|       |   */
 1599|      0|  if (session)
  ------------------
  |  Branch (1599:7): [True: 0, False: 0]
  ------------------
 1600|      0|    SESSIONS_ADD(ctx->sessions, session);
  ------------------
  |  |  936|      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]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1601|      0|  coap_session_release_lkd(session);
 1602|       |  return NULL;
 1603|      0|}

coap_new_string:
   21|     62|coap_new_string(size_t size) {
   22|     62|  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|     62|  if (size > SIZE_MAX - sizeof(coap_str_bin_union_t) - 1 - 8) {
  ------------------
  |  Branch (31:7): [True: 0, False: 62]
  ------------------
   32|      0|    return NULL;
   33|      0|  }
   34|       |
   35|     62|  s = (coap_string_t *)coap_malloc_type(COAP_STRING,
   36|     62|                                        sizeof(coap_str_bin_union_t) + size + 1);
   37|     62|  if (!s) {
  ------------------
  |  Branch (37:7): [True: 0, False: 62]
  ------------------
   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|     62|  memset(s, 0, sizeof(coap_str_bin_union_t));
   43|     62|  s->s = ((unsigned char *)s) + sizeof(coap_str_bin_union_t);
   44|     62|  s->s[size] = '\000';
   45|     62|  s->length = size;
   46|     62|  return s;
   47|     62|}
coap_new_str_const:
   55|     36|coap_new_str_const(const uint8_t *data, size_t size) {
   56|     36|  coap_string_t *s = coap_new_string(size);
   57|     36|  if (!s)
  ------------------
  |  Branch (57:7): [True: 0, False: 36]
  ------------------
   58|      0|    return NULL;
   59|     36|  memcpy(s->s, data, size);
   60|     36|  s->length = size;
   61|     36|  return (coap_str_const_t *)s;
   62|     36|}
coap_delete_str_const:
   65|    160|coap_delete_str_const(coap_str_const_t *s) {
   66|    160|  coap_free_type(COAP_STRING, s);
   67|    160|}
coap_delete_binary:
  114|     98|coap_delete_binary(coap_binary_t *s) {
  115|     98|  coap_free_type(COAP_STRING, s);
  116|     98|}
coap_new_bin_const:
  119|     26|coap_new_bin_const(const uint8_t *data, size_t size) {
  120|     26|  coap_string_t *s = coap_new_string(size);
  121|     26|  if (!s)
  ------------------
  |  Branch (121:7): [True: 0, False: 26]
  ------------------
  122|      0|    return NULL;
  123|     26|  if (data)
  ------------------
  |  Branch (123:7): [True: 26, False: 0]
  ------------------
  124|     26|    memcpy(s->s, data, size);
  125|     26|  s->length = size;
  126|     26|  return (coap_bin_const_t *)s;
  127|     26|}
coap_delete_bin_const:
  130|    408|coap_delete_bin_const(coap_bin_const_t *s) {
  131|    408|  coap_free_type(COAP_STRING, s);
  132|    408|}

coap_persist_track_funcs:
   47|     36|                         void *user_data) {
   48|     36|  context->observe_added_cb = observe_added;
   49|     36|  context->observe_deleted_cb = observe_deleted;
   50|     36|  context->observe_user_data = user_data;
   51|     36|  context->observe_save_freq = save_freq ? save_freq : 1;
  ------------------
  |  Branch (51:32): [True: 0, False: 36]
  ------------------
   52|     36|  context->track_observe_value_cb = track_observe_value;
   53|     36|  context->dyn_resource_added_cb = dyn_resource_added;
   54|     36|  context->resource_deleted_cb = resource_deleted;
   55|     36|}
coap_persist_cleanup:
 1241|     36|coap_persist_cleanup(coap_context_t *context) {
 1242|     36|  coap_delete_bin_const(context->dyn_resource_save_file);
 1243|     36|  coap_delete_bin_const(context->obs_cnt_save_file);
 1244|     36|  coap_delete_bin_const(context->observe_save_file);
 1245|     36|  context->dyn_resource_save_file = NULL;
 1246|     36|  context->obs_cnt_save_file = NULL;
 1247|     36|  context->observe_save_file = NULL;
 1248|       |
 1249|       |  /* Close down any tracking */
 1250|     36|  coap_persist_track_funcs(context, NULL, NULL, NULL, NULL,
 1251|     36|                           NULL, 0, NULL);
 1252|     36|}

coap_clock_init:
   68|     36|coap_clock_init(void) {
   69|     36|#ifdef COAP_CLOCK
   70|     36|  struct timespec tv;
   71|     36|  clock_gettime(COAP_CLOCK, &tv);
  ------------------
  |  |   43|     36|#define COAP_CLOCK CLOCK_REALTIME
  ------------------
   72|       |#else /* _POSIX_TIMERS */
   73|       |  struct timeval tv;
   74|       |  gettimeofday(&tv, NULL);
   75|       |#endif /* not _POSIX_TIMERS */
   76|       |
   77|     36|  coap_clock_offset = tv.tv_sec;
   78|     36|}
coap_ticks:
   90|    317|coap_ticks(coap_tick_t *t) {
   91|    317|  coap_tick_t tmp;
   92|       |
   93|    317|#ifdef COAP_CLOCK
   94|    317|  struct timespec tv;
   95|    317|  clock_gettime(COAP_CLOCK, &tv);
  ------------------
  |  |   43|    317|#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|    317|  tmp = SHR_FP(tv.tv_nsec * Q(FRAC, (COAP_TICKS_PER_SECOND/1000000000.0)), FRAC);
  ------------------
  |  |   87|    317|#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|    317|  *t = tmp + (tv.tv_sec - coap_clock_offset) * COAP_TICKS_PER_SECOND;
  ------------------
  |  |  164|    317|#define COAP_TICKS_PER_SECOND ((coap_tick_t)(1000U))
  ------------------
  120|    317|}
coap_ticks_to_rt_us:
  128|     36|coap_ticks_to_rt_us(coap_tick_t t) {
  129|     36|  return (uint64_t)coap_clock_offset * 1000000 + (uint64_t)t * 1000000 / COAP_TICKS_PER_SECOND;
  ------------------
  |  |  164|     36|#define COAP_TICKS_PER_SECOND ((coap_tick_t)(1000U))
  ------------------
  130|     36|}

coap_split_proxy_uri:
  351|     10|coap_split_proxy_uri(const uint8_t *str_var, size_t len, coap_uri_t *uri) {
  352|     10|  return coap_split_uri_sub(str_var, len, uri, COAP_URI_CHECK_PROXY);
  353|     10|}
coap_uri_into_optlist:
  375|      2|                      coap_optlist_t **optlist_chain, int create_port_host_opt) {
  376|       |  return coap_uri_into_optlist_abbrev(uri, dst, optlist_chain, create_port_host_opt, NULL, 0);
  377|      2|}
coap_uri_into_optlist_abbrev:
  382|      2|                             coap_upa_abbrev_t *mapping, uint32_t count) {
  383|      2|  if (create_port_host_opt && !coap_host_is_unix_domain(&uri->host)) {
  ------------------
  |  Branch (383:7): [True: 0, False: 2]
  |  Branch (383:31): [True: 0, False: 0]
  ------------------
  384|      0|    int add_option = 0;
  385|       |
  386|      0|    if (dst && uri->host.length) {
  ------------------
  |  Branch (386:9): [True: 0, False: 0]
  |  Branch (386:16): [True: 0, False: 0]
  ------------------
  387|      0|#if !defined(WITH_LWIP) && !defined(WITH_CONTIKI)
  388|      0|      char addr[INET6_ADDRSTRLEN];
  389|       |#else /* WITH_LWIP || WITH_CONTIKI */
  390|       |      char addr[40];
  391|       |#endif /* WITH_LWIP || WITH_CONTIKI */
  392|      0|      coap_optlist_t *optlist;
  393|       |
  394|       |      /* Add in Uri-Host if not match (need to strip off %iface) */
  395|      0|      size_t uri_host_len = uri->host.length;
  396|      0|      const uint8_t *cp = uri->host.s;
  397|       |
  398|       |      /* Unfortunately not null terminated */
  399|      0|      for (size_t i = 0; i < uri_host_len; i++) {
  ------------------
  |  Branch (399:26): [True: 0, False: 0]
  ------------------
  400|      0|        if (cp[i] == '%') {
  ------------------
  |  Branch (400:13): [True: 0, False: 0]
  ------------------
  401|       |          /* %iface specified in host name */
  402|      0|          uri_host_len = i;
  403|      0|          break;
  404|      0|        }
  405|      0|      }
  406|       |
  407|      0|      if (coap_print_ip_addr(dst, addr, sizeof(addr)) &&
  ------------------
  |  Branch (407:11): [True: 0, False: 0]
  ------------------
  408|      0|          (strlen(addr) != uri_host_len ||
  ------------------
  |  Branch (408:12): [True: 0, False: 0]
  ------------------
  409|      0|           strncasecmp(addr, (const char *)uri->host.s, uri_host_len) != 0)) {
  ------------------
  |  Branch (409:12): [True: 0, False: 0]
  ------------------
  410|       |        /* add Uri-Host */
  411|      0|        optlist = coap_new_optlist(COAP_OPTION_URI_HOST, uri_host_len,
  412|      0|                                   uri->host.s);
  413|      0|        if (!coap_host_is_unix_domain(&uri->host)) {
  ------------------
  |  Branch (413:13): [True: 0, False: 0]
  ------------------
  414|      0|          coap_replace_percents(optlist);
  415|      0|          coap_replace_upper_lower(optlist);
  416|      0|        }
  417|      0|        if (!coap_insert_optlist(optlist_chain, optlist)) {
  ------------------
  |  Branch (417:13): [True: 0, False: 0]
  ------------------
  418|      0|          return 0;
  419|      0|        }
  420|      0|      }
  421|      0|    }
  422|       |    /* Add in UriPort if not default */
  423|      0|    switch ((int)uri->scheme) {
  424|      0|    case COAP_URI_SCHEME_HTTP:
  ------------------
  |  Branch (424:5): [True: 0, False: 0]
  ------------------
  425|      0|    case COAP_URI_SCHEME_COAP_WS:
  ------------------
  |  Branch (425:5): [True: 0, False: 0]
  ------------------
  426|      0|      if (uri->port != 80)
  ------------------
  |  Branch (426:11): [True: 0, False: 0]
  ------------------
  427|      0|        add_option = 1;
  428|      0|      break;
  429|      0|    case COAP_URI_SCHEME_HTTPS:
  ------------------
  |  Branch (429:5): [True: 0, False: 0]
  ------------------
  430|      0|    case COAP_URI_SCHEME_COAPS_WS:
  ------------------
  |  Branch (430:5): [True: 0, False: 0]
  ------------------
  431|      0|      if (uri->port != 443)
  ------------------
  |  Branch (431:11): [True: 0, False: 0]
  ------------------
  432|      0|        add_option = 1;
  433|      0|      break;
  434|      0|    default:
  ------------------
  |  Branch (434:5): [True: 0, False: 0]
  ------------------
  435|      0|      if (uri->port != (coap_uri_scheme_is_secure(uri) ? COAPS_DEFAULT_PORT :
  ------------------
  |  |   40|      0|#define COAPS_DEFAULT_PORT     5684 /* CoAP default UDP/TCP port for secure transmission */
  ------------------
  |  Branch (435:11): [True: 0, False: 0]
  |  Branch (435:25): [True: 0, False: 0]
  ------------------
  436|      0|                        COAP_DEFAULT_PORT))
  ------------------
  |  |   39|      0|#define COAP_DEFAULT_PORT      5683 /* CoAP default UDP/TCP port */
  ------------------
  437|      0|        add_option = 1;
  438|      0|      break;
  439|      0|    }
  440|      0|    if (add_option) {
  ------------------
  |  Branch (440:9): [True: 0, False: 0]
  ------------------
  441|      0|      uint8_t tbuf[4];
  442|       |
  443|      0|      coap_insert_optlist(optlist_chain,
  444|      0|                          coap_new_optlist(COAP_OPTION_URI_PORT,
  445|      0|                                           coap_encode_var_safe(tbuf, 4,
  446|      0|                                                                (uri->port & 0xffff)),
  447|      0|                                           tbuf));
  448|      0|    }
  449|      0|  }
  450|       |
  451|      2|  if (uri->path.length) {
  ------------------
  |  Branch (451:7): [True: 2, False: 0]
  ------------------
  452|      2|    if (!coap_path_into_optlist_abbrev(uri->path.s, uri->path.length, COAP_OPTION_URI_PATH,
  ------------------
  |  Branch (452:9): [True: 0, False: 2]
  ------------------
  453|      2|                                       optlist_chain, mapping, count))
  454|      0|      return 0;
  455|      2|  }
  456|       |
  457|      2|  if (uri->query.length) {
  ------------------
  |  Branch (457:7): [True: 0, False: 2]
  ------------------
  458|      0|    if (!coap_query_into_optlist(uri->query.s, uri->query.length, COAP_OPTION_URI_QUERY,
  ------------------
  |  Branch (458:9): [True: 0, False: 0]
  ------------------
  459|      0|                                 optlist_chain))
  460|      0|      return 0;
  461|      0|  }
  462|      2|  return 1;
  463|      2|}
coap_host_is_unix_domain:
  466|     26|coap_host_is_unix_domain(const coap_str_const_t *host) {
  467|     26|  if (host->length >= 3 && host->s[0] == '%' &&
  ------------------
  |  Branch (467:7): [True: 26, False: 0]
  |  Branch (467:28): [True: 0, False: 26]
  ------------------
  468|      0|      host->s[1] == '2' &&
  ------------------
  |  Branch (468:7): [True: 0, False: 0]
  ------------------
  469|      0|      (host->s[2] == 'F' || host->s[2] == 'f')) {
  ------------------
  |  Branch (469:8): [True: 0, False: 0]
  |  Branch (469:29): [True: 0, False: 0]
  ------------------
  470|      0|    return 1;
  471|      0|  }
  472|     26|  if (host->length >= 1 && host->s[0] == '/')
  ------------------
  |  Branch (472:7): [True: 26, False: 0]
  |  Branch (472:28): [True: 0, False: 26]
  ------------------
  473|      0|    return 1;
  474|     26|  return 0;
  475|     26|}
coap_host_is_llc:
  478|     26|coap_host_is_llc(const coap_str_const_t *host) {
  479|     26|#if COAP_AF_LLC_SUPPORT
  480|     26|  size_t length;
  481|     26|  const uint8_t *s = NULL;
  482|     26|  int i = 0;
  483|       |
  484|     26|  length = host->length;
  485|     26|  if (length != LLC_HOST_LEN)
  ------------------
  |  |  169|     26|#define LLC_HOST_LEN (4 + HW_ADDRSTRLEN + 4)
  |  |  ------------------
  |  |  |  |  167|     26|#define HW_ADDRSTRLEN 17
  |  |  ------------------
  ------------------
  |  Branch (485:7): [True: 26, False: 0]
  ------------------
  486|     26|    return 0;
  487|       |
  488|      0|  s = host->s;
  489|       |
  490|      0|  if (strncmp((const char *)s, "llc[", 4) != 0)
  ------------------
  |  Branch (490:7): [True: 0, False: 0]
  ------------------
  491|      0|    return 0;
  492|       |
  493|      0|  length -= 4;
  494|      0|  s += 4;
  495|       |
  496|      0|  while (length) {
  ------------------
  |  Branch (496:10): [True: 0, False: 0]
  ------------------
  497|      0|    if (!isxdigit(s[0]) || !isxdigit(s[1]))
  ------------------
  |  Branch (497:9): [True: 0, False: 0]
  |  Branch (497:28): [True: 0, False: 0]
  ------------------
  498|      0|      return 0;
  499|       |
  500|      0|    length -= 2;
  501|      0|    s += 2;
  502|       |
  503|      0|    i++;
  504|       |
  505|      0|    if (length <= 0 || i >= 6)
  ------------------
  |  Branch (505:9): [True: 0, False: 0]
  |  Branch (505:24): [True: 0, False: 0]
  ------------------
  506|      0|      break;
  507|       |
  508|      0|    if (s[0] != ':')
  ------------------
  |  Branch (508:9): [True: 0, False: 0]
  ------------------
  509|      0|      return 0;
  510|       |
  511|      0|    length--;
  512|      0|    s++;
  513|      0|  }
  514|       |
  515|      0|  if (s[0] != ']' || s[1] != ':' || !isxdigit(s[2]) || !isxdigit(s[3]))
  ------------------
  |  Branch (515:7): [True: 0, False: 0]
  |  Branch (515:22): [True: 0, False: 0]
  |  Branch (515:37): [True: 0, False: 0]
  |  Branch (515:56): [True: 0, False: 0]
  ------------------
  516|      0|    return 0;
  517|       |
  518|      0|  return 1;
  519|       |#else /* COAP_AF_LLC_SUPPORT */
  520|       |  (void)host;
  521|       |  return 0;
  522|       |#endif /* COAP_AF_LLC_SUPPORT */
  523|      0|}
coap_check_dots:
  668|     94|coap_check_dots(const uint8_t *s, size_t len) {
  669|     94|  uint8_t p;
  670|       |
  671|     94|  if (!len)
  ------------------
  |  Branch (671:7): [True: 6, False: 88]
  ------------------
  672|      6|    return 0;
  673|       |
  674|     88|  p = *s;
  675|       |
  676|       |  /* Check 'first' char */
  677|     88|  if (p == '%' && len >=3) {
  ------------------
  |  Branch (677:7): [True: 9, False: 79]
  |  Branch (677:19): [True: 9, False: 0]
  ------------------
  678|      9|    if (s[1] == '2' && (s[2] == 'E' || s[2] == 'e')) {
  ------------------
  |  Branch (678:9): [True: 1, False: 8]
  |  Branch (678:25): [True: 0, False: 1]
  |  Branch (678:40): [True: 1, False: 0]
  ------------------
  679|      1|      s += 2;
  680|      1|      len -= 2;
  681|      1|    }
  682|      9|    p = '.';
  683|      9|  }
  684|     88|  if (p != '.')
  ------------------
  |  Branch (684:7): [True: 76, False: 12]
  ------------------
  685|     76|    return 0;
  686|     12|  if (len == 1)
  ------------------
  |  Branch (686:7): [True: 2, False: 10]
  ------------------
  687|      2|    return 1;
  688|       |
  689|       |  /* Check 'second' char, first is '.' */
  690|     10|  s++;
  691|     10|  len--;
  692|     10|  assert(len);
  ------------------
  |  Branch (692:3): [True: 10, False: 0]
  ------------------
  693|     10|  p = *s;
  694|     10|  if (p == '%' && len >=3) {
  ------------------
  |  Branch (694:7): [True: 4, False: 6]
  |  Branch (694:19): [True: 4, False: 0]
  ------------------
  695|      4|    if (s[1] == '2' && (s[2] == 'E' || s[2] == 'e')) {
  ------------------
  |  Branch (695:9): [True: 3, False: 1]
  |  Branch (695:25): [True: 0, False: 3]
  |  Branch (695:40): [True: 3, False: 0]
  ------------------
  696|      3|      len -= 2;
  697|      3|    }
  698|      4|    p = '.';
  699|      4|  }
  700|     10|  if (p != '.')
  ------------------
  |  Branch (700:7): [True: 4, False: 6]
  ------------------
  701|      4|    return 0;
  702|      6|  if (len == 1)
  ------------------
  |  Branch (702:7): [True: 3, False: 3]
  ------------------
  703|      3|    return 2;
  704|       |
  705|      3|  return 0;
  706|      6|}
coap_replace_percents:
  825|     14|coap_replace_percents(coap_optlist_t *optlist) {
  826|     14|  size_t i;
  827|     14|  size_t o = 0;
  828|       |
  829|    150|  for (i = 0; i < optlist->length; i++) {
  ------------------
  |  Branch (829:15): [True: 136, False: 14]
  ------------------
  830|    136|    if (optlist->data[i] == '%' && optlist->length - i >= 3) {
  ------------------
  |  Branch (830:9): [True: 5, False: 131]
  |  Branch (830:36): [True: 4, False: 1]
  ------------------
  831|      4|      optlist->data[o] = (hexchar_to_dec(optlist->data[i+1]) << 4) +
  ------------------
  |  |  532|      4|#define hexchar_to_dec(c) ((c) & 0x40 ? ((c) & 0x0F) + 9 : ((c) & 0x0F))
  |  |  ------------------
  |  |  |  Branch (532:28): [True: 2, False: 2]
  |  |  ------------------
  ------------------
  832|      4|                         hexchar_to_dec(optlist->data[i+2]);
  ------------------
  |  |  532|      4|#define hexchar_to_dec(c) ((c) & 0x40 ? ((c) & 0x0F) + 9 : ((c) & 0x0F))
  |  |  ------------------
  |  |  |  Branch (532:28): [True: 4, False: 0]
  |  |  ------------------
  ------------------
  833|      4|      i+= 2;
  834|    132|    } else if (o != i) {
  ------------------
  |  Branch (834:16): [True: 48, False: 84]
  ------------------
  835|     48|      optlist->data[o] = optlist->data[i];
  836|     48|    }
  837|    136|    o++;
  838|    136|  }
  839|     14|  optlist->length = o;
  840|     14|}
coap_path_into_optlist_abbrev:
  873|      2|                              uint32_t count) {
  874|      2|  const uint8_t *p = s;
  875|      2|  coap_optlist_t *optlist;
  876|      2|  int num_dots;
  877|      2|  coap_optlist_t **optlist_start;
  878|       |
  879|      2|  if (*optlist_chain) {
  ------------------
  |  Branch (879:7): [True: 2, False: 0]
  ------------------
  880|       |    /* Something previously in optlist_chain. Need to make that the start */
  881|      2|    optlist_start = &((*optlist_chain)->next);
  882|      2|  } else {
  883|      0|    optlist_start = optlist_chain;
  884|      0|  }
  885|       |
  886|      2|  if (length > 0 && mapping) {
  ------------------
  |  Branch (886:7): [True: 2, False: 0]
  |  Branch (886:21): [True: 0, False: 2]
  ------------------
  887|      0|    uint32_t i;
  888|      0|    uint8_t buf[4];
  889|       |
  890|      0|    for (i = 0; i < count; i++) {
  ------------------
  |  Branch (890:17): [True: 0, False: 0]
  ------------------
  891|      0|      if (strlen(mapping[i].upa_path) == length &&
  ------------------
  |  Branch (891:11): [True: 0, False: 0]
  ------------------
  892|      0|          memcmp(mapping[i].upa_path, s, length) == 0) {
  ------------------
  |  Branch (892:11): [True: 0, False: 0]
  ------------------
  893|       |        /* add in as Uri_path-Abbrev */
  894|      0|        optlist = coap_new_optlist(COAP_OPTION_URI_PATH_ABB,
  895|      0|                                   coap_encode_var_safe(buf, sizeof(buf), mapping[i].upa_value), buf);
  896|      0|        if (!coap_insert_optlist(optlist_chain, optlist)) {
  ------------------
  |  Branch (896:13): [True: 0, False: 0]
  ------------------
  897|      0|          return 0;
  898|      0|        }
  899|      0|        return 1;
  900|      0|      }
  901|      0|    }
  902|      0|  }
  903|    179|  while (length > 0 && !strnchr((const uint8_t *)"?#", 2, *s)) {
  ------------------
  |  Branch (903:10): [True: 177, False: 2]
  |  Branch (903:24): [True: 177, False: 0]
  ------------------
  904|    177|    if (*s == '/') {                /* start of new path element */
  ------------------
  |  Branch (904:9): [True: 17, False: 160]
  ------------------
  905|       |      /* start new segment */
  906|     17|      num_dots = coap_check_dots(p, s - p);
  907|     17|      switch (num_dots) {
  908|      2|      case 1:
  ------------------
  |  Branch (908:7): [True: 2, False: 15]
  ------------------
  909|       |        /* drop segment */
  910|      2|        break;
  911|      3|      case 2:
  ------------------
  |  Branch (911:7): [True: 3, False: 14]
  ------------------
  912|       |        /* backup segment */
  913|      3|        backup_optlist(optlist_start);
  914|      3|        break;
  915|     12|      case 0:
  ------------------
  |  Branch (915:7): [True: 12, False: 5]
  ------------------
  916|     12|      default:
  ------------------
  |  Branch (916:7): [True: 0, False: 17]
  ------------------
  917|       |        /* add segment */
  918|     12|        optlist = coap_new_optlist(optnum, s - p, p);
  919|     12|        if (!optlist) {
  ------------------
  |  Branch (919:13): [True: 0, False: 12]
  ------------------
  920|      0|          return 0;
  921|      0|        }
  922|     12|        coap_replace_percents(optlist);
  923|     12|        if (!coap_insert_optlist(optlist_chain, optlist)) {
  ------------------
  |  Branch (923:13): [True: 0, False: 12]
  ------------------
  924|      0|          return 0;
  925|      0|        }
  926|     12|        break;
  927|     17|      }
  928|     17|      p = s + 1;
  929|     17|    }
  930|    177|    s++;
  931|    177|    length--;
  932|       |
  933|    177|  }
  934|       |  /* add last path element */
  935|      2|  num_dots = coap_check_dots(p, s - p);
  936|      2|  switch (num_dots) {
  937|      0|  case 1:
  ------------------
  |  Branch (937:3): [True: 0, False: 2]
  ------------------
  938|       |    /* drop segment */
  939|      0|    break;
  940|      0|  case 2:
  ------------------
  |  Branch (940:3): [True: 0, False: 2]
  ------------------
  941|       |    /* backup segment */
  942|      0|    backup_optlist(optlist_start);
  943|      0|    break;
  944|      2|  case 0:
  ------------------
  |  Branch (944:3): [True: 2, False: 0]
  ------------------
  945|      2|  default:
  ------------------
  |  Branch (945:3): [True: 0, False: 2]
  ------------------
  946|       |    /* add segment */
  947|      2|    optlist = coap_new_optlist(optnum, s - p, p);
  948|      2|    if (!optlist) {
  ------------------
  |  Branch (948:9): [True: 0, False: 2]
  ------------------
  949|      0|      return 0;
  950|      0|    }
  951|      2|    coap_replace_percents(optlist);
  952|      2|    if (!coap_insert_optlist(optlist_chain, optlist)) {
  ------------------
  |  Branch (952:9): [True: 0, False: 2]
  ------------------
  953|      0|      return 0;
  954|      0|    }
  955|      2|    break;
  956|      2|  }
  957|      2|  return 1;
  958|      2|}
coap_delete_upa_chain:
 1271|     72|coap_delete_upa_chain(coap_upa_chain_t *chain) {
 1272|     72|  while (chain) {
  ------------------
  |  Branch (1272:10): [True: 0, False: 72]
  ------------------
 1273|      0|    coap_upa_chain_t *next = chain->next;
 1274|       |
 1275|      0|    coap_free_type(COAP_STRING, chain);
 1276|      0|    chain = next;
 1277|      0|  }
 1278|     72|}
coap_uri.c:coap_split_uri_sub:
   84|     10|                   coap_uri_check_t check_proxy) {
   85|     10|  const uint8_t *p, *q;
   86|     10|  int res = 0;
   87|     10|  size_t i;
   88|     10|  int is_unix_domain = 0;
   89|     10|  int is_llc = 0;
   90|       |
   91|     10|  if (!str_var || !uri || len == 0)
  ------------------
  |  Branch (91:7): [True: 0, False: 10]
  |  Branch (91:19): [True: 0, False: 10]
  |  Branch (91:27): [True: 0, False: 10]
  ------------------
   92|      0|    return -1;
   93|       |
   94|     10|  memset(uri, 0, sizeof(coap_uri_t));
   95|     10|  uri->port = COAP_DEFAULT_PORT;
  ------------------
  |  |   39|     10|#define COAP_DEFAULT_PORT      5683 /* CoAP default UDP/TCP port */
  ------------------
   96|       |
   97|       |  /* search for scheme */
   98|     10|  p = str_var;
   99|     10|  if (*p == '/') {
  ------------------
  |  Branch (99:7): [True: 0, False: 10]
  ------------------
  100|       |    /* no scheme, host or port */
  101|      0|    if (check_proxy == COAP_URI_CHECK_PROXY) {
  ------------------
  |  Branch (101:9): [True: 0, False: 0]
  ------------------
  102|       |      /* Must have ongoing host if proxy definition */
  103|      0|      return -1;
  104|      0|    }
  105|      0|    q = p;
  106|      0|    goto path;
  107|      0|  }
  108|       |
  109|       |  /* find scheme terminating :// */
  110|    822|  while (len >= 3 && !(p[0] == ':' && p[1] == '/' && p[2] == '/')) {
  ------------------
  |  Branch (110:10): [True: 818, False: 4]
  |  Branch (110:24): [True: 7, False: 811]
  |  Branch (110:39): [True: 6, False: 1]
  |  Branch (110:54): [True: 6, False: 0]
  ------------------
  111|    812|    ++p;
  112|    812|    --len;
  113|    812|  }
  114|     10|  if (len < 3) {
  ------------------
  |  Branch (114:7): [True: 4, False: 6]
  ------------------
  115|       |    /* scheme not defined with a :// terminator */
  116|      4|    res = -2;
  117|      4|    goto error;
  118|      4|  }
  119|     22|  for (i = 0; i < COAP_URI_SCHEME_LAST; i++) {
  ------------------
  |  Branch (119:15): [True: 22, False: 0]
  ------------------
  120|     22|    if ((p - str_var) == (int)strlen(coap_uri_scheme[i].name) &&
  ------------------
  |  Branch (120:9): [True: 6, False: 16]
  ------------------
  121|      6|        memcmp(str_var, coap_uri_scheme[i].name, p - str_var) == 0) {
  ------------------
  |  Branch (121:9): [True: 6, False: 0]
  ------------------
  122|      6|      if (check_proxy != COAP_URI_CHECK_PROXY && coap_uri_scheme[i].proxy_only) {
  ------------------
  |  Branch (122:11): [True: 0, False: 6]
  |  Branch (122:50): [True: 0, False: 0]
  ------------------
  123|      0|        coap_log_err("%.*s URI scheme not enabled (not a proxy)\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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  124|      0|                     (int)(p - str_var), str_var);
  125|      0|        return -1;
  126|      0|      }
  127|      6|      uri->scheme = coap_uri_scheme[i].scheme;
  128|      6|      uri->port = coap_uri_scheme[i].port;
  129|      6|      break;
  130|      6|    }
  131|     22|  }
  132|      6|  if (i == COAP_URI_SCHEME_LAST) {
  ------------------
  |  Branch (132:7): [True: 0, False: 6]
  ------------------
  133|       |    /* scheme unknown */
  134|      0|    coap_log_err("%.*s URI scheme unknown\n", (int)(p - str_var), str_var);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  135|      0|    res = -1;
  136|      0|    goto error;
  137|      0|  }
  138|      6|  switch (uri->scheme) {
  139|      0|  case COAP_URI_SCHEME_COAP:
  ------------------
  |  Branch (139:3): [True: 0, False: 6]
  ------------------
  140|      0|    break;
  141|      1|  case COAP_URI_SCHEME_COAPS:
  ------------------
  |  Branch (141:3): [True: 1, False: 5]
  ------------------
  142|      1|    if (!coap_dtls_is_supported()) {
  ------------------
  |  Branch (142:9): [True: 0, False: 1]
  ------------------
  143|      0|      coap_log_err("coaps URI scheme not supported in this version of libcoap\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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  144|      0|      return -1;
  145|      0|    }
  146|      1|    break;
  147|      1|  case COAP_URI_SCHEME_COAP_TCP:
  ------------------
  |  Branch (147:3): [True: 0, False: 6]
  ------------------
  148|      0|    if (!coap_tcp_is_supported()) {
  ------------------
  |  Branch (148:9): [True: 0, False: 0]
  ------------------
  149|      0|      coap_log_err("coap+tcp URI scheme not supported in this version of libcoap\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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  150|      0|      return -1;
  151|      0|    }
  152|      0|    break;
  153|      5|  case COAP_URI_SCHEME_COAPS_TCP:
  ------------------
  |  Branch (153:3): [True: 5, False: 1]
  ------------------
  154|      5|    if (!coap_tls_is_supported()) {
  ------------------
  |  Branch (154:9): [True: 0, False: 5]
  ------------------
  155|      0|      coap_log_err("coaps+tcp URI scheme not supported in this version of libcoap\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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  156|      0|      return -1;
  157|      0|    }
  158|      5|    break;
  159|      5|  case COAP_URI_SCHEME_COAP_WS:
  ------------------
  |  Branch (159:3): [True: 0, False: 6]
  ------------------
  160|      0|    if (!coap_ws_is_supported()) {
  ------------------
  |  Branch (160:9): [True: 0, False: 0]
  ------------------
  161|      0|      coap_log_err("coap+ws URI scheme not supported in this version of libcoap\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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  162|      0|      return -1;
  163|      0|    }
  164|      0|    break;
  165|      0|  case COAP_URI_SCHEME_COAPS_WS:
  ------------------
  |  Branch (165:3): [True: 0, False: 6]
  ------------------
  166|      0|    if (!coap_wss_is_supported()) {
  ------------------
  |  Branch (166:9): [True: 0, False: 0]
  ------------------
  167|      0|      coap_log_err("coaps+ws URI scheme not supported in this version of libcoap\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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  168|      0|      return -1;
  169|      0|    }
  170|      0|    break;
  171|      0|  case COAP_URI_SCHEME_HTTP:
  ------------------
  |  Branch (171:3): [True: 0, False: 6]
  ------------------
  172|      0|  case COAP_URI_SCHEME_HTTPS:
  ------------------
  |  Branch (172:3): [True: 0, False: 6]
  ------------------
  173|       |    /* Not proxy, caught above.  For proxy, assume app is doing CoAP <> HTTP mapping. */
  174|      0|    break;
  175|      0|  case COAP_URI_SCHEME_LAST:
  ------------------
  |  Branch (175:3): [True: 0, False: 6]
  ------------------
  176|      0|  default:
  ------------------
  |  Branch (176:3): [True: 0, False: 6]
  ------------------
  177|      0|    coap_log_warn("Unsupported URI type %d\n", uri->scheme);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  178|      0|    return -1;
  179|      6|  }
  180|       |  /* skip :// */
  181|      6|  p += 3;
  182|      6|  len -= 3;
  183|       |
  184|       |  /* p points to beginning of Uri-Host */
  185|      6|  q = p;
  186|       |
  187|      6|  if (len && *p == '[') {
  ------------------
  |  Branch (187:7): [True: 6, False: 0]
  |  Branch (187:14): [True: 0, False: 6]
  ------------------
  188|       |    /* IPv6 address reference or Unix domain */
  189|      0|    ++p;
  190|      0|    ++q;
  191|      0|    --len;
  192|       |
  193|      0|    while (len && *q != ']') {
  ------------------
  |  Branch (193:12): [True: 0, False: 0]
  |  Branch (193:19): [True: 0, False: 0]
  ------------------
  194|      0|      ++q;
  195|      0|      --len;
  196|      0|    }
  197|       |
  198|      0|    if (!len || *q != ']' || p == q) {
  ------------------
  |  Branch (198:9): [True: 0, False: 0]
  |  Branch (198:17): [True: 0, False: 0]
  |  Branch (198:30): [True: 0, False: 0]
  ------------------
  199|      0|      res = -3;
  200|      0|      goto error;
  201|      0|    }
  202|       |
  203|      0|    COAP_SET_STR(&uri->host, q - p, p);
  ------------------
  |  |   52|      0|#define COAP_SET_STR(st,l,v) { (st)->length = (l), (st)->s = (v); }
  ------------------
  204|      0|    ++q;
  205|      0|    --len;
  206|      0|#if COAP_AF_LLC_SUPPORT
  207|      6|  } else if ((len >= LLC_HOST_LEN) && strncmp((const char *)p, "llc[", 4) == 0) {
  ------------------
  |  |  169|      6|#define LLC_HOST_LEN (4 + HW_ADDRSTRLEN + 4)
  |  |  ------------------
  |  |  |  |  167|      6|#define HW_ADDRSTRLEN 17
  |  |  ------------------
  ------------------
  |  Branch (207:14): [True: 4, False: 2]
  |  Branch (207:39): [True: 1, False: 3]
  ------------------
  208|      1|    unsigned long sap = 0;
  209|       |
  210|      1|    is_llc = 1;
  211|       |
  212|      8|    while (len && *q != ']') {
  ------------------
  |  Branch (212:12): [True: 8, False: 0]
  |  Branch (212:19): [True: 7, False: 1]
  ------------------
  213|      7|      ++q;
  214|      7|      --len;
  215|      7|    }
  216|       |
  217|      1|    if (!len || *q != ']' || p == q) {
  ------------------
  |  Branch (217:9): [True: 0, False: 1]
  |  Branch (217:17): [True: 0, False: 1]
  |  Branch (217:30): [True: 0, False: 1]
  ------------------
  218|      0|      res = -7;
  219|      0|      goto error;
  220|      0|    }
  221|       |
  222|      1|    ++q;
  223|      1|    --len;
  224|       |
  225|      1|    if (!len || *q != ':') {
  ------------------
  |  Branch (225:9): [True: 0, False: 1]
  |  Branch (225:17): [True: 0, False: 1]
  ------------------
  226|      0|      coap_log_warn("LLC SAP missing in URI\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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  227|      0|      res = -7;
  228|      0|      goto error;
  229|      0|    }
  230|       |
  231|      1|    ++q;
  232|      1|    --len;
  233|       |
  234|      8|    while (len && isxdigit(*q)) {
  ------------------
  |  Branch (234:12): [True: 8, False: 0]
  |  Branch (234:19): [True: 7, False: 1]
  ------------------
  235|      7|      if (*q >= 'a' && *q <= 'f')
  ------------------
  |  Branch (235:11): [True: 0, False: 7]
  |  Branch (235:24): [True: 0, False: 0]
  ------------------
  236|      0|        sap = sap * 16 + (*q - 'a' + 10);
  237|      7|      else if (*q >= 'A' && *q <= 'F')
  ------------------
  |  Branch (237:16): [True: 7, False: 0]
  |  Branch (237:29): [True: 7, False: 0]
  ------------------
  238|      7|        sap = sap * 16 + (*q - 'A' + 10);
  239|       |
  240|      7|      ++q;
  241|      7|      --len;
  242|      7|    }
  243|       |
  244|      1|    if (sap > UINT8_MAX) {
  ------------------
  |  Branch (244:9): [True: 1, False: 0]
  ------------------
  245|      1|      coap_log_warn("LLC SAP invalid (%lu > 255)\n", sap);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  246|      1|      res = -7;
  247|      1|      goto error;
  248|      1|    }
  249|       |
  250|      0|    COAP_SET_STR(&uri->host, q - p, p);
  ------------------
  |  |   52|      0|#define COAP_SET_STR(st,l,v) { (st)->length = (l), (st)->s = (v); }
  ------------------
  251|      0|#endif /* COAP_AF_LLC_SUPPORT */
  252|      5|  } else {
  253|       |    /* IPv4 address, FQDN or Unix domain socket */
  254|      5|    if (len >= 3 && p[0] == '%' && p[1] == '2' &&
  ------------------
  |  Branch (254:9): [True: 5, False: 0]
  |  Branch (254:21): [True: 0, False: 5]
  |  Branch (254:36): [True: 0, False: 0]
  ------------------
  255|      0|        (p[2] == 'F' || p[2] == 'f')) {
  ------------------
  |  Branch (255:10): [True: 0, False: 0]
  |  Branch (255:25): [True: 0, False: 0]
  ------------------
  256|       |      /* Unix domain definition */
  257|      0|      uri->port = 0;
  258|      0|      is_unix_domain = 1;
  259|      0|    }
  260|     34|    while (len && *q != ':' && *q != '/' && *q != '?') {
  ------------------
  |  Branch (260:12): [True: 34, False: 0]
  |  Branch (260:19): [True: 31, False: 3]
  |  Branch (260:32): [True: 29, False: 2]
  |  Branch (260:45): [True: 29, False: 0]
  ------------------
  261|     29|      ++q;
  262|     29|      --len;
  263|     29|    }
  264|       |
  265|      5|    if (p == q) {
  ------------------
  |  Branch (265:9): [True: 0, False: 5]
  ------------------
  266|      0|      res = -3;
  267|      0|      goto error;
  268|      0|    }
  269|       |
  270|      5|    if ((int)(q - p) > 255) {
  ------------------
  |  Branch (270:9): [True: 0, False: 5]
  ------------------
  271|      0|      coap_log_warn("Host name length too long (%d > 255)\n", (int)(q - p));
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  272|      0|      res = -6;
  273|      0|      goto error;
  274|      0|    }
  275|       |
  276|      5|    COAP_SET_STR(&uri->host, q - p, p);
  ------------------
  |  |   52|      5|#define COAP_SET_STR(st,l,v) { (st)->length = (l), (st)->s = (v); }
  ------------------
  277|      5|  }
  278|       |
  279|       |  /* check for Uri-Port (invalid for Unix) */
  280|      5|  if (len && *q == ':') {
  ------------------
  |  Branch (280:7): [True: 5, False: 0]
  |  Branch (280:14): [True: 3, False: 2]
  ------------------
  281|      3|    if (is_unix_domain || is_llc) {
  ------------------
  |  Branch (281:9): [True: 0, False: 3]
  |  Branch (281:27): [True: 0, False: 3]
  ------------------
  282|      0|      res = -5;
  283|      0|      goto error;
  284|      0|    }
  285|      3|    p = ++q;
  286|      3|    --len;
  287|       |
  288|      4|    while (len && isdigit(*q)) {
  ------------------
  |  Branch (288:12): [True: 4, False: 0]
  |  Branch (288:19): [True: 1, False: 3]
  ------------------
  289|      1|      ++q;
  290|      1|      --len;
  291|      1|    }
  292|       |
  293|      3|    if (p < q) {                /* explicit port number given */
  ------------------
  |  Branch (293:9): [True: 1, False: 2]
  ------------------
  294|      1|      long uri_port = 0;
  295|       |
  296|      2|      while ((p < q) && (uri_port <= UINT16_MAX))
  ------------------
  |  Branch (296:14): [True: 1, False: 1]
  |  Branch (296:25): [True: 1, False: 0]
  ------------------
  297|      1|        uri_port = uri_port * 10 + (*p++ - '0');
  298|       |
  299|       |      /* check if port number is in allowed range */
  300|      1|      if (uri_port > UINT16_MAX) {
  ------------------
  |  Branch (300:11): [True: 0, False: 1]
  ------------------
  301|      0|        coap_log_warn("Port number too big (%ld > 65535)\n", uri_port);
  ------------------
  |  |  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|        res = -4;
  303|      0|        goto error;
  304|      0|      }
  305|       |
  306|      1|      uri->port = (uint16_t)uri_port;
  307|      1|    }
  308|      3|  }
  309|       |
  310|      5|path:                 /* at this point, p must point to an absolute path */
  311|       |
  312|      5|  if (!len)
  ------------------
  |  Branch (312:7): [True: 0, False: 5]
  ------------------
  313|      0|    goto end;
  314|       |
  315|      5|  if (*q == '/') {
  ------------------
  |  Branch (315:7): [True: 2, False: 3]
  ------------------
  316|      2|    p = ++q;
  317|      2|    --len;
  318|       |
  319|    179|    while (len && *q != '?') {
  ------------------
  |  Branch (319:12): [True: 177, False: 2]
  |  Branch (319:19): [True: 177, False: 0]
  ------------------
  320|    177|      ++q;
  321|    177|      --len;
  322|    177|    }
  323|       |
  324|      2|    if (p < q) {
  ------------------
  |  Branch (324:9): [True: 2, False: 0]
  ------------------
  325|      2|      COAP_SET_STR(&uri->path, q - p, p);
  ------------------
  |  |   52|      2|#define COAP_SET_STR(st,l,v) { (st)->length = (l), (st)->s = (v); }
  ------------------
  326|      2|      p = q;
  327|      2|    }
  328|      2|  }
  329|       |
  330|       |  /* Uri_Query */
  331|      5|  if (len && *p == '?') {
  ------------------
  |  Branch (331:7): [True: 3, False: 2]
  |  Branch (331:14): [True: 0, False: 3]
  ------------------
  332|      0|    ++p;
  333|      0|    --len;
  334|      0|    COAP_SET_STR(&uri->query, len, p);
  ------------------
  |  |   52|      0|#define COAP_SET_STR(st,l,v) { (st)->length = (l), (st)->s = (v); }
  ------------------
  335|      0|    len = 0;
  336|      0|  }
  337|       |
  338|      5|end:
  339|      5|  return len ? -1 : 0;
  ------------------
  |  Branch (339:10): [True: 3, False: 2]
  ------------------
  340|       |
  341|      5|error:
  342|      5|  return res;
  343|      5|}
coap_uri.c:strnchr:
   47|    177|strnchr(const uint8_t *s, size_t len, unsigned char c) {
   48|    531|  while (len && *s++ != c)
  ------------------
  |  Branch (48:10): [True: 354, False: 177]
  |  Branch (48:17): [True: 354, False: 0]
  ------------------
   49|    354|    --len;
   50|       |
   51|    177|  return len ? s : NULL;
  ------------------
  |  Branch (51:10): [True: 0, False: 177]
  ------------------
   52|    177|}
coap_uri.c:backup_optlist:
  843|      3|backup_optlist(coap_optlist_t **optlist_begin) {
  844|      3|  coap_optlist_t *last = NULL;
  845|      3|  coap_optlist_t *cur = *optlist_begin;
  846|       |
  847|      3|  if (!cur)
  ------------------
  |  Branch (847:7): [True: 0, False: 3]
  ------------------
  848|      0|    return;
  849|       |
  850|     19|  while (cur) {
  ------------------
  |  Branch (850:10): [True: 19, False: 0]
  ------------------
  851|     19|    if (!cur->next)
  ------------------
  |  Branch (851:9): [True: 3, False: 16]
  ------------------
  852|      3|      break;
  853|     16|    last = cur;
  854|     16|    cur = cur->next;
  855|     16|  }
  856|      3|  coap_delete_optlist(cur);
  857|      3|  if (last) {
  ------------------
  |  Branch (857:7): [True: 3, False: 0]
  ------------------
  858|      3|    last->next = NULL;
  859|      3|  } else {
  860|       |    *optlist_begin = NULL;
  861|      0|  }
  862|      3|}

oscore_free_contexts:
  195|     36|oscore_free_contexts(coap_context_t *c_context) {
  196|     36|  while (c_context->p_osc_ctx) {
  ------------------
  |  Branch (196:10): [True: 0, False: 36]
  ------------------
  197|      0|    oscore_ctx_t *osc_ctx = c_context->p_osc_ctx;
  198|       |
  199|      0|    if (osc_ctx->next == osc_ctx) {
  ------------------
  |  Branch (199:9): [True: 0, False: 0]
  ------------------
  200|      0|      c_context->p_osc_ctx = NULL;
  201|      0|    } else {
  202|      0|      oscore_ctx_t *tail = osc_ctx;
  203|      0|      c_context->p_osc_ctx = osc_ctx->next;
  204|      0|      while (tail->next != osc_ctx) {
  ------------------
  |  Branch (204:14): [True: 0, False: 0]
  ------------------
  205|      0|        tail = tail->next;
  206|      0|      }
  207|      0|      tail->next = c_context->p_osc_ctx;
  208|      0|    }
  209|      0|    osc_ctx->next = NULL;
  210|       |
  211|       |    /*
  212|       |     * Verify if all recipients can be released, if not
  213|       |     * defer freeing of context until later when all recipients are released.
  214|       |     * The oscore context is flagged as ready to be freed by removing
  215|       |     * the oscore context from the coap context.
  216|       |     */
  217|      0|    if (oscore_context_release_recipients(osc_ctx) > 0) {
  ------------------
  |  Branch (217:9): [True: 0, False: 0]
  ------------------
  218|      0|      oscore_free_context(osc_ctx);
  219|      0|    }
  220|      0|  }
  221|     36|}
oscore_release_recipient_ctx:
  975|     62|oscore_release_recipient_ctx(oscore_recipient_ctx_t **recipient_ctx) {
  976|     62|  oscore_ctx_t *osc_ctx;
  977|       |
  978|     62|  if (recipient_ctx == NULL || *recipient_ctx == NULL)
  ------------------
  |  Branch (978:7): [True: 0, False: 62]
  |  Branch (978:32): [True: 62, False: 0]
  ------------------
  979|     62|    return;
  980|       |
  981|       |  /* ensure oscore context is freed if not attached to coap context */
  982|      0|  osc_ctx = (*recipient_ctx)->osc_ctx;
  983|      0|  oscore_free_recipient_ctx(*recipient_ctx);
  984|       |  /*
  985|       |   * Free temporary oscore context if not attached to a coap context
  986|       |   * and no recipients attached anymore.
  987|       |   */
  988|      0|  if (!oscore_is_context_attached(osc_ctx) && osc_ctx->recipient_chain == NULL) {
  ------------------
  |  Branch (988:7): [True: 0, False: 0]
  |  Branch (988:47): [True: 0, False: 0]
  ------------------
  989|      0|    oscore_free_context(osc_ctx);
  990|      0|  }
  991|       |  *recipient_ctx = NULL;
  992|      0|}
oscore_delete_server_associations:
 1093|     62|oscore_delete_server_associations(coap_session_t *session) {
 1094|     62|  if (session) {
  ------------------
  |  Branch (1094:7): [True: 62, False: 0]
  ------------------
 1095|     62|    oscore_association_t *association;
 1096|     62|    oscore_association_t *tmp;
 1097|       |
 1098|     62|    OSCORE_ASSOCIATIONS_ITER_SAFE(session->associations, association, tmp) {
  ------------------
  |  |  147|     62|  for ((el) = (e); (el) && ((rtmp) = (el)->hh.next, 1); (el) = (rtmp))
  |  |  ------------------
  |  |  |  Branch (147:20): [True: 0, False: 62]
  |  |  |  Branch (147:28): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1099|      0|      OSCORE_ASSOCIATIONS_DELETE(session->associations, association);
  ------------------
  |  |  140|      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]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1100|      0|      oscore_free_association(association);
 1101|      0|    }
 1102|       |    session->associations = NULL;
 1103|     62|  }
 1104|     62|}

LLVMFuzzerTestOneInput:
   68|     40|LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
   69|       |  /* Need: mode byte + method byte + at least a few option-payload bytes. */
   70|     40|  if (size < 8)
  ------------------
  |  Branch (70:7): [True: 4, False: 36]
  ------------------
   71|      4|    return 0;
   72|       |
   73|     36|  coap_context_t *ctx = NULL;
   74|     36|  coap_session_t *req_session = NULL;
   75|     36|  coap_resource_t *resource = NULL;
   76|     36|  coap_pdu_t *request = NULL;
   77|     36|  coap_pdu_t *response = NULL;
   78|     36|  coap_address_t addr;
   79|       |
   80|     36|  const uint8_t mode = data[0];
   81|     36|  const uint8_t method_byte = data[1];
   82|       |
   83|     36|  coap_startup();
   84|     36|  coap_set_log_level(COAP_LOG_EMERG);
   85|     36|  coap_dtls_set_log_level(COAP_LOG_EMERG);
   86|     36|  coap_debug_set_packet_loss("100%");
   87|     36|  coap_debug_set_packet_fail("100%");
   88|       |
   89|     36|  ctx = coap_new_context(NULL);
   90|     36|  if (!ctx)
  ------------------
  |  Branch (90:7): [True: 0, False: 36]
  ------------------
   91|      0|    goto cleanup;
   92|     36|  coap_register_event_handler(ctx, proxy_fuzz_event_handler);
   93|       |
   94|       |  /* Pick a proxy type from mode bits 2-4. Cover all three base types (static,
   95|       |   * dynamic, reverse) crossed with the option-controlling bits that are
   96|       |   * meaningful for each, per coap_proxy.h:
   97|       |   *   0: FWD_STATIC                 — needs pre-populated server_list entry
   98|       |   *   1: FWD_STATIC | STRIP         — static, strip proxy options on forward
   99|       |   *   2: FWD_DYNAMIC               — pulls target from request's Proxy-* options
  100|       |   *   3: FWD_DYNAMIC | STRIP        — same, strip proxy options (forces re-walk)
  101|       |   *   4: FWD_DYNAMIC | MCAST        — allow multicast upstream resolution
  102|       |   *   5: FWD_DYNAMIC | DYN_DEFINED  — no auto-added dynamic upstreams
  103|       |   *   6: REV                        — reverse proxy, also uses server_list entry
  104|       |   *   7: REV | STRIP                — reverse, strip proxy options
  105|       |   * STRIP is the more interesting code path because it forces an option re-walk.
  106|       |   */
  107|     36|  static const coap_proxy_t types[8] = {
  108|     36|    COAP_PROXY_FWD_STATIC,
  109|     36|    COAP_PROXY_FWD_STATIC | COAP_PROXY_BIT_STRIP,
  110|     36|    COAP_PROXY_FWD_DYNAMIC,
  111|     36|    COAP_PROXY_FWD_DYNAMIC | COAP_PROXY_BIT_STRIP,
  112|     36|    COAP_PROXY_FWD_DYNAMIC | COAP_PROXY_BIT_MCAST,
  113|     36|    COAP_PROXY_FWD_DYNAMIC | COAP_PROXY_DYN_DEFINED,
  114|     36|    COAP_PROXY_REV,
  115|     36|    COAP_PROXY_REV | COAP_PROXY_BIT_STRIP,
  116|     36|  };
  117|     36|  coap_proxy_t selected_type = types[(mode >> 2) & 0x07];
  118|       |
  119|       |  /* Backing storage for a static server_list entry. coap_proxy_get_session
  120|       |   * memcpys the entry into server_use, so stack storage is fine. */
  121|     36|  coap_proxy_server_t static_entry;
  122|     36|  memset(&static_entry, 0, sizeof(static_entry));
  123|     36|  static_entry.uri.scheme = COAP_URI_SCHEME_COAP;
  124|     36|  static_entry.uri.host.s = (const uint8_t *)"127.0.0.1";
  125|     36|  static_entry.uri.host.length = 9;
  126|     36|  static_entry.uri.port = 0; /* Picks something the OS will quietly drop. */
  127|       |
  128|     36|  coap_proxy_server_list_t server_list;
  129|     36|  memset(&server_list, 0, sizeof(server_list));
  130|     36|  server_list.type = selected_type;
  131|       |  /* Match on the base type only (COAP_PROXY_NEW_MASK), so the STRIP/MCAST/
  132|       |   * DYN_DEFINED option bits don't defeat the comparison — both FWD_STATIC and
  133|       |   * REV (with or without those bits) need a pre-populated upstream entry. */
  134|     36|  coap_proxy_t base_type = selected_type & COAP_PROXY_NEW_MASK;
  ------------------
  |  |   92|     36|#define COAP_PROXY_NEW_MASK 0x38 /**< Space used in coap_proxy_t for new types */
  ------------------
  135|     36|  if (base_type == COAP_PROXY_FWD_STATIC || base_type == COAP_PROXY_REV) {
  ------------------
  |  Branch (135:7): [True: 10, False: 26]
  |  Branch (135:45): [True: 16, False: 10]
  ------------------
  136|     26|    server_list.entry = &static_entry;
  137|     26|    server_list.entry_count = 1;
  138|     26|  }
  139|       |
  140|       |  /* Build the "incoming client" session. We use UDP-to-loopback because UDP
  141|       |   * doesn't connect — coap_new_client_session returns a fully-formed session
  142|       |   * with no real network handshake. We won't actually transmit on it. */
  143|     36|  coap_address_init(&addr);
  144|     36|  addr.addr.sin.sin_family = AF_INET;
  145|     36|  addr.addr.sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
  146|     36|  addr.addr.sin.sin_port = htons(5683);
  147|     36|  req_session = coap_new_client_session(ctx, NULL, &addr, COAP_PROTO_UDP);
  148|     36|  if (!req_session)
  ------------------
  |  Branch (148:7): [True: 0, False: 36]
  ------------------
  149|      0|    goto cleanup;
  150|     36|  req_session->state = COAP_SESSION_STATE_ESTABLISHED;
  151|       |
  152|       |  /* The proxy code uses `resource` to track which proxy URI resource the
  153|       |   * request came in on. Use the official proxy-URI resource builder so flags
  154|       |   * like `is_proxy_uri` are set, but with no host_name_list — we don't enforce
  155|       |   * the host filter here. */
  156|     36|  resource = coap_resource_proxy_uri_init2(proxy_fuzz_handler, 0, NULL, 0);
  157|     36|  if (!resource)
  ------------------
  |  Branch (157:7): [True: 0, False: 36]
  ------------------
  158|      0|    goto cleanup;
  159|     36|  coap_add_resource(ctx, resource);
  160|       |
  161|       |  /* Build the request PDU. */
  162|     36|  const coap_pdu_code_t methods[8] = {
  163|     36|    COAP_REQUEST_CODE_GET,   COAP_REQUEST_CODE_POST,
  164|     36|    COAP_REQUEST_CODE_PUT,   COAP_REQUEST_CODE_DELETE,
  165|     36|    COAP_REQUEST_CODE_FETCH, COAP_REQUEST_CODE_PATCH,
  166|     36|    COAP_REQUEST_CODE_IPATCH, COAP_REQUEST_CODE_GET,
  167|     36|  };
  168|     36|  coap_pdu_type_t pdu_type = (mode & 0x01) ? COAP_MESSAGE_NON : COAP_MESSAGE_CON;
  ------------------
  |  Branch (168:30): [True: 19, False: 17]
  ------------------
  169|     36|  size_t max_pdu = coap_session_max_pdu_size(req_session);
  170|     36|  request = coap_pdu_init(pdu_type, methods[method_byte & 0x07],
  171|     36|                          coap_new_message_id(req_session), max_pdu);
  172|     36|  if (!request)
  ------------------
  |  Branch (172:7): [True: 0, False: 36]
  ------------------
  173|      0|    goto cleanup;
  174|       |
  175|       |  /* Deterministic 4-byte token derived from the input keeps option-tracking
  176|       |   * predictable across iterations without consuming the cursor's payload. */
  177|     36|  const uint8_t token[4] = { data[2], data[3], data[4], data[5] };
  178|     36|  coap_add_token(request, sizeof(token), token);
  179|       |
  180|       |  /* Add options in monotonically increasing number order, since
  181|       |   * coap_add_option doesn't reorder. Numbers below from coap_option.h:
  182|       |   *   IF_MATCH=1  URI_HOST=3  URI_PORT=7  URI_PATH=11  PROXY_URI=35
  183|       |   *   PROXY_SCHEME=39  SIZE1=60  ...
  184|       |   */
  185|     36|  proxy_cursor_t c = { data + 6, size - 6, 0 };
  186|       |
  187|       |  /* URI-Host (option 3). Pull a small slice — the proxy uses this together
  188|       |   * with Proxy-Scheme to compute the upstream target. */
  189|     36|  {
  190|     36|    size_t n;
  191|     36|    const uint8_t *p = proxy_take(&c, 32, &n);
  192|     36|    if (n)
  ------------------
  |  Branch (192:9): [True: 36, False: 0]
  ------------------
  193|     36|      coap_add_option(request, COAP_OPTION_URI_HOST, n, p);
  194|     36|  }
  195|       |
  196|       |  /* URI-Port (option 7). 2 bytes max, encodes as a CoAP varint internally. */
  197|     36|  {
  198|     36|    size_t n;
  199|     36|    const uint8_t *p = proxy_take(&c, 2, &n);
  200|     36|    if (n)
  ------------------
  |  Branch (200:9): [True: 21, False: 15]
  ------------------
  201|     21|      coap_add_option(request, COAP_OPTION_URI_PORT, n, p);
  202|     36|  }
  203|       |
  204|       |  /* URI-Path (option 11) — a couple of segments to drive option-walk code. */
  205|    108|  for (int i = 0; i < 2; i++) {
  ------------------
  |  Branch (205:19): [True: 72, False: 36]
  ------------------
  206|     72|    size_t n;
  207|     72|    const uint8_t *p = proxy_take(&c, 16, &n);
  208|     72|    if (n)
  ------------------
  |  Branch (208:9): [True: 41, False: 31]
  ------------------
  209|     41|      coap_add_option(request, COAP_OPTION_URI_PATH, n, p);
  210|     72|  }
  211|       |
  212|       |  /* Submode (bits 5-6 of mode) selects which proxy target option(s) we set:
  213|       |   *   0: Proxy-Scheme only  — drives coap_get_uri_proxy_scheme_info
  214|       |   *   1: Proxy-Uri only     — drives coap_split_proxy_uri
  215|       |   *   2: both               — proxy code prefers Proxy-Uri but parses both
  216|       |   *   3: neither            — exercises the "404 no proxy info" path
  217|       |   */
  218|     36|  uint8_t submode = (mode >> 5) & 0x03;
  219|       |
  220|     36|  if (submode == 0 || submode == 2) {
  ------------------
  |  Branch (220:7): [True: 10, False: 26]
  |  Branch (220:23): [True: 6, False: 20]
  ------------------
  221|       |    /* Proxy-Scheme value (option 39). The parser at coap_proxy.c:222-249
  222|       |     * branches on opt_len 4/5/7/8/9 to identify "coap" / "coaps" / "coap+ws"
  223|       |     * / "coap+tcp" / "coaps+tcp" — we want the fuzzer to discover those. */
  224|     16|    size_t n;
  225|     16|    const uint8_t *p = proxy_take(&c, 9, &n);
  226|     16|    if (n)
  ------------------
  |  Branch (226:9): [True: 10, False: 6]
  ------------------
  227|     10|      coap_add_option(request, COAP_OPTION_PROXY_SCHEME, n, p);
  228|     16|  }
  229|     36|  if (submode == 1 || submode == 2) {
  ------------------
  |  Branch (229:7): [True: 16, False: 20]
  |  Branch (229:23): [True: 6, False: 14]
  ------------------
  230|       |    /* Proxy-Uri value (option 35). Up to 1034 bytes per RFC 7252 — we cap at
  231|       |     * 256 to leave room for payload. The parser is coap_split_proxy_uri. */
  232|     22|    size_t n;
  233|     22|    const uint8_t *p = proxy_take(&c, 256, &n);
  234|     22|    if (n)
  ------------------
  |  Branch (234:9): [True: 14, False: 8]
  ------------------
  235|     14|      coap_add_option(request, COAP_OPTION_PROXY_URI, n, p);
  236|     22|  }
  237|       |
  238|       |  /* Optional Observe option (bit 7 of mode, 4 bytes max). Triggers the proxy's
  239|       |   * observe-cache logic if a proxy_response_cb were registered. */
  240|     36|  if ((mode >> 7) & 0x01) {
  ------------------
  |  Branch (240:7): [True: 18, False: 18]
  ------------------
  241|     18|    size_t n;
  242|     18|    const uint8_t *p = proxy_take(&c, 4, &n);
  243|     18|    if (n)
  ------------------
  |  Branch (243:9): [True: 4, False: 14]
  ------------------
  244|      4|      coap_add_option(request, COAP_OPTION_OBSERVE, n, p);
  245|     18|  }
  246|       |
  247|       |  /* Remaining bytes become the request body. */
  248|     36|  {
  249|     36|    size_t n;
  250|     36|    const uint8_t *p = proxy_take(&c, c.size > c.pos ? c.size - c.pos : 0, &n);
  ------------------
  |  Branch (250:39): [True: 14, False: 22]
  ------------------
  251|     36|    if (n)
  ------------------
  |  Branch (251:9): [True: 14, False: 22]
  ------------------
  252|     14|      coap_add_data(request, n, p);
  253|     36|  }
  254|       |
  255|       |  /* Response PDU the proxy fills in (with an error code on failure). */
  256|     36|  response = coap_pdu_init(COAP_MESSAGE_ACK, 0,
  257|     36|                           coap_new_message_id(req_session), max_pdu);
  258|     36|  if (!response)
  ------------------
  |  Branch (258:7): [True: 0, False: 36]
  ------------------
  259|      0|    goto cleanup;
  260|       |
  261|       |  /* The single API call we're here to fuzz. */
  262|     36|  coap_proxy_forward_request(req_session, request, response, resource, NULL,
  263|     36|                             &server_list);
  264|       |
  265|     36|cleanup:
  266|     36|  if (request)
  ------------------
  |  Branch (266:7): [True: 36, False: 0]
  ------------------
  267|     36|    coap_delete_pdu(request);
  268|     36|  if (response)
  ------------------
  |  Branch (268:7): [True: 36, False: 0]
  ------------------
  269|     36|    coap_delete_pdu(response);
  270|       |  /* Don't release req_session manually — coap_free_context iterates
  271|       |   * ctx->sessions and releases each (same idiom as the other harnesses). */
  272|     36|  if (ctx)
  ------------------
  |  Branch (272:7): [True: 36, False: 0]
  ------------------
  273|     36|    coap_free_context(ctx);
  274|     36|  coap_cleanup();
  275|     36|  return 0;
  276|     36|}
proxy_target.c:proxy_take:
   58|    236|proxy_take(proxy_cursor_t *c, size_t max, size_t *out_len) {
   59|    236|  size_t avail = c->size > c->pos ? c->size - c->pos : 0;
  ------------------
  |  Branch (59:18): [True: 140, False: 96]
  ------------------
   60|    236|  size_t take = avail < max ? avail : max;
  ------------------
  |  Branch (60:17): [True: 96, False: 140]
  ------------------
   61|    236|  const uint8_t *p = c->data + c->pos;
   62|    236|  c->pos += take;
   63|    236|  *out_len = take;
   64|    236|  return p;
   65|    236|}

