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

coap_address_set_port:
   87|     39|coap_address_set_port(coap_address_t *addr, uint16_t port) {
   88|     39|  assert(addr != NULL);
  ------------------
  |  Branch (88:3): [True: 39, False: 0]
  ------------------
   89|     39|  switch (addr->addr.sa.sa_family) {
   90|      0|#if COAP_IPV4_SUPPORT
   91|     39|  case AF_INET:
  ------------------
  |  Branch (91:3): [True: 39, False: 0]
  ------------------
   92|     39|    addr->addr.sin.sin_port = htons(port);
   93|     39|    break;
   94|      0|#endif /* COAP_IPV4_SUPPORT */
   95|      0|#if COAP_IPV6_SUPPORT
   96|      0|  case AF_INET6:
  ------------------
  |  Branch (96:3): [True: 0, False: 39]
  ------------------
   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: 39]
  ------------------
  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: 39]
  ------------------
  105|      0|    ;
  106|     39|  }
  107|     39|}
coap_address_equals:
  129|     39|coap_address_equals(const coap_address_t *a, const coap_address_t *b) {
  130|     39|  assert(a);
  ------------------
  |  Branch (130:3): [True: 39, False: 0]
  ------------------
  131|     39|  assert(b);
  ------------------
  |  Branch (131:3): [True: 39, False: 0]
  ------------------
  132|       |
  133|     39|  if (a->size != b->size || a->addr.sa.sa_family != b->addr.sa.sa_family)
  ------------------
  |  Branch (133:7): [True: 0, False: 39]
  |  Branch (133:29): [True: 0, False: 39]
  ------------------
  134|      0|    return 0;
  135|       |
  136|       |  /* need to compare only relevant parts of sockaddr_in6 */
  137|     39|  switch (a->addr.sa.sa_family) {
  138|      0|#if COAP_IPV4_SUPPORT
  139|     39|  case AF_INET:
  ------------------
  |  Branch (139:3): [True: 39, False: 0]
  ------------------
  140|     39|    return a->addr.sin.sin_port == b->addr.sin.sin_port &&
  ------------------
  |  Branch (140:12): [True: 26, False: 13]
  ------------------
  141|     26|           memcmp(&a->addr.sin.sin_addr, &b->addr.sin.sin_addr,
  ------------------
  |  Branch (141:12): [True: 26, False: 0]
  ------------------
  142|     26|                  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: 39]
  ------------------
  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: 39]
  ------------------
  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: 39]
  ------------------
  156|      0|    ;
  157|     39|  }
  158|      0|  return 0;
  159|     39|}
coap_is_af_unix:
  162|     13|coap_is_af_unix(const coap_address_t *a) {
  163|     13|#if COAP_AF_UNIX_SUPPORT
  164|     13|  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|     13|}
coap_is_af_llc:
  172|     43|coap_is_af_llc(const coap_address_t *a) {
  173|     43|#if COAP_AF_LLC_SUPPORT
  174|     43|  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|     43|}
coap_is_mcast:
  182|     72|coap_is_mcast(const coap_address_t *a) {
  183|     72|  if (!a)
  ------------------
  |  Branch (183:7): [True: 0, False: 72]
  ------------------
  184|      0|    return 0;
  185|       |
  186|       |  /* Treat broadcast in same way as multicast */
  187|     72|  if (coap_is_bcast(a))
  ------------------
  |  Branch (187:7): [True: 0, False: 72]
  ------------------
  188|      0|    return 1;
  189|       |
  190|     72|  switch (a->addr.sa.sa_family) {
  191|      0|#if COAP_IPV4_SUPPORT
  192|     72|  case AF_INET:
  ------------------
  |  Branch (192:3): [True: 72, False: 0]
  ------------------
  193|     72|    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: 72]
  ------------------
  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: 72]
  ------------------
  206|      0|    ;
  207|     72|  }
  208|      0|  return 0;
  209|     72|}
coap_is_bcast:
  227|     72|coap_is_bcast(const coap_address_t *a) {
  228|     72|#if COAP_IPV4_SUPPORT
  229|     72|  struct in_addr ipv4;
  230|     72|#if defined(HAVE_GETIFADDRS) && !defined(__ZEPHYR__)
  231|     72|  int i;
  232|     72|  coap_tick_t now;
  233|     72|#endif /* HAVE_GETIFADDRS && !defined(__ZEPHYR__) */
  234|     72|#endif /* COAP_IPV4_SUPPORT */
  235|       |
  236|     72|  if (!a)
  ------------------
  |  Branch (236:7): [True: 0, False: 72]
  ------------------
  237|      0|    return 0;
  238|       |
  239|     72|  switch (a->addr.sa.sa_family) {
  240|      0|#if COAP_IPV4_SUPPORT
  241|     72|  case AF_INET:
  ------------------
  |  Branch (241:3): [True: 72, False: 0]
  ------------------
  242|     72|    ipv4.s_addr = a->addr.sin.sin_addr.s_addr;
  243|     72|    break;
  244|      0|#endif /* COAP_IPV4_SUPPORT */
  245|      0|#if COAP_IPV6_SUPPORT
  246|      0|  case  AF_INET6:
  ------------------
  |  Branch (246:3): [True: 0, False: 72]
  ------------------
  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: 72]
  ------------------
  257|      0|    return 0;
  258|     72|  }
  259|     72|#if COAP_IPV4_SUPPORT
  260|       |#ifndef INADDR_BROADCAST
  261|       |#define INADDR_BROADCAST ((uint32_t)0xffffffffUL)
  262|       |#endif /* !INADDR_BROADCAST */
  263|     72|  if (ipv4.s_addr == INADDR_BROADCAST)
  ------------------
  |  Branch (263:7): [True: 0, False: 72]
  ------------------
  264|      0|    return 1;
  265|       |
  266|     72|#if defined(HAVE_GETIFADDRS) && !defined(__ZEPHYR__)
  267|     72|  coap_ticks(&now);
  268|     72|  if (bcst_cnt == -1 ||
  ------------------
  |  Branch (268:7): [True: 1, False: 71]
  ------------------
  269|     71|      (now - last_refresh) > (COAP_BCST_REFRESH_SECS * COAP_TICKS_PER_SECOND)) {
  ------------------
  |  |  217|     71|#define COAP_BCST_REFRESH_SECS 30
  ------------------
                    (now - last_refresh) > (COAP_BCST_REFRESH_SECS * COAP_TICKS_PER_SECOND)) {
  ------------------
  |  |  164|     71|#define COAP_TICKS_PER_SECOND ((coap_tick_t)(1000U))
  ------------------
  |  Branch (269:7): [True: 0, False: 71]
  ------------------
  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|    144|  for (i = 0; i < bcst_cnt; i++) {
  ------------------
  |  Branch (304:15): [True: 72, False: 72]
  ------------------
  305|     72|    if (ipv4.s_addr == b_ipv4[i].s_addr)
  ------------------
  |  Branch (305:9): [True: 0, False: 72]
  ------------------
  306|      0|      return 1;
  307|     72|  }
  308|     72|#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|     72|#endif /* COAP_IPV4_SUPPORT */
  377|     72|  return 0;
  378|     72|}
coap_address_init:
  383|    155|coap_address_init(coap_address_t *addr) {
  384|    155|  assert(addr);
  ------------------
  |  Branch (384:3): [True: 155, False: 0]
  ------------------
  385|    155|  memset(addr, 0, sizeof(coap_address_t));
  386|    155|#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|    155|  addr->size = sizeof(addr->addr);
  389|    155|#endif
  390|    155|}
coap_resolve_address_info_lkd:
  730|     13|                              coap_resolve_type_t type) {
  731|       |
  732|     13|  struct addrinfo *res, *ainfo;
  733|     13|  struct addrinfo hints;
  734|       |#if COAP_CONSTRAINED_STACK
  735|       |  static char addrstr[256];
  736|       |#else /* ! COAP_CONSTRAINED_STACK */
  737|     13|  char addrstr[256];
  738|     13|#endif /* ! COAP_CONSTRAINED_STACK */
  739|     13|  int error;
  740|     13|  coap_addr_info_t *info = NULL;
  741|     13|  coap_addr_info_t *info_prev = NULL;
  742|     13|  coap_addr_info_t *info_list = NULL;
  743|     13|  coap_addr_info_t *info_tmp;
  744|     13|  coap_uri_scheme_t scheme;
  745|       |
  746|     13|  coap_lock_check_locked();
  ------------------
  |  |  638|     13|#define coap_lock_check_locked() {}
  ------------------
  747|       |
  748|     13|#if COAP_AF_UNIX_SUPPORT
  749|     13|  if (address && coap_host_is_unix_domain(address)) {
  ------------------
  |  Branch (749:7): [True: 13, False: 0]
  |  Branch (749:18): [True: 0, False: 13]
  ------------------
  750|       |    /* There can only be one unique filename entry for AF_UNIX */
  751|      0|    if (address->length >= COAP_UNIX_PATH_MAX) {
  ------------------
  |  |  186|      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|     13|#endif /* COAP_AF_UNIX_SUPPORT */
  777|     13|#if COAP_AF_LLC_SUPPORT
  778|     13|  if (address && coap_host_is_llc(address)) {
  ------------------
  |  Branch (778:7): [True: 13, False: 0]
  |  Branch (778:18): [True: 0, False: 13]
  ------------------
  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|     13|#endif /* COAP_AF_LLC_SUPPORT */
  800|       |
  801|     13|  memset(addrstr, 0, sizeof(addrstr));
  802|     13|  if (address && address->length) {
  ------------------
  |  Branch (802:7): [True: 13, False: 0]
  |  Branch (802:18): [True: 13, False: 0]
  ------------------
  803|     13|    if (address->length >= sizeof(addrstr)) {
  ------------------
  |  Branch (803:9): [True: 0, False: 13]
  ------------------
  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|     13|    memcpy(addrstr, address->s, address->length);
  808|     13|  } else {
  809|      0|    memcpy(addrstr, "localhost", 9);
  810|      0|  }
  811|       |
  812|     13|  memset((char *)&hints, 0, sizeof(hints));
  813|     13|  hints.ai_socktype = 0;
  814|     13|  hints.ai_family = AF_UNSPEC;
  815|     13|  hints.ai_flags = ai_hints_flags;
  816|       |
  817|     13|  error = getaddrinfo(addrstr, NULL, &hints, &res);
  818|       |
  819|     13|  if (error != 0) {
  ------------------
  |  Branch (819:7): [True: 0, False: 13]
  ------------------
  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|     52|  for (ainfo = res; ainfo != NULL; ainfo = ainfo->ai_next) {
  ------------------
  |  Branch (828:21): [True: 39, False: 13]
  ------------------
  829|     39|#if !defined(WITH_LWIP)
  830|     39|    if (ainfo->ai_addrlen > (socklen_t)sizeof(info->addr.addr))
  ------------------
  |  Branch (830:9): [True: 0, False: 39]
  ------------------
  831|      0|      continue;
  832|     39|#endif /* ! WITH_LWIP */
  833|       |
  834|     39|    switch (ainfo->ai_family) {
  835|      0|#if COAP_IPV4_SUPPORT
  836|     39|    case AF_INET:
  ------------------
  |  Branch (836:5): [True: 39, False: 0]
  ------------------
  837|     39|#endif /* COAP_IPV4_SUPPORT */
  838|     39|#if COAP_IPV6_SUPPORT
  839|     39|    case AF_INET6:
  ------------------
  |  Branch (839:5): [True: 0, False: 39]
  ------------------
  840|     39|#endif /* COAP_IPV6_SUPPORT */
  841|    351|      for (scheme = 0; scheme < COAP_URI_SCHEME_LAST; scheme++) {
  ------------------
  |  Branch (841:24): [True: 312, False: 39]
  ------------------
  842|    312|        if (scheme_hint_bits & (1 << scheme)) {
  ------------------
  |  Branch (842:13): [True: 39, False: 273]
  ------------------
  843|     39|          info = get_coap_addr_info(scheme);
  844|     39|          if (info == NULL) {
  ------------------
  |  Branch (844:15): [True: 0, False: 39]
  ------------------
  845|      0|            continue;
  846|      0|          }
  847|       |
  848|     39|#if !defined(WITH_LWIP)
  849|     39|          info->addr.size = (socklen_t)ainfo->ai_addrlen;
  850|     39|          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|     39|          update_coap_addr_port(scheme, info, port, secure_port, ws_port,
  883|     39|                                ws_secure_port, type);
  884|       |
  885|       |          /* Check there are no duplications */
  886|     39|          info_tmp = info_list;
  887|     39|          while (info_tmp) {
  ------------------
  |  Branch (887:18): [True: 26, False: 13]
  ------------------
  888|     26|            if (info_tmp->proto == info->proto &&
  ------------------
  |  Branch (888:17): [True: 26, False: 0]
  ------------------
  889|     26|                info_tmp->scheme == info->scheme &&
  ------------------
  |  Branch (889:17): [True: 26, False: 0]
  ------------------
  890|     26|                coap_address_equals(&info_tmp->addr, &info->addr)) {
  ------------------
  |  Branch (890:17): [True: 26, False: 0]
  ------------------
  891|     26|              break;
  892|     26|            }
  893|      0|            info_tmp = info_tmp->next;
  894|      0|          }
  895|       |
  896|     39|          if (info_tmp) {
  ------------------
  |  Branch (896:15): [True: 26, False: 13]
  ------------------
  897|       |            /* Duplicate */
  898|     26|            coap_free_type(COAP_STRING, info);
  899|     26|          } else {
  900|       |            /* Need to return in same order as getaddrinfo() */
  901|     13|            if (!info_prev) {
  ------------------
  |  Branch (901:17): [True: 13, False: 0]
  ------------------
  902|     13|              info_list = info;
  903|     13|              info_prev = info;
  904|     13|            } else {
  905|      0|              info_prev->next = info;
  906|      0|              info_prev = info;
  907|      0|            }
  908|     13|          }
  909|     39|        }
  910|    312|      }
  911|     39|      break;
  912|      0|    default:
  ------------------
  |  Branch (912:5): [True: 0, False: 39]
  ------------------
  913|      0|      break;
  914|     39|    }
  915|     39|  }
  916|       |
  917|     13|  freeaddrinfo(res);
  918|     13|  return info_list;
  919|     13|}
coap_free_address_info:
 1123|     13|coap_free_address_info(coap_addr_info_t *info) {
 1124|     26|  while (info) {
  ------------------
  |  Branch (1124:10): [True: 13, False: 13]
  ------------------
 1125|     13|    coap_addr_info_t *info_next = info->next;
 1126|       |
 1127|     13|    coap_free_type(COAP_STRING, info);
 1128|     13|    info = info_next;
 1129|     13|  }
 1130|     13|}
coap_address_copy:
 1134|     94|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|     94|  memset(dst, 0, sizeof(coap_address_t));
 1139|     94|  dst->size = src->size;
 1140|     94|#if COAP_IPV6_SUPPORT
 1141|     94|  if (src->addr.sa.sa_family == AF_INET6) {
  ------------------
  |  Branch (1141:7): [True: 0, False: 94]
  ------------------
 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|     94|#endif /* COAP_IPV6_SUPPORT */
 1148|     94|#if COAP_IPV4_SUPPORT && COAP_IPV6_SUPPORT
 1149|     94|  else
 1150|     94|#endif /* COAP_IPV4_SUPPORT && COAP_IPV6_SUPPORT */
 1151|     94|#if COAP_IPV4_SUPPORT
 1152|     94|    if (src->addr.sa.sa_family == AF_INET) {
  ------------------
  |  Branch (1152:9): [True: 94, False: 0]
  ------------------
 1153|     94|      dst->addr.sin = src->addr.sin;
 1154|     94|    }
 1155|      0|#endif /* COAP_IPV4_SUPPORT */
 1156|      0|    else {
 1157|      0|      memcpy(&dst->addr, &src->addr, src->size);
 1158|      0|    }
 1159|     94|#endif
 1160|     94|}
coap_address.c:get_coap_addr_info:
  564|     39|get_coap_addr_info(coap_uri_scheme_t scheme) {
  565|     39|  coap_addr_info_t *info = NULL;
  566|     39|  coap_proto_t proto = 0;
  567|       |
  568|     39|  switch (scheme) {
  569|     39|  case COAP_URI_SCHEME_COAP:
  ------------------
  |  Branch (569:3): [True: 39, False: 0]
  ------------------
  570|     39|    proto = COAP_PROTO_UDP;
  571|     39|    break;
  572|      0|  case COAP_URI_SCHEME_COAPS:
  ------------------
  |  Branch (572:3): [True: 0, False: 39]
  ------------------
  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: 39]
  ------------------
  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: 39]
  ------------------
  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: 39]
  ------------------
  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: 39]
  ------------------
  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: 39]
  ------------------
  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: 39]
  ------------------
  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: 39]
  ------------------
  608|      0|  default:
  ------------------
  |  Branch (608:3): [True: 0, False: 39]
  ------------------
  609|      0|    return NULL;
  610|     39|  }
  611|     39|  info = coap_malloc_type(COAP_STRING, sizeof(coap_addr_info_t));
  612|     39|  if (info == NULL)
  ------------------
  |  Branch (612:7): [True: 0, False: 39]
  ------------------
  613|      0|    return NULL;
  614|     39|  info->next = NULL;
  615|     39|  info->proto = proto;
  616|     39|  info->scheme = scheme;
  617|       |
  618|     39|  coap_address_init(&info->addr);
  619|     39|  return info;
  620|     39|}
coap_address.c:update_coap_addr_port:
  626|     39|                      coap_resolve_type_t type) {
  627|     39|  switch (scheme) {
  628|     39|  case COAP_URI_SCHEME_COAP:
  ------------------
  |  Branch (628:3): [True: 39, False: 0]
  ------------------
  629|     39|    update_port(&info->addr, port, COAP_DEFAULT_PORT,
  ------------------
  |  |   39|     39|#define COAP_DEFAULT_PORT      5683 /* CoAP default UDP/TCP port */
  ------------------
  630|     39|                type == COAP_RESOLVE_TYPE_LOCAL);
  631|     39|    break;
  632|      0|  case COAP_URI_SCHEME_COAPS:
  ------------------
  |  Branch (632:3): [True: 0, False: 39]
  ------------------
  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: 39]
  ------------------
  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: 39]
  ------------------
  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: 39]
  ------------------
  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: 39]
  ------------------
  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: 39]
  ------------------
  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: 39]
  ------------------
  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: 39]
  ------------------
  661|      0|  default:
  ------------------
  |  Branch (661:3): [True: 0, False: 39]
  ------------------
  662|      0|    break;
  663|     39|  }
  664|     39|}
coap_address.c:update_port:
  478|     39|            int update_port0) {
  479|       |  /* Client target port must be set if default of 0 */
  480|     39|  if (port == 0 && update_port0)
  ------------------
  |  Branch (480:7): [True: 39, False: 0]
  |  Branch (480:20): [True: 0, False: 39]
  ------------------
  481|      0|    port = default_port;
  482|       |
  483|     39|  coap_address_set_port(addr, port);
  484|     39|  return;
  485|     39|}

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

coap_add_data_large_request_lkd:
 1415|      1|                                void *app_ptr) {
 1416|       |  /*
 1417|       |   * Delay if session->doing_first is set.
 1418|       |   * E.g. Reliable and CSM not in yet for checking block support
 1419|       |   */
 1420|      1|  if (coap_client_delay_first(session) == 0) {
  ------------------
  |  Branch (1420:7): [True: 0, False: 1]
  ------------------
 1421|      0|    if (release_func) {
  ------------------
  |  Branch (1421:9): [True: 0, False: 0]
  ------------------
 1422|      0|      coap_lock_callback(release_func(session, app_ptr));
  ------------------
  |  |  651|      0|#define coap_lock_callback(func) func
  ------------------
 1423|      0|    }
 1424|      0|    return 0;
 1425|      0|  }
 1426|      1|  return coap_add_data_large_internal(session, NULL, pdu, NULL, NULL, -1, 0,
 1427|       |                                      length, data, release_func, NULL, app_ptr, 0, 0);
 1428|      1|}
coap_block.c:coap_add_data_large_internal:
  846|      1|                             int single_request, coap_pdu_code_t request_method) {
  847|       |
  848|      1|  ssize_t avail;
  849|      1|  coap_block_b_t block;
  850|      1|#if COAP_Q_BLOCK_SUPPORT
  851|      1|  coap_block_b_t alt_block;
  852|      1|#endif /* COAP_Q_BLOCK_SUPPORT */
  853|      1|  size_t chunk;
  854|      1|  coap_lg_xmit_t *lg_xmit = NULL;
  855|      1|  uint8_t buf[8];
  856|      1|  int have_block_defined = 0;
  857|      1|  uint8_t blk_size;
  858|      1|  uint8_t max_blk_size;
  859|      1|  uint16_t option;
  860|      1|  size_t token_options;
  861|      1|  coap_opt_t *opt;
  862|      1|  coap_opt_iterator_t opt_iter;
  863|      1|#if COAP_Q_BLOCK_SUPPORT
  864|      1|  uint16_t alt_option;
  865|      1|#endif /* COAP_Q_BLOCK_SUPPORT */
  866|       |
  867|       |#if !COAP_SERVER_SUPPORT
  868|       |  (void)etag;
  869|       |#endif /* COAP_SERVER_SUPPORT */
  870|       |
  871|      1|  assert(pdu);
  ------------------
  |  Branch (871:3): [True: 1, False: 0]
  ------------------
  872|      1|  if (pdu->data) {
  ------------------
  |  Branch (872:7): [True: 0, False: 1]
  ------------------
  873|      0|    coap_log_warn("coap_add_data_large: 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  874|      0|    if (release_func) {
  ------------------
  |  Branch (874:9): [True: 0, False: 0]
  ------------------
  875|      0|      coap_lock_callback(release_func(session, app_ptr));
  ------------------
  |  |  651|      0|#define coap_lock_callback(func) func
  ------------------
  876|      0|    }
  877|      0|    return 0;
  878|      0|  }
  879|       |
  880|      1|  if (!(session->block_mode & COAP_BLOCK_USE_LIBCOAP)) {
  ------------------
  |  |   65|      1|#define COAP_BLOCK_USE_LIBCOAP  0x01 /* Use libcoap to do block requests */
  ------------------
  |  Branch (880:7): [True: 1, False: 0]
  ------------------
  881|      1|    coap_log_debug("** %s: coap_add_data_large: COAP_BLOCK_USE_LIBCOAP not enabled\n",
  ------------------
  |  |  126|      1|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      1|#define coap_log(level, ...) do { \
  |  |  |  |  291|      1|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  292|      1|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      1|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  882|      1|                   coap_session_str(session));
  883|      1|    goto add_data;
  884|      1|  }
  885|       |
  886|       |  /* A lot of the reliable code assumes type is CON */
  887|      0|  if (COAP_PROTO_RELIABLE(session->proto) && pdu->type == COAP_MESSAGE_NON)
  ------------------
  |  |   42|      0|#define COAP_PROTO_RELIABLE(p) ((p)==COAP_PROTO_TCP || (p)==COAP_PROTO_TLS || \
  |  |  ------------------
  |  |  |  Branch (42:33): [True: 0, False: 0]
  |  |  |  Branch (42:56): [True: 0, False: 0]
  |  |  ------------------
  |  |   43|      0|                                (p)==COAP_PROTO_WS || (p)==COAP_PROTO_WSS)
  |  |  ------------------
  |  |  |  Branch (43:33): [True: 0, False: 0]
  |  |  |  Branch (43:55): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (887:46): [True: 0, False: 0]
  ------------------
  888|      0|    pdu->type = COAP_MESSAGE_CON;
  889|       |
  890|       |  /* Block NUM max 20 bits (starting from 0) and block size is "2**(SZX + 4)"
  891|       |     and using SZX max of 6 gives maximum size = 1,073,740,800
  892|       |     CSM Max-Message-Size theoretical maximum = 4,294,967,295
  893|       |     So, if using blocks, we are limited to 1,073,740,800.
  894|       |   */
  895|      0|#define MAX_BLK_LEN ((1UL << 20) * (1 << (6 + 4)))
  896|       |#if UINT_MAX < MAX_BLK_LEN
  897|       |#undef MAX_BLK_LEN
  898|       |#define MAX_BLK_LEN UINT_MAX
  899|       |#endif
  900|       |
  901|      0|  if (length > MAX_BLK_LEN) {
  ------------------
  |  |  895|      0|#define MAX_BLK_LEN ((1UL << 20) * (1 << (6 + 4)))
  ------------------
  |  Branch (901:7): [True: 0, False: 0]
  ------------------
  902|      0|    coap_log_warn("Size of large buffer restricted to 0x%lx bytes\n", MAX_BLK_LEN);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  903|      0|    length = MAX_BLK_LEN;
  ------------------
  |  |  895|      0|#define MAX_BLK_LEN ((1UL << 20) * (1 << (6 + 4)))
  ------------------
  904|      0|  }
  905|       |
  906|      0|#if COAP_SERVER_SUPPORT
  907|       |  /* Possible response code not yet set, so check if not request */
  908|      0|  if (!COAP_PDU_IS_REQUEST(pdu) && length) {
  ------------------
  |  |   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 (908:36): [True: 0, False: 0]
  ------------------
  909|      0|    coap_opt_t *etag_opt = coap_check_option(pdu, COAP_OPTION_ETAG, &opt_iter);
  910|       |
  911|      0|    if (etag_opt) {
  ------------------
  |  Branch (911:9): [True: 0, False: 0]
  ------------------
  912|       |      /* Have to use ETag as supplied in the response PDU */
  913|      0|      etag = coap_decode_var_bytes8(coap_opt_value(etag_opt),
  914|      0|                                    coap_opt_length(etag_opt));
  915|      0|    } else {
  916|      0|      if (!etag) {
  ------------------
  |  Branch (916:11): [True: 0, False: 0]
  ------------------
  917|       |        /* calculate ETag for the response */
  918|      0|        coap_digest_t digest;
  919|      0|        coap_digest_ctx_t *dctx =  coap_digest_setup();
  920|       |
  921|      0|        if (dctx) {
  ------------------
  |  Branch (921:13): [True: 0, False: 0]
  ------------------
  922|      0|          if (coap_is_mcast(&session->addr_info.local)) {
  ------------------
  |  Branch (922:15): [True: 0, False: 0]
  ------------------
  923|      0|            (void)coap_digest_update(dctx, coap_unique_id, sizeof(coap_unique_id));
  924|      0|          }
  925|      0|          if (coap_digest_update(dctx, data, length)) {
  ------------------
  |  Branch (925:15): [True: 0, False: 0]
  ------------------
  926|      0|            if (coap_digest_final(dctx, &digest)) {
  ------------------
  |  Branch (926:17): [True: 0, False: 0]
  ------------------
  927|      0|              memcpy(&etag, digest.key, sizeof(etag));
  928|      0|#if COAP_ETAG_MAX_BYTES != 8
  929|      0|              etag = etag >> 8*(8 - COAP_ETAG_MAX_BYTES);
  ------------------
  |  |   26|      0|#define COAP_ETAG_MAX_BYTES 4
  ------------------
  930|      0|#endif
  931|      0|              dctx = NULL;
  932|      0|            }
  933|      0|          }
  934|      0|          coap_digest_free(dctx);
  935|      0|        }
  936|      0|        if (!etag)
  ------------------
  |  Branch (936:13): [True: 0, False: 0]
  ------------------
  937|      0|          etag = 1;
  938|      0|      }
  939|      0|      coap_update_option(pdu,
  940|      0|                         COAP_OPTION_ETAG,
  941|      0|                         coap_encode_var_safe8(buf, sizeof(buf), etag),
  942|      0|                         buf);
  943|      0|    }
  944|      0|    if (request) {
  ------------------
  |  Branch (944:9): [True: 0, False: 0]
  ------------------
  945|      0|      etag_opt = coap_check_option(request, COAP_OPTION_ETAG, &opt_iter);
  946|      0|      if (etag_opt) {
  ------------------
  |  Branch (946:11): [True: 0, False: 0]
  ------------------
  947|       |        /* There may be multiple ETag - need to check each one */
  948|      0|        coap_option_iterator_init(request, &opt_iter, COAP_OPT_ALL);
  ------------------
  |  |  230|      0|#define COAP_OPT_ALL NULL
  ------------------
  949|      0|        while ((etag_opt = coap_option_next(&opt_iter))) {
  ------------------
  |  Branch (949:16): [True: 0, False: 0]
  ------------------
  950|      0|          if (opt_iter.number == COAP_OPTION_ETAG) {
  ------------------
  |  Branch (950:15): [True: 0, False: 0]
  ------------------
  951|      0|            uint64_t etag_r = coap_decode_var_bytes8(coap_opt_value(etag_opt),
  952|      0|                                                     coap_opt_length(etag_opt));
  953|       |
  954|      0|            if (etag == etag_r) {
  ------------------
  |  Branch (954:17): [True: 0, False: 0]
  ------------------
  955|      0|              pdu->code = COAP_RESPONSE_CODE(203);
  ------------------
  |  |   96|      0|#define COAP_RESPONSE_CODE(N) (((N)/100 << 5) | (N)%100)
  ------------------
  956|      0|              return 1;
  957|      0|            }
  958|      0|          }
  959|      0|        }
  960|      0|      }
  961|      0|    }
  962|      0|  }
  963|      0|#endif /* COAP_SERVER_SUPPORT */
  964|       |
  965|       |  /* Determine the block size to use, adding in sensible options if needed */
  966|      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]
  |  |  ------------------
  ------------------
  967|      0|    coap_lg_xmit_t *q;
  968|       |
  969|      0|#if COAP_Q_BLOCK_SUPPORT
  970|      0|    if (session->block_mode & (COAP_BLOCK_HAS_Q_BLOCK|COAP_BLOCK_TRY_Q_BLOCK)) {
  ------------------
  |  |   71|      0|#define COAP_BLOCK_HAS_Q_BLOCK   0x40000000 /* Set when Q_BLOCK supported */
  ------------------
                  if (session->block_mode & (COAP_BLOCK_HAS_Q_BLOCK|COAP_BLOCK_TRY_Q_BLOCK)) {
  ------------------
  |  |   67|      0|#define COAP_BLOCK_TRY_Q_BLOCK   0x04 /* Try Q-Block method */
  ------------------
  |  Branch (970:9): [True: 0, False: 0]
  ------------------
  971|      0|      option = COAP_OPTION_Q_BLOCK1;
  972|      0|      alt_option = COAP_OPTION_BLOCK1;
  973|      0|    } else {
  974|      0|      option = COAP_OPTION_BLOCK1;
  975|      0|      alt_option = COAP_OPTION_Q_BLOCK1;
  976|      0|    }
  977|       |#else /* ! COAP_Q_BLOCK_SUPPORT */
  978|       |    if (coap_get_block_b(session, pdu, COAP_OPTION_Q_BLOCK1, &block)) {
  979|       |      coap_remove_option(pdu, COAP_OPTION_Q_BLOCK1);
  980|       |    }
  981|       |    option = COAP_OPTION_BLOCK1;
  982|       |#endif /* ! COAP_Q_BLOCK_SUPPORT */
  983|       |
  984|       |    /* See if this token is already in use for large bodies (unlikely) */
  985|      0|    LL_FOREACH_SAFE(session->lg_xmit, lg_xmit, q) {
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  986|      0|      if (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]
  |  |  ------------------
  ------------------
  987|       |        /* Unfortunately need to free this off as potential size change */
  988|      0|        int is_mcast = 0;
  989|      0|        coap_tick_t last_all_sent = lg_xmit->last_all_sent;
  990|      0|#if COAP_CLIENT_SUPPORT
  991|      0|        is_mcast = coap_is_mcast(&lg_xmit->b.b1.upstream);
  992|      0|#endif /* COAP_CLIENT_SUPPORT */
  993|      0|        LL_DELETE(session->lg_xmit, lg_xmit);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  994|      0|        coap_block_delete_lg_xmit(session, lg_xmit);
  995|      0|        lg_xmit = NULL;
  996|      0|        if (!is_mcast && !last_all_sent)
  ------------------
  |  Branch (996:13): [True: 0, False: 0]
  |  Branch (996:26): [True: 0, False: 0]
  ------------------
  997|      0|          coap_handle_event_lkd(session->context, COAP_EVENT_XMIT_BLOCK_FAIL, session);
  998|      0|        break;
  999|      0|      }
 1000|      0|    }
 1001|      0|  } else {
 1002|       |    /* Have to assume that it is a response even if code is 0.00 */
 1003|      0|    assert(resource);
  ------------------
  |  Branch (1003:5): [True: 0, False: 0]
  ------------------
 1004|      0|#if COAP_Q_BLOCK_SUPPORT
 1005|      0|    if (session->block_mode & COAP_BLOCK_HAS_Q_BLOCK) {
  ------------------
  |  |   71|      0|#define COAP_BLOCK_HAS_Q_BLOCK   0x40000000 /* Set when Q_BLOCK supported */
  ------------------
  |  Branch (1005:9): [True: 0, False: 0]
  ------------------
 1006|      0|      option = COAP_OPTION_Q_BLOCK2;
 1007|      0|      alt_option = COAP_OPTION_BLOCK2;
 1008|      0|    } else {
 1009|      0|      option = COAP_OPTION_BLOCK2;
 1010|      0|      alt_option = COAP_OPTION_Q_BLOCK2;
 1011|      0|    }
 1012|       |#else /* ! COAP_Q_BLOCK_SUPPORT */
 1013|       |    if (coap_get_block_b(session, pdu, COAP_OPTION_Q_BLOCK2, &block)) {
 1014|       |      coap_remove_option(pdu, COAP_OPTION_Q_BLOCK2);
 1015|       |    }
 1016|       |    option = COAP_OPTION_BLOCK2;
 1017|       |#endif /* ! COAP_Q_BLOCK_SUPPORT */
 1018|      0|#if COAP_SERVER_SUPPORT
 1019|       |    /*
 1020|       |     * Check if resource+query+rtag is already in use for large bodies
 1021|       |     * (unlikely)
 1022|       |     */
 1023|      0|    lg_xmit = coap_find_lg_xmit_response(session, request, resource, query);
 1024|      0|    if (lg_xmit) {
  ------------------
  |  Branch (1024:9): [True: 0, False: 0]
  ------------------
 1025|      0|      coap_tick_t last_all_sent = lg_xmit->last_all_sent;
 1026|       |      /* Unfortunately need to free this off as potential size change */
 1027|      0|      LL_DELETE(session->lg_xmit, lg_xmit);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1028|      0|      coap_block_delete_lg_xmit(session, lg_xmit);
 1029|      0|      lg_xmit = NULL;
 1030|      0|      if (!last_all_sent)
  ------------------
  |  Branch (1030:11): [True: 0, False: 0]
  ------------------
 1031|      0|        coap_handle_event_lkd(session->context, COAP_EVENT_XMIT_BLOCK_FAIL, session);
 1032|      0|    }
 1033|      0|#endif /* COAP_SERVER_SUPPORT */
 1034|      0|  }
 1035|      0|#if COAP_OSCORE_SUPPORT
 1036|      0|  if (session->oscore_encryption) {
  ------------------
  |  Branch (1036:7): [True: 0, False: 0]
  ------------------
 1037|       |    /* Need to convert Proxy-Uri to Proxy-Scheme option if needed */
 1038|      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 (1038:37): [True: 0, False: 0]
  ------------------
 1039|      0|      goto fail;
 1040|      0|  }
 1041|      0|#endif /* COAP_OSCORE_SUPPORT */
 1042|       |
 1043|      0|  token_options = pdu->data ? (size_t)(pdu->data - pdu->token) : pdu->used_size;
  ------------------
  |  Branch (1043:19): [True: 0, False: 0]
  ------------------
 1044|      0|  avail = pdu->max_size - token_options;
 1045|       |  /* There may be a response with Echo option */
 1046|      0|  avail -= coap_opt_encode_size(COAP_OPTION_ECHO, 40);
 1047|      0|#if COAP_OSCORE_SUPPORT
 1048|      0|  avail -= coap_oscore_overhead(session, pdu);
 1049|      0|#endif /* COAP_OSCORE_SUPPORT */
 1050|       |  /* May need token of length 8, so account for this */
 1051|      0|  avail -= (pdu->actual_token.length < 8) ? 8 - pdu->actual_token.length : 0;
  ------------------
  |  Branch (1051:12): [True: 0, False: 0]
  ------------------
 1052|       |
 1053|      0|  if (avail < 16) {
  ------------------
  |  Branch (1053:7): [True: 0, False: 0]
  ------------------
 1054|      0|    blk_size = 0;
 1055|      0|  } else {
 1056|      0|    blk_size = coap_flsll((long long)avail) - 4 - 1;
 1057|      0|  }
 1058|      0|  if (blk_size > 6)
  ------------------
  |  Branch (1058:7): [True: 0, False: 0]
  ------------------
 1059|      0|    blk_size = 6;
 1060|       |
 1061|      0|  max_blk_size = COAP_BLOCK_MAX_SIZE_GET(session->block_mode);
  ------------------
  |  |   66|      0|#define COAP_BLOCK_MAX_SIZE_GET(a) (((a) & COAP_BLOCK_MAX_SIZE_MASK) >> COAP_BLOCK_MAX_SIZE_SHIFT)
  |  |  ------------------
  |  |  |  |   64|      0|#define COAP_BLOCK_MAX_SIZE_MASK 0x7000000 /* (svr)Mask to get the max supported block size */
  |  |  ------------------
  |  |               #define COAP_BLOCK_MAX_SIZE_GET(a) (((a) & COAP_BLOCK_MAX_SIZE_MASK) >> COAP_BLOCK_MAX_SIZE_SHIFT)
  |  |  ------------------
  |  |  |  |   65|      0|#define COAP_BLOCK_MAX_SIZE_SHIFT 24    /* (svr)Mask shift to get the max supported block size */
  |  |  ------------------
  ------------------
 1062|      0|  if (max_blk_size && blk_size > max_blk_size)
  ------------------
  |  Branch (1062:7): [True: 0, False: 0]
  |  Branch (1062:23): [True: 0, False: 0]
  ------------------
 1063|      0|    blk_size = max_blk_size;
 1064|       |
 1065|       |  /* see if BlockX defined - if so update blk_size as given by app */
 1066|      0|  if (coap_get_block_b(session, pdu, option, &block)) {
  ------------------
  |  Branch (1066:7): [True: 0, False: 0]
  ------------------
 1067|      0|    if (block.szx < blk_size)
  ------------------
  |  Branch (1067:9): [True: 0, False: 0]
  ------------------
 1068|      0|      blk_size = block.szx;
 1069|      0|    have_block_defined = 1;
 1070|      0|  }
 1071|      0|#if COAP_Q_BLOCK_SUPPORT
 1072|       |  /* see if alternate BlockX defined */
 1073|      0|  if (coap_get_block_b(session, pdu, alt_option, &alt_block)) {
  ------------------
  |  Branch (1073:7): [True: 0, False: 0]
  ------------------
 1074|      0|    if (have_block_defined) {
  ------------------
  |  Branch (1074:9): [True: 0, False: 0]
  ------------------
 1075|       |      /* Cannot have both options set */
 1076|      0|      coap_log_warn("Both BlockX and Q-BlockX cannot be set at the same time\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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1077|      0|      coap_remove_option(pdu, alt_option);
 1078|      0|    } else {
 1079|      0|      block = alt_block;
 1080|      0|      if (block.szx < blk_size)
  ------------------
  |  Branch (1080:11): [True: 0, False: 0]
  ------------------
 1081|      0|        blk_size = block.szx;
 1082|      0|      have_block_defined = 1;
 1083|      0|      option = alt_option;
 1084|      0|    }
 1085|      0|  }
 1086|      0|#endif /* COAP_Q_BLOCK_SUPPORT */
 1087|       |
 1088|      0|  if (avail < 16 && ((ssize_t)length > avail || have_block_defined)) {
  ------------------
  |  Branch (1088:7): [True: 0, False: 0]
  |  Branch (1088:22): [True: 0, False: 0]
  |  Branch (1088:49): [True: 0, False: 0]
  ------------------
 1089|       |    /* bad luck, this is the smallest block size */
 1090|      0|    coap_log_debug("not enough space, even the smallest block does not fit (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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1091|      0|    goto fail;
 1092|      0|  }
 1093|       |
 1094|      0|  chunk = (size_t)1 << (blk_size + 4);
 1095|      0|  if ((have_block_defined && block.num != 0) || single_request ||
  ------------------
  |  Branch (1095:8): [True: 0, False: 0]
  |  Branch (1095:30): [True: 0, False: 0]
  |  Branch (1095:49): [True: 0, False: 0]
  ------------------
 1096|      0|      ((session->block_mode & COAP_BLOCK_STLESS_BLOCK2) && session->type != COAP_SESSION_TYPE_CLIENT)) {
  ------------------
  |  |   71|      0|#define COAP_BLOCK_STLESS_BLOCK2 0x40 /* (svr)Server is stateless for handling Block2 */
  ------------------
  |  Branch (1096:8): [True: 0, False: 0]
  |  Branch (1096:60): [True: 0, False: 0]
  ------------------
 1097|       |    /* App is defining a single block to send or we are stateless */
 1098|      0|    size_t rem;
 1099|       |
 1100|      0|    if (length >= block.num * chunk) {
  ------------------
  |  Branch (1100:9): [True: 0, False: 0]
  ------------------
 1101|      0|#if COAP_SERVER_SUPPORT
 1102|      0|      if (session->block_mode & COAP_BLOCK_STLESS_BLOCK2 && session->type != COAP_SESSION_TYPE_CLIENT) {
  ------------------
  |  |   71|      0|#define COAP_BLOCK_STLESS_BLOCK2 0x40 /* (svr)Server is stateless for handling Block2 */
  ------------------
  |  Branch (1102:11): [True: 0, False: 0]
  |  Branch (1102:61): [True: 0, False: 0]
  ------------------
 1103|       |        /* We are running server stateless */
 1104|      0|        coap_update_option(pdu,
 1105|      0|                           COAP_OPTION_SIZE2,
 1106|      0|                           coap_encode_var_safe(buf, sizeof(buf),
 1107|      0|                                                (unsigned int)length),
 1108|      0|                           buf);
 1109|      0|        if (request) {
  ------------------
  |  Branch (1109:13): [True: 0, False: 0]
  ------------------
 1110|      0|          if (!coap_get_block_b(session, request, option, &block))
  ------------------
  |  Branch (1110:15): [True: 0, False: 0]
  ------------------
 1111|      0|            block.num = 0;
 1112|      0|        }
 1113|      0|        if (!setup_block_b(session, pdu, &block, block.num,
  ------------------
  |  Branch (1113:13): [True: 0, False: 0]
  ------------------
 1114|      0|                           blk_size, length))
 1115|      0|          goto fail;
 1116|       |
 1117|       |        /* Add in with requested block num, more bit and block size */
 1118|      0|        coap_update_option(pdu,
 1119|      0|                           option,
 1120|      0|                           coap_encode_var_safe(buf, sizeof(buf),
 1121|      0|                                                (block.num << 4) | (block.m << 3) | block.aszx),
 1122|      0|                           buf);
 1123|      0|      }
 1124|      0|#endif /* COAP_SERVER_SUPPORT */
 1125|      0|      rem = chunk;
 1126|      0|      if (chunk > length - block.num * chunk)
  ------------------
  |  Branch (1126:11): [True: 0, False: 0]
  ------------------
 1127|      0|        rem = length - block.num * chunk;
 1128|      0|      if (get_func) {
  ------------------
  |  Branch (1128:11): [True: 0, False: 0]
  ------------------
 1129|      0|        if (!add_get_func_data(session, pdu, get_func, app_ptr,
  ------------------
  |  Branch (1129:13): [True: 0, False: 0]
  ------------------
 1130|      0|                               block.num * chunk, rem))
 1131|      0|          goto fail;
 1132|      0|      } else {
 1133|      0|        if (!coap_add_data(pdu, rem, &data[block.num * chunk]))
  ------------------
  |  Branch (1133:13): [True: 0, False: 0]
  ------------------
 1134|      0|          goto fail;
 1135|      0|      }
 1136|      0|    }
 1137|      0|    if (release_func) {
  ------------------
  |  Branch (1137:9): [True: 0, False: 0]
  ------------------
 1138|      0|      coap_lock_callback(release_func(session, app_ptr));
  ------------------
  |  |  651|      0|#define coap_lock_callback(func) func
  ------------------
 1139|      0|    }
 1140|      0|  } else if ((have_block_defined && length > chunk) || (ssize_t)length > avail) {
  ------------------
  |  Branch (1140:15): [True: 0, False: 0]
  |  Branch (1140:37): [True: 0, False: 0]
  |  Branch (1140:56): [True: 0, False: 0]
  ------------------
 1141|       |    /* Only add in lg_xmit if more than one block needs to be handled */
 1142|      0|    size_t rem;
 1143|       |
 1144|      0|    lg_xmit = coap_malloc_type(COAP_LG_XMIT, sizeof(coap_lg_xmit_t));
 1145|      0|    if (!lg_xmit)
  ------------------
  |  Branch (1145:9): [True: 0, False: 0]
  ------------------
 1146|      0|      goto fail;
 1147|       |
 1148|       |    /* Set up for displaying all the data in the pdu */
 1149|      0|    if (!get_func) {
  ------------------
  |  Branch (1149:9): [True: 0, False: 0]
  ------------------
 1150|      0|      pdu->body_data = data;
 1151|      0|      pdu->body_length = length;
 1152|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1153|      0|      coap_show_pdu(COAP_LOG_DEBUG, pdu);
 1154|      0|      pdu->body_data = NULL;
 1155|      0|      pdu->body_length = 0;
 1156|      0|    } else {
 1157|      0|      coap_log_debug("PDU presented by app without data.\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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1158|      0|      coap_show_pdu(COAP_LOG_DEBUG, pdu);
 1159|      0|    }
 1160|       |
 1161|      0|    coap_log_debug("** %s: lg_xmit %p initialized\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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1162|      0|                   coap_session_str(session), (void *)lg_xmit);
 1163|       |    /* Update lg_xmit with large data information */
 1164|      0|    memset(lg_xmit, 0, sizeof(coap_lg_xmit_t));
 1165|      0|    lg_xmit->blk_size = blk_size;
 1166|      0|    lg_xmit->option = option;
 1167|      0|    lg_xmit->data_info = coap_malloc_type(COAP_STRING, sizeof(coap_lg_xmit_data_t));
 1168|      0|    if (!lg_xmit->data_info)
  ------------------
  |  Branch (1168:9): [True: 0, False: 0]
  ------------------
 1169|      0|      goto fail;
 1170|      0|    lg_xmit->data_info->ref = 0;
 1171|      0|    lg_xmit->data_info->data = data;
 1172|      0|    lg_xmit->data_info->length = length;
 1173|      0|#if COAP_Q_BLOCK_SUPPORT
 1174|      0|    lg_xmit->non_timeout_random_ticks =
 1175|      0|        coap_get_non_timeout_random_ticks(session);
 1176|      0|#endif /* COAP_Q_BLOCK_SUPPORT */
 1177|      0|    lg_xmit->data_info->get_func = get_func;
 1178|      0|    lg_xmit->data_info->release_func = release_func;
 1179|      0|    lg_xmit->data_info->app_ptr = app_ptr;
 1180|      0|    pdu->lg_xmit = lg_xmit;
 1181|      0|    coap_ticks(&lg_xmit->last_obs);
 1182|      0|    coap_ticks(&lg_xmit->last_sent);
 1183|      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]
  |  |  ------------------
  ------------------
 1184|       |      /* Need to keep original token for updating response PDUs */
 1185|      0|      lg_xmit->b.b1.app_token = coap_new_binary(pdu->actual_token.length);
 1186|      0|      if (!lg_xmit->b.b1.app_token)
  ------------------
  |  Branch (1186:11): [True: 0, False: 0]
  ------------------
 1187|      0|        goto fail;
 1188|      0|      memcpy(lg_xmit->b.b1.app_token->s, pdu->actual_token.s,
 1189|      0|             pdu->actual_token.length);
 1190|       |      /*
 1191|       |       * Need to set up new token for use during transmits
 1192|       |       * RFC9177#section-5
 1193|       |       */
 1194|      0|      lg_xmit->b.b1.count = 1;
 1195|      0|      lg_xmit->b.b1.state_token = STATE_TOKEN_FULL(++session->tx_token,
  ------------------
  |  |   43|      0|#define STATE_TOKEN_FULL(t,r) (STATE_TOKEN_BASE(t) + ((uint64_t)(r) << (64 - STATE_MAX_BLK_CNT_BITS)))
  |  |  ------------------
  |  |  |  |   41|      0|#define STATE_TOKEN_BASE(t) ((t) & (0xffffffffffffffffULL >> STATE_MAX_BLK_CNT_BITS))
  |  |  |  |  ------------------
  |  |  |  |  |  |   39|      0|#define STATE_MAX_BLK_CNT_BITS 20
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define STATE_TOKEN_FULL(t,r) (STATE_TOKEN_BASE(t) + ((uint64_t)(r) << (64 - STATE_MAX_BLK_CNT_BITS)))
  |  |  ------------------
  |  |  |  |   39|      0|#define STATE_MAX_BLK_CNT_BITS 20
  |  |  ------------------
  ------------------
 1196|      0|                                                   lg_xmit->b.b1.count);
 1197|      0|      coap_address_copy(&lg_xmit->b.b1.upstream, &session->addr_info.remote);
 1198|       |      /*
 1199|       |       * Token will be updated in pdu later as original pdu may be needed in
 1200|       |       * coap_send()
 1201|       |       */
 1202|      0|      coap_update_option(pdu,
 1203|      0|                         COAP_OPTION_SIZE1,
 1204|      0|                         coap_encode_var_safe(buf, sizeof(buf),
 1205|      0|                                              (unsigned int)length),
 1206|      0|                         buf);
 1207|      0|      if (!coap_check_option(pdu, COAP_OPTION_RTAG, &opt_iter))
  ------------------
  |  Branch (1207:11): [True: 0, False: 0]
  ------------------
 1208|      0|        coap_insert_option(pdu,
 1209|      0|                           COAP_OPTION_RTAG,
 1210|      0|                           coap_encode_var_safe(buf, sizeof(buf),
 1211|      0|                                                ++session->tx_rtag),
 1212|      0|                           buf);
 1213|      0|    } else {
 1214|       |      /*
 1215|       |       * resource+query+rtag match is used for Block2 large body transmissions
 1216|       |       * token match is used for Block1 large body transmissions
 1217|       |       */
 1218|      0|      lg_xmit->b.b2.resource = resource;
 1219|      0|      if (query) {
  ------------------
  |  Branch (1219:11): [True: 0, False: 0]
  ------------------
 1220|      0|        lg_xmit->b.b2.query = coap_new_string(query->length);
 1221|      0|        if (lg_xmit->b.b2.query) {
  ------------------
  |  Branch (1221:13): [True: 0, False: 0]
  ------------------
 1222|      0|          memcpy(lg_xmit->b.b2.query->s, query->s, query->length);
 1223|      0|        }
 1224|      0|      } else {
 1225|      0|        lg_xmit->b.b2.query = NULL;
 1226|      0|      }
 1227|      0|      opt = coap_check_option(request, COAP_OPTION_RTAG, &opt_iter);
 1228|      0|      if (opt) {
  ------------------
  |  Branch (1228:11): [True: 0, False: 0]
  ------------------
 1229|      0|        lg_xmit->b.b2.rtag_length = (uint8_t)min(coap_opt_length(opt),
  ------------------
  |  |   21|      0|#define min(a,b) ((a) < (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (21:19): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1230|      0|                                                 sizeof(lg_xmit->b.b2.rtag));
 1231|      0|        memcpy(lg_xmit->b.b2.rtag, coap_opt_value(opt), lg_xmit->b.b2.rtag_length);
 1232|      0|        lg_xmit->b.b2.rtag_set = 1;
 1233|      0|      } else {
 1234|      0|        lg_xmit->b.b2.rtag_set = 0;
 1235|      0|      }
 1236|      0|      lg_xmit->b.b2.etag = etag;
 1237|      0|      lg_xmit->b.b2.request_method = request_method;
 1238|      0|      if (maxage >= 0) {
  ------------------
  |  Branch (1238:11): [True: 0, False: 0]
  ------------------
 1239|      0|        coap_tick_t now;
 1240|       |
 1241|      0|        coap_ticks(&now);
 1242|      0|        lg_xmit->b.b2.maxage_expire = coap_ticks_to_rt(now) + maxage;
 1243|      0|      } else {
 1244|      0|        lg_xmit->b.b2.maxage_expire = 0;
 1245|      0|      }
 1246|      0|      coap_update_option(pdu,
 1247|      0|                         COAP_OPTION_SIZE2,
 1248|      0|                         coap_encode_var_safe(buf, sizeof(buf),
 1249|      0|                                              (unsigned int)length),
 1250|      0|                         buf);
 1251|      0|    }
 1252|       |
 1253|      0|    if (!setup_block_b(session, pdu, &block, block.num,
  ------------------
  |  Branch (1253:9): [True: 0, False: 0]
  ------------------
 1254|      0|                       blk_size, lg_xmit->data_info->length))
 1255|      0|      goto fail;
 1256|       |
 1257|       |    /* Add in with requested block num, more bit and block size */
 1258|      0|    coap_update_option(pdu,
 1259|      0|                       lg_xmit->option,
 1260|      0|                       coap_encode_var_safe(buf, sizeof(buf),
 1261|      0|                                            (block.num << 4) | (block.m << 3) | block.aszx),
 1262|      0|                       buf);
 1263|       |
 1264|       |    /* Reference PDU to use as a basis for all the subsequent blocks */
 1265|      0|    lg_xmit->sent_pdu = coap_pdu_reference_lkd(pdu);
 1266|       |
 1267|       |    /* Check we still have space after adding in some options */
 1268|      0|    token_options = pdu->data ? (size_t)(pdu->data - pdu->token) : pdu->used_size;
  ------------------
  |  Branch (1268:21): [True: 0, False: 0]
  ------------------
 1269|      0|    avail = pdu->max_size - token_options;
 1270|       |    /* There may be a response with Echo option */
 1271|      0|    avail -= coap_opt_encode_size(COAP_OPTION_ECHO, 40);
 1272|       |    /* May need token of length 8, so account for this */
 1273|      0|    avail -= (pdu->actual_token.length < 8) ? 8 - pdu->actual_token.length : 0;
  ------------------
  |  Branch (1273:14): [True: 0, False: 0]
  ------------------
 1274|      0|#if COAP_OSCORE_SUPPORT
 1275|      0|    avail -= coap_oscore_overhead(session, pdu);
 1276|      0|#endif /* COAP_OSCORE_SUPPORT */
 1277|      0|    if (avail < (ssize_t)chunk) {
  ------------------
  |  Branch (1277:9): [True: 0, False: 0]
  ------------------
 1278|       |      /* chunk size change down */
 1279|      0|      if (avail < 16) {
  ------------------
  |  Branch (1279:11): [True: 0, False: 0]
  ------------------
 1280|      0|        coap_log_warn("not enough space, even the smallest block does not fit (3)\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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1281|      0|        goto fail;
 1282|      0|      }
 1283|      0|      blk_size = coap_flsll((long long)avail) - 4 - 1;
 1284|      0|      block.num = block.num << (lg_xmit->blk_size - blk_size);
 1285|      0|      lg_xmit->blk_size = blk_size;
 1286|      0|      chunk = (size_t)1 << (lg_xmit->blk_size + 4);
 1287|      0|      block.chunk_size = (uint32_t)chunk;
 1288|      0|      block.bert = 0;
 1289|      0|      coap_update_option(pdu,
 1290|      0|                         lg_xmit->option,
 1291|      0|                         coap_encode_var_safe(buf, sizeof(buf),
 1292|      0|                                              (block.num << 4) | (block.m << 3) | lg_xmit->blk_size),
 1293|      0|                         buf);
 1294|      0|    }
 1295|      0|#if COAP_Q_BLOCK_SUPPORT
 1296|       |    /* Set up send_blocks */
 1297|      0|    lg_xmit->send_blocks.used = 1;
 1298|      0|    lg_xmit->send_blocks.range[0].end = (uint32_t)((lg_xmit->data_info->length - 1) / chunk);
 1299|      0|#endif /* COAP_Q_BLOCK_SUPPORT */
 1300|       |
 1301|      0|    rem = block.chunk_size;
 1302|      0|    if (rem > lg_xmit->data_info->length - block.num * chunk)
  ------------------
  |  Branch (1302:9): [True: 0, False: 0]
  ------------------
 1303|      0|      rem = lg_xmit->data_info->length - block.num * chunk;
 1304|      0|    if (get_func) {
  ------------------
  |  Branch (1304:9): [True: 0, False: 0]
  ------------------
 1305|       |#if COAP_CONSTRAINED_STACK
 1306|       |      /* Protected by global_lock if needed */
 1307|       |      static uint8_t l_data[1024];
 1308|       |      uint8_t *data_buf = l_data;
 1309|       |#else /* ! COAP_CONSTRAINED_STACK */
 1310|      0|      uint8_t l_data[1024];
 1311|      0|      uint8_t *data_buf = l_data;
 1312|      0|#endif /* ! COAP_CONSTRAINED_STACK */
 1313|      0|      size_t l_length;
 1314|      0|      int data_buf_allocated = 0;
 1315|       |
 1316|      0|      if (rem > sizeof(l_data)) {
  ------------------
  |  Branch (1316:11): [True: 0, False: 0]
  ------------------
 1317|      0|        data_buf = coap_malloc_type(COAP_STRING, rem);
 1318|      0|        if (!data_buf) {
  ------------------
  |  Branch (1318:13): [True: 0, False: 0]
  ------------------
 1319|      0|          coap_log_warn("out of memory allocating %" PRIuS " bytes for block data\n", rem);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1320|      0|          goto fail;
 1321|      0|        }
 1322|      0|        data_buf_allocated = 1;
 1323|      0|      }
 1324|      0|      if (get_func(session, rem, block.num * chunk, data_buf, &l_length,
  ------------------
  |  Branch (1324:11): [True: 0, False: 0]
  ------------------
 1325|      0|                   lg_xmit->data_info->app_ptr)) {
 1326|      0|        if (!coap_add_data(pdu, l_length, data_buf)) {
  ------------------
  |  Branch (1326:13): [True: 0, False: 0]
  ------------------
 1327|      0|          if (data_buf_allocated)
  ------------------
  |  Branch (1327:15): [True: 0, False: 0]
  ------------------
 1328|      0|            coap_free_type(COAP_STRING, data_buf);
 1329|      0|          goto fail;
 1330|      0|        }
 1331|      0|      }
 1332|      0|      if (data_buf_allocated)
  ------------------
  |  Branch (1332:11): [True: 0, False: 0]
  ------------------
 1333|      0|        coap_free_type(COAP_STRING, data_buf);
 1334|      0|    } else {
 1335|      0|      if (!coap_add_data(pdu, rem, &data[block.num * chunk]))
  ------------------
  |  Branch (1335:11): [True: 0, False: 0]
  ------------------
 1336|      0|        goto fail;
 1337|      0|    }
 1338|       |
 1339|      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]
  |  |  ------------------
  ------------------
 1340|      0|      lg_xmit->b.b1.bert_size = rem;
 1341|       |
 1342|      0|    lg_xmit->last_block = -1;
 1343|       |
 1344|       |    /* Link the new lg_xmit in */
 1345|      0|    LL_PREPEND(session->lg_xmit,lg_xmit);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1346|      0|  } else {
 1347|       |    /* No need to use blocks */
 1348|      0|    if (have_block_defined) {
  ------------------
  |  Branch (1348:9): [True: 0, False: 0]
  ------------------
 1349|      0|      coap_update_option(pdu,
 1350|      0|                         option,
 1351|      0|                         coap_encode_var_safe(buf, sizeof(buf),
 1352|      0|                                              (0 << 4) | (0 << 3) | blk_size), buf);
 1353|      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]
  |  |  ------------------
  ------------------
 1354|      0|        coap_update_option(pdu,
 1355|      0|                           COAP_OPTION_SIZE1,
 1356|      0|                           coap_encode_var_safe(buf, sizeof(buf),
 1357|      0|                                                (unsigned int)length),
 1358|      0|                           buf);
 1359|      0|      } else {
 1360|      0|        coap_update_option(pdu,
 1361|      0|                           COAP_OPTION_SIZE2,
 1362|      0|                           coap_encode_var_safe(buf, sizeof(buf),
 1363|      0|                                                (unsigned int)length),
 1364|      0|                           buf);
 1365|      0|      }
 1366|      0|    }
 1367|      1|add_data:
 1368|      1|    if (get_func) {
  ------------------
  |  Branch (1368:9): [True: 0, False: 1]
  ------------------
 1369|      0|      if (!add_get_func_data(session, pdu, get_func, app_ptr, 0, length))
  ------------------
  |  Branch (1369:11): [True: 0, False: 0]
  ------------------
 1370|      0|        goto fail;
 1371|      1|    } else {
 1372|      1|      if (!coap_add_data(pdu, length, data))
  ------------------
  |  Branch (1372:11): [True: 0, False: 1]
  ------------------
 1373|      0|        goto fail;
 1374|      1|    }
 1375|       |
 1376|      1|    if (release_func) {
  ------------------
  |  Branch (1376:9): [True: 1, False: 0]
  ------------------
 1377|      1|      coap_lock_callback(release_func(session, app_ptr));
  ------------------
  |  |  651|      1|#define coap_lock_callback(func) func
  ------------------
 1378|      1|    }
 1379|      1|  }
 1380|      1|  return 1;
 1381|       |
 1382|      0|fail:
 1383|      0|  if (lg_xmit) {
  ------------------
  |  Branch (1383:7): [True: 0, False: 0]
  ------------------
 1384|      0|    coap_block_delete_lg_xmit(session, lg_xmit);
 1385|      0|  } else if (release_func) {
  ------------------
  |  Branch (1385:14): [True: 0, False: 0]
  ------------------
 1386|      0|    coap_lock_callback(release_func(session, app_ptr));
  ------------------
  |  |  651|      0|#define coap_lock_callback(func) func
  ------------------
 1387|      0|  }
 1388|      0|  return 0;
 1389|      0|}

coap_delete_cache_key:
  168|     13|coap_delete_cache_key(coap_cache_key_t *cache_key) {
  169|     13|  coap_free_type(COAP_CACHE_KEY, cache_key);
  170|     13|}

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

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

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

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

coap_update_io_timer:
   70|      8|coap_update_io_timer(coap_context_t *context, coap_tick_t delay) {
   71|      8|#if COAP_EPOLL_SUPPORT
   72|      8|  if (context->eptimerfd != -1) {
  ------------------
  |  Branch (72:7): [True: 8, False: 0]
  ------------------
   73|      8|    coap_tick_t now;
   74|       |
   75|      8|    coap_ticks(&now);
   76|      8|    if (context->next_timeout == 0 || context->next_timeout > now + delay) {
  ------------------
  |  Branch (76:9): [True: 8, False: 0]
  |  Branch (76:39): [True: 0, False: 0]
  ------------------
   77|      8|      struct itimerspec new_value;
   78|      8|      int ret;
   79|       |
   80|      8|      context->next_timeout = now + delay;
   81|      8|      memset(&new_value, 0, sizeof(new_value));
   82|      8|      if (delay == 0) {
  ------------------
  |  Branch (82:11): [True: 0, False: 8]
  ------------------
   83|      0|        new_value.it_value.tv_nsec = 1; /* small but not zero */
   84|      8|      } else {
   85|      8|        new_value.it_value.tv_sec = delay / COAP_TICKS_PER_SECOND;
  ------------------
  |  |  164|      8|#define COAP_TICKS_PER_SECOND ((coap_tick_t)(1000U))
  ------------------
   86|      8|        new_value.it_value.tv_nsec = (delay % COAP_TICKS_PER_SECOND) *
  ------------------
  |  |  164|      8|#define COAP_TICKS_PER_SECOND ((coap_tick_t)(1000U))
  ------------------
   87|      8|                                     1000000;
   88|      8|      }
   89|      8|      ret = timerfd_settime(context->eptimerfd, 0, &new_value, NULL);
   90|      8|      if (ret == -1) {
  ------------------
  |  Branch (90:11): [True: 0, False: 8]
  ------------------
   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|      8|    }
  102|      8|  }
  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|      8|}

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

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

coap_insert_node:
  156|      8|coap_insert_node(coap_queue_t **queue, coap_queue_t *node) {
  157|      8|  coap_queue_t *p, *q;
  158|      8|  if (!queue || !node)
  ------------------
  |  Branch (158:7): [True: 0, False: 8]
  |  Branch (158:17): [True: 0, False: 8]
  ------------------
  159|      0|    return 0;
  160|       |
  161|       |  /* set queue head if empty */
  162|      8|  if (!*queue) {
  ------------------
  |  Branch (162:7): [True: 8, False: 0]
  ------------------
  163|      8|    *queue = node;
  164|      8|    return 1;
  165|      8|  }
  166|       |
  167|       |  /* replace queue head if PDU's time is less than head's time */
  168|      0|  q = *queue;
  169|      0|  if (node->t < q->t) {
  ------------------
  |  Branch (169:7): [True: 0, False: 0]
  ------------------
  170|      0|    node->next = q;
  171|      0|    *queue = node;
  172|      0|    q->t -= node->t;                /* make q->t relative to node->t */
  173|      0|    return 1;
  174|      0|  }
  175|       |
  176|       |  /* search for right place to insert */
  177|      0|  do {
  178|      0|    node->t -= q->t;                /* make node-> relative to q->t */
  179|      0|    p = q;
  180|      0|    q = q->next;
  181|      0|  } while (q && q->t <= node->t);
  ------------------
  |  Branch (181:12): [True: 0, False: 0]
  |  Branch (181:17): [True: 0, False: 0]
  ------------------
  182|       |
  183|       |  /* insert new item */
  184|      0|  if (q) {
  ------------------
  |  Branch (184:7): [True: 0, False: 0]
  ------------------
  185|      0|    q->t -= node->t;                /* make q->t relative to node->t */
  186|      0|  }
  187|      0|  node->next = q;
  188|      0|  p->next = node;
  189|      0|  return 1;
  190|      0|}
coap_delete_node_lkd:
  206|      8|coap_delete_node_lkd(coap_queue_t *node) {
  207|      8|  if (!node)
  ------------------
  |  Branch (207:7): [True: 0, False: 8]
  ------------------
  208|      0|    return 0;
  209|       |
  210|      8|  coap_delete_pdu_lkd(node->pdu);
  211|      8|  if (node->session) {
  ------------------
  |  Branch (211:7): [True: 8, False: 0]
  ------------------
  212|       |    /*
  213|       |     * Need to remove out of context->sendqueue as added in by coap_wait_ack()
  214|       |     */
  215|      8|    if (node->session->context->sendqueue) {
  ------------------
  |  Branch (215:9): [True: 8, False: 0]
  ------------------
  216|      8|      LL_DELETE(node->session->context->sendqueue, node);
  ------------------
  |  |  391|      8|    LL_DELETE2(head,del,next)
  |  |  ------------------
  |  |  |  |  393|      8|#define LL_DELETE2(head,del,next)                                                              \
  |  |  |  |  394|      8|do {                                                                                           \
  |  |  |  |  395|      8|  LDECLTYPE(head) _tmp;                                                                        \
  |  |  |  |  ------------------
  |  |  |  |  |  |   81|      8|#define LDECLTYPE(x) __typeof(x)
  |  |  |  |  ------------------
  |  |  |  |  396|      8|  if ((head) == (del)) {                                                                       \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (396:7): [True: 8, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  397|      8|    (head)=(head)->next;                                                                       \
  |  |  |  |  398|      8|  } 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|      8|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (407:10): [Folded, False: 8]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  217|      8|    }
  218|      8|    coap_session_release_lkd(node->session);
  219|      8|  }
  220|      8|  coap_free_node(node);
  221|       |
  222|      8|  return 1;
  223|      8|}
coap_delete_all:
  226|     38|coap_delete_all(coap_queue_t *queue) {
  227|     38|  if (!queue)
  ------------------
  |  Branch (227:7): [True: 30, False: 8]
  ------------------
  228|     30|    return;
  229|       |
  230|      8|  coap_delete_all(queue->next);
  231|      8|  coap_delete_node_lkd(queue);
  232|      8|}
coap_new_node:
  235|      8|coap_new_node(void) {
  236|      8|  coap_queue_t *node;
  237|      8|  node = coap_malloc_node();
  238|       |
  239|      8|  if (!node) {
  ------------------
  |  Branch (239:7): [True: 0, False: 8]
  ------------------
  240|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  241|      0|    return NULL;
  242|      0|  }
  243|       |
  244|      8|  memset(node, 0, sizeof(*node));
  245|      8|  return node;
  246|      8|}
coap_new_context:
  737|     30|coap_new_context(const coap_address_t *listen_addr) {
  738|     30|  coap_context_t *c;
  739|       |
  740|       |#if ! COAP_SERVER_SUPPORT
  741|       |  (void)listen_addr;
  742|       |#endif /* COAP_SERVER_SUPPORT */
  743|       |
  744|     30|  if (!coap_started) {
  ------------------
  |  Branch (744:7): [True: 0, False: 30]
  ------------------
  745|      0|    coap_startup();
  746|      0|    coap_log_warn("coap_startup() should be called before any other "
  ------------------
  |  |  108|      0|#define coap_log_warn(...) coap_log(COAP_LOG_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  747|      0|                  "coap_*() functions are called\n");
  748|      0|  }
  749|       |
  750|     30|  c = coap_malloc_type(COAP_CONTEXT, sizeof(coap_context_t));
  751|     30|  if (!c) {
  ------------------
  |  Branch (751:7): [True: 0, False: 30]
  ------------------
  752|      0|    coap_log_emerg("coap_init: malloc: failed\n");
  ------------------
  |  |   87|      0|#define coap_log_emerg(...) coap_log(COAP_LOG_EMERG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  753|      0|    return NULL;
  754|      0|  }
  755|     30|  memset(c, 0, sizeof(coap_context_t));
  756|       |
  757|     30|  coap_lock_lock(coap_free_type(COAP_CONTEXT, c); return NULL);
  758|     30|#ifdef COAP_EPOLL_SUPPORT
  759|     30|  c->epfd = epoll_create1(0);
  760|     30|  if (c->epfd == -1) {
  ------------------
  |  Branch (760:7): [True: 0, False: 30]
  ------------------
  761|      0|    coap_log_err("coap_new_context: Unable to epoll_create: %s (%d)\n",
  ------------------
  |  |  102|      0|#define coap_log_err(...) coap_log(COAP_LOG_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  762|      0|                 coap_socket_strerror(),
  763|      0|                 errno);
  764|      0|    goto onerror;
  765|      0|  }
  766|     30|  if (c->epfd != -1) {
  ------------------
  |  Branch (766:7): [True: 30, False: 0]
  ------------------
  767|     30|    c->eptimerfd = timerfd_create(CLOCK_REALTIME, TFD_NONBLOCK);
  768|     30|    if (c->eptimerfd == -1) {
  ------------------
  |  Branch (768:9): [True: 0, False: 30]
  ------------------
  769|      0|      coap_log_err("coap_new_context: Unable to timerfd_create: %s (%d)\n",
  ------------------
  |  |  102|      0|#define coap_log_err(...) coap_log(COAP_LOG_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  770|      0|                   coap_socket_strerror(),
  771|      0|                   errno);
  772|      0|      goto onerror;
  773|     30|    } else {
  774|     30|      int ret;
  775|     30|      struct epoll_event event;
  776|       |
  777|       |      /* Needed if running 32bit as ptr is only 32bit */
  778|     30|      memset(&event, 0, sizeof(event));
  779|     30|      event.events = EPOLLIN;
  780|       |      /* We special case this event by setting to NULL */
  781|     30|      event.data.ptr = NULL;
  782|       |
  783|     30|      ret = epoll_ctl(c->epfd, EPOLL_CTL_ADD, c->eptimerfd, &event);
  784|     30|      if (ret == -1) {
  ------------------
  |  Branch (784:11): [True: 0, False: 30]
  ------------------
  785|      0|        coap_log_err("%s: epoll_ctl ADD failed: %s (%d)\n",
  ------------------
  |  |  102|      0|#define coap_log_err(...) coap_log(COAP_LOG_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  786|      0|                     "coap_new_context",
  787|      0|                     coap_socket_strerror(), errno);
  788|      0|        goto onerror;
  789|      0|      }
  790|     30|    }
  791|     30|  }
  792|     30|#endif /* COAP_EPOLL_SUPPORT */
  793|       |
  794|     30|  if (coap_dtls_is_supported() || coap_tls_is_supported()) {
  ------------------
  |  Branch (794:7): [True: 30, False: 0]
  |  Branch (794:35): [True: 0, False: 0]
  ------------------
  795|     30|    c->dtls_context = coap_dtls_new_context(c);
  796|     30|    if (!c->dtls_context) {
  ------------------
  |  Branch (796:9): [True: 0, False: 30]
  ------------------
  797|      0|      coap_log_emerg("coap_init: no DTLS context available\n");
  ------------------
  |  |   87|      0|#define coap_log_emerg(...) coap_log(COAP_LOG_EMERG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  798|      0|      goto onerror;
  799|      0|    }
  800|     30|  }
  801|       |
  802|       |  /* set default CSM values */
  803|     30|  c->csm_timeout_ms = 1000;
  804|     30|  c->csm_max_message_size = COAP_DEFAULT_MAX_PDU_RX_SIZE;
  ------------------
  |  |   84|     30|#define COAP_DEFAULT_MAX_PDU_RX_SIZE (8UL*1024*1024+256)
  ------------------
  805|       |
  806|     30|#if COAP_SERVER_SUPPORT
  807|     30|  if (listen_addr) {
  ------------------
  |  Branch (807:7): [True: 0, False: 30]
  ------------------
  808|      0|    coap_endpoint_t *endpoint = coap_new_endpoint_lkd(c, listen_addr, COAP_PROTO_UDP);
  809|      0|    if (endpoint == NULL) {
  ------------------
  |  Branch (809:9): [True: 0, False: 0]
  ------------------
  810|      0|      goto onerror;
  811|      0|    }
  812|      0|  }
  813|     30|#endif /* COAP_SERVER_SUPPORT */
  814|       |
  815|     30|  c->max_token_size = COAP_TOKEN_DEFAULT_MAX; /* RFC8974 */
  ------------------
  |  |   58|     30|#define COAP_TOKEN_DEFAULT_MAX 8
  ------------------
  816|       |
  817|       |#if defined(WITH_LWIP)
  818|       |#if NO_SYS == 0
  819|       |  if (sys_sem_new(&c->coap_io_timeout_sem, 0) != ERR_OK)
  820|       |    coap_log_warn("coap_new_context: Failed to set up semaphore\n");
  821|       |#endif /* NO_SYS == 0 */
  822|       |#endif /* ! WITH_LWIP */
  823|     30|  coap_lock_unlock();
  824|     30|  return c;
  825|       |
  826|      0|onerror:
  827|      0|  coap_lock_unlock();
  828|      0|  coap_free_type(COAP_CONTEXT, c);
  829|       |  return NULL;
  830|     30|}
coap_free_context:
  847|     30|coap_free_context(coap_context_t *context) {
  848|     30|  if (!context)
  ------------------
  |  Branch (848:7): [True: 0, False: 30]
  ------------------
  849|      0|    return;
  850|     30|  coap_lock_lock(return);
  851|     30|  coap_free_context_lkd(context);
  852|     30|  coap_lock_unlock();
  853|     30|}
coap_free_context_lkd:
  856|     30|coap_free_context_lkd(coap_context_t *context) {
  857|     30|  if (!context)
  ------------------
  |  Branch (857:7): [True: 0, False: 30]
  ------------------
  858|      0|    return;
  859|       |
  860|     30|  coap_lock_check_locked();
  ------------------
  |  |  638|     30|#define coap_lock_check_locked() {}
  ------------------
  861|     30|#if COAP_SERVER_SUPPORT
  862|       |  /* Removing a resource may cause a NON unsolicited observe to be sent */
  863|     30|  context->context_going_away = 1;
  864|     30|  if (context->shutdown_no_send_observe)
  ------------------
  |  Branch (864:7): [True: 0, False: 30]
  ------------------
  865|      0|    context->observe_no_clear = 1;
  866|     30|  coap_delete_all_resources(context);
  867|     30|#endif /* COAP_SERVER_SUPPORT */
  868|     30|#if COAP_CLIENT_SUPPORT
  869|       |  /* Stop any attempts at reconnection */
  870|     30|  context->reconnect_time = 0;
  871|     30|#endif /* COAP_CLIENT_SUPPORT */
  872|       |
  873|     30|  coap_delete_all(context->sendqueue);
  874|     30|  context->sendqueue = NULL;
  875|       |
  876|       |#ifdef WITH_LWIP
  877|       |  if (context->timer_configured) {
  878|       |    LOCK_TCPIP_CORE();
  879|       |    sys_untimeout(coap_io_process_timeout, (void *)context);
  880|       |    UNLOCK_TCPIP_CORE();
  881|       |    context->timer_configured = 0;
  882|       |  }
  883|       |#endif /* WITH_LWIP */
  884|       |
  885|     30|#if COAP_ASYNC_SUPPORT
  886|     30|  coap_delete_all_async(context);
  887|     30|#endif /* COAP_ASYNC_SUPPORT */
  888|       |
  889|     30|#if COAP_SERVER_SUPPORT
  890|     30|  coap_cache_entry_t *cp, *ctmp;
  891|     30|  coap_endpoint_t *ep, *tmp;
  892|       |
  893|     30|  HASH_ITER(hh, context->cache, cp, ctmp) {
  ------------------
  |  | 1071|     30|#define HASH_ITER(hh,head,el,tmp)                                                \
  |  | 1072|     30|for(((el)=(head)), ((tmp)=DECLTYPE(el)((head!=NULL)?(head)->hh.next:NULL));      \
  |  |  ------------------
  |  |  |  |   66|     30|#define DECLTYPE(x) (__typeof(x))
  |  |  ------------------
  |  |  |  Branch (1072:40): [True: 0, False: 30]
  |  |  ------------------
  |  | 1073|     30|  (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: 30]
  |  |  |  Branch (1073:51): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  894|      0|    coap_delete_cache_entry(context, cp);
  895|      0|  }
  896|     30|  if (context->cache_ignore_count) {
  ------------------
  |  Branch (896:7): [True: 0, False: 30]
  ------------------
  897|      0|    coap_free_type(COAP_STRING, context->cache_ignore_options);
  898|      0|  }
  899|       |
  900|     30|  LL_FOREACH_SAFE(context->endpoint, ep, tmp) {
  ------------------
  |  |  425|     30|    LL_FOREACH_SAFE2(head,el,tmp,next)
  |  |  ------------------
  |  |  |  |  428|     30|  for ((el) = (head); (el) && ((tmp) = (el)->next, 1); (el) = (tmp))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (428:23): [True: 0, False: 30]
  |  |  |  |  |  Branch (428:31): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  901|      0|    coap_free_endpoint_lkd(ep);
  902|      0|  }
  903|     30|#endif /* COAP_SERVER_SUPPORT */
  904|       |
  905|     30|#if COAP_CLIENT_SUPPORT
  906|     30|  coap_session_t *sp, *rtmp;
  907|       |
  908|     43|  SESSIONS_ITER_SAFE(context->sessions, sp, rtmp) {
  ------------------
  |  |  956|     73|  for ((el) = (e); (el) && ((rtmp) = (el)->hh.next, 1); (el) = (rtmp))
  |  |  ------------------
  |  |  |  Branch (956:20): [True: 43, False: 30]
  |  |  |  Branch (956:28): [True: 43, False: 0]
  |  |  ------------------
  ------------------
  909|     43|    coap_session_release_lkd(sp);
  910|     43|  }
  911|     30|#endif /* COAP_CLIENT_SUPPORT */
  912|       |
  913|     30|#if COAP_OSCORE_SUPPORT
  914|     30|  coap_delete_all_oscore(context);
  915|     30|#endif /* COAP_OSCORE_SUPPORT */
  916|       |
  917|     30|  if (context->dtls_context)
  ------------------
  |  Branch (917:7): [True: 30, False: 0]
  ------------------
  918|     30|    coap_dtls_free_context(context->dtls_context);
  919|     30|#ifdef COAP_EPOLL_SUPPORT
  920|     30|  if (context->eptimerfd != -1) {
  ------------------
  |  Branch (920:7): [True: 30, False: 0]
  ------------------
  921|     30|    int ret;
  922|     30|    struct epoll_event event;
  923|       |
  924|       |    /* Kernels prior to 2.6.9 expect non NULL event parameter */
  925|     30|    ret = epoll_ctl(context->epfd, EPOLL_CTL_DEL, context->eptimerfd, &event);
  926|     30|    if (ret == -1) {
  ------------------
  |  Branch (926:9): [True: 0, False: 30]
  ------------------
  927|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  928|      0|                   "coap_free_context",
  929|      0|                   coap_socket_strerror(), errno);
  930|      0|    }
  931|     30|    close(context->eptimerfd);
  932|     30|    context->eptimerfd = -1;
  933|     30|  }
  934|     30|  if (context->epfd != -1) {
  ------------------
  |  Branch (934:7): [True: 30, False: 0]
  ------------------
  935|     30|    close(context->epfd);
  936|     30|    context->epfd = -1;
  937|     30|  }
  938|     30|#endif /* COAP_EPOLL_SUPPORT */
  939|     30|#if COAP_SERVER_SUPPORT
  940|     30|#if COAP_WITH_OBSERVE_PERSIST
  941|     30|  coap_persist_cleanup(context);
  942|     30|#endif /* COAP_WITH_OBSERVE_PERSIST */
  943|     30|#endif /* COAP_SERVER_SUPPORT */
  944|     30|#if COAP_PROXY_SUPPORT
  945|     30|  coap_proxy_cleanup(context);
  946|     30|#endif /* COAP_PROXY_SUPPORT */
  947|       |
  948|     30|  if (context->app_cb) {
  ------------------
  |  Branch (948:7): [True: 0, False: 30]
  ------------------
  949|      0|    coap_lock_callback(context->app_cb(context->app_data));
  ------------------
  |  |  651|      0|#define coap_lock_callback(func) func
  ------------------
  950|      0|  }
  951|       |#if defined(WITH_LWIP)
  952|       |#if NO_SYS == 0
  953|       |  sys_sem_free(&context->coap_io_timeout_sem);
  954|       |#endif /* NO_SYS == 0 */
  955|       |#endif /* ! WITH_LWIP */
  956|       |#if COAP_THREAD_SAFE && !WITH_LWIP
  957|       |  coap_io_process_remove_threads_lkd(context);
  958|       |#endif /* COAP_THREAD_SAFE && !WITH_LWIP */
  959|     30|  coap_free_type(COAP_CONTEXT, context);
  960|     30|  coap_dump_memory_type_counts(COAP_LOG_DEBUG);
  961|     30|}
coap_session_send_pdu:
 1267|      9|coap_session_send_pdu(coap_session_t *session, coap_pdu_t *pdu) {
 1268|      9|  ssize_t bytes_written = -1;
 1269|      9|  assert(pdu->hdr_size > 0);
  ------------------
  |  Branch (1269:3): [True: 9, False: 0]
  ------------------
 1270|       |
 1271|       |  /* Caller handles partial writes */
 1272|      9|  bytes_written = session->sock.lfunc[COAP_LAYER_SESSION].l_write(session,
 1273|      9|                  pdu->token - pdu->hdr_size,
 1274|      9|                  pdu->used_size + pdu->hdr_size);
 1275|      9|  coap_show_pdu(COAP_LOG_DEBUG, pdu);
 1276|      9|  return bytes_written;
 1277|      9|}
coap_calc_timeout:
 1390|      8|coap_calc_timeout(coap_session_t *session, unsigned char r) {
 1391|      8|  unsigned int result;
 1392|       |
 1393|       |  /* The integer 1.0 as a Qx.FRAC_BITS */
 1394|      8|#define FP1 Q(FRAC_BITS, ((coap_fixed_point_t){1,0}))
 1395|       |
 1396|       |  /* rounds val up and right shifts by frac positions */
 1397|      8|#define SHR_FP(val,frac) (((val) + (1 << ((frac) - 1))) >> (frac))
 1398|       |
 1399|       |  /* Inner term: multiply ACK_RANDOM_FACTOR by Q0.MAX_BITS[r] and
 1400|       |   * make the result a rounded Qx.FRAC_BITS */
 1401|      8|  result = SHR_FP((ACK_RANDOM_FACTOR - FP1) * r, MAX_BITS);
  ------------------
  |  | 1397|      8|#define SHR_FP(val,frac) (((val) + (1 << ((frac) - 1))) >> (frac))
  ------------------
 1402|       |
 1403|       |  /* Add 1 to the inner term and multiply with ACK_TIMEOUT, then
 1404|       |   * make the result a rounded Qx.FRAC_BITS */
 1405|      8|  result = SHR_FP(((result + FP1) * ACK_TIMEOUT), FRAC_BITS);
  ------------------
  |  | 1397|      8|#define SHR_FP(val,frac) (((val) + (1 << ((frac) - 1))) >> (frac))
  ------------------
 1406|       |
 1407|       |  /* Multiply with COAP_TICKS_PER_SECOND to yield system ticks
 1408|       |   * (yields a Qx.FRAC_BITS) and shift to get an integer */
 1409|      8|  return SHR_FP((COAP_TICKS_PER_SECOND * result), FRAC_BITS);
  ------------------
  |  | 1397|      8|#define SHR_FP(val,frac) (((val) + (1 << ((frac) - 1))) >> (frac))
  ------------------
 1410|       |
 1411|      8|#undef FP1
 1412|      8|#undef SHR_FP
 1413|      8|}
coap_wait_ack:
 1417|      8|              coap_queue_t *node) {
 1418|      8|  coap_tick_t now;
 1419|       |
 1420|      8|  node->session = coap_session_reference_lkd(session);
 1421|       |
 1422|       |  /* Set timer for pdu retransmission. If this is the first element in
 1423|       |  * the retransmission queue, the base time is set to the current
 1424|       |  * time and the retransmission time is node->timeout. If there is
 1425|       |  * already an entry in the sendqueue, we must check if this node is
 1426|       |  * to be retransmitted earlier. Therefore, node->timeout is first
 1427|       |  * normalized to the base time and then inserted into the queue with
 1428|       |  * an adjusted relative time.
 1429|       |  */
 1430|      8|  coap_ticks(&now);
 1431|      8|  if (context->sendqueue == NULL) {
  ------------------
  |  Branch (1431:7): [True: 8, False: 0]
  ------------------
 1432|      8|    node->t = node->timeout << node->retransmit_cnt;
 1433|      8|    context->sendqueue_basetime = now;
 1434|      8|  } else {
 1435|       |    /* make node->t relative to context->sendqueue_basetime */
 1436|      0|    node->t = (now - context->sendqueue_basetime) +
 1437|      0|              (node->timeout << node->retransmit_cnt);
 1438|      0|  }
 1439|      8|  coap_address_copy(&node->remote, &session->addr_info.remote);
 1440|       |
 1441|      8|  coap_insert_node(&context->sendqueue, node);
 1442|       |
 1443|      8|  coap_log_debug("** %s: mid=0x%04x: added to retransmit queue (%ums)\n",
  ------------------
  |  |  126|      8|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      8|#define coap_log(level, ...) do { \
  |  |  |  |  291|      8|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 8]
  |  |  |  |  ------------------
  |  |  |  |  292|      8|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      8|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 8]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1444|      8|                 coap_session_str(node->session), node->id,
 1445|      8|                 (unsigned)((node->timeout << node->retransmit_cnt) * 1000 /
 1446|      8|                            COAP_TICKS_PER_SECOND));
 1447|       |
 1448|      8|  coap_update_io_timer(context, node->t);
 1449|       |
 1450|      8|  return node->id;
 1451|      8|}
coap_client_delay_first:
 1510|      1|coap_client_delay_first(coap_session_t *session) {
 1511|      1|#if COAP_CLIENT_SUPPORT
 1512|      1|  if (session->type == COAP_SESSION_TYPE_CLIENT && session->doing_first) {
  ------------------
  |  Branch (1512:7): [True: 1, False: 0]
  |  Branch (1512:52): [True: 0, False: 1]
  ------------------
 1513|      0|    int timeout_ms = 5000;
 1514|      0|    coap_session_state_t current_state = session->state;
 1515|       |
 1516|      0|    if (session->delay_recursive) {
  ------------------
  |  Branch (1516:9): [True: 0, False: 0]
  ------------------
 1517|      0|      return 0;
 1518|      0|    } else {
 1519|      0|      session->delay_recursive = 1;
 1520|      0|    }
 1521|       |    /*
 1522|       |     * Need to wait for first request to get out and response back before
 1523|       |     * continuing.. Response handler has to clear doing_first if not an error.
 1524|       |     */
 1525|      0|    coap_session_reference_lkd(session);
 1526|      0|    while (session->doing_first != 0) {
  ------------------
  |  Branch (1526:12): [True: 0, False: 0]
  ------------------
 1527|      0|      int result = coap_io_process_lkd(session->context, 1000);
 1528|       |
 1529|      0|      if (result < 0) {
  ------------------
  |  Branch (1529:11): [True: 0, False: 0]
  ------------------
 1530|      0|        coap_reset_doing_first(session);
 1531|      0|        session->delay_recursive = 0;
 1532|      0|        coap_session_release_lkd(session);
 1533|      0|        return 0;
 1534|      0|      }
 1535|       |
 1536|       |      /* coap_io_process_lkd() may have updated session state */
 1537|      0|      if (session->state == COAP_SESSION_STATE_CSM &&
  ------------------
  |  Branch (1537:11): [True: 0, False: 0]
  ------------------
 1538|      0|          current_state != COAP_SESSION_STATE_CSM) {
  ------------------
  |  Branch (1538:11): [True: 0, False: 0]
  ------------------
 1539|       |        /* Update timeout and restart the clock for CSM timeout */
 1540|      0|        current_state = COAP_SESSION_STATE_CSM;
 1541|      0|        timeout_ms = session->context->csm_timeout_ms;
 1542|      0|        result = 0;
 1543|      0|      }
 1544|       |
 1545|      0|      if (result < timeout_ms) {
  ------------------
  |  Branch (1545:11): [True: 0, False: 0]
  ------------------
 1546|      0|        timeout_ms -= result;
 1547|      0|      } else {
 1548|      0|        if (session->doing_first == 1) {
  ------------------
  |  Branch (1548:13): [True: 0, False: 0]
  ------------------
 1549|       |          /* Timeout failure of some sort with first request */
 1550|      0|          if (session->state == COAP_SESSION_STATE_CSM) {
  ------------------
  |  Branch (1550:15): [True: 0, False: 0]
  ------------------
 1551|      0|            coap_log_debug("** %s: timeout waiting for CSM response\n",
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1552|      0|                           coap_session_str(session));
 1553|      0|            session->csm_not_seen = 1;
 1554|      0|          } else {
 1555|      0|            coap_log_debug("** %s: timeout waiting for first response\n",
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1556|      0|                           coap_session_str(session));
 1557|      0|          }
 1558|      0|          coap_reset_doing_first(session);
 1559|      0|          coap_session_connected(session);
 1560|      0|        }
 1561|      0|      }
 1562|      0|    }
 1563|      0|    session->delay_recursive = 0;
 1564|      0|    coap_session_release_lkd(session);
 1565|      0|  }
 1566|       |#else /* ! COAP_CLIENT_SUPPORT */
 1567|       |  (void)session;
 1568|       |#endif /* ! COAP_CLIENT_SUPPORT */
 1569|      1|  return 1;
 1570|      1|}
coap_check_code_class:
 1577|      9|coap_check_code_class(coap_session_t *session, coap_pdu_t *pdu) {
 1578|       |
 1579|       |  /* Check validity of sending code */
 1580|      9|  switch (COAP_RESPONSE_CLASS(pdu->code)) {
  ------------------
  |  |   99|      9|#define COAP_RESPONSE_CLASS(C) (((C) >> 5) & 0xFF)
  ------------------
 1581|      9|  case 0: /* Empty or request */
  ------------------
  |  Branch (1581:3): [True: 9, False: 0]
  ------------------
 1582|      9|  case 2: /* Success */
  ------------------
  |  Branch (1582:3): [True: 0, False: 9]
  ------------------
 1583|      9|  case 3: /* Reserved for future use */
  ------------------
  |  Branch (1583:3): [True: 0, False: 9]
  ------------------
 1584|      9|  case 4: /* Client error */
  ------------------
  |  Branch (1584:3): [True: 0, False: 9]
  ------------------
 1585|      9|  case 5: /* Server error */
  ------------------
  |  Branch (1585:3): [True: 0, False: 9]
  ------------------
 1586|      9|    break;
 1587|      0|  case 7: /* Reliable signalling */
  ------------------
  |  Branch (1587:3): [True: 0, False: 9]
  ------------------
 1588|      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]
  |  |  ------------------
  ------------------
 1589|      0|      break;
 1590|       |  /* Not valid if UDP */
 1591|       |  /* Fall through */
 1592|      0|  case 1: /* Invalid */
  ------------------
  |  Branch (1592:3): [True: 0, False: 9]
  ------------------
 1593|      0|  case 6: /* Invalid */
  ------------------
  |  Branch (1593:3): [True: 0, False: 9]
  ------------------
 1594|      0|  default:
  ------------------
  |  Branch (1594:3): [True: 0, False: 9]
  ------------------
 1595|      0|    return 0;
 1596|      9|  }
 1597|      9|  return 1;
 1598|      9|}
coap_send_lkd:
 1642|      9|coap_send_lkd(coap_session_t *session, coap_pdu_t *pdu) {
 1643|      9|  coap_mid_t mid = COAP_INVALID_MID;
  ------------------
  |  |  187|      9|#define COAP_INVALID_MID -1
  ------------------
 1644|      9|#if COAP_CLIENT_SUPPORT
 1645|      9|  coap_lg_crcv_t *lg_crcv = NULL;
 1646|      9|  coap_opt_iterator_t opt_iter;
 1647|      9|  coap_block_b_t block;
 1648|      9|  int observe_action = -1;
 1649|      9|  int have_block1 = 0;
 1650|      9|  coap_opt_t *opt;
 1651|      9|#endif /* COAP_CLIENT_SUPPORT */
 1652|       |
 1653|      9|  assert(pdu);
  ------------------
  |  Branch (1653:3): [True: 9, False: 0]
  ------------------
 1654|       |
 1655|      9|  coap_lock_check_locked();
  ------------------
  |  |  638|      9|#define coap_lock_check_locked() {}
  ------------------
 1656|       |
 1657|       |  /* Check validity of sending code */
 1658|      9|  if (!coap_check_code_class(session, pdu)) {
  ------------------
  |  Branch (1658:7): [True: 0, False: 9]
  ------------------
 1659|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1660|      0|                 COAP_RESPONSE_CLASS(pdu->code),
 1661|      0|                 pdu->code & 0x1f);
 1662|      0|    goto error;
 1663|      0|  }
 1664|      9|  pdu->session = session;
 1665|      9|#if COAP_CLIENT_SUPPORT
 1666|      9|  if (session->type == COAP_SESSION_TYPE_CLIENT &&
  ------------------
  |  Branch (1666:7): [True: 9, False: 0]
  ------------------
 1667|      9|      !coap_netif_available(session) && !session->session_failed) {
  ------------------
  |  Branch (1667:7): [True: 0, False: 9]
  |  Branch (1667:41): [True: 0, False: 0]
  ------------------
 1668|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1669|      0|    goto error;
 1670|      0|  }
 1671|       |
 1672|      9|  if (session->doing_first) {
  ------------------
  |  Branch (1672:7): [True: 0, False: 9]
  ------------------
 1673|      0|    unsigned int depth = 0;
 1674|      0|    coap_pdu_t *q_pdu;
 1675|       |
 1676|      0|    LL_FOREACH(session->doing_first_pdu, q_pdu)
  ------------------
  |  |  419|      0|    LL_FOREACH2(head,el,next)
  |  |  ------------------
  |  |  |  |  422|      0|    for ((el) = (head); el; (el) = (el)->next)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (422:25): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1677|      0|    depth++;
 1678|      0|    if (depth >= COAP_DOING_FIRST_MAX_QUEUE) {
  ------------------
  |  |   79|      0|#define COAP_DOING_FIRST_MAX_QUEUE 4
  ------------------
  |  Branch (1678:9): [True: 0, False: 0]
  ------------------
 1679|      0|      coap_log_warn("** %s: mid=0x%04x: doing_first queue full (%u) - dropped\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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1680|      0|                    coap_session_str(session), pdu->mid, depth);
 1681|      0|      goto error;
 1682|      0|    }
 1683|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1684|      0|    coap_show_pdu(COAP_LOG_DEBUG, pdu);
 1685|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1686|      0|                   coap_session_str(session), pdu->mid);
 1687|      0|    return  pdu->mid;
 1688|      0|  }
 1689|       |
 1690|       |  /* Indicate support for Extended Tokens if appropriate */
 1691|      9|  if (session->max_token_checked == COAP_EXT_T_NOT_CHECKED &&
  ------------------
  |  Branch (1691:7): [True: 9, False: 0]
  ------------------
 1692|      9|      session->max_token_size > COAP_TOKEN_DEFAULT_MAX &&
  ------------------
  |  |   58|     18|#define COAP_TOKEN_DEFAULT_MAX 8
  ------------------
  |  Branch (1692:7): [True: 0, False: 9]
  ------------------
 1693|      0|      session->type == COAP_SESSION_TYPE_CLIENT &&
  ------------------
  |  Branch (1693:7): [True: 0, False: 0]
  ------------------
 1694|      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]
  |  |  ------------------
  ------------------
 1695|      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]
  |  |  ------------------
  ------------------
 1696|       |      /*
 1697|       |       * When the pass / fail response for Extended Token is received, this PDU
 1698|       |       * will get transmitted.
 1699|       |       */
 1700|      0|      if (coap_send_test_extended_token(session) == COAP_INVALID_MID) {
  ------------------
  |  |  187|      0|#define COAP_INVALID_MID -1
  ------------------
  |  Branch (1700:11): [True: 0, False: 0]
  ------------------
 1701|      0|        goto error;
 1702|      0|      }
 1703|      0|    }
 1704|       |    /*
 1705|       |     * For reliable protocols, this will get cleared after CSM exchanged
 1706|       |     * in coap_session_connected() where Token size support is indicated in the CSM.
 1707|       |     */
 1708|      0|    session->doing_first = 1;
 1709|      0|    coap_ticks(&session->doing_first_timeout);
 1710|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1711|      0|    if (session->proto != COAP_PROTO_UDP) {
  ------------------
  |  Branch (1711:9): [True: 0, False: 0]
  ------------------
 1712|       |      /* In case the next handshake / CSM is already in */
 1713|      0|      coap_io_process_lkd(session->context, COAP_IO_NO_WAIT);
  ------------------
  |  |  867|      0|#define COAP_IO_NO_WAIT ((uint32_t)-1)
  ------------------
 1714|      0|    }
 1715|       |    /*
 1716|       |     * Once Extended Token support size is determined, coap_send_lkd(session, pdu)
 1717|       |     * will get called again.
 1718|       |     */
 1719|      0|    coap_show_pdu(COAP_LOG_DEBUG, pdu);
 1720|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1721|      0|                   coap_session_str(session), pdu->mid);
 1722|      0|    return pdu->mid;
 1723|      0|  }
 1724|      9|#if COAP_Q_BLOCK_SUPPORT
 1725|       |  /* Indicate support for Q-Block if appropriate */
 1726|      9|  if (session->block_mode & COAP_BLOCK_TRY_Q_BLOCK &&
  ------------------
  |  |   67|     18|#define COAP_BLOCK_TRY_Q_BLOCK   0x04 /* Try Q-Block method */
  ------------------
  |  Branch (1726:7): [True: 0, False: 9]
  ------------------
 1727|      0|      session->type == COAP_SESSION_TYPE_CLIENT &&
  ------------------
  |  Branch (1727:7): [True: 0, False: 0]
  ------------------
 1728|      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]
  |  |  ------------------
  ------------------
 1729|      0|    if (coap_block_test_q_block(session, pdu) == COAP_INVALID_MID) {
  ------------------
  |  |  187|      0|#define COAP_INVALID_MID -1
  ------------------
  |  Branch (1729:9): [True: 0, False: 0]
  ------------------
 1730|      0|      goto error;
 1731|      0|    }
 1732|      0|    session->doing_first = 1;
 1733|      0|    coap_ticks(&session->doing_first_timeout);
 1734|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1735|      0|    if (session->proto != COAP_PROTO_UDP) {
  ------------------
  |  Branch (1735:9): [True: 0, False: 0]
  ------------------
 1736|       |      /* In case the next handshake / CSM is already in */
 1737|      0|      coap_io_process_lkd(session->context, COAP_IO_NO_WAIT);
  ------------------
  |  |  867|      0|#define COAP_IO_NO_WAIT ((uint32_t)-1)
  ------------------
 1738|      0|    }
 1739|       |    /*
 1740|       |     * Once Extended Token support size is determined, coap_send_lkd(session, pdu)
 1741|       |     * will get called again.
 1742|       |     */
 1743|      0|    coap_show_pdu(COAP_LOG_DEBUG, pdu);
 1744|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1745|      0|                   coap_session_str(session), pdu->mid);
 1746|      0|    return pdu->mid;
 1747|      0|  }
 1748|      9|#endif /* COAP_Q_BLOCK_SUPPORT */
 1749|       |
 1750|       |  /*
 1751|       |   * Check validity of token length
 1752|       |   */
 1753|      9|  if (COAP_PDU_IS_REQUEST(pdu) &&
  ------------------
  |  |   99|     18|#define COAP_PDU_IS_REQUEST(pdu)   (!COAP_PDU_IS_EMPTY(pdu) && (pdu)->code < 32)
  |  |  ------------------
  |  |  |  |   98|     18|#define COAP_PDU_IS_EMPTY(pdu)     ((pdu)->code == 0)
  |  |  ------------------
  |  |  |  Branch (99:37): [True: 9, False: 0]
  |  |  |  Branch (99:64): [True: 9, False: 0]
  |  |  ------------------
  ------------------
 1754|      9|      pdu->actual_token.length > session->max_token_size) {
  ------------------
  |  Branch (1754:7): [True: 0, False: 9]
  ------------------
 1755|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1756|      0|                  pdu->actual_token.length, session->max_token_size);
 1757|      0|    goto error;
 1758|      0|  }
 1759|       |
 1760|       |  /* A lot of the reliable code assumes type is CON */
 1761|      9|  if (COAP_PROTO_RELIABLE(session->proto) && pdu->type != COAP_MESSAGE_CON)
  ------------------
  |  |   42|     18|#define COAP_PROTO_RELIABLE(p) ((p)==COAP_PROTO_TCP || (p)==COAP_PROTO_TLS || \
  |  |  ------------------
  |  |  |  Branch (42:33): [True: 0, False: 9]
  |  |  |  Branch (42:56): [True: 0, False: 9]
  |  |  ------------------
  |  |   43|      9|                                (p)==COAP_PROTO_WS || (p)==COAP_PROTO_WSS)
  |  |  ------------------
  |  |  |  Branch (43:33): [True: 0, False: 9]
  |  |  |  Branch (43:55): [True: 0, False: 9]
  |  |  ------------------
  ------------------
  |  Branch (1761:46): [True: 0, False: 0]
  ------------------
 1762|      0|    pdu->type = COAP_MESSAGE_CON;
 1763|       |
 1764|      9|#if COAP_OSCORE_SUPPORT
 1765|      9|  if (session->oscore_encryption) {
  ------------------
  |  Branch (1765:7): [True: 0, False: 9]
  ------------------
 1766|      0|    if (session->recipient_ctx->initial_state == 1 &&
  ------------------
  |  Branch (1766:9): [True: 0, False: 0]
  ------------------
 1767|      0|        !session->recipient_ctx->silent_server) {
  ------------------
  |  Branch (1767:9): [True: 0, False: 0]
  ------------------
 1768|       |      /*
 1769|       |       * Not sure if remote supports OSCORE, or is going to send us a
 1770|       |       * "4.01 + ECHO" etc. so need to hold off future coap_send()s until all
 1771|       |       * is OK. Continue sending current pdu to test things.
 1772|       |       *
 1773|       |       * Record when we started waiting so coap_io_prepare_io_lkd() can time
 1774|       |       * out (same 5s window as Extended Token / Q-Block) and call
 1775|       |       * coap_reset_doing_first(). Without doing_first_timeout set, UDP clients
 1776|       |       * could stall forever if no response arrives (e.g. observe resubscribe
 1777|       |       * while recipient_ctx->initial_state is still 1).
 1778|       |       */
 1779|      0|      session->doing_first = 1;
 1780|      0|      coap_ticks(&session->doing_first_timeout);
 1781|      0|    }
 1782|       |    /* Need to convert Proxy-Uri to Proxy-Scheme option if needed */
 1783|      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 (1783:37): [True: 0, False: 0]
  ------------------
 1784|      0|      goto error;
 1785|      0|    }
 1786|      0|  }
 1787|      9|#endif /* COAP_OSCORE_SUPPORT */
 1788|       |
 1789|      9|  if (!(session->block_mode & COAP_BLOCK_USE_LIBCOAP)) {
  ------------------
  |  |   65|      9|#define COAP_BLOCK_USE_LIBCOAP  0x01 /* Use libcoap to do block requests */
  ------------------
  |  Branch (1789:7): [True: 9, False: 0]
  ------------------
 1790|      9|    return coap_send_internal(session, pdu, NULL);
 1791|      9|  }
 1792|       |
 1793|      0|  if (session->no_path_abbrev) {
  ------------------
  |  Branch (1793:7): [True: 0, False: 0]
  ------------------
 1794|      0|    opt = coap_check_option(pdu, COAP_OPTION_URI_PATH_ABB, &opt_iter);
 1795|      0|    if (opt) {
  ------------------
  |  Branch (1795:9): [True: 0, False: 0]
  ------------------
 1796|       |      /* Server cannot handle Uri-Path-Abbrev */
 1797|      0|      coap_pdu_t *new;
 1798|      0|      size_t data_len;
 1799|      0|      const uint8_t *data;
 1800|       |
 1801|      0|      new = coap_pdu_duplicate_lkd(pdu, session, pdu->actual_token.length,
 1802|      0|                                   pdu->actual_token.s, NULL, COAP_BOOL_TRUE);
 1803|      0|      if (new) {
  ------------------
  |  Branch (1803:11): [True: 0, False: 0]
  ------------------
 1804|      0|        if (coap_get_data(pdu, &data_len, &data)) {
  ------------------
  |  Branch (1804:13): [True: 0, False: 0]
  ------------------
 1805|      0|          coap_add_data(pdu, data_len, data);
 1806|      0|        }
 1807|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1808|      0|        coap_delete_pdu_lkd(pdu);
 1809|      0|        pdu = new;
 1810|      0|      }
 1811|      0|    }
 1812|      0|  }
 1813|       |
 1814|      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]
  |  |  ------------------
  ------------------
 1815|      0|    uint8_t buf[4];
 1816|       |
 1817|      0|    opt = coap_check_option(pdu, COAP_OPTION_OBSERVE, &opt_iter);
 1818|       |
 1819|      0|    if (opt) {
  ------------------
  |  Branch (1819:9): [True: 0, False: 0]
  ------------------
 1820|      0|      observe_action = coap_decode_var_bytes(coap_opt_value(opt),
 1821|      0|                                             coap_opt_length(opt));
 1822|      0|    }
 1823|       |
 1824|      0|    if (coap_get_block_b(session, pdu, COAP_OPTION_BLOCK1, &block) &&
  ------------------
  |  Branch (1824:9): [True: 0, False: 0]
  ------------------
 1825|      0|        (block.m == 1 || block.bert == 1)) {
  ------------------
  |  Branch (1825:10): [True: 0, False: 0]
  |  Branch (1825:26): [True: 0, False: 0]
  ------------------
 1826|      0|      have_block1 = 1;
 1827|      0|    }
 1828|      0|#if COAP_Q_BLOCK_SUPPORT
 1829|      0|    if (coap_get_block_b(session, pdu, COAP_OPTION_Q_BLOCK1, &block) &&
  ------------------
  |  Branch (1829:9): [True: 0, False: 0]
  ------------------
 1830|      0|        (block.m == 1 || block.bert == 1)) {
  ------------------
  |  Branch (1830:10): [True: 0, False: 0]
  |  Branch (1830:26): [True: 0, False: 0]
  ------------------
 1831|      0|      if (have_block1) {
  ------------------
  |  Branch (1831:11): [True: 0, False: 0]
  ------------------
 1832|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1833|      0|        coap_remove_option(pdu, COAP_OPTION_BLOCK1);
 1834|      0|      }
 1835|      0|      have_block1 = 1;
 1836|      0|    }
 1837|      0|#endif /* COAP_Q_BLOCK_SUPPORT */
 1838|      0|    if (observe_action != COAP_OBSERVE_CANCEL) {
  ------------------
  |  |   44|      0|#define COAP_OBSERVE_CANCEL 1
  ------------------
  |  Branch (1838:9): [True: 0, False: 0]
  ------------------
 1839|       |      /* Warn about reuse of tokens */
 1840|      0|      if (session->last_token &&
  ------------------
  |  Branch (1840:11): [True: 0, False: 0]
  ------------------
 1841|      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]
  |  |  ------------------
  ------------------
 1842|      0|        if (coap_get_log_level() >= COAP_LOG_DEBUG) {
  ------------------
  |  Branch (1842:13): [True: 0, False: 0]
  ------------------
 1843|      0|          char scratch[24];
 1844|      0|          size_t size;
 1845|      0|          size_t i;
 1846|       |
 1847|      0|          scratch[0] = '\000';
 1848|      0|          for (i = 0; i < pdu->actual_token.length; i++) {
  ------------------
  |  Branch (1848:23): [True: 0, False: 0]
  ------------------
 1849|      0|            size = strlen(scratch);
 1850|      0|            snprintf(&scratch[size], sizeof(scratch)-size,
 1851|      0|                     "%02x", pdu->actual_token.s[i]);
 1852|      0|          }
 1853|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1854|      0|                         scratch);
 1855|      0|        }
 1856|      0|      }
 1857|      0|      coap_delete_bin_const(session->last_token);
 1858|      0|      session->last_token = coap_new_bin_const(pdu->actual_token.s,
 1859|      0|                                               pdu->actual_token.length);
 1860|      0|    } else {
 1861|       |      /* observe_action == COAP_OBSERVE_CANCEL */
 1862|      0|      coap_binary_t tmp;
 1863|      0|      int ret;
 1864|       |
 1865|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1866|       |      /* Unfortunately need to change the ptr type to be r/w */
 1867|      0|      memcpy(&tmp.s, &pdu->actual_token.s, sizeof(tmp.s));
 1868|      0|      tmp.length = pdu->actual_token.length;
 1869|      0|      ret = coap_cancel_observe_lkd(session, &tmp, pdu->type);
 1870|      0|      if (ret == 1) {
  ------------------
  |  Branch (1870:11): [True: 0, False: 0]
  ------------------
 1871|       |        /* Observe Cancel successfully sent */
 1872|      0|        coap_delete_pdu_lkd(pdu);
 1873|      0|        return ret;
 1874|      0|      }
 1875|       |      /* Some mismatch somewhere - continue to send original packet */
 1876|      0|    }
 1877|      0|    if (!coap_check_option(pdu, COAP_OPTION_RTAG, &opt_iter) &&
  ------------------
  |  Branch (1877:9): [True: 0, False: 0]
  ------------------
 1878|      0|        (session->block_mode & COAP_BLOCK_NO_PREEMPTIVE_RTAG) == 0 &&
  ------------------
  |  |   69|      0|#define COAP_BLOCK_NO_PREEMPTIVE_RTAG 0x10 /* (cl) Don't use preemptive Request-Tags */
  ------------------
  |  Branch (1878:9): [True: 0, False: 0]
  ------------------
 1879|      0|        pdu->code != COAP_REQUEST_CODE_DELETE)
  ------------------
  |  Branch (1879:9): [True: 0, False: 0]
  ------------------
 1880|      0|      coap_insert_option(pdu,
 1881|      0|                         COAP_OPTION_RTAG,
 1882|      0|                         coap_encode_var_safe(buf, sizeof(buf),
 1883|      0|                                              ++session->tx_rtag),
 1884|      0|                         buf);
 1885|      0|  } else {
 1886|      0|    memset(&block, 0, sizeof(block));
 1887|      0|  }
 1888|       |
 1889|      0|#if COAP_Q_BLOCK_SUPPORT
 1890|      0|  if (!(session->block_mode & COAP_BLOCK_HAS_Q_BLOCK))
  ------------------
  |  |   71|      0|#define COAP_BLOCK_HAS_Q_BLOCK   0x40000000 /* Set when Q_BLOCK supported */
  ------------------
  |  Branch (1890:7): [True: 0, False: 0]
  ------------------
 1891|      0|#endif /* COAP_Q_BLOCK_SUPPORT */
 1892|      0|  {
 1893|       |    /* Need to check if we need to reset Q-Block to Block */
 1894|      0|    uint8_t buf[4];
 1895|       |
 1896|      0|    if (coap_get_block_b(session, pdu, COAP_OPTION_Q_BLOCK2, &block)) {
  ------------------
  |  Branch (1896:9): [True: 0, False: 0]
  ------------------
 1897|      0|      coap_remove_option(pdu, COAP_OPTION_Q_BLOCK2);
 1898|      0|      coap_insert_option(pdu, COAP_OPTION_BLOCK2,
 1899|      0|                         coap_encode_var_safe(buf, sizeof(buf),
 1900|      0|                                              (block.num << 4) | (0 << 3) | block.szx),
 1901|      0|                         buf);
 1902|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1903|       |      /* Need to update associated lg_xmit */
 1904|      0|      coap_lg_xmit_t *lg_xmit;
 1905|       |
 1906|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1907|      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]
  |  |  ------------------
  ------------------
 1908|      0|            lg_xmit->b.b1.app_token &&
  ------------------
  |  Branch (1908:13): [True: 0, False: 0]
  ------------------
 1909|      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]
  |  |  ------------------
  ------------------
 1910|       |          /* Update the skeletal PDU with the block1 option */
 1911|      0|          coap_remove_option(lg_xmit->sent_pdu, COAP_OPTION_Q_BLOCK2);
 1912|      0|          coap_update_option(lg_xmit->sent_pdu, COAP_OPTION_BLOCK2,
 1913|      0|                             coap_encode_var_safe(buf, sizeof(buf),
 1914|      0|                                                  (block.num << 4) | (0 << 3) | block.szx),
 1915|      0|                             buf);
 1916|      0|          break;
 1917|      0|        }
 1918|      0|      }
 1919|      0|    }
 1920|      0|    if (coap_get_block_b(session, pdu, COAP_OPTION_Q_BLOCK1, &block)) {
  ------------------
  |  Branch (1920:9): [True: 0, False: 0]
  ------------------
 1921|      0|      coap_remove_option(pdu, COAP_OPTION_Q_BLOCK1);
 1922|      0|      coap_insert_option(pdu, COAP_OPTION_BLOCK1,
 1923|      0|                         coap_encode_var_safe(buf, sizeof(buf),
 1924|      0|                                              (block.num << 4) | (block.m << 3) | block.szx),
 1925|      0|                         buf);
 1926|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1927|       |      /* Need to update associated lg_xmit */
 1928|      0|      coap_lg_xmit_t *lg_xmit;
 1929|       |
 1930|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1931|      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]
  |  |  ------------------
  ------------------
 1932|      0|            lg_xmit->b.b1.app_token &&
  ------------------
  |  Branch (1932:13): [True: 0, False: 0]
  ------------------
 1933|      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]
  |  |  ------------------
  ------------------
 1934|       |          /* Update the skeletal PDU with the block1 option */
 1935|      0|          coap_remove_option(lg_xmit->sent_pdu, COAP_OPTION_Q_BLOCK1);
 1936|      0|          coap_update_option(lg_xmit->sent_pdu, COAP_OPTION_BLOCK1,
 1937|      0|                             coap_encode_var_safe(buf, sizeof(buf),
 1938|      0|                                                  (block.num << 4) |
 1939|      0|                                                  (block.m << 3) |
 1940|      0|                                                  block.szx),
 1941|      0|                             buf);
 1942|       |          /* Update as this is a Request */
 1943|      0|          lg_xmit->option = COAP_OPTION_BLOCK1;
 1944|      0|          break;
 1945|      0|        }
 1946|      0|      }
 1947|      0|    }
 1948|      0|  }
 1949|       |
 1950|      0|#if COAP_Q_BLOCK_SUPPORT
 1951|      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]
  |  |  ------------------
  ------------------
 1952|      0|      coap_get_block_b(session, pdu, COAP_OPTION_Q_BLOCK2, &block)) {
  ------------------
  |  Branch (1952:7): [True: 0, False: 0]
  ------------------
 1953|      0|    if (block.num == 0 && block.m == 0) {
  ------------------
  |  Branch (1953:9): [True: 0, False: 0]
  |  Branch (1953:27): [True: 0, False: 0]
  ------------------
 1954|      0|      uint8_t buf[4];
 1955|       |
 1956|       |      /* M needs to be set as asking for all the blocks */
 1957|      0|      coap_update_option(pdu, COAP_OPTION_Q_BLOCK2,
 1958|      0|                         coap_encode_var_safe(buf, sizeof(buf),
 1959|      0|                                              (0 << 4) | (1 << 3) | block.szx),
 1960|      0|                         buf);
 1961|      0|    }
 1962|      0|  }
 1963|      0|#endif /* COAP_Q_BLOCK_SUPPORT */
 1964|       |
 1965|       |  /*
 1966|       |   * If type is CON and protocol is not reliable, there is no need to set up
 1967|       |   * lg_crcv here as it can be built up based on sent PDU if there is a
 1968|       |   * (Q-)Block2 in the response.  However, still need it for Observe, Oscore and
 1969|       |   * (Q-)Block1.
 1970|       |   */
 1971|      0|  if (coap_check_send_need_lg_crcv(session, pdu)) {
  ------------------
  |  Branch (1971:7): [True: 0, False: 0]
  ------------------
 1972|      0|    coap_lg_xmit_t *lg_xmit = NULL;
 1973|       |
 1974|      0|    if (!session->lg_xmit && have_block1) {
  ------------------
  |  Branch (1974:9): [True: 0, False: 0]
  |  Branch (1974:30): [True: 0, False: 0]
  ------------------
 1975|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1976|      0|      coap_show_pdu(COAP_LOG_DEBUG, pdu);
 1977|      0|    }
 1978|       |    /* See if this token is already in use for large body responses */
 1979|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1980|      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]
  |  |  ------------------
  ------------------
 1981|       |        /* Need to terminate and clean up previous response setup */
 1982|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1983|      0|        coap_block_delete_lg_crcv(session, lg_crcv);
 1984|      0|        break;
 1985|      0|      }
 1986|      0|    }
 1987|       |
 1988|      0|    if (have_block1 && session->lg_xmit) {
  ------------------
  |  Branch (1988:9): [True: 0, False: 0]
  |  Branch (1988:24): [True: 0, False: 0]
  ------------------
 1989|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1990|      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]
  |  |  ------------------
  ------------------
 1991|      0|            lg_xmit->b.b1.app_token &&
  ------------------
  |  Branch (1991:13): [True: 0, False: 0]
  ------------------
 1992|      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]
  |  |  ------------------
  ------------------
 1993|      0|          break;
 1994|      0|        }
 1995|      0|      }
 1996|      0|    }
 1997|      0|    lg_crcv = coap_block_new_lg_crcv(session, pdu, lg_xmit);
 1998|      0|    if (lg_crcv == NULL) {
  ------------------
  |  Branch (1998:9): [True: 0, False: 0]
  ------------------
 1999|      0|      goto error;
 2000|      0|    }
 2001|      0|    if (lg_xmit) {
  ------------------
  |  Branch (2001:9): [True: 0, False: 0]
  ------------------
 2002|       |      /* Need to update the token as set up in the session->lg_xmit */
 2003|      0|      lg_xmit->b.b1.state_token = lg_crcv->state_token;
 2004|      0|    }
 2005|      0|  }
 2006|      0|  if (session->sock.flags & COAP_SOCKET_MULTICAST)
  ------------------
  |  |   86|      0|#define COAP_SOCKET_MULTICAST    0x1000  /**< socket is used for multicast communication */
  ------------------
  |  Branch (2006:7): [True: 0, False: 0]
  ------------------
 2007|      0|    coap_address_copy(&session->addr_info.remote, &session->sock.mcast_addr);
 2008|       |
 2009|      0|#if COAP_Q_BLOCK_SUPPORT
 2010|       |  /* See if large xmit using Q-Block1 (but not testing Q-Block1) */
 2011|      0|  if (coap_get_block_b(session, pdu, COAP_OPTION_Q_BLOCK1, &block)) {
  ------------------
  |  Branch (2011:7): [True: 0, False: 0]
  ------------------
 2012|      0|    mid = coap_send_q_block1(session, block, pdu, COAP_SEND_INC_PDU);
 2013|      0|  } else
 2014|      0|#endif /* COAP_Q_BLOCK_SUPPORT */
 2015|      0|    mid = coap_send_internal(session, pdu, NULL);
 2016|       |#else /* !COAP_CLIENT_SUPPORT */
 2017|       |  mid = coap_send_internal(session, pdu, NULL);
 2018|       |#endif /* !COAP_CLIENT_SUPPORT */
 2019|      0|#if COAP_CLIENT_SUPPORT
 2020|      0|  if (lg_crcv) {
  ------------------
  |  Branch (2020:7): [True: 0, False: 0]
  ------------------
 2021|      0|    if (mid != COAP_INVALID_MID) {
  ------------------
  |  |  187|      0|#define COAP_INVALID_MID -1
  ------------------
  |  Branch (2021:9): [True: 0, False: 0]
  ------------------
 2022|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2023|      0|    } else {
 2024|      0|      coap_block_delete_lg_crcv(session, lg_crcv);
 2025|      0|    }
 2026|      0|  }
 2027|      0|#endif /* COAP_CLIENT_SUPPORT */
 2028|      0|  return mid;
 2029|       |
 2030|      0|error:
 2031|      0|  coap_delete_pdu_lkd(pdu);
 2032|      0|  return COAP_INVALID_MID;
  ------------------
  |  |  187|      0|#define COAP_INVALID_MID -1
  ------------------
 2033|      0|}
coap_send_internal:
 2151|      9|coap_send_internal(coap_session_t *session, coap_pdu_t *pdu, coap_pdu_t *request_pdu) {
 2152|      9|  uint8_t r;
 2153|      9|  ssize_t bytes_written;
 2154|       |
 2155|       |#if ! COAP_SERVER_SUPPORT
 2156|       |  (void)request_pdu;
 2157|       |#endif /* COAP_SERVER_SUPPORT */
 2158|      9|  pdu->session = session;
 2159|      9|#if COAP_CLIENT_SUPPORT
 2160|      9|  if (session->session_failed) {
  ------------------
  |  Branch (2160:7): [True: 0, False: 9]
  ------------------
 2161|      0|    coap_session_reconnect(session);
 2162|      0|    if (session->session_failed)
  ------------------
  |  Branch (2162:9): [True: 0, False: 0]
  ------------------
 2163|      0|      goto error;
 2164|      0|  }
 2165|      9|#endif /* COAP_CLIENT_SUPPORT */
 2166|      9|  if (pdu->type == COAP_MESSAGE_NON && session->rl_ticks_per_packet) {
  ------------------
  |  Branch (2166:7): [True: 1, False: 8]
  |  Branch (2166:40): [True: 0, False: 1]
  ------------------
 2167|      0|    coap_tick_t now;
 2168|       |
 2169|      0|    if (!session->is_rate_limiting) {
  ------------------
  |  Branch (2169:9): [True: 0, False: 0]
  ------------------
 2170|      0|      coap_ticks(&now);
 2171|      0|#if (COAP_MAX_LOGGING_LEVEL >= _COAP_LOG_DEBUG)
 2172|      0|      if (now - session->last_tx < session->rl_ticks_per_packet) {
  ------------------
  |  Branch (2172:11): [True: 0, False: 0]
  ------------------
 2173|      0|        uint32_t rem = (uint32_t)(session->rl_ticks_per_packet -
 2174|      0|                                  (now - session->last_tx)) * 1000 / COAP_TICKS_PER_SECOND;
  ------------------
  |  |  164|      0|#define COAP_TICKS_PER_SECOND ((coap_tick_t)(1000U))
  ------------------
 2175|      0|        coap_log_debug("** %s: mid 0x%04x: delaying transmission (%" PRIu32 ".%03" PRIu32 "s)\n",
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2176|      0|                       coap_session_str(session), pdu->mid, rem / 1000, rem %1000);
 2177|      0|        coap_show_pdu(COAP_LOG_DEBUG, pdu);
 2178|      0|      }
 2179|      0|#endif /* COAP_MAX_LOGGING_LEVEL >= _COAP_LOG_DEBUG */
 2180|      0|      while (1) {
  ------------------
  |  Branch (2180:14): [True: 0, Folded]
  ------------------
 2181|      0|        uint32_t timeout_ms;
 2182|       |
 2183|      0|        if (send_recv_terminate) {
  ------------------
  |  Branch (2183:13): [True: 0, False: 0]
  ------------------
 2184|      0|          goto error;
 2185|      0|        }
 2186|       |
 2187|      0|        if (now - session->last_tx >= session->rl_ticks_per_packet) {
  ------------------
  |  Branch (2187:13): [True: 0, False: 0]
  ------------------
 2188|      0|          break;
 2189|      0|        }
 2190|      0|        timeout_ms = (uint32_t)(((session->rl_ticks_per_packet - (now - session->last_tx)) *
 2191|      0|                                 1000) / COAP_TICKS_PER_SECOND);
  ------------------
  |  |  164|      0|#define COAP_TICKS_PER_SECOND ((coap_tick_t)(1000U))
  ------------------
 2192|       |
 2193|      0|        if (timeout_ms == 0) {
  ------------------
  |  Branch (2193:13): [True: 0, False: 0]
  ------------------
 2194|      0|          timeout_ms = COAP_IO_NO_WAIT;
  ------------------
  |  |  867|      0|#define COAP_IO_NO_WAIT ((uint32_t)-1)
  ------------------
 2195|      0|        }
 2196|       |
 2197|      0|        session->is_rate_limiting = 1;
 2198|      0|        coap_io_process_lkd(session->context, timeout_ms);
 2199|      0|        session->is_rate_limiting = 0;
 2200|      0|        coap_ticks(&now);
 2201|      0|      }
 2202|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2203|      0|                     coap_session_str(session), pdu->mid);
 2204|      0|      session->last_tx = now;
 2205|      0|    }
 2206|      0|  }
 2207|      9|#if COAP_PROXY_SUPPORT
 2208|      9|  if (session->server_list) {
  ------------------
  |  Branch (2208:7): [True: 0, False: 9]
  ------------------
 2209|       |    /* Local session wanting to use proxy logic */
 2210|      0|    return coap_proxy_local_write(session, pdu);
 2211|      0|  }
 2212|      9|#endif /* COAP_PROXY_SUPPORT */
 2213|      9|  if (pdu->code == COAP_RESPONSE_CODE(508)) {
  ------------------
  |  |   96|      9|#define COAP_RESPONSE_CODE(N) (((N)/100 << 5) | (N)%100)
  ------------------
  |  Branch (2213:7): [True: 0, False: 9]
  ------------------
 2214|       |    /*
 2215|       |     * Need to prepend our IP identifier to the data as per
 2216|       |     * https://rfc-editor.org/rfc/rfc8768.html#section-4
 2217|       |     */
 2218|      0|    if (!prepend_508_ip(session, pdu)) {
  ------------------
  |  Branch (2218:9): [True: 0, False: 0]
  ------------------
 2219|      0|      return (coap_mid_t)COAP_DROPPED_RESPONSE;
  ------------------
  |  |   92|      0|#define COAP_DROPPED_RESPONSE -2
  ------------------
 2220|      0|    }
 2221|      0|  }
 2222|       |
 2223|      9|  if (session->echo) {
  ------------------
  |  Branch (2223:7): [True: 0, False: 9]
  ------------------
 2224|      0|    if (!coap_insert_option(pdu, COAP_OPTION_ECHO, session->echo->length,
  ------------------
  |  Branch (2224:9): [True: 0, False: 0]
  ------------------
 2225|      0|                            session->echo->s))
 2226|      0|      goto error;
 2227|      0|    coap_delete_bin_const(session->echo);
 2228|      0|    session->echo = NULL;
 2229|      0|  }
 2230|      9|#if COAP_OSCORE_SUPPORT
 2231|      9|  if (session->oscore_encryption) {
  ------------------
  |  Branch (2231:7): [True: 0, False: 9]
  ------------------
 2232|       |    /* Need to convert Proxy-Uri to Proxy-Scheme option if needed */
 2233|      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 (2233:37): [True: 0, False: 0]
  ------------------
 2234|      0|      goto error;
 2235|      0|  }
 2236|      9|#endif /* COAP_OSCORE_SUPPORT */
 2237|       |
 2238|      9|  if (!coap_pdu_encode_header(pdu, session->proto)) {
  ------------------
  |  Branch (2238:7): [True: 0, False: 9]
  ------------------
 2239|      0|    goto error;
 2240|      0|  }
 2241|       |
 2242|      9|#if !COAP_DISABLE_TCP
 2243|      9|  if (COAP_PROTO_RELIABLE(session->proto) &&
  ------------------
  |  |   42|     18|#define COAP_PROTO_RELIABLE(p) ((p)==COAP_PROTO_TCP || (p)==COAP_PROTO_TLS || \
  |  |  ------------------
  |  |  |  Branch (42:33): [True: 0, False: 9]
  |  |  |  Branch (42:56): [True: 0, False: 9]
  |  |  ------------------
  |  |   43|      9|                                (p)==COAP_PROTO_WS || (p)==COAP_PROTO_WSS)
  |  |  ------------------
  |  |  |  Branch (43:33): [True: 0, False: 9]
  |  |  |  Branch (43:55): [True: 0, False: 9]
  |  |  ------------------
  ------------------
 2244|      0|      session->state == COAP_SESSION_STATE_ESTABLISHED) {
  ------------------
  |  Branch (2244:7): [True: 0, False: 0]
  ------------------
 2245|      0|    coap_opt_iterator_t opt_iter;
 2246|       |
 2247|      0|    if (!session->csm_block_supported) {
  ------------------
  |  Branch (2247:9): [True: 0, False: 0]
  ------------------
 2248|       |      /*
 2249|       |       * Need to check that this instance is not sending any block options as
 2250|       |       * the remote end via CSM has not informed us that there is support
 2251|       |       * https://rfc-editor.org/rfc/rfc8323#section-5.3.2
 2252|       |       * This includes potential BERT blocks.
 2253|       |       */
 2254|      0|      if (coap_check_option(pdu, COAP_OPTION_BLOCK1, &opt_iter) != NULL) {
  ------------------
  |  Branch (2254:11): [True: 0, False: 0]
  ------------------
 2255|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2256|      0|      }
 2257|      0|      if (coap_check_option(pdu, COAP_OPTION_BLOCK2, &opt_iter) != NULL) {
  ------------------
  |  Branch (2257:11): [True: 0, False: 0]
  ------------------
 2258|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2259|      0|      }
 2260|      0|    } else if (!session->csm_bert_rem_support) {
  ------------------
  |  Branch (2260:16): [True: 0, False: 0]
  ------------------
 2261|      0|      coap_opt_t *opt;
 2262|       |
 2263|      0|      opt = coap_check_option(pdu, COAP_OPTION_BLOCK1, &opt_iter);
 2264|      0|      if (opt && COAP_OPT_BLOCK_SZX(opt) == 7) {
  ------------------
  |  |   96|      0|  (coap_opt_length(opt) ? (COAP_OPT_BLOCK_END_BYTE(opt) & 0x07) : 0)
  |  |  ------------------
  |  |  |  |   87|      0|  ((coap_opt_length(opt) && coap_opt_value(opt)) ? \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (87:5): [True: 0, False: 0]
  |  |  |  |  |  Branch (87:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   88|      0|   *(coap_opt_value(opt) + (coap_opt_length(opt)-1)) : 0)
  |  |  ------------------
  |  |  |  Branch (96:4): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (2264:11): [True: 0, False: 0]
  |  Branch (2264:18): [True: 0, False: 0]
  ------------------
 2265|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2266|      0|      }
 2267|      0|      opt = coap_check_option(pdu, COAP_OPTION_BLOCK2, &opt_iter);
 2268|      0|      if (opt && COAP_OPT_BLOCK_SZX(opt) == 7) {
  ------------------
  |  |   96|      0|  (coap_opt_length(opt) ? (COAP_OPT_BLOCK_END_BYTE(opt) & 0x07) : 0)
  |  |  ------------------
  |  |  |  |   87|      0|  ((coap_opt_length(opt) && coap_opt_value(opt)) ? \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (87:5): [True: 0, False: 0]
  |  |  |  |  |  Branch (87:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   88|      0|   *(coap_opt_value(opt) + (coap_opt_length(opt)-1)) : 0)
  |  |  ------------------
  |  |  |  Branch (96:4): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (2268:11): [True: 0, False: 0]
  |  Branch (2268:18): [True: 0, False: 0]
  ------------------
 2269|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2270|      0|      }
 2271|      0|    }
 2272|      0|  }
 2273|      9|#endif /* !COAP_DISABLE_TCP */
 2274|       |
 2275|      9|#if COAP_OSCORE_SUPPORT
 2276|      9|  if (session->oscore_encryption &&
  ------------------
  |  Branch (2276:7): [True: 0, False: 9]
  ------------------
 2277|      0|      pdu->type != COAP_MESSAGE_RST &&
  ------------------
  |  Branch (2277:7): [True: 0, False: 0]
  ------------------
 2278|      0|      !(pdu->type == COAP_MESSAGE_ACK && pdu->code == COAP_EMPTY_CODE) &&
  ------------------
  |  Branch (2278:9): [True: 0, False: 0]
  |  Branch (2278:42): [True: 0, False: 0]
  ------------------
 2279|      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 (2279:48): [True: 0, False: 0]
  ------------------
 2280|       |    /* Refactor PDU as appropriate RFC8613 */
 2281|      0|    coap_pdu_t *osc_pdu = coap_oscore_new_pdu_encrypted_lkd(session, pdu, NULL, 0);
 2282|       |
 2283|      0|    if (osc_pdu == NULL) {
  ------------------
  |  Branch (2283:9): [True: 0, False: 0]
  ------------------
 2284|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2285|      0|      if (coap_get_log_level() < COAP_LOG_DEBUG)
  ------------------
  |  Branch (2285:11): [True: 0, False: 0]
  ------------------
 2286|      0|        coap_show_pdu(COAP_LOG_WARN, pdu);
 2287|      0|      goto error;
 2288|      0|    }
 2289|      0|    bytes_written = coap_send_pdu(session, osc_pdu, NULL);
 2290|      0|    coap_delete_pdu_lkd(pdu);
 2291|      0|    pdu = osc_pdu;
 2292|      0|  } else
 2293|      9|#endif /* COAP_OSCORE_SUPPORT */
 2294|      9|    bytes_written = coap_send_pdu(session, pdu, NULL);
 2295|       |
 2296|      9|#if COAP_SERVER_SUPPORT
 2297|      9|  if (session->last_resp_pdu != pdu &&
  ------------------
  |  Branch (2297:7): [True: 9, False: 0]
  ------------------
 2298|      9|      request_pdu && 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: 0, False: 0]
  |  |  |  Branch (41:60): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (2298:7): [True: 0, False: 9]
  ------------------
 2299|      0|      COAP_PDU_IS_REQUEST(request_pdu) &&
  ------------------
  |  |   99|      9|#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]
  |  |  ------------------
  ------------------
 2300|      0|      COAP_PDU_IS_RESPONSE(pdu) && pdu->type == COAP_MESSAGE_ACK) {
  ------------------
  |  |  101|      9|#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 (2300:36): [True: 0, False: 0]
  ------------------
 2301|      0|    coap_delete_pdu_lkd(session->last_resp_pdu);
 2302|      0|    session->last_resp_pdu = pdu;
 2303|      0|    coap_pdu_reference_lkd(session->last_resp_pdu);
 2304|      0|  }
 2305|      9|#endif /* COAP_SERVER_SUPPORT */
 2306|       |
 2307|      9|  if (bytes_written == COAP_PDU_DELAYED) {
  ------------------
  |  |   94|      9|#define COAP_PDU_DELAYED -3
  ------------------
  |  Branch (2307:7): [True: 0, False: 9]
  ------------------
 2308|       |    /* do not free pdu as it is stored with session for later use */
 2309|      0|    return pdu->mid;
 2310|      0|  }
 2311|      9|  if (bytes_written < 0) {
  ------------------
  |  Branch (2311:7): [True: 0, False: 9]
  ------------------
 2312|      0|    if (pdu->code != 0)
  ------------------
  |  Branch (2312:9): [True: 0, False: 0]
  ------------------
 2313|      0|      coap_session_disconnected_lkd(session, COAP_NACK_NOT_DELIVERABLE);
 2314|      0|    goto error;
 2315|      0|  }
 2316|       |
 2317|      9|#if !COAP_DISABLE_TCP
 2318|      9|  if (COAP_PROTO_RELIABLE(session->proto) &&
  ------------------
  |  |   42|     18|#define COAP_PROTO_RELIABLE(p) ((p)==COAP_PROTO_TCP || (p)==COAP_PROTO_TLS || \
  |  |  ------------------
  |  |  |  Branch (42:33): [True: 0, False: 9]
  |  |  |  Branch (42:56): [True: 0, False: 9]
  |  |  ------------------
  |  |   43|      9|                                (p)==COAP_PROTO_WS || (p)==COAP_PROTO_WSS)
  |  |  ------------------
  |  |  |  Branch (43:33): [True: 0, False: 9]
  |  |  |  Branch (43:55): [True: 0, False: 9]
  |  |  ------------------
  ------------------
 2319|      0|      (size_t)bytes_written < pdu->used_size + pdu->hdr_size) {
  ------------------
  |  Branch (2319:7): [True: 0, False: 0]
  ------------------
 2320|      0|    if (coap_session_delay_pdu(session, pdu, NULL) == COAP_PDU_DELAYED) {
  ------------------
  |  |   94|      0|#define COAP_PDU_DELAYED -3
  ------------------
  |  Branch (2320:9): [True: 0, False: 0]
  ------------------
 2321|      0|      session->partial_write = (size_t)bytes_written;
 2322|       |      /* do not free pdu as it is stored with session for later use */
 2323|      0|      return pdu->mid;
 2324|      0|    } else {
 2325|      0|      goto error;
 2326|      0|    }
 2327|      0|  }
 2328|      9|#endif /* !COAP_DISABLE_TCP */
 2329|       |
 2330|      9|  if (pdu->type != COAP_MESSAGE_CON
  ------------------
  |  Branch (2330:7): [True: 1, False: 8]
  ------------------
 2331|      8|      || COAP_PROTO_RELIABLE(session->proto)) {
  ------------------
  |  |   42|      8|#define COAP_PROTO_RELIABLE(p) ((p)==COAP_PROTO_TCP || (p)==COAP_PROTO_TLS || \
  |  |  ------------------
  |  |  |  Branch (42:33): [True: 0, False: 8]
  |  |  |  Branch (42:56): [True: 0, False: 8]
  |  |  ------------------
  |  |   43|      8|                                (p)==COAP_PROTO_WS || (p)==COAP_PROTO_WSS)
  |  |  ------------------
  |  |  |  Branch (43:33): [True: 0, False: 8]
  |  |  |  Branch (43:55): [True: 0, False: 8]
  |  |  ------------------
  ------------------
 2332|      1|    coap_mid_t id = pdu->mid;
 2333|      1|    coap_delete_pdu_lkd(pdu);
 2334|      1|    return id;
 2335|      1|  }
 2336|       |
 2337|      8|  coap_queue_t *node = coap_new_node();
 2338|      8|  if (!node) {
  ------------------
  |  Branch (2338:7): [True: 0, False: 8]
  ------------------
 2339|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2340|      0|    goto error;
 2341|      0|  }
 2342|       |
 2343|      8|  node->id = pdu->mid;
 2344|      8|  node->pdu = pdu;
 2345|      8|  coap_prng_lkd(&r, sizeof(r));
 2346|       |  /* add timeout in range [ACK_TIMEOUT...ACK_TIMEOUT * ACK_RANDOM_FACTOR] */
 2347|      8|  node->timeout = coap_calc_timeout(session, r);
 2348|      8|  return coap_wait_ack(session->context, session, node);
 2349|      0|error:
 2350|      0|  coap_delete_pdu_lkd(pdu);
 2351|      0|  return COAP_INVALID_MID;
  ------------------
  |  |  187|      0|#define COAP_INVALID_MID -1
  ------------------
 2352|      8|}
coap_remove_first_from_delayq:
 3248|     43|coap_remove_first_from_delayq(coap_session_t *session) {
 3249|     43|  coap_queue_t *q = session->delayqueue;
 3250|       |
 3251|     43|  if (q) {
  ------------------
  |  Branch (3251:7): [True: 0, False: 43]
  ------------------
 3252|      0|    session->delayqueue = q->next;
 3253|      0|    if (session->delayqueue == NULL)
  ------------------
  |  Branch (3253:9): [True: 0, False: 0]
  ------------------
 3254|      0|      session->delayqueue_tail = NULL;
 3255|       |    q->next = NULL;
 3256|      0|  }
 3257|     43|  return q;
 3258|     43|}
coap_startup:
 5654|     30|coap_startup(void) {
 5655|     30|  coap_tick_t now;
 5656|     30|#ifndef WITH_CONTIKI
 5657|     30|  uint64_t us;
 5658|     30|#endif /* !WITH_CONTIKI */
 5659|       |
 5660|     30|  if (coap_started)
  ------------------
  |  Branch (5660:7): [True: 0, False: 30]
  ------------------
 5661|      0|    return;
 5662|     30|  coap_started = 1;
 5663|       |
 5664|       |#if COAP_THREAD_SAFE
 5665|       |  coap_lock_init(&global_lock);
 5666|       |  coap_mutex_init(&m_show_pdu);
 5667|       |  coap_mutex_init(&m_log_impl);
 5668|       |  coap_mutex_init(&m_io_threads);
 5669|       |#endif /* COAP_THREAD_SAFE */
 5670|       |
 5671|       |#if defined(HAVE_WINSOCK2_H)
 5672|       |  WORD wVersionRequested = MAKEWORD(2, 2);
 5673|       |  WSADATA wsaData;
 5674|       |  WSAStartup(wVersionRequested, &wsaData);
 5675|       |#endif
 5676|     30|  coap_clock_init();
 5677|     30|  coap_ticks(&now);
 5678|     30|#ifndef WITH_CONTIKI
 5679|     30|  us = coap_ticks_to_rt_us(now);
 5680|       |  /* Be accurate to the nearest (approx) us */
 5681|     30|  coap_prng_init_lkd((unsigned int)us);
 5682|       |#else /* WITH_CONTIKI */
 5683|       |  coap_start_io_process();
 5684|       |#endif /* WITH_CONTIKI */
 5685|     30|  coap_memory_init();
 5686|     30|  coap_dtls_startup();
 5687|       |#ifdef WITH_LWIP
 5688|       |  coap_io_lwip_init();
 5689|       |#endif /* WITH_LWIP */
 5690|     30|#if COAP_SERVER_SUPPORT
 5691|     30|  static coap_str_const_t well_known = { sizeof(".well-known/core")-1,
 5692|     30|                                         (const uint8_t *)".well-known/core"
 5693|     30|                                       };
 5694|     30|  memset(&resource_uri_wellknown, 0, sizeof(resource_uri_wellknown));
 5695|     30|  resource_uri_wellknown.ref = 1;
 5696|     30|  resource_uri_wellknown.handler[COAP_REQUEST_GET-1] = hnd_get_wellknown_lkd;
 5697|     30|  resource_uri_wellknown.flags = COAP_RESOURCE_FLAGS_HAS_MCAST_SUPPORT;
  ------------------
  |  |   89|     30|#define COAP_RESOURCE_FLAGS_HAS_MCAST_SUPPORT 0x8
  ------------------
 5698|     30|  resource_uri_wellknown.uri_path = &well_known;
 5699|     30|#endif /* COAP_SERVER_SUPPORT */
 5700|     30|  send_recv_terminate = 0;
 5701|     30|  coap_prng_lkd(&coap_unique_id, sizeof(coap_unique_id));
 5702|     30|}
coap_cleanup:
 5705|     30|coap_cleanup(void) {
 5706|     30|  if (!coap_started)
  ------------------
  |  Branch (5706:7): [True: 0, False: 30]
  ------------------
 5707|      0|    return;
 5708|     30|  coap_started = 0;
 5709|       |#if defined(HAVE_WINSOCK2_H)
 5710|       |  WSACleanup();
 5711|       |#elif defined(WITH_CONTIKI)
 5712|       |  coap_stop_io_process();
 5713|       |#endif
 5714|       |#ifdef WITH_LWIP
 5715|       |  coap_io_lwip_cleanup();
 5716|       |#endif /* WITH_LWIP */
 5717|     30|  coap_dtls_shutdown();
 5718|       |
 5719|     30|  coap_delete_upa_chain(coap_upa_client_fallback_chain);
 5720|     30|  coap_upa_client_fallback_chain = NULL;
 5721|     30|  coap_delete_upa_chain(coap_upa_server_mapping_chain);
 5722|     30|  coap_upa_server_mapping_chain = NULL;
 5723|       |#if COAP_THREAD_SAFE
 5724|       |  coap_mutex_destroy(&m_show_pdu);
 5725|       |  coap_mutex_destroy(&m_log_impl);
 5726|       |  coap_mutex_destroy(&m_io_threads);
 5727|       |#endif /* COAP_THREAD_SAFE */
 5728|       |
 5729|     30|  coap_debug_reset();
 5730|     30|}
coap_net.c:coap_free_node:
  114|      8|coap_free_node(coap_queue_t *node) {
  115|      8|  coap_free_type(COAP_NODE, node);
  116|      8|}
coap_net.c:coap_malloc_node:
  109|      8|coap_malloc_node(void) {
  110|      8|  return (coap_queue_t *)coap_malloc_type(COAP_NODE, sizeof(coap_queue_t));
  111|      8|}
coap_net.c:coap_send_pdu:
 1280|      9|coap_send_pdu(coap_session_t *session, coap_pdu_t *pdu, coap_queue_t *node) {
 1281|      9|  ssize_t bytes_written;
 1282|       |
 1283|      9|  if (session->state == COAP_SESSION_STATE_NONE) {
  ------------------
  |  Branch (1283:7): [True: 0, False: 9]
  ------------------
 1284|       |#if ! COAP_CLIENT_SUPPORT
 1285|       |    return -1;
 1286|       |#else /* COAP_CLIENT_SUPPORT */
 1287|      0|    if (session->type != COAP_SESSION_TYPE_CLIENT)
  ------------------
  |  Branch (1287:9): [True: 0, False: 0]
  ------------------
 1288|      0|      return -1;
 1289|      0|#endif /* COAP_CLIENT_SUPPORT */
 1290|      0|  }
 1291|       |
 1292|      9|  if (pdu->type == COAP_MESSAGE_CON &&
  ------------------
  |  Branch (1292:7): [True: 8, False: 1]
  ------------------
 1293|      8|      (session->sock.flags & COAP_SOCKET_NOT_EMPTY) &&
  ------------------
  |  |   75|      8|#define COAP_SOCKET_NOT_EMPTY    0x0001  /**< the socket is not empty */
  ------------------
  |  Branch (1293:7): [True: 8, False: 0]
  ------------------
 1294|      8|      coap_is_mcast(&session->addr_info.remote)) {
  ------------------
  |  Branch (1294:7): [True: 0, False: 8]
  ------------------
 1295|       |    /* Violates RFC72522 8.1 */
 1296|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1297|      0|    return -1;
 1298|      0|  }
 1299|       |
 1300|      9|  if (session->state != COAP_SESSION_STATE_ESTABLISHED ||
  ------------------
  |  Branch (1300:7): [True: 0, False: 9]
  ------------------
 1301|      9|      (pdu->type == COAP_MESSAGE_CON &&
  ------------------
  |  Branch (1301:8): [True: 8, False: 1]
  ------------------
 1302|      8|       session->con_active >= COAP_NSTART(session))) {
  ------------------
  |  |  809|      8|#define COAP_NSTART(s) ((s)->nstart)
  ------------------
  |  Branch (1302:8): [True: 0, False: 8]
  ------------------
 1303|      0|    return coap_session_delay_pdu(session, pdu, node);
 1304|      0|  }
 1305|       |
 1306|      9|  if ((session->sock.flags & COAP_SOCKET_NOT_EMPTY) &&
  ------------------
  |  |   75|      9|#define COAP_SOCKET_NOT_EMPTY    0x0001  /**< the socket is not empty */
  ------------------
  |  Branch (1306:7): [True: 9, False: 0]
  ------------------
 1307|      9|      (session->sock.flags & COAP_SOCKET_WANT_WRITE))
  ------------------
  |  |   79|      9|#define COAP_SOCKET_WANT_WRITE   0x0020  /**< non blocking socket is waiting for writing */
  ------------------
  |  Branch (1307:7): [True: 0, False: 9]
  ------------------
 1308|      0|    return coap_session_delay_pdu(session, pdu, node);
 1309|       |
 1310|      9|  bytes_written = coap_session_send_pdu(session, pdu);
 1311|      9|  if (bytes_written >= 0 && pdu->type == COAP_MESSAGE_CON &&
  ------------------
  |  Branch (1311:7): [True: 9, False: 0]
  |  Branch (1311:29): [True: 8, False: 1]
  ------------------
 1312|      8|      COAP_PROTO_NOT_RELIABLE(session->proto))
  ------------------
  |  |   41|      8|#define COAP_PROTO_NOT_RELIABLE(p) ((p)==COAP_PROTO_UDP || (p)==COAP_PROTO_DTLS)
  |  |  ------------------
  |  |  |  Branch (41:37): [True: 8, False: 0]
  |  |  |  Branch (41:60): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1313|      8|    session->con_active++;
 1314|       |
 1315|      9|  return bytes_written;
 1316|      9|}

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

coap_dtls_is_supported:
  191|     30|coap_dtls_is_supported(void) {
  192|     30|  if (SSLeay() < 0x10100000L) {
  ------------------
  |  Branch (192:7): [True: 0, False: 30]
  ------------------
  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|     30|#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|     30|  if (SSLeay() < 0x10101000L) {
  ------------------
  |  Branch (204:7): [True: 0, False: 30]
  ------------------
  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|     30|#endif /* OPENSSL_VERSION_NUMBER >= 0x10101000L */
  209|     30|  return 1;
  210|     30|}
coap_tls_is_supported:
  213|      1|coap_tls_is_supported(void) {
  214|      1|#if !COAP_DISABLE_TCP
  215|      1|  if (SSLeay() < 0x10100000L) {
  ------------------
  |  Branch (215:7): [True: 0, False: 1]
  ------------------
  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|      1|#if OPENSSL_VERSION_NUMBER >= 0x10101000L
  220|      1|  if (SSLeay() < 0x10101000L) {
  ------------------
  |  Branch (220:7): [True: 0, False: 1]
  ------------------
  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|      1|#endif /* OPENSSL_VERSION_NUMBER >= 0x10101000L */
  225|      1|  return 1;
  226|       |#else /* COAP_DISABLE_TCP */
  227|       |  return 0;
  228|       |#endif /* COAP_DISABLE_TCP */
  229|      1|}
coap_dtls_startup:
  304|     30|coap_dtls_startup(void) {
  305|     30|  SSL_load_error_strings();
  306|     30|  SSL_library_init();
  307|     30|#if OPENSSL_VERSION_NUMBER < 0x40000000L
  308|       |  ENGINE_load_dynamic();
  309|     30|#endif /* OPENSSL_VERSION_NUMBER < 0x40000000L */
  310|     30|}
coap_dtls_shutdown:
  313|     30|coap_dtls_shutdown(void) {
  314|     30|#if OPENSSL_VERSION_NUMBER < 0x30000000L
  315|     30|  if (pkcs11_engine) {
  ------------------
  |  Branch (315:7): [True: 0, False: 30]
  ------------------
  316|       |    /* Release the functional reference from ENGINE_init() */
  317|      0|    ENGINE_finish(pkcs11_engine);
  318|      0|    pkcs11_engine = NULL;
  319|      0|  }
  320|     30|  if (defined_engine) {
  ------------------
  |  Branch (320:7): [True: 0, False: 30]
  ------------------
  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: 30]
  ------------------
  330|     30|  coap_dtls_set_log_level(COAP_LOG_EMERG);
  331|     30|}
coap_dtls_set_log_level:
  590|     60|coap_dtls_set_log_level(coap_log_t level) {
  591|     60|  dtls_log_level = level;
  592|     60|}
coap_dtls_new_context:
 1164|     30|coap_dtls_new_context(coap_context_t *coap_context) {
 1165|     30|  coap_openssl_context_t *context;
 1166|     30|  (void)coap_context;
 1167|       |
 1168|     30|  context = (coap_openssl_context_t *)coap_malloc_type(COAP_STRING, sizeof(coap_openssl_context_t));
 1169|     30|  if (context) {
  ------------------
  |  Branch (1169:7): [True: 30, False: 0]
  ------------------
 1170|     30|    uint8_t cookie_secret[32];
 1171|       |
 1172|     30|    memset(context, 0, sizeof(coap_openssl_context_t));
 1173|       |
 1174|       |    /* Set up DTLS context */
 1175|     30|    context->dtls.ctx = SSL_CTX_new(DTLS_method());
 1176|     30|    if (!context->dtls.ctx)
  ------------------
  |  Branch (1176:9): [True: 0, False: 30]
  ------------------
 1177|      0|      goto error;
 1178|     30|    SSL_CTX_set_min_proto_version(context->dtls.ctx, DTLS1_2_VERSION);
 1179|     30|    SSL_CTX_set_app_data(context->dtls.ctx, &context->dtls);
 1180|     30|    SSL_CTX_set_read_ahead(context->dtls.ctx, 1);
 1181|     30|    coap_set_user_prefs(context->dtls.ctx);
 1182|     30|    memset(cookie_secret, 0, sizeof(cookie_secret));
 1183|     30|    if (!RAND_bytes(cookie_secret, (int)sizeof(cookie_secret))) {
  ------------------
  |  Branch (1183:9): [True: 0, False: 30]
  ------------------
 1184|      0|      coap_dtls_log(COAP_LOG_WARN,
  ------------------
  |  |  306|      0|#define coap_dtls_log(level, ...) do { \
  |  |  307|      0|    if ((int)((level))<=(int)coap_dtls_get_log_level()) \
  |  |  ------------------
  |  |  |  Branch (307:9): [True: 0, False: 0]
  |  |  ------------------
  |  |  308|      0|      coap_log_impl((level)+COAP_LOG_DTLS_BASE, __VA_ARGS__); \
  |  |  309|      0|  } while(0)
  |  |  ------------------
  |  |  |  Branch (309:11): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1185|      0|                    "Insufficient entropy for random cookie generation");
 1186|      0|      coap_prng_lkd(cookie_secret, sizeof(cookie_secret));
 1187|      0|    }
 1188|     30|    context->dtls.cookie_hmac = HMAC_CTX_new();
 1189|     30|    if (!context->dtls.cookie_hmac)
  ------------------
  |  Branch (1189:9): [True: 0, False: 30]
  ------------------
 1190|      0|      goto error;
 1191|     30|    if (!HMAC_Init_ex(context->dtls.cookie_hmac, cookie_secret, (int)sizeof(cookie_secret),
  ------------------
  |  Branch (1191:9): [True: 0, False: 30]
  ------------------
 1192|     30|                      EVP_sha256(), NULL))
 1193|      0|      goto error;
 1194|     30|    SSL_CTX_set_cookie_generate_cb(context->dtls.ctx, coap_dtls_generate_cookie);
 1195|     30|    SSL_CTX_set_cookie_verify_cb(context->dtls.ctx, coap_dtls_verify_cookie);
 1196|     30|    SSL_CTX_set_info_callback(context->dtls.ctx, coap_dtls_info_callback);
 1197|     30|    SSL_CTX_set_options(context->dtls.ctx, SSL_OP_NO_QUERY_MTU);
 1198|       |#if OPENSSL_VERSION_NUMBER >= 0x30000000L
 1199|       |    SSL_CTX_set_options(context->dtls.ctx, SSL_OP_LEGACY_SERVER_CONNECT);
 1200|       |#endif /* OPENSSL_VERSION_NUMBER >= 0x30000000L */
 1201|     30|    context->dtls.meth = BIO_meth_new(BIO_TYPE_DGRAM, "coapdgram");
 1202|     30|    if (!context->dtls.meth)
  ------------------
  |  Branch (1202:9): [True: 0, False: 30]
  ------------------
 1203|      0|      goto error;
 1204|     30|    context->dtls.bio_addr = BIO_ADDR_new();
 1205|     30|    if (!context->dtls.bio_addr)
  ------------------
  |  Branch (1205:9): [True: 0, False: 30]
  ------------------
 1206|      0|      goto error;
 1207|     30|    BIO_meth_set_write(context->dtls.meth, coap_dgram_write);
 1208|     30|    BIO_meth_set_read(context->dtls.meth, coap_dgram_read);
 1209|     30|    BIO_meth_set_puts(context->dtls.meth, coap_dgram_puts);
 1210|     30|    BIO_meth_set_ctrl(context->dtls.meth, coap_dgram_ctrl);
 1211|     30|    BIO_meth_set_create(context->dtls.meth, coap_dgram_create);
 1212|     30|    BIO_meth_set_destroy(context->dtls.meth, coap_dgram_destroy);
 1213|       |
 1214|     30|#if !COAP_DISABLE_TCP
 1215|       |    /* Set up TLS context */
 1216|     30|    context->tls.ctx = SSL_CTX_new(TLS_method());
 1217|     30|    if (!context->tls.ctx)
  ------------------
  |  Branch (1217:9): [True: 0, False: 30]
  ------------------
 1218|      0|      goto error;
 1219|     30|    SSL_CTX_set_app_data(context->tls.ctx, &context->tls);
 1220|     30|    SSL_CTX_set_min_proto_version(context->tls.ctx, TLS1_VERSION);
 1221|     30|    coap_set_user_prefs(context->tls.ctx);
 1222|     30|    SSL_CTX_set_info_callback(context->tls.ctx, coap_dtls_info_callback);
 1223|     30|    context->tls.meth = BIO_meth_new(BIO_TYPE_SOCKET, "coapsock");
 1224|     30|    if (!context->tls.meth)
  ------------------
  |  Branch (1224:9): [True: 0, False: 30]
  ------------------
 1225|      0|      goto error;
 1226|     30|    BIO_meth_set_write(context->tls.meth, coap_sock_write);
 1227|     30|    BIO_meth_set_read(context->tls.meth, coap_sock_read);
 1228|     30|    BIO_meth_set_puts(context->tls.meth, coap_sock_puts);
 1229|     30|    BIO_meth_set_ctrl(context->tls.meth, coap_sock_ctrl);
 1230|     30|    BIO_meth_set_create(context->tls.meth, coap_sock_create);
 1231|     30|    BIO_meth_set_destroy(context->tls.meth, coap_sock_destroy);
 1232|     30|#endif /* !COAP_DISABLE_TCP */
 1233|     30|  }
 1234|       |
 1235|     30|  return context;
 1236|       |
 1237|      0|error:
 1238|      0|  coap_dtls_free_context(context);
 1239|       |  return NULL;
 1240|     30|}
coap_dtls_free_context:
 3414|     30|coap_dtls_free_context(void *handle) {
 3415|     30|  size_t i;
 3416|     30|  coap_openssl_context_t *context = (coap_openssl_context_t *)handle;
 3417|       |
 3418|     30|  if (context->dtls.ssl)
  ------------------
  |  Branch (3418:7): [True: 0, False: 30]
  ------------------
 3419|      0|    SSL_free(context->dtls.ssl);
 3420|     30|  if (context->dtls.ctx)
  ------------------
  |  Branch (3420:7): [True: 30, False: 0]
  ------------------
 3421|     30|    SSL_CTX_free(context->dtls.ctx);
 3422|     30|  if (context->dtls.cookie_hmac)
  ------------------
  |  Branch (3422:7): [True: 30, False: 0]
  ------------------
 3423|     30|    HMAC_CTX_free(context->dtls.cookie_hmac);
 3424|     30|  if (context->dtls.meth)
  ------------------
  |  Branch (3424:7): [True: 30, False: 0]
  ------------------
 3425|     30|    BIO_meth_free(context->dtls.meth);
 3426|     30|  if (context->dtls.bio_addr)
  ------------------
  |  Branch (3426:7): [True: 30, False: 0]
  ------------------
 3427|     30|    BIO_ADDR_free(context->dtls.bio_addr);
 3428|     30|#if !COAP_DISABLE_TCP
 3429|     30|  if (context->tls.ctx)
  ------------------
  |  Branch (3429:7): [True: 30, False: 0]
  ------------------
 3430|     30|    SSL_CTX_free(context->tls.ctx);
 3431|     30|  if (context->tls.meth)
  ------------------
  |  Branch (3431:7): [True: 30, False: 0]
  ------------------
 3432|     30|    BIO_meth_free(context->tls.meth);
 3433|     30|#endif /* !COAP_DISABLE_TCP */
 3434|     30|  for (i = 0; i < context->sni_count; i++) {
  ------------------
  |  Branch (3434:15): [True: 0, False: 30]
  ------------------
 3435|      0|    OPENSSL_free(context->sni_entry_list[i].sni);
 3436|       |#if OPENSSL_VERSION_NUMBER < 0x10101000L
 3437|       |    SSL_CTX_free(context->sni_entry_list[i].ctx);
 3438|       |#endif /* OPENSSL_VERSION_NUMBER < 0x10101000L */
 3439|      0|  }
 3440|     30|  if (context->sni_count)
  ------------------
  |  Branch (3440:7): [True: 0, False: 30]
  ------------------
 3441|     30|    OPENSSL_free(context->sni_entry_list);
 3442|       |#if OPENSSL_VERSION_NUMBER < 0x10101000L
 3443|       |  for (i = 0; i < context->psk_sni_count; i++) {
 3444|       |    OPENSSL_free((char *)context->psk_sni_entry_list[i].sni);
 3445|       |    SSL_CTX_free(context->psk_sni_entry_list[i].ctx);
 3446|       |  }
 3447|       |  if (context->psk_sni_count)
 3448|       |    OPENSSL_free(context->psk_sni_entry_list);
 3449|       |#endif /* OPENSSL_VERSION_NUMBER < 0x10101000L */
 3450|     30|  coap_free_type(COAP_STRING, context);
 3451|     30|}
coap_openssl.c:coap_set_user_prefs:
 1137|     60|coap_set_user_prefs(SSL_CTX *ctx) {
 1138|     60|  SSL_CTX_set_cipher_list(ctx, COAP_OPENSSL_CIPHERS);
  ------------------
  |  |  119|     60|#define COAP_OPENSSL_CIPHERS "TLSv1.3:TLSv1.2:!NULL"
  ------------------
 1139|       |
 1140|       |#ifdef COAP_OPENSSL_SIGALGS
 1141|       |  SSL_CTX_set1_sigalgs_list(ctx, COAP_OPENSSL_SIGALGS);
 1142|       |  SSL_CTX_set1_client_sigalgs_list(ctx, COAP_OPENSSL_SIGALGS);
 1143|       |#endif
 1144|       |
 1145|       |#if OPENSSL_VERSION_NUMBER >= 0x10101000L && defined(COAP_OPENSSL_GROUPS)
 1146|       |  SSL_CTX_set1_groups_list(ctx, COAP_OPENSSL_GROUPS);
 1147|       |#endif
 1148|     60|}

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

coap_delete_all_oscore:
 2690|     30|coap_delete_all_oscore(coap_context_t *c_context) {
 2691|     30|  oscore_free_contexts(c_context);
 2692|     30|}
coap_delete_oscore_associations:
 2695|     43|coap_delete_oscore_associations(coap_session_t *session) {
 2696|     43|  oscore_delete_server_associations(session);
 2697|     43|}

coap_pdu_clear:
   47|     73|coap_pdu_clear(coap_pdu_t *pdu, size_t size) {
   48|     73|  assert(pdu);
  ------------------
  |  Branch (48:3): [True: 73, False: 0]
  ------------------
   49|     73|  assert(pdu->token);
  ------------------
  |  Branch (49:3): [True: 73, False: 0]
  ------------------
   50|     73|  assert(pdu->max_hdr_size >= COAP_PDU_MAX_UDP_HEADER_SIZE);
  ------------------
  |  Branch (50:3): [True: 73, False: 0]
  ------------------
   51|     73|  if (pdu->alloc_size > size)
  ------------------
  |  Branch (51:7): [True: 0, False: 73]
  ------------------
   52|      0|    pdu->alloc_size = size;
   53|     73|  pdu->type = 0;
   54|     73|  pdu->code = 0;
   55|     73|  pdu->ref = 0;
   56|     73|  pdu->hdr_size = 0;
   57|     73|  pdu->actual_token.length = 0;
   58|     73|  pdu->e_token_length = 0;
   59|     73|  pdu->crit_opt = 0;
   60|     73|  pdu->mid = 0;
   61|     73|  pdu->max_opt = 0;
   62|     73|  pdu->max_size = size;
   63|     73|  pdu->used_size = 0;
   64|     73|  pdu->data = NULL;
   65|     73|  pdu->body_data = NULL;
   66|     73|  pdu->body_length = 0;
   67|     73|  pdu->body_offset = 0;
   68|     73|  pdu->body_total = 0;
   69|     73|  pdu->lg_xmit = NULL;
   70|     73|  pdu->session = NULL;
   71|       |  pdu->data_free = NULL;
   72|     73|}
coap_pdu_init:
  105|     73|              size_t size) {
  106|     73|  coap_pdu_t *pdu;
  107|       |
  108|     73|#ifndef RIOT_VERSION
  109|     73|  assert(type <= 0x3);
  ------------------
  |  Branch (109:3): [True: 73, False: 0]
  ------------------
  110|     73|  assert(code <= 0xff);
  ------------------
  |  Branch (110:3): [True: 73, False: 0]
  ------------------
  111|     73|  assert(mid >= 0 && mid <= 0xffff);
  ------------------
  |  Branch (111:3): [True: 73, False: 0]
  |  Branch (111:3): [True: 73, False: 0]
  ------------------
  112|     73|#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|     73|  pdu = coap_malloc_type(COAP_PDU, sizeof(coap_pdu_t));
  125|     73|  if (!pdu)
  ------------------
  |  Branch (125:7): [True: 0, False: 73]
  ------------------
  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|     73|  pdu->max_hdr_size = COAP_PDU_MAX_TCP_HEADER_SIZE;
  ------------------
  |  |  108|     73|#define COAP_PDU_MAX_TCP_HEADER_SIZE 6
  ------------------
  133|     73|#endif
  134|     73|  if (size > ((size_t)COAP_DEFAULT_MAX_PDU_RX_SIZE - pdu->max_hdr_size)) {
  ------------------
  |  |   84|     73|#define COAP_DEFAULT_MAX_PDU_RX_SIZE (8UL*1024*1024+256)
  ------------------
  |  Branch (134:7): [True: 0, False: 73]
  ------------------
  135|      0|    coap_free_type(COAP_PDU, pdu);
  136|      0|    return NULL;
  137|      0|  }
  138|       |
  139|     73|  pdu->alloc_size = min(size, COAP_DEFAULT_MTU);
  ------------------
  |  |   37|     73|#define min(a,b) ((a) < (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (37:19): [True: 73, False: 0]
  |  |  ------------------
  ------------------
  140|       |#ifdef WITH_LWIP
  141|       |  pdu->pbuf = pbuf_alloc(PBUF_TRANSPORT, pdu->alloc_size + 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|     73|  uint8_t *buf;
  150|     73|  buf = coap_malloc_type(COAP_PDU_BUF, pdu->alloc_size + pdu->max_hdr_size);
  151|     73|  if (buf == NULL) {
  ------------------
  |  Branch (151:7): [True: 0, False: 73]
  ------------------
  152|      0|    coap_free_type(COAP_PDU, pdu);
  153|      0|    return NULL;
  154|      0|  }
  155|     73|  pdu->token = buf + pdu->max_hdr_size;
  156|     73|#endif /* ! WITH_LWIP */
  157|     73|  coap_pdu_clear(pdu, size);
  158|     73|  pdu->mid = mid;
  159|     73|  pdu->type = type;
  160|     73|  pdu->code = code;
  161|     73|  return pdu;
  162|     73|}
coap_delete_pdu:
  190|     60|coap_delete_pdu(coap_pdu_t *pdu) {
  191|     60|  coap_lock_lock(return);
  192|     60|  coap_delete_pdu_lkd(pdu);
  193|     60|  coap_lock_unlock();
  194|     60|}
coap_delete_pdu_lkd:
  197|    142|coap_delete_pdu_lkd(coap_pdu_t *pdu) {
  198|    142|  if (pdu != NULL) {
  ------------------
  |  Branch (198:7): [True: 99, False: 43]
  ------------------
  199|     99|    if (pdu->ref) {
  ------------------
  |  Branch (199:9): [True: 26, False: 73]
  ------------------
  200|     26|      pdu->ref--;
  201|     26|      return;
  202|     26|    }
  203|       |#ifdef WITH_LWIP
  204|       |    pbuf_free(pdu->pbuf);
  205|       |#else
  206|     73|    if (pdu->token != NULL)
  ------------------
  |  Branch (206:9): [True: 73, False: 0]
  ------------------
  207|     73|      coap_free_type(COAP_PDU_BUF, pdu->token - pdu->max_hdr_size);
  208|     73|#endif
  209|     73|    coap_delete_binary(pdu->data_free);
  210|     73|    coap_free_type(COAP_PDU, pdu);
  211|     73|  }
  212|    142|}
coap_pdu_duplicate_lkd:
  242|      5|                       coap_bool_t expand_opt_abb) {
  243|      5|#if COAP_CLIENT_SUPPORT
  244|      5|  uint8_t doing_first = session->doing_first;
  245|      5|#endif /* COAP_CLIENT_SUPPORT */
  246|      5|  coap_pdu_t *pdu;
  247|       |
  248|      5|  coap_lock_check_locked();
  ------------------
  |  |  638|      5|#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|      5|#if COAP_CLIENT_SUPPORT
  256|      5|  session->doing_first = 0;
  257|      5|#endif /* COAP_CLIENT_SUPPORT */
  258|      5|  pdu = coap_pdu_init(old_pdu->type, old_pdu->code,
  259|      5|                      coap_new_message_id_lkd(session),
  260|      5|                      old_pdu->max_size);
  261|      5|#if COAP_CLIENT_SUPPORT
  262|       |  /* Restore any pending waits */
  263|      5|  session->doing_first = doing_first;
  264|      5|#endif /* COAP_CLIENT_SUPPORT */
  265|      5|  if (pdu == NULL)
  ------------------
  |  Branch (265:7): [True: 0, False: 5]
  ------------------
  266|      0|    return NULL;
  267|       |
  268|      5|  coap_add_token(pdu, token_length, token);
  269|      5|  pdu->lg_xmit = old_pdu->lg_xmit;
  270|       |
  271|      5|  if (drop_options == NULL && expand_opt_abb == COAP_BOOL_FALSE) {
  ------------------
  |  Branch (271:7): [True: 5, False: 0]
  |  Branch (271:31): [True: 5, False: 0]
  ------------------
  272|       |    /* Drop COAP_PAYLOAD_START as well if data */
  273|      5|    size_t length = old_pdu->used_size - old_pdu->e_token_length -
  274|      5|                    (old_pdu->data ?
  ------------------
  |  Branch (274:22): [True: 0, False: 5]
  ------------------
  275|      5|                     old_pdu->used_size - (old_pdu->data - old_pdu->token) +1 : 0);
  276|      5|    if (!coap_pdu_resize(pdu, length + pdu->e_token_length))
  ------------------
  |  Branch (276:9): [True: 0, False: 5]
  ------------------
  277|      0|      goto fail;
  278|       |    /* Copy the options but not any data across */
  279|      5|    memcpy(pdu->token + pdu->e_token_length,
  280|      5|           old_pdu->token + old_pdu->e_token_length, length);
  281|      5|    pdu->used_size += length;
  282|      5|    pdu->max_opt = old_pdu->max_opt;
  283|      5|  } else {
  284|       |    /* Copy across all the options the slow way */
  285|      0|    coap_opt_iterator_t opt_iter;
  286|      0|    coap_opt_t *option;
  287|       |
  288|      0|    coap_option_iterator_init(old_pdu, &opt_iter, COAP_OPT_ALL);
  ------------------
  |  |  230|      0|#define COAP_OPT_ALL NULL
  ------------------
  289|      0|    while ((option = coap_option_next(&opt_iter))) {
  ------------------
  |  Branch (289:12): [True: 0, False: 0]
  ------------------
  290|      0|      if (opt_iter.number == COAP_OPTION_URI_PATH_ABB && expand_opt_abb == COAP_BOOL_TRUE) {
  ------------------
  |  Branch (290:11): [True: 0, False: 0]
  |  Branch (290:58): [True: 0, False: 0]
  ------------------
  291|      0|        uint32_t value;
  292|      0|        const char *exp;
  293|       |
  294|      0|        value = coap_decode_var_bytes(coap_opt_value(option),
  295|      0|                                      coap_opt_length(option));
  296|      0|        exp = coap_map_abbrev_uri_path(coap_upa_server_mapping_chain, value);
  297|      0|        if (exp) {
  ------------------
  |  Branch (297:13): [True: 0, False: 0]
  ------------------
  298|      0|          while (exp) {
  ------------------
  |  Branch (298:18): [True: 0, False: 0]
  ------------------
  299|      0|            const char *next = strchr(exp, '/');
  300|       |
  301|      0|            if (!coap_insert_option(pdu, COAP_OPTION_URI_PATH,
  ------------------
  |  Branch (301:17): [True: 0, False: 0]
  ------------------
  302|      0|                                    next ? (int)(next - exp) : (int)strlen(exp),
  ------------------
  |  Branch (302:37): [True: 0, False: 0]
  ------------------
  303|      0|                                    (const uint8_t *)exp))
  304|      0|              goto fail;
  305|      0|            if (next)
  ------------------
  |  Branch (305:17): [True: 0, False: 0]
  ------------------
  306|      0|              exp = next + 1;
  307|      0|            else
  308|      0|              exp = NULL;
  309|      0|          }
  310|      0|        } else {
  311|      0|          coap_delete_pdu_lkd(pdu);
  312|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  313|      0|                        value);
  314|      0|          return NULL;
  315|      0|        }
  316|      0|      } else {
  317|      0|        if (drop_options) {
  ------------------
  |  Branch (317:13): [True: 0, False: 0]
  ------------------
  318|      0|          if (coap_option_filter_get(drop_options, opt_iter.number))
  ------------------
  |  Branch (318:15): [True: 0, False: 0]
  ------------------
  319|      0|            continue;
  320|      0|        }
  321|      0|        if (!coap_insert_option(pdu, opt_iter.number,
  ------------------
  |  Branch (321:13): [True: 0, False: 0]
  ------------------
  322|      0|                                coap_opt_length(option),
  323|      0|                                coap_opt_value(option)))
  324|      0|          goto fail;
  325|      0|      }
  326|      0|    }
  327|      0|  }
  328|      5|  return pdu;
  329|       |
  330|      0|fail:
  331|      0|  coap_delete_pdu_lkd(pdu);
  332|       |  return NULL;
  333|      5|}
coap_pdu_resize:
  340|     20|coap_pdu_resize(coap_pdu_t *pdu, size_t new_size) {
  341|     20|  if (new_size > pdu->alloc_size) {
  ------------------
  |  Branch (341:7): [True: 12, False: 8]
  ------------------
  342|       |    /* Expanding the PDU usage */
  343|     12|#if !defined(WITH_LWIP)
  344|     12|    uint8_t *new_hdr;
  345|       |#else /* WITH_LWIP */
  346|       |    struct pbuf *new_hdr;
  347|       |#endif /* WITH_LWIP */
  348|     12|    size_t offset;
  349|       |
  350|     12|    if (pdu->max_size && new_size > pdu->max_size) {
  ------------------
  |  Branch (350:9): [True: 12, False: 0]
  |  Branch (350:26): [True: 12, False: 0]
  ------------------
  351|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  352|     12|      return 0;
  353|     12|    }
  354|      0|    if (pdu->data != NULL) {
  ------------------
  |  Branch (354:9): [True: 0, False: 0]
  ------------------
  355|      0|      assert(pdu->data > pdu->token);
  ------------------
  |  Branch (355:7): [True: 0, False: 0]
  ------------------
  356|      0|      offset = pdu->data - pdu->token;
  357|      0|    } else {
  358|      0|      offset = 0;
  359|      0|    }
  360|      0|#if !defined(WITH_LWIP)
  361|      0|    new_hdr = (uint8_t *)coap_realloc_type(COAP_PDU_BUF,
  362|      0|                                           pdu->token - pdu->max_hdr_size,
  363|      0|                                           new_size + pdu->max_hdr_size);
  364|       |#else /* WITH_LWIP */
  365|       |    new_hdr = pbuf_alloc(PBUF_TRANSPORT, new_size + pdu->max_hdr_size, PBUF_RAM);
  366|       |#endif /* WITH_LWIP */
  367|      0|    if (new_hdr == NULL) {
  ------------------
  |  Branch (367:9): [True: 0, False: 0]
  ------------------
  368|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  369|      0|      return 0;
  370|      0|    }
  371|      0|#if !defined(WITH_LWIP)
  372|      0|    pdu->token = new_hdr + pdu->max_hdr_size;
  373|       |#else /* WITH_LWIP */
  374|       |    memcpy(new_hdr->payload, pdu->pbuf->payload, pdu->pbuf->len);
  375|       |    pbuf_free(pdu->pbuf);
  376|       |    pdu->pbuf = new_hdr;
  377|       |    pdu->token = (uint8_t *)pdu->pbuf->payload + pdu->max_hdr_size;
  378|       |#endif /* WITH_LWIP */
  379|      0|    if (offset > 0)
  ------------------
  |  Branch (379:9): [True: 0, False: 0]
  ------------------
  380|      0|      pdu->data = pdu->token + offset;
  381|      0|    else
  382|      0|      pdu->data = NULL;
  383|      0|    if (pdu->actual_token.length < COAP_TOKEN_EXT_1B_BIAS)
  ------------------
  |  |   56|      0|#define COAP_TOKEN_EXT_1B_BIAS 13
  ------------------
  |  Branch (383:9): [True: 0, False: 0]
  ------------------
  384|      0|      pdu->actual_token.s = &pdu->token[0];
  385|      0|    else if (pdu->actual_token.length < COAP_TOKEN_EXT_2B_BIAS)
  ------------------
  |  |   57|      0|#define COAP_TOKEN_EXT_2B_BIAS 269 /* 13 + 256 */
  ------------------
  |  Branch (385:14): [True: 0, False: 0]
  ------------------
  386|      0|      pdu->actual_token.s = &pdu->token[1];
  387|      0|    else
  388|      0|      pdu->actual_token.s = &pdu->token[2];
  389|      0|    pdu->alloc_size = new_size;
  390|      0|  }
  391|      8|  return 1;
  392|     20|}
coap_pdu_check_resize:
  395|    171|coap_pdu_check_resize(coap_pdu_t *pdu, size_t size) {
  396|    171|  if (size > pdu->alloc_size) {
  ------------------
  |  Branch (396:7): [True: 0, False: 171]
  ------------------
  397|       |#if defined WITH_LWIP || defined WITH_CONTIKI || defined RIOT_BERSION || defined __ZEPHYR__
  398|       |    size_t new_size = max(64, pdu->alloc_size * 2);
  399|       |#else /* ! WITH_LWIP && ! WITH_CONTIKI && ! RIOT_BERSION && ! __ZEPHYR__ */
  400|      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]
  |  |  ------------------
  ------------------
  401|      0|#endif /* ! WITH_LWIP && ! WITH_CONTIKI && ! RIOT_BERSION && ! __ZEPHYR__ */
  402|       |
  403|      0|    while (size > new_size)
  ------------------
  |  Branch (403:12): [True: 0, False: 0]
  ------------------
  404|      0|      new_size *= 2;
  405|      0|    if (pdu->max_size && new_size > pdu->max_size) {
  ------------------
  |  Branch (405:9): [True: 0, False: 0]
  |  Branch (405:26): [True: 0, False: 0]
  ------------------
  406|      0|      new_size = pdu->max_size;
  407|      0|      if (new_size < size)
  ------------------
  |  Branch (407:11): [True: 0, False: 0]
  ------------------
  408|      0|        return 0;
  409|      0|    }
  410|      0|    if (!coap_pdu_resize(pdu, new_size))
  ------------------
  |  Branch (410:9): [True: 0, False: 0]
  ------------------
  411|      0|      return 0;
  412|      0|  }
  413|    171|  return 1;
  414|    171|}
coap_add_token:
  417|     43|coap_add_token(coap_pdu_t *pdu, size_t len, const uint8_t *data) {
  418|     43|  size_t bias = 0;
  419|       |
  420|       |  /* must allow for pdu == NULL as callers may rely on this */
  421|     43|  if (!pdu)
  ------------------
  |  Branch (421:7): [True: 0, False: 43]
  ------------------
  422|      0|    return 0;
  423|       |
  424|     43|  if (pdu->used_size) {
  ------------------
  |  Branch (424:7): [True: 0, False: 43]
  ------------------
  425|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  426|      0|    return 0;
  427|      0|  }
  428|     43|  pdu->actual_token.length = len;
  429|     43|  if (len < COAP_TOKEN_EXT_1B_BIAS) {
  ------------------
  |  |   56|     43|#define COAP_TOKEN_EXT_1B_BIAS 13
  ------------------
  |  Branch (429:7): [True: 43, False: 0]
  ------------------
  430|     43|    bias = 0;
  431|     43|  } else if (len < COAP_TOKEN_EXT_2B_BIAS) {
  ------------------
  |  |   57|      0|#define COAP_TOKEN_EXT_2B_BIAS 269 /* 13 + 256 */
  ------------------
  |  Branch (431:14): [True: 0, False: 0]
  ------------------
  432|      0|    bias = 1;
  433|      0|  } else if (len <= COAP_TOKEN_EXT_MAX) {
  ------------------
  |  |   60|      0|#define COAP_TOKEN_EXT_MAX 65804UL /* 13 + 256 + 65535 */
  ------------------
  |  Branch (433:14): [True: 0, False: 0]
  ------------------
  434|      0|    bias = 2;
  435|      0|  } else {
  436|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  437|      0|    return 0;
  438|      0|  }
  439|     43|  if (!coap_pdu_check_resize(pdu, len + bias)) {
  ------------------
  |  Branch (439:7): [True: 0, False: 43]
  ------------------
  440|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  441|      0|    return 0;
  442|      0|  }
  443|       |
  444|     43|  pdu->actual_token.length = len;
  445|     43|  pdu->actual_token.s = &pdu->token[bias];
  446|     43|  pdu->e_token_length = (uint32_t)(len + bias);
  447|     43|  if (len) {
  ------------------
  |  Branch (447:7): [True: 43, False: 0]
  ------------------
  448|     43|    switch (bias) {
  449|     43|    case 0:
  ------------------
  |  Branch (449:5): [True: 43, False: 0]
  ------------------
  450|     43|      memcpy(pdu->token, data, len);
  451|     43|      break;
  452|      0|    case 1:
  ------------------
  |  Branch (452:5): [True: 0, False: 43]
  ------------------
  453|      0|      pdu->token[0] = (uint8_t)(len - COAP_TOKEN_EXT_1B_BIAS);
  ------------------
  |  |   56|      0|#define COAP_TOKEN_EXT_1B_BIAS 13
  ------------------
  454|      0|      memcpy(&pdu->token[1], data, len);
  455|      0|      break;
  456|      0|    case 2:
  ------------------
  |  Branch (456:5): [True: 0, False: 43]
  ------------------
  457|      0|      pdu->token[0] = (uint8_t)((len - COAP_TOKEN_EXT_2B_BIAS) >> 8);
  ------------------
  |  |   57|      0|#define COAP_TOKEN_EXT_2B_BIAS 269 /* 13 + 256 */
  ------------------
  458|      0|      pdu->token[1] = (uint8_t)((len - COAP_TOKEN_EXT_2B_BIAS) & 0xff);
  ------------------
  |  |   57|      0|#define COAP_TOKEN_EXT_2B_BIAS 269 /* 13 + 256 */
  ------------------
  459|      0|      memcpy(&pdu->token[2], data, len);
  460|      0|      break;
  461|      0|    default:
  ------------------
  |  Branch (461:5): [True: 0, False: 43]
  ------------------
  462|      0|      break;
  463|     43|    }
  464|     43|  }
  465|     43|  pdu->max_opt = 0;
  466|     43|  pdu->used_size = len + bias;
  467|     43|  pdu->data = NULL;
  468|       |
  469|     43|  return 1;
  470|     43|}
coap_option_check_repeatable:
  644|     20|coap_option_check_repeatable(coap_pdu_t *pdu, coap_option_num_t number) {
  645|       |  /* Validate that the option is repeatable */
  646|     20|  switch ((coap_code_opt_num_t)number) {
  647|      0|  case COAP_OPTION_ETAG:
  ------------------
  |  Branch (647:3): [True: 0, False: 20]
  ------------------
  648|      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]
  |  |  ------------------
  ------------------
  649|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  650|      0|      return 0;
  651|      0|    }
  652|      0|    break;
  653|       |  /* Ignore list of genuine repeatable */
  654|      0|  case COAP_OPTION_IF_MATCH:
  ------------------
  |  Branch (654:3): [True: 0, False: 20]
  ------------------
  655|      0|  case COAP_OPTION_LOCATION_PATH:
  ------------------
  |  Branch (655:3): [True: 0, False: 20]
  ------------------
  656|     19|  case COAP_OPTION_URI_PATH:
  ------------------
  |  Branch (656:3): [True: 19, False: 1]
  ------------------
  657|     20|  case COAP_OPTION_URI_QUERY:
  ------------------
  |  Branch (657:3): [True: 1, False: 19]
  ------------------
  658|     20|  case COAP_OPTION_LOCATION_QUERY:
  ------------------
  |  Branch (658:3): [True: 0, False: 20]
  ------------------
  659|     20|  case COAP_OPTION_Q_BLOCK2:
  ------------------
  |  Branch (659:3): [True: 0, False: 20]
  ------------------
  660|     20|  case COAP_OPTION_RTAG:
  ------------------
  |  Branch (660:3): [True: 0, False: 20]
  ------------------
  661|     20|    break;
  662|       |  /* Protest at the known non-repeatable options and ignore them */
  663|      0|  case COAP_OPTION_URI_HOST:
  ------------------
  |  Branch (663:3): [True: 0, False: 20]
  ------------------
  664|      0|  case COAP_OPTION_IF_NONE_MATCH:
  ------------------
  |  Branch (664:3): [True: 0, False: 20]
  ------------------
  665|      0|  case COAP_OPTION_OBSERVE:
  ------------------
  |  Branch (665:3): [True: 0, False: 20]
  ------------------
  666|      0|  case COAP_OPTION_URI_PORT:
  ------------------
  |  Branch (666:3): [True: 0, False: 20]
  ------------------
  667|      0|  case COAP_OPTION_OSCORE:
  ------------------
  |  Branch (667:3): [True: 0, False: 20]
  ------------------
  668|      0|  case COAP_OPTION_CONTENT_FORMAT:
  ------------------
  |  Branch (668:3): [True: 0, False: 20]
  ------------------
  669|      0|  case COAP_OPTION_URI_PATH_ABB:
  ------------------
  |  Branch (669:3): [True: 0, False: 20]
  ------------------
  670|      0|  case COAP_OPTION_MAXAGE:
  ------------------
  |  Branch (670:3): [True: 0, False: 20]
  ------------------
  671|      0|  case COAP_OPTION_HOP_LIMIT:
  ------------------
  |  Branch (671:3): [True: 0, False: 20]
  ------------------
  672|      0|  case COAP_OPTION_ACCEPT:
  ------------------
  |  Branch (672:3): [True: 0, False: 20]
  ------------------
  673|      0|  case COAP_OPTION_Q_BLOCK1:
  ------------------
  |  Branch (673:3): [True: 0, False: 20]
  ------------------
  674|      0|  case COAP_OPTION_EDHOC:
  ------------------
  |  Branch (674:3): [True: 0, False: 20]
  ------------------
  675|      0|  case COAP_OPTION_BLOCK2:
  ------------------
  |  Branch (675:3): [True: 0, False: 20]
  ------------------
  676|      0|  case COAP_OPTION_BLOCK1:
  ------------------
  |  Branch (676:3): [True: 0, False: 20]
  ------------------
  677|      0|  case COAP_OPTION_SIZE2:
  ------------------
  |  Branch (677:3): [True: 0, False: 20]
  ------------------
  678|      0|  case COAP_OPTION_PROXY_URI:
  ------------------
  |  Branch (678:3): [True: 0, False: 20]
  ------------------
  679|      0|  case COAP_OPTION_PROXY_SCHEME:
  ------------------
  |  Branch (679:3): [True: 0, False: 20]
  ------------------
  680|      0|  case COAP_OPTION_SIZE1:
  ------------------
  |  Branch (680:3): [True: 0, False: 20]
  ------------------
  681|      0|  case COAP_OPTION_ECHO:
  ------------------
  |  Branch (681:3): [True: 0, False: 20]
  ------------------
  682|      0|  case COAP_OPTION_NORESPONSE:
  ------------------
  |  Branch (682:3): [True: 0, False: 20]
  ------------------
  683|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  684|      0|                  coap_option_string(pdu->code, number), number);
  685|      0|    return 0;
  686|      0|  default:
  ------------------
  |  Branch (686:3): [True: 0, False: 20]
  ------------------
  687|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  688|      0|                  number);
  689|       |    /* Accepting it after warning as there may be user definable options */
  690|      0|    break;
  691|     20|  }
  692|     20|  return 1;
  693|     20|}
coap_insert_option:
  697|     25|                   const uint8_t *data) {
  698|     25|  coap_opt_iterator_t opt_iter;
  699|     25|  coap_opt_t *option;
  700|     25|  uint16_t prev_number = 0;
  701|     25|  size_t shift;
  702|     25|  size_t opt_delta;
  703|     25|  coap_option_t decode;
  704|     25|  size_t shrink = 0;
  705|       |
  706|     25|  if (number >= pdu->max_opt)
  ------------------
  |  Branch (706:7): [True: 16, False: 9]
  ------------------
  707|     16|    return coap_add_option_internal(pdu, number, len, data);
  708|       |
  709|      9|  if (COAP_PDU_IS_SIGNALING(pdu) ?
  ------------------
  |  |  102|      9|#define COAP_PDU_IS_SIGNALING(pdu) ((pdu)->code >= 224)
  |  |  ------------------
  |  |  |  Branch (102:36): [True: 0, False: 9]
  |  |  ------------------
  ------------------
  |  Branch (709:7): [True: 0, False: 9]
  ------------------
  710|      0|      !coap_pdu_parse_opt_csm(pdu->code, number, len) :
  711|      9|      !coap_pdu_parse_opt_base(number, len, data)) {
  712|      0|    coap_log_debug("coap_insert_option: Option %u has invalid length %" PRIuS "\n", number, len);
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  713|      0|    return 0;
  714|      0|  }
  715|       |  /* Need to locate where in current options to insert this one */
  716|      9|  coap_option_iterator_init(pdu, &opt_iter, COAP_OPT_ALL);
  ------------------
  |  |  230|      9|#define COAP_OPT_ALL NULL
  ------------------
  717|     54|  while ((option = coap_option_next(&opt_iter))) {
  ------------------
  |  Branch (717:10): [True: 54, False: 0]
  ------------------
  718|     54|    if (opt_iter.number > number) {
  ------------------
  |  Branch (718:9): [True: 9, False: 45]
  ------------------
  719|       |      /* Found where to insert */
  720|      9|      break;
  721|      9|    }
  722|     45|    prev_number = opt_iter.number;
  723|     45|  }
  724|      9|  if (option == NULL) {
  ------------------
  |  Branch (724:7): [True: 0, False: 9]
  ------------------
  725|       |    /* Code is broken somewhere */
  726|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  727|      0|    return 0;
  728|      0|  }
  729|       |
  730|       |  /* size of option inc header to insert */
  731|      9|  shift = coap_opt_encode_size(number - prev_number, len);
  732|       |
  733|       |  /* size of next option (header may shrink in size as delta changes */
  734|      9|  if (!coap_opt_parse(option, pdu->used_size - (option - pdu->token), &decode))
  ------------------
  |  Branch (734:7): [True: 0, False: 9]
  ------------------
  735|      0|    return 0;
  736|      9|  opt_delta = opt_iter.number - number;
  737|      9|  if (opt_delta == 0) {
  ------------------
  |  Branch (737:7): [True: 0, False: 9]
  ------------------
  738|      0|    if (!coap_option_check_repeatable(pdu, number))
  ------------------
  |  Branch (738:9): [True: 0, False: 0]
  ------------------
  739|      0|      return 0;
  740|      0|  }
  741|       |
  742|      9|  if (!coap_pdu_check_resize(pdu,
  ------------------
  |  Branch (742:7): [True: 0, False: 9]
  ------------------
  743|      9|                             pdu->used_size + shift - shrink))
  744|      0|    return 0;
  745|       |
  746|       |  /* Possible a re-size took place with a realloc() */
  747|       |  /* Need to locate where in current options to insert this one */
  748|      9|  coap_option_iterator_init(pdu, &opt_iter, COAP_OPT_ALL);
  ------------------
  |  |  230|      9|#define COAP_OPT_ALL NULL
  ------------------
  749|     54|  while ((option = coap_option_next(&opt_iter))) {
  ------------------
  |  Branch (749:10): [True: 54, False: 0]
  ------------------
  750|     54|    if (opt_iter.number > number) {
  ------------------
  |  Branch (750:9): [True: 9, False: 45]
  ------------------
  751|       |      /* Found where to insert */
  752|      9|      break;
  753|      9|    }
  754|     54|  }
  755|      9|  assert(option != NULL);
  ------------------
  |  Branch (755:3): [True: 9, False: 0]
  ------------------
  756|       |
  757|      9|  if (decode.delta < 13) {
  ------------------
  |  Branch (757:7): [True: 0, False: 9]
  ------------------
  758|       |    /* can simply patch in the new delta of next option */
  759|      0|    option[0] = (option[0] & 0x0f) + (coap_opt_t)(opt_delta << 4);
  760|      9|  } else if (decode.delta < 269 && opt_delta < 13) {
  ------------------
  |  Branch (760:14): [True: 9, False: 0]
  |  Branch (760:36): [True: 9, False: 0]
  ------------------
  761|       |    /* option header is going to shrink by one byte */
  762|      9|    option[1] = (option[0] & 0x0f) + (coap_opt_t)(opt_delta << 4);
  763|      9|    shrink = 1;
  764|      9|  } else if (decode.delta < 269 && opt_delta < 269) {
  ------------------
  |  Branch (764:14): [True: 0, False: 0]
  |  Branch (764:36): [True: 0, False: 0]
  ------------------
  765|       |    /* can simply patch in the new delta of next option */
  766|      0|    option[1] = (coap_opt_t)(opt_delta - 13);
  767|      0|  } else if (opt_delta < 13) {
  ------------------
  |  Branch (767:14): [True: 0, False: 0]
  ------------------
  768|       |    /* option header is going to shrink by two bytes */
  769|      0|    option[2] = (option[0] & 0x0f) + (coap_opt_t)(opt_delta << 4);
  770|      0|    shrink = 2;
  771|      0|  } else if (opt_delta < 269) {
  ------------------
  |  Branch (771:14): [True: 0, False: 0]
  ------------------
  772|       |    /* option header is going to shrink by one bytes */
  773|      0|    option[1] = (option[0] & 0x0f) + 0xd0;
  774|      0|    option[2] = (coap_opt_t)(opt_delta - 13);
  775|      0|    shrink = 1;
  776|      0|  } else {
  777|       |    /* can simply patch in the new delta of next option */
  778|      0|    option[1] = (coap_opt_t)((opt_delta - 269) >> 8);
  779|      0|    option[2] = (opt_delta - 269) & 0xff;
  780|      0|  }
  781|       |
  782|      9|  memmove(&option[shift], &option[shrink],
  783|      9|          pdu->used_size - (option - pdu->token) - shrink);
  784|      9|  if (!coap_opt_encode(option, pdu->alloc_size - pdu->used_size,
  ------------------
  |  Branch (784:7): [True: 0, False: 9]
  ------------------
  785|      9|                       number - prev_number, data, len))
  786|      0|    return 0;
  787|       |
  788|      9|  if (shift >= shrink) {
  ------------------
  |  Branch (788:7): [True: 9, False: 0]
  ------------------
  789|      9|    pdu->used_size += shift - shrink;
  790|      9|    if (pdu->data)
  ------------------
  |  Branch (790:9): [True: 0, False: 9]
  ------------------
  791|      0|      pdu->data += shift - shrink;
  792|      9|  } else {
  793|      0|    pdu->used_size -= shrink - shift;
  794|      0|    if (pdu->data)
  ------------------
  |  Branch (794:9): [True: 0, False: 0]
  ------------------
  795|      0|      pdu->data -= shrink - shift;
  796|      0|  }
  797|      9|  return shift;
  798|      9|}
coap_add_option:
  854|    110|                const uint8_t *data) {
  855|    110|  if (pdu->data) {
  ------------------
  |  Branch (855:7): [True: 0, False: 110]
  ------------------
  856|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  857|      0|    return 0;
  858|      0|  }
  859|    110|  return coap_add_option_internal(pdu, number, len, data);
  860|    110|}
coap_add_option_internal:
  864|    133|                         const uint8_t *data) {
  865|    133|  size_t optsize;
  866|    133|  coap_opt_t *opt;
  867|       |
  868|    133|  assert(pdu);
  ------------------
  |  Branch (868:3): [True: 133, False: 0]
  ------------------
  869|       |
  870|    133|  if (COAP_PDU_IS_SIGNALING(pdu) ?
  ------------------
  |  |  102|    133|#define COAP_PDU_IS_SIGNALING(pdu) ((pdu)->code >= 224)
  |  |  ------------------
  |  |  |  Branch (102:36): [True: 0, False: 133]
  |  |  ------------------
  ------------------
  |  Branch (870:7): [True: 5, False: 128]
  ------------------
  871|      0|      !coap_pdu_parse_opt_csm(pdu->code, number, len) :
  872|    133|      !coap_pdu_parse_opt_base(number, len, data)) {
  873|      5|    coap_log_debug("coap_add_option: Option %u has invalid length %" PRIuS "\n", number, len);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  874|      5|    return 0;
  875|      5|  }
  876|       |
  877|    128|  if (number == pdu->max_opt) {
  ------------------
  |  Branch (877:7): [True: 20, False: 108]
  ------------------
  878|     20|    if (!coap_option_check_repeatable(pdu, number))
  ------------------
  |  Branch (878:9): [True: 0, False: 20]
  ------------------
  879|      0|      return 0;
  880|     20|  }
  881|       |
  882|    128|  if (COAP_PDU_IS_REQUEST(pdu) &&
  ------------------
  |  |   99|    256|#define COAP_PDU_IS_REQUEST(pdu)   (!COAP_PDU_IS_EMPTY(pdu) && (pdu)->code < 32)
  |  |  ------------------
  |  |  |  |   98|    256|#define COAP_PDU_IS_EMPTY(pdu)     ((pdu)->code == 0)
  |  |  ------------------
  |  |  |  Branch (99:37): [True: 128, False: 0]
  |  |  |  Branch (99:64): [True: 128, False: 0]
  |  |  ------------------
  ------------------
  883|    128|      (number == COAP_OPTION_PROXY_URI ||
  ------------------
  |  Branch (883:8): [True: 10, False: 118]
  ------------------
  884|    118|       number == COAP_OPTION_PROXY_SCHEME)) {
  ------------------
  |  Branch (884:8): [True: 15, False: 103]
  ------------------
  885|       |    /*
  886|       |     * Need to check whether there is a hop-limit option.  If not, it needs
  887|       |     * to be inserted by default (RFC 8768).
  888|       |     */
  889|     25|    coap_opt_iterator_t opt_iter;
  890|       |
  891|     25|    if (coap_check_option(pdu, COAP_OPTION_HOP_LIMIT, &opt_iter) == NULL) {
  ------------------
  |  Branch (891:9): [True: 16, False: 9]
  ------------------
  892|     16|      size_t hop_limit = COAP_OPTION_HOP_LIMIT;
  893|       |
  894|     16|      coap_insert_option(pdu, COAP_OPTION_HOP_LIMIT, 1, (uint8_t *)&hop_limit);
  895|     16|    }
  896|     25|  }
  897|       |
  898|    128|  if (number < pdu->max_opt) {
  ------------------
  |  Branch (898:7): [True: 9, False: 119]
  ------------------
  899|      9|    coap_log_debug("coap_add_option: options are not in correct order\n");
  ------------------
  |  |  126|      9|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      9|#define coap_log(level, ...) do { \
  |  |  |  |  291|      9|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 9]
  |  |  |  |  ------------------
  |  |  |  |  292|      9|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      9|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 9]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  900|      9|    return coap_insert_option(pdu, number, len, data);
  901|      9|  }
  902|       |
  903|    119|  optsize = coap_opt_encode_size(number - pdu->max_opt, len);
  904|    119|  if (!coap_pdu_check_resize(pdu,
  ------------------
  |  Branch (904:7): [True: 0, False: 119]
  ------------------
  905|    119|                             pdu->used_size + optsize))
  906|      0|    return 0;
  907|       |
  908|    119|  if (pdu->data) {
  ------------------
  |  Branch (908:7): [True: 0, False: 119]
  ------------------
  909|       |    /* include option delimiter */
  910|      0|    memmove(&pdu->data[optsize-1], &pdu->data[-1],
  911|      0|            pdu->used_size - (pdu->data - pdu->token) + 1);
  912|      0|    opt = pdu->data -1;
  913|      0|    pdu->data += optsize;
  914|    119|  } else {
  915|    119|    opt = pdu->token + pdu->used_size;
  916|    119|  }
  917|       |
  918|       |  /* encode option and check length */
  919|    119|  optsize = coap_opt_encode(opt, pdu->alloc_size - pdu->used_size,
  920|    119|                            number - pdu->max_opt, data, len);
  921|       |
  922|    119|  if (!optsize) {
  ------------------
  |  Branch (922:7): [True: 0, False: 119]
  ------------------
  923|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  924|       |    /* error */
  925|      0|    return 0;
  926|    119|  } else {
  927|    119|    pdu->max_opt = number;
  928|    119|    pdu->used_size += optsize;
  929|    119|  }
  930|       |
  931|    119|  return optsize;
  932|    119|}
coap_add_data:
  935|     15|coap_add_data(coap_pdu_t *pdu, size_t len, const uint8_t *data) {
  936|     15|  if (len == 0) {
  ------------------
  |  Branch (936:7): [True: 0, False: 15]
  ------------------
  937|      0|    return 1;
  938|     15|  } else {
  939|     15|    uint8_t *payload = coap_add_data_after(pdu, len);
  940|     15|    if (payload != NULL)
  ------------------
  |  Branch (940:9): [True: 3, False: 12]
  ------------------
  941|      3|      memcpy(payload, data, len);
  942|       |    return payload != NULL;
  943|     15|  }
  944|     15|}
coap_add_data_after:
  947|     15|coap_add_data_after(coap_pdu_t *pdu, size_t len) {
  948|     15|  assert(pdu);
  ------------------
  |  Branch (948:3): [True: 15, False: 0]
  ------------------
  949|     15|  if (pdu->data) {
  ------------------
  |  Branch (949:7): [True: 0, False: 15]
  ------------------
  950|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  951|      0|    return 0;
  952|      0|  }
  953|       |
  954|     15|  if (len == 0)
  ------------------
  |  Branch (954:7): [True: 0, False: 15]
  ------------------
  955|      0|    return NULL;
  956|       |
  957|     15|  if (!coap_pdu_resize(pdu, pdu->used_size + len + 1))
  ------------------
  |  Branch (957:7): [True: 12, False: 3]
  ------------------
  958|     12|    return 0;
  959|      3|  pdu->token[pdu->used_size++] = COAP_PAYLOAD_START;
  ------------------
  |  |   96|      3|#define COAP_PAYLOAD_START 0xFF /* payload marker */
  ------------------
  960|      3|  pdu->data = pdu->token + pdu->used_size;
  961|      3|  pdu->used_size += len;
  962|      3|  return pdu->data;
  963|     15|}
coap_get_data_large:
  975|      9|                    size_t *offset, size_t *total) {
  976|      9|  assert(pdu);
  ------------------
  |  Branch (976:3): [True: 9, False: 0]
  ------------------
  977|      9|  assert(len);
  ------------------
  |  Branch (977:3): [True: 9, False: 0]
  ------------------
  978|      9|  assert(data);
  ------------------
  |  Branch (978:3): [True: 9, False: 0]
  ------------------
  979|       |
  980|      9|  *offset = pdu->body_offset;
  981|      9|  *total = pdu->body_total;
  982|      9|  if (pdu->body_data) {
  ------------------
  |  Branch (982:7): [True: 0, False: 9]
  ------------------
  983|      0|    *data = pdu->body_data;
  984|      0|    *len = pdu->body_length;
  985|      0|    return 1;
  986|      0|  }
  987|      9|  *data = pdu->data;
  988|      9|  if (pdu->data == NULL) {
  ------------------
  |  Branch (988:7): [True: 8, False: 1]
  ------------------
  989|      8|    *len = 0;
  990|      8|    *total = 0;
  991|      8|    return 0;
  992|      8|  }
  993|       |
  994|      1|  *len = pdu->used_size - (pdu->data - pdu->token);
  995|      1|  if (*total == 0)
  ------------------
  |  Branch (995:7): [True: 1, False: 0]
  ------------------
  996|      1|    *total = *len;
  997|       |
  998|      1|  return 1;
  999|      9|}
coap_pdu_parse_opt_base:
 1307|    161|coap_pdu_parse_opt_base(coap_option_num_t number, size_t len, const uint8_t *opt_val) {
 1308|    161|  int res = 1;
 1309|       |
 1310|    161|  switch ((coap_code_opt_num_t)number) {
 1311|      0|  case COAP_OPTION_IF_MATCH:
  ------------------
  |  Branch (1311:3): [True: 0, False: 161]
  ------------------
 1312|      0|    if (len > 8)
  ------------------
  |  Branch (1312:9): [True: 0, False: 0]
  ------------------
 1313|      0|      res = 0;
 1314|      0|    break;
 1315|     30|  case COAP_OPTION_URI_HOST:
  ------------------
  |  Branch (1315:3): [True: 30, False: 131]
  ------------------
 1316|     30|    if (len < 1 || len > 255)
  ------------------
  |  Branch (1316:9): [True: 0, False: 30]
  |  Branch (1316:20): [True: 0, False: 30]
  ------------------
 1317|      0|      res = 0;
 1318|     30|    break;
 1319|      0|  case COAP_OPTION_ETAG:
  ------------------
  |  Branch (1319:3): [True: 0, False: 161]
  ------------------
 1320|      0|    if (len < 1 || len > 8)
  ------------------
  |  Branch (1320:9): [True: 0, False: 0]
  |  Branch (1320:20): [True: 0, False: 0]
  ------------------
 1321|      0|      res = 0;
 1322|      0|    break;
 1323|      0|  case COAP_OPTION_IF_NONE_MATCH:
  ------------------
  |  Branch (1323:3): [True: 0, False: 161]
  ------------------
 1324|      0|    if (len != 0)
  ------------------
  |  Branch (1324:9): [True: 0, False: 0]
  ------------------
 1325|      0|      res = 0;
 1326|      0|    break;
 1327|      5|  case COAP_OPTION_OBSERVE:
  ------------------
  |  Branch (1327:3): [True: 5, False: 156]
  ------------------
 1328|      5|    if (len > 3)
  ------------------
  |  Branch (1328:9): [True: 5, False: 0]
  ------------------
 1329|      5|      res = 0;
 1330|      5|    break;
 1331|     17|  case COAP_OPTION_URI_PORT:
  ------------------
  |  Branch (1331:3): [True: 17, False: 144]
  ------------------
 1332|     17|    if (len > 2)
  ------------------
  |  Branch (1332:9): [True: 0, False: 17]
  ------------------
 1333|      0|      res = 0;
 1334|     17|    break;
 1335|      0|  case COAP_OPTION_LOCATION_PATH:
  ------------------
  |  Branch (1335:3): [True: 0, False: 161]
  ------------------
 1336|     49|  case COAP_OPTION_URI_PATH:
  ------------------
  |  Branch (1336:3): [True: 49, False: 112]
  ------------------
 1337|     49|    if (len > 255)
  ------------------
  |  Branch (1337:9): [True: 0, False: 49]
  ------------------
 1338|      0|      res = 0;
 1339|     49|    if (coap_check_dots(opt_val, len)) {
  ------------------
  |  Branch (1339:9): [True: 0, False: 49]
  ------------------
 1340|      0|      res = 0;
 1341|      0|    }
 1342|     49|    break;
 1343|      0|  case COAP_OPTION_OSCORE:
  ------------------
  |  Branch (1343:3): [True: 0, False: 161]
  ------------------
 1344|      0|    if (len > 255)
  ------------------
  |  Branch (1344:9): [True: 0, False: 0]
  ------------------
 1345|      0|      res = 0;
 1346|      0|    break;
 1347|      0|  case COAP_OPTION_CONTENT_FORMAT:
  ------------------
  |  Branch (1347:3): [True: 0, False: 161]
  ------------------
 1348|      0|    if (len > 2)
  ------------------
  |  Branch (1348:9): [True: 0, False: 0]
  ------------------
 1349|      0|      res = 0;
 1350|      0|    break;
 1351|      0|  case COAP_OPTION_URI_PATH_ABB:
  ------------------
  |  Branch (1351:3): [True: 0, False: 161]
  ------------------
 1352|      0|    if (len > 4)
  ------------------
  |  Branch (1352:9): [True: 0, False: 0]
  ------------------
 1353|      0|      res = 0;
 1354|      0|    break;
 1355|      0|  case COAP_OPTION_MAXAGE:
  ------------------
  |  Branch (1355:3): [True: 0, False: 161]
  ------------------
 1356|      0|    if (len > 4)
  ------------------
  |  Branch (1356:9): [True: 0, False: 0]
  ------------------
 1357|      0|      res = 0;
 1358|      0|    break;
 1359|      4|  case COAP_OPTION_URI_QUERY:
  ------------------
  |  Branch (1359:3): [True: 4, False: 157]
  ------------------
 1360|      4|    if (len > 255)
  ------------------
  |  Branch (1360:9): [True: 0, False: 4]
  ------------------
 1361|      0|      res = 0;
 1362|      4|    break;
 1363|     22|  case COAP_OPTION_HOP_LIMIT:
  ------------------
  |  Branch (1363:3): [True: 22, False: 139]
  ------------------
 1364|     22|    if (len != 1)
  ------------------
  |  Branch (1364:9): [True: 0, False: 22]
  ------------------
 1365|      0|      res = 0;
 1366|     22|    break;
 1367|      0|  case COAP_OPTION_ACCEPT:
  ------------------
  |  Branch (1367:3): [True: 0, False: 161]
  ------------------
 1368|      0|    if (len > 2)
  ------------------
  |  Branch (1368:9): [True: 0, False: 0]
  ------------------
 1369|      0|      res = 0;
 1370|      0|    break;
 1371|      0|  case COAP_OPTION_Q_BLOCK1:
  ------------------
  |  Branch (1371:3): [True: 0, False: 161]
  ------------------
 1372|      0|    if (len > 3)
  ------------------
  |  Branch (1372:9): [True: 0, False: 0]
  ------------------
 1373|      0|      res = 0;
 1374|      0|    break;
 1375|      0|  case COAP_OPTION_LOCATION_QUERY:
  ------------------
  |  Branch (1375:3): [True: 0, False: 161]
  ------------------
 1376|      0|    if (len > 255)
  ------------------
  |  Branch (1376:9): [True: 0, False: 0]
  ------------------
 1377|      0|      res = 0;
 1378|      0|    break;
 1379|      0|  case COAP_OPTION_EDHOC:
  ------------------
  |  Branch (1379:3): [True: 0, False: 161]
  ------------------
 1380|      0|    if (len != 0)
  ------------------
  |  Branch (1380:9): [True: 0, False: 0]
  ------------------
 1381|      0|      res = 0;
 1382|      0|    break;
 1383|      0|  case COAP_OPTION_BLOCK2:
  ------------------
  |  Branch (1383:3): [True: 0, False: 161]
  ------------------
 1384|      0|    if (len > 3)
  ------------------
  |  Branch (1384:9): [True: 0, False: 0]
  ------------------
 1385|      0|      res = 0;
 1386|      0|    break;
 1387|      0|  case COAP_OPTION_BLOCK1:
  ------------------
  |  Branch (1387:3): [True: 0, False: 161]
  ------------------
 1388|      0|    if (len > 3)
  ------------------
  |  Branch (1388:9): [True: 0, False: 0]
  ------------------
 1389|      0|      res = 0;
 1390|      0|    break;
 1391|      0|  case COAP_OPTION_SIZE2:
  ------------------
  |  Branch (1391:3): [True: 0, False: 161]
  ------------------
 1392|      0|    if (len > 4)
  ------------------
  |  Branch (1392:9): [True: 0, False: 0]
  ------------------
 1393|      0|      res = 0;
 1394|      0|    break;
 1395|      0|  case COAP_OPTION_Q_BLOCK2:
  ------------------
  |  Branch (1395:3): [True: 0, False: 161]
  ------------------
 1396|      0|    if (len > 3)
  ------------------
  |  Branch (1396:9): [True: 0, False: 0]
  ------------------
 1397|      0|      res = 0;
 1398|      0|    break;
 1399|     19|  case COAP_OPTION_PROXY_URI:
  ------------------
  |  Branch (1399:3): [True: 19, False: 142]
  ------------------
 1400|     19|    if (len < 1 || len > 1034)
  ------------------
  |  Branch (1400:9): [True: 0, False: 19]
  |  Branch (1400:20): [True: 0, False: 19]
  ------------------
 1401|      0|      res = 0;
 1402|     19|    break;
 1403|     15|  case COAP_OPTION_PROXY_SCHEME:
  ------------------
  |  Branch (1403:3): [True: 15, False: 146]
  ------------------
 1404|     15|    if (len < 1 || len > 255)
  ------------------
  |  Branch (1404:9): [True: 0, False: 15]
  |  Branch (1404:20): [True: 0, False: 15]
  ------------------
 1405|      0|      res = 0;
 1406|     15|    break;
 1407|      0|  case COAP_OPTION_SIZE1:
  ------------------
  |  Branch (1407:3): [True: 0, False: 161]
  ------------------
 1408|      0|    if (len > 4)
  ------------------
  |  Branch (1408:9): [True: 0, False: 0]
  ------------------
 1409|      0|      res = 0;
 1410|      0|    break;
 1411|      0|  case COAP_OPTION_ECHO:
  ------------------
  |  Branch (1411:3): [True: 0, False: 161]
  ------------------
 1412|      0|    if (len > 40)
  ------------------
  |  Branch (1412:9): [True: 0, False: 0]
  ------------------
 1413|      0|      res = 0;
 1414|      0|    break;
 1415|      0|  case COAP_OPTION_NORESPONSE:
  ------------------
  |  Branch (1415:3): [True: 0, False: 161]
  ------------------
 1416|      0|    if (len > 1)
  ------------------
  |  Branch (1416:9): [True: 0, False: 0]
  ------------------
 1417|      0|      res = 0;
 1418|      0|    break;
 1419|      0|  case COAP_OPTION_RTAG:
  ------------------
  |  Branch (1419:3): [True: 0, False: 161]
  ------------------
 1420|      0|    if (len > 8)
  ------------------
  |  Branch (1420:9): [True: 0, False: 0]
  ------------------
 1421|      0|      res = 0;
 1422|      0|    break;
 1423|      0|  default:
  ------------------
  |  Branch (1423:3): [True: 0, False: 161]
  ------------------
 1424|      0|    ;
 1425|    161|  }
 1426|    161|  return res;
 1427|    161|}
coap_pdu_encode_header:
 1635|      9|coap_pdu_encode_header(coap_pdu_t *pdu, coap_proto_t proto) {
 1636|      9|  uint8_t e_token_length;
 1637|       |
 1638|      9|  if (pdu->actual_token.length < COAP_TOKEN_EXT_1B_BIAS) {
  ------------------
  |  |   56|      9|#define COAP_TOKEN_EXT_1B_BIAS 13
  ------------------
  |  Branch (1638:7): [True: 9, False: 0]
  ------------------
 1639|      9|    e_token_length = (uint8_t)pdu->actual_token.length;
 1640|      9|  } else if (pdu->actual_token.length < COAP_TOKEN_EXT_2B_BIAS) {
  ------------------
  |  |   57|      0|#define COAP_TOKEN_EXT_2B_BIAS 269 /* 13 + 256 */
  ------------------
  |  Branch (1640:14): [True: 0, False: 0]
  ------------------
 1641|      0|    e_token_length = COAP_TOKEN_EXT_1B_TKL;
  ------------------
  |  |   54|      0|#define COAP_TOKEN_EXT_1B_TKL 13
  ------------------
 1642|      0|  } else if (pdu->actual_token.length <= COAP_TOKEN_EXT_MAX) {
  ------------------
  |  |   60|      0|#define COAP_TOKEN_EXT_MAX 65804UL /* 13 + 256 + 65535 */
  ------------------
  |  Branch (1642:14): [True: 0, False: 0]
  ------------------
 1643|      0|    e_token_length = COAP_TOKEN_EXT_2B_TKL;
  ------------------
  |  |   55|      0|#define COAP_TOKEN_EXT_2B_TKL 14
  ------------------
 1644|      0|  } else {
 1645|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1646|      0|    return 0;
 1647|      0|  }
 1648|      9|  if (COAP_PROTO_NOT_RELIABLE(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]
  |  |  ------------------
  ------------------
 1649|      9|    assert(pdu->max_hdr_size >= 4);
  ------------------
  |  Branch (1649:5): [True: 9, False: 0]
  ------------------
 1650|      9|    if (pdu->max_hdr_size < 4) {
  ------------------
  |  Branch (1650:9): [True: 0, False: 9]
  ------------------
 1651|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1652|      0|      return 0;
 1653|      0|    }
 1654|      9|    pdu->token[-4] = COAP_DEFAULT_VERSION << 6
  ------------------
  |  |   35|      9|#define COAP_DEFAULT_VERSION      1 /* version of CoAP supported */
  ------------------
 1655|      9|                     | pdu->type << 4
 1656|      9|                     | e_token_length;
 1657|      9|    pdu->token[-3] = pdu->code;
 1658|      9|    pdu->token[-2] = (uint8_t)(pdu->mid >> 8);
 1659|      9|    pdu->token[-1] = (uint8_t)(pdu->mid);
 1660|      9|    pdu->hdr_size = 4;
 1661|      9|#if !COAP_DISABLE_TCP
 1662|      9|  } 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]
  |  |  ------------------
  ------------------
 1663|      0|    size_t len;
 1664|      0|    assert(pdu->used_size >= pdu->e_token_length);
  ------------------
  |  Branch (1664:5): [True: 0, False: 0]
  ------------------
 1665|      0|    if (pdu->used_size < pdu->e_token_length) {
  ------------------
  |  Branch (1665:9): [True: 0, False: 0]
  ------------------
 1666|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1667|      0|      return 0;
 1668|      0|    }
 1669|       |
 1670|       |    /* A lot of the reliable code assumes type is CON */
 1671|      0|    if (pdu->type != COAP_MESSAGE_CON)
  ------------------
  |  Branch (1671:9): [True: 0, False: 0]
  ------------------
 1672|      0|      pdu->type = COAP_MESSAGE_CON;
 1673|       |
 1674|      0|    if (proto == COAP_PROTO_WS || proto == COAP_PROTO_WSS)
  ------------------
  |  Branch (1674:9): [True: 0, False: 0]
  |  Branch (1674:35): [True: 0, False: 0]
  ------------------
 1675|      0|      len = 0;
 1676|      0|    else
 1677|      0|      len = pdu->used_size - pdu->e_token_length;
 1678|      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 (1678:9): [True: 0, False: 0]
  ------------------
 1679|      0|      assert(pdu->max_hdr_size >= 2);
  ------------------
  |  Branch (1679:7): [True: 0, False: 0]
  ------------------
 1680|      0|      if (pdu->max_hdr_size < 2) {
  ------------------
  |  Branch (1680:11): [True: 0, False: 0]
  ------------------
 1681|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1682|      0|        return 0;
 1683|      0|      }
 1684|      0|      pdu->token[-2] = (uint8_t)len << 4
 1685|      0|                       | e_token_length;
 1686|      0|      pdu->token[-1] = pdu->code;
 1687|      0|      pdu->hdr_size = 2;
 1688|      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 (1688:16): [True: 0, False: 0]
  ------------------
 1689|      0|      assert(pdu->max_hdr_size >= 3);
  ------------------
  |  Branch (1689:7): [True: 0, False: 0]
  ------------------
 1690|      0|      if (pdu->max_hdr_size < 3) {
  ------------------
  |  Branch (1690:11): [True: 0, False: 0]
  ------------------
 1691|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1692|      0|        return 0;
 1693|      0|      }
 1694|      0|      pdu->token[-3] = 13 << 4 | e_token_length;
 1695|      0|      pdu->token[-2] = (uint8_t)(len - COAP_MESSAGE_SIZE_OFFSET_TCP8);
  ------------------
  |  |   38|      0|#define COAP_MESSAGE_SIZE_OFFSET_TCP8 13
  ------------------
 1696|      0|      pdu->token[-1] = pdu->code;
 1697|      0|      pdu->hdr_size = 3;
 1698|      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 (1698:16): [True: 0, False: 0]
  ------------------
 1699|      0|      assert(pdu->max_hdr_size >= 4);
  ------------------
  |  Branch (1699:7): [True: 0, False: 0]
  ------------------
 1700|      0|      if (pdu->max_hdr_size < 4) {
  ------------------
  |  Branch (1700:11): [True: 0, False: 0]
  ------------------
 1701|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1702|      0|        return 0;
 1703|      0|      }
 1704|      0|      pdu->token[-4] = 14 << 4 | e_token_length;
 1705|      0|      pdu->token[-3] = (uint8_t)((len - COAP_MESSAGE_SIZE_OFFSET_TCP16) >> 8);
  ------------------
  |  |   39|      0|#define COAP_MESSAGE_SIZE_OFFSET_TCP16 269 /* 13 + 256 */
  ------------------
 1706|      0|      pdu->token[-2] = (uint8_t)(len - COAP_MESSAGE_SIZE_OFFSET_TCP16);
  ------------------
  |  |   39|      0|#define COAP_MESSAGE_SIZE_OFFSET_TCP16 269 /* 13 + 256 */
  ------------------
 1707|      0|      pdu->token[-1] = pdu->code;
 1708|      0|      pdu->hdr_size = 4;
 1709|      0|    } else {
 1710|      0|      assert(pdu->max_hdr_size >= 6);
  ------------------
  |  Branch (1710:7): [True: 0, False: 0]
  ------------------
 1711|      0|      if (pdu->max_hdr_size < 6) {
  ------------------
  |  Branch (1711:11): [True: 0, False: 0]
  ------------------
 1712|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1713|      0|        return 0;
 1714|      0|      }
 1715|      0|      pdu->token[-6] = 15 << 4 | e_token_length;
 1716|      0|      pdu->token[-5] = (uint8_t)((len - COAP_MESSAGE_SIZE_OFFSET_TCP32) >> 24);
  ------------------
  |  |   40|      0|#define COAP_MESSAGE_SIZE_OFFSET_TCP32 65805 /* 269 + 65536 */
  ------------------
 1717|      0|      pdu->token[-4] = (uint8_t)((len - COAP_MESSAGE_SIZE_OFFSET_TCP32) >> 16);
  ------------------
  |  |   40|      0|#define COAP_MESSAGE_SIZE_OFFSET_TCP32 65805 /* 269 + 65536 */
  ------------------
 1718|      0|      pdu->token[-3] = (uint8_t)((len - COAP_MESSAGE_SIZE_OFFSET_TCP32) >> 8);
  ------------------
  |  |   40|      0|#define COAP_MESSAGE_SIZE_OFFSET_TCP32 65805 /* 269 + 65536 */
  ------------------
 1719|      0|      pdu->token[-2] = (uint8_t)(len - COAP_MESSAGE_SIZE_OFFSET_TCP32);
  ------------------
  |  |   40|      0|#define COAP_MESSAGE_SIZE_OFFSET_TCP32 65805 /* 269 + 65536 */
  ------------------
 1720|      0|      pdu->token[-1] = pdu->code;
 1721|      0|      pdu->hdr_size = 6;
 1722|      0|    }
 1723|      0|#endif /* ! COAP_DISABLE_TCP */
 1724|      0|  } else {
 1725|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1726|      0|  }
 1727|      9|  return pdu->hdr_size;
 1728|      9|}
coap_pdu_get_token:
 1755|     30|coap_pdu_get_token(const coap_pdu_t *pdu) {
 1756|     30|  return pdu->actual_token;
 1757|     30|}
coap_const_pdu_reference_lkd:
 1781|     26|coap_const_pdu_reference_lkd(const coap_pdu_t *pdu) {
 1782|     26|  coap_pdu_t *pdu_rw = NULL;
 1783|       |
 1784|     26|  if (pdu != NULL) {
  ------------------
  |  Branch (1784:7): [True: 26, False: 0]
  ------------------
 1785|       |
 1786|       |    /* Need to do this to not get a compiler warning about const parameters */
 1787|     26|    memcpy(&pdu_rw, &pdu, sizeof(pdu_rw));
 1788|     26|    ++pdu_rw->ref;
 1789|     26|  }
 1790|     26|  return pdu_rw;
 1791|     26|}

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

coap_proxy_log_entry:
   43|     48|                     coap_bin_const_t *upstream_token, const char *type) {
   44|     48|  if (coap_get_log_level() >= COAP_LOG_DEBUG) {
  ------------------
  |  Branch (44:7): [True: 0, False: 48]
  ------------------
   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|     48|}
coap_proxy_del_req:
   79|     13|coap_proxy_del_req(coap_proxy_entry_t *proxy_entry, coap_proxy_req_t *proxy_req) {
   80|     13|  coap_proxy_log_entry(proxy_req->incoming, proxy_req->pdu,  proxy_req->token_used, "del");
   81|       |
   82|     13|  coap_delete_pdu_lkd(proxy_req->pdu);
   83|     13|  coap_delete_bin_const(proxy_req->token_used);
   84|     13|  coap_delete_cache_key(proxy_req->cache_key);
   85|     13|  if (proxy_req->proxy_cache) {
  ------------------
  |  Branch (85:7): [True: 0, False: 13]
  ------------------
   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);
  ------------------
  |  |  291|      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|     13|  proxy_req->incoming = NULL;
  113|       |
  114|     13|  LL_DELETE(proxy_entry->proxy_req, proxy_req);
  ------------------
  |  |  391|     13|    LL_DELETE2(head,del,next)
  |  |  ------------------
  |  |  |  |  393|     13|#define LL_DELETE2(head,del,next)                                                              \
  |  |  |  |  394|     13|do {                                                                                           \
  |  |  |  |  395|     13|  LDECLTYPE(head) _tmp;                                                                        \
  |  |  |  |  ------------------
  |  |  |  |  |  |   81|     13|#define LDECLTYPE(x) __typeof(x)
  |  |  |  |  ------------------
  |  |  |  |  396|     13|  if ((head) == (del)) {                                                                       \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (396:7): [True: 13, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  397|     13|    (head)=(head)->next;                                                                       \
  |  |  |  |  398|     13|  } 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|     13|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (407:10): [Folded, False: 13]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  115|     13|  coap_free_type(COAP_STRING, proxy_req);
  116|     13|}
coap_proxy_cleanup:
  155|     30|coap_proxy_cleanup(coap_context_t *context) {
  156|     30|  size_t i;
  157|       |
  158|     43|  for (i = 0; i < context->proxy_list_count; i++) {
  ------------------
  |  Branch (158:15): [True: 13, False: 30]
  ------------------
  159|       |    /* All sessions have now been closed down */
  160|     13|    coap_log_debug("proxy_entry %p cleaned up\n",
  ------------------
  |  |  126|     13|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|     13|#define coap_log(level, ...) do { \
  |  |  |  |  291|     13|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 13]
  |  |  |  |  ------------------
  |  |  |  |  292|     13|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|     13|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 13]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  161|     13|                   (void *)&context->proxy_list[i]);
  162|     13|    coap_proxy_cleanup_entry(&context->proxy_list[i], 0);
  163|     13|  }
  164|     30|  coap_free_type(COAP_STRING, context->proxy_list);
  165|     30|}
coap_verify_proxy_scheme_supported:
  298|     13|coap_verify_proxy_scheme_supported(coap_uri_scheme_t scheme) {
  299|       |
  300|       |  /* Sanity check that the connection can be forwarded on */
  301|     13|  switch (scheme) {
  302|      0|  case COAP_URI_SCHEME_HTTP:
  ------------------
  |  Branch (302:3): [True: 0, False: 13]
  ------------------
  303|      0|  case COAP_URI_SCHEME_HTTPS:
  ------------------
  |  Branch (303:3): [True: 0, False: 13]
  ------------------
  304|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  305|      0|    return 0;
  306|     13|  case COAP_URI_SCHEME_COAP:
  ------------------
  |  Branch (306:3): [True: 13, False: 0]
  ------------------
  307|     13|    break;
  308|      0|  case COAP_URI_SCHEME_COAPS:
  ------------------
  |  Branch (308:3): [True: 0, False: 13]
  ------------------
  309|      0|    if (!coap_dtls_is_supported()) {
  ------------------
  |  Branch (309:9): [True: 0, False: 0]
  ------------------
  310|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  311|      0|      return 0;
  312|      0|    }
  313|      0|    break;
  314|      0|  case COAP_URI_SCHEME_COAP_TCP:
  ------------------
  |  Branch (314:3): [True: 0, False: 13]
  ------------------
  315|      0|    if (!coap_tcp_is_supported()) {
  ------------------
  |  Branch (315:9): [True: 0, False: 0]
  ------------------
  316|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  317|      0|      return 0;
  318|      0|    }
  319|      0|    break;
  320|      0|  case COAP_URI_SCHEME_COAPS_TCP:
  ------------------
  |  Branch (320:3): [True: 0, False: 13]
  ------------------
  321|      0|    if (!coap_tls_is_supported()) {
  ------------------
  |  Branch (321:9): [True: 0, False: 0]
  ------------------
  322|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  323|      0|      return 0;
  324|      0|    }
  325|      0|    break;
  326|      0|  case COAP_URI_SCHEME_COAP_WS:
  ------------------
  |  Branch (326:3): [True: 0, False: 13]
  ------------------
  327|      0|    if (!coap_ws_is_supported()) {
  ------------------
  |  Branch (327:9): [True: 0, False: 0]
  ------------------
  328|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  329|      0|      return 0;
  330|      0|    }
  331|      0|    break;
  332|      0|  case COAP_URI_SCHEME_COAPS_WS:
  ------------------
  |  Branch (332:3): [True: 0, False: 13]
  ------------------
  333|      0|    if (!coap_wss_is_supported()) {
  ------------------
  |  Branch (333:9): [True: 0, False: 0]
  ------------------
  334|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  335|      0|      return 0;
  336|      0|    }
  337|      0|    break;
  338|      0|  case COAP_URI_SCHEME_LAST:
  ------------------
  |  Branch (338:3): [True: 0, False: 13]
  ------------------
  339|      0|  default:
  ------------------
  |  Branch (339:3): [True: 0, False: 13]
  ------------------
  340|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  341|      0|    return 0;
  342|     13|  }
  343|     13|  return 1;
  344|     13|}
coap_proxy_forward_request:
  968|     30|                           coap_proxy_server_list_t *server_list) {
  969|     30|  int ret;
  970|       |
  971|     30|  coap_lock_lock(return 0);
  972|     30|  ret = coap_proxy_forward_request_lkd(session,
  973|     30|                                       request,
  974|     30|                                       response,
  975|     30|                                       resource,
  976|     30|                                       cache_key,
  977|     30|                                       server_list);
  978|     30|  coap_lock_unlock();
  979|     30|  return ret;
  980|     30|}
coap_proxy_forward_request_lkd:
  996|     30|                               coap_proxy_server_list_t *server_list) {
  997|     30|  coap_proxy_entry_t *proxy_entry;
  998|     30|  size_t size;
  999|     30|  size_t offset;
 1000|     30|  size_t total;
 1001|     30|  coap_binary_t *body_data = NULL;
 1002|     30|  const uint8_t *data;
 1003|     30|  coap_pdu_t *pdu = NULL;
 1004|     30|  coap_bin_const_t r_token = coap_pdu_get_token(request);
 1005|     30|  uint8_t token[8];
 1006|     30|  size_t token_len;
 1007|     30|  coap_proxy_req_t *proxy_req = NULL;
 1008|     30|  coap_optlist_t *optlist = NULL;
 1009|     30|  coap_opt_t *option;
 1010|     30|  coap_opt_iterator_t opt_iter;
 1011|     30|  coap_uri_t uri;
 1012|     30|  coap_opt_t *obs_opt = coap_check_option(request,
 1013|     30|                                          COAP_OPTION_OBSERVE,
 1014|     30|                                          &opt_iter);
 1015|     30|  coap_proxy_cache_t *proxy_cache = NULL;
 1016|     30|  coap_proxy_t proxy_type;
 1017|     30|  coap_tick_t now;
 1018|     30|  uint32_t new_maxage;
 1019|     30|  uint8_t buf[4];
 1020|       |
 1021|     30|  coap_ticks(&now);
 1022|       |
 1023|       |  /* Set up ongoing session (if not already done) */
 1024|     30|  proxy_entry = coap_proxy_get_ongoing_session(session, request, response,
 1025|     30|                                               server_list);
 1026|     30|  if (!proxy_entry) {
  ------------------
  |  Branch (1026:7): [True: 17, False: 13]
  ------------------
 1027|       |    /* Error response code already set */
 1028|     17|    return 0;
 1029|     17|  }
 1030|     13|  coap_proxy_log_entry(session, request, NULL, "req");
 1031|       |
 1032|       |  /* Is this a observe cached request? */
 1033|     13|  if (obs_opt && session->context->proxy_response_cb) {
  ------------------
  |  Branch (1033:7): [True: 0, False: 13]
  |  Branch (1033:18): [True: 0, False: 0]
  ------------------
 1034|      0|    coap_cache_key_t *cache_key_l;
 1035|       |
 1036|      0|    cache_key_l = coap_cache_derive_key_w_ignore(session, request,
 1037|      0|                                                 COAP_CACHE_NOT_SESSION_BASED,
 1038|      0|                                                 coap_proxy_ignore_options,
 1039|      0|                                                 sizeof(coap_proxy_ignore_options)/sizeof(coap_proxy_ignore_options[0]));
 1040|      0|    if (!cache_key_l) {
  ------------------
  |  Branch (1040:9): [True: 0, False: 0]
  ------------------
 1041|      0|      response->code = COAP_RESPONSE_CODE(505);
  ------------------
  |  |   96|      0|#define COAP_RESPONSE_CODE(N) (((N)/100 << 5) | (N)%100)
  ------------------
 1042|      0|      return 0;
 1043|      0|    }
 1044|      0|    PROXY_CACHE_FIND(proxy_entry->rsp_cache, cache_key_l, proxy_cache);
  ------------------
  |  |  299|      0|#define PROXY_CACHE_FIND(e, k, res) {                     \
  |  |  300|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  301|      0|  }
  ------------------
 1045|      0|    coap_delete_cache_key(cache_key_l);
 1046|      0|  }
 1047|       |
 1048|     13|  if (proxy_cache) {
  ------------------
  |  Branch (1048:7): [True: 0, False: 13]
  ------------------
 1049|      0|    proxy_req = coap_proxy_get_req(proxy_entry, proxy_cache, session);
 1050|      0|    if (proxy_req) {
  ------------------
  |  Branch (1050:9): [True: 0, False: 0]
  ------------------
 1051|      0|      if (obs_opt) {
  ------------------
  |  Branch (1051:11): [True: 0, False: 0]
  ------------------
 1052|      0|        int observe_action;
 1053|       |
 1054|      0|        observe_action = coap_decode_var_bytes(coap_opt_value(obs_opt),
 1055|      0|                                               coap_opt_length(obs_opt));
 1056|       |
 1057|      0|        if (observe_action == COAP_OBSERVE_CANCEL) {
  ------------------
  |  |   44|      0|#define COAP_OBSERVE_CANCEL 1
  ------------------
  |  Branch (1057:13): [True: 0, False: 0]
  ------------------
 1058|      0|          if (proxy_req->doing_observe) {
  ------------------
  |  Branch (1058:15): [True: 0, False: 0]
  ------------------
 1059|      0|            assert(proxy_req->incoming->ref_proxy_subs);
  ------------------
  |  Branch (1059:13): [True: 0, False: 0]
  ------------------
 1060|      0|            proxy_req->incoming->ref_proxy_subs--;
 1061|      0|            proxy_req->doing_observe = 0;
 1062|      0|          }
 1063|      0|          if (proxy_entry->proxy_req && !proxy_entry->proxy_req->next &&
  ------------------
  |  Branch (1063:15): [True: 0, False: 0]
  |  Branch (1063:41): [True: 0, False: 0]
  ------------------
 1064|      0|              proxy_req->token_used) {
  ------------------
  |  Branch (1064:15): [True: 0, False: 0]
  ------------------
 1065|      0|            coap_binary_t tmp;
 1066|       |
 1067|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1068|       |            /* Unfortunately need to change the ptr type to be r/w */
 1069|      0|            memcpy(&tmp.s, &proxy_req->token_used->s, sizeof(tmp.s));
 1070|      0|            tmp.length = proxy_req->token_used->length;
 1071|      0|            coap_cancel_observe_lkd(proxy_entry->ongoing, &tmp, COAP_MESSAGE_CON);
 1072|       |            /* Let the upstream cancellation be the response */
 1073|      0|            return 1;
 1074|      0|          } else {
 1075|      0|            obs_opt = 0;
 1076|      0|            goto return_cached_info;
 1077|      0|          }
 1078|      0|        } else if (observe_action == COAP_OBSERVE_ESTABLISH) {
  ------------------
  |  |   37|      0|#define COAP_OBSERVE_ESTABLISH 0
  ------------------
  |  Branch (1078:20): [True: 0, False: 0]
  ------------------
 1079|       |          /* Client must be re-registering */
 1080|      0|          if (proxy_cache && (proxy_cache->expire + COAP_TICKS_PER_SECOND) < now) {
  ------------------
  |  |  164|      0|#define COAP_TICKS_PER_SECOND ((coap_tick_t)(1000U))
  ------------------
  |  Branch (1080:15): [True: 0, False: 0]
  |  Branch (1080:30): [True: 0, False: 0]
  ------------------
 1081|       |            /* Need to get an updated rsp_pdu */
 1082|      0|            coap_proxy_del_req(proxy_entry, proxy_req);
 1083|      0|            proxy_req = NULL;
 1084|      0|            proxy_cache = NULL;
 1085|      0|          } else {
 1086|      0|            goto return_cached_info;
 1087|      0|          }
 1088|      0|        }
 1089|      0|      } else {
 1090|      0|        if (proxy_cache && (proxy_cache->expire + COAP_TICKS_PER_SECOND) < now) {
  ------------------
  |  |  164|      0|#define COAP_TICKS_PER_SECOND ((coap_tick_t)(1000U))
  ------------------
  |  Branch (1090:13): [True: 0, False: 0]
  |  Branch (1090:28): [True: 0, False: 0]
  ------------------
 1091|       |          /* Need to get an updated rsp_pdu */
 1092|      0|          coap_proxy_del_req(proxy_entry, proxy_req);
 1093|      0|          proxy_req = NULL;
 1094|      0|          proxy_cache = NULL;
 1095|      0|        } else {
 1096|      0|          goto return_cached_info;
 1097|      0|        }
 1098|      0|      }
 1099|      0|    }
 1100|      0|  }
 1101|       |
 1102|     13|  if (!proxy_req) {
  ------------------
  |  Branch (1102:7): [True: 13, False: 0]
  ------------------
 1103|     13|    proxy_req = coap_malloc_type(COAP_STRING, sizeof(coap_proxy_req_t));
 1104|     13|    if (proxy_req == NULL) {
  ------------------
  |  Branch (1104:9): [True: 0, False: 13]
  ------------------
 1105|      0|      goto failed;
 1106|      0|    }
 1107|     13|    memset(proxy_req, 0, sizeof(coap_proxy_req_t));
 1108|     13|    LL_PREPEND(proxy_entry->proxy_req, proxy_req);
  ------------------
  |  |  320|     13|    LL_PREPEND2(head,add,next)
  |  |  ------------------
  |  |  |  |  322|     13|#define LL_PREPEND2(head,add,next)                                                             \
  |  |  |  |  323|     13|do {                                                                                           \
  |  |  |  |  324|     13|  (add)->next = (head);                                                                        \
  |  |  |  |  325|     13|  (head) = (add);                                                                              \
  |  |  |  |  326|     13|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (326:10): [Folded, False: 13]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1109|       |
 1110|     13|    proxy_req->pdu = coap_const_pdu_reference_lkd(request);
 1111|     13|    proxy_req->resource = resource;
 1112|     13|    proxy_req->incoming = session;
 1113|     13|    proxy_req->cache_key = cache_key;
 1114|     13|    proxy_req->proxy_cache = proxy_cache;
 1115|       |
 1116|     13|    coap_proxy_log_entry(proxy_req->incoming, proxy_req->pdu, proxy_req->token_used,  "add");
 1117|     13|  }
 1118|       |
 1119|     13|  if (proxy_cache) {
  ------------------
  |  Branch (1119:7): [True: 0, False: 13]
  ------------------
 1120|      0|    coap_bin_const_t j_token;
 1121|       |
 1122|      0|    if (obs_opt)
  ------------------
  |  Branch (1122:9): [True: 0, False: 0]
  ------------------
 1123|      0|      proxy_cache->ref++;
 1124|      0|    coap_delete_bin_const(proxy_req->token_used);
 1125|      0|    j_token = coap_pdu_get_token(proxy_cache->rsp_pdu);
 1126|      0|    proxy_req->token_used = coap_new_bin_const(j_token.s, j_token.length);
 1127|      0|    if (proxy_req->token_used == NULL) {
  ------------------
  |  Branch (1127:9): [True: 0, False: 0]
  ------------------
 1128|      0|      goto failed;
 1129|      0|    }
 1130|      0|    goto return_cached_info;
 1131|      0|  }
 1132|       |
 1133|       |  /* Get a new token for ongoing session */
 1134|     13|  coap_session_new_token(proxy_entry->ongoing, &token_len, token);
 1135|     13|  coap_delete_bin_const(proxy_req->token_used);
 1136|     13|  proxy_req->token_used = coap_new_bin_const(token, token_len);
 1137|     13|  if (proxy_req->token_used == NULL) {
  ------------------
  |  Branch (1137:7): [True: 0, False: 13]
  ------------------
 1138|      0|    goto failed;
 1139|      0|  }
 1140|     13|  coap_pdu_release_lkd(proxy_req->pdu);
 1141|     13|  proxy_req->pdu = coap_const_pdu_reference_lkd(request);
 1142|       |
 1143|       |  /* Need to create the ongoing request pdu entry */
 1144|     13|  proxy_type = coap_proxy_map_type(server_list->type);
 1145|     13|  if (proxy_type & COAP_PROXY_BIT_STRIP) {
  ------------------
  |  Branch (1145:7): [True: 8, False: 5]
  ------------------
 1146|       |    /*
 1147|       |     * Need to replace Proxy-Uri with Uri-Host (and Uri-Port)
 1148|       |     * and strip out Proxy-Scheme.
 1149|       |     */
 1150|       |
 1151|       |    /*
 1152|       |     * Build up the ongoing PDU that we are going to send
 1153|       |     */
 1154|      8|    pdu = coap_pdu_init(request->type, request->code,
 1155|      8|                        coap_new_message_id_lkd(proxy_entry->ongoing),
 1156|      8|                        coap_session_max_pdu_size_lkd(proxy_entry->ongoing));
 1157|      8|    if (!pdu) {
  ------------------
  |  Branch (1157:9): [True: 0, False: 8]
  ------------------
 1158|      0|      goto failed;
 1159|      0|    }
 1160|       |
 1161|      8|    if (coap_is_mcast(&proxy_entry->ongoing->addr_info.remote)) {
  ------------------
  |  Branch (1161:9): [True: 0, False: 8]
  ------------------
 1162|      0|      pdu->type = COAP_MESSAGE_NON;
 1163|      0|    }
 1164|       |
 1165|      8|    if (!coap_add_token(pdu, token_len, token)) {
  ------------------
  |  Branch (1165:9): [True: 0, False: 8]
  ------------------
 1166|      0|      goto failed;
 1167|      0|    }
 1168|       |
 1169|       |    /* Copy the remaining options across */
 1170|      8|    coap_option_iterator_init(request, &opt_iter, COAP_OPT_ALL);
  ------------------
  |  |  230|      8|#define COAP_OPT_ALL NULL
  ------------------
 1171|     38|    while ((option = coap_option_next(&opt_iter))) {
  ------------------
  |  Branch (1171:12): [True: 34, False: 4]
  ------------------
 1172|     34|      switch (opt_iter.number) {
 1173|      5|      case COAP_OPTION_PROXY_URI:
  ------------------
  |  Branch (1173:7): [True: 5, False: 29]
  ------------------
 1174|      5|        if (coap_split_proxy_uri(coap_opt_value(option),
  ------------------
  |  Branch (1174:13): [True: 4, False: 1]
  ------------------
 1175|      5|                                 coap_opt_length(option),
 1176|      5|                                 &uri) < 0) {
 1177|       |          /* Need to return a 5.05 RFC7252 Section 5.7.2 */
 1178|      4|          coap_log_warn("Proxy URI not decodable\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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1179|      4|          goto failed;
 1180|      4|        }
 1181|      1|        if (!coap_uri_into_optlist(&uri, NULL, &optlist, 0)) {
  ------------------
  |  Branch (1181:13): [True: 0, False: 1]
  ------------------
 1182|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1183|      0|          goto failed;
 1184|      0|        }
 1185|      1|        break;
 1186|      1|      case COAP_OPTION_PROXY_SCHEME:
  ------------------
  |  Branch (1186:7): [True: 1, False: 33]
  ------------------
 1187|      1|        break;
 1188|      0|      case COAP_OPTION_BLOCK1:
  ------------------
  |  Branch (1188:7): [True: 0, False: 34]
  ------------------
 1189|      0|      case COAP_OPTION_BLOCK2:
  ------------------
  |  Branch (1189:7): [True: 0, False: 34]
  ------------------
 1190|      0|      case COAP_OPTION_Q_BLOCK1:
  ------------------
  |  Branch (1190:7): [True: 0, False: 34]
  ------------------
 1191|      0|      case COAP_OPTION_Q_BLOCK2:
  ------------------
  |  Branch (1191:7): [True: 0, False: 34]
  ------------------
 1192|       |        /* These are not passed on */
 1193|      0|        break;
 1194|      8|      case COAP_OPTION_URI_HOST:
  ------------------
  |  Branch (1194:7): [True: 8, False: 26]
  ------------------
 1195|     13|      case COAP_OPTION_URI_PORT:
  ------------------
  |  Branch (1195:7): [True: 5, False: 29]
  ------------------
 1196|     13|        break;
 1197|     15|      default:
  ------------------
  |  Branch (1197:7): [True: 15, False: 19]
  ------------------
 1198|     15|        coap_insert_optlist(&optlist,
 1199|     15|                            coap_new_optlist(opt_iter.number,
 1200|     15|                                             coap_opt_length(option),
 1201|     15|                                             coap_opt_value(option)));
 1202|     15|        break;
 1203|     34|      }
 1204|     34|    }
 1205|       |
 1206|       |    /* Update pdu with options */
 1207|      4|    coap_add_optlist_pdu(pdu, &optlist);
 1208|      4|    coap_delete_optlist(optlist);
 1209|      4|    optlist = NULL;
 1210|      5|  } else {
 1211|       |    /*
 1212|       |     * Duplicate request PDU for onward transmission (with new token).
 1213|       |     */
 1214|      5|    pdu = coap_pdu_duplicate_lkd(request, proxy_entry->ongoing, token_len,
 1215|      5|                                 token, NULL, COAP_BOOL_FALSE);
 1216|      5|    if (!pdu) {
  ------------------
  |  Branch (1216:9): [True: 0, False: 5]
  ------------------
 1217|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1218|      0|      goto failed;
 1219|      0|    }
 1220|      5|    if (COAP_PROTO_NOT_RELIABLE(session->proto))
  ------------------
  |  |   41|      5|#define COAP_PROTO_NOT_RELIABLE(p) ((p)==COAP_PROTO_UDP || (p)==COAP_PROTO_DTLS)
  |  |  ------------------
  |  |  |  Branch (41:37): [True: 5, False: 0]
  |  |  |  Branch (41:60): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1221|      5|      pdu->max_size = coap_session_max_pdu_size_lkd(proxy_entry->ongoing);
 1222|      5|  }
 1223|       |
 1224|      9|  if (coap_get_data_large(request, &size, &data, &offset, &total)) {
  ------------------
  |  Branch (1224:7): [True: 1, False: 8]
  ------------------
 1225|       |    /* COAP_BLOCK_SINGLE_BODY is set, so single body should be given */
 1226|      1|    assert(size == total);
  ------------------
  |  Branch (1226:5): [True: 1, False: 0]
  ------------------
 1227|       |    /*
 1228|       |     * Need to take a copy of the data as request PDU may go away before
 1229|       |     * all data is transmitted.
 1230|       |     */
 1231|      1|    body_data = coap_new_binary(total);
 1232|      1|    if (!body_data) {
  ------------------
  |  Branch (1232:9): [True: 0, False: 1]
  ------------------
 1233|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1234|      0|      goto failed;
 1235|      0|    }
 1236|      1|    memcpy(body_data->s, data, size);
 1237|      1|    data = body_data->s;
 1238|      1|    if (!coap_add_data_large_request_lkd(proxy_entry->ongoing, pdu, total, data,
  ------------------
  |  Branch (1238:9): [True: 0, False: 1]
  ------------------
 1239|      1|                                         coap_proxy_release_body_data, body_data)) {
 1240|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1241|      0|      goto failed;
 1242|      0|    }
 1243|      1|  }
 1244|       |
 1245|      9|  coap_proxy_log_entry(proxy_req->incoming, proxy_req->pdu, proxy_req->token_used,  "fwd");
 1246|      9|  proxy_entry->mid = coap_send_lkd(proxy_entry->ongoing, pdu);
 1247|      9|  if (proxy_entry->mid == COAP_INVALID_MID) {
  ------------------
  |  |  187|      9|#define COAP_INVALID_MID -1
  ------------------
  |  Branch (1247:7): [True: 0, False: 9]
  ------------------
 1248|      0|    pdu = NULL;
 1249|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1250|      0|    goto failed;
 1251|      0|  }
 1252|      9|  if (request->type == COAP_MESSAGE_CON && COAP_PROTO_NOT_RELIABLE(proxy_entry->ongoing->proto)) {
  ------------------
  |  |   41|      8|#define COAP_PROTO_NOT_RELIABLE(p) ((p)==COAP_PROTO_UDP || (p)==COAP_PROTO_DTLS)
  |  |  ------------------
  |  |  |  Branch (41:37): [True: 8, False: 0]
  |  |  |  Branch (41:60): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (1252:7): [True: 8, False: 1]
  ------------------
 1253|      8|    proxy_entry->req_start_ticks = now;
 1254|      8|  }
 1255|       |
 1256|       |  /*
 1257|       |   * Do not update the response code (hence empty ACK) as will be sending
 1258|       |   * separate response when response comes back from upstream server
 1259|       |   */
 1260|       |
 1261|      9|  return 1;
 1262|       |
 1263|      4|failed:
 1264|      4|  response->code = COAP_RESPONSE_CODE(500);
  ------------------
  |  |   96|      4|#define COAP_RESPONSE_CODE(N) (((N)/100 << 5) | (N)%100)
  ------------------
 1265|      4|  coap_delete_optlist(optlist);
 1266|      4|  coap_delete_pdu_lkd(pdu);
 1267|      4|  return 0;
 1268|       |
 1269|      0|return_cached_info:
 1270|      0|  if (obs_opt && !proxy_req->doing_observe) {
  ------------------
  |  Branch (1270:7): [True: 0, False: 0]
  |  Branch (1270:18): [True: 0, False: 0]
  ------------------
 1271|      0|    int observe_action;
 1272|       |
 1273|      0|    observe_action = coap_decode_var_bytes(coap_opt_value(obs_opt),
 1274|      0|                                           coap_opt_length(obs_opt));
 1275|       |
 1276|      0|    if (observe_action == COAP_OBSERVE_ESTABLISH) {
  ------------------
  |  |   37|      0|#define COAP_OBSERVE_ESTABLISH 0
  ------------------
  |  Branch (1276:9): [True: 0, False: 0]
  ------------------
 1277|      0|      proxy_req->doing_observe = 1;
 1278|      0|      proxy_req->incoming->ref_proxy_subs++;
 1279|      0|    }
 1280|      0|  }
 1281|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1282|      0|                 coap_session_str(session),
 1283|      0|                 proxy_cache->ref);
 1284|      0|  coap_proxy_log_entry(session, request, &proxy_cache->rsp_pdu->actual_token,  "rspc");
 1285|      0|  if (now < proxy_cache->expire) {
  ------------------
  |  Branch (1285:7): [True: 0, False: 0]
  ------------------
 1286|      0|    new_maxage = (uint32_t)((proxy_cache->expire - now) / COAP_TICKS_PER_SECOND);
  ------------------
  |  |  164|      0|#define COAP_TICKS_PER_SECOND ((coap_tick_t)(1000U))
  ------------------
 1287|      0|    if (new_maxage == 0)
  ------------------
  |  Branch (1287:9): [True: 0, False: 0]
  ------------------
 1288|      0|      new_maxage = 1;
 1289|      0|  } else {
 1290|      0|    new_maxage = 1;
 1291|      0|  }
 1292|      0|  coap_update_option(proxy_cache->rsp_pdu,
 1293|      0|                     COAP_OPTION_MAXAGE,
 1294|      0|                     coap_encode_var_safe(buf, sizeof(buf), new_maxage), buf);
 1295|      0|  coap_proxy_call_response_handler(session, request, proxy_cache->rsp_pdu,
 1296|      0|                                   &r_token, proxy_req, 1, obs_opt ? 0 : 1);
  ------------------
  |  Branch (1296:60): [True: 0, False: 0]
  ------------------
 1297|      0|  if (!obs_opt)
  ------------------
  |  Branch (1297:7): [True: 0, False: 0]
  ------------------
 1298|      0|    coap_proxy_del_req(proxy_entry, proxy_req);
 1299|      0|  return 1;
 1300|      9|}
coap_proxy.c:coap_proxy_cleanup_entry:
  119|     13|coap_proxy_cleanup_entry(coap_proxy_entry_t *proxy_entry, coap_pdu_code_t failure_code) {
  120|     13|  coap_proxy_req_t *proxy_req, *treq;
  121|       |
  122|     13|  LL_FOREACH_SAFE(proxy_entry->proxy_req, proxy_req, treq) {
  ------------------
  |  |  425|     13|    LL_FOREACH_SAFE2(head,el,tmp,next)
  |  |  ------------------
  |  |  |  |  428|     26|  for ((el) = (head); (el) && ((tmp) = (el)->next, 1); (el) = (tmp))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (428:23): [True: 13, False: 13]
  |  |  |  |  |  Branch (428:31): [True: 13, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  123|     13|    if (failure_code) {
  ------------------
  |  Branch (123:9): [True: 0, False: 13]
  ------------------
  124|      0|      coap_pdu_t *response;
  125|      0|      coap_bin_const_t l_token;
  126|       |
  127|       |      /* Need to send back a gateway failure as per failure_code */
  128|      0|      response = coap_pdu_init(proxy_req->pdu->type,
  129|      0|                               failure_code,
  130|      0|                               coap_new_message_id_lkd(proxy_req->incoming),
  131|      0|                               coap_session_max_pdu_size_lkd(proxy_req->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_req->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 %u.%02u proxy 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|                      COAP_RESPONSE_CLASS(failure_code), failure_code & 0x1f);
  146|      0|      }
  147|      0|    }
  148|     13|cleanup:
  149|     13|    coap_proxy_del_req(proxy_entry, proxy_req);
  150|     13|  }
  151|     13|  coap_free_type(COAP_STRING, proxy_entry->uri_host_keep);
  152|     13|}
coap_proxy.c:coap_proxy_get_ongoing_session:
  614|     30|                               coap_proxy_server_list_t *server_list) {
  615|       |
  616|     30|  coap_address_t dst;
  617|     30|  coap_proto_t proto;
  618|     30|  coap_addr_info_t *info_list = NULL;
  619|     30|  coap_proxy_entry_t *proxy_entry;
  620|     30|  coap_context_t *context = session->context;
  621|     30|  static char client_sni[256];
  622|     30|  coap_proxy_server_t server_use;
  623|     30|  int proxy_entry_created;
  624|       |
  625|     30|  proxy_entry = coap_proxy_get_session(session, request, response, server_list,
  626|     30|                                       &server_use, &proxy_entry_created);
  627|     30|  if (!proxy_entry) {
  ------------------
  |  Branch (627:7): [True: 17, False: 13]
  ------------------
  628|       |    /* Error response code already set */
  629|     17|    return NULL;
  630|     17|  }
  631|       |
  632|     13|  if (!proxy_entry->ongoing) {
  ------------------
  |  Branch (632:7): [True: 13, False: 0]
  ------------------
  633|       |    /* Need to create a new session */
  634|     13|    coap_address_t *local_addr = NULL;
  635|       |
  636|       |    /* resolve destination address where data should be sent */
  637|     13|    info_list = coap_resolve_address_info_lkd(&server_use.uri.host,
  638|     13|                                              server_use.uri.port,
  639|     13|                                              server_use.uri.port,
  640|     13|                                              server_use.uri.port,
  641|     13|                                              server_use.uri.port,
  642|     13|                                              0,
  643|     13|                                              1 << server_use.uri.scheme,
  644|     13|                                              COAP_RESOLVE_TYPE_REMOTE);
  645|       |
  646|     13|    if (info_list == NULL) {
  ------------------
  |  Branch (646:9): [True: 0, False: 13]
  ------------------
  647|      0|      response->code = COAP_RESPONSE_CODE(502);
  ------------------
  |  |   96|      0|#define COAP_RESPONSE_CODE(N) (((N)/100 << 5) | (N)%100)
  ------------------
  648|      0|      coap_proxy_remove_association(session, 0);
  649|      0|      return NULL;
  650|      0|    }
  651|     13|    proto = info_list->proto;
  652|     13|    memcpy(&dst, &info_list->addr, sizeof(dst));
  653|     13|    coap_free_address_info(info_list);
  654|     13|    if (coap_is_mcast(&dst)) {
  ------------------
  |  Branch (654:9): [True: 0, False: 13]
  ------------------
  655|      0|      coap_proxy_t proxy_type = coap_proxy_map_type(server_list->type);
  656|       |
  657|      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 (657:11): [True: 0, False: 0]
  ------------------
  658|      0|          (proxy_type & COAP_PROXY_BIT_MCAST) == 0) {
  ------------------
  |  Branch (658:11): [True: 0, False: 0]
  ------------------
  659|      0|        response->code = COAP_RESPONSE_CODE(501);
  ------------------
  |  |   96|      0|#define COAP_RESPONSE_CODE(N) (((N)/100 << 5) | (N)%100)
  ------------------
  660|      0|        coap_proxy_remove_association(session, 0);
  661|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  662|      0|                       coap_session_str(session));
  663|      0|        return NULL;
  664|      0|      }
  665|      0|      if (server_use.uri.scheme != COAP_URI_SCHEME_COAP) {
  ------------------
  |  Branch (665:11): [True: 0, False: 0]
  ------------------
  666|      0|        response->code = COAP_RESPONSE_CODE(501);
  ------------------
  |  |   96|      0|#define COAP_RESPONSE_CODE(N) (((N)/100 << 5) | (N)%100)
  ------------------
  667|      0|        coap_proxy_remove_association(session, 0);
  668|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  669|      0|                       coap_session_str(session));
  670|      0|        return NULL;
  671|      0|      }
  672|      0|    }
  673|       |
  674|     13|#if COAP_AF_UNIX_SUPPORT
  675|     13|    coap_address_t bind_addr;
  676|     13|    if (coap_is_af_unix(&dst)) {
  ------------------
  |  Branch (676:9): [True: 0, False: 13]
  ------------------
  677|      0|      char buf[COAP_UNIX_PATH_MAX];
  678|      0|      coap_tick_t now;
  679|       |
  680|       |      /* Need a unique 'client' address */
  681|      0|      coap_ticks(&now);
  682|      0|      snprintf(buf, COAP_UNIX_PATH_MAX,
  ------------------
  |  |  186|      0|#define COAP_UNIX_PATH_MAX   (sizeof(struct sockaddr_in6) - sizeof(sa_family_t))
  ------------------
  683|      0|               "/tmp/coap-pr-cl-%" PRIu64, (uint64_t)now);
  684|      0|      if (!coap_address_set_unix_domain(&bind_addr, (const uint8_t *)buf,
  ------------------
  |  Branch (684:11): [True: 0, False: 0]
  ------------------
  685|      0|                                        strlen(buf))) {
  686|      0|        fprintf(stderr, "coap_address_set_unix_domain: %s: failed\n",
  687|      0|                buf);
  688|      0|        remove(buf);
  689|      0|        return NULL;
  690|      0|      }
  691|      0|      (void)remove(buf);
  692|      0|      local_addr = &bind_addr;
  693|      0|    }
  694|     13|#endif /* COAP_AF_UNIX_SUPPORT */
  695|       |
  696|     13|    snprintf(client_sni, sizeof(client_sni), "%*.*s", (int)server_use.uri.host.length,
  697|     13|             (int)server_use.uri.host.length, server_use.uri.host.s);
  698|       |
  699|     13|    switch (server_use.uri.scheme) {
  700|     13|    case COAP_URI_SCHEME_COAP:
  ------------------
  |  Branch (700:5): [True: 13, False: 0]
  ------------------
  701|     13|    case COAP_URI_SCHEME_COAP_TCP:
  ------------------
  |  Branch (701:5): [True: 0, False: 13]
  ------------------
  702|     13|    case COAP_URI_SCHEME_COAP_WS:
  ------------------
  |  Branch (702:5): [True: 0, False: 13]
  ------------------
  703|     13|#if COAP_OSCORE_SUPPORT
  704|     13|      if (server_use.oscore_conf) {
  ------------------
  |  Branch (704:11): [True: 0, False: 13]
  ------------------
  705|      0|        proxy_entry->ongoing =
  706|      0|            coap_new_client_session_oscore3_lkd(context, local_addr, &dst,
  707|      0|                                                proto, server_use.oscore_conf,
  708|      0|                                                NULL, NULL, NULL);
  709|     13|      } else {
  710|     13|#endif /* COAP_OSCORE_SUPPORT */
  711|     13|        proxy_entry->ongoing =
  712|     13|            coap_new_client_session3_lkd(context, local_addr, &dst, proto,
  713|     13|                                         NULL, NULL, NULL);
  714|     13|#if COAP_OSCORE_SUPPORT
  715|     13|      }
  716|     13|#endif /* COAP_OSCORE_SUPPORT */
  717|     13|      break;
  718|      0|    case COAP_URI_SCHEME_COAPS:
  ------------------
  |  Branch (718:5): [True: 0, False: 13]
  ------------------
  719|      0|    case COAP_URI_SCHEME_COAPS_TCP:
  ------------------
  |  Branch (719:5): [True: 0, False: 13]
  ------------------
  720|      0|    case COAP_URI_SCHEME_COAPS_WS:
  ------------------
  |  Branch (720:5): [True: 0, False: 13]
  ------------------
  721|      0|#if COAP_OSCORE_SUPPORT
  722|      0|      if (server_use.oscore_conf) {
  ------------------
  |  Branch (722:11): [True: 0, False: 0]
  ------------------
  723|      0|        if (server_use.dtls_pki) {
  ------------------
  |  Branch (723:13): [True: 0, False: 0]
  ------------------
  724|      0|          server_use.dtls_pki->client_sni = client_sni;
  725|      0|          proxy_entry->ongoing =
  726|      0|              coap_new_client_session_oscore_pki3_lkd(context, local_addr, &dst,
  727|      0|                                                      proto, server_use.dtls_pki,
  728|      0|                                                      server_use.oscore_conf,
  729|      0|                                                      NULL, NULL, NULL);
  730|      0|        } else if (server_use.dtls_cpsk) {
  ------------------
  |  Branch (730:20): [True: 0, False: 0]
  ------------------
  731|      0|          server_use.dtls_cpsk->client_sni = client_sni;
  732|      0|          proxy_entry->ongoing =
  733|      0|              coap_new_client_session_oscore_psk3_lkd(context, local_addr, &dst,
  734|      0|                                                      proto, server_use.dtls_cpsk,
  735|      0|                                                      server_use.oscore_conf,
  736|      0|                                                      NULL, NULL, NULL);
  737|      0|        } else {
  738|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  739|      0|        }
  740|      0|      } else {
  741|      0|#endif /* COAP_OSCORE_SUPPORT */
  742|       |        /* Not doing OSCORE */
  743|      0|        if (server_use.dtls_pki) {
  ------------------
  |  Branch (743:13): [True: 0, False: 0]
  ------------------
  744|      0|          server_use.dtls_pki->client_sni = client_sni;
  745|      0|          proxy_entry->ongoing =
  746|      0|              coap_new_client_session_pki3_lkd(context, local_addr, &dst,
  747|      0|                                               proto, server_use.dtls_pki,
  748|      0|                                               NULL, NULL, NULL);
  749|      0|        } else if (server_use.dtls_cpsk) {
  ------------------
  |  Branch (749:20): [True: 0, False: 0]
  ------------------
  750|      0|          server_use.dtls_cpsk->client_sni = client_sni;
  751|      0|          proxy_entry->ongoing =
  752|      0|              coap_new_client_session_psk3_lkd(context, local_addr, &dst,
  753|      0|                                               proto, server_use.dtls_cpsk,
  754|      0|                                               NULL, NULL, NULL);
  755|      0|        } else {
  756|       |          /* Using client anonymous PKI */
  757|      0|          proxy_entry->ongoing =
  758|      0|              coap_new_client_session3_lkd(context, local_addr, &dst, proto,
  759|      0|                                           NULL, NULL, NULL);
  760|      0|        }
  761|      0|#if COAP_OSCORE_SUPPORT
  762|      0|      }
  763|      0|#endif /* COAP_OSCORE_SUPPORT */
  764|      0|      break;
  765|      0|    case COAP_URI_SCHEME_HTTP:
  ------------------
  |  Branch (765:5): [True: 0, False: 13]
  ------------------
  766|      0|    case COAP_URI_SCHEME_HTTPS:
  ------------------
  |  Branch (766:5): [True: 0, False: 13]
  ------------------
  767|      0|    case COAP_URI_SCHEME_LAST:
  ------------------
  |  Branch (767:5): [True: 0, False: 13]
  ------------------
  768|      0|    default:
  ------------------
  |  Branch (768:5): [True: 0, False: 13]
  ------------------
  769|      0|      assert(0);
  ------------------
  |  Branch (769:7): [Folded, False: 0]
  ------------------
  770|      0|      break;
  771|     13|    }
  772|     13|    if (proxy_entry->ongoing == NULL) {
  ------------------
  |  Branch (772:9): [True: 0, False: 13]
  ------------------
  773|      0|      response->code = COAP_RESPONSE_CODE(505);
  ------------------
  |  |   96|      0|#define COAP_RESPONSE_CODE(N) (((N)/100 << 5) | (N)%100)
  ------------------
  774|      0|      coap_proxy_remove_association(session, 0);
  775|      0|      return NULL;
  776|      0|    }
  777|     13|    if (proxy_entry_created) {
  ------------------
  |  Branch (777:9): [True: 13, False: 0]
  ------------------
  778|     13|      coap_log_debug("*  %s: proxy_entry %.*s:%d %p created (tot count = % " PRIdS ")\n",
  ------------------
  |  |  126|     13|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|     13|#define coap_log(level, ...) do { \
  |  |  |  |  291|     13|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 13]
  |  |  |  |  ------------------
  |  |  |  |  292|     13|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|     13|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 13]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  779|     13|                     coap_session_str(proxy_entry->ongoing),
  780|     13|                     (int)proxy_entry->uri.host.length, proxy_entry->uri.host.s,
  781|     13|                     proxy_entry->uri.port,
  782|     13|                     (void *)proxy_entry,
  783|     13|                     session->context->proxy_list_count);
  784|     13|    }
  785|     13|  } else if (proxy_entry->ongoing->session_failed) {
  ------------------
  |  Branch (785:14): [True: 0, False: 0]
  ------------------
  786|      0|    if (!coap_session_reconnect(proxy_entry->ongoing)) {
  ------------------
  |  Branch (786:9): [True: 0, False: 0]
  ------------------
  787|       |      /* Server is not yet back up */
  788|      0|      return NULL;
  789|      0|    }
  790|      0|  }
  791|       |
  792|     13|  return proxy_entry;
  793|     13|}
coap_proxy.c:coap_proxy_get_session:
  456|     30|                       coap_proxy_server_t *server_use, int *proxy_entry_created) {
  457|     30|  size_t i;
  458|     30|  coap_proxy_entry_t *proxy_entry;
  459|     30|  coap_proxy_entry_t *proxy_list = session->context->proxy_list;
  460|     30|  size_t proxy_list_count = session->context->proxy_list_count;
  461|     30|  coap_opt_iterator_t opt_iter;
  462|     30|  coap_opt_t *proxy_scheme;
  463|     30|  coap_opt_t *proxy_uri;
  464|     30|  coap_proxy_t proxy_type;
  465|       |
  466|     30|  *proxy_entry_created = 0;
  467|       |
  468|       |  /*
  469|       |   * Maintain server stickability. server_use not needed as there is
  470|       |   * ongoing session in place.
  471|       |   */
  472|     30|  if (session->proxy_entry) {
  ------------------
  |  Branch (472:7): [True: 0, False: 30]
  ------------------
  473|      0|    for (i = 0; i < proxy_list_count; i++) {
  ------------------
  |  Branch (473:17): [True: 0, False: 0]
  ------------------
  474|      0|      if (&proxy_list[i] == session->proxy_entry) {
  ------------------
  |  Branch (474:11): [True: 0, False: 0]
  ------------------
  475|      0|        if (session->proxy_entry->ongoing) {
  ------------------
  |  Branch (475:13): [True: 0, False: 0]
  ------------------
  476|      0|          memset(server_use, 0, sizeof(*server_use));
  477|      0|          return session->proxy_entry;
  478|      0|        }
  479|      0|      }
  480|      0|    }
  481|      0|  }
  482|       |
  483|       |  /* Round robin the defined next server list (which usually is just one */
  484|     30|  server_list->next_entry++;
  485|     30|  if (server_list->next_entry >= server_list->entry_count)
  ------------------
  |  Branch (485:7): [True: 30, False: 0]
  ------------------
  486|     30|    server_list->next_entry = 0;
  487|       |
  488|     30|  if (server_list->entry_count) {
  ------------------
  |  Branch (488:7): [True: 13, False: 17]
  ------------------
  489|     13|    memcpy(server_use, &server_list->entry[server_list->next_entry], sizeof(*server_use));
  490|     17|  } else {
  491|     17|    memset(server_use, 0, sizeof(*server_use));
  492|     17|  }
  493|       |
  494|     30|  proxy_type = coap_proxy_map_type(server_list->type);
  495|       |
  496|     30|  if ((proxy_type & COAP_PROXY_NEW_MASK) == COAP_PROXY_FWD_DYNAMIC) {
  ------------------
  |  |   92|     30|#define COAP_PROXY_NEW_MASK 0x38 /**< Space used in coap_proxy_t for new types */
  ------------------
  |  Branch (496:7): [True: 17, False: 13]
  ------------------
  497|       |    /* Need to get actual server from CoAP Proxy-Uri or Proxy-Scheme options */
  498|       |    /*
  499|       |     * See if Proxy-Scheme
  500|       |     */
  501|     17|    proxy_scheme = coap_check_option(request, COAP_OPTION_PROXY_SCHEME, &opt_iter);
  502|     17|    if (proxy_scheme) {
  ------------------
  |  Branch (502:9): [True: 8, False: 9]
  ------------------
  503|      8|      if (!coap_get_uri_proxy_scheme_info(request, proxy_scheme, &server_use->uri)) {
  ------------------
  |  Branch (503:11): [True: 8, False: 0]
  ------------------
  504|      8|        response->code = COAP_RESPONSE_CODE(505);
  ------------------
  |  |   96|      8|#define COAP_RESPONSE_CODE(N) (((N)/100 << 5) | (N)%100)
  ------------------
  505|      8|        return NULL;
  506|      8|      }
  507|      8|    }
  508|       |    /*
  509|       |     * See if Proxy-Uri
  510|       |     */
  511|      9|    proxy_uri = coap_check_option(request, COAP_OPTION_PROXY_URI, &opt_iter);
  512|      9|    if (proxy_uri) {
  ------------------
  |  Branch (512:9): [True: 0, False: 9]
  ------------------
  513|      0|      coap_log_info("Proxy URI '%.*s'\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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  514|      0|                    (int)coap_opt_length(proxy_uri),
  515|      0|                    (const char *)coap_opt_value(proxy_uri));
  516|      0|      if (coap_split_proxy_uri(coap_opt_value(proxy_uri),
  ------------------
  |  Branch (516:11): [True: 0, False: 0]
  ------------------
  517|      0|                               coap_opt_length(proxy_uri),
  518|      0|                               &server_use->uri) < 0) {
  519|       |        /* Need to return a 5.05 RFC7252 Section 5.7.2 */
  520|      0|        coap_log_warn("Proxy URI not decodable\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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  521|      0|        response->code = COAP_RESPONSE_CODE(505);
  ------------------
  |  |   96|      0|#define COAP_RESPONSE_CODE(N) (((N)/100 << 5) | (N)%100)
  ------------------
  522|      0|        return NULL;
  523|      0|      }
  524|      0|    }
  525|       |
  526|      9|    if (!(proxy_scheme || proxy_uri)) {
  ------------------
  |  Branch (526:11): [True: 0, False: 9]
  |  Branch (526:27): [True: 0, False: 9]
  ------------------
  527|      9|      response->code = COAP_RESPONSE_CODE(404);
  ------------------
  |  |   96|      9|#define COAP_RESPONSE_CODE(N) (((N)/100 << 5) | (N)%100)
  ------------------
  528|      9|      return NULL;
  529|      9|    }
  530|      9|  }
  531|       |
  532|     13|  if (server_use->uri.host.length == 0) {
  ------------------
  |  Branch (532:7): [True: 0, False: 13]
  ------------------
  533|       |    /* Ongoing connection not well formed */
  534|      0|    response->code = COAP_RESPONSE_CODE(505);
  ------------------
  |  |   96|      0|#define COAP_RESPONSE_CODE(N) (((N)/100 << 5) | (N)%100)
  ------------------
  535|      0|    return NULL;
  536|      0|  }
  537|       |
  538|     13|  if (!coap_verify_proxy_scheme_supported(server_use->uri.scheme)) {
  ------------------
  |  Branch (538:7): [True: 0, False: 13]
  ------------------
  539|      0|    response->code = COAP_RESPONSE_CODE(505);
  ------------------
  |  |   96|      0|#define COAP_RESPONSE_CODE(N) (((N)/100 << 5) | (N)%100)
  ------------------
  540|      0|    return NULL;
  541|      0|  }
  542|       |
  543|       |  /* Check if need to create a new forwarding mapping */
  544|     13|  proxy_entry = coap_proxy_get_add_list_entry(session, NULL, server_use->uri, server_list, 0);
  545|       |
  546|     13|  if (proxy_entry == NULL) {
  ------------------
  |  Branch (546:7): [True: 0, False: 13]
  ------------------
  547|      0|    response->code = COAP_RESPONSE_CODE(500);
  ------------------
  |  |   96|      0|#define COAP_RESPONSE_CODE(N) (((N)/100 << 5) | (N)%100)
  ------------------
  548|      0|    return NULL;
  549|      0|  }
  550|       |
  551|     13|  *proxy_entry_created = 1;
  552|     13|  return proxy_entry;
  553|     13|}
coap_proxy.c:coap_get_uri_proxy_scheme_info:
  243|      8|                               coap_uri_t *uri) {
  244|      8|  const char *opt_val = (const char *)coap_opt_value(opt);
  245|      8|  int opt_len = coap_opt_length(opt);
  246|      8|  coap_opt_iterator_t opt_iter;
  247|       |
  248|      8|  if (opt_len == 9 &&
  ------------------
  |  Branch (248:7): [True: 8, False: 0]
  ------------------
  249|      8|      strncasecmp(opt_val, "coaps+tcp", 9) == 0) {
  ------------------
  |  Branch (249:7): [True: 0, False: 8]
  ------------------
  250|      0|    uri->scheme = COAP_URI_SCHEME_COAPS_TCP;
  251|      0|    uri->port = COAPS_DEFAULT_PORT;
  ------------------
  |  |   40|      0|#define COAPS_DEFAULT_PORT     5684 /* CoAP default UDP/TCP port for secure transmission */
  ------------------
  252|      8|  } else if (opt_len == 8 &&
  ------------------
  |  Branch (252:14): [True: 0, False: 8]
  ------------------
  253|      0|             strncasecmp(opt_val, "coap+tcp", 8) == 0) {
  ------------------
  |  Branch (253:14): [True: 0, False: 0]
  ------------------
  254|      0|    uri->scheme = COAP_URI_SCHEME_COAP_TCP;
  255|      0|    uri->port = COAP_DEFAULT_PORT;
  ------------------
  |  |   39|      0|#define COAP_DEFAULT_PORT      5683 /* CoAP default UDP/TCP port */
  ------------------
  256|      8|  } else if (opt_len == 5 &&
  ------------------
  |  Branch (256:14): [True: 0, False: 8]
  ------------------
  257|      0|             strncasecmp(opt_val, "coaps", 5) == 0) {
  ------------------
  |  Branch (257:14): [True: 0, False: 0]
  ------------------
  258|      0|    uri->scheme = COAP_URI_SCHEME_COAPS;
  259|      0|    uri->port = COAPS_DEFAULT_PORT;
  ------------------
  |  |   40|      0|#define COAPS_DEFAULT_PORT     5684 /* CoAP default UDP/TCP port for secure transmission */
  ------------------
  260|      8|  } else if (opt_len == 4 &&
  ------------------
  |  Branch (260:14): [True: 0, False: 8]
  ------------------
  261|      0|             strncasecmp(opt_val, "coap", 4) == 0) {
  ------------------
  |  Branch (261:14): [True: 0, False: 0]
  ------------------
  262|      0|    uri->scheme = COAP_URI_SCHEME_COAP;
  263|      0|    uri->port = COAP_DEFAULT_PORT;
  ------------------
  |  |   39|      0|#define COAP_DEFAULT_PORT      5683 /* CoAP default UDP/TCP port */
  ------------------
  264|      8|  } else if (opt_len == 7 &&
  ------------------
  |  Branch (264:14): [True: 0, False: 8]
  ------------------
  265|      0|             strncasecmp(opt_val, "coap+ws", 7) == 0) {
  ------------------
  |  Branch (265:14): [True: 0, False: 0]
  ------------------
  266|      0|    uri->scheme = COAP_URI_SCHEME_COAP_WS;
  267|      0|    uri->port = 80;
  268|      8|  } else if (opt_len == 8 &&
  ------------------
  |  Branch (268:14): [True: 0, False: 8]
  ------------------
  269|      0|             strncasecmp(opt_val, "coaps+ws", 8) == 0) {
  ------------------
  |  Branch (269:14): [True: 0, False: 0]
  ------------------
  270|      0|    uri->scheme = COAP_URI_SCHEME_COAPS_WS;
  271|      0|    uri->port = 443;
  272|      8|  } else {
  273|      8|    coap_log_warn("Unsupported Proxy Scheme '%*.*s'\n",
  ------------------
  |  |  108|      8|#define coap_log_warn(...) coap_log(COAP_LOG_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      8|#define coap_log(level, ...) do { \
  |  |  |  |  291|      8|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 8]
  |  |  |  |  ------------------
  |  |  |  |  292|      8|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      8|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 8]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  274|      8|                  opt_len, opt_len, opt_val);
  275|      8|    return 0;
  276|      8|  }
  277|       |
  278|      0|  opt = coap_check_option(request, COAP_OPTION_URI_HOST, &opt_iter);
  279|      0|  if (opt) {
  ------------------
  |  Branch (279:7): [True: 0, False: 0]
  ------------------
  280|      0|    uri->host.length = coap_opt_length(opt);
  281|      0|    uri->host.s = coap_opt_value(opt);
  282|      0|  } else {
  283|      0|    uri->host.s = NULL;
  284|      0|    uri->host.length = 0;
  285|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  286|      0|    return 0;
  287|      0|  }
  288|      0|  opt = coap_check_option(request, COAP_OPTION_URI_PORT, &opt_iter);
  289|      0|  if (opt) {
  ------------------
  |  Branch (289:7): [True: 0, False: 0]
  ------------------
  290|      0|    uri->port =
  291|      0|        coap_decode_var_bytes(coap_opt_value(opt),
  292|      0|                              coap_opt_length(opt));
  293|      0|  }
  294|      0|  return 1;
  295|      0|}
coap_proxy.c:coap_proxy_map_type:
  347|     43|coap_proxy_map_type(coap_proxy_t proxy_type) {
  348|     43|  if ((proxy_type & COAP_PROXY_NEW_MASK) == 0) {
  ------------------
  |  |   92|     43|#define COAP_PROXY_NEW_MASK 0x38 /**< Space used in coap_proxy_t for new types */
  ------------------
  |  Branch (348:7): [True: 0, False: 43]
  ------------------
  349|       |    /* Old version - update to bitwise version */
  350|      0|    switch ((int)proxy_type) {
  351|      0|    case COAP_PROXY_REVERSE:
  ------------------
  |  Branch (351:5): [True: 0, False: 0]
  ------------------
  352|      0|      proxy_type = COAP_PROXY_REV;
  353|      0|      break;
  354|      0|    case COAP_PROXY_REVERSE_STRIP:
  ------------------
  |  Branch (354:5): [True: 0, False: 0]
  ------------------
  355|      0|      proxy_type = COAP_PROXY_REV | COAP_PROXY_BIT_STRIP;
  356|      0|      break;
  357|      0|    case COAP_PROXY_FORWARD:
  ------------------
  |  Branch (357:5): [True: 0, False: 0]
  ------------------
  358|      0|      proxy_type = COAP_PROXY_FWD_STATIC;
  359|      0|      break;
  360|      0|    case COAP_PROXY_FORWARD_STRIP:
  ------------------
  |  Branch (360:5): [True: 0, False: 0]
  ------------------
  361|      0|      proxy_type = COAP_PROXY_FWD_STATIC | COAP_PROXY_BIT_STRIP;
  362|      0|      break;
  363|      0|    case COAP_PROXY_DIRECT:
  ------------------
  |  Branch (363:5): [True: 0, False: 0]
  ------------------
  364|       |      /* Mcast was always let through */
  365|      0|      proxy_type = COAP_PROXY_FWD_DYNAMIC | COAP_PROXY_BIT_MCAST;
  366|      0|      break;
  367|      0|    case COAP_PROXY_DIRECT_STRIP:
  ------------------
  |  Branch (367:5): [True: 0, False: 0]
  ------------------
  368|       |      /* Mcast was always let through */
  369|      0|      proxy_type = COAP_PROXY_FWD_DYNAMIC | COAP_PROXY_BIT_MCAST | COAP_PROXY_BIT_STRIP;
  370|      0|      break;
  371|      0|    default:
  ------------------
  |  Branch (371:5): [True: 0, False: 0]
  ------------------
  372|      0|      coap_log_warn("Proxy old proxy_type 0x%u unknown\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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  373|      0|      proxy_type = COAP_PROXY_FWD_DYNAMIC;
  374|      0|      break;
  375|      0|    }
  376|      0|  }
  377|     43|  return proxy_type;
  378|     43|}
coap_proxy.c:coap_proxy_release_body_data:
  797|      1|                             void *app_ptr) {
  798|      1|  coap_delete_binary(app_ptr);
  799|      1|}
coap_proxy.c:coap_proxy_get_add_list_entry:
  383|     13|                              int allow_add) {
  384|     13|  if (!incoming && !ongoing)
  ------------------
  |  Branch (384:7): [True: 0, False: 13]
  |  Branch (384:20): [True: 0, False: 0]
  ------------------
  385|      0|    return NULL;
  386|     13|  coap_context_t *context = incoming ? incoming->context : ongoing->context;
  ------------------
  |  Branch (386:29): [True: 13, False: 0]
  ------------------
  387|     13|  coap_proxy_entry_t *proxy_list = context->proxy_list;
  388|     13|  size_t proxy_list_count = context->proxy_list_count;
  389|     13|  coap_proxy_entry_t *new_proxy_list;
  390|     13|  size_t i;
  391|       |
  392|       |  /* See if we are already connected to the Server */
  393|     13|  for (i = 0; i < proxy_list_count; i++) {
  ------------------
  |  Branch (393:15): [True: 0, False: 13]
  ------------------
  394|      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]
  |  |  ------------------
  ------------------
  395|      0|        proxy_list[i].uri.port == uri.port &&
  ------------------
  |  Branch (395:9): [True: 0, False: 0]
  ------------------
  396|      0|        proxy_list[i].uri.scheme == uri.scheme) {
  ------------------
  |  Branch (396:9): [True: 0, False: 0]
  ------------------
  397|      0|      if (!proxy_list[i].track_client_session && context->proxy_response_cb) {
  ------------------
  |  Branch (397:11): [True: 0, False: 0]
  |  Branch (397:50): [True: 0, False: 0]
  ------------------
  398|      0|        coap_ticks(&proxy_list[i].last_used);
  399|      0|        return &proxy_list[i];
  400|      0|      } else {
  401|      0|        if (proxy_list[i].incoming == incoming) {
  ------------------
  |  Branch (401:13): [True: 0, False: 0]
  ------------------
  402|      0|          coap_ticks(&proxy_list[i].last_used);
  403|      0|          return &proxy_list[i];
  404|      0|        }
  405|      0|      }
  406|      0|    }
  407|      0|  }
  408|     13|  if ((server_list->type & COAP_PROXY_DYN_DEFINED) && !allow_add)
  ------------------
  |  Branch (408:7): [True: 0, False: 13]
  |  Branch (408:55): [True: 0, False: 0]
  ------------------
  409|      0|    return NULL;
  410|       |
  411|       |  /* Need to create a new forwarding mapping */
  412|     13|  new_proxy_list = coap_realloc_type(COAP_STRING, proxy_list,
  413|     13|                                     (proxy_list_count+1)*sizeof(proxy_list[0]));
  414|       |
  415|     13|  if (new_proxy_list == NULL) {
  ------------------
  |  Branch (415:7): [True: 0, False: 13]
  ------------------
  416|      0|    return NULL;
  417|      0|  }
  418|     13|  context->proxy_list = proxy_list = new_proxy_list;
  419|     13|  memset(&proxy_list[proxy_list_count], 0, sizeof(proxy_list[proxy_list_count]));
  420|       |
  421|       |  /* Keep a copy of the host as server_use->uri pointed to will be going away */
  422|     13|  proxy_list[proxy_list_count].uri = uri;
  423|     13|  proxy_list[proxy_list_count].uri_host_keep = coap_malloc_type(COAP_STRING,
  424|     13|                                               uri.host.length);
  425|     13|  if (!proxy_list[proxy_list_count].uri_host_keep) {
  ------------------
  |  Branch (425:7): [True: 0, False: 13]
  ------------------
  426|      0|    return NULL;
  427|      0|  }
  428|     13|  memcpy(proxy_list[proxy_list_count].uri_host_keep, uri.host.s, uri.host.length);
  429|     13|  proxy_list[proxy_list_count].uri.host.s = proxy_list[proxy_list_count].uri_host_keep;
  430|       |  /* Unset uri parts which point to going away information */
  431|     13|  proxy_list[proxy_list_count].uri.path.s = NULL;
  432|     13|  proxy_list[proxy_list_count].uri.path.length = 0;
  433|     13|  proxy_list[proxy_list_count].uri.query.s = NULL;
  434|     13|  proxy_list[proxy_list_count].uri.query.length = 0;
  435|       |
  436|     13|  proxy_list[proxy_list_count].ongoing = ongoing;
  437|     13|  proxy_list[proxy_list_count].idle_timeout_ticks = server_list->idle_timeout_secs *
  438|     13|                                                    COAP_TICKS_PER_SECOND;
  ------------------
  |  |  164|     13|#define COAP_TICKS_PER_SECOND ((coap_tick_t)(1000U))
  ------------------
  439|     13|  proxy_list[proxy_list_count].track_client_session = server_list->track_client_session;
  440|     13|  coap_ticks(&proxy_list[proxy_list_count].last_used);
  441|     13|  if (incoming) {
  ------------------
  |  Branch (441:7): [True: 13, False: 0]
  ------------------
  442|     13|    incoming->proxy_entry = &proxy_list[proxy_list_count];
  443|     13|    if (server_list->track_client_session)
  ------------------
  |  Branch (443:9): [True: 0, False: 13]
  ------------------
  444|      0|      proxy_list[proxy_list_count].incoming = incoming;
  445|     13|    incoming->proxy_entry = &proxy_list[proxy_list_count];
  446|     13|  }
  447|       |
  448|     13|  context->proxy_list_count++;
  449|     13|  return &proxy_list[proxy_list_count];
  450|     13|}

coap_resource_proxy_uri_init2:
  381|     30|                              const char *host_name_list[], int flags) {
  382|     30|  coap_resource_t *r;
  383|       |
  384|     30|  r = (coap_resource_t *)coap_malloc_type(COAP_RESOURCE, sizeof(coap_resource_t));
  385|     30|  if (r) {
  ------------------
  |  Branch (385:7): [True: 30, False: 0]
  ------------------
  386|     30|    size_t i;
  387|     30|    memset(r, 0, sizeof(coap_resource_t));
  388|       |#if COAP_THREAD_SAFE
  389|       |    coap_lock_init(&r->lock);
  390|       |#endif /* COAP_THREAD_SAFE */
  391|     30|    r->is_proxy_uri = 1;
  392|       |    /* Something unlikely to be used, but it shows up in the logs */
  393|     30|    r->uri_path = coap_new_str_const(coap_proxy_resource_uri, sizeof(coap_proxy_resource_uri)-1);
  394|       |    /* Preset all the handlers */
  395|    240|    for (i = 0; i < (sizeof(r->handler) / sizeof(r->handler[0])); i++) {
  ------------------
  |  Branch (395:17): [True: 210, False: 30]
  ------------------
  396|    210|      r->handler[i] = handler;
  397|    210|    }
  398|     30|    if (host_name_count) {
  ------------------
  |  Branch (398:9): [True: 0, False: 30]
  ------------------
  399|      0|      r->proxy_name_list = coap_malloc_type(COAP_STRING, host_name_count *
  400|      0|                                            sizeof(coap_str_const_t *));
  401|      0|      if (r->proxy_name_list) {
  ------------------
  |  Branch (401:11): [True: 0, False: 0]
  ------------------
  402|      0|        for (i = 0; i < host_name_count; i++) {
  ------------------
  |  Branch (402:21): [True: 0, False: 0]
  ------------------
  403|      0|          r->proxy_name_list[i] =
  404|      0|              coap_new_str_const((const uint8_t *)host_name_list[i],
  405|      0|                                 strlen(host_name_list[i]));
  406|      0|          if (!r->proxy_name_list[i]) {
  ------------------
  |  Branch (406:15): [True: 0, False: 0]
  ------------------
  407|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  408|      0|            if (i == 0) {
  ------------------
  |  Branch (408:17): [True: 0, False: 0]
  ------------------
  409|      0|              coap_free_type(COAP_STRING, r->proxy_name_list);
  410|      0|              r->proxy_name_list = NULL;
  411|      0|            }
  412|      0|            break;
  413|      0|          }
  414|      0|        }
  415|      0|        r->proxy_name_count = i;
  416|      0|      }
  417|      0|    }
  418|     30|    r->flags = flags & ~COAP_RESOURCE_FLAGS_RELEASE_URI;
  ------------------
  |  |   55|     30|#define COAP_RESOURCE_FLAGS_RELEASE_URI 0x1
  ------------------
  419|     30|  } else {
  420|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  421|      0|  }
  422|       |
  423|     30|  return r;
  424|     30|}
coap_add_resource:
  590|     30|coap_add_resource(coap_context_t *context, coap_resource_t *resource) {
  591|     30|  coap_lock_lock(return);
  592|     30|  coap_add_resource_lkd(context, resource);
  593|     30|  coap_lock_unlock();
  594|     30|}
coap_add_resource_lkd:
  597|     30|coap_add_resource_lkd(coap_context_t *context, coap_resource_t *resource) {
  598|     30|  coap_lock_check_locked();
  ------------------
  |  |  638|     30|#define coap_lock_check_locked() {}
  ------------------
  599|     30|  if (resource->is_unknown) {
  ------------------
  |  Branch (599:7): [True: 0, False: 30]
  ------------------
  600|      0|    if (context->unknown_resource)
  ------------------
  |  Branch (600:9): [True: 0, False: 0]
  ------------------
  601|      0|      coap_free_resource(context->unknown_resource, COAP_DELETING_RESOURCE);
  602|      0|    context->unknown_resource = resource;
  603|     30|  } else if (resource->is_proxy_uri) {
  ------------------
  |  Branch (603:14): [True: 30, False: 0]
  ------------------
  604|     30|    if (context->proxy_uri_resource)
  ------------------
  |  Branch (604:9): [True: 0, False: 30]
  ------------------
  605|      0|      coap_free_resource(context->proxy_uri_resource, COAP_DELETING_RESOURCE);
  606|     30|    context->proxy_uri_resource = resource;
  607|     30|  } else {
  608|      0|    coap_resource_t *r = coap_get_resource_from_uri_path_lkd(context,
  609|      0|                                                             resource->uri_path);
  610|       |
  611|      0|    if (r) {
  ------------------
  |  Branch (611:9): [True: 0, False: 0]
  ------------------
  612|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  613|      0|                    (int)resource->uri_path->length, (int)resource->uri_path->length,
  614|      0|                    resource->uri_path->s);
  615|      0|      coap_delete_resource_lkd(r);
  616|      0|    }
  617|      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]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  618|      0|#if COAP_WITH_OBSERVE_PERSIST
  619|      0|    if (context->unknown_pdu && context->dyn_resource_save_file &&
  ------------------
  |  Branch (619:9): [True: 0, False: 0]
  |  Branch (619:33): [True: 0, False: 0]
  ------------------
  620|      0|        context->dyn_resource_added_cb && resource->observable) {
  ------------------
  |  Branch (620:9): [True: 0, False: 0]
  |  Branch (620:43): [True: 0, False: 0]
  ------------------
  621|      0|      coap_bin_const_t raw_packet;
  622|       |
  623|      0|      raw_packet.s = context->unknown_pdu->token -
  624|      0|                     context->unknown_pdu->hdr_size;
  625|      0|      raw_packet.length = context->unknown_pdu->used_size +
  626|      0|                          context->unknown_pdu->hdr_size;
  627|      0|      coap_lock_callback(context->dyn_resource_added_cb(context->unknown_session,
  ------------------
  |  |  651|      0|#define coap_lock_callback(func) func
  ------------------
  628|      0|                                                        resource->uri_path,
  629|      0|                                                        &raw_packet,
  630|      0|                                                        context->observe_user_data));
  631|      0|    }
  632|      0|#endif /* COAP_WITH_OBSERVE_PERSIST */
  633|      0|  }
  634|     30|  assert(resource->context == NULL);
  ------------------
  |  Branch (634:3): [True: 30, False: 0]
  ------------------
  635|     30|  resource->context = context;
  636|     30|}
coap_delete_resource_lkd:
  656|     30|coap_delete_resource_lkd(coap_resource_t *resource) {
  657|     30|  coap_context_t *context;
  658|     30|  coap_deleting_resource_t deleting;
  659|       |
  660|     30|  if (!resource)
  ------------------
  |  Branch (660:7): [True: 0, False: 30]
  ------------------
  661|      0|    return 0;
  662|       |
  663|     30|  context = resource->context;
  664|     30|  coap_lock_check_locked();
  ------------------
  |  |  638|     30|#define coap_lock_check_locked() {}
  ------------------
  665|       |
  666|     30|  if (resource->ref) {
  ------------------
  |  Branch (666:7): [True: 0, False: 30]
  ------------------
  667|      0|    resource->ref--;
  668|      0|    return 1;
  669|      0|  }
  670|     30|  if (context && context->context_going_away) {
  ------------------
  |  Branch (670:7): [True: 30, False: 0]
  |  Branch (670:18): [True: 30, False: 0]
  ------------------
  671|     30|    deleting = COAP_DELETING_RESOURCE_ON_EXIT;
  672|     30|  } else {
  673|      0|    deleting = COAP_DELETING_RESOURCE;
  674|      0|  }
  675|     30|  if (resource->is_unknown) {
  ------------------
  |  Branch (675:7): [True: 0, False: 30]
  ------------------
  676|      0|    if (context && context->unknown_resource == resource) {
  ------------------
  |  Branch (676:9): [True: 0, False: 0]
  |  Branch (676:20): [True: 0, False: 0]
  ------------------
  677|      0|      context->unknown_resource = NULL;
  678|      0|    }
  679|     30|  } else if (resource->is_proxy_uri) {
  ------------------
  |  Branch (679:14): [True: 30, False: 0]
  ------------------
  680|     30|    if (context && context->proxy_uri_resource == resource) {
  ------------------
  |  Branch (680:9): [True: 30, False: 0]
  |  Branch (680:20): [True: 30, False: 0]
  ------------------
  681|     30|      context->proxy_uri_resource = NULL;
  682|     30|    }
  683|     30|  } else if (context) {
  ------------------
  |  Branch (683:14): [True: 0, False: 0]
  ------------------
  684|       |    /* remove resource from list */
  685|      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]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  686|      0|  }
  687|     30|  if (resource->is_dynamic) {
  ------------------
  |  Branch (687:7): [True: 0, False: 30]
  ------------------
  688|      0|    if (context) {
  ------------------
  |  Branch (688:9): [True: 0, False: 0]
  ------------------
  689|      0|      assert(context->dynamic_cur);
  ------------------
  |  Branch (689:7): [True: 0, False: 0]
  ------------------
  690|      0|      context->dynamic_cur--;
  691|      0|    }
  692|      0|  }
  693|       |
  694|       |  /* and free its allocated memory */
  695|     30|  coap_free_resource(resource, deleting);
  696|       |
  697|     30|  return 1;
  698|     30|}
coap_delete_all_resources:
  701|     30|coap_delete_all_resources(coap_context_t *context) {
  702|     30|  coap_resource_t *r;
  703|     30|  coap_resource_t *tmp;
  704|       |
  705|     30|  RESOURCE_ITER_SAFE(context->resources, r, tmp) {
  ------------------
  |  |  197|     30|  for ((el) = (e); (el) && ((rtmp) = (el)->hh.next, 1); (el) = (rtmp))
  |  |  ------------------
  |  |  |  Branch (197:20): [True: 0, False: 30]
  |  |  |  Branch (197:28): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  706|      0|    coap_delete_resource_lkd(r);
  707|      0|  }
  708|       |
  709|     30|  context->resources = NULL;
  710|       |
  711|     30|  if (context->unknown_resource) {
  ------------------
  |  Branch (711:7): [True: 0, False: 30]
  ------------------
  712|      0|    coap_delete_resource_lkd(context->unknown_resource);
  713|      0|    context->unknown_resource = NULL;
  714|      0|  }
  715|     30|  if (context->proxy_uri_resource) {
  ------------------
  |  Branch (715:7): [True: 30, False: 0]
  ------------------
  716|     30|    coap_delete_resource_lkd(context->proxy_uri_resource);
  717|       |    context->proxy_uri_resource = NULL;
  718|     30|  }
  719|     30|}
coap_resource_notify_observers_lkd:
 1520|     30|                                   coap_deleting_resource_t deleting) {
 1521|     30|  coap_lock_check_locked();
  ------------------
  |  |  638|     30|#define coap_lock_check_locked() {}
  ------------------
 1522|     30|  if (!r->observable)
  ------------------
  |  Branch (1522:7): [True: 30, False: 0]
  ------------------
 1523|     30|    return 0;
 1524|      0|  if (!r->subscribers)
  ------------------
  |  Branch (1524:7): [True: 0, False: 0]
  ------------------
 1525|      0|    return 0;
 1526|      0|  r->dirty = 1;
 1527|       |
 1528|       |  /* Increment value for next Observe use. Observe value must be < 2^24 */
 1529|      0|  r->observe = (r->observe + 1) & 0xFFFFFF;
 1530|       |
 1531|      0|  assert(r->context);
  ------------------
  |  Branch (1531:3): [True: 0, False: 0]
  ------------------
 1532|       |
 1533|      0|  if (r->context->track_observe_value_cb) {
  ------------------
  |  Branch (1533:7): [True: 0, False: 0]
  ------------------
 1534|       |    /* Track last used observe value */
 1535|      0|    if ((r->observe % r->context->observe_save_freq) == 0)
  ------------------
  |  Branch (1535:9): [True: 0, False: 0]
  ------------------
 1536|      0|      coap_lock_callback(r->context->track_observe_value_cb(r->context, r->uri_path,
  ------------------
  |  |  651|      0|#define coap_lock_callback(func) func
  ------------------
 1537|      0|                                                            r->observe,
 1538|      0|                                                            r->context->observe_user_data));
 1539|      0|  }
 1540|       |
 1541|      0|  coap_notify_observers(r->context, r, deleting);
 1542|      0|  return 1;
 1543|      0|}
coap_resource.c:coap_free_resource:
  543|     30|coap_free_resource(coap_resource_t *resource, coap_deleting_resource_t deleting) {
  544|     30|  coap_attr_t *attr, *tmp;
  545|     30|  coap_subscription_t *obs, *otmp;
  546|     30|  coap_context_t *context;
  547|       |
  548|     30|  assert(resource);
  ------------------
  |  Branch (548:3): [True: 30, False: 0]
  ------------------
  549|       |
  550|     30|  context = resource->context;
  551|     30|  if (context) {
  ------------------
  |  Branch (551:7): [True: 30, False: 0]
  ------------------
  552|     30|    if (!context->observe_no_clear) {
  ------------------
  |  Branch (552:9): [True: 30, False: 0]
  ------------------
  553|     30|      coap_resource_notify_observers_lkd(resource, deleting);
  554|     30|      coap_notify_observers(context, resource, deleting);
  555|     30|    }
  556|       |
  557|     30|    if (context->resource_deleted_cb)
  ------------------
  |  Branch (557:9): [True: 0, False: 30]
  ------------------
  558|      0|      coap_lock_callback(context->resource_deleted_cb(context,
  ------------------
  |  |  651|     30|#define coap_lock_callback(func) func
  ------------------
  559|     30|                                                      resource->uri_path,
  560|     30|                                                      context->observe_user_data));
  561|       |
  562|     30|    if (context->release_userdata_cb && resource->user_data) {
  ------------------
  |  Branch (562:9): [True: 0, False: 30]
  |  Branch (562:41): [True: 0, False: 0]
  ------------------
  563|      0|      coap_lock_callback(context->release_userdata_cb(resource->user_data));
  ------------------
  |  |  651|      0|#define coap_lock_callback(func) func
  ------------------
  564|      0|    }
  565|     30|  }
  566|       |
  567|       |  /* delete registered attributes */
  568|     30|  LL_FOREACH_SAFE(resource->link_attr, attr, tmp) coap_delete_attr(attr);
  ------------------
  |  |  425|     30|    LL_FOREACH_SAFE2(head,el,tmp,next)
  |  |  ------------------
  |  |  |  |  428|     30|  for ((el) = (head); (el) && ((tmp) = (el)->next, 1); (el) = (tmp))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (428:23): [True: 0, False: 30]
  |  |  |  |  |  Branch (428:31): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  569|       |
  570|       |  /* Either the application provided or libcoap copied - need to delete it */
  571|     30|  coap_delete_str_const(resource->uri_path);
  572|       |
  573|       |  /* free all elements from resource->subscribers */
  574|     30|  LL_FOREACH_SAFE(resource->subscribers, obs, otmp) {
  ------------------
  |  |  425|     30|    LL_FOREACH_SAFE2(head,el,tmp,next)
  |  |  ------------------
  |  |  |  |  428|     30|  for ((el) = (head); (el) && ((tmp) = (el)->next, 1); (el) = (tmp))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (428:23): [True: 0, False: 30]
  |  |  |  |  |  Branch (428:31): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  575|      0|    coap_delete_observer_internal(resource, obs->session, obs);
  576|      0|  }
  577|     30|  if (resource->proxy_name_count && resource->proxy_name_list) {
  ------------------
  |  Branch (577:7): [True: 0, False: 30]
  |  Branch (577:37): [True: 0, False: 0]
  ------------------
  578|      0|    size_t i;
  579|       |
  580|      0|    for (i = 0; i < resource->proxy_name_count; i++) {
  ------------------
  |  Branch (580:17): [True: 0, False: 0]
  ------------------
  581|      0|      coap_delete_str_const(resource->proxy_name_list[i]);
  582|      0|    }
  583|      0|    coap_free_type(COAP_STRING, resource->proxy_name_list);
  584|      0|  }
  585|       |
  586|     30|  coap_free_type(COAP_RESOURCE, resource);
  587|     30|}
coap_resource.c:coap_notify_observers:
 1184|     30|                      coap_deleting_resource_t deleting) {
 1185|     30|  coap_method_handler_t h;
 1186|     30|  coap_subscription_t *obs;
 1187|     30|  coap_pdu_t *response;
 1188|     30|  uint8_t buf[4];
 1189|     30|  coap_string_t *query;
 1190|     30|  coap_block_b_t block;
 1191|     30|  coap_tick_t now;
 1192|       |
 1193|     30|  coap_lock_check_locked();
  ------------------
  |  |  638|     30|#define coap_lock_check_locked() {}
  ------------------
 1194|       |
 1195|     30|  if (r->observable && (r->dirty || r->partiallydirty)) {
  ------------------
  |  Branch (1195:7): [True: 0, False: 30]
  |  Branch (1195:25): [True: 0, False: 0]
  |  Branch (1195:37): [True: 0, False: 0]
  ------------------
 1196|      0|    if (r->list_being_traversed)
  ------------------
  |  Branch (1196:9): [True: 0, False: 0]
  ------------------
 1197|      0|      return;
 1198|      0|    r->list_being_traversed = 1;
 1199|       |
 1200|      0|    coap_resource_reference_lkd(r);
 1201|       |
 1202|      0|    r->partiallydirty = 0;
 1203|       |
 1204|       |    /*
 1205|       |     * Any subscription (not just the one being notified) may get deleted
 1206|       |     * in the callback, by another running thread when executing the
 1207|       |     * callback, or when sending a response (e.g. the session fails and all
 1208|       |     * of its subscriptions are deleted). So no pointer into the list is kept
 1209|       |     * over a notification: the next subscription to visit is looked up again
 1210|       |     * from the head of the list each time.
 1211|       |     */
 1212|      0|    LL_FOREACH(r->subscribers, obs) {
  ------------------
  |  |  419|      0|    LL_FOREACH2(head,el,next)
  |  |  ------------------
  |  |  |  |  422|      0|    for ((el) = (head); el; (el) = (el)->next)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (422:25): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1213|      0|      obs->to_visit = 1;
 1214|      0|    }
 1215|      0|    for (;;) {
 1216|      0|      coap_session_t *obs_session;
 1217|      0|      coap_pdu_t *obs_pdu;
 1218|      0|      coap_mid_t mid = COAP_INVALID_MID;
  ------------------
  |  |  187|      0|#define COAP_INVALID_MID -1
  ------------------
 1219|       |
 1220|      0|      LL_FOREACH(r->subscribers, obs) {
  ------------------
  |  |  419|      0|    LL_FOREACH2(head,el,next)
  |  |  ------------------
  |  |  |  |  422|      0|    for ((el) = (head); el; (el) = (el)->next)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (422:25): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1221|      0|        if (obs->to_visit)
  ------------------
  |  Branch (1221:13): [True: 0, False: 0]
  ------------------
 1222|      0|          break;
 1223|      0|      }
 1224|      0|      if (obs == NULL)
  ------------------
  |  Branch (1224:11): [True: 0, False: 0]
  ------------------
 1225|      0|        break;
 1226|      0|      obs->to_visit = 0;
 1227|       |
 1228|      0|      if ((r->dirty == 0 && obs->dirty == 0) || obs->session->is_rate_limiting) {
  ------------------
  |  Branch (1228:12): [True: 0, False: 0]
  |  Branch (1228:29): [True: 0, False: 0]
  |  Branch (1228:49): [True: 0, False: 0]
  ------------------
 1229|       |        /*
 1230|       |         * running this resource due to partiallydirty, but this observation's
 1231|       |         * notification was already enqueued
 1232|       |         */
 1233|      0|        context->observe_pending = 1;
 1234|      0|        continue;
 1235|      0|      }
 1236|       |
 1237|       |      /*
 1238|       |       * obs may get deleted in the callback, or by another running
 1239|       |       * thread when executing the callback or when sending a response.
 1240|       |       */
 1241|      0|      obs_session = obs->session;
 1242|      0|      obs_pdu = obs->pdu;
 1243|      0|      coap_session_reference_lkd(obs_session);
 1244|      0|      coap_pdu_reference_lkd(obs_pdu);
 1245|       |
 1246|      0|      if (obs->session->con_active >= COAP_NSTART(obs->session) &&
  ------------------
  |  |  809|      0|#define COAP_NSTART(s) ((s)->nstart)
  ------------------
  |  Branch (1246:11): [True: 0, False: 0]
  ------------------
 1247|      0|          ((r->flags & COAP_RESOURCE_FLAGS_NOTIFY_CON) ||
  ------------------
  |  |   69|      0|#define COAP_RESOURCE_FLAGS_NOTIFY_CON  0x2
  ------------------
  |  Branch (1247:12): [True: 0, False: 0]
  ------------------
 1248|      0|           (obs->non_cnt >= COAP_OBS_MAX_NON))) {
  ------------------
  |  |   39|      0|#define COAP_OBS_MAX_NON   5
  ------------------
  |  Branch (1248:12): [True: 0, False: 0]
  ------------------
 1249|       |        /* Waiting for the previous unsolicited response to finish */
 1250|      0|        goto next_one_fail;
 1251|      0|      }
 1252|      0|      coap_ticks(&now);
 1253|      0|      if (obs->session->lg_xmit && obs->session->lg_xmit->last_all_sent == 0 &&
  ------------------
  |  Branch (1253:11): [True: 0, False: 0]
  |  Branch (1253:36): [True: 0, False: 0]
  ------------------
 1254|      0|          obs->session->lg_xmit->last_obs &&
  ------------------
  |  Branch (1254:11): [True: 0, False: 0]
  ------------------
 1255|      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 (1255:11): [True: 0, False: 0]
  ------------------
 1256|       |        /* Waiting for the previous blocked unsolicited response to finish */
 1257|      0|        goto next_one_fail;
 1258|      0|      }
 1259|       |
 1260|       |      /* Other packets on this session may have changed the local address,
 1261|       |       * including multicast requests from the same peer and source port.
 1262|       |       * Restore it before the handler can register an async response. */
 1263|      0|      coap_address_copy(&obs_session->addr_info.local, &obs->local_if);
 1264|       |
 1265|      0|      obs->dirty = 0;
 1266|       |      /* initialize response */
 1267|      0|      response = coap_pdu_init(COAP_MESSAGE_CON, 0, 0,
 1268|      0|                               coap_session_max_pdu_size_lkd(obs->session));
 1269|      0|      if (!response) {
  ------------------
  |  Branch (1269:11): [True: 0, False: 0]
  ------------------
 1270|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1271|      0|                       "partially dirty\n");
 1272|      0|        goto next_one_fail_no_pending;
 1273|      0|      }
 1274|       |
 1275|      0|      if (!coap_add_token(response, obs->pdu->actual_token.length,
  ------------------
  |  Branch (1275:11): [True: 0, False: 0]
  ------------------
 1276|      0|                          obs->pdu->actual_token.s)) {
 1277|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1278|      0|                       "partially dirty\n");
 1279|      0|        coap_delete_pdu_lkd(response);
 1280|      0|        goto next_one_fail_no_pending;
 1281|      0|      }
 1282|       |
 1283|      0|      obs->pdu->mid = response->mid = coap_new_message_id_lkd(obs->session);
 1284|       |      /* A lot of the reliable code assumes type is CON */
 1285|      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]
  |  |  ------------------
  ------------------
 1286|      0|          (r->flags & COAP_RESOURCE_FLAGS_NOTIFY_CON) == 0 &&
  ------------------
  |  |   69|      0|#define COAP_RESOURCE_FLAGS_NOTIFY_CON  0x2
  ------------------
  |  Branch (1286:11): [True: 0, False: 0]
  ------------------
 1287|      0|          ((r->flags & COAP_RESOURCE_FLAGS_NOTIFY_NON_ALWAYS) ||
  ------------------
  |  |   79|      0|#define COAP_RESOURCE_FLAGS_NOTIFY_NON_ALWAYS  0x4
  ------------------
  |  Branch (1287:12): [True: 0, False: 0]
  ------------------
 1288|      0|           obs->non_cnt < COAP_OBS_MAX_NON)) {
  ------------------
  |  |   39|      0|#define COAP_OBS_MAX_NON   5
  ------------------
  |  Branch (1288:12): [True: 0, False: 0]
  ------------------
 1289|      0|        response->type = COAP_MESSAGE_NON;
 1290|      0|      } else {
 1291|      0|        response->type = COAP_MESSAGE_CON;
 1292|      0|      }
 1293|      0|      switch (deleting) {
 1294|      0|      case COAP_NOT_DELETING_RESOURCE:
  ------------------
  |  Branch (1294:7): [True: 0, False: 0]
  ------------------
 1295|       |        /* fill with observer-specific data */
 1296|      0|        coap_add_option_internal(response, COAP_OPTION_OBSERVE,
 1297|      0|                                 coap_encode_var_safe(buf, sizeof(buf),
 1298|      0|                                                      r->observe),
 1299|      0|                                 buf);
 1300|      0|        if (coap_get_block_b(obs->session, obs->pdu, COAP_OPTION_BLOCK2,
  ------------------
  |  Branch (1300:13): [True: 0, False: 0]
  ------------------
 1301|      0|                             &block)) {
 1302|       |          /* Will get updated later (e.g. M bit) if appropriate */
 1303|      0|          coap_add_option_internal(response, COAP_OPTION_BLOCK2,
 1304|      0|                                   coap_encode_var_safe(buf, sizeof(buf),
 1305|      0|                                                        ((0 << 4) |
 1306|      0|                                                         (0 << 3) |
 1307|      0|                                                         block.aszx)),
 1308|      0|                                   buf);
 1309|      0|        }
 1310|      0|#if COAP_Q_BLOCK_SUPPORT
 1311|      0|        else if (coap_get_block_b(obs->session, obs->pdu, COAP_OPTION_Q_BLOCK2,
  ------------------
  |  Branch (1311:18): [True: 0, False: 0]
  ------------------
 1312|      0|                                  &block)) {
 1313|       |          /* Will get updated later (e.g. M bit) if appropriate */
 1314|      0|          coap_add_option_internal(response, COAP_OPTION_Q_BLOCK2,
 1315|      0|                                   coap_encode_var_safe(buf, sizeof(buf),
 1316|      0|                                                        ((0 << 4) |
 1317|      0|                                                         (0 << 3) |
 1318|      0|                                                         block.szx)),
 1319|      0|                                   buf);
 1320|      0|        }
 1321|      0|#endif /* COAP_Q_BLOCK_SUPPORT */
 1322|       |
 1323|      0|        h = r->handler[obs->pdu->code - 1];
 1324|      0|        assert(h);      /* we do not allow subscriptions if no
  ------------------
  |  Branch (1324:9): [True: 0, False: 0]
  ------------------
 1325|       |                         * GET/FETCH handler is defined */
 1326|      0|        query = coap_get_query(obs->pdu);
 1327|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1328|      0|        coap_show_pdu(COAP_LOG_DEBUG, obs->pdu);
 1329|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1330|      0|                       (int)r->uri_path->length, (int)r->uri_path->length,
 1331|      0|                       r->uri_path->s);
 1332|       |
 1333|       |        /* obs may get deleted during callback (potentially by another thread) */
 1334|      0|        if (r->flags & COAP_RESOURCE_SAFE_REQUEST_HANDLER) {
  ------------------
  |  |  181|      0|#define COAP_RESOURCE_SAFE_REQUEST_HANDLER 0x4000
  ------------------
  |  Branch (1334:13): [True: 0, False: 0]
  ------------------
 1335|      0|          coap_lock_callback_release(h(r, obs->session, obs->pdu, query, response),
  ------------------
  |  |  680|      0|#define coap_lock_callback_release(func,failed) func
  ------------------
 1336|       |                                     /* context is being freed off */
 1337|      0|                                     coap_delete_string(query);
 1338|      0|                                     coap_delete_pdu_lkd(response);
 1339|      0|                                     coap_session_release_lkd(obs_session);
 1340|      0|                                     coap_pdu_release_lkd(obs_pdu);
 1341|      0|                                     r->list_being_traversed = 0;
 1342|      0|                                     coap_resource_release_lkd(r);
 1343|      0|                                     return);
 1344|      0|        } else {
 1345|      0|          coap_lock_specific_callback_release(&r->lock,
  ------------------
  |  |  692|      0|#define coap_lock_specific_callback_release(lock,func,failed) func
  ------------------
 1346|      0|                                              h(r, obs->session, obs->pdu, query, response),
 1347|       |                                              /* context is being freed off */
 1348|      0|                                              coap_delete_string(query);
 1349|      0|                                              coap_delete_pdu_lkd(response);
 1350|      0|                                              coap_session_release_lkd(obs_session);
 1351|      0|                                              coap_pdu_release_lkd(obs_pdu);
 1352|      0|                                              r->list_being_traversed = 0;
 1353|      0|                                              coap_resource_release_lkd(r);
 1354|      0|                                              return);
 1355|      0|        }
 1356|       |
 1357|       |        /* Check validity of response code */
 1358|      0|        if (!coap_check_code_class(obs_session, response)) {
  ------------------
  |  Branch (1358:13): [True: 0, False: 0]
  ------------------
 1359|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1360|      0|                        COAP_RESPONSE_CLASS(response->code),
 1361|      0|                        response->code & 0x1f);
 1362|      0|          coap_delete_string(query);
 1363|      0|          coap_delete_pdu_lkd(response);
 1364|      0|          coap_session_release_lkd(obs_session);
 1365|      0|          coap_pdu_release_lkd(obs_pdu);
 1366|      0|          r->list_being_traversed = 0;
 1367|      0|          coap_resource_release_lkd(r);
 1368|      0|          return;
 1369|      0|        }
 1370|       |
 1371|       |        /* Check if lg_xmit generated and update PDU code if so */
 1372|      0|        coap_check_code_lg_xmit(obs_session, obs_pdu, response, r, query);
 1373|      0|        coap_delete_string(query);
 1374|      0|        if (COAP_RESPONSE_CLASS(response->code) != 2) {
  ------------------
  |  |   99|      0|#define COAP_RESPONSE_CLASS(C) (((C) >> 5) & 0xFF)
  ------------------
  |  Branch (1374:13): [True: 0, False: 0]
  ------------------
 1375|      0|          coap_remove_option(response, COAP_OPTION_OBSERVE);
 1376|      0|        }
 1377|      0|        if (COAP_RESPONSE_CLASS(response->code) > 2) {
  ------------------
  |  |   99|      0|#define COAP_RESPONSE_CLASS(C) (((C) >> 5) & 0xFF)
  ------------------
  |  Branch (1377:13): [True: 0, False: 0]
  ------------------
 1378|      0|          coap_delete_observer(r, obs_session, &obs_pdu->actual_token);
 1379|      0|          obs = NULL;
 1380|      0|        }
 1381|      0|        break;
 1382|      0|      case COAP_DELETING_RESOURCE_ON_EXIT:
  ------------------
  |  Branch (1382:7): [True: 0, False: 0]
  ------------------
 1383|       |        /* Don't worry if it does not get there */
 1384|      0|        response->type = COAP_MESSAGE_NON;
 1385|      0|        response->code = COAP_RESPONSE_CODE(503);
  ------------------
  |  |   96|      0|#define COAP_RESPONSE_CODE(N) (((N)/100 << 5) | (N)%100)
  ------------------
 1386|      0|        coap_add_option_internal(response, COAP_OPTION_MAXAGE,
 1387|      0|                                 coap_encode_var_safe(buf, sizeof(buf),
 1388|      0|                                                      30),
 1389|      0|                                 buf);
 1390|      0|        break;
 1391|      0|      case COAP_DELETING_RESOURCE:
  ------------------
  |  Branch (1391:7): [True: 0, False: 0]
  ------------------
 1392|      0|      default:
  ------------------
  |  Branch (1392:7): [True: 0, False: 0]
  ------------------
 1393|       |        /* Don't worry if it does not get there */
 1394|      0|        response->type = COAP_MESSAGE_NON;
 1395|      0|        response->code = COAP_RESPONSE_CODE(404);
  ------------------
  |  |   96|      0|#define COAP_RESPONSE_CODE(N) (((N)/100 << 5) | (N)%100)
  ------------------
 1396|      0|        break;
 1397|      0|      }
 1398|       |
 1399|      0|      if (obs) {
  ------------------
  |  Branch (1399:11): [True: 0, False: 0]
  ------------------
 1400|      0|        coap_subscription_t *s;
 1401|       |        /*
 1402|       |         * obs may have been deleted in the callback, or by another running
 1403|       |         * thread when executing the callback.
 1404|       |         */
 1405|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1406|      0|          if (s == obs) {
  ------------------
  |  Branch (1406:15): [True: 0, False: 0]
  ------------------
 1407|      0|            break;
 1408|      0|          }
 1409|      0|        }
 1410|      0|        if (s == NULL)
  ------------------
  |  Branch (1410:13): [True: 0, False: 0]
  ------------------
 1411|      0|          obs = NULL;
 1412|      0|      }
 1413|      0|      if (obs) {
  ------------------
  |  Branch (1413:11): [True: 0, False: 0]
  ------------------
 1414|      0|        if (response->type == COAP_MESSAGE_CON ||
  ------------------
  |  Branch (1414:13): [True: 0, False: 0]
  ------------------
 1415|      0|            (r->flags & COAP_RESOURCE_FLAGS_NOTIFY_NON_ALWAYS)) {
  ------------------
  |  |   79|      0|#define COAP_RESOURCE_FLAGS_NOTIFY_NON_ALWAYS  0x4
  ------------------
  |  Branch (1415:13): [True: 0, False: 0]
  ------------------
 1416|      0|          obs->non_cnt = 0;
 1417|      0|        } else {
 1418|      0|          obs->non_cnt++;
 1419|      0|        }
 1420|       |
 1421|      0|#if COAP_Q_BLOCK_SUPPORT
 1422|      0|        if (response->code == COAP_RESPONSE_CODE(205) &&
  ------------------
  |  |   96|      0|#define COAP_RESPONSE_CODE(N) (((N)/100 << 5) | (N)%100)
  ------------------
  |  Branch (1422:13): [True: 0, False: 0]
  ------------------
 1423|      0|            coap_get_block_b(obs_session, response, COAP_OPTION_Q_BLOCK2,
  ------------------
  |  Branch (1423:13): [True: 0, False: 0]
  ------------------
 1424|      0|                             &block) &&
 1425|      0|            block.m) {
  ------------------
  |  Branch (1425:13): [True: 0, False: 0]
  ------------------
 1426|      0|          query = coap_get_query(obs_pdu);
 1427|      0|          mid = coap_send_q_block2(obs_session, r, query, obs_pdu->code,
 1428|      0|                                   block, response, 1);
 1429|      0|          coap_delete_string(query);
 1430|      0|          goto finish;
 1431|      0|        }
 1432|      0|#endif /* COAP_Q_BLOCK_SUPPORT */
 1433|      0|      }
 1434|      0|      if (response->code == COAP_EMPTY_CODE &&
  ------------------
  |  Branch (1434:11): [True: 0, False: 0]
  ------------------
 1435|      0|          (response->type == COAP_MESSAGE_NON ||
  ------------------
  |  Branch (1435:12): [True: 0, False: 0]
  ------------------
 1436|      0|           response->type == COAP_MESSAGE_CON) &&
  ------------------
  |  Branch (1436:12): [True: 0, False: 0]
  ------------------
 1437|      0|          response->actual_token.length != 0) {
  ------------------
  |  Branch (1437:11): [True: 0, False: 0]
  ------------------
 1438|       |        /*
 1439|       |         * If a resource has been updated, triggering the sending of an
 1440|       |         * observer response and the request handler does not set a response
 1441|       |         * code (a coding error condition), then this PDU must be dropped as
 1442|       |         * it is illegally formatted.
 1443|       |         */
 1444|      0|        coap_delete_pdu_lkd(response);
 1445|      0|        mid = (coap_mid_t)COAP_DROPPED_RESPONSE;
  ------------------
  |  |   92|      0|#define COAP_DROPPED_RESPONSE -2
  ------------------
 1446|      0|      } else {
 1447|      0|        mid = coap_send_internal(obs_session, response, NULL);
 1448|      0|      }
 1449|       |
 1450|      0|#if COAP_Q_BLOCK_SUPPORT
 1451|      0|finish:
 1452|      0|#endif /* COAP_Q_BLOCK_SUPPORT */
 1453|      0|      if (COAP_INVALID_MID == mid) {
  ------------------
  |  |  187|      0|#define COAP_INVALID_MID -1
  ------------------
  |  Branch (1453:11): [True: 0, False: 0]
  ------------------
 1454|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1455|      0|                       "partially dirty\n", coap_session_str(obs_session));
 1456|      0|        if (obs) {
  ------------------
  |  Branch (1456:13): [True: 0, False: 0]
  ------------------
 1457|      0|          coap_subscription_t *s;
 1458|       |          /*
 1459|       |           * obs may have been deleted in coap_send_internal() or
 1460|       |           * coap_send_q_block2().
 1461|       |           */
 1462|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1463|      0|            if (s == obs) {
  ------------------
  |  Branch (1463:17): [True: 0, False: 0]
  ------------------
 1464|      0|              break;
 1465|      0|            }
 1466|      0|          }
 1467|      0|          if (s == NULL)
  ------------------
  |  Branch (1467:15): [True: 0, False: 0]
  ------------------
 1468|      0|            obs = NULL;
 1469|      0|        }
 1470|      0|        if (obs)
  ------------------
  |  Branch (1470:13): [True: 0, False: 0]
  ------------------
 1471|      0|          obs->dirty = 1;
 1472|      0|        r->partiallydirty = 1;
 1473|      0|      }
 1474|      0|      goto cleanup;
 1475|       |
 1476|      0|next_one_fail:
 1477|      0|      context->observe_pending = 1;
 1478|      0|next_one_fail_no_pending:
 1479|      0|      r->partiallydirty = 1;
 1480|      0|      if (obs)
  ------------------
  |  Branch (1480:11): [True: 0, False: 0]
  ------------------
 1481|      0|        obs->dirty = 1;
 1482|      0|cleanup:
 1483|      0|      coap_session_release_lkd(obs_session);
 1484|      0|      coap_pdu_release_lkd(obs_pdu);
 1485|      0|    }
 1486|      0|    r->list_being_traversed = 0;
 1487|      0|    r->dirty = 0;
 1488|      0|    coap_resource_release_lkd(r);
 1489|       |    /* r may be no more if elsewhere coap_free_resource() has been called */
 1490|     30|  } else {
 1491|     30|    r->dirty = 0;
 1492|     30|  }
 1493|     30|}

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

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

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

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

coap_split_proxy_uri:
  357|      5|coap_split_proxy_uri(const uint8_t *str_var, size_t len, coap_uri_t *uri) {
  358|      5|  return coap_split_uri_sub(str_var, len, uri, COAP_URI_CHECK_PROXY);
  359|      5|}
coap_uri_into_optlist:
  381|      1|                      coap_optlist_t **optlist_chain, int create_port_host_opt) {
  382|       |  return coap_uri_into_optlist_abbrev(uri, dst, optlist_chain, create_port_host_opt, NULL, 0);
  383|      1|}
coap_uri_into_optlist_abbrev:
  388|      1|                             coap_upa_abbrev_t *mapping, uint32_t count) {
  389|      1|  if (create_port_host_opt && !coap_host_is_unix_domain(&uri->host)) {
  ------------------
  |  Branch (389:7): [True: 0, False: 1]
  |  Branch (389:31): [True: 0, False: 0]
  ------------------
  390|      0|    int add_option = 0;
  391|       |
  392|      0|    if (dst && uri->host.length) {
  ------------------
  |  Branch (392:9): [True: 0, False: 0]
  |  Branch (392:16): [True: 0, False: 0]
  ------------------
  393|      0|#if !defined(WITH_LWIP) && !defined(WITH_CONTIKI)
  394|      0|      char addr[INET6_ADDRSTRLEN];
  395|       |#else /* WITH_LWIP || WITH_CONTIKI */
  396|       |      char addr[40];
  397|       |#endif /* WITH_LWIP || WITH_CONTIKI */
  398|      0|      coap_optlist_t *optlist;
  399|       |
  400|       |      /* Add in Uri-Host if not match (need to strip off %iface) */
  401|      0|      size_t uri_host_len = uri->host.length;
  402|      0|      const uint8_t *cp = uri->host.s;
  403|       |
  404|       |      /* Unfortunately not null terminated */
  405|      0|      for (size_t i = 0; i < uri_host_len; i++) {
  ------------------
  |  Branch (405:26): [True: 0, False: 0]
  ------------------
  406|      0|        if (cp[i] == '%') {
  ------------------
  |  Branch (406:13): [True: 0, False: 0]
  ------------------
  407|       |          /* %iface specified in host name */
  408|      0|          uri_host_len = i;
  409|      0|          break;
  410|      0|        }
  411|      0|      }
  412|       |
  413|      0|      if (coap_print_ip_addr(dst, addr, sizeof(addr)) &&
  ------------------
  |  Branch (413:11): [True: 0, False: 0]
  ------------------
  414|      0|          (strlen(addr) != uri_host_len ||
  ------------------
  |  Branch (414:12): [True: 0, False: 0]
  ------------------
  415|      0|           strncasecmp(addr, (const char *)uri->host.s, uri_host_len) != 0)) {
  ------------------
  |  Branch (415:12): [True: 0, False: 0]
  ------------------
  416|       |        /* add Uri-Host */
  417|      0|        optlist = coap_new_optlist(COAP_OPTION_URI_HOST, uri_host_len,
  418|      0|                                   uri->host.s);
  419|      0|        if (!optlist)
  ------------------
  |  Branch (419:13): [True: 0, False: 0]
  ------------------
  420|      0|          return 0;
  421|      0|        if (!coap_host_is_unix_domain(&uri->host)) {
  ------------------
  |  Branch (421:13): [True: 0, False: 0]
  ------------------
  422|      0|          coap_replace_percents(optlist);
  423|      0|          coap_replace_upper_lower(optlist);
  424|      0|        }
  425|      0|        if (!coap_insert_optlist(optlist_chain, optlist)) {
  ------------------
  |  Branch (425:13): [True: 0, False: 0]
  ------------------
  426|      0|          return 0;
  427|      0|        }
  428|      0|      }
  429|      0|    }
  430|       |    /* Add in UriPort if not default */
  431|      0|    switch ((int)uri->scheme) {
  432|      0|    case COAP_URI_SCHEME_HTTP:
  ------------------
  |  Branch (432:5): [True: 0, False: 0]
  ------------------
  433|      0|    case COAP_URI_SCHEME_COAP_WS:
  ------------------
  |  Branch (433:5): [True: 0, False: 0]
  ------------------
  434|      0|      if (uri->port != 80)
  ------------------
  |  Branch (434:11): [True: 0, False: 0]
  ------------------
  435|      0|        add_option = 1;
  436|      0|      break;
  437|      0|    case COAP_URI_SCHEME_HTTPS:
  ------------------
  |  Branch (437:5): [True: 0, False: 0]
  ------------------
  438|      0|    case COAP_URI_SCHEME_COAPS_WS:
  ------------------
  |  Branch (438:5): [True: 0, False: 0]
  ------------------
  439|      0|      if (uri->port != 443)
  ------------------
  |  Branch (439:11): [True: 0, False: 0]
  ------------------
  440|      0|        add_option = 1;
  441|      0|      break;
  442|      0|    default:
  ------------------
  |  Branch (442:5): [True: 0, False: 0]
  ------------------
  443|      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 (443:11): [True: 0, False: 0]
  |  Branch (443:25): [True: 0, False: 0]
  ------------------
  444|      0|                        COAP_DEFAULT_PORT))
  ------------------
  |  |   39|      0|#define COAP_DEFAULT_PORT      5683 /* CoAP default UDP/TCP port */
  ------------------
  445|      0|        add_option = 1;
  446|      0|      break;
  447|      0|    }
  448|      0|    if (add_option) {
  ------------------
  |  Branch (448:9): [True: 0, False: 0]
  ------------------
  449|      0|      uint8_t tbuf[4];
  450|       |
  451|      0|      coap_insert_optlist(optlist_chain,
  452|      0|                          coap_new_optlist(COAP_OPTION_URI_PORT,
  453|      0|                                           coap_encode_var_safe(tbuf, 4,
  454|      0|                                                                (uri->port & 0xffff)),
  455|      0|                                           tbuf));
  456|      0|    }
  457|      0|  }
  458|       |
  459|      1|  if (uri->path.length) {
  ------------------
  |  Branch (459:7): [True: 1, False: 0]
  ------------------
  460|      1|    if (!coap_path_into_optlist_abbrev(uri->path.s, uri->path.length, COAP_OPTION_URI_PATH,
  ------------------
  |  Branch (460:9): [True: 0, False: 1]
  ------------------
  461|      1|                                       optlist_chain, mapping, count))
  462|      0|      return 0;
  463|      1|  }
  464|       |
  465|      1|  if (uri->query.length) {
  ------------------
  |  Branch (465:7): [True: 1, False: 0]
  ------------------
  466|      1|    if (!coap_query_into_optlist(uri->query.s, uri->query.length, COAP_OPTION_URI_QUERY,
  ------------------
  |  Branch (466:9): [True: 0, False: 1]
  ------------------
  467|      1|                                 optlist_chain))
  468|      0|      return 0;
  469|      1|  }
  470|      1|  return 1;
  471|      1|}
coap_host_is_unix_domain:
  474|     13|coap_host_is_unix_domain(const coap_str_const_t *host) {
  475|     13|  if (host->length >= 3 && host->s[0] == '%' &&
  ------------------
  |  Branch (475:7): [True: 13, False: 0]
  |  Branch (475:28): [True: 0, False: 13]
  ------------------
  476|      0|      host->s[1] == '2' &&
  ------------------
  |  Branch (476:7): [True: 0, False: 0]
  ------------------
  477|      0|      (host->s[2] == 'F' || host->s[2] == 'f')) {
  ------------------
  |  Branch (477:8): [True: 0, False: 0]
  |  Branch (477:29): [True: 0, False: 0]
  ------------------
  478|      0|    return 1;
  479|      0|  }
  480|     13|  if (host->length >= 1 && host->s[0] == '/')
  ------------------
  |  Branch (480:7): [True: 13, False: 0]
  |  Branch (480:28): [True: 0, False: 13]
  ------------------
  481|      0|    return 1;
  482|     13|  return 0;
  483|     13|}
coap_host_is_llc:
  486|     13|coap_host_is_llc(const coap_str_const_t *host) {
  487|     13|#if COAP_AF_LLC_SUPPORT
  488|     13|  size_t length;
  489|     13|  const uint8_t *s = NULL;
  490|     13|  int i = 0;
  491|       |
  492|     13|  length = host->length;
  493|     13|  if (length != LLC_HOST_LEN)
  ------------------
  |  |  178|     13|#define LLC_HOST_LEN (4 + HW_ADDRSTRLEN + 4)
  |  |  ------------------
  |  |  |  |  176|     13|#define HW_ADDRSTRLEN 17
  |  |  ------------------
  ------------------
  |  Branch (493:7): [True: 13, False: 0]
  ------------------
  494|     13|    return 0;
  495|       |
  496|      0|  s = host->s;
  497|       |
  498|      0|  if (strncmp((const char *)s, "llc[", 4) != 0)
  ------------------
  |  Branch (498:7): [True: 0, False: 0]
  ------------------
  499|      0|    return 0;
  500|       |
  501|      0|  length -= 4;
  502|      0|  s += 4;
  503|       |
  504|      0|  while (length) {
  ------------------
  |  Branch (504:10): [True: 0, False: 0]
  ------------------
  505|      0|    if (!isxdigit(s[0]) || !isxdigit(s[1]))
  ------------------
  |  Branch (505:9): [True: 0, False: 0]
  |  Branch (505:28): [True: 0, False: 0]
  ------------------
  506|      0|      return 0;
  507|       |
  508|      0|    length -= 2;
  509|      0|    s += 2;
  510|       |
  511|      0|    i++;
  512|       |
  513|      0|    if (length <= 0 || i >= 6)
  ------------------
  |  Branch (513:9): [True: 0, False: 0]
  |  Branch (513:24): [True: 0, False: 0]
  ------------------
  514|      0|      break;
  515|       |
  516|      0|    if (s[0] != ':')
  ------------------
  |  Branch (516:9): [True: 0, False: 0]
  ------------------
  517|      0|      return 0;
  518|       |
  519|      0|    length--;
  520|      0|    s++;
  521|      0|  }
  522|       |
  523|      0|  if (s[0] != ']' || s[1] != ':' || !isxdigit(s[2]) || !isxdigit(s[3]))
  ------------------
  |  Branch (523:7): [True: 0, False: 0]
  |  Branch (523:22): [True: 0, False: 0]
  |  Branch (523:37): [True: 0, False: 0]
  |  Branch (523:56): [True: 0, False: 0]
  ------------------
  524|      0|    return 0;
  525|       |
  526|      0|  return 1;
  527|       |#else /* COAP_AF_LLC_SUPPORT */
  528|       |  (void)host;
  529|       |  return 0;
  530|       |#endif /* COAP_AF_LLC_SUPPORT */
  531|      0|}
coap_check_dots:
  676|     51|coap_check_dots(const uint8_t *s, size_t len) {
  677|     51|  uint8_t p;
  678|       |
  679|     51|  if (!len)
  ------------------
  |  Branch (679:7): [True: 3, False: 48]
  ------------------
  680|      3|    return 0;
  681|       |
  682|     48|  p = *s;
  683|       |
  684|       |  /* Check 'first' char */
  685|     48|  if (p == '%' && len >=3) {
  ------------------
  |  Branch (685:7): [True: 2, False: 46]
  |  Branch (685:19): [True: 2, False: 0]
  ------------------
  686|      2|    if (s[1] == '2' && (s[2] == 'E' || s[2] == 'e')) {
  ------------------
  |  Branch (686:9): [True: 0, False: 2]
  |  Branch (686:25): [True: 0, False: 0]
  |  Branch (686:40): [True: 0, False: 0]
  ------------------
  687|      0|      s += 2;
  688|      0|      len -= 2;
  689|      0|    }
  690|      2|    p = '.';
  691|      2|  }
  692|     48|  if (p != '.')
  ------------------
  |  Branch (692:7): [True: 46, False: 2]
  ------------------
  693|     46|    return 0;
  694|      2|  if (len == 1)
  ------------------
  |  Branch (694:7): [True: 0, False: 2]
  ------------------
  695|      0|    return 1;
  696|       |
  697|       |  /* Check 'second' char, first is '.' */
  698|      2|  s++;
  699|      2|  len--;
  700|      2|  assert(len);
  ------------------
  |  Branch (700:3): [True: 2, False: 0]
  ------------------
  701|      2|  p = *s;
  702|      2|  if (p == '%' && len >=3) {
  ------------------
  |  Branch (702:7): [True: 0, False: 2]
  |  Branch (702:19): [True: 0, False: 0]
  ------------------
  703|      0|    if (s[1] == '2' && (s[2] == 'E' || s[2] == 'e')) {
  ------------------
  |  Branch (703:9): [True: 0, False: 0]
  |  Branch (703:25): [True: 0, False: 0]
  |  Branch (703:40): [True: 0, False: 0]
  ------------------
  704|      0|      len -= 2;
  705|      0|    }
  706|      0|    p = '.';
  707|      0|  }
  708|      2|  if (p != '.')
  ------------------
  |  Branch (708:7): [True: 2, False: 0]
  ------------------
  709|      2|    return 0;
  710|      0|  if (len == 1)
  ------------------
  |  Branch (710:7): [True: 0, False: 0]
  ------------------
  711|      0|    return 2;
  712|       |
  713|      0|  return 0;
  714|      0|}
coap_replace_percents:
  833|      4|coap_replace_percents(coap_optlist_t *optlist) {
  834|      4|  size_t i;
  835|      4|  size_t o = 0;
  836|       |
  837|    179|  for (i = 0; i < optlist->length; i++) {
  ------------------
  |  Branch (837:15): [True: 175, False: 4]
  ------------------
  838|    175|    if (optlist->data[i] == '%' && optlist->length - i >= 3) {
  ------------------
  |  Branch (838:9): [True: 17, False: 158]
  |  Branch (838:36): [True: 17, False: 0]
  ------------------
  839|     17|      optlist->data[o] = (hexchar_to_dec(optlist->data[i+1]) << 4) +
  ------------------
  |  |  540|     17|#define hexchar_to_dec(c) ((c) & 0x40 ? ((c) & 0x0F) + 9 : ((c) & 0x0F))
  |  |  ------------------
  |  |  |  Branch (540:28): [True: 5, False: 12]
  |  |  ------------------
  ------------------
  840|     17|                         hexchar_to_dec(optlist->data[i+2]);
  ------------------
  |  |  540|     17|#define hexchar_to_dec(c) ((c) & 0x40 ? ((c) & 0x0F) + 9 : ((c) & 0x0F))
  |  |  ------------------
  |  |  |  Branch (540:28): [True: 3, False: 14]
  |  |  ------------------
  ------------------
  841|     17|      i+= 2;
  842|    158|    } else if (o != i) {
  ------------------
  |  Branch (842:16): [True: 123, False: 35]
  ------------------
  843|    123|      optlist->data[o] = optlist->data[i];
  844|    123|    }
  845|    175|    o++;
  846|    175|  }
  847|      4|  optlist->length = o;
  848|      4|}
coap_path_into_optlist_abbrev:
  881|      1|                              uint32_t count) {
  882|      1|  const uint8_t *p = s;
  883|      1|  coap_optlist_t *optlist;
  884|      1|  int num_dots;
  885|      1|  coap_optlist_t **optlist_start;
  886|       |
  887|      1|  if (*optlist_chain) {
  ------------------
  |  Branch (887:7): [True: 1, False: 0]
  ------------------
  888|       |    /* Something previously in optlist_chain. Need to make that the start */
  889|      1|    optlist_start = &((*optlist_chain)->next);
  890|      1|  } else {
  891|      0|    optlist_start = optlist_chain;
  892|      0|  }
  893|       |
  894|      1|  if (length > 0 && mapping) {
  ------------------
  |  Branch (894:7): [True: 1, False: 0]
  |  Branch (894:21): [True: 0, False: 1]
  ------------------
  895|      0|    uint32_t i;
  896|      0|    uint8_t buf[4];
  897|       |
  898|      0|    for (i = 0; i < count; i++) {
  ------------------
  |  Branch (898:17): [True: 0, False: 0]
  ------------------
  899|      0|      if (strlen(mapping[i].upa_path) == length &&
  ------------------
  |  Branch (899:11): [True: 0, False: 0]
  ------------------
  900|      0|          memcmp(mapping[i].upa_path, s, length) == 0) {
  ------------------
  |  Branch (900:11): [True: 0, False: 0]
  ------------------
  901|       |        /* add in as Uri_path-Abbrev */
  902|      0|        optlist = coap_new_optlist(COAP_OPTION_URI_PATH_ABB,
  903|      0|                                   coap_encode_var_safe(buf, sizeof(buf), mapping[i].upa_value), buf);
  904|      0|        if (!coap_insert_optlist(optlist_chain, optlist)) {
  ------------------
  |  Branch (904:13): [True: 0, False: 0]
  ------------------
  905|      0|          return 0;
  906|      0|        }
  907|      0|        return 1;
  908|      0|      }
  909|      0|    }
  910|      0|  }
  911|    112|  while (length > 0 && !strnchr((const uint8_t *)"?#", 2, *s)) {
  ------------------
  |  Branch (911:10): [True: 111, False: 1]
  |  Branch (911:24): [True: 111, False: 0]
  ------------------
  912|    111|    if (*s == '/') {                /* start of new path element */
  ------------------
  |  Branch (912:9): [True: 1, False: 110]
  ------------------
  913|       |      /* start new segment */
  914|      1|      num_dots = coap_check_dots(p, s - p);
  915|      1|      switch (num_dots) {
  916|      0|      case 1:
  ------------------
  |  Branch (916:7): [True: 0, False: 1]
  ------------------
  917|       |        /* drop segment */
  918|      0|        break;
  919|      0|      case 2:
  ------------------
  |  Branch (919:7): [True: 0, False: 1]
  ------------------
  920|       |        /* backup segment */
  921|      0|        backup_optlist(optlist_start);
  922|      0|        break;
  923|      1|      case 0:
  ------------------
  |  Branch (923:7): [True: 1, False: 0]
  ------------------
  924|      1|      default:
  ------------------
  |  Branch (924:7): [True: 0, False: 1]
  ------------------
  925|       |        /* add segment */
  926|      1|        optlist = coap_new_optlist(optnum, s - p, p);
  927|      1|        if (!optlist) {
  ------------------
  |  Branch (927:13): [True: 0, False: 1]
  ------------------
  928|      0|          return 0;
  929|      0|        }
  930|      1|        coap_replace_percents(optlist);
  931|      1|        if (!coap_insert_optlist(optlist_chain, optlist)) {
  ------------------
  |  Branch (931:13): [True: 0, False: 1]
  ------------------
  932|      0|          return 0;
  933|      0|        }
  934|      1|        break;
  935|      1|      }
  936|      1|      p = s + 1;
  937|      1|    }
  938|    111|    s++;
  939|    111|    length--;
  940|       |
  941|    111|  }
  942|       |  /* add last path element */
  943|      1|  num_dots = coap_check_dots(p, s - p);
  944|      1|  switch (num_dots) {
  945|      0|  case 1:
  ------------------
  |  Branch (945:3): [True: 0, False: 1]
  ------------------
  946|       |    /* drop segment */
  947|      0|    break;
  948|      0|  case 2:
  ------------------
  |  Branch (948:3): [True: 0, False: 1]
  ------------------
  949|       |    /* backup segment */
  950|      0|    backup_optlist(optlist_start);
  951|      0|    break;
  952|      1|  case 0:
  ------------------
  |  Branch (952:3): [True: 1, False: 0]
  ------------------
  953|      1|  default:
  ------------------
  |  Branch (953:3): [True: 0, False: 1]
  ------------------
  954|       |    /* add segment */
  955|      1|    optlist = coap_new_optlist(optnum, s - p, p);
  956|      1|    if (!optlist) {
  ------------------
  |  Branch (956:9): [True: 0, False: 1]
  ------------------
  957|      0|      return 0;
  958|      0|    }
  959|      1|    coap_replace_percents(optlist);
  960|      1|    if (!coap_insert_optlist(optlist_chain, optlist)) {
  ------------------
  |  Branch (960:9): [True: 0, False: 1]
  ------------------
  961|      0|      return 0;
  962|      0|    }
  963|      1|    break;
  964|      1|  }
  965|      1|  return 1;
  966|      1|}
coap_query_into_optlist:
  994|      1|                        coap_optlist_t **optlist_chain) {
  995|      1|  const uint8_t *p = s;
  996|      1|  coap_optlist_t *optlist;
  997|       |
  998|    101|  while (length > 0 && *s != '#') {
  ------------------
  |  Branch (998:10): [True: 100, False: 1]
  |  Branch (998:24): [True: 100, False: 0]
  ------------------
  999|    100|    if (*s == '&') {                /* start of new query element */
  ------------------
  |  Branch (999:9): [True: 1, False: 99]
  ------------------
 1000|       |      /* add previous query element */
 1001|      1|      optlist = coap_new_optlist(optnum, s - p, p);
 1002|      1|      if (!optlist) {
  ------------------
  |  Branch (1002:11): [True: 0, False: 1]
  ------------------
 1003|      0|        return 0;
 1004|      0|      }
 1005|      1|      coap_replace_percents(optlist);
 1006|      1|      if (!coap_insert_optlist(optlist_chain, optlist)) {
  ------------------
  |  Branch (1006:11): [True: 0, False: 1]
  ------------------
 1007|      0|        return 0;
 1008|      0|      }
 1009|      1|      p = s + 1;
 1010|      1|    }
 1011|    100|    s++;
 1012|    100|    length--;
 1013|    100|  }
 1014|       |  /* add last query element */
 1015|      1|  optlist = coap_new_optlist(optnum, s - p, p);
 1016|      1|  if (!optlist) {
  ------------------
  |  Branch (1016:7): [True: 0, False: 1]
  ------------------
 1017|      0|    return 0;
 1018|      0|  }
 1019|      1|  coap_replace_percents(optlist);
 1020|      1|  if (!coap_insert_optlist(optlist_chain, optlist)) {
  ------------------
  |  Branch (1020:7): [True: 0, False: 1]
  ------------------
 1021|      0|    return 0;
 1022|      0|  }
 1023|      1|  return 1;
 1024|      1|}
coap_delete_upa_chain:
 1279|     60|coap_delete_upa_chain(coap_upa_chain_t *chain) {
 1280|     60|  while (chain) {
  ------------------
  |  Branch (1280:10): [True: 0, False: 60]
  ------------------
 1281|      0|    coap_upa_chain_t *next = chain->next;
 1282|       |
 1283|      0|    coap_free_type(COAP_STRING, chain);
 1284|      0|    chain = next;
 1285|      0|  }
 1286|     60|}
coap_uri.c:coap_split_uri_sub:
   84|      5|                   coap_uri_check_t check_proxy) {
   85|      5|  const uint8_t *p, *q;
   86|      5|  int res = 0;
   87|      5|  size_t i;
   88|      5|  int is_unix_domain = 0;
   89|      5|  int is_llc = 0;
   90|       |
   91|      5|  if (!str_var || !uri || len == 0)
  ------------------
  |  Branch (91:7): [True: 0, False: 5]
  |  Branch (91:19): [True: 0, False: 5]
  |  Branch (91:27): [True: 0, False: 5]
  ------------------
   92|      0|    return -1;
   93|       |
   94|      5|  memset(uri, 0, sizeof(coap_uri_t));
   95|      5|  uri->port = COAP_DEFAULT_PORT;
  ------------------
  |  |   39|      5|#define COAP_DEFAULT_PORT      5683 /* CoAP default UDP/TCP port */
  ------------------
   96|       |
   97|       |  /* search for scheme */
   98|      5|  p = str_var;
   99|      5|  if (*p == '/') {
  ------------------
  |  Branch (99:7): [True: 0, False: 5]
  ------------------
  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|    553|  while (len >= 3 && !(p[0] == ':' && p[1] == '/' && p[2] == '/')) {
  ------------------
  |  Branch (110:10): [True: 551, False: 2]
  |  Branch (110:24): [True: 4, False: 547]
  |  Branch (110:39): [True: 4, False: 0]
  |  Branch (110:54): [True: 3, False: 1]
  ------------------
  111|    548|    ++p;
  112|    548|    --len;
  113|    548|  }
  114|      5|  if (len < 3) {
  ------------------
  |  Branch (114:7): [True: 2, False: 3]
  ------------------
  115|       |    /* scheme not defined with a :// terminator */
  116|      2|    res = -2;
  117|      2|    goto error;
  118|      2|  }
  119|     22|  for (i = 0; i < COAP_URI_SCHEME_LAST; i++) {
  ------------------
  |  Branch (119:15): [True: 20, False: 2]
  ------------------
  120|     20|    if ((p - str_var) == (int)strlen(coap_uri_scheme[i].name) &&
  ------------------
  |  Branch (120:9): [True: 2, False: 18]
  ------------------
  121|      2|        memcmp(str_var, coap_uri_scheme[i].name, p - str_var) == 0) {
  ------------------
  |  Branch (121:9): [True: 1, False: 1]
  ------------------
  122|      1|      if (check_proxy != COAP_URI_CHECK_PROXY && coap_uri_scheme[i].proxy_only) {
  ------------------
  |  Branch (122:11): [True: 0, False: 1]
  |  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|      1|      uri->scheme = coap_uri_scheme[i].scheme;
  128|      1|      uri->port = coap_uri_scheme[i].port;
  129|      1|      break;
  130|      1|    }
  131|     20|  }
  132|      3|  if (i == COAP_URI_SCHEME_LAST) {
  ------------------
  |  Branch (132:7): [True: 2, False: 1]
  ------------------
  133|       |    /* scheme unknown */
  134|      2|    coap_log_err("%.*s URI scheme unknown\n", (int)(p - str_var), str_var);
  ------------------
  |  |  102|      2|#define coap_log_err(...) coap_log(COAP_LOG_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      2|#define coap_log(level, ...) do { \
  |  |  |  |  291|      2|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 2]
  |  |  |  |  ------------------
  |  |  |  |  292|      2|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      2|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 2]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  135|      2|    res = -1;
  136|      2|    goto error;
  137|      2|  }
  138|      1|  switch (uri->scheme) {
  139|      0|  case COAP_URI_SCHEME_COAP:
  ------------------
  |  Branch (139:3): [True: 0, False: 1]
  ------------------
  140|      0|    break;
  141|      0|  case COAP_URI_SCHEME_COAPS:
  ------------------
  |  Branch (141:3): [True: 0, False: 1]
  ------------------
  142|      0|    if (!coap_dtls_is_supported()) {
  ------------------
  |  Branch (142:9): [True: 0, False: 0]
  ------------------
  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|      0|    break;
  147|      0|  case COAP_URI_SCHEME_COAP_TCP:
  ------------------
  |  Branch (147:3): [True: 0, False: 1]
  ------------------
  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|      1|  case COAP_URI_SCHEME_COAPS_TCP:
  ------------------
  |  Branch (153:3): [True: 1, False: 0]
  ------------------
  154|      1|    if (!coap_tls_is_supported()) {
  ------------------
  |  Branch (154:9): [True: 0, False: 1]
  ------------------
  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|      1|    break;
  159|      1|  case COAP_URI_SCHEME_COAP_WS:
  ------------------
  |  Branch (159:3): [True: 0, False: 1]
  ------------------
  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: 1]
  ------------------
  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: 1]
  ------------------
  172|      0|  case COAP_URI_SCHEME_HTTPS:
  ------------------
  |  Branch (172:3): [True: 0, False: 1]
  ------------------
  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: 1]
  ------------------
  176|      0|  default:
  ------------------
  |  Branch (176:3): [True: 0, False: 1]
  ------------------
  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|      1|  }
  180|       |  /* skip :// */
  181|      1|  p += 3;
  182|      1|  len -= 3;
  183|       |
  184|       |  /* p points to beginning of Uri-Host */
  185|      1|  q = p;
  186|       |
  187|      1|  if (len && *p == '[') {
  ------------------
  |  Branch (187:7): [True: 1, False: 0]
  |  Branch (187:14): [True: 0, False: 1]
  ------------------
  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|    if ((int)(q - p) > 255) {
  ------------------
  |  Branch (203:9): [True: 0, False: 0]
  ------------------
  204|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  205|      0|      res = -6;
  206|      0|      goto error;
  207|      0|    }
  208|       |
  209|      0|    COAP_SET_STR(&uri->host, q - p, p);
  ------------------
  |  |   52|      0|#define COAP_SET_STR(st,l,v) { (st)->length = (l), (st)->s = (v); }
  ------------------
  210|      0|    ++q;
  211|      0|    --len;
  212|      0|#if COAP_AF_LLC_SUPPORT
  213|      1|  } else if ((len >= LLC_HOST_LEN) && strncmp((const char *)p, "llc[", 4) == 0) {
  ------------------
  |  |  178|      1|#define LLC_HOST_LEN (4 + HW_ADDRSTRLEN + 4)
  |  |  ------------------
  |  |  |  |  176|      1|#define HW_ADDRSTRLEN 17
  |  |  ------------------
  ------------------
  |  Branch (213:14): [True: 1, False: 0]
  |  Branch (213:39): [True: 0, False: 1]
  ------------------
  214|      0|    unsigned long sap = 0;
  215|       |
  216|      0|    is_llc = 1;
  217|       |
  218|      0|    while (len && *q != ']') {
  ------------------
  |  Branch (218:12): [True: 0, False: 0]
  |  Branch (218:19): [True: 0, False: 0]
  ------------------
  219|      0|      ++q;
  220|      0|      --len;
  221|      0|    }
  222|       |
  223|      0|    if (!len || *q != ']' || p == q) {
  ------------------
  |  Branch (223:9): [True: 0, False: 0]
  |  Branch (223:17): [True: 0, False: 0]
  |  Branch (223:30): [True: 0, False: 0]
  ------------------
  224|      0|      res = -7;
  225|      0|      goto error;
  226|      0|    }
  227|       |
  228|      0|    ++q;
  229|      0|    --len;
  230|       |
  231|      0|    if (!len || *q != ':') {
  ------------------
  |  Branch (231:9): [True: 0, False: 0]
  |  Branch (231:17): [True: 0, False: 0]
  ------------------
  232|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  233|      0|      res = -7;
  234|      0|      goto error;
  235|      0|    }
  236|       |
  237|      0|    ++q;
  238|      0|    --len;
  239|       |
  240|      0|    while (len && isxdigit(*q)) {
  ------------------
  |  Branch (240:12): [True: 0, False: 0]
  |  Branch (240:19): [True: 0, False: 0]
  ------------------
  241|      0|      if (*q >= 'a' && *q <= 'f')
  ------------------
  |  Branch (241:11): [True: 0, False: 0]
  |  Branch (241:24): [True: 0, False: 0]
  ------------------
  242|      0|        sap = sap * 16 + (*q - 'a' + 10);
  243|      0|      else if (*q >= 'A' && *q <= 'F')
  ------------------
  |  Branch (243:16): [True: 0, False: 0]
  |  Branch (243:29): [True: 0, False: 0]
  ------------------
  244|      0|        sap = sap * 16 + (*q - 'A' + 10);
  245|       |
  246|      0|      ++q;
  247|      0|      --len;
  248|      0|    }
  249|       |
  250|      0|    if (sap > UINT8_MAX) {
  ------------------
  |  Branch (250:9): [True: 0, False: 0]
  ------------------
  251|      0|      coap_log_warn("LLC SAP invalid (%lu > 255)\n", sap);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  252|      0|      res = -7;
  253|      0|      goto error;
  254|      0|    }
  255|       |
  256|      0|    COAP_SET_STR(&uri->host, q - p, p);
  ------------------
  |  |   52|      0|#define COAP_SET_STR(st,l,v) { (st)->length = (l), (st)->s = (v); }
  ------------------
  257|      0|#endif /* COAP_AF_LLC_SUPPORT */
  258|      1|  } else {
  259|       |    /* IPv4 address, FQDN or Unix domain socket */
  260|      1|    if (len >= 3 && p[0] == '%' && p[1] == '2' &&
  ------------------
  |  Branch (260:9): [True: 1, False: 0]
  |  Branch (260:21): [True: 0, False: 1]
  |  Branch (260:36): [True: 0, False: 0]
  ------------------
  261|      0|        (p[2] == 'F' || p[2] == 'f')) {
  ------------------
  |  Branch (261:10): [True: 0, False: 0]
  |  Branch (261:25): [True: 0, False: 0]
  ------------------
  262|       |      /* Unix domain definition */
  263|      0|      uri->port = 0;
  264|      0|      is_unix_domain = 1;
  265|      0|    }
  266|     31|    while (len && *q != ':' && *q != '/' && *q != '?') {
  ------------------
  |  Branch (266:12): [True: 31, False: 0]
  |  Branch (266:19): [True: 30, False: 1]
  |  Branch (266:32): [True: 30, False: 0]
  |  Branch (266:45): [True: 30, False: 0]
  ------------------
  267|     30|      ++q;
  268|     30|      --len;
  269|     30|    }
  270|       |
  271|      1|    if (p == q) {
  ------------------
  |  Branch (271:9): [True: 0, False: 1]
  ------------------
  272|      0|      res = -3;
  273|      0|      goto error;
  274|      0|    }
  275|       |
  276|      1|    if ((int)(q - p) > 255) {
  ------------------
  |  Branch (276:9): [True: 0, False: 1]
  ------------------
  277|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  278|      0|      res = -6;
  279|      0|      goto error;
  280|      0|    }
  281|       |
  282|      1|    COAP_SET_STR(&uri->host, q - p, p);
  ------------------
  |  |   52|      1|#define COAP_SET_STR(st,l,v) { (st)->length = (l), (st)->s = (v); }
  ------------------
  283|      1|  }
  284|       |
  285|       |  /* check for Uri-Port (invalid for Unix) */
  286|      1|  if (len && *q == ':') {
  ------------------
  |  Branch (286:7): [True: 1, False: 0]
  |  Branch (286:14): [True: 1, False: 0]
  ------------------
  287|      1|    if (is_unix_domain || is_llc) {
  ------------------
  |  Branch (287:9): [True: 0, False: 1]
  |  Branch (287:27): [True: 0, False: 1]
  ------------------
  288|      0|      res = -5;
  289|      0|      goto error;
  290|      0|    }
  291|      1|    p = ++q;
  292|      1|    --len;
  293|       |
  294|      1|    while (len && isdigit(*q)) {
  ------------------
  |  Branch (294:12): [True: 1, False: 0]
  |  Branch (294:19): [True: 0, False: 1]
  ------------------
  295|      0|      ++q;
  296|      0|      --len;
  297|      0|    }
  298|       |
  299|      1|    if (p < q) {                /* explicit port number given */
  ------------------
  |  Branch (299:9): [True: 0, False: 1]
  ------------------
  300|      0|      long uri_port = 0;
  301|       |
  302|      0|      while ((p < q) && (uri_port <= UINT16_MAX))
  ------------------
  |  Branch (302:14): [True: 0, False: 0]
  |  Branch (302:25): [True: 0, False: 0]
  ------------------
  303|      0|        uri_port = uri_port * 10 + (*p++ - '0');
  304|       |
  305|       |      /* check if port number is in allowed range */
  306|      0|      if (uri_port > UINT16_MAX) {
  ------------------
  |  Branch (306:11): [True: 0, False: 0]
  ------------------
  307|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  308|      0|        res = -4;
  309|      0|        goto error;
  310|      0|      }
  311|       |
  312|      0|      uri->port = (uint16_t)uri_port;
  313|      0|    }
  314|      1|  }
  315|       |
  316|      1|path:                 /* at this point, p must point to an absolute path */
  317|       |
  318|      1|  if (!len)
  ------------------
  |  Branch (318:7): [True: 0, False: 1]
  ------------------
  319|      0|    goto end;
  320|       |
  321|      1|  if (*q == '/') {
  ------------------
  |  Branch (321:7): [True: 1, False: 0]
  ------------------
  322|      1|    p = ++q;
  323|      1|    --len;
  324|       |
  325|    112|    while (len && *q != '?') {
  ------------------
  |  Branch (325:12): [True: 112, False: 0]
  |  Branch (325:19): [True: 111, False: 1]
  ------------------
  326|    111|      ++q;
  327|    111|      --len;
  328|    111|    }
  329|       |
  330|      1|    if (p < q) {
  ------------------
  |  Branch (330:9): [True: 1, False: 0]
  ------------------
  331|      1|      COAP_SET_STR(&uri->path, q - p, p);
  ------------------
  |  |   52|      1|#define COAP_SET_STR(st,l,v) { (st)->length = (l), (st)->s = (v); }
  ------------------
  332|      1|      p = q;
  333|      1|    }
  334|      1|  }
  335|       |
  336|       |  /* Uri_Query */
  337|      1|  if (len && *p == '?') {
  ------------------
  |  Branch (337:7): [True: 1, False: 0]
  |  Branch (337:14): [True: 1, False: 0]
  ------------------
  338|      1|    ++p;
  339|      1|    --len;
  340|      1|    COAP_SET_STR(&uri->query, len, p);
  ------------------
  |  |   52|      1|#define COAP_SET_STR(st,l,v) { (st)->length = (l), (st)->s = (v); }
  ------------------
  341|      1|    len = 0;
  342|      1|  }
  343|       |
  344|      1|end:
  345|      1|  return len ? -1 : 0;
  ------------------
  |  Branch (345:10): [True: 0, False: 1]
  ------------------
  346|       |
  347|      4|error:
  348|      4|  return res;
  349|      1|}
coap_uri.c:strnchr:
   47|    111|strnchr(const uint8_t *s, size_t len, unsigned char c) {
   48|    333|  while (len && *s++ != c)
  ------------------
  |  Branch (48:10): [True: 222, False: 111]
  |  Branch (48:17): [True: 222, False: 0]
  ------------------
   49|    222|    --len;
   50|       |
   51|    111|  return len ? s : NULL;
  ------------------
  |  Branch (51:10): [True: 0, False: 111]
  ------------------
   52|    111|}

oscore_free_contexts:
  195|     30|oscore_free_contexts(coap_context_t *c_context) {
  196|     30|  while (c_context->p_osc_ctx) {
  ------------------
  |  Branch (196:10): [True: 0, False: 30]
  ------------------
  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|     30|}
oscore_release_recipient_ctx:
  976|     43|oscore_release_recipient_ctx(oscore_recipient_ctx_t **recipient_ctx) {
  977|     43|  oscore_ctx_t *osc_ctx;
  978|       |
  979|     43|  if (recipient_ctx == NULL || *recipient_ctx == NULL)
  ------------------
  |  Branch (979:7): [True: 0, False: 43]
  |  Branch (979:32): [True: 43, False: 0]
  ------------------
  980|     43|    return;
  981|       |
  982|       |  /* ensure oscore context is freed if not attached to coap context */
  983|      0|  osc_ctx = (*recipient_ctx)->osc_ctx;
  984|      0|  oscore_free_recipient_ctx(*recipient_ctx);
  985|       |  /*
  986|       |   * Free temporary oscore context if not attached to a coap context
  987|       |   * and no recipients attached anymore.
  988|       |   */
  989|      0|  if (!oscore_is_context_attached(osc_ctx) && osc_ctx->recipient_chain == NULL) {
  ------------------
  |  Branch (989:7): [True: 0, False: 0]
  |  Branch (989:47): [True: 0, False: 0]
  ------------------
  990|      0|    oscore_free_context(osc_ctx);
  991|      0|  }
  992|       |  *recipient_ctx = NULL;
  993|      0|}
oscore_delete_server_associations:
 1096|     43|oscore_delete_server_associations(coap_session_t *session) {
 1097|     43|  if (session) {
  ------------------
  |  Branch (1097:7): [True: 43, False: 0]
  ------------------
 1098|     43|    oscore_association_t *association;
 1099|     43|    oscore_association_t *tmp;
 1100|       |
 1101|     43|    OSCORE_ASSOCIATIONS_ITER_SAFE(session->associations, association, tmp) {
  ------------------
  |  |  149|     43|  for ((el) = (e); (el) && ((rtmp) = (el)->hh.next, 1); (el) = (rtmp))
  |  |  ------------------
  |  |  |  Branch (149:20): [True: 0, False: 43]
  |  |  |  Branch (149:28): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1102|      0|      OSCORE_ASSOCIATIONS_DELETE(session->associations, association);
  ------------------
  |  |  142|      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]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1103|      0|      coap_log_oscore("Association %p deleted\n", (void *)association);
  ------------------
  |  |  132|      0|#define coap_log_oscore(...) coap_log(COAP_LOG_OSCORE, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1104|      0|      oscore_free_association(association);
 1105|      0|    }
 1106|       |    session->associations = NULL;
 1107|     43|  }
 1108|     43|}

LLVMFuzzerTestOneInput:
   68|     34|LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
   69|       |  /* Need: mode byte + method byte + at least a few option-payload bytes. */
   70|     34|  if (size < 8)
  ------------------
  |  Branch (70:7): [True: 4, False: 30]
  ------------------
   71|      4|    return 0;
   72|       |
   73|     30|  coap_context_t *ctx = NULL;
   74|     30|  coap_session_t *req_session = NULL;
   75|     30|  coap_resource_t *resource = NULL;
   76|     30|  coap_pdu_t *request = NULL;
   77|     30|  coap_pdu_t *response = NULL;
   78|     30|  coap_address_t addr;
   79|       |
   80|     30|  const uint8_t mode = data[0];
   81|     30|  const uint8_t method_byte = data[1];
   82|       |
   83|     30|  coap_startup();
   84|     30|  coap_set_log_level(COAP_LOG_EMERG);
   85|     30|  coap_dtls_set_log_level(COAP_LOG_EMERG);
   86|     30|  coap_debug_set_packet_loss("100%");
   87|     30|  coap_debug_set_packet_fail("100%");
   88|       |
   89|     30|  ctx = coap_new_context(NULL);
   90|     30|  if (!ctx)
  ------------------
  |  Branch (90:7): [True: 0, False: 30]
  ------------------
   91|      0|    goto cleanup;
   92|     30|  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|     30|  static const coap_proxy_t types[8] = {
  108|     30|    COAP_PROXY_FWD_STATIC,
  109|     30|    COAP_PROXY_FWD_STATIC | COAP_PROXY_BIT_STRIP,
  110|     30|    COAP_PROXY_FWD_DYNAMIC,
  111|     30|    COAP_PROXY_FWD_DYNAMIC | COAP_PROXY_BIT_STRIP,
  112|     30|    COAP_PROXY_FWD_DYNAMIC | COAP_PROXY_BIT_MCAST,
  113|     30|    COAP_PROXY_FWD_DYNAMIC | COAP_PROXY_DYN_DEFINED,
  114|     30|    COAP_PROXY_REV,
  115|     30|    COAP_PROXY_REV | COAP_PROXY_BIT_STRIP,
  116|     30|  };
  117|     30|  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|     30|  coap_proxy_server_t static_entry;
  122|     30|  memset(&static_entry, 0, sizeof(static_entry));
  123|     30|  static_entry.uri.scheme = COAP_URI_SCHEME_COAP;
  124|     30|  static_entry.uri.host.s = (const uint8_t *)"127.0.0.1";
  125|     30|  static_entry.uri.host.length = 9;
  126|     30|  static_entry.uri.port = 0; /* Picks something the OS will quietly drop. */
  127|       |
  128|     30|  coap_proxy_server_list_t server_list;
  129|     30|  memset(&server_list, 0, sizeof(server_list));
  130|     30|  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|     30|  coap_proxy_t base_type = selected_type & COAP_PROXY_NEW_MASK;
  ------------------
  |  |   92|     30|#define COAP_PROXY_NEW_MASK 0x38 /**< Space used in coap_proxy_t for new types */
  ------------------
  135|     30|  if (base_type == COAP_PROXY_FWD_STATIC || base_type == COAP_PROXY_REV) {
  ------------------
  |  Branch (135:7): [True: 11, False: 19]
  |  Branch (135:45): [True: 2, False: 17]
  ------------------
  136|     13|    server_list.entry = &static_entry;
  137|     13|    server_list.entry_count = 1;
  138|     13|  }
  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|     30|  coap_address_init(&addr);
  144|     30|  addr.addr.sin.sin_family = AF_INET;
  145|     30|  addr.addr.sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
  146|     30|  addr.addr.sin.sin_port = htons(5683);
  147|     30|  req_session = coap_new_client_session(ctx, NULL, &addr, COAP_PROTO_UDP);
  148|     30|  if (!req_session)
  ------------------
  |  Branch (148:7): [True: 0, False: 30]
  ------------------
  149|      0|    goto cleanup;
  150|     30|  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|     30|  resource = coap_resource_proxy_uri_init2(proxy_fuzz_handler, 0, NULL, 0);
  157|     30|  if (!resource)
  ------------------
  |  Branch (157:7): [True: 0, False: 30]
  ------------------
  158|      0|    goto cleanup;
  159|     30|  coap_add_resource(ctx, resource);
  160|       |
  161|       |  /* Build the request PDU. */
  162|     30|  const coap_pdu_code_t methods[8] = {
  163|     30|    COAP_REQUEST_CODE_GET,   COAP_REQUEST_CODE_POST,
  164|     30|    COAP_REQUEST_CODE_PUT,   COAP_REQUEST_CODE_DELETE,
  165|     30|    COAP_REQUEST_CODE_FETCH, COAP_REQUEST_CODE_PATCH,
  166|     30|    COAP_REQUEST_CODE_IPATCH, COAP_REQUEST_CODE_GET,
  167|     30|  };
  168|     30|  coap_pdu_type_t pdu_type = (mode & 0x01) ? COAP_MESSAGE_NON : COAP_MESSAGE_CON;
  ------------------
  |  Branch (168:30): [True: 10, False: 20]
  ------------------
  169|     30|  size_t max_pdu = coap_session_max_pdu_size(req_session);
  170|     30|  request = coap_pdu_init(pdu_type, methods[method_byte & 0x07],
  171|     30|                          coap_new_message_id(req_session), max_pdu);
  172|     30|  if (!request)
  ------------------
  |  Branch (172:7): [True: 0, False: 30]
  ------------------
  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|     30|  const uint8_t token[4] = { data[2], data[3], data[4], data[5] };
  178|     30|  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|     30|  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|     30|  {
  190|     30|    size_t n;
  191|     30|    const uint8_t *p = proxy_take(&c, 32, &n);
  192|     30|    if (n)
  ------------------
  |  Branch (192:9): [True: 30, False: 0]
  ------------------
  193|     30|      coap_add_option(request, COAP_OPTION_URI_HOST, n, p);
  194|     30|  }
  195|       |
  196|       |  /* URI-Port (option 7). 2 bytes max, encodes as a CoAP varint internally. */
  197|     30|  {
  198|     30|    size_t n;
  199|     30|    const uint8_t *p = proxy_take(&c, 2, &n);
  200|     30|    if (n)
  ------------------
  |  Branch (200:9): [True: 17, False: 13]
  ------------------
  201|     17|      coap_add_option(request, COAP_OPTION_URI_PORT, n, p);
  202|     30|  }
  203|       |
  204|       |  /* URI-Path (option 11) — a couple of segments to drive option-walk code. */
  205|     90|  for (int i = 0; i < 2; i++) {
  ------------------
  |  Branch (205:19): [True: 60, False: 30]
  ------------------
  206|     60|    size_t n;
  207|     60|    const uint8_t *p = proxy_take(&c, 16, &n);
  208|     60|    if (n)
  ------------------
  |  Branch (208:9): [True: 33, False: 27]
  ------------------
  209|     33|      coap_add_option(request, COAP_OPTION_URI_PATH, n, p);
  210|     60|  }
  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|     30|  uint8_t submode = (mode >> 5) & 0x03;
  219|       |
  220|     30|  if (submode == 0 || submode == 2) {
  ------------------
  |  Branch (220:7): [True: 10, False: 20]
  |  Branch (220:23): [True: 11, False: 9]
  ------------------
  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|     21|    size_t n;
  225|     21|    const uint8_t *p = proxy_take(&c, 9, &n);
  226|     21|    if (n)
  ------------------
  |  Branch (226:9): [True: 15, False: 6]
  ------------------
  227|     15|      coap_add_option(request, COAP_OPTION_PROXY_SCHEME, n, p);
  228|     21|  }
  229|     30|  if (submode == 1 || submode == 2) {
  ------------------
  |  Branch (229:7): [True: 5, False: 25]
  |  Branch (229:23): [True: 11, 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|     16|    size_t n;
  233|     16|    const uint8_t *p = proxy_take(&c, 256, &n);
  234|     16|    if (n)
  ------------------
  |  Branch (234:9): [True: 10, False: 6]
  ------------------
  235|     10|      coap_add_option(request, COAP_OPTION_PROXY_URI, n, p);
  236|     16|  }
  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|     30|  if ((mode >> 7) & 0x01) {
  ------------------
  |  Branch (240:7): [True: 11, False: 19]
  ------------------
  241|     11|    size_t n;
  242|     11|    const uint8_t *p = proxy_take(&c, 4, &n);
  243|     11|    if (n)
  ------------------
  |  Branch (243:9): [True: 5, False: 6]
  ------------------
  244|      5|      coap_add_option(request, COAP_OPTION_OBSERVE, n, p);
  245|     11|  }
  246|       |
  247|       |  /* Remaining bytes become the request body. */
  248|     30|  {
  249|     30|    size_t n;
  250|     30|    const uint8_t *p = proxy_take(&c, c.size > c.pos ? c.size - c.pos : 0, &n);
  ------------------
  |  Branch (250:39): [True: 14, False: 16]
  ------------------
  251|     30|    if (n)
  ------------------
  |  Branch (251:9): [True: 14, False: 16]
  ------------------
  252|     14|      coap_add_data(request, n, p);
  253|     30|  }
  254|       |
  255|       |  /* Response PDU the proxy fills in (with an error code on failure). */
  256|     30|  response = coap_pdu_init(COAP_MESSAGE_ACK, 0,
  257|     30|                           coap_new_message_id(req_session), max_pdu);
  258|     30|  if (!response)
  ------------------
  |  Branch (258:7): [True: 0, False: 30]
  ------------------
  259|      0|    goto cleanup;
  260|       |
  261|       |  /* The single API call we're here to fuzz. */
  262|     30|  coap_proxy_forward_request(req_session, request, response, resource, NULL,
  263|     30|                             &server_list);
  264|       |
  265|     30|cleanup:
  266|     30|  if (request)
  ------------------
  |  Branch (266:7): [True: 30, False: 0]
  ------------------
  267|     30|    coap_delete_pdu(request);
  268|     30|  if (response)
  ------------------
  |  Branch (268:7): [True: 30, False: 0]
  ------------------
  269|     30|    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|     30|  if (ctx)
  ------------------
  |  Branch (272:7): [True: 30, False: 0]
  ------------------
  273|     30|    coap_free_context(ctx);
  274|     30|  coap_cleanup();
  275|     30|  return 0;
  276|     30|}
proxy_target.c:proxy_take:
   58|    198|proxy_take(proxy_cursor_t *c, size_t max, size_t *out_len) {
   59|    198|  size_t avail = c->size > c->pos ? c->size - c->pos : 0;
  ------------------
  |  Branch (59:18): [True: 124, False: 74]
  ------------------
   60|    198|  size_t take = avail < max ? avail : max;
  ------------------
  |  Branch (60:17): [True: 74, False: 124]
  ------------------
   61|    198|  const uint8_t *p = c->data + c->pos;
   62|    198|  c->pos += take;
   63|    198|  *out_len = take;
   64|    198|  return p;
   65|    198|}

