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

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

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

coap_delete_cache_key:
  162|     12|coap_delete_cache_key(coap_cache_key_t *cache_key) {
  163|     12|  coap_free_type(COAP_CACHE_KEY, cache_key);
  164|     12|}

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

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

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

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

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

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

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

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

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

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

coap_opt_parse:
   41|    471|coap_opt_parse(const coap_opt_t *opt, size_t length, coap_option_t *result) {
   42|       |
   43|    471|  const coap_opt_t *opt_start = opt; /* store where parsing starts  */
   44|       |
   45|    471|  assert(opt);
  ------------------
  |  Branch (45:3): [True: 471, False: 0]
  ------------------
   46|    471|  assert(result);
  ------------------
  |  Branch (46:3): [True: 471, False: 0]
  ------------------
   47|       |
   48|    471|  if (length < 1)
  ------------------
  |  Branch (48:7): [True: 49, False: 422]
  ------------------
   49|     49|    return 0;
   50|       |
   51|    422|  result->delta = (*opt & 0xf0) >> 4;
   52|    422|  result->length = *opt & 0x0f;
   53|       |
   54|    422|  switch (result->delta) {
   55|      4|  case 15:
  ------------------
  |  Branch (55:3): [True: 4, False: 418]
  ------------------
   56|      4|    if (*opt != COAP_PAYLOAD_START) {
  ------------------
  |  |   96|      4|#define COAP_PAYLOAD_START 0xFF /* payload marker */
  ------------------
  |  Branch (56:9): [True: 0, False: 4]
  ------------------
   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|      4|    return 0;
   60|      0|  case 14:
  ------------------
  |  Branch (60:3): [True: 0, False: 422]
  ------------------
   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|     52|  case 13:
  ------------------
  |  Branch (71:3): [True: 52, False: 370]
  ------------------
   72|     52|    ADVANCE_OPT_CHECK(opt,length,1);
  ------------------
  |  |   34|     52|#define ADVANCE_OPT_CHECK(o,e,step) do { \
  |  |   35|     52|    ADVANCE_OPT(o,e,step);               \
  |  |  ------------------
  |  |  |  |   22|     52|#define ADVANCE_OPT(o,e,step) if ((e) < step) {           \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (22:35): [True: 0, False: 52]
  |  |  |  |  ------------------
  |  |  |  |   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|     52|  } else {                                                \
  |  |  |  |   26|     52|    (e) -= step;                                          \
  |  |  |  |   27|     52|    (o) = ((o)) + step;                                   \
  |  |  |  |   28|     52|  }
  |  |  ------------------
  |  |   36|     52|    if ((e) < 1)                         \
  |  |  ------------------
  |  |  |  Branch (36:9): [True: 0, False: 52]
  |  |  ------------------
  |  |   37|     52|      return 0;                          \
  |  |   38|     52|  } while (0)
  |  |  ------------------
  |  |  |  Branch (38:12): [Folded, False: 52]
  |  |  ------------------
  ------------------
   73|     52|    result->delta += *opt & 0xff;
   74|     52|    break;
   75|       |
   76|    366|  default:
  ------------------
  |  Branch (76:3): [True: 366, False: 56]
  ------------------
   77|    366|    ;
   78|    422|  }
   79|       |
   80|    418|  switch (result->length) {
   81|      0|  case 15:
  ------------------
  |  Branch (81:3): [True: 0, False: 418]
  ------------------
   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: 418]
  ------------------
   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|    239|  case 13:
  ------------------
  |  Branch (91:3): [True: 239, False: 179]
  ------------------
   92|    239|    ADVANCE_OPT_CHECK(opt,length,1);
  ------------------
  |  |   34|    239|#define ADVANCE_OPT_CHECK(o,e,step) do { \
  |  |   35|    239|    ADVANCE_OPT(o,e,step);               \
  |  |  ------------------
  |  |  |  |   22|    239|#define ADVANCE_OPT(o,e,step) if ((e) < step) {           \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (22:35): [True: 0, False: 239]
  |  |  |  |  ------------------
  |  |  |  |   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|    239|  } else {                                                \
  |  |  |  |   26|    239|    (e) -= step;                                          \
  |  |  |  |   27|    239|    (o) = ((o)) + step;                                   \
  |  |  |  |   28|    239|  }
  |  |  ------------------
  |  |   36|    239|    if ((e) < 1)                         \
  |  |  ------------------
  |  |  |  Branch (36:9): [True: 0, False: 239]
  |  |  ------------------
  |  |   37|    239|      return 0;                          \
  |  |   38|    239|  } while (0)
  |  |  ------------------
  |  |  |  Branch (38:12): [Folded, False: 239]
  |  |  ------------------
  ------------------
   93|    239|    result->length += *opt & 0xff;
   94|    239|    break;
   95|       |
   96|    179|  default:
  ------------------
  |  Branch (96:3): [True: 179, False: 239]
  ------------------
   97|    179|    ;
   98|    418|  }
   99|       |
  100|       |  /* ADVANCE_OPT() is correct here */
  101|    418|  ADVANCE_OPT(opt,length,1);
  ------------------
  |  |   22|    418|#define ADVANCE_OPT(o,e,step) if ((e) < step) {           \
  |  |  ------------------
  |  |  |  Branch (22:35): [True: 0, False: 418]
  |  |  ------------------
  |  |   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|    418|  } else {                                                \
  |  |   26|    418|    (e) -= step;                                          \
  |  |   27|    418|    (o) = ((o)) + step;                                   \
  |  |   28|    418|  }
  ------------------
  102|       |  /* opt now points to value, if present */
  103|       |
  104|    418|  result->value = opt;
  105|    418|  if (length < result->length) {
  ------------------
  |  Branch (105:7): [True: 0, False: 418]
  ------------------
  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|    418|#undef ADVANCE_OPT
  111|    418|#undef ADVANCE_OPT_CHECK
  112|       |
  113|    418|  return (opt + result->length) - opt_start;
  114|    418|}
coap_option_iterator_init:
  118|     93|                          const coap_opt_filter_t *filter) {
  119|     93|  assert(pdu);
  ------------------
  |  Branch (119:3): [True: 93, False: 0]
  ------------------
  120|     93|  assert(pdu->token);
  ------------------
  |  Branch (120:3): [True: 93, False: 0]
  ------------------
  121|     93|  assert(oi);
  ------------------
  |  Branch (121:3): [True: 93, False: 0]
  ------------------
  122|       |
  123|     93|  memset(oi, 0, sizeof(coap_opt_iterator_t));
  124|       |
  125|     93|  oi->next_option = pdu->token + pdu->e_token_length;
  126|     93|  if (pdu->token + pdu->used_size <= oi->next_option) {
  ------------------
  |  Branch (126:7): [True: 0, False: 93]
  ------------------
  127|      0|    oi->bad = 1;
  128|      0|    return NULL;
  129|      0|  }
  130|       |
  131|     93|  oi->length = pdu->used_size - pdu->e_token_length;
  132|       |
  133|     93|  if (filter) {
  ------------------
  |  Branch (133:7): [True: 73, False: 20]
  ------------------
  134|     73|    memcpy(&oi->filter, filter, sizeof(coap_opt_filter_t));
  135|     73|    oi->filtered = 1;
  136|     73|  }
  137|     93|  return oi;
  138|     93|}
coap_option_next:
  153|    176|coap_option_next(coap_opt_iterator_t *oi) {
  154|    176|  coap_option_t option;
  155|    176|  coap_opt_t *current_opt = NULL;
  156|    176|  size_t optsize;
  157|       |
  158|    176|  assert(oi);
  ------------------
  |  Branch (158:3): [True: 176, False: 0]
  ------------------
  159|       |
  160|    176|  if (opt_finished(oi))
  ------------------
  |  Branch (160:7): [True: 6, False: 170]
  ------------------
  161|      6|    return NULL;
  162|       |
  163|    465|  while (1) {
  ------------------
  |  Branch (163:10): [True: 465, 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|    465|    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|    465|    optsize = coap_opt_parse(oi->next_option, oi->length, &option);
  174|    465|    if (optsize) {
  ------------------
  |  Branch (174:9): [True: 412, False: 53]
  ------------------
  175|    412|      assert(optsize <= oi->length);
  ------------------
  |  Branch (175:7): [True: 412, False: 0]
  ------------------
  176|       |
  177|    412|      oi->next_option += optsize;
  178|    412|      oi->length -= optsize;
  179|       |
  180|    412|      oi->number += option.delta;
  181|    412|    } else {                        /* current option is malformed */
  182|     53|      oi->bad = 1;
  183|     53|      return NULL;
  184|     53|    }
  185|       |
  186|       |    /* Exit the while loop when:
  187|       |     *   - no filtering is done at all
  188|       |     *   - the filter matches for the current option
  189|       |     */
  190|    412|    if (!oi->filtered ||
  ------------------
  |  Branch (190:9): [True: 97, False: 315]
  ------------------
  191|    315|        coap_option_filter_get(&oi->filter, oi->number) > 0)
  ------------------
  |  Branch (191:9): [True: 20, False: 295]
  ------------------
  192|    117|      break;
  193|    412|  }
  194|       |
  195|    117|  return current_opt;
  196|    170|}
coap_check_option:
  200|     73|                  coap_opt_iterator_t *oi) {
  201|     73|  coap_opt_filter_t f;
  202|       |
  203|     73|  coap_option_filter_clear(&f);
  204|     73|  coap_option_filter_set(&f, number);
  205|       |
  206|     73|  coap_option_iterator_init(pdu, oi, &f);
  207|       |
  208|     73|  return coap_option_next(oi);
  209|     73|}
coap_opt_length:
  212|     27|coap_opt_length(const coap_opt_t *opt) {
  213|     27|  uint32_t length;
  214|       |
  215|     27|  length = *opt & 0x0f;
  216|     27|  switch (*opt & 0xf0) {
  217|      0|  case 0xf0:
  ------------------
  |  Branch (217:3): [True: 0, False: 27]
  ------------------
  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: 27]
  ------------------
  221|      0|    ++opt;
  222|       |  /* fall through */
  223|       |  /* to skip another byte */
  224|      9|  case 0xd0:
  ------------------
  |  Branch (224:3): [True: 9, False: 18]
  ------------------
  225|      9|    ++opt;
  226|       |  /* fall through */
  227|       |  /* to skip another byte */
  228|     27|  default:
  ------------------
  |  Branch (228:3): [True: 18, False: 9]
  ------------------
  229|     27|    ++opt;
  230|     27|  }
  231|       |
  232|     27|  switch (length) {
  233|      0|  case 0x0f:
  ------------------
  |  Branch (233:3): [True: 0, False: 27]
  ------------------
  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: 27]
  ------------------
  237|      0|    length = (*opt++ << 8) + 269;
  238|       |  /* fall through */
  239|     15|  case 0x0d:
  ------------------
  |  Branch (239:3): [True: 15, False: 12]
  ------------------
  240|     15|    length += *opt++;
  241|     15|    break;
  242|     12|  default:
  ------------------
  |  Branch (242:3): [True: 12, False: 15]
  ------------------
  243|     12|    ;
  244|     27|  }
  245|     27|  return length;
  246|     27|}
coap_opt_value:
  249|     27|coap_opt_value(const coap_opt_t *opt) {
  250|     27|  size_t ofs = 1;
  251|       |
  252|     27|  switch (*opt & 0xf0) {
  253|      0|  case 0xf0:
  ------------------
  |  Branch (253:3): [True: 0, False: 27]
  ------------------
  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: 27]
  ------------------
  257|      0|    ++ofs;
  258|       |  /* fall through */
  259|      9|  case 0xd0:
  ------------------
  |  Branch (259:3): [True: 9, False: 18]
  ------------------
  260|      9|    ++ofs;
  261|      9|    break;
  262|     18|  default:
  ------------------
  |  Branch (262:3): [True: 18, False: 9]
  ------------------
  263|     18|    ;
  264|     27|  }
  265|       |
  266|     27|  switch (*opt & 0x0f) {
  267|      0|  case 0x0f:
  ------------------
  |  Branch (267:3): [True: 0, False: 27]
  ------------------
  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: 27]
  ------------------
  271|      0|    ++ofs;
  272|       |  /* fall through */
  273|     15|  case 0x0d:
  ------------------
  |  Branch (273:3): [True: 15, False: 12]
  ------------------
  274|     15|    ++ofs;
  275|     15|    break;
  276|     12|  default:
  ------------------
  |  Branch (276:3): [True: 12, False: 15]
  ------------------
  277|     12|    ;
  278|     27|  }
  279|       |
  280|     27|  return (const uint8_t *)opt + ofs;
  281|     27|}
