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

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

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

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

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

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

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

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

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

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

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

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

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

coap_dtls_is_supported:
  191|     32|coap_dtls_is_supported(void) {
  192|     32|  if (SSLeay() < 0x10100000L) {
  ------------------
  |  Branch (192:7): [True: 0, False: 32]
  ------------------
  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|     32|#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|     32|  if (SSLeay() < 0x10101000L) {
  ------------------
  |  Branch (204:7): [True: 0, False: 32]
  ------------------
  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|     32|#endif /* OPENSSL_VERSION_NUMBER >= 0x10101000L */
  209|     32|  return 1;
  210|     32|}
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:
 1159|     30|coap_dtls_new_context(coap_context_t *coap_context) {
 1160|     30|  coap_openssl_context_t *context;
 1161|     30|  (void)coap_context;
 1162|       |
 1163|     30|  context = (coap_openssl_context_t *)coap_malloc_type(COAP_STRING, sizeof(coap_openssl_context_t));
 1164|     30|  if (context) {
  ------------------
  |  Branch (1164:7): [True: 30, False: 0]
  ------------------
 1165|     30|    uint8_t cookie_secret[32];
 1166|       |
 1167|     30|    memset(context, 0, sizeof(coap_openssl_context_t));
 1168|       |
 1169|       |    /* Set up DTLS context */
 1170|     30|    context->dtls.ctx = SSL_CTX_new(DTLS_method());
 1171|     30|    if (!context->dtls.ctx)
  ------------------
  |  Branch (1171:9): [True: 0, False: 30]
  ------------------
 1172|      0|      goto error;
 1173|     30|    SSL_CTX_set_min_proto_version(context->dtls.ctx, DTLS1_2_VERSION);
 1174|     30|    SSL_CTX_set_app_data(context->dtls.ctx, &context->dtls);
 1175|     30|    SSL_CTX_set_read_ahead(context->dtls.ctx, 1);
 1176|     30|    coap_set_user_prefs(context->dtls.ctx);
 1177|     30|    memset(cookie_secret, 0, sizeof(cookie_secret));
 1178|     30|    if (!RAND_bytes(cookie_secret, (int)sizeof(cookie_secret))) {
  ------------------
  |  Branch (1178:9): [True: 0, False: 30]
  ------------------
 1179|      0|      coap_dtls_log(COAP_LOG_WARN,
  ------------------
  |  |  306|      0|#define coap_dtls_log(level, ...) do { \
  |  |  307|      0|    if ((int)((level))<=(int)coap_dtls_get_log_level()) \
  |  |  ------------------
  |  |  |  Branch (307:9): [True: 0, False: 0]
  |  |  ------------------
  |  |  308|      0|      coap_log_impl((level)+COAP_LOG_DTLS_BASE, __VA_ARGS__); \
  |  |  309|      0|  } while(0)
  |  |  ------------------
  |  |  |  Branch (309:11): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1180|      0|                    "Insufficient entropy for random cookie generation");
 1181|      0|      coap_prng_lkd(cookie_secret, sizeof(cookie_secret));
 1182|      0|    }
 1183|     30|    context->dtls.cookie_hmac = HMAC_CTX_new();
 1184|     30|    if (!context->dtls.cookie_hmac)
  ------------------
  |  Branch (1184:9): [True: 0, False: 30]
  ------------------
 1185|      0|      goto error;
 1186|     30|    if (!HMAC_Init_ex(context->dtls.cookie_hmac, cookie_secret, (int)sizeof(cookie_secret),
  ------------------
  |  Branch (1186:9): [True: 0, False: 30]
  ------------------
 1187|     30|                      EVP_sha256(), NULL))
 1188|      0|      goto error;
 1189|     30|    SSL_CTX_set_cookie_generate_cb(context->dtls.ctx, coap_dtls_generate_cookie);
 1190|     30|    SSL_CTX_set_cookie_verify_cb(context->dtls.ctx, coap_dtls_verify_cookie);
 1191|     30|    SSL_CTX_set_info_callback(context->dtls.ctx, coap_dtls_info_callback);
 1192|     30|    SSL_CTX_set_options(context->dtls.ctx, SSL_OP_NO_QUERY_MTU);
 1193|       |#if OPENSSL_VERSION_NUMBER >= 0x30000000L
 1194|       |    SSL_CTX_set_options(context->dtls.ctx, SSL_OP_LEGACY_SERVER_CONNECT);
 1195|       |#endif /* OPENSSL_VERSION_NUMBER >= 0x30000000L */
 1196|     30|    context->dtls.meth = BIO_meth_new(BIO_TYPE_DGRAM, "coapdgram");
 1197|     30|    if (!context->dtls.meth)
  ------------------
  |  Branch (1197:9): [True: 0, False: 30]
  ------------------
 1198|      0|      goto error;
 1199|     30|    context->dtls.bio_addr = BIO_ADDR_new();
 1200|     30|    if (!context->dtls.bio_addr)
  ------------------
  |  Branch (1200:9): [True: 0, False: 30]
  ------------------
 1201|      0|      goto error;
 1202|     30|    BIO_meth_set_write(context->dtls.meth, coap_dgram_write);
 1203|     30|    BIO_meth_set_read(context->dtls.meth, coap_dgram_read);
 1204|     30|    BIO_meth_set_puts(context->dtls.meth, coap_dgram_puts);
 1205|     30|    BIO_meth_set_ctrl(context->dtls.meth, coap_dgram_ctrl);
 1206|     30|    BIO_meth_set_create(context->dtls.meth, coap_dgram_create);
 1207|     30|    BIO_meth_set_destroy(context->dtls.meth, coap_dgram_destroy);
 1208|       |
 1209|     30|#if !COAP_DISABLE_TCP
 1210|       |    /* Set up TLS context */
 1211|     30|    context->tls.ctx = SSL_CTX_new(TLS_method());
 1212|     30|    if (!context->tls.ctx)
  ------------------
  |  Branch (1212:9): [True: 0, False: 30]
  ------------------
 1213|      0|      goto error;
 1214|     30|    SSL_CTX_set_app_data(context->tls.ctx, &context->tls);
 1215|     30|    SSL_CTX_set_min_proto_version(context->tls.ctx, TLS1_VERSION);
 1216|     30|    coap_set_user_prefs(context->tls.ctx);
 1217|     30|    SSL_CTX_set_info_callback(context->tls.ctx, coap_dtls_info_callback);
 1218|     30|    context->tls.meth = BIO_meth_new(BIO_TYPE_SOCKET, "coapsock");
 1219|     30|    if (!context->tls.meth)
  ------------------
  |  Branch (1219:9): [True: 0, False: 30]
  ------------------
 1220|      0|      goto error;
 1221|     30|    BIO_meth_set_write(context->tls.meth, coap_sock_write);
 1222|     30|    BIO_meth_set_read(context->tls.meth, coap_sock_read);
 1223|     30|    BIO_meth_set_puts(context->tls.meth, coap_sock_puts);
 1224|     30|    BIO_meth_set_ctrl(context->tls.meth, coap_sock_ctrl);
 1225|     30|    BIO_meth_set_create(context->tls.meth, coap_sock_create);
 1226|     30|    BIO_meth_set_destroy(context->tls.meth, coap_sock_destroy);
 1227|     30|#endif /* !COAP_DISABLE_TCP */
 1228|     30|  }
 1229|       |
 1230|     30|  return context;
 1231|       |
 1232|      0|error:
 1233|      0|  coap_dtls_free_context(context);
 1234|       |  return NULL;
 1235|     30|}
coap_dtls_free_context:
 3428|     30|coap_dtls_free_context(void *handle) {
 3429|     30|  size_t i;
 3430|     30|  coap_openssl_context_t *context = (coap_openssl_context_t *)handle;
 3431|       |
 3432|     30|  if (context->dtls.ssl)
  ------------------
  |  Branch (3432:7): [True: 0, False: 30]
  ------------------
 3433|      0|    SSL_free(context->dtls.ssl);
 3434|     30|  if (context->dtls.ctx)
  ------------------
  |  Branch (3434:7): [True: 30, False: 0]
  ------------------
 3435|     30|    SSL_CTX_free(context->dtls.ctx);
 3436|     30|  if (context->dtls.cookie_hmac)
  ------------------
  |  Branch (3436:7): [True: 30, False: 0]
  ------------------
 3437|     30|    HMAC_CTX_free(context->dtls.cookie_hmac);
 3438|     30|  if (context->dtls.meth)
  ------------------
  |  Branch (3438:7): [True: 30, False: 0]
  ------------------
 3439|     30|    BIO_meth_free(context->dtls.meth);
 3440|     30|  if (context->dtls.bio_addr)
  ------------------
  |  Branch (3440:7): [True: 30, False: 0]
  ------------------
 3441|     30|    BIO_ADDR_free(context->dtls.bio_addr);
 3442|     30|#if !COAP_DISABLE_TCP
 3443|     30|  if (context->tls.ctx)
  ------------------
  |  Branch (3443:7): [True: 30, False: 0]
  ------------------
 3444|     30|    SSL_CTX_free(context->tls.ctx);
 3445|     30|  if (context->tls.meth)
  ------------------
  |  Branch (3445:7): [True: 30, False: 0]
  ------------------
 3446|     30|    BIO_meth_free(context->tls.meth);
 3447|     30|#endif /* !COAP_DISABLE_TCP */
 3448|     30|  for (i = 0; i < context->sni_count; i++) {
  ------------------
  |  Branch (3448:15): [True: 0, False: 30]
  ------------------
 3449|      0|    OPENSSL_free(context->sni_entry_list[i].sni);
 3450|       |#if OPENSSL_VERSION_NUMBER < 0x10101000L
 3451|       |    SSL_CTX_free(context->sni_entry_list[i].ctx);
 3452|       |#endif /* OPENSSL_VERSION_NUMBER < 0x10101000L */
 3453|      0|  }
 3454|     30|  if (context->sni_count)
  ------------------
  |  Branch (3454:7): [True: 0, False: 30]
  ------------------
 3455|     30|    OPENSSL_free(context->sni_entry_list);
 3456|       |#if OPENSSL_VERSION_NUMBER < 0x10101000L
 3457|       |  for (i = 0; i < context->psk_sni_count; i++) {
 3458|       |    OPENSSL_free((char *)context->psk_sni_entry_list[i].sni);
 3459|       |    SSL_CTX_free(context->psk_sni_entry_list[i].ctx);
 3460|       |  }
 3461|       |  if (context->psk_sni_count)
 3462|       |    OPENSSL_free(context->psk_sni_entry_list);
 3463|       |#endif /* OPENSSL_VERSION_NUMBER < 0x10101000L */
 3464|     30|  coap_free_type(COAP_STRING, context);
 3465|     30|}
coap_openssl.c:coap_set_user_prefs:
 1132|     60|coap_set_user_prefs(SSL_CTX *ctx) {
 1133|     60|  SSL_CTX_set_cipher_list(ctx, COAP_OPENSSL_CIPHERS);
  ------------------
  |  |  119|     60|#define COAP_OPENSSL_CIPHERS "TLSv1.3:TLSv1.2:!NULL"
  ------------------
 1134|       |
 1135|       |#ifdef COAP_OPENSSL_SIGALGS
 1136|       |  SSL_CTX_set1_sigalgs_list(ctx, COAP_OPENSSL_SIGALGS);
 1137|       |  SSL_CTX_set1_client_sigalgs_list(ctx, COAP_OPENSSL_SIGALGS);
 1138|       |#endif
 1139|       |
 1140|       |#if OPENSSL_VERSION_NUMBER >= 0x10101000L && defined(COAP_OPENSSL_GROUPS)
 1141|       |  SSL_CTX_set1_groups_list(ctx, COAP_OPENSSL_GROUPS);
 1142|       |#endif
 1143|     60|}

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

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

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

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

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

coap_resource_proxy_uri_init2:
  335|     30|                              const char *host_name_list[], int flags) {
  336|     30|  coap_resource_t *r;
  337|       |
  338|     30|  r = (coap_resource_t *)coap_malloc_type(COAP_RESOURCE, sizeof(coap_resource_t));
  339|     30|  if (r) {
  ------------------
  |  Branch (339:7): [True: 30, False: 0]
  ------------------
  340|     30|    size_t i;
  341|     30|    memset(r, 0, sizeof(coap_resource_t));
  342|       |#if COAP_THREAD_SAFE
  343|       |    coap_lock_init(&r->lock);
  344|       |#endif /* COAP_THREAD_SAFE */
  345|     30|    r->is_proxy_uri = 1;
  346|       |    /* Something unlikely to be used, but it shows up in the logs */
  347|     30|    r->uri_path = coap_new_str_const(coap_proxy_resource_uri, sizeof(coap_proxy_resource_uri)-1);
  348|       |    /* Preset all the handlers */
  349|    240|    for (i = 0; i < (sizeof(r->handler) / sizeof(r->handler[0])); i++) {
  ------------------
  |  Branch (349:17): [True: 210, False: 30]
  ------------------
  350|    210|      r->handler[i] = handler;
  351|    210|    }
  352|     30|    if (host_name_count) {
  ------------------
  |  Branch (352:9): [True: 0, False: 30]
  ------------------
  353|      0|      r->proxy_name_list = coap_malloc_type(COAP_STRING, host_name_count *
  354|      0|                                            sizeof(coap_str_const_t *));
  355|      0|      if (r->proxy_name_list) {
  ------------------
  |  Branch (355:11): [True: 0, False: 0]
  ------------------
  356|      0|        for (i = 0; i < host_name_count; i++) {
  ------------------
  |  Branch (356:21): [True: 0, False: 0]
  ------------------
  357|      0|          r->proxy_name_list[i] =
  358|      0|              coap_new_str_const((const uint8_t *)host_name_list[i],
  359|      0|                                 strlen(host_name_list[i]));
  360|      0|          if (!r->proxy_name_list[i]) {
  ------------------
  |  Branch (360:15): [True: 0, False: 0]
  ------------------
  361|      0|            coap_log_err("coap_resource_proxy_uri_init: unable to add host name\n");
  ------------------
  |  |  102|      0|#define coap_log_err(...) coap_log(COAP_LOG_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  362|      0|            if (i == 0) {
  ------------------
  |  Branch (362:17): [True: 0, False: 0]
  ------------------
  363|      0|              coap_free_type(COAP_STRING, r->proxy_name_list);
  364|      0|              r->proxy_name_list = NULL;
  365|      0|            }
  366|      0|            break;
  367|      0|          }
  368|      0|        }
  369|      0|        r->proxy_name_count = i;
  370|      0|      }
  371|      0|    }
  372|     30|    r->flags = flags & ~COAP_RESOURCE_FLAGS_RELEASE_URI;
  ------------------
  |  |   55|     30|#define COAP_RESOURCE_FLAGS_RELEASE_URI 0x1
  ------------------
  373|     30|  } else {
  374|      0|    coap_log_debug("coap_resource_proxy_uri_init2: no memory left\n");
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  375|      0|  }
  376|       |
  377|     30|  return r;
  378|     30|}
coap_add_resource:
  544|     30|coap_add_resource(coap_context_t *context, coap_resource_t *resource) {
  545|     30|  coap_lock_lock(return);
  546|     30|  coap_add_resource_lkd(context, resource);
  547|     30|  coap_lock_unlock();
  548|     30|}
coap_add_resource_lkd:
  551|     30|coap_add_resource_lkd(coap_context_t *context, coap_resource_t *resource) {
  552|     30|  coap_lock_check_locked();
  ------------------
  |  |  638|     30|#define coap_lock_check_locked() {}
  ------------------
  553|     30|  if (resource->is_unknown) {
  ------------------
  |  Branch (553:7): [True: 0, False: 30]
  ------------------
  554|      0|    if (context->unknown_resource)
  ------------------
  |  Branch (554:9): [True: 0, False: 0]
  ------------------
  555|      0|      coap_free_resource(context->unknown_resource, COAP_DELETING_RESOURCE);
  556|      0|    context->unknown_resource = resource;
  557|     30|  } else if (resource->is_proxy_uri) {
  ------------------
  |  Branch (557:14): [True: 30, False: 0]
  ------------------
  558|     30|    if (context->proxy_uri_resource)
  ------------------
  |  Branch (558:9): [True: 0, False: 30]
  ------------------
  559|      0|      coap_free_resource(context->proxy_uri_resource, COAP_DELETING_RESOURCE);
  560|     30|    context->proxy_uri_resource = resource;
  561|     30|  } else {
  562|      0|    coap_resource_t *r = coap_get_resource_from_uri_path_lkd(context,
  563|      0|                                                             resource->uri_path);
  564|       |
  565|      0|    if (r) {
  ------------------
  |  Branch (565:9): [True: 0, False: 0]
  ------------------
  566|      0|      coap_log_warn("coap_add_resource: Duplicate uri_path '%*.*s', old resource deleted\n",
  ------------------
  |  |  108|      0|#define coap_log_warn(...) coap_log(COAP_LOG_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  567|      0|                    (int)resource->uri_path->length, (int)resource->uri_path->length,
  568|      0|                    resource->uri_path->s);
  569|      0|      coap_delete_resource_lkd(r);
  570|      0|    }
  571|      0|    RESOURCES_ADD(context->resources, resource);
  ------------------
  |  |  187|      0|  HASH_ADD(hh, (r), uri_path->s[0], (obj)->uri_path->length, (obj))
  |  |  ------------------
  |  |  |  |  442|      0|  HASH_ADD_KEYPTR(hh, head, &((add)->fieldname), keylen_in, add)
  |  |  |  |  ------------------
  |  |  |  |  |  |  431|      0|#define HASH_ADD_KEYPTR(hh,head,keyptr,keylen_in,add)                            \
  |  |  |  |  |  |  432|      0|do {                                                                             \
  |  |  |  |  |  |  433|      0|  uint32_t _ha_hashv;                                                            \
  |  |  |  |  |  |  434|      0|  HASH_VALUE(keyptr, keylen_in, _ha_hashv);                                      \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  162|      0|#define HASH_VALUE(keyptr,keylen,hashv)                                          \
  |  |  |  |  |  |  |  |  163|      0|do {                                                                             \
  |  |  |  |  |  |  |  |  164|      0|  HASH_FUNCTION(keyptr, keylen, hashv);                                          \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  102|      0|#define HASH_FUNCTION(keyptr,keylen,hashv) HASH_JEN(keyptr, keylen, hashv)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  658|      0|#define HASH_JEN(key,keylen,hashv)                                               \
  |  |  |  |  |  |  |  |  |  |  |  |  659|      0|do {                                                                             \
  |  |  |  |  |  |  |  |  |  |  |  |  660|      0|  uint32_t _hj_i,_hj_j,_hj_k;                                                    \
  |  |  |  |  |  |  |  |  |  |  |  |  661|      0|  unsigned const char *_hj_key=(unsigned const char*)(key);                      \
  |  |  |  |  |  |  |  |  |  |  |  |  662|      0|  hashv = 0xfeedbeefu;                                                           \
  |  |  |  |  |  |  |  |  |  |  |  |  663|      0|  _hj_i = _hj_j = 0x9e3779b9u;                                                   \
  |  |  |  |  |  |  |  |  |  |  |  |  664|      0|  _hj_k = (uint32_t)(keylen);                                                    \
  |  |  |  |  |  |  |  |  |  |  |  |  665|      0|  while (_hj_k >= 12U) {                                                         \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (665:10): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  666|      0|    _hj_i = (int64_t)_hj_i + (_hj_key[0] + ( (uint32_t)_hj_key[1] << 8 )         \
  |  |  |  |  |  |  |  |  |  |  |  |  667|      0|        + ( (uint32_t)_hj_key[2] << 16 )                                         \
  |  |  |  |  |  |  |  |  |  |  |  |  668|      0|        + ( (uint32_t)_hj_key[3] << 24 ) );                                      \
  |  |  |  |  |  |  |  |  |  |  |  |  669|      0|    _hj_j = (int64_t)_hj_j + (_hj_key[4] + ( (uint32_t)_hj_key[5] << 8 )         \
  |  |  |  |  |  |  |  |  |  |  |  |  670|      0|        + ( (uint32_t)_hj_key[6] << 16 )                                         \
  |  |  |  |  |  |  |  |  |  |  |  |  671|      0|        + ( (uint32_t)_hj_key[7] << 24 ) );                                      \
  |  |  |  |  |  |  |  |  |  |  |  |  672|      0|    hashv = (int64_t)hashv + (_hj_key[8] + ( (uint32_t)_hj_key[9] << 8 )         \
  |  |  |  |  |  |  |  |  |  |  |  |  673|      0|        + ( (uint32_t)_hj_key[10] << 16 )                                        \
  |  |  |  |  |  |  |  |  |  |  |  |  674|      0|        + ( (uint32_t)_hj_key[11] << 24 ) );                                     \
  |  |  |  |  |  |  |  |  |  |  |  |  675|      0|                                                                                 \
  |  |  |  |  |  |  |  |  |  |  |  |  676|      0|     HASH_JEN_MIX(_hj_i, _hj_j, hashv);                                          \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  645|      0|#define HASH_JEN_MIX(a,b,c)                                                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  646|      0|do {                                                                             \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  647|      0|  a = (int64_t)a - b; a = (int64_t)a - c; a ^= ( c >> 13 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  648|      0|  b = (int64_t)b - c; b = (int64_t)b - a; b ^= ( a << 8 );                       \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  649|      0|  c = (int64_t)c - a; c = (int64_t)c - b; c ^= ( b >> 13 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  650|      0|  a = (int64_t)a - b; a = (int64_t)a - c; a ^= ( c >> 12 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  651|      0|  b = (int64_t)b - c; b = (int64_t)b - a; b ^= ( a << 16 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  652|      0|  c = (int64_t)c - a; c = (int64_t)c - b; c ^= ( b >> 5 );                       \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  653|      0|  a = (int64_t)a - b; a = (int64_t)a - c; a ^= ( c >> 3 );                       \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  654|      0|  b = (int64_t)b - c; b = (int64_t)b - a; b ^= ( a << 10 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  655|      0|  c = (int64_t)c - a; c = (int64_t)c - b; c ^= ( b >> 15 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  656|      0|} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (656:10): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  677|      0|                                                                                 \
  |  |  |  |  |  |  |  |  |  |  |  |  678|      0|     _hj_key += 12;                                                              \
  |  |  |  |  |  |  |  |  |  |  |  |  679|      0|     _hj_k -= 12U;                                                               \
  |  |  |  |  |  |  |  |  |  |  |  |  680|      0|  }                                                                              \
  |  |  |  |  |  |  |  |  |  |  |  |  681|      0|  hashv += (uint32_t)(keylen);                                                   \
  |  |  |  |  |  |  |  |  |  |  |  |  682|      0|  switch ( _hj_k ) {                                                             \
  |  |  |  |  |  |  |  |  |  |  |  |  683|      0|    case 11: hashv = (int64_t)hashv + ( (uint32_t)_hj_key[10] << 24 ); /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (683:5): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  684|      0|    case 10: hashv = (int64_t)hashv + ( (uint32_t)_hj_key[9] << 16 );  /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (684:5): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  685|      0|    case 9:  hashv = (int64_t)hashv + ( (uint32_t)_hj_key[8] << 8 );   /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (685:5): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  686|      0|    case 8:  _hj_j = (int64_t)_hj_j + ( (uint32_t)_hj_key[7] << 24 );  /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (686:5): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  687|      0|    case 7:  _hj_j = (int64_t)_hj_j + ( (uint32_t)_hj_key[6] << 16 );  /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (687:5): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  688|      0|    case 6:  _hj_j = (int64_t)_hj_j + ( (uint32_t)_hj_key[5] << 8 );   /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (688:5): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  689|      0|    case 5:  _hj_j = (int64_t)_hj_j + _hj_key[4];                      /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (689:5): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  690|      0|    case 4:  _hj_i = (int64_t)_hj_i + ( (uint32_t)_hj_key[3] << 24 );  /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (690:5): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  691|      0|    case 3:  _hj_i = (int64_t)_hj_i + ( (uint32_t)_hj_key[2] << 16 );  /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (691:5): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  692|      0|    case 2:  _hj_i = (int64_t)_hj_i + ( (uint32_t)_hj_key[1] << 8 );   /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (692:5): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  693|      0|    case 1:  _hj_i = (int64_t)_hj_i + _hj_key[0];                      /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (693:5): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  694|      0|    default: ;                                                                   \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (694:5): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  695|      0|  }                                                                              \
  |  |  |  |  |  |  |  |  |  |  |  |  696|      0|  HASH_JEN_MIX(_hj_i, _hj_j, hashv);                                             \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  645|      0|#define HASH_JEN_MIX(a,b,c)                                                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  646|      0|do {                                                                             \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  647|      0|  a = (int64_t)a - b; a = (int64_t)a - c; a ^= ( c >> 13 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  648|      0|  b = (int64_t)b - c; b = (int64_t)b - a; b ^= ( a << 8 );                       \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  649|      0|  c = (int64_t)c - a; c = (int64_t)c - b; c ^= ( b >> 13 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  650|      0|  a = (int64_t)a - b; a = (int64_t)a - c; a ^= ( c >> 12 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  651|      0|  b = (int64_t)b - c; b = (int64_t)b - a; b ^= ( a << 16 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  652|      0|  c = (int64_t)c - a; c = (int64_t)c - b; c ^= ( b >> 5 );                       \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  653|      0|  a = (int64_t)a - b; a = (int64_t)a - c; a ^= ( c >> 3 );                       \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  654|      0|  b = (int64_t)b - c; b = (int64_t)b - a; b ^= ( a << 10 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  655|      0|  c = (int64_t)c - a; c = (int64_t)c - b; c ^= ( b >> 15 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  656|      0|} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (656:10): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  697|      0|} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (697:10): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  165|      0|} while (0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (165:10): [Folded, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  435|      0|  HASH_ADD_KEYPTR_BYHASHVALUE(hh, head, keyptr, keylen_in, _ha_hashv, add);      \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  410|      0|#define HASH_ADD_KEYPTR_BYHASHVALUE(hh,head,keyptr,keylen_in,hashval,add)        \
  |  |  |  |  |  |  |  |  411|      0|do {                                                                             \
  |  |  |  |  |  |  |  |  412|      0|  IF_HASH_NONFATAL_OOM( int _ha_oomed = 0; )                                     \
  |  |  |  |  |  |  |  |  413|      0|  (add)->hh.hashv = (hashval);                                                   \
  |  |  |  |  |  |  |  |  414|      0|  (add)->hh.key = (const void*) (keyptr);                                        \
  |  |  |  |  |  |  |  |  415|      0|  (add)->hh.keylen = (uint32_t) (keylen_in);                                     \
  |  |  |  |  |  |  |  |  416|      0|  if (!(head)) {                                                                 \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (416:7): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  417|      0|    (add)->hh.next = NULL;                                                       \
  |  |  |  |  |  |  |  |  418|      0|    (add)->hh.prev = NULL;                                                       \
  |  |  |  |  |  |  |  |  419|      0|    HASH_MAKE_TABLE(hh, add, _ha_oomed);                                         \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  226|      0|#define HASH_MAKE_TABLE(hh,head,oomed)                                           \
  |  |  |  |  |  |  |  |  |  |  227|      0|do {                                                                             \
  |  |  |  |  |  |  |  |  |  |  228|      0|  (head)->hh.tbl = (UT_hash_table*)uthash_malloc(sizeof(UT_hash_table));         \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   89|      0|#define uthash_malloc(sz) malloc(sz)      /* malloc fcn                      */
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  229|      0|  if (!(head)->hh.tbl) {                                                         \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (229:7): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  230|      0|    HASH_RECORD_OOM(oomed);                                                      \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  137|      0|#define HASH_RECORD_OOM(oomed) uthash_fatal("out of memory")
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  134|      0|#define uthash_fatal(msg) exit(-1)        /* fatal OOM error */
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  231|      0|  } else {                                                                       \
  |  |  |  |  |  |  |  |  |  |  232|      0|    uthash_bzero((head)->hh.tbl, sizeof(UT_hash_table));                         \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   95|      0|#define uthash_bzero(a,n) memset(a,'\0',n)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  233|      0|    (head)->hh.tbl->tail = &((head)->hh);                                        \
  |  |  |  |  |  |  |  |  |  |  234|      0|    (head)->hh.tbl->num_buckets = HASH_INITIAL_NUM_BUCKETS;                      \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  143|      0|#define HASH_INITIAL_NUM_BUCKETS 32U     /* initial number of buckets        */
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  235|      0|    (head)->hh.tbl->log2_num_buckets = HASH_INITIAL_NUM_BUCKETS_LOG2;            \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  144|      0|#define HASH_INITIAL_NUM_BUCKETS_LOG2 5U /* lg2 of initial number of buckets */
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  236|      0|    (head)->hh.tbl->hho = (char*)(&(head)->hh) - (char*)(head);                  \
  |  |  |  |  |  |  |  |  |  |  237|      0|    (head)->hh.tbl->buckets = (UT_hash_bucket*)uthash_malloc(                    \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   89|      0|#define uthash_malloc(sz) malloc(sz)      /* malloc fcn                      */
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  238|      0|        HASH_INITIAL_NUM_BUCKETS * sizeof(struct UT_hash_bucket));               \
  |  |  |  |  |  |  |  |  |  |  239|      0|    (head)->hh.tbl->signature = HASH_SIGNATURE;                                  \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  | 1101|      0|#define HASH_SIGNATURE 0xa0111fe1u
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  240|      0|    if (!(head)->hh.tbl->buckets) {                                              \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (240:9): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  241|      0|      HASH_RECORD_OOM(oomed);                                                    \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  137|      0|#define HASH_RECORD_OOM(oomed) uthash_fatal("out of memory")
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  134|      0|#define uthash_fatal(msg) exit(-1)        /* fatal OOM error */
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  242|      0|      uthash_free((head)->hh.tbl, sizeof(UT_hash_table));                        \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   92|      0|#define uthash_free(ptr,sz) free(ptr)     /* free fcn                        */
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  243|      0|    } else {                                                                     \
  |  |  |  |  |  |  |  |  |  |  244|      0|      uthash_bzero((head)->hh.tbl->buckets,                                      \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   95|      0|#define uthash_bzero(a,n) memset(a,'\0',n)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  245|      0|          HASH_INITIAL_NUM_BUCKETS * sizeof(struct UT_hash_bucket));             \
  |  |  |  |  |  |  |  |  |  |  246|      0|      HASH_BLOOM_MAKE((head)->hh.tbl, oomed);                                    \
  |  |  |  |  |  |  |  |  |  |  247|      0|      IF_HASH_NONFATAL_OOM(                                                      \
  |  |  |  |  |  |  |  |  |  |  248|      0|        if (oomed) {                                                             \
  |  |  |  |  |  |  |  |  |  |  249|      0|          uthash_free((head)->hh.tbl->buckets,                                   \
  |  |  |  |  |  |  |  |  |  |  250|      0|              HASH_INITIAL_NUM_BUCKETS*sizeof(struct UT_hash_bucket));           \
  |  |  |  |  |  |  |  |  |  |  251|      0|          uthash_free((head)->hh.tbl, sizeof(UT_hash_table));                    \
  |  |  |  |  |  |  |  |  |  |  252|      0|        }                                                                        \
  |  |  |  |  |  |  |  |  |  |  253|      0|      )                                                                          \
  |  |  |  |  |  |  |  |  |  |  254|      0|    }                                                                            \
  |  |  |  |  |  |  |  |  |  |  255|      0|  }                                                                              \
  |  |  |  |  |  |  |  |  |  |  256|      0|} while (0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (256:10): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  420|      0|    IF_HASH_NONFATAL_OOM( if (!_ha_oomed) { )                                    \
  |  |  |  |  |  |  |  |  421|      0|      (head) = (add);                                                            \
  |  |  |  |  |  |  |  |  422|      0|    IF_HASH_NONFATAL_OOM( } )                                                    \
  |  |  |  |  |  |  |  |  423|      0|  } else {                                                                       \
  |  |  |  |  |  |  |  |  424|      0|    (add)->hh.tbl = (head)->hh.tbl;                                              \
  |  |  |  |  |  |  |  |  425|      0|    HASH_APPEND_LIST(hh, head, add);                                             \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  292|      0|#define HASH_APPEND_LIST(hh, head, add)                                          \
  |  |  |  |  |  |  |  |  |  |  293|      0|do {                                                                             \
  |  |  |  |  |  |  |  |  |  |  294|      0|  (add)->hh.next = NULL;                                                         \
  |  |  |  |  |  |  |  |  |  |  295|      0|  (add)->hh.prev = ELMT_FROM_HH((head)->hh.tbl, (head)->hh.tbl->tail);           \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  148|      0|#define ELMT_FROM_HH(tbl,hhp) ((void*)(((char*)(hhp)) - ((tbl)->hho)))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  296|      0|  (head)->hh.tbl->tail->next = (add);                                            \
  |  |  |  |  |  |  |  |  |  |  297|      0|  (head)->hh.tbl->tail = &((add)->hh);                                           \
  |  |  |  |  |  |  |  |  |  |  298|      0|} while (0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (298:10): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  426|      0|  }                                                                              \
  |  |  |  |  |  |  |  |  427|      0|  HASH_ADD_TO_TABLE(hh, head, keyptr, keylen_in, hashval, add, _ha_oomed);       \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  351|      0|#define HASH_ADD_TO_TABLE(hh,head,keyptr,keylen_in,hashval,add,oomed)            \
  |  |  |  |  |  |  |  |  |  |  352|      0|do {                                                                             \
  |  |  |  |  |  |  |  |  |  |  353|      0|  uint32_t _ha_bkt;                                                              \
  |  |  |  |  |  |  |  |  |  |  354|      0|  (head)->hh.tbl->num_items++;                                                   \
  |  |  |  |  |  |  |  |  |  |  355|      0|  HASH_TO_BKT(hashval, (head)->hh.tbl->num_buckets, _ha_bkt);                    \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  444|      0|#define HASH_TO_BKT(hashv,num_bkts,bkt)                                          \
  |  |  |  |  |  |  |  |  |  |  |  |  445|      0|do {                                                                             \
  |  |  |  |  |  |  |  |  |  |  |  |  446|      0|  bkt = ((hashv) & ((num_bkts) - 1U));                                           \
  |  |  |  |  |  |  |  |  |  |  |  |  447|      0|} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (447:10): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  356|      0|  HASH_ADD_TO_BKT((head)->hh.tbl->buckets[_ha_bkt], hh, &(add)->hh, oomed);      \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  778|      0|#define HASH_ADD_TO_BKT(head,hh,addhh,oomed)                                     \
  |  |  |  |  |  |  |  |  |  |  |  |  779|      0|do {                                                                             \
  |  |  |  |  |  |  |  |  |  |  |  |  780|      0|  UT_hash_bucket *_ha_head = &(head);                                            \
  |  |  |  |  |  |  |  |  |  |  |  |  781|      0|  _ha_head->count++;                                                             \
  |  |  |  |  |  |  |  |  |  |  |  |  782|      0|  (addhh)->hh_next = _ha_head->hh_head;                                          \
  |  |  |  |  |  |  |  |  |  |  |  |  783|      0|  (addhh)->hh_prev = NULL;                                                       \
  |  |  |  |  |  |  |  |  |  |  |  |  784|      0|  if (_ha_head->hh_head != NULL) {                                               \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (784:7): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  785|      0|    _ha_head->hh_head->hh_prev = (addhh);                                        \
  |  |  |  |  |  |  |  |  |  |  |  |  786|      0|  }                                                                              \
  |  |  |  |  |  |  |  |  |  |  |  |  787|      0|  _ha_head->hh_head = (addhh);                                                   \
  |  |  |  |  |  |  |  |  |  |  |  |  788|      0|  if ((_ha_head->count >= ((_ha_head->expand_mult + 1U) * HASH_BKT_CAPACITY_THRESH)) \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  145|      0|#define HASH_BKT_CAPACITY_THRESH 10U     /* expand when bucket count reaches */
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (788:7): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  789|      0|      && !(addhh)->tbl->noexpand) {                                              \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (789:10): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  790|      0|    HASH_EXPAND_BUCKETS(addhh,(addhh)->tbl, oomed);                              \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  844|      0|#define HASH_EXPAND_BUCKETS(hh,tbl,oomed)                                        \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  845|      0|do {                                                                             \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  846|      0|  uint32_t _he_bkt;                                                              \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  847|      0|  uint32_t _he_bkt_i;                                                            \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  848|      0|  struct UT_hash_handle *_he_thh, *_he_hh_nxt;                                   \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  849|      0|  UT_hash_bucket *_he_new_buckets, *_he_newbkt;                                  \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  850|      0|  _he_new_buckets = (UT_hash_bucket*)uthash_malloc(                              \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   89|      0|#define uthash_malloc(sz) malloc(sz)      /* malloc fcn                      */
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  851|      0|           sizeof(struct UT_hash_bucket) * (tbl)->num_buckets * 2U);             \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  852|      0|  if (!_he_new_buckets) {                                                        \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (852:7): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  853|      0|    HASH_RECORD_OOM(oomed);                                                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  137|      0|#define HASH_RECORD_OOM(oomed) uthash_fatal("out of memory")
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  134|      0|#define uthash_fatal(msg) exit(-1)        /* fatal OOM error */
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  854|      0|  } else {                                                                       \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  855|      0|    uthash_bzero(_he_new_buckets,                                                \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   95|      0|#define uthash_bzero(a,n) memset(a,'\0',n)
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  856|      0|        sizeof(struct UT_hash_bucket) * (tbl)->num_buckets * 2U);                \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  857|      0|    (tbl)->ideal_chain_maxlen =                                                  \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  858|      0|       ((tbl)->num_items >> ((tbl)->log2_num_buckets+1U)) +                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  859|      0|       ((((tbl)->num_items & (((tbl)->num_buckets*2U)-1U)) != 0U) ? 1U : 0U);    \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (859:9): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  860|      0|    (tbl)->nonideal_items = 0;                                                   \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  861|      0|    for (_he_bkt_i = 0; _he_bkt_i < (tbl)->num_buckets; _he_bkt_i++) {           \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (861:25): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  862|      0|      _he_thh = (tbl)->buckets[ _he_bkt_i ].hh_head;                             \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  863|      0|      while (_he_thh != NULL) {                                                  \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (863:14): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  864|      0|        _he_hh_nxt = _he_thh->hh_next;                                           \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  865|      0|        HASH_TO_BKT(_he_thh->hashv, (tbl)->num_buckets * 2U, _he_bkt);           \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  444|      0|#define HASH_TO_BKT(hashv,num_bkts,bkt)                                          \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  445|      0|do {                                                                             \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  446|      0|  bkt = ((hashv) & ((num_bkts) - 1U));                                           \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  447|      0|} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (447:10): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  866|      0|        _he_newbkt = &(_he_new_buckets[_he_bkt]);                                \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  867|      0|        if (++(_he_newbkt->count) > (tbl)->ideal_chain_maxlen) {                 \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (867:13): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  868|      0|          (tbl)->nonideal_items++;                                               \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  869|      0|          if (_he_newbkt->count > _he_newbkt->expand_mult * (tbl)->ideal_chain_maxlen) { \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (869:15): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  870|      0|            _he_newbkt->expand_mult++;                                           \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  871|      0|          }                                                                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  872|      0|        }                                                                        \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  873|      0|        _he_thh->hh_prev = NULL;                                                 \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  874|      0|        _he_thh->hh_next = _he_newbkt->hh_head;                                  \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  875|      0|        if (_he_newbkt->hh_head != NULL) {                                       \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (875:13): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  876|      0|          _he_newbkt->hh_head->hh_prev = _he_thh;                                \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  877|      0|        }                                                                        \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  878|      0|        _he_newbkt->hh_head = _he_thh;                                           \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  879|      0|        _he_thh = _he_hh_nxt;                                                    \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  880|      0|      }                                                                          \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  881|      0|    }                                                                            \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  882|      0|    uthash_free((tbl)->buckets, (tbl)->num_buckets * sizeof(struct UT_hash_bucket)); \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   92|      0|#define uthash_free(ptr,sz) free(ptr)     /* free fcn                        */
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  883|      0|    (tbl)->num_buckets *= 2U;                                                    \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  884|      0|    (tbl)->log2_num_buckets++;                                                   \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  885|      0|    (tbl)->buckets = _he_new_buckets;                                            \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  886|      0|    (tbl)->ineff_expands = ((tbl)->nonideal_items > ((tbl)->num_items >> 1)) ?   \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (886:28): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  887|      0|        ((tbl)->ineff_expands+1U) : 0U;                                          \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  888|      0|    if ((tbl)->ineff_expands > 1U) {                                             \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (888:9): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  889|      0|      (tbl)->noexpand = 1;                                                       \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  890|      0|      uthash_noexpand_fyi(tbl);                                                  \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  891|      0|    }                                                                            \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  892|      0|    uthash_expand_fyi(tbl);                                                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  893|      0|  }                                                                              \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  894|      0|} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (894:10): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  791|      0|    IF_HASH_NONFATAL_OOM(                                                        \
  |  |  |  |  |  |  |  |  |  |  |  |  792|      0|      if (oomed) {                                                               \
  |  |  |  |  |  |  |  |  |  |  |  |  793|      0|        HASH_DEL_IN_BKT(head,addhh);                                             \
  |  |  |  |  |  |  |  |  |  |  |  |  794|      0|      }                                                                          \
  |  |  |  |  |  |  |  |  |  |  |  |  795|      0|    )                                                                            \
  |  |  |  |  |  |  |  |  |  |  |  |  796|      0|  }                                                                              \
  |  |  |  |  |  |  |  |  |  |  |  |  797|      0|} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (797:10): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  357|      0|  HASH_BLOOM_ADD((head)->hh.tbl, hashval);                                       \
  |  |  |  |  |  |  |  |  |  |  358|      0|  HASH_EMIT_KEY(hh, head, keyptr, keylen_in);                                    \
  |  |  |  |  |  |  |  |  |  |  359|      0|} while (0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (359:10): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  428|      0|  HASH_FSCK(hh, head, "HASH_ADD_KEYPTR_BYHASHVALUE");                            \
  |  |  |  |  |  |  |  |  429|      0|} while (0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (429:10): [Folded, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  436|      0|} while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (436:10): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  572|      0|#if COAP_WITH_OBSERVE_PERSIST
  573|      0|    if (context->unknown_pdu && context->dyn_resource_save_file &&
  ------------------
  |  Branch (573:9): [True: 0, False: 0]
  |  Branch (573:33): [True: 0, False: 0]
  ------------------
  574|      0|        context->dyn_resource_added_cb && resource->observable) {
  ------------------
  |  Branch (574:9): [True: 0, False: 0]
  |  Branch (574:43): [True: 0, False: 0]
  ------------------
  575|      0|      coap_bin_const_t raw_packet;
  576|       |
  577|      0|      raw_packet.s = context->unknown_pdu->token -
  578|      0|                     context->unknown_pdu->hdr_size;
  579|      0|      raw_packet.length = context->unknown_pdu->used_size +
  580|      0|                          context->unknown_pdu->hdr_size;
  581|      0|      coap_lock_callback(context->dyn_resource_added_cb(context->unknown_session,
  ------------------
  |  |  651|      0|#define coap_lock_callback(func) func
  ------------------
  582|      0|                                                        resource->uri_path,
  583|      0|                                                        &raw_packet,
  584|      0|                                                        context->observe_user_data));
  585|      0|    }
  586|      0|#endif /* COAP_WITH_OBSERVE_PERSIST */
  587|      0|  }
  588|     30|  assert(resource->context == NULL);
  ------------------
  |  Branch (588:3): [True: 30, False: 0]
  ------------------
  589|     30|  resource->context = context;
  590|     30|}
coap_delete_resource_lkd:
  610|     30|coap_delete_resource_lkd(coap_resource_t *resource) {
  611|     30|  coap_context_t *context;
  612|     30|  coap_deleting_resource_t deleting;
  613|       |
  614|     30|  if (!resource)
  ------------------
  |  Branch (614:7): [True: 0, False: 30]
  ------------------
  615|      0|    return 0;
  616|       |
  617|     30|  context = resource->context;
  618|     30|  coap_lock_check_locked();
  ------------------
  |  |  638|     30|#define coap_lock_check_locked() {}
  ------------------
  619|       |
  620|     30|  if (resource->ref) {
  ------------------
  |  Branch (620:7): [True: 0, False: 30]
  ------------------
  621|      0|    resource->ref--;
  622|      0|    return 1;
  623|      0|  }
  624|     30|  if (context && context->context_going_away) {
  ------------------
  |  Branch (624:7): [True: 30, False: 0]
  |  Branch (624:18): [True: 30, False: 0]
  ------------------
  625|     30|    deleting = COAP_DELETING_RESOURCE_ON_EXIT;
  626|     30|  } else {
  627|      0|    deleting = COAP_DELETING_RESOURCE;
  628|      0|  }
  629|     30|  if (resource->is_unknown) {
  ------------------
  |  Branch (629:7): [True: 0, False: 30]
  ------------------
  630|      0|    if (context && context->unknown_resource == resource) {
  ------------------
  |  Branch (630:9): [True: 0, False: 0]
  |  Branch (630:20): [True: 0, False: 0]
  ------------------
  631|      0|      context->unknown_resource = NULL;
  632|      0|    }
  633|     30|  } else if (resource->is_proxy_uri) {
  ------------------
  |  Branch (633:14): [True: 30, False: 0]
  ------------------
  634|     30|    if (context && context->proxy_uri_resource == resource) {
  ------------------
  |  Branch (634:9): [True: 30, False: 0]
  |  Branch (634:20): [True: 30, False: 0]
  ------------------
  635|     30|      context->proxy_uri_resource = NULL;
  636|     30|    }
  637|     30|  } else if (context) {
  ------------------
  |  Branch (637:14): [True: 0, False: 0]
  ------------------
  638|       |    /* remove resource from list */
  639|      0|    RESOURCES_DELETE(context->resources, resource);
  ------------------
  |  |  190|      0|  HASH_DELETE(hh, (r), (obj))
  |  |  ------------------
  |  |  |  |  462|      0|    HASH_DELETE_HH(hh, head, &(delptr)->hh)
  |  |  |  |  ------------------
  |  |  |  |  |  |  464|      0|#define HASH_DELETE_HH(hh,head,delptrhh)                                         \
  |  |  |  |  |  |  465|      0|do {                                                                             \
  |  |  |  |  |  |  466|      0|  struct UT_hash_handle *_hd_hh_del = (delptrhh);                                \
  |  |  |  |  |  |  467|      0|  if ((_hd_hh_del->prev == NULL) && (_hd_hh_del->next == NULL)) {                \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (467:7): [True: 0, False: 0]
  |  |  |  |  |  |  |  Branch (467:37): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  468|      0|    HASH_BLOOM_FREE((head)->hh.tbl);                                             \
  |  |  |  |  |  |  469|      0|    uthash_free((head)->hh.tbl->buckets,                                         \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   92|      0|#define uthash_free(ptr,sz) free(ptr)     /* free fcn                        */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  470|      0|                (head)->hh.tbl->num_buckets * sizeof(struct UT_hash_bucket));    \
  |  |  |  |  |  |  471|      0|    uthash_free((head)->hh.tbl, sizeof(UT_hash_table));                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   92|      0|#define uthash_free(ptr,sz) free(ptr)     /* free fcn                        */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  472|      0|    (head) = NULL;                                                               \
  |  |  |  |  |  |  473|      0|  } else {                                                                       \
  |  |  |  |  |  |  474|      0|    uint32_t _hd_bkt;                                                            \
  |  |  |  |  |  |  475|      0|    if (_hd_hh_del == (head)->hh.tbl->tail) {                                    \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (475:9): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  476|      0|      (head)->hh.tbl->tail = HH_FROM_ELMT((head)->hh.tbl, _hd_hh_del->prev);     \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  150|      0|#define HH_FROM_ELMT(tbl,elp) ((UT_hash_handle*)(void*)(((char*)(elp)) + ((tbl)->hho)))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  477|      0|    }                                                                            \
  |  |  |  |  |  |  478|      0|    if (_hd_hh_del->prev != NULL) {                                              \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (478:9): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  479|      0|      HH_FROM_ELMT((head)->hh.tbl, _hd_hh_del->prev)->next = _hd_hh_del->next;   \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  150|      0|#define HH_FROM_ELMT(tbl,elp) ((UT_hash_handle*)(void*)(((char*)(elp)) + ((tbl)->hho)))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  480|      0|    } else {                                                                     \
  |  |  |  |  |  |  481|      0|      DECLTYPE_ASSIGN(head, _hd_hh_del->next);                                   \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   78|      0|#define DECLTYPE_ASSIGN(dst,src)                                                 \
  |  |  |  |  |  |  |  |   79|      0|do {                                                                             \
  |  |  |  |  |  |  |  |   80|      0|  (dst) = DECLTYPE(dst)(src);                                                    \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   66|      0|#define DECLTYPE(x) (__typeof(x))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   81|      0|} while (0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (81:10): [Folded, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  482|      0|    }                                                                            \
  |  |  |  |  |  |  483|      0|    if (_hd_hh_del->next != NULL) {                                              \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (483:9): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  484|      0|      HH_FROM_ELMT((head)->hh.tbl, _hd_hh_del->next)->prev = _hd_hh_del->prev;   \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  150|      0|#define HH_FROM_ELMT(tbl,elp) ((UT_hash_handle*)(void*)(((char*)(elp)) + ((tbl)->hho)))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  485|      0|    }                                                                            \
  |  |  |  |  |  |  486|      0|    HASH_TO_BKT(_hd_hh_del->hashv, (head)->hh.tbl->num_buckets, _hd_bkt);        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  444|      0|#define HASH_TO_BKT(hashv,num_bkts,bkt)                                          \
  |  |  |  |  |  |  |  |  445|      0|do {                                                                             \
  |  |  |  |  |  |  |  |  446|      0|  bkt = ((hashv) & ((num_bkts) - 1U));                                           \
  |  |  |  |  |  |  |  |  447|      0|} while (0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (447:10): [Folded, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  487|      0|    HASH_DEL_IN_BKT((head)->hh.tbl->buckets[_hd_bkt], _hd_hh_del);               \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  800|      0|#define HASH_DEL_IN_BKT(head,delhh)                                              \
  |  |  |  |  |  |  |  |  801|      0|do {                                                                             \
  |  |  |  |  |  |  |  |  802|      0|  UT_hash_bucket *_hd_head = &(head);                                            \
  |  |  |  |  |  |  |  |  803|      0|  _hd_head->count--;                                                             \
  |  |  |  |  |  |  |  |  804|      0|  if (_hd_head->hh_head == (delhh)) {                                            \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (804:7): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  805|      0|    _hd_head->hh_head = (delhh)->hh_next;                                        \
  |  |  |  |  |  |  |  |  806|      0|  }                                                                              \
  |  |  |  |  |  |  |  |  807|      0|  if ((delhh)->hh_prev) {                                                        \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (807:7): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  808|      0|    (delhh)->hh_prev->hh_next = (delhh)->hh_next;                                \
  |  |  |  |  |  |  |  |  809|      0|  }                                                                              \
  |  |  |  |  |  |  |  |  810|      0|  if ((delhh)->hh_next) {                                                        \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (810:7): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  811|      0|    (delhh)->hh_next->hh_prev = (delhh)->hh_prev;                                \
  |  |  |  |  |  |  |  |  812|      0|  }                                                                              \
  |  |  |  |  |  |  |  |  813|      0|} while (0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (813:10): [Folded, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  488|      0|    (head)->hh.tbl->num_items--;                                                 \
  |  |  |  |  |  |  489|      0|  }                                                                              \
  |  |  |  |  |  |  490|      0|  HASH_FSCK(hh, head, "HASH_DELETE_HH");                                         \
  |  |  |  |  |  |  491|      0|} while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (491:10): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  640|      0|  }
  641|     30|  if (resource->is_dynamic) {
  ------------------
  |  Branch (641:7): [True: 0, False: 30]
  ------------------
  642|      0|    if (context) {
  ------------------
  |  Branch (642:9): [True: 0, False: 0]
  ------------------
  643|      0|      assert(context->dynamic_cur);
  ------------------
  |  Branch (643:7): [True: 0, False: 0]
  ------------------
  644|      0|      context->dynamic_cur--;
  645|      0|    }
  646|      0|  }
  647|       |
  648|       |  /* and free its allocated memory */
  649|     30|  coap_free_resource(resource, deleting);
  650|       |
  651|     30|  return 1;
  652|     30|}
coap_delete_all_resources:
  655|     30|coap_delete_all_resources(coap_context_t *context) {
  656|     30|  coap_resource_t *r;
  657|     30|  coap_resource_t *tmp;
  658|       |
  659|     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]
  |  |  ------------------
  ------------------
  660|      0|    coap_delete_resource_lkd(r);
  661|      0|  }
  662|       |
  663|     30|  context->resources = NULL;
  664|       |
  665|     30|  if (context->unknown_resource) {
  ------------------
  |  Branch (665:7): [True: 0, False: 30]
  ------------------
  666|      0|    coap_delete_resource_lkd(context->unknown_resource);
  667|      0|    context->unknown_resource = NULL;
  668|      0|  }
  669|     30|  if (context->proxy_uri_resource) {
  ------------------
  |  Branch (669:7): [True: 30, False: 0]
  ------------------
  670|     30|    coap_delete_resource_lkd(context->proxy_uri_resource);
  671|       |    context->proxy_uri_resource = NULL;
  672|     30|  }
  673|     30|}
coap_resource_notify_observers_lkd:
 1434|     30|                                   coap_deleting_resource_t deleting) {
 1435|     30|  coap_lock_check_locked();
  ------------------
  |  |  638|     30|#define coap_lock_check_locked() {}
  ------------------
 1436|     30|  if (!r->observable)
  ------------------
  |  Branch (1436:7): [True: 30, False: 0]
  ------------------
 1437|     30|    return 0;
 1438|      0|  if (!r->subscribers)
  ------------------
  |  Branch (1438:7): [True: 0, False: 0]
  ------------------
 1439|      0|    return 0;
 1440|      0|  r->dirty = 1;
 1441|       |
 1442|       |  /* Increment value for next Observe use. Observe value must be < 2^24 */
 1443|      0|  r->observe = (r->observe + 1) & 0xFFFFFF;
 1444|       |
 1445|      0|  assert(r->context);
  ------------------
  |  Branch (1445:3): [True: 0, False: 0]
  ------------------
 1446|       |
 1447|      0|  if (r->context->track_observe_value_cb) {
  ------------------
  |  Branch (1447:7): [True: 0, False: 0]
  ------------------
 1448|       |    /* Track last used observe value */
 1449|      0|    if ((r->observe % r->context->observe_save_freq) == 0)
  ------------------
  |  Branch (1449:9): [True: 0, False: 0]
  ------------------
 1450|      0|      coap_lock_callback(r->context->track_observe_value_cb(r->context, r->uri_path,
  ------------------
  |  |  651|      0|#define coap_lock_callback(func) func
  ------------------
 1451|      0|                                                            r->observe,
 1452|      0|                                                            r->context->observe_user_data));
 1453|      0|  }
 1454|       |
 1455|      0|  coap_notify_observers(r->context, r, deleting);
 1456|      0|  return 1;
 1457|      0|}
coap_resource.c:coap_free_resource:
  497|     30|coap_free_resource(coap_resource_t *resource, coap_deleting_resource_t deleting) {
  498|     30|  coap_attr_t *attr, *tmp;
  499|     30|  coap_subscription_t *obs, *otmp;
  500|     30|  coap_context_t *context;
  501|       |
  502|     30|  assert(resource);
  ------------------
  |  Branch (502:3): [True: 30, False: 0]
  ------------------
  503|       |
  504|     30|  context = resource->context;
  505|     30|  if (context) {
  ------------------
  |  Branch (505:7): [True: 30, False: 0]
  ------------------
  506|     30|    if (!context->observe_no_clear) {
  ------------------
  |  Branch (506:9): [True: 30, False: 0]
  ------------------
  507|     30|      coap_resource_notify_observers_lkd(resource, deleting);
  508|     30|      coap_notify_observers(context, resource, deleting);
  509|     30|    }
  510|       |
  511|     30|    if (context->resource_deleted_cb)
  ------------------
  |  Branch (511:9): [True: 0, False: 30]
  ------------------
  512|      0|      coap_lock_callback(context->resource_deleted_cb(context,
  ------------------
  |  |  651|     30|#define coap_lock_callback(func) func
  ------------------
  513|     30|                                                      resource->uri_path,
  514|     30|                                                      context->observe_user_data));
  515|       |
  516|     30|    if (context->release_userdata_cb && resource->user_data) {
  ------------------
  |  Branch (516:9): [True: 0, False: 30]
  |  Branch (516:41): [True: 0, False: 0]
  ------------------
  517|      0|      coap_lock_callback(context->release_userdata_cb(resource->user_data));
  ------------------
  |  |  651|      0|#define coap_lock_callback(func) func
  ------------------
  518|      0|    }
  519|     30|  }
  520|       |
  521|       |  /* delete registered attributes */
  522|     30|  LL_FOREACH_SAFE(resource->link_attr, attr, tmp) coap_delete_attr(attr);
  ------------------
  |  |  423|     30|    LL_FOREACH_SAFE2(head,el,tmp,next)
  |  |  ------------------
  |  |  |  |  426|     30|  for ((el) = (head); (el) && ((tmp) = (el)->next, 1); (el) = (tmp))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (426:23): [True: 0, False: 30]
  |  |  |  |  |  Branch (426:31): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  523|       |
  524|       |  /* Either the application provided or libcoap copied - need to delete it */
  525|     30|  coap_delete_str_const(resource->uri_path);
  526|       |
  527|       |  /* free all elements from resource->subscribers */
  528|     30|  LL_FOREACH_SAFE(resource->subscribers, obs, otmp) {
  ------------------
  |  |  423|     30|    LL_FOREACH_SAFE2(head,el,tmp,next)
  |  |  ------------------
  |  |  |  |  426|     30|  for ((el) = (head); (el) && ((tmp) = (el)->next, 1); (el) = (tmp))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (426:23): [True: 0, False: 30]
  |  |  |  |  |  Branch (426:31): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  529|      0|    coap_delete_observer_internal(resource, obs->session, obs);
  530|      0|  }
  531|     30|  if (resource->proxy_name_count && resource->proxy_name_list) {
  ------------------
  |  Branch (531:7): [True: 0, False: 30]
  |  Branch (531:37): [True: 0, False: 0]
  ------------------
  532|      0|    size_t i;
  533|       |
  534|      0|    for (i = 0; i < resource->proxy_name_count; i++) {
  ------------------
  |  Branch (534:17): [True: 0, False: 0]
  ------------------
  535|      0|      coap_delete_str_const(resource->proxy_name_list[i]);
  536|      0|    }
  537|      0|    coap_free_type(COAP_STRING, resource->proxy_name_list);
  538|      0|  }
  539|       |
  540|     30|  coap_free_type(COAP_RESOURCE, resource);
  541|     30|}
coap_resource.c:coap_notify_observers:
 1136|     30|                      coap_deleting_resource_t deleting) {
 1137|     30|  coap_method_handler_t h;
 1138|     30|  coap_subscription_t *obs, *otmp;
 1139|     30|  coap_pdu_t *response;
 1140|     30|  uint8_t buf[4];
 1141|     30|  coap_string_t *query;
 1142|     30|  coap_block_b_t block;
 1143|     30|  coap_tick_t now;
 1144|       |
 1145|     30|  coap_lock_check_locked();
  ------------------
  |  |  638|     30|#define coap_lock_check_locked() {}
  ------------------
 1146|       |
 1147|     30|  if (r->observable && (r->dirty || r->partiallydirty)) {
  ------------------
  |  Branch (1147:7): [True: 0, False: 30]
  |  Branch (1147:25): [True: 0, False: 0]
  |  Branch (1147:37): [True: 0, False: 0]
  ------------------
 1148|      0|    if (r->list_being_traversed)
  ------------------
  |  Branch (1148:9): [True: 0, False: 0]
  ------------------
 1149|      0|      return;
 1150|      0|    r->list_being_traversed = 1;
 1151|       |
 1152|      0|    coap_resource_reference_lkd(r);
 1153|       |
 1154|      0|    r->partiallydirty = 0;
 1155|       |
 1156|      0|    LL_FOREACH_SAFE(r->subscribers, obs, otmp) {
  ------------------
  |  |  423|      0|    LL_FOREACH_SAFE2(head,el,tmp,next)
  |  |  ------------------
  |  |  |  |  426|      0|  for ((el) = (head); (el) && ((tmp) = (el)->next, 1); (el) = (tmp))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (426:23): [True: 0, False: 0]
  |  |  |  |  |  Branch (426:31): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1157|      0|      coap_session_t *obs_session;
 1158|      0|      coap_pdu_t *obs_pdu;
 1159|      0|      coap_mid_t mid = COAP_INVALID_MID;
  ------------------
  |  |  187|      0|#define COAP_INVALID_MID -1
  ------------------
 1160|       |
 1161|      0|      if ((r->dirty == 0 && obs->dirty == 0) || obs->session->is_rate_limiting) {
  ------------------
  |  Branch (1161:12): [True: 0, False: 0]
  |  Branch (1161:29): [True: 0, False: 0]
  |  Branch (1161:49): [True: 0, False: 0]
  ------------------
 1162|       |        /*
 1163|       |         * running this resource due to partiallydirty, but this observation's
 1164|       |         * notification was already enqueued
 1165|       |         */
 1166|      0|        context->observe_pending = 1;
 1167|      0|        continue;
 1168|      0|      }
 1169|       |
 1170|       |      /*
 1171|       |       * obs may get deleted in the callback, or by another running
 1172|       |       * thread when executing the callback or when sending a response.
 1173|       |       */
 1174|      0|      obs_session = obs->session;
 1175|      0|      obs_pdu = obs->pdu;
 1176|      0|      coap_session_reference_lkd(obs_session);
 1177|      0|      coap_pdu_reference_lkd(obs_pdu);
 1178|       |
 1179|      0|      if (obs->session->con_active >= COAP_NSTART(obs->session) &&
  ------------------
  |  |  798|      0|#define COAP_NSTART(s) ((s)->nstart)
  ------------------
  |  Branch (1179:11): [True: 0, False: 0]
  ------------------
 1180|      0|          ((r->flags & COAP_RESOURCE_FLAGS_NOTIFY_CON) ||
  ------------------
  |  |   69|      0|#define COAP_RESOURCE_FLAGS_NOTIFY_CON  0x2
  ------------------
  |  Branch (1180:12): [True: 0, False: 0]
  ------------------
 1181|      0|           (obs->non_cnt >= COAP_OBS_MAX_NON))) {
  ------------------
  |  |   39|      0|#define COAP_OBS_MAX_NON   5
  ------------------
  |  Branch (1181:12): [True: 0, False: 0]
  ------------------
 1182|       |        /* Waiting for the previous unsolicited response to finish */
 1183|      0|        goto next_one_fail;
 1184|      0|      }
 1185|      0|      coap_ticks(&now);
 1186|      0|      if (obs->session->lg_xmit && obs->session->lg_xmit->last_all_sent == 0 &&
  ------------------
  |  Branch (1186:11): [True: 0, False: 0]
  |  Branch (1186:36): [True: 0, False: 0]
  ------------------
 1187|      0|          obs->session->lg_xmit->last_obs &&
  ------------------
  |  Branch (1187:11): [True: 0, False: 0]
  ------------------
 1188|      0|          (obs->session->lg_xmit->last_obs + 2*COAP_TICKS_PER_SECOND) > now) {
  ------------------
  |  |  164|      0|#define COAP_TICKS_PER_SECOND ((coap_tick_t)(1000U))
  ------------------
  |  Branch (1188:11): [True: 0, False: 0]
  ------------------
 1189|       |        /* Waiting for the previous blocked unsolicited response to finish */
 1190|      0|        goto next_one_fail;
 1191|      0|      }
 1192|       |
 1193|      0|      obs->dirty = 0;
 1194|       |      /* initialize response */
 1195|      0|      response = coap_pdu_init(COAP_MESSAGE_CON, 0, 0,
 1196|      0|                               coap_session_max_pdu_size_lkd(obs->session));
 1197|      0|      if (!response) {
  ------------------
  |  Branch (1197:11): [True: 0, False: 0]
  ------------------
 1198|      0|        coap_log_debug("coap_check_notify: pdu init failed, resource stays "
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1199|      0|                       "partially dirty\n");
 1200|      0|        goto next_one_fail_no_pending;
 1201|      0|      }
 1202|       |
 1203|      0|      if (!coap_add_token(response, obs->pdu->actual_token.length,
  ------------------
  |  Branch (1203:11): [True: 0, False: 0]
  ------------------
 1204|      0|                          obs->pdu->actual_token.s)) {
 1205|      0|        coap_log_debug("coap_check_notify: cannot add token, resource stays "
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1206|      0|                       "partially dirty\n");
 1207|      0|        coap_delete_pdu_lkd(response);
 1208|      0|        goto next_one_fail_no_pending;
 1209|      0|      }
 1210|       |
 1211|      0|      obs->pdu->mid = response->mid = coap_new_message_id_lkd(obs->session);
 1212|       |      /* A lot of the reliable code assumes type is CON */
 1213|      0|      if (COAP_PROTO_NOT_RELIABLE(obs->session->proto) &&
  ------------------
  |  |   41|      0|#define COAP_PROTO_NOT_RELIABLE(p) ((p)==COAP_PROTO_UDP || (p)==COAP_PROTO_DTLS)
  |  |  ------------------
  |  |  |  Branch (41:37): [True: 0, False: 0]
  |  |  |  Branch (41:60): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1214|      0|          (r->flags & COAP_RESOURCE_FLAGS_NOTIFY_CON) == 0 &&
  ------------------
  |  |   69|      0|#define COAP_RESOURCE_FLAGS_NOTIFY_CON  0x2
  ------------------
  |  Branch (1214:11): [True: 0, False: 0]
  ------------------
 1215|      0|          ((r->flags & COAP_RESOURCE_FLAGS_NOTIFY_NON_ALWAYS) ||
  ------------------
  |  |   79|      0|#define COAP_RESOURCE_FLAGS_NOTIFY_NON_ALWAYS  0x4
  ------------------
  |  Branch (1215:12): [True: 0, False: 0]
  ------------------
 1216|      0|           obs->non_cnt < COAP_OBS_MAX_NON)) {
  ------------------
  |  |   39|      0|#define COAP_OBS_MAX_NON   5
  ------------------
  |  Branch (1216:12): [True: 0, False: 0]
  ------------------
 1217|      0|        response->type = COAP_MESSAGE_NON;
 1218|      0|      } else {
 1219|      0|        response->type = COAP_MESSAGE_CON;
 1220|      0|      }
 1221|      0|      switch (deleting) {
 1222|      0|      case COAP_NOT_DELETING_RESOURCE:
  ------------------
  |  Branch (1222:7): [True: 0, False: 0]
  ------------------
 1223|       |        /* fill with observer-specific data */
 1224|      0|        coap_add_option_internal(response, COAP_OPTION_OBSERVE,
 1225|      0|                                 coap_encode_var_safe(buf, sizeof(buf),
 1226|      0|                                                      r->observe),
 1227|      0|                                 buf);
 1228|      0|        if (coap_get_block_b(obs->session, obs->pdu, COAP_OPTION_BLOCK2,
  ------------------
  |  Branch (1228:13): [True: 0, False: 0]
  ------------------
 1229|      0|                             &block)) {
 1230|       |          /* Will get updated later (e.g. M bit) if appropriate */
 1231|      0|          coap_add_option_internal(response, COAP_OPTION_BLOCK2,
 1232|      0|                                   coap_encode_var_safe(buf, sizeof(buf),
 1233|      0|                                                        ((0 << 4) |
 1234|      0|                                                         (0 << 3) |
 1235|      0|                                                         block.aszx)),
 1236|      0|                                   buf);
 1237|      0|        }
 1238|      0|#if COAP_Q_BLOCK_SUPPORT
 1239|      0|        else if (coap_get_block_b(obs->session, obs->pdu, COAP_OPTION_Q_BLOCK2,
  ------------------
  |  Branch (1239:18): [True: 0, False: 0]
  ------------------
 1240|      0|                                  &block)) {
 1241|       |          /* Will get updated later (e.g. M bit) if appropriate */
 1242|      0|          coap_add_option_internal(response, COAP_OPTION_Q_BLOCK2,
 1243|      0|                                   coap_encode_var_safe(buf, sizeof(buf),
 1244|      0|                                                        ((0 << 4) |
 1245|      0|                                                         (0 << 3) |
 1246|      0|                                                         block.szx)),
 1247|      0|                                   buf);
 1248|      0|        }
 1249|      0|#endif /* COAP_Q_BLOCK_SUPPORT */
 1250|       |
 1251|      0|        h = r->handler[obs->pdu->code - 1];
 1252|      0|        assert(h);      /* we do not allow subscriptions if no
  ------------------
  |  Branch (1252:9): [True: 0, False: 0]
  ------------------
 1253|       |                         * GET/FETCH handler is defined */
 1254|      0|        query = coap_get_query(obs->pdu);
 1255|      0|        coap_log_debug("Observe PDU presented to app.\n");
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1256|      0|        coap_show_pdu(COAP_LOG_DEBUG, obs->pdu);
 1257|      0|        coap_log_debug("call custom handler for resource '%*.*s' (4)\n",
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1258|      0|                       (int)r->uri_path->length, (int)r->uri_path->length,
 1259|      0|                       r->uri_path->s);
 1260|       |
 1261|       |        /* obs may get deleted during callback (potentially by another thread) */
 1262|      0|        if (r->flags & COAP_RESOURCE_SAFE_REQUEST_HANDLER) {
  ------------------
  |  |  181|      0|#define COAP_RESOURCE_SAFE_REQUEST_HANDLER 0x4000
  ------------------
  |  Branch (1262:13): [True: 0, False: 0]
  ------------------
 1263|      0|          coap_lock_callback_release(h(r, obs->session, obs->pdu, query, response),
  ------------------
  |  |  680|      0|#define coap_lock_callback_release(func,failed) func
  ------------------
 1264|       |                                     /* context is being freed off */
 1265|      0|                                     coap_delete_string(query);
 1266|      0|                                     coap_delete_pdu_lkd(response);
 1267|      0|                                     coap_session_release_lkd(obs_session);
 1268|      0|                                     coap_pdu_release_lkd(obs_pdu);
 1269|      0|                                     r->list_being_traversed = 0;
 1270|      0|                                     coap_resource_release_lkd(r);
 1271|      0|                                     return);
 1272|      0|        } else {
 1273|      0|          coap_lock_specific_callback_release(&r->lock,
  ------------------
  |  |  692|      0|#define coap_lock_specific_callback_release(lock,func,failed) func
  ------------------
 1274|      0|                                              h(r, obs->session, obs->pdu, query, response),
 1275|       |                                              /* context is being freed off */
 1276|      0|                                              coap_delete_string(query);
 1277|      0|                                              coap_delete_pdu_lkd(response);
 1278|      0|                                              coap_session_release_lkd(obs_session);
 1279|      0|                                              coap_pdu_release_lkd(obs_pdu);
 1280|      0|                                              r->list_being_traversed = 0;
 1281|      0|                                              coap_resource_release_lkd(r);
 1282|      0|                                              return);
 1283|      0|        }
 1284|       |
 1285|       |        /* Check validity of response code */
 1286|      0|        if (!coap_check_code_class(obs_session, response)) {
  ------------------
  |  Branch (1286:13): [True: 0, False: 0]
  ------------------
 1287|      0|          coap_log_warn("handle_request: Invalid PDU response code (%d.%02d)\n",
  ------------------
  |  |  108|      0|#define coap_log_warn(...) coap_log(COAP_LOG_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1288|      0|                        COAP_RESPONSE_CLASS(response->code),
 1289|      0|                        response->code & 0x1f);
 1290|      0|          coap_delete_string(query);
 1291|      0|          coap_delete_pdu_lkd(response);
 1292|      0|          coap_session_release_lkd(obs_session);
 1293|      0|          coap_pdu_release_lkd(obs_pdu);
 1294|      0|          r->list_being_traversed = 0;
 1295|      0|          coap_resource_release_lkd(r);
 1296|      0|          return;
 1297|      0|        }
 1298|       |
 1299|       |        /* Check if lg_xmit generated and update PDU code if so */
 1300|      0|        coap_check_code_lg_xmit(obs_session, obs_pdu, response, r, query);
 1301|      0|        coap_delete_string(query);
 1302|      0|        if (COAP_RESPONSE_CLASS(response->code) != 2) {
  ------------------
  |  |   99|      0|#define COAP_RESPONSE_CLASS(C) (((C) >> 5) & 0xFF)
  ------------------
  |  Branch (1302:13): [True: 0, False: 0]
  ------------------
 1303|      0|          coap_remove_option(response, COAP_OPTION_OBSERVE);
 1304|      0|        }
 1305|      0|        if (COAP_RESPONSE_CLASS(response->code) > 2) {
  ------------------
  |  |   99|      0|#define COAP_RESPONSE_CLASS(C) (((C) >> 5) & 0xFF)
  ------------------
  |  Branch (1305:13): [True: 0, False: 0]
  ------------------
 1306|      0|          coap_delete_observer(r, obs_session, &obs_pdu->actual_token);
 1307|      0|          obs = NULL;
 1308|      0|        }
 1309|      0|        break;
 1310|      0|      case COAP_DELETING_RESOURCE_ON_EXIT:
  ------------------
  |  Branch (1310:7): [True: 0, False: 0]
  ------------------
 1311|       |        /* Don't worry if it does not get there */
 1312|      0|        response->type = COAP_MESSAGE_NON;
 1313|      0|        response->code = COAP_RESPONSE_CODE(503);
  ------------------
  |  |   96|      0|#define COAP_RESPONSE_CODE(N) (((N)/100 << 5) | (N)%100)
  ------------------
 1314|      0|        coap_add_option_internal(response, COAP_OPTION_MAXAGE,
 1315|      0|                                 coap_encode_var_safe(buf, sizeof(buf),
 1316|      0|                                                      30),
 1317|      0|                                 buf);
 1318|      0|        break;
 1319|      0|      case COAP_DELETING_RESOURCE:
  ------------------
  |  Branch (1319:7): [True: 0, False: 0]
  ------------------
 1320|      0|      default:
  ------------------
  |  Branch (1320:7): [True: 0, False: 0]
  ------------------
 1321|       |        /* Don't worry if it does not get there */
 1322|      0|        response->type = COAP_MESSAGE_NON;
 1323|      0|        response->code = COAP_RESPONSE_CODE(404);
  ------------------
  |  |   96|      0|#define COAP_RESPONSE_CODE(N) (((N)/100 << 5) | (N)%100)
  ------------------
 1324|      0|        break;
 1325|      0|      }
 1326|       |
 1327|      0|      if (obs) {
  ------------------
  |  Branch (1327:11): [True: 0, False: 0]
  ------------------
 1328|      0|        coap_subscription_t *s;
 1329|       |        /*
 1330|       |         * obs may have been deleted in the callback, or by another running
 1331|       |         * thread when executing the callback.
 1332|       |         */
 1333|      0|        LL_FOREACH(r->subscribers, s) {
  ------------------
  |  |  417|      0|    LL_FOREACH2(head,el,next)
  |  |  ------------------
  |  |  |  |  420|      0|    for ((el) = (head); el; (el) = (el)->next)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (420:25): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1334|      0|          if (s == obs) {
  ------------------
  |  Branch (1334:15): [True: 0, False: 0]
  ------------------
 1335|      0|            break;
 1336|      0|          }
 1337|      0|        }
 1338|      0|        if (s == NULL)
  ------------------
  |  Branch (1338:13): [True: 0, False: 0]
  ------------------
 1339|      0|          obs = NULL;
 1340|      0|      }
 1341|      0|      if (obs) {
  ------------------
  |  Branch (1341:11): [True: 0, False: 0]
  ------------------
 1342|      0|        if (response->type == COAP_MESSAGE_CON ||
  ------------------
  |  Branch (1342:13): [True: 0, False: 0]
  ------------------
 1343|      0|            (r->flags & COAP_RESOURCE_FLAGS_NOTIFY_NON_ALWAYS)) {
  ------------------
  |  |   79|      0|#define COAP_RESOURCE_FLAGS_NOTIFY_NON_ALWAYS  0x4
  ------------------
  |  Branch (1343:13): [True: 0, False: 0]
  ------------------
 1344|      0|          obs->non_cnt = 0;
 1345|      0|        } else {
 1346|      0|          obs->non_cnt++;
 1347|      0|        }
 1348|       |
 1349|      0|#if COAP_Q_BLOCK_SUPPORT
 1350|      0|        if (response->code == COAP_RESPONSE_CODE(205) &&
  ------------------
  |  |   96|      0|#define COAP_RESPONSE_CODE(N) (((N)/100 << 5) | (N)%100)
  ------------------
  |  Branch (1350:13): [True: 0, False: 0]
  ------------------
 1351|      0|            coap_get_block_b(obs_session, response, COAP_OPTION_Q_BLOCK2,
  ------------------
  |  Branch (1351:13): [True: 0, False: 0]
  ------------------
 1352|      0|                             &block) &&
 1353|      0|            block.m) {
  ------------------
  |  Branch (1353:13): [True: 0, False: 0]
  ------------------
 1354|      0|          query = coap_get_query(obs_pdu);
 1355|      0|          mid = coap_send_q_block2(obs_session, r, query, obs_pdu->code,
 1356|      0|                                   block, response, 1);
 1357|      0|          coap_delete_string(query);
 1358|      0|          goto finish;
 1359|      0|        }
 1360|      0|#endif /* COAP_Q_BLOCK_SUPPORT */
 1361|      0|      }
 1362|      0|      mid = coap_send_internal(obs_session, response, NULL);
 1363|       |
 1364|      0|#if COAP_Q_BLOCK_SUPPORT
 1365|      0|finish:
 1366|      0|#endif /* COAP_Q_BLOCK_SUPPORT */
 1367|      0|      if (COAP_INVALID_MID == mid) {
  ------------------
  |  |  187|      0|#define COAP_INVALID_MID -1
  ------------------
  |  Branch (1367:11): [True: 0, False: 0]
  ------------------
 1368|      0|        coap_log_debug("*  %s: coap_check_notify: sending failed, resource stays "
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1369|      0|                       "partially dirty\n", coap_session_str(obs_session));
 1370|      0|        if (obs) {
  ------------------
  |  Branch (1370:13): [True: 0, False: 0]
  ------------------
 1371|      0|          coap_subscription_t *s;
 1372|       |          /*
 1373|       |           * obs may have been deleted in coap_send_internal() or
 1374|       |           * coap_send_q_block2().
 1375|       |           */
 1376|      0|          LL_FOREACH(r->subscribers, s) {
  ------------------
  |  |  417|      0|    LL_FOREACH2(head,el,next)
  |  |  ------------------
  |  |  |  |  420|      0|    for ((el) = (head); el; (el) = (el)->next)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (420:25): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1377|      0|            if (s == obs) {
  ------------------
  |  Branch (1377:17): [True: 0, False: 0]
  ------------------
 1378|      0|              break;
 1379|      0|            }
 1380|      0|          }
 1381|      0|          if (s == NULL)
  ------------------
  |  Branch (1381:15): [True: 0, False: 0]
  ------------------
 1382|      0|            obs = NULL;
 1383|      0|        }
 1384|      0|        if (obs)
  ------------------
  |  Branch (1384:13): [True: 0, False: 0]
  ------------------
 1385|      0|          obs->dirty = 1;
 1386|      0|        r->partiallydirty = 1;
 1387|      0|      }
 1388|      0|      goto cleanup;
 1389|       |
 1390|      0|next_one_fail:
 1391|      0|      context->observe_pending = 1;
 1392|      0|next_one_fail_no_pending:
 1393|      0|      r->partiallydirty = 1;
 1394|      0|      if (obs)
  ------------------
  |  Branch (1394:11): [True: 0, False: 0]
  ------------------
 1395|      0|        obs->dirty = 1;
 1396|      0|cleanup:
 1397|      0|      coap_session_release_lkd(obs_session);
 1398|      0|      coap_pdu_release_lkd(obs_pdu);
 1399|      0|    }
 1400|      0|    r->list_being_traversed = 0;
 1401|      0|    r->dirty = 0;
 1402|      0|    coap_resource_release_lkd(r);
 1403|       |    /* r may be no more if elsewhere coap_free_resource() has been called */
 1404|     30|  } else {
 1405|     30|    r->dirty = 0;
 1406|     30|  }
 1407|     30|}

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

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

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:
 1241|     30|coap_persist_cleanup(coap_context_t *context) {
 1242|     30|  coap_delete_bin_const(context->dyn_resource_save_file);
 1243|     30|  coap_delete_bin_const(context->obs_cnt_save_file);
 1244|     30|  coap_delete_bin_const(context->observe_save_file);
 1245|     30|  context->dyn_resource_save_file = NULL;
 1246|     30|  context->obs_cnt_save_file = NULL;
 1247|     30|  context->observe_save_file = NULL;
 1248|       |
 1249|       |  /* Close down any tracking */
 1250|     30|  coap_persist_track_funcs(context, NULL, NULL, NULL, NULL,
 1251|     30|                           NULL, 0, NULL);
 1252|     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|    210|coap_ticks(coap_tick_t *t) {
   91|    210|  coap_tick_t tmp;
   92|       |
   93|    210|#ifdef COAP_CLOCK
   94|    210|  struct timespec tv;
   95|    210|  clock_gettime(COAP_CLOCK, &tv);
  ------------------
  |  |   43|    210|#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|    210|  tmp = SHR_FP(tv.tv_nsec * Q(FRAC, (COAP_TICKS_PER_SECOND/1000000000.0)), FRAC);
  ------------------
  |  |   87|    210|#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|    210|  *t = tmp + (tv.tv_sec - coap_clock_offset) * COAP_TICKS_PER_SECOND;
  ------------------
  |  |  164|    210|#define COAP_TICKS_PER_SECOND ((coap_tick_t)(1000U))
  ------------------
  120|    210|}
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:
  351|      8|coap_split_proxy_uri(const uint8_t *str_var, size_t len, coap_uri_t *uri) {
  352|      8|  return coap_split_uri_sub(str_var, len, uri, COAP_URI_CHECK_PROXY);
  353|      8|}
coap_uri_into_optlist:
  375|      1|                      coap_optlist_t **optlist_chain, int create_port_host_opt) {
  376|       |  return coap_uri_into_optlist_abbrev(uri, dst, optlist_chain, create_port_host_opt, NULL, 0);
  377|      1|}
coap_uri_into_optlist_abbrev:
  382|      1|                             coap_upa_abbrev_t *mapping, uint32_t count) {
  383|      1|  if (create_port_host_opt && !coap_host_is_unix_domain(&uri->host)) {
  ------------------
  |  Branch (383:7): [True: 0, False: 1]
  |  Branch (383:31): [True: 0, False: 0]
  ------------------
  384|      0|    int add_option = 0;
  385|       |
  386|      0|    if (dst && uri->host.length) {
  ------------------
  |  Branch (386:9): [True: 0, False: 0]
  |  Branch (386:16): [True: 0, False: 0]
  ------------------
  387|      0|#if !defined(WITH_LWIP) && !defined(WITH_CONTIKI)
  388|      0|      char addr[INET6_ADDRSTRLEN];
  389|       |#else /* WITH_LWIP || WITH_CONTIKI */
  390|       |      char addr[40];
  391|       |#endif /* WITH_LWIP || WITH_CONTIKI */
  392|      0|      coap_optlist_t *optlist;
  393|       |
  394|       |      /* Add in Uri-Host if not match (need to strip off %iface) */
  395|      0|      size_t uri_host_len = uri->host.length;
  396|      0|      const uint8_t *cp = uri->host.s;
  397|       |
  398|       |      /* Unfortunately not null terminated */
  399|      0|      for (size_t i = 0; i < uri_host_len; i++) {
  ------------------
  |  Branch (399:26): [True: 0, False: 0]
  ------------------
  400|      0|        if (cp[i] == '%') {
  ------------------
  |  Branch (400:13): [True: 0, False: 0]
  ------------------
  401|       |          /* %iface specified in host name */
  402|      0|          uri_host_len = i;
  403|      0|          break;
  404|      0|        }
  405|      0|      }
  406|       |
  407|      0|      if (coap_print_ip_addr(dst, addr, sizeof(addr)) &&
  ------------------
  |  Branch (407:11): [True: 0, False: 0]
  ------------------
  408|      0|          (strlen(addr) != uri_host_len ||
  ------------------
  |  Branch (408:12): [True: 0, False: 0]
  ------------------
  409|      0|           strncasecmp(addr, (const char *)uri->host.s, uri_host_len) != 0)) {
  ------------------
  |  Branch (409:12): [True: 0, False: 0]
  ------------------
  410|       |        /* add Uri-Host */
  411|      0|        optlist = coap_new_optlist(COAP_OPTION_URI_HOST, uri_host_len,
  412|      0|                                   uri->host.s);
  413|      0|        if (!coap_host_is_unix_domain(&uri->host)) {
  ------------------
  |  Branch (413:13): [True: 0, False: 0]
  ------------------
  414|      0|          coap_replace_percents(optlist);
  415|      0|          coap_replace_upper_lower(optlist);
  416|      0|        }
  417|      0|        if (!coap_insert_optlist(optlist_chain, optlist)) {
  ------------------
  |  Branch (417:13): [True: 0, False: 0]
  ------------------
  418|      0|          return 0;
  419|      0|        }
  420|      0|      }
  421|      0|    }
  422|       |    /* Add in UriPort if not default */
  423|      0|    switch ((int)uri->scheme) {
  424|      0|    case COAP_URI_SCHEME_HTTP:
  ------------------
  |  Branch (424:5): [True: 0, False: 0]
  ------------------
  425|      0|    case COAP_URI_SCHEME_COAP_WS:
  ------------------
  |  Branch (425:5): [True: 0, False: 0]
  ------------------
  426|      0|      if (uri->port != 80)
  ------------------
  |  Branch (426:11): [True: 0, False: 0]
  ------------------
  427|      0|        add_option = 1;
  428|      0|      break;
  429|      0|    case COAP_URI_SCHEME_HTTPS:
  ------------------
  |  Branch (429:5): [True: 0, False: 0]
  ------------------
  430|      0|    case COAP_URI_SCHEME_COAPS_WS:
  ------------------
  |  Branch (430:5): [True: 0, False: 0]
  ------------------
  431|      0|      if (uri->port != 443)
  ------------------
  |  Branch (431:11): [True: 0, False: 0]
  ------------------
  432|      0|        add_option = 1;
  433|      0|      break;
  434|      0|    default:
  ------------------
  |  Branch (434:5): [True: 0, False: 0]
  ------------------
  435|      0|      if (uri->port != (coap_uri_scheme_is_secure(uri) ? COAPS_DEFAULT_PORT :
  ------------------
  |  |   40|      0|#define COAPS_DEFAULT_PORT     5684 /* CoAP default UDP/TCP port for secure transmission */
  ------------------
  |  Branch (435:11): [True: 0, False: 0]
  |  Branch (435:25): [True: 0, False: 0]
  ------------------
  436|      0|                        COAP_DEFAULT_PORT))
  ------------------
  |  |   39|      0|#define COAP_DEFAULT_PORT      5683 /* CoAP default UDP/TCP port */
  ------------------
  437|      0|        add_option = 1;
  438|      0|      break;
  439|      0|    }
  440|      0|    if (add_option) {
  ------------------
  |  Branch (440:9): [True: 0, False: 0]
  ------------------
  441|      0|      uint8_t tbuf[4];
  442|       |
  443|      0|      coap_insert_optlist(optlist_chain,
  444|      0|                          coap_new_optlist(COAP_OPTION_URI_PORT,
  445|      0|                                           coap_encode_var_safe(tbuf, 4,
  446|      0|                                                                (uri->port & 0xffff)),
  447|      0|                                           tbuf));
  448|      0|    }
  449|      0|  }
  450|       |
  451|      1|  if (uri->path.length) {
  ------------------
  |  Branch (451:7): [True: 1, False: 0]
  ------------------
  452|      1|    if (!coap_path_into_optlist_abbrev(uri->path.s, uri->path.length, COAP_OPTION_URI_PATH,
  ------------------
  |  Branch (452:9): [True: 0, False: 1]
  ------------------
  453|      1|                                       optlist_chain, mapping, count))
  454|      0|      return 0;
  455|      1|  }
  456|       |
  457|      1|  if (uri->query.length) {
  ------------------
  |  Branch (457:7): [True: 0, False: 1]
  ------------------
  458|      0|    if (!coap_query_into_optlist(uri->query.s, uri->query.length, COAP_OPTION_URI_QUERY,
  ------------------
  |  Branch (458:9): [True: 0, False: 0]
  ------------------
  459|      0|                                 optlist_chain))
  460|      0|      return 0;
  461|      0|  }
  462|      1|  return 1;
  463|      1|}
coap_host_is_unix_domain:
  466|     21|coap_host_is_unix_domain(const coap_str_const_t *host) {
  467|     21|  if (host->length >= 3 && host->s[0] == '%' &&
  ------------------
  |  Branch (467:7): [True: 21, False: 0]
  |  Branch (467:28): [True: 0, False: 21]
  ------------------
  468|      0|      host->s[1] == '2' &&
  ------------------
  |  Branch (468:7): [True: 0, False: 0]
  ------------------
  469|      0|      (host->s[2] == 'F' || host->s[2] == 'f')) {
  ------------------
  |  Branch (469:8): [True: 0, False: 0]
  |  Branch (469:29): [True: 0, False: 0]
  ------------------
  470|      0|    return 1;
  471|      0|  }
  472|     21|  if (host->length >= 1 && host->s[0] == '/')
  ------------------
  |  Branch (472:7): [True: 21, False: 0]
  |  Branch (472:28): [True: 1, False: 20]
  ------------------
  473|      1|    return 1;
  474|     20|  return 0;
  475|     21|}
coap_host_is_llc:
  478|     20|coap_host_is_llc(const coap_str_const_t *host) {
  479|     20|#if COAP_AF_LLC_SUPPORT
  480|     20|  size_t length;
  481|     20|  const uint8_t *s = NULL;
  482|     20|  int i = 0;
  483|       |
  484|     20|  length = host->length;
  485|     20|  if (length != LLC_HOST_LEN)
  ------------------
  |  |  169|     20|#define LLC_HOST_LEN (4 + HW_ADDRSTRLEN + 4)
  |  |  ------------------
  |  |  |  |  167|     20|#define HW_ADDRSTRLEN 17
  |  |  ------------------
  ------------------
  |  Branch (485:7): [True: 20, False: 0]
  ------------------
  486|     20|    return 0;
  487|       |
  488|      0|  s = host->s;
  489|       |
  490|      0|  if (strncmp((const char *)s, "llc[", 4) != 0)
  ------------------
  |  Branch (490:7): [True: 0, False: 0]
  ------------------
  491|      0|    return 0;
  492|       |
  493|      0|  length -= 4;
  494|      0|  s += 4;
  495|       |
  496|      0|  while (length) {
  ------------------
  |  Branch (496:10): [True: 0, False: 0]
  ------------------
  497|      0|    if (!isxdigit(s[0]) || !isxdigit(s[1]))
  ------------------
  |  Branch (497:9): [True: 0, False: 0]
  |  Branch (497:28): [True: 0, False: 0]
  ------------------
  498|      0|      return 0;
  499|       |
  500|      0|    length -= 2;
  501|      0|    s += 2;
  502|       |
  503|      0|    i++;
  504|       |
  505|      0|    if (length <= 0 || i >= 6)
  ------------------
  |  Branch (505:9): [True: 0, False: 0]
  |  Branch (505:24): [True: 0, False: 0]
  ------------------
  506|      0|      break;
  507|       |
  508|      0|    if (s[0] != ':')
  ------------------
  |  Branch (508:9): [True: 0, False: 0]
  ------------------
  509|      0|      return 0;
  510|       |
  511|      0|    length--;
  512|      0|    s++;
  513|      0|  }
  514|       |
  515|      0|  if (s[0] != ']' || s[1] != ':' || !isxdigit(s[2]) || !isxdigit(s[3]))
  ------------------
  |  Branch (515:7): [True: 0, False: 0]
  |  Branch (515:22): [True: 0, False: 0]
  |  Branch (515:37): [True: 0, False: 0]
  |  Branch (515:56): [True: 0, False: 0]
  ------------------
  516|      0|    return 0;
  517|       |
  518|      0|  return 1;
  519|       |#else /* COAP_AF_LLC_SUPPORT */
  520|       |  (void)host;
  521|       |  return 0;
  522|       |#endif /* COAP_AF_LLC_SUPPORT */
  523|      0|}
coap_check_dots:
  668|     62|coap_check_dots(const uint8_t *s, size_t len) {
  669|     62|  uint8_t p;
  670|       |
  671|     62|  if (!len)
  ------------------
  |  Branch (671:7): [True: 4, False: 58]
  ------------------
  672|      4|    return 0;
  673|       |
  674|     58|  p = *s;
  675|       |
  676|       |  /* Check 'first' char */
  677|     58|  if (p == '%' && len >=3) {
  ------------------
  |  Branch (677:7): [True: 12, False: 46]
  |  Branch (677:19): [True: 12, False: 0]
  ------------------
  678|     12|    if (s[1] == '2' && (s[2] == 'E' || s[2] == 'e')) {
  ------------------
  |  Branch (678:9): [True: 8, False: 4]
  |  Branch (678:25): [True: 8, False: 0]
  |  Branch (678:40): [True: 0, False: 0]
  ------------------
  679|      8|      s += 2;
  680|      8|      len -= 2;
  681|      8|    }
  682|     12|    p = '.';
  683|     12|  }
  684|     58|  if (p != '.')
  ------------------
  |  Branch (684:7): [True: 46, False: 12]
  ------------------
  685|     46|    return 0;
  686|     12|  if (len == 1)
  ------------------
  |  Branch (686:7): [True: 0, False: 12]
  ------------------
  687|      0|    return 1;
  688|       |
  689|       |  /* Check 'second' char, first is '.' */
  690|     12|  s++;
  691|     12|  len--;
  692|     12|  assert(len);
  ------------------
  |  Branch (692:3): [True: 12, False: 0]
  ------------------
  693|     12|  p = *s;
  694|     12|  if (p == '%' && len >=3) {
  ------------------
  |  Branch (694:7): [True: 2, False: 10]
  |  Branch (694:19): [True: 2, False: 0]
  ------------------
  695|      2|    if (s[1] == '2' && (s[2] == 'E' || s[2] == 'e')) {
  ------------------
  |  Branch (695:9): [True: 2, False: 0]
  |  Branch (695:25): [True: 2, False: 0]
  |  Branch (695:40): [True: 0, False: 0]
  ------------------
  696|      2|      len -= 2;
  697|      2|    }
  698|      2|    p = '.';
  699|      2|  }
  700|     12|  if (p != '.')
  ------------------
  |  Branch (700:7): [True: 10, False: 2]
  ------------------
  701|     10|    return 0;
  702|      2|  if (len == 1)
  ------------------
  |  Branch (702:7): [True: 0, False: 2]
  ------------------
  703|      0|    return 2;
  704|       |
  705|      2|  return 0;
  706|      2|}
coap_replace_percents:
  825|      8|coap_replace_percents(coap_optlist_t *optlist) {
  826|      8|  size_t i;
  827|      8|  size_t o = 0;
  828|       |
  829|    238|  for (i = 0; i < optlist->length; i++) {
  ------------------
  |  Branch (829:15): [True: 230, False: 8]
  ------------------
  830|    230|    if (optlist->data[i] == '%' && optlist->length - i >= 3) {
  ------------------
  |  Branch (830:9): [True: 4, False: 226]
  |  Branch (830:36): [True: 4, False: 0]
  ------------------
  831|      4|      optlist->data[o] = (hexchar_to_dec(optlist->data[i+1]) << 4) +
  ------------------
  |  |  532|      4|#define hexchar_to_dec(c) ((c) & 0x40 ? ((c) & 0x0F) + 9 : ((c) & 0x0F))
  |  |  ------------------
  |  |  |  Branch (532:28): [True: 0, False: 4]
  |  |  ------------------
  ------------------
  832|      4|                         hexchar_to_dec(optlist->data[i+2]);
  ------------------
  |  |  532|      4|#define hexchar_to_dec(c) ((c) & 0x40 ? ((c) & 0x0F) + 9 : ((c) & 0x0F))
  |  |  ------------------
  |  |  |  Branch (532:28): [True: 4, False: 0]
  |  |  ------------------
  ------------------
  833|      4|      i+= 2;
  834|    226|    } else if (o != i) {
  ------------------
  |  Branch (834:16): [True: 22, False: 204]
  ------------------
  835|     22|      optlist->data[o] = optlist->data[i];
  836|     22|    }
  837|    230|    o++;
  838|    230|  }
  839|      8|  optlist->length = o;
  840|      8|}
coap_path_into_optlist_abbrev:
  873|      1|                              uint32_t count) {
  874|      1|  const uint8_t *p = s;
  875|      1|  coap_optlist_t *optlist;
  876|      1|  int num_dots;
  877|      1|  coap_optlist_t **optlist_start;
  878|       |
  879|      1|  if (*optlist_chain) {
  ------------------
  |  Branch (879:7): [True: 1, False: 0]
  ------------------
  880|       |    /* Something previously in optlist_chain. Need to make that the start */
  881|      1|    optlist_start = &((*optlist_chain)->next);
  882|      1|  } else {
  883|      0|    optlist_start = optlist_chain;
  884|      0|  }
  885|       |
  886|      1|  if (length > 0 && mapping) {
  ------------------
  |  Branch (886:7): [True: 1, False: 0]
  |  Branch (886:21): [True: 0, False: 1]
  ------------------
  887|      0|    uint32_t i;
  888|      0|    uint8_t buf[4];
  889|       |
  890|      0|    for (i = 0; i < count; i++) {
  ------------------
  |  Branch (890:17): [True: 0, False: 0]
  ------------------
  891|      0|      if (strlen(mapping[i].upa_path) == length &&
  ------------------
  |  Branch (891:11): [True: 0, False: 0]
  ------------------
  892|      0|          memcmp(mapping[i].upa_path, s, length) == 0) {
  ------------------
  |  Branch (892:11): [True: 0, False: 0]
  ------------------
  893|       |        /* add in as Uri_path-Abbrev */
  894|      0|        optlist = coap_new_optlist(COAP_OPTION_URI_PATH_ABB,
  895|      0|                                   coap_encode_var_safe(buf, sizeof(buf), mapping[i].upa_value), buf);
  896|      0|        if (!coap_insert_optlist(optlist_chain, optlist)) {
  ------------------
  |  Branch (896:13): [True: 0, False: 0]
  ------------------
  897|      0|          return 0;
  898|      0|        }
  899|      0|        return 1;
  900|      0|      }
  901|      0|    }
  902|      0|  }
  903|    246|  while (length > 0 && !strnchr((const uint8_t *)"?#", 2, *s)) {
  ------------------
  |  Branch (903:10): [True: 245, False: 1]
  |  Branch (903:24): [True: 245, False: 0]
  ------------------
  904|    245|    if (*s == '/') {                /* start of new path element */
  ------------------
  |  Branch (904:9): [True: 7, False: 238]
  ------------------
  905|       |      /* start new segment */
  906|      7|      num_dots = coap_check_dots(p, s - p);
  907|      7|      switch (num_dots) {
  908|      0|      case 1:
  ------------------
  |  Branch (908:7): [True: 0, False: 7]
  ------------------
  909|       |        /* drop segment */
  910|      0|        break;
  911|      0|      case 2:
  ------------------
  |  Branch (911:7): [True: 0, False: 7]
  ------------------
  912|       |        /* backup segment */
  913|      0|        backup_optlist(optlist_start);
  914|      0|        break;
  915|      7|      case 0:
  ------------------
  |  Branch (915:7): [True: 7, False: 0]
  ------------------
  916|      7|      default:
  ------------------
  |  Branch (916:7): [True: 0, False: 7]
  ------------------
  917|       |        /* add segment */
  918|      7|        optlist = coap_new_optlist(optnum, s - p, p);
  919|      7|        if (!optlist) {
  ------------------
  |  Branch (919:13): [True: 0, False: 7]
  ------------------
  920|      0|          return 0;
  921|      0|        }
  922|      7|        coap_replace_percents(optlist);
  923|      7|        if (!coap_insert_optlist(optlist_chain, optlist)) {
  ------------------
  |  Branch (923:13): [True: 0, False: 7]
  ------------------
  924|      0|          return 0;
  925|      0|        }
  926|      7|        break;
  927|      7|      }
  928|      7|      p = s + 1;
  929|      7|    }
  930|    245|    s++;
  931|    245|    length--;
  932|       |
  933|    245|  }
  934|       |  /* add last path element */
  935|      1|  num_dots = coap_check_dots(p, s - p);
  936|      1|  switch (num_dots) {
  937|      0|  case 1:
  ------------------
  |  Branch (937:3): [True: 0, False: 1]
  ------------------
  938|       |    /* drop segment */
  939|      0|    break;
  940|      0|  case 2:
  ------------------
  |  Branch (940:3): [True: 0, False: 1]
  ------------------
  941|       |    /* backup segment */
  942|      0|    backup_optlist(optlist_start);
  943|      0|    break;
  944|      1|  case 0:
  ------------------
  |  Branch (944:3): [True: 1, False: 0]
  ------------------
  945|      1|  default:
  ------------------
  |  Branch (945:3): [True: 0, False: 1]
  ------------------
  946|       |    /* add segment */
  947|      1|    optlist = coap_new_optlist(optnum, s - p, p);
  948|      1|    if (!optlist) {
  ------------------
  |  Branch (948:9): [True: 0, False: 1]
  ------------------
  949|      0|      return 0;
  950|      0|    }
  951|      1|    coap_replace_percents(optlist);
  952|      1|    if (!coap_insert_optlist(optlist_chain, optlist)) {
  ------------------
  |  Branch (952:9): [True: 0, False: 1]
  ------------------
  953|      0|      return 0;
  954|      0|    }
  955|      1|    break;
  956|      1|  }
  957|      1|  return 1;
  958|      1|}
coap_delete_upa_chain:
 1271|     60|coap_delete_upa_chain(coap_upa_chain_t *chain) {
 1272|     60|  while (chain) {
  ------------------
  |  Branch (1272:10): [True: 0, False: 60]
  ------------------
 1273|      0|    coap_upa_chain_t *next = chain->next;
 1274|       |
 1275|      0|    coap_free_type(COAP_STRING, chain);
 1276|      0|    chain = next;
 1277|      0|  }
 1278|     60|}
coap_uri.c:coap_split_uri_sub:
   84|      8|                   coap_uri_check_t check_proxy) {
   85|      8|  const uint8_t *p, *q;
   86|      8|  int res = 0;
   87|      8|  size_t i;
   88|      8|  int is_unix_domain = 0;
   89|      8|  int is_llc = 0;
   90|       |
   91|      8|  if (!str_var || !uri || len == 0)
  ------------------
  |  Branch (91:7): [True: 0, False: 8]
  |  Branch (91:19): [True: 0, False: 8]
  |  Branch (91:27): [True: 0, False: 8]
  ------------------
   92|      0|    return -1;
   93|       |
   94|      8|  memset(uri, 0, sizeof(coap_uri_t));
   95|      8|  uri->port = COAP_DEFAULT_PORT;
  ------------------
  |  |   39|      8|#define COAP_DEFAULT_PORT      5683 /* CoAP default UDP/TCP port */
  ------------------
   96|       |
   97|       |  /* search for scheme */
   98|      8|  p = str_var;
   99|      8|  if (*p == '/') {
  ------------------
  |  Branch (99:7): [True: 0, False: 8]
  ------------------
  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|  1.30k|  while (len >= 3 && !(p[0] == ':' && p[1] == '/' && p[2] == '/')) {
  ------------------
  |  Branch (110:10): [True: 1.30k, False: 5]
  |  Branch (110:24): [True: 11, False: 1.29k]
  |  Branch (110:39): [True: 3, False: 8]
  |  Branch (110:54): [True: 3, False: 0]
  ------------------
  111|  1.30k|    ++p;
  112|  1.30k|    --len;
  113|  1.30k|  }
  114|      8|  if (len < 3) {
  ------------------
  |  Branch (114:7): [True: 5, False: 3]
  ------------------
  115|       |    /* scheme not defined with a :// terminator */
  116|      5|    res = -2;
  117|      5|    goto error;
  118|      5|  }
  119|     20|  for (i = 0; i < COAP_URI_SCHEME_LAST; i++) {
  ------------------
  |  Branch (119:15): [True: 18, False: 2]
  ------------------
  120|     18|    if ((p - str_var) == (int)strlen(coap_uri_scheme[i].name) &&
  ------------------
  |  Branch (120:9): [True: 1, False: 17]
  ------------------
  121|      1|        memcmp(str_var, coap_uri_scheme[i].name, p - str_var) == 0) {
  ------------------
  |  Branch (121:9): [True: 1, False: 0]
  ------------------
  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|     18|  }
  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|      1|  case COAP_URI_SCHEME_COAPS:
  ------------------
  |  Branch (141:3): [True: 1, False: 0]
  ------------------
  142|      1|    if (!coap_dtls_is_supported()) {
  ------------------
  |  Branch (142:9): [True: 0, False: 1]
  ------------------
  143|      0|      coap_log_err("coaps URI scheme not supported in this version of libcoap\n");
  ------------------
  |  |  102|      0|#define coap_log_err(...) coap_log(COAP_LOG_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  144|      0|      return -1;
  145|      0|    }
  146|      1|    break;
  147|      1|  case COAP_URI_SCHEME_COAP_TCP:
  ------------------
  |  Branch (147:3): [True: 0, False: 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|      0|  case COAP_URI_SCHEME_COAPS_TCP:
  ------------------
  |  Branch (153:3): [True: 0, False: 1]
  ------------------
  154|      0|    if (!coap_tls_is_supported()) {
  ------------------
  |  Branch (154:9): [True: 0, False: 0]
  ------------------
  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|      0|    break;
  159|      0|  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|    COAP_SET_STR(&uri->host, q - p, p);
  ------------------
  |  |   52|      0|#define COAP_SET_STR(st,l,v) { (st)->length = (l), (st)->s = (v); }
  ------------------
  204|      0|    ++q;
  205|      0|    --len;
  206|      0|#if COAP_AF_LLC_SUPPORT
  207|      1|  } else if ((len >= LLC_HOST_LEN) && strncmp((const char *)p, "llc[", 4) == 0) {
  ------------------
  |  |  169|      1|#define LLC_HOST_LEN (4 + HW_ADDRSTRLEN + 4)
  |  |  ------------------
  |  |  |  |  167|      1|#define HW_ADDRSTRLEN 17
  |  |  ------------------
  ------------------
  |  Branch (207:14): [True: 1, False: 0]
  |  Branch (207:39): [True: 0, False: 1]
  ------------------
  208|      0|    unsigned long sap = 0;
  209|       |
  210|      0|    is_llc = 1;
  211|       |
  212|      0|    while (len && *q != ']') {
  ------------------
  |  Branch (212:12): [True: 0, False: 0]
  |  Branch (212:19): [True: 0, False: 0]
  ------------------
  213|      0|      ++q;
  214|      0|      --len;
  215|      0|    }
  216|       |
  217|      0|    if (!len || *q != ']' || p == q) {
  ------------------
  |  Branch (217:9): [True: 0, False: 0]
  |  Branch (217:17): [True: 0, False: 0]
  |  Branch (217:30): [True: 0, False: 0]
  ------------------
  218|      0|      res = -7;
  219|      0|      goto error;
  220|      0|    }
  221|       |
  222|      0|    ++q;
  223|      0|    --len;
  224|       |
  225|      0|    if (!len || *q != ':') {
  ------------------
  |  Branch (225:9): [True: 0, False: 0]
  |  Branch (225:17): [True: 0, False: 0]
  ------------------
  226|      0|      coap_log_warn("LLC SAP missing in URI\n");
  ------------------
  |  |  108|      0|#define coap_log_warn(...) coap_log(COAP_LOG_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  227|      0|      res = -7;
  228|      0|      goto error;
  229|      0|    }
  230|       |
  231|      0|    ++q;
  232|      0|    --len;
  233|       |
  234|      0|    while (len && isxdigit(*q)) {
  ------------------
  |  Branch (234:12): [True: 0, False: 0]
  |  Branch (234:19): [True: 0, False: 0]
  ------------------
  235|      0|      if (*q >= 'a' && *q <= 'f')
  ------------------
  |  Branch (235:11): [True: 0, False: 0]
  |  Branch (235:24): [True: 0, False: 0]
  ------------------
  236|      0|        sap = sap * 16 + (*q - 'a' + 10);
  237|      0|      else if (*q >= 'A' && *q <= 'F')
  ------------------
  |  Branch (237:16): [True: 0, False: 0]
  |  Branch (237:29): [True: 0, False: 0]
  ------------------
  238|      0|        sap = sap * 16 + (*q - 'A' + 10);
  239|       |
  240|      0|      ++q;
  241|      0|      --len;
  242|      0|    }
  243|       |
  244|      0|    if (sap > UINT8_MAX) {
  ------------------
  |  Branch (244:9): [True: 0, False: 0]
  ------------------
  245|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  246|      0|      res = -7;
  247|      0|      goto error;
  248|      0|    }
  249|       |
  250|      0|    COAP_SET_STR(&uri->host, q - p, p);
  ------------------
  |  |   52|      0|#define COAP_SET_STR(st,l,v) { (st)->length = (l), (st)->s = (v); }
  ------------------
  251|      0|#endif /* COAP_AF_LLC_SUPPORT */
  252|      1|  } else {
  253|       |    /* IPv4 address, FQDN or Unix domain socket */
  254|      1|    if (len >= 3 && p[0] == '%' && p[1] == '2' &&
  ------------------
  |  Branch (254:9): [True: 1, False: 0]
  |  Branch (254:21): [True: 0, False: 1]
  |  Branch (254:36): [True: 0, False: 0]
  ------------------
  255|      0|        (p[2] == 'F' || p[2] == 'f')) {
  ------------------
  |  Branch (255:10): [True: 0, False: 0]
  |  Branch (255:25): [True: 0, False: 0]
  ------------------
  256|       |      /* Unix domain definition */
  257|      0|      uri->port = 0;
  258|      0|      is_unix_domain = 1;
  259|      0|    }
  260|      3|    while (len && *q != ':' && *q != '/' && *q != '?') {
  ------------------
  |  Branch (260:12): [True: 3, False: 0]
  |  Branch (260:19): [True: 3, False: 0]
  |  Branch (260:32): [True: 2, False: 1]
  |  Branch (260:45): [True: 2, False: 0]
  ------------------
  261|      2|      ++q;
  262|      2|      --len;
  263|      2|    }
  264|       |
  265|      1|    if (p == q) {
  ------------------
  |  Branch (265:9): [True: 0, False: 1]
  ------------------
  266|      0|      res = -3;
  267|      0|      goto error;
  268|      0|    }
  269|       |
  270|      1|    if ((int)(q - p) > 255) {
  ------------------
  |  Branch (270:9): [True: 0, False: 1]
  ------------------
  271|      0|      coap_log_warn("Host name length too long (%d > 255)\n", (int)(q - p));
  ------------------
  |  |  108|      0|#define coap_log_warn(...) coap_log(COAP_LOG_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  272|      0|      res = -6;
  273|      0|      goto error;
  274|      0|    }
  275|       |
  276|      1|    COAP_SET_STR(&uri->host, q - p, p);
  ------------------
  |  |   52|      1|#define COAP_SET_STR(st,l,v) { (st)->length = (l), (st)->s = (v); }
  ------------------
  277|      1|  }
  278|       |
  279|       |  /* check for Uri-Port (invalid for Unix) */
  280|      1|  if (len && *q == ':') {
  ------------------
  |  Branch (280:7): [True: 1, False: 0]
  |  Branch (280:14): [True: 0, False: 1]
  ------------------
  281|      0|    if (is_unix_domain || is_llc) {
  ------------------
  |  Branch (281:9): [True: 0, False: 0]
  |  Branch (281:27): [True: 0, False: 0]
  ------------------
  282|      0|      res = -5;
  283|      0|      goto error;
  284|      0|    }
  285|      0|    p = ++q;
  286|      0|    --len;
  287|       |
  288|      0|    while (len && isdigit(*q)) {
  ------------------
  |  Branch (288:12): [True: 0, False: 0]
  |  Branch (288:19): [True: 0, False: 0]
  ------------------
  289|      0|      ++q;
  290|      0|      --len;
  291|      0|    }
  292|       |
  293|      0|    if (p < q) {                /* explicit port number given */
  ------------------
  |  Branch (293:9): [True: 0, False: 0]
  ------------------
  294|      0|      long uri_port = 0;
  295|       |
  296|      0|      while ((p < q) && (uri_port <= UINT16_MAX))
  ------------------
  |  Branch (296:14): [True: 0, False: 0]
  |  Branch (296:25): [True: 0, False: 0]
  ------------------
  297|      0|        uri_port = uri_port * 10 + (*p++ - '0');
  298|       |
  299|       |      /* check if port number is in allowed range */
  300|      0|      if (uri_port > UINT16_MAX) {
  ------------------
  |  Branch (300:11): [True: 0, False: 0]
  ------------------
  301|      0|        coap_log_warn("Port number too big (%ld > 65535)\n", uri_port);
  ------------------
  |  |  108|      0|#define coap_log_warn(...) coap_log(COAP_LOG_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  302|      0|        res = -4;
  303|      0|        goto error;
  304|      0|      }
  305|       |
  306|      0|      uri->port = (uint16_t)uri_port;
  307|      0|    }
  308|      0|  }
  309|       |
  310|      1|path:                 /* at this point, p must point to an absolute path */
  311|       |
  312|      1|  if (!len)
  ------------------
  |  Branch (312:7): [True: 0, False: 1]
  ------------------
  313|      0|    goto end;
  314|       |
  315|      1|  if (*q == '/') {
  ------------------
  |  Branch (315:7): [True: 1, False: 0]
  ------------------
  316|      1|    p = ++q;
  317|      1|    --len;
  318|       |
  319|    246|    while (len && *q != '?') {
  ------------------
  |  Branch (319:12): [True: 245, False: 1]
  |  Branch (319:19): [True: 245, False: 0]
  ------------------
  320|    245|      ++q;
  321|    245|      --len;
  322|    245|    }
  323|       |
  324|      1|    if (p < q) {
  ------------------
  |  Branch (324:9): [True: 1, False: 0]
  ------------------
  325|      1|      COAP_SET_STR(&uri->path, q - p, p);
  ------------------
  |  |   52|      1|#define COAP_SET_STR(st,l,v) { (st)->length = (l), (st)->s = (v); }
  ------------------
  326|      1|      p = q;
  327|      1|    }
  328|      1|  }
  329|       |
  330|       |  /* Uri_Query */
  331|      1|  if (len && *p == '?') {
  ------------------
  |  Branch (331:7): [True: 0, False: 1]
  |  Branch (331:14): [True: 0, False: 0]
  ------------------
  332|      0|    ++p;
  333|      0|    --len;
  334|      0|    COAP_SET_STR(&uri->query, len, p);
  ------------------
  |  |   52|      0|#define COAP_SET_STR(st,l,v) { (st)->length = (l), (st)->s = (v); }
  ------------------
  335|      0|    len = 0;
  336|      0|  }
  337|       |
  338|      1|end:
  339|      1|  return len ? -1 : 0;
  ------------------
  |  Branch (339:10): [True: 0, False: 1]
  ------------------
  340|       |
  341|      7|error:
  342|      7|  return res;
  343|      1|}
coap_uri.c:strnchr:
   47|    245|strnchr(const uint8_t *s, size_t len, unsigned char c) {
   48|    735|  while (len && *s++ != c)
  ------------------
  |  Branch (48:10): [True: 490, False: 245]
  |  Branch (48:17): [True: 490, False: 0]
  ------------------
   49|    490|    --len;
   50|       |
   51|    245|  return len ? s : NULL;
  ------------------
  |  Branch (51:10): [True: 0, False: 245]
  ------------------
   52|    245|}

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:
  975|     50|oscore_release_recipient_ctx(oscore_recipient_ctx_t **recipient_ctx) {
  976|     50|  oscore_ctx_t *osc_ctx;
  977|       |
  978|     50|  if (recipient_ctx == NULL || *recipient_ctx == NULL)
  ------------------
  |  Branch (978:7): [True: 0, False: 50]
  |  Branch (978:32): [True: 50, False: 0]
  ------------------
  979|     50|    return;
  980|       |
  981|       |  /* ensure oscore context is freed if not attached to coap context */
  982|      0|  osc_ctx = (*recipient_ctx)->osc_ctx;
  983|      0|  oscore_free_recipient_ctx(*recipient_ctx);
  984|       |  /*
  985|       |   * Free temporary oscore context if not attached to a coap context
  986|       |   * and no recipients attached anymore.
  987|       |   */
  988|      0|  if (!oscore_is_context_attached(osc_ctx) && osc_ctx->recipient_chain == NULL) {
  ------------------
  |  Branch (988:7): [True: 0, False: 0]
  |  Branch (988:47): [True: 0, False: 0]
  ------------------
  989|      0|    oscore_free_context(osc_ctx);
  990|      0|  }
  991|       |  *recipient_ctx = NULL;
  992|      0|}
oscore_delete_server_associations:
 1093|     50|oscore_delete_server_associations(coap_session_t *session) {
 1094|     50|  if (session) {
  ------------------
  |  Branch (1094:7): [True: 50, False: 0]
  ------------------
 1095|     50|    oscore_association_t *association;
 1096|     50|    oscore_association_t *tmp;
 1097|       |
 1098|     50|    OSCORE_ASSOCIATIONS_ITER_SAFE(session->associations, association, tmp) {
  ------------------
  |  |  147|     50|  for ((el) = (e); (el) && ((rtmp) = (el)->hh.next, 1); (el) = (rtmp))
  |  |  ------------------
  |  |  |  Branch (147:20): [True: 0, False: 50]
  |  |  |  Branch (147:28): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1099|      0|      OSCORE_ASSOCIATIONS_DELETE(session->associations, association);
  ------------------
  |  |  140|      0|#define OSCORE_ASSOCIATIONS_DELETE(r, obj) HASH_DELETE(hh, (r), (obj))
  |  |  ------------------
  |  |  |  |  462|      0|    HASH_DELETE_HH(hh, head, &(delptr)->hh)
  |  |  |  |  ------------------
  |  |  |  |  |  |  464|      0|#define HASH_DELETE_HH(hh,head,delptrhh)                                         \
  |  |  |  |  |  |  465|      0|do {                                                                             \
  |  |  |  |  |  |  466|      0|  struct UT_hash_handle *_hd_hh_del = (delptrhh);                                \
  |  |  |  |  |  |  467|      0|  if ((_hd_hh_del->prev == NULL) && (_hd_hh_del->next == NULL)) {                \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (467:7): [True: 0, False: 0]
  |  |  |  |  |  |  |  Branch (467:37): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  468|      0|    HASH_BLOOM_FREE((head)->hh.tbl);                                             \
  |  |  |  |  |  |  469|      0|    uthash_free((head)->hh.tbl->buckets,                                         \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   92|      0|#define uthash_free(ptr,sz) free(ptr)     /* free fcn                        */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  470|      0|                (head)->hh.tbl->num_buckets * sizeof(struct UT_hash_bucket));    \
  |  |  |  |  |  |  471|      0|    uthash_free((head)->hh.tbl, sizeof(UT_hash_table));                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   92|      0|#define uthash_free(ptr,sz) free(ptr)     /* free fcn                        */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  472|      0|    (head) = NULL;                                                               \
  |  |  |  |  |  |  473|      0|  } else {                                                                       \
  |  |  |  |  |  |  474|      0|    uint32_t _hd_bkt;                                                            \
  |  |  |  |  |  |  475|      0|    if (_hd_hh_del == (head)->hh.tbl->tail) {                                    \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (475:9): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  476|      0|      (head)->hh.tbl->tail = HH_FROM_ELMT((head)->hh.tbl, _hd_hh_del->prev);     \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  150|      0|#define HH_FROM_ELMT(tbl,elp) ((UT_hash_handle*)(void*)(((char*)(elp)) + ((tbl)->hho)))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  477|      0|    }                                                                            \
  |  |  |  |  |  |  478|      0|    if (_hd_hh_del->prev != NULL) {                                              \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (478:9): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  479|      0|      HH_FROM_ELMT((head)->hh.tbl, _hd_hh_del->prev)->next = _hd_hh_del->next;   \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  150|      0|#define HH_FROM_ELMT(tbl,elp) ((UT_hash_handle*)(void*)(((char*)(elp)) + ((tbl)->hho)))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  480|      0|    } else {                                                                     \
  |  |  |  |  |  |  481|      0|      DECLTYPE_ASSIGN(head, _hd_hh_del->next);                                   \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   78|      0|#define DECLTYPE_ASSIGN(dst,src)                                                 \
  |  |  |  |  |  |  |  |   79|      0|do {                                                                             \
  |  |  |  |  |  |  |  |   80|      0|  (dst) = DECLTYPE(dst)(src);                                                    \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   66|      0|#define DECLTYPE(x) (__typeof(x))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   81|      0|} while (0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (81:10): [Folded, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  482|      0|    }                                                                            \
  |  |  |  |  |  |  483|      0|    if (_hd_hh_del->next != NULL) {                                              \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (483:9): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  484|      0|      HH_FROM_ELMT((head)->hh.tbl, _hd_hh_del->next)->prev = _hd_hh_del->prev;   \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  150|      0|#define HH_FROM_ELMT(tbl,elp) ((UT_hash_handle*)(void*)(((char*)(elp)) + ((tbl)->hho)))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  485|      0|    }                                                                            \
  |  |  |  |  |  |  486|      0|    HASH_TO_BKT(_hd_hh_del->hashv, (head)->hh.tbl->num_buckets, _hd_bkt);        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  444|      0|#define HASH_TO_BKT(hashv,num_bkts,bkt)                                          \
  |  |  |  |  |  |  |  |  445|      0|do {                                                                             \
  |  |  |  |  |  |  |  |  446|      0|  bkt = ((hashv) & ((num_bkts) - 1U));                                           \
  |  |  |  |  |  |  |  |  447|      0|} while (0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (447:10): [Folded, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  487|      0|    HASH_DEL_IN_BKT((head)->hh.tbl->buckets[_hd_bkt], _hd_hh_del);               \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  800|      0|#define HASH_DEL_IN_BKT(head,delhh)                                              \
  |  |  |  |  |  |  |  |  801|      0|do {                                                                             \
  |  |  |  |  |  |  |  |  802|      0|  UT_hash_bucket *_hd_head = &(head);                                            \
  |  |  |  |  |  |  |  |  803|      0|  _hd_head->count--;                                                             \
  |  |  |  |  |  |  |  |  804|      0|  if (_hd_head->hh_head == (delhh)) {                                            \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (804:7): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  805|      0|    _hd_head->hh_head = (delhh)->hh_next;                                        \
  |  |  |  |  |  |  |  |  806|      0|  }                                                                              \
  |  |  |  |  |  |  |  |  807|      0|  if ((delhh)->hh_prev) {                                                        \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (807:7): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  808|      0|    (delhh)->hh_prev->hh_next = (delhh)->hh_next;                                \
  |  |  |  |  |  |  |  |  809|      0|  }                                                                              \
  |  |  |  |  |  |  |  |  810|      0|  if ((delhh)->hh_next) {                                                        \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (810:7): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  811|      0|    (delhh)->hh_next->hh_prev = (delhh)->hh_prev;                                \
  |  |  |  |  |  |  |  |  812|      0|  }                                                                              \
  |  |  |  |  |  |  |  |  813|      0|} while (0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (813:10): [Folded, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  488|      0|    (head)->hh.tbl->num_items--;                                                 \
  |  |  |  |  |  |  489|      0|  }                                                                              \
  |  |  |  |  |  |  490|      0|  HASH_FSCK(hh, head, "HASH_DELETE_HH");                                         \
  |  |  |  |  |  |  491|      0|} while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (491:10): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1100|      0|      oscore_free_association(association);
 1101|      0|    }
 1102|       |    session->associations = NULL;
 1103|     50|  }
 1104|     50|}

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: 3, False: 27]
  |  Branch (135:45): [True: 17, False: 10]
  ------------------
  136|     20|    server_list.entry = &static_entry;
  137|     20|    server_list.entry_count = 1;
  138|     20|  }
  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: 15, False: 15]
  ------------------
  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: 14, False: 16]
  ------------------
  201|     14|      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: 25, False: 35]
  ------------------
  209|     25|      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: 4, False: 26]
  |  Branch (220:23): [True: 6, False: 20]
  ------------------
  221|       |    /* Proxy-Scheme value (option 39). The parser at coap_proxy.c:222-249
  222|       |     * branches on opt_len 4/5/7/8/9 to identify "coap" / "coaps" / "coap+ws"
  223|       |     * / "coap+tcp" / "coaps+tcp" — we want the fuzzer to discover those. */
  224|     10|    size_t n;
  225|     10|    const uint8_t *p = proxy_take(&c, 9, &n);
  226|     10|    if (n)
  ------------------
  |  Branch (226:9): [True: 2, False: 8]
  ------------------
  227|      2|      coap_add_option(request, COAP_OPTION_PROXY_SCHEME, n, p);
  228|     10|  }
  229|     30|  if (submode == 1 || submode == 2) {
  ------------------
  |  Branch (229:7): [True: 16, False: 14]
  |  Branch (229:23): [True: 6, False: 8]
  ------------------
  230|       |    /* Proxy-Uri value (option 35). Up to 1034 bytes per RFC 7252 — we cap at
  231|       |     * 256 to leave room for payload. The parser is coap_split_proxy_uri. */
  232|     22|    size_t n;
  233|     22|    const uint8_t *p = proxy_take(&c, 256, &n);
  234|     22|    if (n)
  ------------------
  |  Branch (234:9): [True: 9, False: 13]
  ------------------
  235|      9|      coap_add_option(request, COAP_OPTION_PROXY_URI, n, p);
  236|     22|  }
  237|       |
  238|       |  /* Optional Observe option (bit 7 of mode, 4 bytes max). Triggers the proxy's
  239|       |   * observe-cache logic if a proxy_response_cb were registered. */
  240|     30|  if ((mode >> 7) & 0x01) {
  ------------------
  |  Branch (240:7): [True: 20, False: 10]
  ------------------
  241|     20|    size_t n;
  242|     20|    const uint8_t *p = proxy_take(&c, 4, &n);
  243|     20|    if (n)
  ------------------
  |  Branch (243:9): [True: 7, False: 13]
  ------------------
  244|      7|      coap_add_option(request, COAP_OPTION_OBSERVE, n, p);
  245|     20|  }
  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: 9, False: 21]
  ------------------
  251|     30|    if (n)
  ------------------
  |  Branch (251:9): [True: 9, False: 21]
  ------------------
  252|      9|      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|    202|proxy_take(proxy_cursor_t *c, size_t max, size_t *out_len) {
   59|    202|  size_t avail = c->size > c->pos ? c->size - c->pos : 0;
  ------------------
  |  Branch (59:18): [True: 96, False: 106]
  ------------------
   60|    202|  size_t take = avail < max ? avail : max;
  ------------------
  |  Branch (60:17): [True: 106, False: 96]
  ------------------
   61|    202|  const uint8_t *p = c->data + c->pos;
   62|    202|  c->pos += take;
   63|    202|  *out_len = take;
   64|    202|  return p;
   65|    202|}