coap_opt_setheader:
  293|    134|                   uint16_t delta, size_t length) {
  294|    134|  size_t skip = 0;
  295|       |
  296|    134|  assert(opt);
  ------------------
  |  Branch (296:3): [True: 134, False: 0]
  ------------------
  297|       |
  298|    134|  if (maxlen == 0)                /* need at least one byte */
  ------------------
  |  Branch (298:7): [True: 0, False: 134]
  ------------------
  299|      0|    return 0;
  300|       |
  301|    134|  if (delta < 13) {
  ------------------
  |  Branch (301:7): [True: 112, False: 22]
  ------------------
  302|    112|    opt[0] = (coap_opt_t)(delta << 4);
  303|    112|  } else if (delta < 269) {
  ------------------
  |  Branch (303:14): [True: 22, False: 0]
  ------------------
  304|     22|    if (maxlen < 2) {
  ------------------
  |  Branch (304:9): [True: 0, False: 22]
  ------------------
  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|     22|    opt[0] = 0xd0;
  311|     22|    opt[++skip] = (coap_opt_t)(delta - 13);
  312|     22|  } 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|    134|  if (length < 13) {
  ------------------
  |  Branch (324:7): [True: 65, False: 69]
  ------------------
  325|     65|    opt[0] |= length & 0x0f;
  326|     69|  } else if (length < 269) {
  ------------------
  |  Branch (326:14): [True: 69, False: 0]
  ------------------
  327|     69|    if (maxlen < skip + 2) {
  ------------------
  |  Branch (327:9): [True: 0, False: 69]
  ------------------
  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|     69|    opt[0] |= 0x0d;
  334|     69|    opt[++skip] = (coap_opt_t)(length - 13);
  335|     69|  } 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|    134|  return skip + 1;
  348|    134|}
coap_opt_encode_size:
  351|    134|coap_opt_encode_size(uint16_t delta, size_t length) {
  352|    134|  size_t n = 1;
  353|       |
  354|    134|  if (delta >= 13) {
  ------------------
  |  Branch (354:7): [True: 22, False: 112]
  ------------------
  355|     22|    if (delta < 269)
  ------------------
  |  Branch (355:9): [True: 22, False: 0]
  ------------------
  356|     22|      n += 1;
  357|      0|    else
  358|      0|      n += 2;
  359|     22|  }
  360|       |
  361|    134|  if (length >= 13) {
  ------------------
  |  Branch (361:7): [True: 69, False: 65]
  ------------------
  362|     69|    if (length < 269)
  ------------------
  |  Branch (362:9): [True: 69, False: 0]
  ------------------
  363|     69|      n += 1;
  364|      0|    else
  365|      0|      n += 2;
  366|     69|  }
  367|       |
  368|    134|  return n + length;
  369|    134|}
coap_opt_encode:
  373|    134|                const uint8_t *val, size_t length) {
  374|    134|  size_t l = 1;
  375|       |
  376|    134|  l = coap_opt_setheader(opt, maxlen, delta, length);
  377|    134|  assert(l <= maxlen);
  ------------------
  |  Branch (377:3): [True: 134, False: 0]
  ------------------
  378|       |
  379|    134|  if (!l) {
  ------------------
  |  Branch (379:7): [True: 0, False: 134]
  ------------------
  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|    134|  maxlen -= l;
  385|    134|  opt += l;
  386|       |
  387|    134|  if (maxlen < length) {
  ------------------
  |  Branch (387:7): [True: 0, False: 134]
  ------------------
  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|    134|  if (val)                        /* better be safe here */
  ------------------
  |  Branch (392:7): [True: 134, False: 0]
  ------------------
  393|    134|    memcpy(opt, val, length);
  394|       |
  395|    134|  return l + length;
  396|    134|}
coap_option_filter_clear:
  491|     73|coap_option_filter_clear(coap_opt_filter_t *filter) {
  492|     73|  memset(filter, 0, sizeof(coap_opt_filter_t));
  493|     73|}
coap_option_filter_set:
  496|     73|coap_option_filter_set(coap_opt_filter_t *filter, coap_option_num_t option) {
  497|     73|  return coap_option_filter_op(filter, option, FILTER_SET);
  498|     73|}
coap_option_filter_get:
  506|    315|coap_option_filter_get(coap_opt_filter_t *filter, coap_option_num_t option) {
  507|    315|  return coap_option_filter_op(filter, option, FILTER_GET);
  508|    315|}
coap_new_optlist:
  513|     26|                 const uint8_t *data) {
  514|     26|  coap_optlist_t *node;
  515|       |
  516|     26|  if (!coap_pdu_parse_opt_base(number, length, data)) {
  ------------------
  |  Branch (516:7): [True: 0, False: 26]
  ------------------
  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|     26|  node = coap_malloc_type(COAP_OPTLIST, sizeof(coap_optlist_t) + length);
  528|       |
  529|     26|  if (node) {
  ------------------
  |  Branch (529:7): [True: 26, False: 0]
  ------------------
  530|     26|    memset(node, 0, (sizeof(coap_optlist_t) + length));
  531|     26|    node->number = number;
  532|     26|    node->length = length;
  533|     26|    node->data = (uint8_t *)&node[1];
  534|     26|    memcpy(node->data, data, length);
  535|     26|  } 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|     26|  return node;
  540|     26|}
coap_add_optlist_pdu:
  554|      6|coap_add_optlist_pdu(coap_pdu_t *pdu, coap_optlist_t **options) {
  555|      6|  coap_optlist_t *opt;
  556|       |
  557|      6|  if (options && *options) {
  ------------------
  |  Branch (557:7): [True: 6, False: 0]
  |  Branch (557:18): [True: 2, False: 4]
  ------------------
  558|      2|    if (pdu->data) {
  ------------------
  |  Branch (558:9): [True: 0, False: 2]
  ------------------
  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|      2|    LL_SORT((*options), order_opts);
  ------------------
  |  |  114|      2|    LL_SORT2(list, cmp, next)
  |  |  ------------------
  |  |  |  |  116|      2|#define LL_SORT2(list, cmp, next)                                                              \
  |  |  |  |  117|      2|do {                                                                                           \
  |  |  |  |  118|      2|  LDECLTYPE(list) _ls_p;                                                                       \
  |  |  |  |  ------------------
  |  |  |  |  |  |   81|      2|#define LDECLTYPE(x) __typeof(x)
  |  |  |  |  ------------------
  |  |  |  |  119|      2|  LDECLTYPE(list) _ls_q;                                                                       \
  |  |  |  |  ------------------
  |  |  |  |  |  |   81|      2|#define LDECLTYPE(x) __typeof(x)
  |  |  |  |  ------------------
  |  |  |  |  120|      2|  LDECLTYPE(list) _ls_e;                                                                       \
  |  |  |  |  ------------------
  |  |  |  |  |  |   81|      2|#define LDECLTYPE(x) __typeof(x)
  |  |  |  |  ------------------
  |  |  |  |  121|      2|  LDECLTYPE(list) _ls_tail;                                                                    \
  |  |  |  |  ------------------
  |  |  |  |  |  |   81|      2|#define LDECLTYPE(x) __typeof(x)
  |  |  |  |  ------------------
  |  |  |  |  122|      2|  IF_NO_DECLTYPE(LDECLTYPE(list) _tmp;)                                                        \
  |  |  |  |  123|      2|  int _ls_insize, _ls_nmerges, _ls_psize, _ls_qsize, _ls_i, _ls_looping;                       \
  |  |  |  |  124|      2|  if (list) {                                                                                  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (124:7): [True: 2, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  125|      2|    _ls_insize = 1;                                                                            \
  |  |  |  |  126|      2|    _ls_looping = 1;                                                                           \
  |  |  |  |  127|      8|    while (_ls_looping) {                                                                      \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (127:12): [True: 6, False: 2]
  |  |  |  |  ------------------
  |  |  |  |  128|      6|      UTLIST_CASTASGN(_ls_p,list);                                                             \
  |  |  |  |  ------------------
  |  |  |  |  |  |  106|      6|#define UTLIST_CASTASGN(a,b) (a)=(b)
  |  |  |  |  ------------------
  |  |  |  |  129|      6|      (list) = NULL;                                                                           \
  |  |  |  |  130|      6|      _ls_tail = NULL;                                                                         \
  |  |  |  |  131|      6|      _ls_nmerges = 0;                                                                         \
  |  |  |  |  132|     28|      while (_ls_p) {                                                                          \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (132:14): [True: 22, False: 6]
  |  |  |  |  ------------------
  |  |  |  |  133|     22|        _ls_nmerges++;                                                                         \
  |  |  |  |  134|     22|        _ls_q = _ls_p;                                                                         \
  |  |  |  |  135|     22|        _ls_psize = 0;                                                                         \
  |  |  |  |  136|     77|        for (_ls_i = 0; _ls_i < _ls_insize; _ls_i++) {                                         \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (136:25): [True: 59, False: 18]
  |  |  |  |  ------------------
  |  |  |  |  137|     59|          _ls_psize++;                                                                         \
  |  |  |  |  138|     59|          UTLIST_SV(_ls_q,list); _ls_q = UTLIST_NEXT(_ls_q,list,next); UTLIST_RS(list);        \
  |  |  |  |  ------------------
  |  |  |  |  |  |  101|     59|#define UTLIST_NEXT(elt,list,next) ((elt)->next)
  |  |  |  |  ------------------
  |  |  |  |  139|     59|          if (!_ls_q) break;                                                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (139:15): [True: 4, False: 55]
  |  |  |  |  ------------------
  |  |  |  |  140|     59|        }                                                                                      \
  |  |  |  |  141|     22|        _ls_qsize = _ls_insize;                                                                \
  |  |  |  |  142|    118|        while (_ls_psize > 0 || (_ls_qsize > 0 && _ls_q)) {                                    \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (142:16): [True: 75, False: 43]
  |  |  |  |  |  Branch (142:34): [True: 27, False: 16]
  |  |  |  |  |  Branch (142:51): [True: 21, False: 6]
  |  |  |  |  ------------------
  |  |  |  |  143|     96|          if (_ls_psize == 0) {                                                                \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (143:15): [True: 21, False: 75]
  |  |  |  |  ------------------
  |  |  |  |  144|     21|            _ls_e = _ls_q; UTLIST_SV(_ls_q,list); _ls_q =                                      \
  |  |  |  |  145|     21|              UTLIST_NEXT(_ls_q,list,next); UTLIST_RS(list); _ls_qsize--;                      \
  |  |  |  |  ------------------
  |  |  |  |  |  |  101|     21|#define UTLIST_NEXT(elt,list,next) ((elt)->next)
  |  |  |  |  ------------------
  |  |  |  |  146|     75|          } else if (_ls_qsize == 0 || !_ls_q) {                                               \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:22): [True: 3, False: 72]
  |  |  |  |  |  Branch (146:40): [True: 9, False: 63]
  |  |  |  |  ------------------
  |  |  |  |  147|     12|            _ls_e = _ls_p; UTLIST_SV(_ls_p,list); _ls_p =                                      \
  |  |  |  |  148|     12|              UTLIST_NEXT(_ls_p,list,next); UTLIST_RS(list); _ls_psize--;                      \
  |  |  |  |  ------------------
  |  |  |  |  |  |  101|     12|#define UTLIST_NEXT(elt,list,next) ((elt)->next)
  |  |  |  |  ------------------
  |  |  |  |  149|     63|          } else if (cmp(_ls_p,_ls_q) <= 0) {                                                  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (149:22): [True: 47, False: 16]
  |  |  |  |  ------------------
  |  |  |  |  150|     47|            _ls_e = _ls_p; UTLIST_SV(_ls_p,list); _ls_p =                                      \
  |  |  |  |  151|     47|              UTLIST_NEXT(_ls_p,list,next); UTLIST_RS(list); _ls_psize--;                      \
  |  |  |  |  ------------------
  |  |  |  |  |  |  101|     47|#define UTLIST_NEXT(elt,list,next) ((elt)->next)
  |  |  |  |  ------------------
  |  |  |  |  152|     47|          } else {                                                                             \
  |  |  |  |  153|     16|            _ls_e = _ls_q; UTLIST_SV(_ls_q,list); _ls_q =                                      \
  |  |  |  |  154|     16|              UTLIST_NEXT(_ls_q,list,next); UTLIST_RS(list); _ls_qsize--;                      \
  |  |  |  |  ------------------
  |  |  |  |  |  |  101|     16|#define UTLIST_NEXT(elt,list,next) ((elt)->next)
  |  |  |  |  ------------------
  |  |  |  |  155|     16|          }                                                                                    \
  |  |  |  |  156|     96|          if (_ls_tail) {                                                                      \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:15): [True: 90, False: 6]
  |  |  |  |  ------------------
  |  |  |  |  157|     90|            UTLIST_SV(_ls_tail,list); UTLIST_NEXTASGN(_ls_tail,list,_ls_e,next); UTLIST_RS(list); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  102|     90|#define UTLIST_NEXTASGN(elt,list,to,next) ((elt)->next)=(to)
  |  |  |  |  ------------------
  |  |  |  |  158|     90|          } else {                                                                             \
  |  |  |  |  159|      6|            UTLIST_CASTASGN(list,_ls_e);                                                       \
  |  |  |  |  ------------------
  |  |  |  |  |  |  106|      6|#define UTLIST_CASTASGN(a,b) (a)=(b)
  |  |  |  |  ------------------
  |  |  |  |  160|      6|          }                                                                                    \
  |  |  |  |  161|     96|          _ls_tail = _ls_e;                                                                    \
  |  |  |  |  162|     96|        }                                                                                      \
  |  |  |  |  163|     22|        _ls_p = _ls_q;                                                                         \
  |  |  |  |  164|     22|      }                                                                                        \
  |  |  |  |  165|      6|      if (_ls_tail) {                                                                          \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (165:11): [True: 6, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  166|      6|        UTLIST_SV(_ls_tail,list); UTLIST_NEXTASGN(_ls_tail,list,NULL,next); UTLIST_RS(list);   \
  |  |  |  |  ------------------
  |  |  |  |  |  |  102|      6|#define UTLIST_NEXTASGN(elt,list,to,next) ((elt)->next)=(to)
  |  |  |  |  ------------------
  |  |  |  |  167|      6|      }                                                                                        \
  |  |  |  |  168|      6|      if (_ls_nmerges <= 1) {                                                                  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:11): [True: 2, False: 4]
  |  |  |  |  ------------------
  |  |  |  |  169|      2|        _ls_looping=0;                                                                         \
  |  |  |  |  170|      2|      }                                                                                        \
  |  |  |  |  171|      6|      _ls_insize *= 2;                                                                         \
  |  |  |  |  172|      6|    }                                                                                          \
  |  |  |  |  173|      2|  }                                                                                            \
  |  |  |  |  174|      2|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (174:10): [Folded, False: 2]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  564|       |
  565|     20|    LL_FOREACH((*options), opt) {
  ------------------
  |  |  419|      2|    LL_FOREACH2(head,el,next)
  |  |  ------------------
  |  |  |  |  422|     22|    for ((el) = (head); el; (el) = (el)->next)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (422:25): [True: 20, False: 2]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  566|     20|      if (!coap_add_option_internal(pdu, opt->number, opt->length, opt->data))
  ------------------
  |  Branch (566:11): [True: 0, False: 20]
  ------------------
  567|      0|        return 0;
  568|     20|    }
  569|      2|  }
  570|      6|  return 1;
  571|      6|}
coap_insert_optlist:
  584|     26|coap_insert_optlist(coap_optlist_t **head, coap_optlist_t *node) {
  585|     26|  if (!node) {
  ------------------
  |  Branch (585:7): [True: 0, False: 26]
  ------------------
  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|     26|  } else {
  588|       |    /* must append at the list end to avoid re-ordering of
  589|       |     * options during sort */
  590|     26|    LL_APPEND((*head), node);
  ------------------
  |  |  344|     26|    LL_APPEND2(head,add,next)
  |  |  ------------------
  |  |  |  |  346|     26|#define LL_APPEND2(head,add,next)                                                              \
  |  |  |  |  347|     26|do {                                                                                           \
  |  |  |  |  348|     26|  LDECLTYPE(head) _tmp;                                                                        \
  |  |  |  |  ------------------
  |  |  |  |  |  |   81|     26|#define LDECLTYPE(x) __typeof(x)
  |  |  |  |  ------------------
  |  |  |  |  349|     26|  (add)->next=NULL;                                                                            \
  |  |  |  |  350|     26|  if (head) {                                                                                  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (350:7): [True: 22, False: 4]
  |  |  |  |  ------------------
  |  |  |  |  351|     22|    _tmp = (head);                                                                             \
  |  |  |  |  352|    177|    while (_tmp->next) { _tmp = _tmp->next; }                                                  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (352:12): [True: 155, False: 22]
  |  |  |  |  ------------------
  |  |  |  |  353|     22|    _tmp->next=(add);                                                                          \
  |  |  |  |  354|     22|  } else {                                                                                     \
  |  |  |  |  355|      4|    (head)=(add);                                                                              \
  |  |  |  |  356|      4|  }                                                                                            \
  |  |  |  |  357|     26|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (357:10): [Folded, False: 26]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  591|     26|  }
  592|       |
  593|       |  return node != NULL;
  594|     26|}
coap_delete_optlist:
  605|      8|coap_delete_optlist(coap_optlist_t *queue) {
  606|      8|  coap_optlist_t *elt, *tmp;
  607|       |
  608|      8|  if (!queue)
  ------------------
  |  Branch (608:7): [True: 4, False: 4]
  ------------------
  609|      4|    return;
  610|       |
  611|     26|  LL_FOREACH_SAFE(queue, elt, tmp) {
  ------------------
  |  |  425|      4|    LL_FOREACH_SAFE2(head,el,tmp,next)
  |  |  ------------------
  |  |  |  |  428|     30|  for ((el) = (head); (el) && ((tmp) = (el)->next, 1); (el) = (tmp))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (428:23): [True: 26, False: 4]
  |  |  |  |  |  Branch (428:31): [True: 26, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  612|     26|    coap_internal_delete(elt);
  613|     26|  }
  614|      4|}
coap_option.c:opt_finished:
  141|    176|opt_finished(coap_opt_iterator_t *oi) {
  142|    176|  assert(oi);
  ------------------
  |  Branch (142:3): [True: 176, False: 0]
  ------------------
  143|       |
  144|    176|  if (oi->bad || oi->length == 0 ||
  ------------------
  |  Branch (144:7): [True: 0, False: 176]
  |  Branch (144:18): [True: 6, False: 170]
  ------------------
  145|    170|      !oi->next_option || *oi->next_option == COAP_PAYLOAD_START) {
  ------------------
  |  |   96|    170|#define COAP_PAYLOAD_START 0xFF /* payload marker */
  ------------------
  |  Branch (145:7): [True: 0, False: 170]
  |  Branch (145:27): [True: 0, False: 170]
  ------------------
  146|      6|    oi->bad = 1;
  147|      6|  }
  148|       |
  149|    176|  return oi->bad;
  150|    176|}
coap_option.c:coap_option_filter_op:
  433|    388|                      enum filter_op_t op) {
  434|    388|  size_t lindex = 0;
  435|    388|  coap_opt_filter_t *of = filter;
  436|    388|  uint16_t nr, mask = 0;
  437|       |
  438|    388|  if (is_long_option(number)) {
  ------------------
  |  Branch (438:7): [True: 0, False: 388]
  ------------------
  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|    388|  } else {
  452|    388|    mask = SHORT_MASK;
  ------------------
  |  |  400|    388|  (~LONG_MASK & ((1 << (COAP_OPT_FILTER_LONG + COAP_OPT_FILTER_SHORT)) - 1))
  |  |  ------------------
  |  |  |  |  398|    388|#define LONG_MASK ((1 << COAP_OPT_FILTER_LONG) - 1)
  |  |  |  |  ------------------
  |  |  |  |  |  |  208|    388|#define COAP_OPT_FILTER_LONG  2
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                 (~LONG_MASK & ((1 << (COAP_OPT_FILTER_LONG + COAP_OPT_FILTER_SHORT)) - 1))
  |  |  ------------------
  |  |  |  |  208|    388|#define COAP_OPT_FILTER_LONG  2
  |  |  ------------------
  |  |                 (~LONG_MASK & ((1 << (COAP_OPT_FILTER_LONG + COAP_OPT_FILTER_SHORT)) - 1))
  |  |  ------------------
  |  |  |  |  200|    388|#define COAP_OPT_FILTER_SHORT 6
  |  |  ------------------
  ------------------
  453|       |
  454|  2.69k|    for (nr = 1 << COAP_OPT_FILTER_LONG; lindex < COAP_OPT_FILTER_SHORT;
  ------------------
  |  |  208|    388|#define COAP_OPT_FILTER_LONG  2
  ------------------
                  for (nr = 1 << COAP_OPT_FILTER_LONG; lindex < COAP_OPT_FILTER_SHORT;
  ------------------
  |  |  200|  2.69k|#define COAP_OPT_FILTER_SHORT 6
  ------------------
  |  Branch (454:42): [True: 2.32k, False: 368]
  ------------------
  455|  2.32k|         nr <<= 1, lindex++) {
  456|       |
  457|  2.32k|      if (((of->mask & nr) > 0) && (of->short_opts[lindex] == (number & 0xff))) {
  ------------------
  |  Branch (457:11): [True: 315, False: 2.01k]
  |  Branch (457:36): [True: 20, False: 295]
  ------------------
  458|     20|        if (op == FILTER_CLEAR) {
  ------------------
  |  Branch (458:13): [True: 0, False: 20]
  ------------------
  459|      0|          of->mask &= ~nr;
  460|      0|        }
  461|       |
  462|     20|        return 1;
  463|     20|      }
  464|  2.32k|    }
  465|    388|  }
  466|       |
  467|       |  /* number was not found, so there is nothing to do if op is CLEAR or GET */
  468|    368|  if ((op == FILTER_CLEAR) || (op == FILTER_GET)) {
  ------------------
  |  Branch (468:7): [True: 0, False: 368]
  |  Branch (468:31): [True: 295, False: 73]
  ------------------
  469|    295|    return 0;
  470|    295|  }
  471|       |
  472|       |  /* handle FILTER_SET: */
  473|       |
  474|     73|  lindex = coap_fls(~of->mask & mask);
  475|     73|  if (!lindex) {
  ------------------
  |  Branch (475:7): [True: 0, False: 73]
  ------------------
  476|      0|    return 0;
  477|      0|  }
  478|       |
  479|     73|  if (is_long_option(number)) {
  ------------------
  |  Branch (479:7): [True: 0, False: 73]
  ------------------
  480|      0|    of->long_opts[lindex - 1] = number;
  481|     73|  } else {
  482|     73|    of->short_opts[lindex - COAP_OPT_FILTER_LONG - 1] = (uint8_t)number;
  ------------------
  |  |  208|     73|#define COAP_OPT_FILTER_LONG  2
  ------------------
  483|     73|  }
  484|       |
  485|     73|  of->mask |= 1 << (lindex - 1);
  486|       |
  487|     73|  return 1;
  488|     73|}
coap_option.c:is_long_option:
  404|    461|is_long_option(coap_option_num_t number) {
  405|    461|  return number > 255;
  406|    461|}
coap_option.c:order_opts:
  543|     63|order_opts(void *a, void *b) {
  544|     63|  coap_optlist_t *o1 = (coap_optlist_t *)a;
  545|     63|  coap_optlist_t *o2 = (coap_optlist_t *)b;
  546|       |
  547|     63|  if (!a || !b)
  ------------------
  |  Branch (547:7): [True: 0, False: 63]
  |  Branch (547:13): [True: 0, False: 63]
  ------------------
  548|      0|    return a < b ? -1 : 1;
  ------------------
  |  Branch (548:12): [True: 0, False: 0]
  ------------------
  549|       |
  550|     63|  return (int)(o1->number - o2->number);
  551|     63|}
coap_option.c:coap_internal_delete:
  597|     26|coap_internal_delete(coap_optlist_t *node) {
  598|     26|  if (node) {
  ------------------
  |  Branch (598:7): [True: 26, False: 0]
  ------------------
  599|     26|    coap_free_type(COAP_OPTLIST, node);
  600|     26|  }
  601|     26|  return 1;
  602|     26|}

coap_delete_all_oscore:
 2646|     26|coap_delete_all_oscore(coap_context_t *c_context) {
 2647|     26|  oscore_free_contexts(c_context);
 2648|     26|}
coap_delete_oscore_associations:
 2651|     38|coap_delete_oscore_associations(coap_session_t *session) {
 2652|     38|  oscore_delete_server_associations(session);
 2653|     38|}

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

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

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

coap_resource_proxy_uri_init2:
  381|     26|                              const char *host_name_list[], int flags) {
  382|     26|  coap_resource_t *r;
  383|       |
  384|     26|  r = (coap_resource_t *)coap_malloc_type(COAP_RESOURCE, sizeof(coap_resource_t));
  385|     26|  if (r) {
  ------------------
  |  Branch (385:7): [True: 26, False: 0]
  ------------------
  386|     26|    size_t i;
  387|     26|    memset(r, 0, sizeof(coap_resource_t));
  388|       |#if COAP_THREAD_SAFE
  389|       |    coap_lock_init(&r->lock);
  390|       |#endif /* COAP_THREAD_SAFE */
  391|     26|    r->is_proxy_uri = 1;
  392|       |    /* Something unlikely to be used, but it shows up in the logs */
  393|     26|    r->uri_path = coap_new_str_const(coap_proxy_resource_uri, sizeof(coap_proxy_resource_uri)-1);
  394|       |    /* Preset all the handlers */
  395|    208|    for (i = 0; i < (sizeof(r->handler) / sizeof(r->handler[0])); i++) {
  ------------------
  |  Branch (395:17): [True: 182, False: 26]
  ------------------
  396|    182|      r->handler[i] = handler;
  397|    182|    }
  398|     26|    if (host_name_count) {
  ------------------
  |  Branch (398:9): [True: 0, False: 26]
  ------------------
  399|      0|      r->proxy_name_list = coap_malloc_type(COAP_STRING, host_name_count *
  400|      0|                                            sizeof(coap_str_const_t *));
  401|      0|      if (r->proxy_name_list) {
  ------------------
  |  Branch (401:11): [True: 0, False: 0]
  ------------------
  402|      0|        for (i = 0; i < host_name_count; i++) {
  ------------------
  |  Branch (402:21): [True: 0, False: 0]
  ------------------
  403|      0|          r->proxy_name_list[i] =
  404|      0|              coap_new_str_const((const uint8_t *)host_name_list[i],
  405|      0|                                 strlen(host_name_list[i]));
  406|      0|          if (!r->proxy_name_list[i]) {
  ------------------
  |  Branch (406:15): [True: 0, False: 0]
  ------------------
  407|      0|            coap_log_err("coap_resource_proxy_uri_init: unable to add host name\n");
  ------------------
  |  |  102|      0|#define coap_log_err(...) coap_log(COAP_LOG_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  408|      0|            if (i == 0) {
  ------------------
  |  Branch (408:17): [True: 0, False: 0]
  ------------------
  409|      0|              coap_free_type(COAP_STRING, r->proxy_name_list);
  410|      0|              r->proxy_name_list = NULL;
  411|      0|            }
  412|      0|            break;
  413|      0|          }
  414|      0|        }
  415|      0|        r->proxy_name_count = i;
  416|      0|      }
  417|      0|    }
  418|     26|    r->flags = flags & ~COAP_RESOURCE_FLAGS_RELEASE_URI;
  ------------------
  |  |   55|     26|#define COAP_RESOURCE_FLAGS_RELEASE_URI 0x1
  ------------------
  419|     26|  } else {
  420|      0|    coap_log_debug("coap_resource_proxy_uri_init2: no memory left\n");
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  421|      0|  }
  422|       |
  423|     26|  return r;
  424|     26|}
coap_add_resource:
  590|     26|coap_add_resource(coap_context_t *context, coap_resource_t *resource) {
  591|     26|  coap_lock_lock(return);
  592|     26|  coap_add_resource_lkd(context, resource);
  593|     26|  coap_lock_unlock();
  594|     26|}
coap_add_resource_lkd:
  597|     26|coap_add_resource_lkd(coap_context_t *context, coap_resource_t *resource) {
  598|     26|  coap_lock_check_locked();
  ------------------
  |  |  638|     26|#define coap_lock_check_locked() {}
  ------------------
  599|     26|  if (resource->is_unknown) {
  ------------------
  |  Branch (599:7): [True: 0, False: 26]
  ------------------
  600|      0|    if (context->unknown_resource)
  ------------------
  |  Branch (600:9): [True: 0, False: 0]
  ------------------
  601|      0|      coap_free_resource(context->unknown_resource, COAP_DELETING_RESOURCE);
  602|      0|    context->unknown_resource = resource;
  603|     26|  } else if (resource->is_proxy_uri) {
  ------------------
  |  Branch (603:14): [True: 26, False: 0]
  ------------------
  604|     26|    if (context->proxy_uri_resource)
  ------------------
  |  Branch (604:9): [True: 0, False: 26]
  ------------------
  605|      0|      coap_free_resource(context->proxy_uri_resource, COAP_DELETING_RESOURCE);
  606|     26|    context->proxy_uri_resource = resource;
  607|     26|  } else {
  608|      0|    coap_resource_t *r = coap_get_resource_from_uri_path_lkd(context,
  609|      0|                                                             resource->uri_path);
  610|       |
  611|      0|    if (r) {
  ------------------
  |  Branch (611:9): [True: 0, False: 0]
  ------------------
  612|      0|      coap_log_warn("coap_add_resource: Duplicate uri_path '%*.*s', old resource deleted\n",
  ------------------
  |  |  108|      0|#define coap_log_warn(...) coap_log(COAP_LOG_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  613|      0|                    (int)resource->uri_path->length, (int)resource->uri_path->length,
  614|      0|                    resource->uri_path->s);
  615|      0|      coap_delete_resource_lkd(r);
  616|      0|    }
  617|      0|    RESOURCES_ADD(context->resources, resource);
  ------------------
  |  |  187|      0|  HASH_ADD(hh, (r), uri_path->s[0], (obj)->uri_path->length, (obj))
  |  |  ------------------
  |  |  |  |  442|      0|  HASH_ADD_KEYPTR(hh, head, &((add)->fieldname), keylen_in, add)
  |  |  |  |  ------------------
  |  |  |  |  |  |  431|      0|#define HASH_ADD_KEYPTR(hh,head,keyptr,keylen_in,add)                            \
  |  |  |  |  |  |  432|      0|do {                                                                             \
  |  |  |  |  |  |  433|      0|  uint32_t _ha_hashv;                                                            \
  |  |  |  |  |  |  434|      0|  HASH_VALUE(keyptr, keylen_in, _ha_hashv);                                      \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  162|      0|#define HASH_VALUE(keyptr,keylen,hashv)                                          \
  |  |  |  |  |  |  |  |  163|      0|do {                                                                             \
  |  |  |  |  |  |  |  |  164|      0|  HASH_FUNCTION(keyptr, keylen, hashv);                                          \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  102|      0|#define HASH_FUNCTION(keyptr,keylen,hashv) HASH_JEN(keyptr, keylen, hashv)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  658|      0|#define HASH_JEN(key,keylen,hashv)                                               \
  |  |  |  |  |  |  |  |  |  |  |  |  659|      0|do {                                                                             \
  |  |  |  |  |  |  |  |  |  |  |  |  660|      0|  uint32_t _hj_i,_hj_j,_hj_k;                                                    \
  |  |  |  |  |  |  |  |  |  |  |  |  661|      0|  unsigned const char *_hj_key=(unsigned const char*)(key);                      \
  |  |  |  |  |  |  |  |  |  |  |  |  662|      0|  hashv = 0xfeedbeefu;                                                           \
  |  |  |  |  |  |  |  |  |  |  |  |  663|      0|  _hj_i = _hj_j = 0x9e3779b9u;                                                   \
  |  |  |  |  |  |  |  |  |  |  |  |  664|      0|  _hj_k = (uint32_t)(keylen);                                                    \
  |  |  |  |  |  |  |  |  |  |  |  |  665|      0|  while (_hj_k >= 12U) {                                                         \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (665:10): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  666|      0|    _hj_i = (int64_t)_hj_i + (_hj_key[0] + ( (uint32_t)_hj_key[1] << 8 )         \
  |  |  |  |  |  |  |  |  |  |  |  |  667|      0|        + ( (uint32_t)_hj_key[2] << 16 )                                         \
  |  |  |  |  |  |  |  |  |  |  |  |  668|      0|        + ( (uint32_t)_hj_key[3] << 24 ) );                                      \
  |  |  |  |  |  |  |  |  |  |  |  |  669|      0|    _hj_j = (int64_t)_hj_j + (_hj_key[4] + ( (uint32_t)_hj_key[5] << 8 )         \
  |  |  |  |  |  |  |  |  |  |  |  |  670|      0|        + ( (uint32_t)_hj_key[6] << 16 )                                         \
  |  |  |  |  |  |  |  |  |  |  |  |  671|      0|        + ( (uint32_t)_hj_key[7] << 24 ) );                                      \
  |  |  |  |  |  |  |  |  |  |  |  |  672|      0|    hashv = (int64_t)hashv + (_hj_key[8] + ( (uint32_t)_hj_key[9] << 8 )         \
  |  |  |  |  |  |  |  |  |  |  |  |  673|      0|        + ( (uint32_t)_hj_key[10] << 16 )                                        \
  |  |  |  |  |  |  |  |  |  |  |  |  674|      0|        + ( (uint32_t)_hj_key[11] << 24 ) );                                     \
  |  |  |  |  |  |  |  |  |  |  |  |  675|      0|                                                                                 \
  |  |  |  |  |  |  |  |  |  |  |  |  676|      0|     HASH_JEN_MIX(_hj_i, _hj_j, hashv);                                          \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  645|      0|#define HASH_JEN_MIX(a,b,c)                                                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  646|      0|do {                                                                             \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  647|      0|  a = (int64_t)a - b; a = (int64_t)a - c; a ^= ( c >> 13 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  648|      0|  b = (int64_t)b - c; b = (int64_t)b - a; b ^= ( a << 8 );                       \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  649|      0|  c = (int64_t)c - a; c = (int64_t)c - b; c ^= ( b >> 13 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  650|      0|  a = (int64_t)a - b; a = (int64_t)a - c; a ^= ( c >> 12 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  651|      0|  b = (int64_t)b - c; b = (int64_t)b - a; b ^= ( a << 16 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  652|      0|  c = (int64_t)c - a; c = (int64_t)c - b; c ^= ( b >> 5 );                       \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  653|      0|  a = (int64_t)a - b; a = (int64_t)a - c; a ^= ( c >> 3 );                       \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  654|      0|  b = (int64_t)b - c; b = (int64_t)b - a; b ^= ( a << 10 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  655|      0|  c = (int64_t)c - a; c = (int64_t)c - b; c ^= ( b >> 15 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  656|      0|} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (656:10): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  677|      0|                                                                                 \
  |  |  |  |  |  |  |  |  |  |  |  |  678|      0|     _hj_key += 12;                                                              \
  |  |  |  |  |  |  |  |  |  |  |  |  679|      0|     _hj_k -= 12U;                                                               \
  |  |  |  |  |  |  |  |  |  |  |  |  680|      0|  }                                                                              \
  |  |  |  |  |  |  |  |  |  |  |  |  681|      0|  hashv += (uint32_t)(keylen);                                                   \
  |  |  |  |  |  |  |  |  |  |  |  |  682|      0|  switch ( _hj_k ) {                                                             \
  |  |  |  |  |  |  |  |  |  |  |  |  683|      0|    case 11: hashv = (int64_t)hashv + ( (uint32_t)_hj_key[10] << 24 ); /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (683:5): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  684|      0|    case 10: hashv = (int64_t)hashv + ( (uint32_t)_hj_key[9] << 16 );  /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (684:5): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  685|      0|    case 9:  hashv = (int64_t)hashv + ( (uint32_t)_hj_key[8] << 8 );   /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (685:5): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  686|      0|    case 8:  _hj_j = (int64_t)_hj_j + ( (uint32_t)_hj_key[7] << 24 );  /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (686:5): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  687|      0|    case 7:  _hj_j = (int64_t)_hj_j + ( (uint32_t)_hj_key[6] << 16 );  /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (687:5): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  688|      0|    case 6:  _hj_j = (int64_t)_hj_j + ( (uint32_t)_hj_key[5] << 8 );   /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (688:5): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  689|      0|    case 5:  _hj_j = (int64_t)_hj_j + _hj_key[4];                      /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (689:5): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  690|      0|    case 4:  _hj_i = (int64_t)_hj_i + ( (uint32_t)_hj_key[3] << 24 );  /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (690:5): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  691|      0|    case 3:  _hj_i = (int64_t)_hj_i + ( (uint32_t)_hj_key[2] << 16 );  /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (691:5): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  692|      0|    case 2:  _hj_i = (int64_t)_hj_i + ( (uint32_t)_hj_key[1] << 8 );   /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (692:5): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  693|      0|    case 1:  _hj_i = (int64_t)_hj_i + _hj_key[0];                      /* FALLTHROUGH */ \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (693:5): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  694|      0|    default: ;                                                                   \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (694:5): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  695|      0|  }                                                                              \
  |  |  |  |  |  |  |  |  |  |  |  |  696|      0|  HASH_JEN_MIX(_hj_i, _hj_j, hashv);                                             \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  645|      0|#define HASH_JEN_MIX(a,b,c)                                                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  646|      0|do {                                                                             \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  647|      0|  a = (int64_t)a - b; a = (int64_t)a - c; a ^= ( c >> 13 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  648|      0|  b = (int64_t)b - c; b = (int64_t)b - a; b ^= ( a << 8 );                       \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  649|      0|  c = (int64_t)c - a; c = (int64_t)c - b; c ^= ( b >> 13 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  650|      0|  a = (int64_t)a - b; a = (int64_t)a - c; a ^= ( c >> 12 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  651|      0|  b = (int64_t)b - c; b = (int64_t)b - a; b ^= ( a << 16 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  652|      0|  c = (int64_t)c - a; c = (int64_t)c - b; c ^= ( b >> 5 );                       \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  653|      0|  a = (int64_t)a - b; a = (int64_t)a - c; a ^= ( c >> 3 );                       \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  654|      0|  b = (int64_t)b - c; b = (int64_t)b - a; b ^= ( a << 10 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  655|      0|  c = (int64_t)c - a; c = (int64_t)c - b; c ^= ( b >> 15 );                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  656|      0|} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (656:10): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  697|      0|} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (697:10): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  165|      0|} while (0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (165:10): [Folded, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  435|      0|  HASH_ADD_KEYPTR_BYHASHVALUE(hh, head, keyptr, keylen_in, _ha_hashv, add);      \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  410|      0|#define HASH_ADD_KEYPTR_BYHASHVALUE(hh,head,keyptr,keylen_in,hashval,add)        \
  |  |  |  |  |  |  |  |  411|      0|do {                                                                             \
  |  |  |  |  |  |  |  |  412|      0|  IF_HASH_NONFATAL_OOM( int _ha_oomed = 0; )                                     \
  |  |  |  |  |  |  |  |  413|      0|  (add)->hh.hashv = (hashval);                                                   \
  |  |  |  |  |  |  |  |  414|      0|  (add)->hh.key = (const void*) (keyptr);                                        \
  |  |  |  |  |  |  |  |  415|      0|  (add)->hh.keylen = (uint32_t) (keylen_in);                                     \
  |  |  |  |  |  |  |  |  416|      0|  if (!(head)) {                                                                 \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (416:7): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  417|      0|    (add)->hh.next = NULL;                                                       \
  |  |  |  |  |  |  |  |  418|      0|    (add)->hh.prev = NULL;                                                       \
  |  |  |  |  |  |  |  |  419|      0|    HASH_MAKE_TABLE(hh, add, _ha_oomed);                                         \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  226|      0|#define HASH_MAKE_TABLE(hh,head,oomed)                                           \
  |  |  |  |  |  |  |  |  |  |  227|      0|do {                                                                             \
  |  |  |  |  |  |  |  |  |  |  228|      0|  (head)->hh.tbl = (UT_hash_table*)uthash_malloc(sizeof(UT_hash_table));         \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   89|      0|#define uthash_malloc(sz) malloc(sz)      /* malloc fcn                      */
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  229|      0|  if (!(head)->hh.tbl) {                                                         \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (229:7): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  230|      0|    HASH_RECORD_OOM(oomed);                                                      \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  137|      0|#define HASH_RECORD_OOM(oomed) uthash_fatal("out of memory")
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  134|      0|#define uthash_fatal(msg) exit(-1)        /* fatal OOM error */
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  231|      0|  } else {                                                                       \
  |  |  |  |  |  |  |  |  |  |  232|      0|    uthash_bzero((head)->hh.tbl, sizeof(UT_hash_table));                         \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   95|      0|#define uthash_bzero(a,n) memset(a,'\0',n)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  233|      0|    (head)->hh.tbl->tail = &((head)->hh);                                        \
  |  |  |  |  |  |  |  |  |  |  234|      0|    (head)->hh.tbl->num_buckets = HASH_INITIAL_NUM_BUCKETS;                      \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  143|      0|#define HASH_INITIAL_NUM_BUCKETS 32U     /* initial number of buckets        */
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  235|      0|    (head)->hh.tbl->log2_num_buckets = HASH_INITIAL_NUM_BUCKETS_LOG2;            \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  144|      0|#define HASH_INITIAL_NUM_BUCKETS_LOG2 5U /* lg2 of initial number of buckets */
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  236|      0|    (head)->hh.tbl->hho = (char*)(&(head)->hh) - (char*)(head);                  \
  |  |  |  |  |  |  |  |  |  |  237|      0|    (head)->hh.tbl->buckets = (UT_hash_bucket*)uthash_malloc(                    \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   89|      0|#define uthash_malloc(sz) malloc(sz)      /* malloc fcn                      */
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  238|      0|        HASH_INITIAL_NUM_BUCKETS * sizeof(struct UT_hash_bucket));               \
  |  |  |  |  |  |  |  |  |  |  239|      0|    (head)->hh.tbl->signature = HASH_SIGNATURE;                                  \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  | 1101|      0|#define HASH_SIGNATURE 0xa0111fe1u
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  240|      0|    if (!(head)->hh.tbl->buckets) {                                              \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (240:9): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  241|      0|      HASH_RECORD_OOM(oomed);                                                    \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  137|      0|#define HASH_RECORD_OOM(oomed) uthash_fatal("out of memory")
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  134|      0|#define uthash_fatal(msg) exit(-1)        /* fatal OOM error */
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  242|      0|      uthash_free((head)->hh.tbl, sizeof(UT_hash_table));                        \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   92|      0|#define uthash_free(ptr,sz) free(ptr)     /* free fcn                        */
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  243|      0|    } else {                                                                     \
  |  |  |  |  |  |  |  |  |  |  244|      0|      uthash_bzero((head)->hh.tbl->buckets,                                      \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   95|      0|#define uthash_bzero(a,n) memset(a,'\0',n)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  245|      0|          HASH_INITIAL_NUM_BUCKETS * sizeof(struct UT_hash_bucket));             \
  |  |  |  |  |  |  |  |  |  |  246|      0|      HASH_BLOOM_MAKE((head)->hh.tbl, oomed);                                    \
  |  |  |  |  |  |  |  |  |  |  247|      0|      IF_HASH_NONFATAL_OOM(                                                      \
  |  |  |  |  |  |  |  |  |  |  248|      0|        if (oomed) {                                                             \
  |  |  |  |  |  |  |  |  |  |  249|      0|          uthash_free((head)->hh.tbl->buckets,                                   \
  |  |  |  |  |  |  |  |  |  |  250|      0|              HASH_INITIAL_NUM_BUCKETS*sizeof(struct UT_hash_bucket));           \
  |  |  |  |  |  |  |  |  |  |  251|      0|          uthash_free((head)->hh.tbl, sizeof(UT_hash_table));                    \
  |  |  |  |  |  |  |  |  |  |  252|      0|        }                                                                        \
  |  |  |  |  |  |  |  |  |  |  253|      0|      )                                                                          \
  |  |  |  |  |  |  |  |  |  |  254|      0|    }                                                                            \
  |  |  |  |  |  |  |  |  |  |  255|      0|  }                                                                              \
  |  |  |  |  |  |  |  |  |  |  256|      0|} while (0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (256:10): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  420|      0|    IF_HASH_NONFATAL_OOM( if (!_ha_oomed) { )                                    \
  |  |  |  |  |  |  |  |  421|      0|      (head) = (add);                                                            \
  |  |  |  |  |  |  |  |  422|      0|    IF_HASH_NONFATAL_OOM( } )                                                    \
  |  |  |  |  |  |  |  |  423|      0|  } else {                                                                       \
  |  |  |  |  |  |  |  |  424|      0|    (add)->hh.tbl = (head)->hh.tbl;                                              \
  |  |  |  |  |  |  |  |  425|      0|    HASH_APPEND_LIST(hh, head, add);                                             \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  292|      0|#define HASH_APPEND_LIST(hh, head, add)                                          \
  |  |  |  |  |  |  |  |  |  |  293|      0|do {                                                                             \
  |  |  |  |  |  |  |  |  |  |  294|      0|  (add)->hh.next = NULL;                                                         \
  |  |  |  |  |  |  |  |  |  |  295|      0|  (add)->hh.prev = ELMT_FROM_HH((head)->hh.tbl, (head)->hh.tbl->tail);           \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  148|      0|#define ELMT_FROM_HH(tbl,hhp) ((void*)(((char*)(hhp)) - ((tbl)->hho)))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  296|      0|  (head)->hh.tbl->tail->next = (add);                                            \
  |  |  |  |  |  |  |  |  |  |  297|      0|  (head)->hh.tbl->tail = &((add)->hh);                                           \
  |  |  |  |  |  |  |  |  |  |  298|      0|} while (0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (298:10): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  426|      0|  }                                                                              \
  |  |  |  |  |  |  |  |  427|      0|  HASH_ADD_TO_TABLE(hh, head, keyptr, keylen_in, hashval, add, _ha_oomed);       \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  351|      0|#define HASH_ADD_TO_TABLE(hh,head,keyptr,keylen_in,hashval,add,oomed)            \
  |  |  |  |  |  |  |  |  |  |  352|      0|do {                                                                             \
  |  |  |  |  |  |  |  |  |  |  353|      0|  uint32_t _ha_bkt;                                                              \
  |  |  |  |  |  |  |  |  |  |  354|      0|  (head)->hh.tbl->num_items++;                                                   \
  |  |  |  |  |  |  |  |  |  |  355|      0|  HASH_TO_BKT(hashval, (head)->hh.tbl->num_buckets, _ha_bkt);                    \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  444|      0|#define HASH_TO_BKT(hashv,num_bkts,bkt)                                          \
  |  |  |  |  |  |  |  |  |  |  |  |  445|      0|do {                                                                             \
  |  |  |  |  |  |  |  |  |  |  |  |  446|      0|  bkt = ((hashv) & ((num_bkts) - 1U));                                           \
  |  |  |  |  |  |  |  |  |  |  |  |  447|      0|} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (447:10): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  356|      0|  HASH_ADD_TO_BKT((head)->hh.tbl->buckets[_ha_bkt], hh, &(add)->hh, oomed);      \
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  778|      0|#define HASH_ADD_TO_BKT(head,hh,addhh,oomed)                                     \
  |  |  |  |  |  |  |  |  |  |  |  |  779|      0|do {                                                                             \
  |  |  |  |  |  |  |  |  |  |  |  |  780|      0|  UT_hash_bucket *_ha_head = &(head);                                            \
  |  |  |  |  |  |  |  |  |  |  |  |  781|      0|  _ha_head->count++;                                                             \
  |  |  |  |  |  |  |  |  |  |  |  |  782|      0|  (addhh)->hh_next = _ha_head->hh_head;                                          \
  |  |  |  |  |  |  |  |  |  |  |  |  783|      0|  (addhh)->hh_prev = NULL;                                                       \
  |  |  |  |  |  |  |  |  |  |  |  |  784|      0|  if (_ha_head->hh_head != NULL) {                                               \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (784:7): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  785|      0|    _ha_head->hh_head->hh_prev = (addhh);                                        \
  |  |  |  |  |  |  |  |  |  |  |  |  786|      0|  }                                                                              \
  |  |  |  |  |  |  |  |  |  |  |  |  787|      0|  _ha_head->hh_head = (addhh);                                                   \
  |  |  |  |  |  |  |  |  |  |  |  |  788|      0|  if ((_ha_head->count >= ((_ha_head->expand_mult + 1U) * HASH_BKT_CAPACITY_THRESH)) \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  145|      0|#define HASH_BKT_CAPACITY_THRESH 10U     /* expand when bucket count reaches */
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (788:7): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  789|      0|      && !(addhh)->tbl->noexpand) {                                              \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (789:10): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  790|      0|    HASH_EXPAND_BUCKETS(addhh,(addhh)->tbl, oomed);                              \
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  844|      0|#define HASH_EXPAND_BUCKETS(hh,tbl,oomed)                                        \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  845|      0|do {                                                                             \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  846|      0|  uint32_t _he_bkt;                                                              \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  847|      0|  uint32_t _he_bkt_i;                                                            \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  848|      0|  struct UT_hash_handle *_he_thh, *_he_hh_nxt;                                   \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  849|      0|  UT_hash_bucket *_he_new_buckets, *_he_newbkt;                                  \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  850|      0|  _he_new_buckets = (UT_hash_bucket*)uthash_malloc(                              \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   89|      0|#define uthash_malloc(sz) malloc(sz)      /* malloc fcn                      */
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  851|      0|           sizeof(struct UT_hash_bucket) * (tbl)->num_buckets * 2U);             \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  852|      0|  if (!_he_new_buckets) {                                                        \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (852:7): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  853|      0|    HASH_RECORD_OOM(oomed);                                                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  137|      0|#define HASH_RECORD_OOM(oomed) uthash_fatal("out of memory")
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  134|      0|#define uthash_fatal(msg) exit(-1)        /* fatal OOM error */
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  854|      0|  } else {                                                                       \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  855|      0|    uthash_bzero(_he_new_buckets,                                                \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   95|      0|#define uthash_bzero(a,n) memset(a,'\0',n)
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  856|      0|        sizeof(struct UT_hash_bucket) * (tbl)->num_buckets * 2U);                \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  857|      0|    (tbl)->ideal_chain_maxlen =                                                  \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  858|      0|       ((tbl)->num_items >> ((tbl)->log2_num_buckets+1U)) +                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  859|      0|       ((((tbl)->num_items & (((tbl)->num_buckets*2U)-1U)) != 0U) ? 1U : 0U);    \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (859:9): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  860|      0|    (tbl)->nonideal_items = 0;                                                   \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  861|      0|    for (_he_bkt_i = 0; _he_bkt_i < (tbl)->num_buckets; _he_bkt_i++) {           \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (861:25): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  862|      0|      _he_thh = (tbl)->buckets[ _he_bkt_i ].hh_head;                             \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  863|      0|      while (_he_thh != NULL) {                                                  \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (863:14): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  864|      0|        _he_hh_nxt = _he_thh->hh_next;                                           \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  865|      0|        HASH_TO_BKT(_he_thh->hashv, (tbl)->num_buckets * 2U, _he_bkt);           \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  444|      0|#define HASH_TO_BKT(hashv,num_bkts,bkt)                                          \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  445|      0|do {                                                                             \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  446|      0|  bkt = ((hashv) & ((num_bkts) - 1U));                                           \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  447|      0|} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (447:10): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  866|      0|        _he_newbkt = &(_he_new_buckets[_he_bkt]);                                \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  867|      0|        if (++(_he_newbkt->count) > (tbl)->ideal_chain_maxlen) {                 \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (867:13): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  868|      0|          (tbl)->nonideal_items++;                                               \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  869|      0|          if (_he_newbkt->count > _he_newbkt->expand_mult * (tbl)->ideal_chain_maxlen) { \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (869:15): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  870|      0|            _he_newbkt->expand_mult++;                                           \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  871|      0|          }                                                                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  872|      0|        }                                                                        \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  873|      0|        _he_thh->hh_prev = NULL;                                                 \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  874|      0|        _he_thh->hh_next = _he_newbkt->hh_head;                                  \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  875|      0|        if (_he_newbkt->hh_head != NULL) {                                       \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (875:13): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  876|      0|          _he_newbkt->hh_head->hh_prev = _he_thh;                                \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  877|      0|        }                                                                        \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  878|      0|        _he_newbkt->hh_head = _he_thh;                                           \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  879|      0|        _he_thh = _he_hh_nxt;                                                    \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  880|      0|      }                                                                          \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  881|      0|    }                                                                            \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  882|      0|    uthash_free((tbl)->buckets, (tbl)->num_buckets * sizeof(struct UT_hash_bucket)); \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   92|      0|#define uthash_free(ptr,sz) free(ptr)     /* free fcn                        */
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  883|      0|    (tbl)->num_buckets *= 2U;                                                    \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  884|      0|    (tbl)->log2_num_buckets++;                                                   \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  885|      0|    (tbl)->buckets = _he_new_buckets;                                            \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  886|      0|    (tbl)->ineff_expands = ((tbl)->nonideal_items > ((tbl)->num_items >> 1)) ?   \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (886:28): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  887|      0|        ((tbl)->ineff_expands+1U) : 0U;                                          \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  888|      0|    if ((tbl)->ineff_expands > 1U) {                                             \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (888:9): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  889|      0|      (tbl)->noexpand = 1;                                                       \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  890|      0|      uthash_noexpand_fyi(tbl);                                                  \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  891|      0|    }                                                                            \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  892|      0|    uthash_expand_fyi(tbl);                                                      \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  893|      0|  }                                                                              \
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  894|      0|} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (894:10): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  791|      0|    IF_HASH_NONFATAL_OOM(                                                        \
  |  |  |  |  |  |  |  |  |  |  |  |  792|      0|      if (oomed) {                                                               \
  |  |  |  |  |  |  |  |  |  |  |  |  793|      0|        HASH_DEL_IN_BKT(head,addhh);                                             \
  |  |  |  |  |  |  |  |  |  |  |  |  794|      0|      }                                                                          \
  |  |  |  |  |  |  |  |  |  |  |  |  795|      0|    )                                                                            \
  |  |  |  |  |  |  |  |  |  |  |  |  796|      0|  }                                                                              \
  |  |  |  |  |  |  |  |  |  |  |  |  797|      0|} while (0)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  Branch (797:10): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  357|      0|  HASH_BLOOM_ADD((head)->hh.tbl, hashval);                                       \
  |  |  |  |  |  |  |  |  |  |  358|      0|  HASH_EMIT_KEY(hh, head, keyptr, keylen_in);                                    \
  |  |  |  |  |  |  |  |  |  |  359|      0|} while (0)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  Branch (359:10): [Folded, False: 0]
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  428|      0|  HASH_FSCK(hh, head, "HASH_ADD_KEYPTR_BYHASHVALUE");                            \
  |  |  |  |  |  |  |  |  429|      0|} while (0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (429:10): [Folded, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  436|      0|} while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (436:10): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  618|      0|#if COAP_WITH_OBSERVE_PERSIST
  619|      0|    if (context->unknown_pdu && context->dyn_resource_save_file &&
  ------------------
  |  Branch (619:9): [True: 0, False: 0]
  |  Branch (619:33): [True: 0, False: 0]
  ------------------
  620|      0|        context->dyn_resource_added_cb && resource->observable) {
  ------------------
  |  Branch (620:9): [True: 0, False: 0]
  |  Branch (620:43): [True: 0, False: 0]
  ------------------
  621|      0|      coap_bin_const_t raw_packet;
  622|       |
  623|      0|      raw_packet.s = context->unknown_pdu->token -
  624|      0|                     context->unknown_pdu->hdr_size;
  625|      0|      raw_packet.length = context->unknown_pdu->used_size +
  626|      0|                          context->unknown_pdu->hdr_size;
  627|      0|      coap_lock_callback(context->dyn_resource_added_cb(context->unknown_session,
  ------------------
  |  |  651|      0|#define coap_lock_callback(func) func
  ------------------
  628|      0|                                                        resource->uri_path,
  629|      0|                                                        &raw_packet,
  630|      0|                                                        context->observe_user_data));
  631|      0|    }
  632|      0|#endif /* COAP_WITH_OBSERVE_PERSIST */
  633|      0|  }
  634|     26|  assert(resource->context == NULL);
  ------------------
  |  Branch (634:3): [True: 26, False: 0]
  ------------------
  635|     26|  resource->context = context;
  636|     26|}
coap_delete_resource_lkd:
  656|     26|coap_delete_resource_lkd(coap_resource_t *resource) {
  657|     26|  coap_context_t *context;
  658|     26|  coap_deleting_resource_t deleting;
  659|       |
  660|     26|  if (!resource)
  ------------------
  |  Branch (660:7): [True: 0, False: 26]
  ------------------
  661|      0|    return 0;
  662|       |
  663|     26|  context = resource->context;
  664|     26|  coap_lock_check_locked();
  ------------------
  |  |  638|     26|#define coap_lock_check_locked() {}
  ------------------
  665|       |
  666|     26|  if (resource->ref) {
  ------------------
  |  Branch (666:7): [True: 0, False: 26]
  ------------------
  667|      0|    resource->ref--;
  668|      0|    return 1;
  669|      0|  }
  670|     26|  if (context && context->context_going_away) {
  ------------------
  |  Branch (670:7): [True: 26, False: 0]
  |  Branch (670:18): [True: 26, False: 0]
  ------------------
  671|     26|    deleting = COAP_DELETING_RESOURCE_ON_EXIT;
  672|     26|  } else {
  673|      0|    deleting = COAP_DELETING_RESOURCE;
  674|      0|  }
  675|     26|  if (resource->is_unknown) {
  ------------------
  |  Branch (675:7): [True: 0, False: 26]
  ------------------
  676|      0|    if (context && context->unknown_resource == resource) {
  ------------------
  |  Branch (676:9): [True: 0, False: 0]
  |  Branch (676:20): [True: 0, False: 0]
  ------------------
  677|      0|      context->unknown_resource = NULL;
  678|      0|    }
  679|     26|  } else if (resource->is_proxy_uri) {
  ------------------
  |  Branch (679:14): [True: 26, False: 0]
  ------------------
  680|     26|    if (context && context->proxy_uri_resource == resource) {
  ------------------
  |  Branch (680:9): [True: 26, False: 0]
  |  Branch (680:20): [True: 26, False: 0]
  ------------------
  681|     26|      context->proxy_uri_resource = NULL;
  682|     26|    }
  683|     26|  } else if (context) {
  ------------------
  |  Branch (683:14): [True: 0, False: 0]
  ------------------
  684|       |    /* remove resource from list */
  685|      0|    RESOURCES_DELETE(context->resources, resource);
  ------------------
  |  |  190|      0|  HASH_DELETE(hh, (r), (obj))
  |  |  ------------------
  |  |  |  |  462|      0|    HASH_DELETE_HH(hh, head, &(delptr)->hh)
  |  |  |  |  ------------------
  |  |  |  |  |  |  464|      0|#define HASH_DELETE_HH(hh,head,delptrhh)                                         \
  |  |  |  |  |  |  465|      0|do {                                                                             \
  |  |  |  |  |  |  466|      0|  struct UT_hash_handle *_hd_hh_del = (delptrhh);                                \
  |  |  |  |  |  |  467|      0|  if ((_hd_hh_del->prev == NULL) && (_hd_hh_del->next == NULL)) {                \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (467:7): [True: 0, False: 0]
  |  |  |  |  |  |  |  Branch (467:37): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  468|      0|    HASH_BLOOM_FREE((head)->hh.tbl);                                             \
  |  |  |  |  |  |  469|      0|    uthash_free((head)->hh.tbl->buckets,                                         \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   92|      0|#define uthash_free(ptr,sz) free(ptr)     /* free fcn                        */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  470|      0|                (head)->hh.tbl->num_buckets * sizeof(struct UT_hash_bucket));    \
  |  |  |  |  |  |  471|      0|    uthash_free((head)->hh.tbl, sizeof(UT_hash_table));                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   92|      0|#define uthash_free(ptr,sz) free(ptr)     /* free fcn                        */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  472|      0|    (head) = NULL;                                                               \
  |  |  |  |  |  |  473|      0|  } else {                                                                       \
  |  |  |  |  |  |  474|      0|    uint32_t _hd_bkt;                                                            \
  |  |  |  |  |  |  475|      0|    if (_hd_hh_del == (head)->hh.tbl->tail) {                                    \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (475:9): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  476|      0|      (head)->hh.tbl->tail = HH_FROM_ELMT((head)->hh.tbl, _hd_hh_del->prev);     \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  150|      0|#define HH_FROM_ELMT(tbl,elp) ((UT_hash_handle*)(void*)(((char*)(elp)) + ((tbl)->hho)))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  477|      0|    }                                                                            \
  |  |  |  |  |  |  478|      0|    if (_hd_hh_del->prev != NULL) {                                              \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (478:9): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  479|      0|      HH_FROM_ELMT((head)->hh.tbl, _hd_hh_del->prev)->next = _hd_hh_del->next;   \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  150|      0|#define HH_FROM_ELMT(tbl,elp) ((UT_hash_handle*)(void*)(((char*)(elp)) + ((tbl)->hho)))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  480|      0|    } else {                                                                     \
  |  |  |  |  |  |  481|      0|      DECLTYPE_ASSIGN(head, _hd_hh_del->next);                                   \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   78|      0|#define DECLTYPE_ASSIGN(dst,src)                                                 \
  |  |  |  |  |  |  |  |   79|      0|do {                                                                             \
  |  |  |  |  |  |  |  |   80|      0|  (dst) = DECLTYPE(dst)(src);                                                    \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   66|      0|#define DECLTYPE(x) (__typeof(x))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   81|      0|} while (0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (81:10): [Folded, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  482|      0|    }                                                                            \
  |  |  |  |  |  |  483|      0|    if (_hd_hh_del->next != NULL) {                                              \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (483:9): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  484|      0|      HH_FROM_ELMT((head)->hh.tbl, _hd_hh_del->next)->prev = _hd_hh_del->prev;   \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  150|      0|#define HH_FROM_ELMT(tbl,elp) ((UT_hash_handle*)(void*)(((char*)(elp)) + ((tbl)->hho)))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  485|      0|    }                                                                            \
  |  |  |  |  |  |  486|      0|    HASH_TO_BKT(_hd_hh_del->hashv, (head)->hh.tbl->num_buckets, _hd_bkt);        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  444|      0|#define HASH_TO_BKT(hashv,num_bkts,bkt)                                          \
  |  |  |  |  |  |  |  |  445|      0|do {                                                                             \
  |  |  |  |  |  |  |  |  446|      0|  bkt = ((hashv) & ((num_bkts) - 1U));                                           \
  |  |  |  |  |  |  |  |  447|      0|} while (0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (447:10): [Folded, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  487|      0|    HASH_DEL_IN_BKT((head)->hh.tbl->buckets[_hd_bkt], _hd_hh_del);               \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  800|      0|#define HASH_DEL_IN_BKT(head,delhh)                                              \
  |  |  |  |  |  |  |  |  801|      0|do {                                                                             \
  |  |  |  |  |  |  |  |  802|      0|  UT_hash_bucket *_hd_head = &(head);                                            \
  |  |  |  |  |  |  |  |  803|      0|  _hd_head->count--;                                                             \
  |  |  |  |  |  |  |  |  804|      0|  if (_hd_head->hh_head == (delhh)) {                                            \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (804:7): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  805|      0|    _hd_head->hh_head = (delhh)->hh_next;                                        \
  |  |  |  |  |  |  |  |  806|      0|  }                                                                              \
  |  |  |  |  |  |  |  |  807|      0|  if ((delhh)->hh_prev) {                                                        \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (807:7): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  808|      0|    (delhh)->hh_prev->hh_next = (delhh)->hh_next;                                \
  |  |  |  |  |  |  |  |  809|      0|  }                                                                              \
  |  |  |  |  |  |  |  |  810|      0|  if ((delhh)->hh_next) {                                                        \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (810:7): [True: 0, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  811|      0|    (delhh)->hh_next->hh_prev = (delhh)->hh_prev;                                \
  |  |  |  |  |  |  |  |  812|      0|  }                                                                              \
  |  |  |  |  |  |  |  |  813|      0|} while (0)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  Branch (813:10): [Folded, False: 0]
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  488|      0|    (head)->hh.tbl->num_items--;                                                 \
  |  |  |  |  |  |  489|      0|  }                                                                              \
  |  |  |  |  |  |  490|      0|  HASH_FSCK(hh, head, "HASH_DELETE_HH");                                         \
  |  |  |  |  |  |  491|      0|} while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (491:10): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  686|      0|  }
  687|     26|  if (resource->is_dynamic) {
  ------------------
  |  Branch (687:7): [True: 0, False: 26]
  ------------------
  688|      0|    if (context) {
  ------------------
  |  Branch (688:9): [True: 0, False: 0]
  ------------------
  689|      0|      assert(context->dynamic_cur);
  ------------------
  |  Branch (689:7): [True: 0, False: 0]
  ------------------
  690|      0|      context->dynamic_cur--;
  691|      0|    }
  692|      0|  }
  693|       |
  694|       |  /* and free its allocated memory */
  695|     26|  coap_free_resource(resource, deleting);
  696|       |
  697|     26|  return 1;
  698|     26|}
coap_delete_all_resources:
  701|     26|coap_delete_all_resources(coap_context_t *context) {
  702|     26|  coap_resource_t *r;
  703|     26|  coap_resource_t *tmp;
  704|       |
  705|     26|  RESOURCE_ITER_SAFE(context->resources, r, tmp) {
  ------------------
  |  |  197|     26|  for ((el) = (e); (el) && ((rtmp) = (el)->hh.next, 1); (el) = (rtmp))
  |  |  ------------------
  |  |  |  Branch (197:20): [True: 0, False: 26]
  |  |  |  Branch (197:28): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  706|      0|    coap_delete_resource_lkd(r);
  707|      0|  }
  708|       |
  709|     26|  context->resources = NULL;
  710|       |
  711|     26|  if (context->unknown_resource) {
  ------------------
  |  Branch (711:7): [True: 0, False: 26]
  ------------------
  712|      0|    coap_delete_resource_lkd(context->unknown_resource);
  713|      0|    context->unknown_resource = NULL;
  714|      0|  }
  715|     26|  if (context->proxy_uri_resource) {
  ------------------
  |  Branch (715:7): [True: 26, False: 0]
  ------------------
  716|     26|    coap_delete_resource_lkd(context->proxy_uri_resource);
  717|       |    context->proxy_uri_resource = NULL;
  718|     26|  }
  719|     26|}
coap_resource_notify_observers_lkd:
 1487|     26|                                   coap_deleting_resource_t deleting) {
 1488|     26|  coap_lock_check_locked();
  ------------------
  |  |  638|     26|#define coap_lock_check_locked() {}
  ------------------
 1489|     26|  if (!r->observable)
  ------------------
  |  Branch (1489:7): [True: 26, False: 0]
  ------------------
 1490|     26|    return 0;
 1491|      0|  if (!r->subscribers)
  ------------------
  |  Branch (1491:7): [True: 0, False: 0]
  ------------------
 1492|      0|    return 0;
 1493|      0|  r->dirty = 1;
 1494|       |
 1495|       |  /* Increment value for next Observe use. Observe value must be < 2^24 */
 1496|      0|  r->observe = (r->observe + 1) & 0xFFFFFF;
 1497|       |
 1498|      0|  assert(r->context);
  ------------------
  |  Branch (1498:3): [True: 0, False: 0]
  ------------------
 1499|       |
 1500|      0|  if (r->context->track_observe_value_cb) {
  ------------------
  |  Branch (1500:7): [True: 0, False: 0]
  ------------------
 1501|       |    /* Track last used observe value */
 1502|      0|    if ((r->observe % r->context->observe_save_freq) == 0)
  ------------------
  |  Branch (1502:9): [True: 0, False: 0]
  ------------------
 1503|      0|      coap_lock_callback(r->context->track_observe_value_cb(r->context, r->uri_path,
  ------------------
  |  |  651|      0|#define coap_lock_callback(func) func
  ------------------
 1504|      0|                                                            r->observe,
 1505|      0|                                                            r->context->observe_user_data));
 1506|      0|  }
 1507|       |
 1508|      0|  coap_notify_observers(r->context, r, deleting);
 1509|      0|  return 1;
 1510|      0|}
coap_resource.c:coap_free_resource:
  543|     26|coap_free_resource(coap_resource_t *resource, coap_deleting_resource_t deleting) {
  544|     26|  coap_attr_t *attr, *tmp;
  545|     26|  coap_subscription_t *obs, *otmp;
  546|     26|  coap_context_t *context;
  547|       |
  548|     26|  assert(resource);
  ------------------
  |  Branch (548:3): [True: 26, False: 0]
  ------------------
  549|       |
  550|     26|  context = resource->context;
  551|     26|  if (context) {
  ------------------
  |  Branch (551:7): [True: 26, False: 0]
  ------------------
  552|     26|    if (!context->observe_no_clear) {
  ------------------
  |  Branch (552:9): [True: 26, False: 0]
  ------------------
  553|     26|      coap_resource_notify_observers_lkd(resource, deleting);
  554|     26|      coap_notify_observers(context, resource, deleting);
  555|     26|    }
  556|       |
  557|     26|    if (context->resource_deleted_cb)
  ------------------
  |  Branch (557:9): [True: 0, False: 26]
  ------------------
  558|      0|      coap_lock_callback(context->resource_deleted_cb(context,
  ------------------
  |  |  651|     26|#define coap_lock_callback(func) func
  ------------------
  559|     26|                                                      resource->uri_path,
  560|     26|                                                      context->observe_user_data));
  561|       |
  562|     26|    if (context->release_userdata_cb && resource->user_data) {
  ------------------
  |  Branch (562:9): [True: 0, False: 26]
  |  Branch (562:41): [True: 0, False: 0]
  ------------------
  563|      0|      coap_lock_callback(context->release_userdata_cb(resource->user_data));
  ------------------
  |  |  651|      0|#define coap_lock_callback(func) func
  ------------------
  564|      0|    }
  565|     26|  }
  566|       |
  567|       |  /* delete registered attributes */
  568|     26|  LL_FOREACH_SAFE(resource->link_attr, attr, tmp) coap_delete_attr(attr);
  ------------------
  |  |  425|     26|    LL_FOREACH_SAFE2(head,el,tmp,next)
  |  |  ------------------
  |  |  |  |  428|     26|  for ((el) = (head); (el) && ((tmp) = (el)->next, 1); (el) = (tmp))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (428:23): [True: 0, False: 26]
  |  |  |  |  |  Branch (428:31): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  569|       |
  570|       |  /* Either the application provided or libcoap copied - need to delete it */
  571|     26|  coap_delete_str_const(resource->uri_path);
  572|       |
  573|       |  /* free all elements from resource->subscribers */
  574|     26|  LL_FOREACH_SAFE(resource->subscribers, obs, otmp) {
  ------------------
  |  |  425|     26|    LL_FOREACH_SAFE2(head,el,tmp,next)
  |  |  ------------------
  |  |  |  |  428|     26|  for ((el) = (head); (el) && ((tmp) = (el)->next, 1); (el) = (tmp))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (428:23): [True: 0, False: 26]
  |  |  |  |  |  Branch (428:31): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  575|      0|    coap_delete_observer_internal(resource, obs->session, obs);
  576|      0|  }
  577|     26|  if (resource->proxy_name_count && resource->proxy_name_list) {
  ------------------
  |  Branch (577:7): [True: 0, False: 26]
  |  Branch (577:37): [True: 0, False: 0]
  ------------------
  578|      0|    size_t i;
  579|       |
  580|      0|    for (i = 0; i < resource->proxy_name_count; i++) {
  ------------------
  |  Branch (580:17): [True: 0, False: 0]
  ------------------
  581|      0|      coap_delete_str_const(resource->proxy_name_list[i]);
  582|      0|    }
  583|      0|    coap_free_type(COAP_STRING, resource->proxy_name_list);
  584|      0|  }
  585|       |
  586|     26|  coap_free_type(COAP_RESOURCE, resource);
  587|     26|}
coap_resource.c:coap_notify_observers:
 1184|     26|                      coap_deleting_resource_t deleting) {
 1185|     26|  coap_method_handler_t h;
 1186|     26|  coap_subscription_t *obs, *otmp;
 1187|     26|  coap_pdu_t *response;
 1188|     26|  uint8_t buf[4];
 1189|     26|  coap_string_t *query;
 1190|     26|  coap_block_b_t block;
 1191|     26|  coap_tick_t now;
 1192|       |
 1193|     26|  coap_lock_check_locked();
  ------------------
  |  |  638|     26|#define coap_lock_check_locked() {}
  ------------------
 1194|       |
 1195|     26|  if (r->observable && (r->dirty || r->partiallydirty)) {
  ------------------
  |  Branch (1195:7): [True: 0, False: 26]
  |  Branch (1195:25): [True: 0, False: 0]
  |  Branch (1195:37): [True: 0, False: 0]
  ------------------
 1196|      0|    if (r->list_being_traversed)
  ------------------
  |  Branch (1196:9): [True: 0, False: 0]
  ------------------
 1197|      0|      return;
 1198|      0|    r->list_being_traversed = 1;
 1199|       |
 1200|      0|    coap_resource_reference_lkd(r);
 1201|       |
 1202|      0|    r->partiallydirty = 0;
 1203|       |
 1204|      0|    LL_FOREACH_SAFE(r->subscribers, obs, otmp) {
  ------------------
  |  |  425|      0|    LL_FOREACH_SAFE2(head,el,tmp,next)
  |  |  ------------------
  |  |  |  |  428|      0|  for ((el) = (head); (el) && ((tmp) = (el)->next, 1); (el) = (tmp))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (428:23): [True: 0, False: 0]
  |  |  |  |  |  Branch (428:31): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1205|      0|      coap_session_t *obs_session;
 1206|      0|      coap_pdu_t *obs_pdu;
 1207|      0|      coap_mid_t mid = COAP_INVALID_MID;
  ------------------
  |  |  187|      0|#define COAP_INVALID_MID -1
  ------------------
 1208|       |
 1209|      0|      if ((r->dirty == 0 && obs->dirty == 0) || obs->session->is_rate_limiting) {
  ------------------
  |  Branch (1209:12): [True: 0, False: 0]
  |  Branch (1209:29): [True: 0, False: 0]
  |  Branch (1209:49): [True: 0, False: 0]
  ------------------
 1210|       |        /*
 1211|       |         * running this resource due to partiallydirty, but this observation's
 1212|       |         * notification was already enqueued
 1213|       |         */
 1214|      0|        context->observe_pending = 1;
 1215|      0|        continue;
 1216|      0|      }
 1217|       |
 1218|       |      /*
 1219|       |       * obs may get deleted in the callback, or by another running
 1220|       |       * thread when executing the callback or when sending a response.
 1221|       |       */
 1222|      0|      obs_session = obs->session;
 1223|      0|      obs_pdu = obs->pdu;
 1224|      0|      coap_session_reference_lkd(obs_session);
 1225|      0|      coap_pdu_reference_lkd(obs_pdu);
 1226|       |
 1227|      0|      if (obs->session->con_active >= COAP_NSTART(obs->session) &&
  ------------------
  |  |  800|      0|#define COAP_NSTART(s) ((s)->nstart)
  ------------------
  |  Branch (1227:11): [True: 0, False: 0]
  ------------------
 1228|      0|          ((r->flags & COAP_RESOURCE_FLAGS_NOTIFY_CON) ||
  ------------------
  |  |   69|      0|#define COAP_RESOURCE_FLAGS_NOTIFY_CON  0x2
  ------------------
  |  Branch (1228:12): [True: 0, False: 0]
  ------------------
 1229|      0|           (obs->non_cnt >= COAP_OBS_MAX_NON))) {
  ------------------
  |  |   39|      0|#define COAP_OBS_MAX_NON   5
  ------------------
  |  Branch (1229:12): [True: 0, False: 0]
  ------------------
 1230|       |        /* Waiting for the previous unsolicited response to finish */
 1231|      0|        goto next_one_fail;
 1232|      0|      }
 1233|      0|      coap_ticks(&now);
 1234|      0|      if (obs->session->lg_xmit && obs->session->lg_xmit->last_all_sent == 0 &&
  ------------------
  |  Branch (1234:11): [True: 0, False: 0]
  |  Branch (1234:36): [True: 0, False: 0]
  ------------------
 1235|      0|          obs->session->lg_xmit->last_obs &&
  ------------------
  |  Branch (1235:11): [True: 0, False: 0]
  ------------------
 1236|      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 (1236:11): [True: 0, False: 0]
  ------------------
 1237|       |        /* Waiting for the previous blocked unsolicited response to finish */
 1238|      0|        goto next_one_fail;
 1239|      0|      }
 1240|       |
 1241|       |      /* Other packets on this session may have changed the local address,
 1242|       |       * including multicast requests from the same peer and source port.
 1243|       |       * Restore it before the handler can register an async response. */
 1244|      0|      coap_address_copy(&obs_session->addr_info.local, &obs->local_if);
 1245|       |
 1246|      0|      obs->dirty = 0;
 1247|       |      /* initialize response */
 1248|      0|      response = coap_pdu_init(COAP_MESSAGE_CON, 0, 0,
 1249|      0|                               coap_session_max_pdu_size_lkd(obs->session));
 1250|      0|      if (!response) {
  ------------------
  |  Branch (1250:11): [True: 0, False: 0]
  ------------------
 1251|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1252|      0|                       "partially dirty\n");
 1253|      0|        goto next_one_fail_no_pending;
 1254|      0|      }
 1255|       |
 1256|      0|      if (!coap_add_token(response, obs->pdu->actual_token.length,
  ------------------
  |  Branch (1256:11): [True: 0, False: 0]
  ------------------
 1257|      0|                          obs->pdu->actual_token.s)) {
 1258|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1259|      0|                       "partially dirty\n");
 1260|      0|        coap_delete_pdu_lkd(response);
 1261|      0|        goto next_one_fail_no_pending;
 1262|      0|      }
 1263|       |
 1264|      0|      obs->pdu->mid = response->mid = coap_new_message_id_lkd(obs->session);
 1265|       |      /* A lot of the reliable code assumes type is CON */
 1266|      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]
  |  |  ------------------
  ------------------
 1267|      0|          (r->flags & COAP_RESOURCE_FLAGS_NOTIFY_CON) == 0 &&
  ------------------
  |  |   69|      0|#define COAP_RESOURCE_FLAGS_NOTIFY_CON  0x2
  ------------------
  |  Branch (1267:11): [True: 0, False: 0]
  ------------------
 1268|      0|          ((r->flags & COAP_RESOURCE_FLAGS_NOTIFY_NON_ALWAYS) ||
  ------------------
  |  |   79|      0|#define COAP_RESOURCE_FLAGS_NOTIFY_NON_ALWAYS  0x4
  ------------------
  |  Branch (1268:12): [True: 0, False: 0]
  ------------------
 1269|      0|           obs->non_cnt < COAP_OBS_MAX_NON)) {
  ------------------
  |  |   39|      0|#define COAP_OBS_MAX_NON   5
  ------------------
  |  Branch (1269:12): [True: 0, False: 0]
  ------------------
 1270|      0|        response->type = COAP_MESSAGE_NON;
 1271|      0|      } else {
 1272|      0|        response->type = COAP_MESSAGE_CON;
 1273|      0|      }
 1274|      0|      switch (deleting) {
 1275|      0|      case COAP_NOT_DELETING_RESOURCE:
  ------------------
  |  Branch (1275:7): [True: 0, False: 0]
  ------------------
 1276|       |        /* fill with observer-specific data */
 1277|      0|        coap_add_option_internal(response, COAP_OPTION_OBSERVE,
 1278|      0|                                 coap_encode_var_safe(buf, sizeof(buf),
 1279|      0|                                                      r->observe),
 1280|      0|                                 buf);
 1281|      0|        if (coap_get_block_b(obs->session, obs->pdu, COAP_OPTION_BLOCK2,
  ------------------
  |  Branch (1281:13): [True: 0, False: 0]
  ------------------
 1282|      0|                             &block)) {
 1283|       |          /* Will get updated later (e.g. M bit) if appropriate */
 1284|      0|          coap_add_option_internal(response, COAP_OPTION_BLOCK2,
 1285|      0|                                   coap_encode_var_safe(buf, sizeof(buf),
 1286|      0|                                                        ((0 << 4) |
 1287|      0|                                                         (0 << 3) |
 1288|      0|                                                         block.aszx)),
 1289|      0|                                   buf);
 1290|      0|        }
 1291|      0|#if COAP_Q_BLOCK_SUPPORT
 1292|      0|        else if (coap_get_block_b(obs->session, obs->pdu, COAP_OPTION_Q_BLOCK2,
  ------------------
  |  Branch (1292:18): [True: 0, False: 0]
  ------------------
 1293|      0|                                  &block)) {
 1294|       |          /* Will get updated later (e.g. M bit) if appropriate */
 1295|      0|          coap_add_option_internal(response, COAP_OPTION_Q_BLOCK2,
 1296|      0|                                   coap_encode_var_safe(buf, sizeof(buf),
 1297|      0|                                                        ((0 << 4) |
 1298|      0|                                                         (0 << 3) |
 1299|      0|                                                         block.szx)),
 1300|      0|                                   buf);
 1301|      0|        }
 1302|      0|#endif /* COAP_Q_BLOCK_SUPPORT */
 1303|       |
 1304|      0|        h = r->handler[obs->pdu->code - 1];
 1305|      0|        assert(h);      /* we do not allow subscriptions if no
  ------------------
  |  Branch (1305:9): [True: 0, False: 0]
  ------------------
 1306|       |                         * GET/FETCH handler is defined */
 1307|      0|        query = coap_get_query(obs->pdu);
 1308|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1309|      0|        coap_show_pdu(COAP_LOG_DEBUG, obs->pdu);
 1310|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1311|      0|                       (int)r->uri_path->length, (int)r->uri_path->length,
 1312|      0|                       r->uri_path->s);
 1313|       |
 1314|       |        /* obs may get deleted during callback (potentially by another thread) */
 1315|      0|        if (r->flags & COAP_RESOURCE_SAFE_REQUEST_HANDLER) {
  ------------------
  |  |  181|      0|#define COAP_RESOURCE_SAFE_REQUEST_HANDLER 0x4000
  ------------------
  |  Branch (1315:13): [True: 0, False: 0]
  ------------------
 1316|      0|          coap_lock_callback_release(h(r, obs->session, obs->pdu, query, response),
  ------------------
  |  |  680|      0|#define coap_lock_callback_release(func,failed) func
  ------------------
 1317|       |                                     /* context is being freed off */
 1318|      0|                                     coap_delete_string(query);
 1319|      0|                                     coap_delete_pdu_lkd(response);
 1320|      0|                                     coap_session_release_lkd(obs_session);
 1321|      0|                                     coap_pdu_release_lkd(obs_pdu);
 1322|      0|                                     r->list_being_traversed = 0;
 1323|      0|                                     coap_resource_release_lkd(r);
 1324|      0|                                     return);
 1325|      0|        } else {
 1326|      0|          coap_lock_specific_callback_release(&r->lock,
  ------------------
  |  |  692|      0|#define coap_lock_specific_callback_release(lock,func,failed) func
  ------------------
 1327|      0|                                              h(r, obs->session, obs->pdu, query, response),
 1328|       |                                              /* context is being freed off */
 1329|      0|                                              coap_delete_string(query);
 1330|      0|                                              coap_delete_pdu_lkd(response);
 1331|      0|                                              coap_session_release_lkd(obs_session);
 1332|      0|                                              coap_pdu_release_lkd(obs_pdu);
 1333|      0|                                              r->list_being_traversed = 0;
 1334|      0|                                              coap_resource_release_lkd(r);
 1335|      0|                                              return);
 1336|      0|        }
 1337|       |
 1338|       |        /* Check validity of response code */
 1339|      0|        if (!coap_check_code_class(obs_session, response)) {
  ------------------
  |  Branch (1339:13): [True: 0, False: 0]
  ------------------
 1340|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1341|      0|                        COAP_RESPONSE_CLASS(response->code),
 1342|      0|                        response->code & 0x1f);
 1343|      0|          coap_delete_string(query);
 1344|      0|          coap_delete_pdu_lkd(response);
 1345|      0|          coap_session_release_lkd(obs_session);
 1346|      0|          coap_pdu_release_lkd(obs_pdu);
 1347|      0|          r->list_being_traversed = 0;
 1348|      0|          coap_resource_release_lkd(r);
 1349|      0|          return;
 1350|      0|        }
 1351|       |
 1352|       |        /* Check if lg_xmit generated and update PDU code if so */
 1353|      0|        coap_check_code_lg_xmit(obs_session, obs_pdu, response, r, query);
 1354|      0|        coap_delete_string(query);
 1355|      0|        if (COAP_RESPONSE_CLASS(response->code) != 2) {
  ------------------
  |  |   99|      0|#define COAP_RESPONSE_CLASS(C) (((C) >> 5) & 0xFF)
  ------------------
  |  Branch (1355:13): [True: 0, False: 0]
  ------------------
 1356|      0|          coap_remove_option(response, COAP_OPTION_OBSERVE);
 1357|      0|        }
 1358|      0|        if (COAP_RESPONSE_CLASS(response->code) > 2) {
  ------------------
  |  |   99|      0|#define COAP_RESPONSE_CLASS(C) (((C) >> 5) & 0xFF)
  ------------------
  |  Branch (1358:13): [True: 0, False: 0]
  ------------------
 1359|      0|          coap_delete_observer(r, obs_session, &obs_pdu->actual_token);
 1360|      0|          obs = NULL;
 1361|      0|        }
 1362|      0|        break;
 1363|      0|      case COAP_DELETING_RESOURCE_ON_EXIT:
  ------------------
  |  Branch (1363:7): [True: 0, False: 0]
  ------------------
 1364|       |        /* Don't worry if it does not get there */
 1365|      0|        response->type = COAP_MESSAGE_NON;
 1366|      0|        response->code = COAP_RESPONSE_CODE(503);
  ------------------
  |  |   96|      0|#define COAP_RESPONSE_CODE(N) (((N)/100 << 5) | (N)%100)
  ------------------
 1367|      0|        coap_add_option_internal(response, COAP_OPTION_MAXAGE,
 1368|      0|                                 coap_encode_var_safe(buf, sizeof(buf),
 1369|      0|                                                      30),
 1370|      0|                                 buf);
 1371|      0|        break;
 1372|      0|      case COAP_DELETING_RESOURCE:
  ------------------
  |  Branch (1372:7): [True: 0, False: 0]
  ------------------
 1373|      0|      default:
  ------------------
  |  Branch (1373:7): [True: 0, False: 0]
  ------------------
 1374|       |        /* Don't worry if it does not get there */
 1375|      0|        response->type = COAP_MESSAGE_NON;
 1376|      0|        response->code = COAP_RESPONSE_CODE(404);
  ------------------
  |  |   96|      0|#define COAP_RESPONSE_CODE(N) (((N)/100 << 5) | (N)%100)
  ------------------
 1377|      0|        break;
 1378|      0|      }
 1379|       |
 1380|      0|      if (obs) {
  ------------------
  |  Branch (1380:11): [True: 0, False: 0]
  ------------------
 1381|      0|        coap_subscription_t *s;
 1382|       |        /*
 1383|       |         * obs may have been deleted in the callback, or by another running
 1384|       |         * thread when executing the callback.
 1385|       |         */
 1386|      0|        LL_FOREACH(r->subscribers, s) {
  ------------------
  |  |  419|      0|    LL_FOREACH2(head,el,next)
  |  |  ------------------
  |  |  |  |  422|      0|    for ((el) = (head); el; (el) = (el)->next)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (422:25): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1387|      0|          if (s == obs) {
  ------------------
  |  Branch (1387:15): [True: 0, False: 0]
  ------------------
 1388|      0|            break;
 1389|      0|          }
 1390|      0|        }
 1391|      0|        if (s == NULL)
  ------------------
  |  Branch (1391:13): [True: 0, False: 0]
  ------------------
 1392|      0|          obs = NULL;
 1393|      0|      }
 1394|      0|      if (obs) {
  ------------------
  |  Branch (1394:11): [True: 0, False: 0]
  ------------------
 1395|      0|        if (response->type == COAP_MESSAGE_CON ||
  ------------------
  |  Branch (1395:13): [True: 0, False: 0]
  ------------------
 1396|      0|            (r->flags & COAP_RESOURCE_FLAGS_NOTIFY_NON_ALWAYS)) {
  ------------------
  |  |   79|      0|#define COAP_RESOURCE_FLAGS_NOTIFY_NON_ALWAYS  0x4
  ------------------
  |  Branch (1396:13): [True: 0, False: 0]
  ------------------
 1397|      0|          obs->non_cnt = 0;
 1398|      0|        } else {
 1399|      0|          obs->non_cnt++;
 1400|      0|        }
 1401|       |
 1402|      0|#if COAP_Q_BLOCK_SUPPORT
 1403|      0|        if (response->code == COAP_RESPONSE_CODE(205) &&
  ------------------
  |  |   96|      0|#define COAP_RESPONSE_CODE(N) (((N)/100 << 5) | (N)%100)
  ------------------
  |  Branch (1403:13): [True: 0, False: 0]
  ------------------
 1404|      0|            coap_get_block_b(obs_session, response, COAP_OPTION_Q_BLOCK2,
  ------------------
  |  Branch (1404:13): [True: 0, False: 0]
  ------------------
 1405|      0|                             &block) &&
 1406|      0|            block.m) {
  ------------------
  |  Branch (1406:13): [True: 0, False: 0]
  ------------------
 1407|      0|          query = coap_get_query(obs_pdu);
 1408|      0|          mid = coap_send_q_block2(obs_session, r, query, obs_pdu->code,
 1409|      0|                                   block, response, 1);
 1410|      0|          coap_delete_string(query);
 1411|      0|          goto finish;
 1412|      0|        }
 1413|      0|#endif /* COAP_Q_BLOCK_SUPPORT */
 1414|      0|      }
 1415|      0|      mid = coap_send_internal(obs_session, response, NULL);
 1416|       |
 1417|      0|#if COAP_Q_BLOCK_SUPPORT
 1418|      0|finish:
 1419|      0|#endif /* COAP_Q_BLOCK_SUPPORT */
 1420|      0|      if (COAP_INVALID_MID == mid) {
  ------------------
  |  |  187|      0|#define COAP_INVALID_MID -1
  ------------------
  |  Branch (1420:11): [True: 0, False: 0]
  ------------------
 1421|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1422|      0|                       "partially dirty\n", coap_session_str(obs_session));
 1423|      0|        if (obs) {
  ------------------
  |  Branch (1423:13): [True: 0, False: 0]
  ------------------
 1424|      0|          coap_subscription_t *s;
 1425|       |          /*
 1426|       |           * obs may have been deleted in coap_send_internal() or
 1427|       |           * coap_send_q_block2().
 1428|       |           */
 1429|      0|          LL_FOREACH(r->subscribers, s) {
  ------------------
  |  |  419|      0|    LL_FOREACH2(head,el,next)
  |  |  ------------------
  |  |  |  |  422|      0|    for ((el) = (head); el; (el) = (el)->next)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (422:25): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1430|      0|            if (s == obs) {
  ------------------
  |  Branch (1430:17): [True: 0, False: 0]
  ------------------
 1431|      0|              break;
 1432|      0|            }
 1433|      0|          }
 1434|      0|          if (s == NULL)
  ------------------
  |  Branch (1434:15): [True: 0, False: 0]
  ------------------
 1435|      0|            obs = NULL;
 1436|      0|        }
 1437|      0|        if (obs)
  ------------------
  |  Branch (1437:13): [True: 0, False: 0]
  ------------------
 1438|      0|          obs->dirty = 1;
 1439|      0|        r->partiallydirty = 1;
 1440|      0|      }
 1441|      0|      goto cleanup;
 1442|       |
 1443|      0|next_one_fail:
 1444|      0|      context->observe_pending = 1;
 1445|      0|next_one_fail_no_pending:
 1446|      0|      r->partiallydirty = 1;
 1447|      0|      if (obs)
  ------------------
  |  Branch (1447:11): [True: 0, False: 0]
  ------------------
 1448|      0|        obs->dirty = 1;
 1449|      0|cleanup:
 1450|      0|      coap_session_release_lkd(obs_session);
 1451|      0|      coap_pdu_release_lkd(obs_pdu);
 1452|      0|    }
 1453|      0|    r->list_being_traversed = 0;
 1454|      0|    r->dirty = 0;
 1455|      0|    coap_resource_release_lkd(r);
 1456|       |    /* r may be no more if elsewhere coap_free_resource() has been called */
 1457|     26|  } else {
 1458|     26|    r->dirty = 0;
 1459|     26|  }
 1460|     26|}

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

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

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

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

coap_split_proxy_uri:
  351|      7|coap_split_proxy_uri(const uint8_t *str_var, size_t len, coap_uri_t *uri) {
  352|      7|  return coap_split_uri_sub(str_var, len, uri, COAP_URI_CHECK_PROXY);
  353|      7|}
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|     13|coap_host_is_unix_domain(const coap_str_const_t *host) {
  467|     13|  if (host->length >= 3 && host->s[0] == '%' &&
  ------------------
  |  Branch (467:7): [True: 13, False: 0]
  |  Branch (467:28): [True: 0, False: 13]
  ------------------
  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|     13|  if (host->length >= 1 && host->s[0] == '/')
  ------------------
  |  Branch (472:7): [True: 13, False: 0]
  |  Branch (472:28): [True: 0, False: 13]
  ------------------
  473|      0|    return 1;
  474|     13|  return 0;
  475|     13|}
coap_host_is_llc:
  478|     13|coap_host_is_llc(const coap_str_const_t *host) {
  479|     13|#if COAP_AF_LLC_SUPPORT
  480|     13|  size_t length;
  481|     13|  const uint8_t *s = NULL;
  482|     13|  int i = 0;
  483|       |
  484|     13|  length = host->length;
  485|     13|  if (length != LLC_HOST_LEN)
  ------------------
  |  |  178|     13|#define LLC_HOST_LEN (4 + HW_ADDRSTRLEN + 4)
  |  |  ------------------
  |  |  |  |  176|     13|#define HW_ADDRSTRLEN 17
  |  |  ------------------
  ------------------
  |  Branch (485:7): [True: 13, False: 0]
  ------------------
  486|     13|    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|     91|coap_check_dots(const uint8_t *s, size_t len) {
  669|     91|  uint8_t p;
  670|       |
  671|     91|  if (!len)
  ------------------
  |  Branch (671:7): [True: 24, False: 67]
  ------------------
  672|     24|    return 0;
  673|       |
  674|     67|  p = *s;
  675|       |
  676|       |  /* Check 'first' char */
  677|     67|  if (p == '%' && len >=3) {
  ------------------
  |  Branch (677:7): [True: 8, False: 59]
  |  Branch (677:19): [True: 8, False: 0]
  ------------------
  678|      8|    if (s[1] == '2' && (s[2] == 'E' || s[2] == 'e')) {
  ------------------
  |  Branch (678:9): [True: 0, False: 8]
  |  Branch (678:25): [True: 0, False: 0]
  |  Branch (678:40): [True: 0, False: 0]
  ------------------
  679|      0|      s += 2;
  680|      0|      len -= 2;
  681|      0|    }
  682|      8|    p = '.';
  683|      8|  }
  684|     67|  if (p != '.')
  ------------------
  |  Branch (684:7): [True: 59, False: 8]
  ------------------
  685|     59|    return 0;
  686|      8|  if (len == 1)
  ------------------
  |  Branch (686:7): [True: 0, False: 8]
  ------------------
  687|      0|    return 1;
  688|       |
  689|       |  /* Check 'second' char, first is '.' */
  690|      8|  s++;
  691|      8|  len--;
  692|      8|  assert(len);
  ------------------
  |  Branch (692:3): [True: 8, False: 0]
  ------------------
  693|      8|  p = *s;
  694|      8|  if (p == '%' && len >=3) {
  ------------------
  |  Branch (694:7): [True: 8, False: 0]
  |  Branch (694:19): [True: 8, False: 0]
  ------------------
  695|      8|    if (s[1] == '2' && (s[2] == 'E' || s[2] == 'e')) {
  ------------------
  |  Branch (695:9): [True: 4, False: 4]
  |  Branch (695:25): [True: 0, False: 4]
  |  Branch (695:40): [True: 4, False: 0]
  ------------------
  696|      4|      len -= 2;
  697|      4|    }
  698|      8|    p = '.';
  699|      8|  }
  700|      8|  if (p != '.')
  ------------------
  |  Branch (700:7): [True: 0, False: 8]
  ------------------
  701|      0|    return 0;
  702|      8|  if (len == 1)
  ------------------
  |  Branch (702:7): [True: 0, False: 8]
  ------------------
  703|      0|    return 2;
  704|       |
  705|      8|  return 0;
  706|      8|}
coap_replace_percents:
  825|     16|coap_replace_percents(coap_optlist_t *optlist) {
  826|     16|  size_t i;
  827|     16|  size_t o = 0;
  828|       |
  829|    148|  for (i = 0; i < optlist->length; i++) {
  ------------------
  |  Branch (829:15): [True: 132, False: 16]
  ------------------
  830|    132|    if (optlist->data[i] == '%' && optlist->length - i >= 3) {
  ------------------
  |  Branch (830:9): [True: 7, False: 125]
  |  Branch (830:36): [True: 7, False: 0]
  ------------------
  831|      7|      optlist->data[o] = (hexchar_to_dec(optlist->data[i+1]) << 4) +
  ------------------
  |  |  532|      7|#define hexchar_to_dec(c) ((c) & 0x40 ? ((c) & 0x0F) + 9 : ((c) & 0x0F))
  |  |  ------------------
  |  |  |  Branch (532:28): [True: 5, False: 2]
  |  |  ------------------
  ------------------
  832|      7|                         hexchar_to_dec(optlist->data[i+2]);
  ------------------
  |  |  532|      7|#define hexchar_to_dec(c) ((c) & 0x40 ? ((c) & 0x0F) + 9 : ((c) & 0x0F))
  |  |  ------------------
  |  |  |  Branch (532:28): [True: 2, False: 5]
  |  |  ------------------
  ------------------
  833|      7|      i+= 2;
  834|    125|    } else if (o != i) {
  ------------------
  |  Branch (834:16): [True: 56, False: 69]
  ------------------
  835|     56|      optlist->data[o] = optlist->data[i];
  836|     56|    }
  837|    132|    o++;
  838|    132|  }
  839|     16|  optlist->length = o;
  840|     16|}
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|    162|  while (length > 0 && !strnchr((const uint8_t *)"?#", 2, *s)) {
  ------------------
  |  Branch (903:10): [True: 161, False: 1]
  |  Branch (903:24): [True: 161, False: 0]
  ------------------
  904|    161|    if (*s == '/') {                /* start of new path element */
  ------------------
  |  Branch (904:9): [True: 15, False: 146]
  ------------------
  905|       |      /* start new segment */
  906|     15|      num_dots = coap_check_dots(p, s - p);
  907|     15|      switch (num_dots) {
  908|      0|      case 1:
  ------------------
  |  Branch (908:7): [True: 0, False: 15]
  ------------------
  909|       |        /* drop segment */
  910|      0|        break;
  911|      0|      case 2:
  ------------------
  |  Branch (911:7): [True: 0, False: 15]
  ------------------
  912|       |        /* backup segment */
  913|      0|        backup_optlist(optlist_start);
  914|      0|        break;
  915|     15|      case 0:
  ------------------
  |  Branch (915:7): [True: 15, False: 0]
  ------------------
  916|     15|      default:
  ------------------
  |  Branch (916:7): [True: 0, False: 15]
  ------------------
  917|       |        /* add segment */
  918|     15|        optlist = coap_new_optlist(optnum, s - p, p);
  919|     15|        if (!optlist) {
  ------------------
  |  Branch (919:13): [True: 0, False: 15]
  ------------------
  920|      0|          return 0;
  921|      0|        }
  922|     15|        coap_replace_percents(optlist);
  923|     15|        if (!coap_insert_optlist(optlist_chain, optlist)) {
  ------------------
  |  Branch (923:13): [True: 0, False: 15]
  ------------------
  924|      0|          return 0;
  925|      0|        }
  926|     15|        break;
  927|     15|      }
  928|     15|      p = s + 1;
  929|     15|    }
  930|    161|    s++;
  931|    161|    length--;
  932|       |
  933|    161|  }
  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|     52|coap_delete_upa_chain(coap_upa_chain_t *chain) {
 1272|     52|  while (chain) {
  ------------------
  |  Branch (1272:10): [True: 0, False: 52]
  ------------------
 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|     52|}
coap_uri.c:coap_split_uri_sub:
   84|      7|                   coap_uri_check_t check_proxy) {
   85|      7|  const uint8_t *p, *q;
   86|      7|  int res = 0;
   87|      7|  size_t i;
   88|      7|  int is_unix_domain = 0;
   89|      7|  int is_llc = 0;
   90|       |
   91|      7|  if (!str_var || !uri || len == 0)
  ------------------
  |  Branch (91:7): [True: 0, False: 7]
  |  Branch (91:19): [True: 0, False: 7]
  |  Branch (91:27): [True: 0, False: 7]
  ------------------
   92|      0|    return -1;
   93|       |
   94|      7|  memset(uri, 0, sizeof(coap_uri_t));
   95|      7|  uri->port = COAP_DEFAULT_PORT;
  ------------------
  |  |   39|      7|#define COAP_DEFAULT_PORT      5683 /* CoAP default UDP/TCP port */
  ------------------
   96|       |
   97|       |  /* search for scheme */
   98|      7|  p = str_var;
   99|      7|  if (*p == '/') {
  ------------------
  |  Branch (99:7): [True: 0, False: 7]
  ------------------
  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|    568|  while (len >= 3 && !(p[0] == ':' && p[1] == '/' && p[2] == '/')) {
  ------------------
  |  Branch (110:10): [True: 565, False: 3]
  |  Branch (110:24): [True: 4, False: 561]
  |  Branch (110:39): [True: 4, False: 0]
  |  Branch (110:54): [True: 4, False: 0]
  ------------------
  111|    561|    ++p;
  112|    561|    --len;
  113|    561|  }
  114|      7|  if (len < 3) {
  ------------------
  |  Branch (114:7): [True: 3, False: 4]
  ------------------
  115|       |    /* scheme not defined with a :// terminator */
  116|      3|    res = -2;
  117|      3|    goto error;
  118|      3|  }
  119|     15|  for (i = 0; i < COAP_URI_SCHEME_LAST; i++) {
  ------------------
  |  Branch (119:15): [True: 14, False: 1]
  ------------------
  120|     14|    if ((p - str_var) == (int)strlen(coap_uri_scheme[i].name) &&
  ------------------
  |  Branch (120:9): [True: 3, False: 11]
  ------------------
  121|      3|        memcmp(str_var, coap_uri_scheme[i].name, p - str_var) == 0) {
  ------------------
  |  Branch (121:9): [True: 3, False: 0]
  ------------------
  122|      3|      if (check_proxy != COAP_URI_CHECK_PROXY && coap_uri_scheme[i].proxy_only) {
  ------------------
  |  Branch (122:11): [True: 0, False: 3]
  |  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|      3|      uri->scheme = coap_uri_scheme[i].scheme;
  128|      3|      uri->port = coap_uri_scheme[i].port;
  129|      3|      break;
  130|      3|    }
  131|     14|  }
  132|      4|  if (i == COAP_URI_SCHEME_LAST) {
  ------------------
  |  Branch (132:7): [True: 1, False: 3]
  ------------------
  133|       |    /* scheme unknown */
  134|      1|    coap_log_err("%.*s URI scheme unknown\n", (int)(p - str_var), str_var);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  135|      1|    res = -1;
  136|      1|    goto error;
  137|      1|  }
  138|      3|  switch (uri->scheme) {
  139|      2|  case COAP_URI_SCHEME_COAP:
  ------------------
  |  Branch (139:3): [True: 2, False: 1]
  ------------------
  140|      2|    break;
  141|      0|  case COAP_URI_SCHEME_COAPS:
  ------------------
  |  Branch (141:3): [True: 0, False: 3]
  ------------------
  142|      0|    if (!coap_dtls_is_supported()) {
  ------------------
  |  Branch (142:9): [True: 0, False: 0]
  ------------------
  143|      0|      coap_log_err("coaps URI scheme not supported in this version of libcoap\n");
  ------------------
  |  |  102|      0|#define coap_log_err(...) coap_log(COAP_LOG_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  144|      0|      return -1;
  145|      0|    }
  146|      0|    break;
  147|      0|  case COAP_URI_SCHEME_COAP_TCP:
  ------------------
  |  Branch (147:3): [True: 0, False: 3]
  ------------------
  148|      0|    if (!coap_tcp_is_supported()) {
  ------------------
  |  Branch (148:9): [True: 0, False: 0]
  ------------------
  149|      0|      coap_log_err("coap+tcp URI scheme not supported in this version of libcoap\n");
  ------------------
  |  |  102|      0|#define coap_log_err(...) coap_log(COAP_LOG_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  150|      0|      return -1;
  151|      0|    }
  152|      0|    break;
  153|      1|  case COAP_URI_SCHEME_COAPS_TCP:
  ------------------
  |  Branch (153:3): [True: 1, False: 2]
  ------------------
  154|      1|    if (!coap_tls_is_supported()) {
  ------------------
  |  Branch (154:9): [True: 0, False: 1]
  ------------------
  155|      0|      coap_log_err("coaps+tcp URI scheme not supported in this version of libcoap\n");
  ------------------
  |  |  102|      0|#define coap_log_err(...) coap_log(COAP_LOG_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  156|      0|      return -1;
  157|      0|    }
  158|      1|    break;
  159|      1|  case COAP_URI_SCHEME_COAP_WS:
  ------------------
  |  Branch (159:3): [True: 0, False: 3]
  ------------------
  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: 3]
  ------------------
  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: 3]
  ------------------
  172|      0|  case COAP_URI_SCHEME_HTTPS:
  ------------------
  |  Branch (172:3): [True: 0, False: 3]
  ------------------
  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: 3]
  ------------------
  176|      0|  default:
  ------------------
  |  Branch (176:3): [True: 0, False: 3]
  ------------------
  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|      3|  }
  180|       |  /* skip :// */
  181|      3|  p += 3;
  182|      3|  len -= 3;
  183|       |
  184|       |  /* p points to beginning of Uri-Host */
  185|      3|  q = p;
  186|       |
  187|      3|  if (len && *p == '[') {
  ------------------
  |  Branch (187:7): [True: 3, False: 0]
  |  Branch (187:14): [True: 0, False: 3]
  ------------------
  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|      3|  } else if ((len >= LLC_HOST_LEN) && strncmp((const char *)p, "llc[", 4) == 0) {
  ------------------
  |  |  178|      3|#define LLC_HOST_LEN (4 + HW_ADDRSTRLEN + 4)
  |  |  ------------------
  |  |  |  |  176|      3|#define HW_ADDRSTRLEN 17
  |  |  ------------------
  ------------------
  |  Branch (207:14): [True: 3, False: 0]
  |  Branch (207:39): [True: 0, False: 3]
  ------------------
  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|      3|  } else {
  253|       |    /* IPv4 address, FQDN or Unix domain socket */
  254|      3|    if (len >= 3 && p[0] == '%' && p[1] == '2' &&
  ------------------
  |  Branch (254:9): [True: 3, False: 0]
  |  Branch (254:21): [True: 0, False: 3]
  |  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|     31|    while (len && *q != ':' && *q != '/' && *q != '?') {
  ------------------
  |  Branch (260:12): [True: 31, False: 0]
  |  Branch (260:19): [True: 30, False: 1]
  |  Branch (260:32): [True: 28, False: 2]
  |  Branch (260:45): [True: 28, False: 0]
  ------------------
  261|     28|      ++q;
  262|     28|      --len;
  263|     28|    }
  264|       |
  265|      3|    if (p == q) {
  ------------------
  |  Branch (265:9): [True: 0, False: 3]
  ------------------
  266|      0|      res = -3;
  267|      0|      goto error;
  268|      0|    }
  269|       |
  270|      3|    if ((int)(q - p) > 255) {
  ------------------
  |  Branch (270:9): [True: 0, False: 3]
  ------------------
  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|      3|    COAP_SET_STR(&uri->host, q - p, p);
  ------------------
  |  |   52|      3|#define COAP_SET_STR(st,l,v) { (st)->length = (l), (st)->s = (v); }
  ------------------
  277|      3|  }
  278|       |
  279|       |  /* check for Uri-Port (invalid for Unix) */
  280|      3|  if (len && *q == ':') {
  ------------------
  |  Branch (280:7): [True: 3, False: 0]
  |  Branch (280:14): [True: 1, False: 2]
  ------------------
  281|      1|    if (is_unix_domain || is_llc) {
  ------------------
  |  Branch (281:9): [True: 0, False: 1]
  |  Branch (281:27): [True: 0, False: 1]
  ------------------
  282|      0|      res = -5;
  283|      0|      goto error;
  284|      0|    }
  285|      1|    p = ++q;
  286|      1|    --len;
  287|       |
  288|      1|    while (len && isdigit(*q)) {
  ------------------
  |  Branch (288:12): [True: 1, False: 0]
  |  Branch (288:19): [True: 0, False: 1]
  ------------------
  289|      0|      ++q;
  290|      0|      --len;
  291|      0|    }
  292|       |
  293|      1|    if (p < q) {                /* explicit port number given */
  ------------------
  |  Branch (293:9): [True: 0, False: 1]
  ------------------
  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|      1|  }
  309|       |
  310|      3|path:                 /* at this point, p must point to an absolute path */
  311|       |
  312|      3|  if (!len)
  ------------------
  |  Branch (312:7): [True: 0, False: 3]
  ------------------
  313|      0|    goto end;
  314|       |
  315|      3|  if (*q == '/') {
  ------------------
  |  Branch (315:7): [True: 3, False: 0]
  ------------------
  316|      3|    p = ++q;
  317|      3|    --len;
  318|       |
  319|    488|    while (len && *q != '?') {
  ------------------
  |  Branch (319:12): [True: 486, False: 2]
  |  Branch (319:19): [True: 485, False: 1]
  ------------------
  320|    485|      ++q;
  321|    485|      --len;
  322|    485|    }
  323|       |
  324|      3|    if (p < q) {
  ------------------
  |  Branch (324:9): [True: 3, False: 0]
  ------------------
  325|      3|      COAP_SET_STR(&uri->path, q - p, p);
  ------------------
  |  |   52|      3|#define COAP_SET_STR(st,l,v) { (st)->length = (l), (st)->s = (v); }
  ------------------
  326|      3|      p = q;
  327|      3|    }
  328|      3|  }
  329|       |
  330|       |  /* Uri_Query */
  331|      3|  if (len && *p == '?') {
  ------------------
  |  Branch (331:7): [True: 1, False: 2]
  |  Branch (331:14): [True: 1, False: 0]
  ------------------
  332|      1|    ++p;
  333|      1|    --len;
  334|      1|    COAP_SET_STR(&uri->query, len, p);
  ------------------
  |  |   52|      1|#define COAP_SET_STR(st,l,v) { (st)->length = (l), (st)->s = (v); }
  ------------------
  335|      1|    len = 0;
  336|      1|  }
  337|       |
  338|      3|end:
  339|      3|  return len ? -1 : 0;
  ------------------
  |  Branch (339:10): [True: 0, False: 3]
  ------------------
  340|       |
  341|      4|error:
  342|      4|  return res;
  343|      3|}
coap_uri.c:strnchr:
   47|    161|strnchr(const uint8_t *s, size_t len, unsigned char c) {
   48|    483|  while (len && *s++ != c)
  ------------------
  |  Branch (48:10): [True: 322, False: 161]
  |  Branch (48:17): [True: 322, False: 0]
  ------------------
   49|    322|    --len;
   50|       |
   51|    161|  return len ? s : NULL;
  ------------------
  |  Branch (51:10): [True: 0, False: 161]
  ------------------
   52|    161|}

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

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

