coap_proxy.c:coap_pdu_release_lkd:
  436|     15|coap_pdu_release_lkd(coap_pdu_t *pdu) {
  437|     15|  coap_delete_pdu_lkd(pdu);
  438|     15|}

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

coap_delete_all_async:
  238|     32|coap_delete_all_async(coap_context_t *context) {
  239|     32|  coap_async_t *astate, *tmp;
  240|       |
  241|     32|  LL_FOREACH_SAFE(context->async_state, astate, tmp) {
  ------------------
  |  |  425|     32|    LL_FOREACH_SAFE2(head,el,tmp,next)
  |  |  ------------------
  |  |  |  |  428|     32|  for ((el) = (head); (el) && ((tmp) = (el)->next, 1); (el) = (tmp))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (428:23): [True: 0, False: 32]
  |  |  |  |  |  Branch (428:31): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  242|      0|    coap_free_async_sub(context, astate);
  243|      0|  }
  244|       |  context->async_state = NULL;
  245|     32|}

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

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

coap_socket_connect_udp:
  217|     47|                        coap_address_t *remote_addr) {
  218|     47|  int on = 1;
  219|     47|#if COAP_IPV6_SUPPORT
  220|     47|  int off = 0;
  221|     47|#endif /* COAP_IPV6_SUPPORT */
  222|       |#ifdef _WIN32
  223|       |  u_long u_on = 1;
  224|       |#endif
  225|     47|  coap_address_t connect_addr;
  226|     47|  int is_mcast = coap_is_mcast(server);
  227|     47|  coap_address_copy(&connect_addr, server);
  228|       |
  229|     47|  sock->flags &= ~(COAP_SOCKET_CONNECTED | COAP_SOCKET_MULTICAST);
  ------------------
  |  |   77|     47|#define COAP_SOCKET_CONNECTED    0x0004  /**< the socket is connected */
  ------------------
                sock->flags &= ~(COAP_SOCKET_CONNECTED | COAP_SOCKET_MULTICAST);
  ------------------
  |  |   87|     47|#define COAP_SOCKET_MULTICAST    0x1000  /**< socket is used for multicast communication */
  ------------------
  230|     47|  sock->fd = socket(connect_addr.addr.sa.sa_family, SOCK_DGRAM, 0);
  231|       |
  232|     47|  if (sock->fd == COAP_INVALID_SOCKET) {
  ------------------
  |  |   52|     47|#define COAP_INVALID_SOCKET (-1)
  ------------------
  |  Branch (232:7): [True: 0, False: 47]
  ------------------
  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|     47|  if (ioctl(sock->fd, FIONBIO, &on) == COAP_SOCKET_ERROR)
  ------------------
  |  |   51|     47|#define COAP_SOCKET_ERROR (-1)
  ------------------
  |  Branch (241:7): [True: 0, False: 47]
  ------------------
  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|     47|  switch (connect_addr.addr.sa.sa_family) {
  254|      0|#if COAP_IPV4_SUPPORT
  255|     47|  case AF_INET:
  ------------------
  |  Branch (255:3): [True: 47, False: 0]
  ------------------
  256|     47|    if (connect_addr.addr.sin.sin_port == 0)
  ------------------
  |  Branch (256:9): [True: 15, False: 32]
  ------------------
  257|     15|      connect_addr.addr.sin.sin_port = htons(default_port);
  258|     47|#if IP_RECVERR && defined(HAVE_STRUCT_CMSGHDR) && defined(HAVE_LINUX_ERRQUEUE_H)
  259|     47|    if (setsockopt(sock->fd, IPPROTO_IP, IP_RECVERR, OPTVAL_T(&on),
  ------------------
  |  |   34|     47|# define OPTVAL_T(t)         (t)
  ------------------
  |  Branch (259:9): [True: 0, False: 47]
  ------------------
  260|     47|                   sizeof(on)) == COAP_SOCKET_ERROR)
  ------------------
  |  |   51|     47|#define COAP_SOCKET_ERROR (-1)
  ------------------
  261|     47|      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|     47|                     coap_socket_strerror());
  263|     47|#endif /* IP_RECVERR && HAVE_STRUCT_CMSGHDR && HAVE_LINUX_ERRQUEUE_H */
  264|     47|    break;
  265|      0|#endif /* COAP_IPV4_SUPPORT */
  266|      0|#if COAP_IPV6_SUPPORT
  267|      0|  case AF_INET6:
  ------------------
  |  Branch (267:3): [True: 0, False: 47]
  ------------------
  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: 47]
  ------------------
  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: 47]
  ------------------
  291|      0|    break;
  292|      0|#endif /* COAP_AF_LLC_SUPPORT */
  293|      0|  default:
  ------------------
  |  Branch (293:3): [True: 0, False: 47]
  ------------------
  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|     47|  }
  298|       |
  299|     47|  if (local_if && local_if->addr.sa.sa_family) {
  ------------------
  |  Branch (299:7): [True: 0, False: 47]
  |  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|     47|  } else if (connect_addr.addr.sa.sa_family == AF_UNIX) {
  ------------------
  |  Branch (319:14): [True: 0, False: 47]
  ------------------
  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|     47|  if (is_mcast) {
  ------------------
  |  Branch (327:7): [True: 0, False: 47]
  ------------------
  328|      0|    if (!(local_if && local_if->addr.sa.sa_family)) {
  ------------------
  |  Branch (328:11): [True: 0, False: 0]
  |  Branch (328:23): [True: 0, False: 0]
  ------------------
  329|       |      /* Bind to a (unused) port to simplify logging */
  330|      0|      coap_address_t bind_addr;
  331|       |
  332|      0|      coap_address_init(&bind_addr);
  333|      0|      bind_addr.addr.sa.sa_family = connect_addr.addr.sa.sa_family;
  334|      0|      if (bind(sock->fd, &bind_addr.addr.sa,
  ------------------
  |  Branch (334:11): [True: 0, False: 0]
  ------------------
  335|      0|#if COAP_IPV4_SUPPORT
  336|      0|               bind_addr.addr.sa.sa_family == AF_INET ?
  ------------------
  |  Branch (336:16): [True: 0, False: 0]
  ------------------
  337|      0|               (socklen_t)sizeof(struct sockaddr_in) :
  338|      0|#endif /* COAP_IPV4_SUPPORT */
  339|      0|               (socklen_t)bind_addr.size) == COAP_SOCKET_ERROR) {
  ------------------
  |  |   51|      0|#define COAP_SOCKET_ERROR (-1)
  ------------------
  340|      0|        coap_log_warn("coap_socket_connect_udp: bind: %s\n",
  ------------------
  |  |  108|      0|#define coap_log_warn(...) coap_log(COAP_LOG_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  341|      0|                      coap_socket_strerror());
  342|      0|        goto error;
  343|      0|      }
  344|      0|    }
  345|      0|    if (getsockname(sock->fd, &local_addr->addr.sa, &local_addr->size) == COAP_SOCKET_ERROR) {
  ------------------
  |  |   51|      0|#define COAP_SOCKET_ERROR (-1)
  ------------------
  |  Branch (345:9): [True: 0, False: 0]
  ------------------
  346|      0|      coap_log_warn("coap_socket_connect_udp: getsockname for multicast socket: %s\n",
  ------------------
  |  |  108|      0|#define coap_log_warn(...) coap_log(COAP_LOG_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  347|      0|                    coap_socket_strerror());
  348|      0|    }
  349|      0|    coap_address_copy(remote_addr, &connect_addr);
  350|      0|    coap_address_copy(&sock->mcast_addr, &connect_addr);
  351|      0|    sock->flags |= COAP_SOCKET_MULTICAST;
  ------------------
  |  |   87|      0|#define COAP_SOCKET_MULTICAST    0x1000  /**< socket is used for multicast communication */
  ------------------
  352|      0|    if (coap_is_bcast(server) &&
  ------------------
  |  Branch (352:9): [True: 0, False: 0]
  ------------------
  353|      0|        setsockopt(sock->fd, SOL_SOCKET, SO_BROADCAST, OPTVAL_T(&on),
  ------------------
  |  |   34|      0|# define OPTVAL_T(t)         (t)
  ------------------
  |  Branch (353:9): [True: 0, False: 0]
  ------------------
  354|      0|                   sizeof(on)) == COAP_SOCKET_ERROR)
  ------------------
  |  |   51|      0|#define COAP_SOCKET_ERROR (-1)
  ------------------
  355|      0|      coap_log_warn("coap_socket_connect_udp: setsockopt SO_BROADCAST: %s\n",
  ------------------
  |  |  108|      0|#define coap_log_warn(...) coap_log(COAP_LOG_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  356|      0|                    coap_socket_strerror());
  357|      0|    return 1;
  358|      0|  }
  359|       |
  360|     47|  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: 47]
  ------------------
  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: 47]
  ------------------
  368|      0|#endif /* COAP_AF_UNIX_SUPPORT */
  369|     47|  default:
  ------------------
  |  Branch (369:3): [True: 47, False: 0]
  ------------------
  370|     47|    if (connect(sock->fd, &connect_addr.addr.sa, connect_addr.size) == COAP_SOCKET_ERROR) {
  ------------------
  |  |   51|     47|#define COAP_SOCKET_ERROR (-1)
  ------------------
  |  Branch (370:9): [True: 0, False: 47]
  ------------------
  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|     47|    if (getpeername(sock->fd, &remote_addr->addr.sa, &remote_addr->size) == COAP_SOCKET_ERROR) {
  ------------------
  |  |   51|     47|#define COAP_SOCKET_ERROR (-1)
  ------------------
  |  Branch (384:9): [True: 0, False: 47]
  ------------------
  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|     47|    break;
  389|     47|  }
  390|       |
  391|     47|  if (getsockname(sock->fd, &local_addr->addr.sa, &local_addr->size) == COAP_SOCKET_ERROR) {
  ------------------
  |  |   51|     47|#define COAP_SOCKET_ERROR (-1)
  ------------------
  |  Branch (391:7): [True: 0, False: 47]
  ------------------
  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|     47|#if COAP_AF_LLC_SUPPORT
  397|       |  /* AF_LLC sockets send to the local address without an explicit destination. */
  398|     47|  if (coap_is_af_llc(&connect_addr))
  ------------------
  |  Branch (398:7): [True: 0, False: 47]
  ------------------
  399|      0|    sock->flags |= COAP_SOCKET_WANT_SENDTO;
  ------------------
  |  |   89|      0|#define COAP_SOCKET_WANT_SENDTO  0x4000  /**< socket requires a destination address for sending */
  ------------------
  400|     47|#endif /* COAP_AF_LLC_SUPPORT */
  401|       |
  402|     47|  sock->flags |= COAP_SOCKET_CONNECTED;
  ------------------
  |  |   77|     47|#define COAP_SOCKET_CONNECTED    0x0004  /**< the socket is connected */
  ------------------
  403|     47|  return 1;
  404|       |
  405|      0|error:
  406|      0|  coap_socket_dgrm_close(sock);
  407|      0|  return 0;
  408|     47|}
coap_socket_send:
  621|     12|                 const uint8_t *data, size_t datalen) {
  622|     12|  ssize_t bytes_written = 0;
  623|     12|  int r;
  624|       |
  625|     12|#if COAP_CLIENT_SUPPORT
  626|     12|  coap_test_cid_tuple_change(session);
  627|     12|#endif /* COAP_CLIENT_SUPPORT */
  628|       |
  629|     12|  if ((r = coap_debug_send_packet()) != 1) {
  ------------------
  |  Branch (629:7): [True: 12, False: 0]
  ------------------
  630|     12|    if (r)
  ------------------
  |  Branch (630:9): [True: 0, False: 12]
  ------------------
  631|      0|      bytes_written = -1;
  632|     12|    else
  633|     12|      bytes_written = (ssize_t)datalen;
  634|     12|  } else if (sock->flags & COAP_SOCKET_CONNECTED &&
  ------------------
  |  |   77|      0|#define COAP_SOCKET_CONNECTED    0x0004  /**< the socket is connected */
  ------------------
  |  Branch (634:14): [True: 0, False: 0]
  ------------------
  635|      0|             !(sock->flags & COAP_SOCKET_WANT_SENDTO)) {
  ------------------
  |  |   89|      0|#define COAP_SOCKET_WANT_SENDTO  0x4000  /**< socket requires a destination address for sending */
  ------------------
  |  Branch (635:14): [True: 0, False: 0]
  ------------------
  636|       |#ifdef _WIN32
  637|       |    bytes_written = send(sock->fd, (const char *)data, (int)datalen, 0);
  638|       |#else
  639|      0|    bytes_written = send(sock->fd, data, datalen, 0);
  640|      0|#endif
  641|      0|  } else {
  642|       |#if defined(_WIN32)
  643|       |    DWORD dwNumberOfBytesSent = 0;
  644|       |#endif /* _WIN32 */
  645|      0|#ifdef HAVE_STRUCT_CMSGHDR
  646|       |    /* a buffer large enough to hold all packet info types, ipv6 is the largest */
  647|      0|    char buf[CMSG_SPACE(sizeof(struct in6_pktinfo))];
  648|      0|    struct msghdr mhdr;
  649|      0|    struct iovec iov[1];
  650|      0|    const void *addr = &session->addr_info.remote.addr;
  651|       |
  652|      0|    assert(session);
  ------------------
  |  Branch (652:5): [True: 0, False: 0]
  ------------------
  653|       |
  654|      0|    memcpy(&iov[0].iov_base, &data, sizeof(iov[0].iov_base));
  655|      0|    iov[0].iov_len = (iov_len_t)datalen;
  656|       |
  657|      0|    memset(buf, 0, sizeof(buf));
  658|       |
  659|      0|    memset(&mhdr, 0, sizeof(struct msghdr));
  660|      0|    memcpy(&mhdr.msg_name, &addr, sizeof(mhdr.msg_name));
  661|      0|    mhdr.msg_namelen = session->addr_info.remote.addr.sa.sa_family == AF_INET ?
  ------------------
  |  Branch (661:24): [True: 0, False: 0]
  ------------------
  662|      0|                       (socklen_t)sizeof(struct sockaddr_in) :
  663|      0|                       session->addr_info.remote.size;
  664|       |
  665|      0|    mhdr.msg_iov = iov;
  666|      0|    mhdr.msg_iovlen = 1;
  667|       |
  668|      0|    if (!coap_address_isany(&session->addr_info.local) &&
  ------------------
  |  Branch (668:9): [True: 0, False: 0]
  ------------------
  669|      0|        !coap_is_mcast(&session->addr_info.local)) {
  ------------------
  |  Branch (669:9): [True: 0, False: 0]
  ------------------
  670|      0|      switch (session->addr_info.local.addr.sa.sa_family) {
  671|      0|#if COAP_IPV6_SUPPORT
  672|      0|      case AF_INET6: {
  ------------------
  |  Branch (672:7): [True: 0, False: 0]
  ------------------
  673|      0|        struct cmsghdr *cmsg;
  674|       |
  675|      0|#if COAP_IPV4_SUPPORT
  676|      0|        if (IN6_IS_ADDR_V4MAPPED(&session->addr_info.local.addr.sin6.sin6_addr)) {
  ------------------
  |  Branch (676:13): [True: 0, False: 0]
  ------------------
  677|      0|#if defined(IP_PKTINFO)
  678|      0|          struct in_pktinfo *pktinfo;
  679|      0|          mhdr.msg_control = buf;
  680|      0|          mhdr.msg_controllen = CMSG_SPACE(sizeof(struct in_pktinfo));
  681|       |
  682|      0|          cmsg = CMSG_FIRSTHDR(&mhdr);
  ------------------
  |  Branch (682:18): [True: 0, False: 0]
  ------------------
  683|      0|          cmsg->cmsg_level = COAP_SOL_IP;
  ------------------
  |  |  438|      0|#define COAP_SOL_IP SOL_IP
  ------------------
  684|      0|          cmsg->cmsg_type = IP_PKTINFO;
  685|      0|          cmsg->cmsg_len = CMSG_LEN(sizeof(struct in_pktinfo));
  686|       |
  687|      0|          pktinfo = (struct in_pktinfo *)CMSG_DATA(cmsg);
  688|       |
  689|      0|          pktinfo->ipi_ifindex = session->ifindex;
  690|      0|          memcpy(&pktinfo->ipi_spec_dst,
  691|      0|                 session->addr_info.local.addr.sin6.sin6_addr.s6_addr + 12,
  692|      0|                 sizeof(pktinfo->ipi_spec_dst));
  693|       |#elif defined(IP_SENDSRCADDR)
  694|       |          mhdr.msg_control = buf;
  695|       |          mhdr.msg_controllen = CMSG_SPACE(sizeof(struct in_addr));
  696|       |
  697|       |          cmsg = CMSG_FIRSTHDR(&mhdr);
  698|       |          cmsg->cmsg_level = IPPROTO_IP;
  699|       |          cmsg->cmsg_type = IP_SENDSRCADDR;
  700|       |          cmsg->cmsg_len = CMSG_LEN(sizeof(struct in_addr));
  701|       |
  702|       |          memcpy(CMSG_DATA(cmsg),
  703|       |                 session->addr_info.local.addr.sin6.sin6_addr.s6_addr + 12,
  704|       |                 sizeof(struct in_addr));
  705|       |#endif /* IP_PKTINFO */
  706|      0|        } else {
  707|      0|#endif /* COAP_IPV4_SUPPORT */
  708|      0|          struct in6_pktinfo *pktinfo;
  709|      0|          mhdr.msg_control = buf;
  710|      0|          mhdr.msg_controllen = CMSG_SPACE(sizeof(struct in6_pktinfo));
  711|       |
  712|      0|          cmsg = CMSG_FIRSTHDR(&mhdr);
  ------------------
  |  Branch (712:18): [True: 0, False: 0]
  ------------------
  713|      0|          cmsg->cmsg_level = IPPROTO_IPV6;
  714|      0|          cmsg->cmsg_type = IPV6_PKTINFO;
  715|      0|          cmsg->cmsg_len = CMSG_LEN(sizeof(struct in6_pktinfo));
  716|       |
  717|      0|          pktinfo = (struct in6_pktinfo *)CMSG_DATA(cmsg);
  718|       |
  719|      0|          if (coap_is_mcast(&session->addr_info.remote)) {
  ------------------
  |  Branch (719:15): [True: 0, False: 0]
  ------------------
  720|      0|            pktinfo->ipi6_ifindex = session->addr_info.remote.addr.sin6.sin6_scope_id;
  721|      0|          } else {
  722|      0|            pktinfo->ipi6_ifindex = session->ifindex;
  723|      0|          }
  724|      0|          memcpy(&pktinfo->ipi6_addr,
  725|      0|                 &session->addr_info.local.addr.sin6.sin6_addr,
  726|      0|                 sizeof(pktinfo->ipi6_addr));
  727|      0|#if COAP_IPV4_SUPPORT
  728|      0|        }
  729|      0|#endif /* COAP_IPV4_SUPPORT */
  730|      0|        break;
  731|      0|      }
  732|      0|#endif /* COAP_IPV6_SUPPORT */
  733|      0|#if COAP_IPV4_SUPPORT
  734|      0|      case AF_INET: {
  ------------------
  |  Branch (734:7): [True: 0, False: 0]
  ------------------
  735|      0|#if defined(IP_PKTINFO)
  736|      0|        struct cmsghdr *cmsg;
  737|      0|        struct in_pktinfo *pktinfo;
  738|       |
  739|      0|        mhdr.msg_control = buf;
  740|      0|        mhdr.msg_controllen = CMSG_SPACE(sizeof(struct in_pktinfo));
  741|       |
  742|      0|        cmsg = CMSG_FIRSTHDR(&mhdr);
  ------------------
  |  Branch (742:16): [True: 0, False: 0]
  ------------------
  743|      0|        cmsg->cmsg_level = COAP_SOL_IP;
  ------------------
  |  |  438|      0|#define COAP_SOL_IP SOL_IP
  ------------------
  744|      0|        cmsg->cmsg_type = IP_PKTINFO;
  745|      0|        cmsg->cmsg_len = CMSG_LEN(sizeof(struct in_pktinfo));
  746|       |
  747|      0|        pktinfo = (struct in_pktinfo *)CMSG_DATA(cmsg);
  748|       |
  749|      0|        pktinfo->ipi_ifindex = session->ifindex;
  750|      0|        memcpy(&pktinfo->ipi_spec_dst,
  751|      0|               &session->addr_info.local.addr.sin.sin_addr,
  752|      0|               sizeof(pktinfo->ipi_spec_dst));
  753|       |#elif defined(IP_SENDSRCADDR)
  754|       |        struct cmsghdr *cmsg;
  755|       |        mhdr.msg_control = buf;
  756|       |        mhdr.msg_controllen = CMSG_SPACE(sizeof(struct in_addr));
  757|       |
  758|       |        cmsg = CMSG_FIRSTHDR(&mhdr);
  759|       |        cmsg->cmsg_level = IPPROTO_IP;
  760|       |        cmsg->cmsg_type = IP_SENDSRCADDR;
  761|       |        cmsg->cmsg_len = CMSG_LEN(sizeof(struct in_addr));
  762|       |
  763|       |        memcpy(CMSG_DATA(cmsg),
  764|       |               &session->addr_info.local.addr.sin.sin_addr,
  765|       |               sizeof(struct in_addr));
  766|       |#endif /* IP_PKTINFO */
  767|      0|        break;
  768|      0|      }
  769|      0|#endif /* COAP_IPV4_SUPPORT */
  770|      0|#if COAP_AF_UNIX_SUPPORT
  771|      0|      case AF_UNIX:
  ------------------
  |  Branch (771:7): [True: 0, False: 0]
  ------------------
  772|      0|        break;
  773|      0|#endif /* COAP_AF_UNIX_SUPPORT */
  774|      0|#if COAP_AF_LLC_SUPPORT
  775|      0|      case AF_LLC:
  ------------------
  |  Branch (775:7): [True: 0, False: 0]
  ------------------
  776|      0|        break;
  777|      0|#endif /* COAP_AF_LLC_SUPPORT */
  778|      0|      default:
  ------------------
  |  Branch (778:7): [True: 0, False: 0]
  ------------------
  779|       |        /* error */
  780|      0|        coap_log_warn("protocol not supported\n");
  ------------------
  |  |  108|      0|#define coap_log_warn(...) coap_log(COAP_LOG_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  781|      0|        return -1;
  782|      0|      }
  783|      0|    }
  784|      0|#endif /* HAVE_STRUCT_CMSGHDR */
  785|       |
  786|       |#if defined(_WIN32)
  787|       |    r = WSASendMsg(sock->fd, &mhdr, 0 /*dwFlags*/, &dwNumberOfBytesSent, NULL /*lpOverlapped*/,
  788|       |                   NULL /*lpCompletionRoutine*/);
  789|       |    if (r == 0)
  790|       |      bytes_written = (ssize_t)dwNumberOfBytesSent;
  791|       |    else {
  792|       |      bytes_written = -1;
  793|       |      coap_win_error_to_errno();
  794|       |    }
  795|       |#else /* !_WIN32 */
  796|      0|#ifdef HAVE_STRUCT_CMSGHDR
  797|      0|    bytes_written = sendmsg(sock->fd, &mhdr, 0);
  798|       |#else /* ! HAVE_STRUCT_CMSGHDR */
  799|       |    bytes_written = sendto(sock->fd, (const void *)data, datalen, 0,
  800|       |                           &session->addr_info.remote.addr.sa,
  801|       |                           session->addr_info.remote.size);
  802|       |#endif /* ! HAVE_STRUCT_CMSGHDR */
  803|      0|#endif /* !_WIN32 */
  804|      0|  }
  805|       |
  806|     12|  if (bytes_written < 0)
  ------------------
  |  Branch (806:7): [True: 0, False: 12]
  ------------------
  807|     12|    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|     12|  return bytes_written;
  810|     12|}
coap_socket_dgrm_close:
 1052|     47|coap_socket_dgrm_close(coap_socket_t *sock) {
 1053|     47|  if (sock->fd != COAP_INVALID_SOCKET && !(sock->flags & COAP_SOCKET_SLAVE)) {
  ------------------
  |  |   52|     94|#define COAP_INVALID_SOCKET (-1)
  ------------------
                if (sock->fd != COAP_INVALID_SOCKET && !(sock->flags & COAP_SOCKET_SLAVE)) {
  ------------------
  |  |   88|     47|#define COAP_SOCKET_SLAVE        0x2000  /**< socket is a slave socket - do not close */
  ------------------
  |  Branch (1053:7): [True: 47, False: 0]
  |  Branch (1053:42): [True: 47, False: 0]
  ------------------
 1054|     47|#ifdef COAP_EPOLL_SUPPORT
 1055|     47|#if COAP_SERVER_SUPPORT
 1056|     47|    coap_context_t *context = sock->session ? sock->session->context :
  ------------------
  |  Branch (1056:31): [True: 47, False: 0]
  ------------------
 1057|     47|                              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|     47|    if (context != NULL) {
  ------------------
  |  Branch (1061:9): [True: 47, False: 0]
  ------------------
 1062|     47|      int ret;
 1063|     47|      struct epoll_event event;
 1064|       |
 1065|       |      /* Kernels prior to 2.6.9 expect non NULL event parameter */
 1066|     47|      ret = epoll_ctl(context->epfd, EPOLL_CTL_DEL, sock->fd, &event);
 1067|     47|      if (ret == -1 && errno != ENOENT) {
  ------------------
  |  Branch (1067:11): [True: 0, False: 47]
  |  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|     47|    }
 1074|     47|#endif /* COAP_EPOLL_SUPPORT */
 1075|     47|#if COAP_SERVER_SUPPORT
 1076|     47|#if COAP_AF_UNIX_SUPPORT
 1077|     47|    if (sock->endpoint &&
  ------------------
  |  Branch (1077:9): [True: 0, False: 47]
  ------------------
 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|     47|#endif /* COAP_AF_UNIX_SUPPORT */
 1087|     47|    sock->endpoint = NULL;
 1088|     47|#endif /* COAP_SERVER_SUPPORT */
 1089|     47|#if COAP_CLIENT_SUPPORT
 1090|     47|#if COAP_AF_UNIX_SUPPORT
 1091|     47|    if (sock->session && sock->session->type == COAP_SESSION_TYPE_CLIENT &&
  ------------------
  |  Branch (1091:9): [True: 47, False: 0]
  |  Branch (1091:26): [True: 47, False: 0]
  ------------------
 1092|     47|        sock->session->addr_info.local.addr.sa.sa_family == AF_UNIX) {
  ------------------
  |  Branch (1092:9): [True: 0, False: 47]
  ------------------
 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|     47|#endif /* COAP_AF_UNIX_SUPPORT */
 1101|     47|#endif /* COAP_CLIENT_SUPPORT */
 1102|     47|    sock->session = NULL;
 1103|     47|    coap_closesocket(sock->fd);
  ------------------
  |  |   50|     47|#define coap_closesocket close
  ------------------
 1104|     47|    sock->fd = COAP_INVALID_SOCKET;
  ------------------
  |  |   52|     47|#define COAP_INVALID_SOCKET (-1)
  ------------------
 1105|     47|    sock->flags = COAP_SOCKET_EMPTY;
  ------------------
  |  |   74|     47|#define COAP_SOCKET_EMPTY        0x0000  /**< the socket is not used */
  ------------------
 1106|     47|  }
 1107|     47|}
coap_dgrm_posix.c:coap_test_cid_tuple_change:
  487|     12|coap_test_cid_tuple_change(coap_session_t *session) {
  488|     12|  if (session->type == COAP_SESSION_TYPE_CLIENT &&
  ------------------
  |  Branch (488:7): [True: 12, False: 0]
  ------------------
  489|     12|      session->negotiated_cid &&
  ------------------
  |  Branch (489:7): [True: 0, False: 12]
  ------------------
  490|      0|      session->state == COAP_SESSION_STATE_ESTABLISHED &&
  ------------------
  |  Branch (490:7): [True: 0, False: 0]
  ------------------
  491|      0|      session->proto == COAP_PROTO_DTLS && session->context->testing_cids) {
  ------------------
  |  Branch (491:7): [True: 0, False: 0]
  |  Branch (491:44): [True: 0, False: 0]
  ------------------
  492|      0|    if ((++cid_track_counter) % session->context->testing_cids == 0) {
  ------------------
  |  Branch (492:9): [True: 0, False: 0]
  ------------------
  493|      0|      coap_address_t local_if = session->addr_info.local;
  494|      0|      uint16_t port = coap_address_get_port(&local_if);
  495|       |
  496|      0|      port++;
  497|      0|      coap_address_set_port(&local_if, port);
  498|       |
  499|      0|      coap_socket_dgrm_close(&session->sock);
  500|      0|      session->sock.session = session;
  501|      0|      if (!coap_socket_connect_udp(&session->sock, &local_if, &session->addr_info.remote,
  ------------------
  |  Branch (501:11): [True: 0, False: 0]
  ------------------
  502|      0|                                   port,
  503|      0|                                   &session->addr_info.local,
  504|      0|                                   &session->addr_info.remote)) {
  505|      0|        coap_log_err("Tuple change for CID failed\n");
  ------------------
  |  |  102|      0|#define coap_log_err(...) coap_log(COAP_LOG_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  506|      0|        return;
  507|      0|#ifdef COAP_EPOLL_SUPPORT
  508|      0|      } else {
  509|      0|        coap_epoll_ctl_add(&session->sock,
  510|      0|                           EPOLLIN |
  511|      0|                           ((session->sock.flags & COAP_SOCKET_WANT_CONNECT) ?
  ------------------
  |  |   82|      0|#define COAP_SOCKET_WANT_CONNECT 0x0080  /**< non blocking client socket is waiting for connect */
  ------------------
  |  Branch (511:29): [True: 0, False: 0]
  ------------------
  512|      0|                            EPOLLOUT : 0),
  513|      0|                           __func__);
  514|      0|#endif /* COAP_EPOLL_SUPPORT */
  515|      0|      }
  516|      0|      session->sock.flags |= COAP_SOCKET_NOT_EMPTY | COAP_SOCKET_WANT_READ | COAP_SOCKET_BOUND;
  ------------------
  |  |   75|      0|#define COAP_SOCKET_NOT_EMPTY    0x0001  /**< the socket is not empty */
  ------------------
                    session->sock.flags |= COAP_SOCKET_NOT_EMPTY | COAP_SOCKET_WANT_READ | COAP_SOCKET_BOUND;
  ------------------
  |  |   79|      0|#define COAP_SOCKET_WANT_READ    0x0010  /**< non blocking socket is waiting for reading */
  ------------------
                    session->sock.flags |= COAP_SOCKET_NOT_EMPTY | COAP_SOCKET_WANT_READ | COAP_SOCKET_BOUND;
  ------------------
  |  |   76|      0|#define COAP_SOCKET_BOUND        0x0002  /**< the socket is bound */
  ------------------
  517|      0|    }
  518|      0|  }
  519|     12|}

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

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

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

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

coap_memory_init:
  623|     32|coap_memory_init(void) {
  624|     32|}
coap_malloc_type:
  627|    520|coap_malloc_type(coap_memory_tag_t type, size_t size) {
  628|    520|  void *ptr;
  629|       |
  630|    520|  (void)type;
  631|    520|  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|    520|  return ptr;
  643|    520|}
coap_realloc_type:
  646|     15|coap_realloc_type(coap_memory_tag_t type, void *p, size_t size) {
  647|     15|  void *ptr;
  648|       |
  649|     15|  (void)type;
  650|     15|  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|     15|  return ptr;
  663|     15|}
coap_free_type:
  666|  1.13k|coap_free_type(coap_memory_tag_t type, void *p) {
  667|  1.13k|  (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|  1.13k|  free(p);
  674|  1.13k|}
coap_dump_memory_type_counts:
  735|     32|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|     32|  (void)level;
  783|     32|#endif /* COAP_MEMORY_TYPE_TRACK */
  784|     32|}

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

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

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

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

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

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

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

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

coap_resource_proxy_uri_init2:
  396|     32|                              const char *host_name_list[], int flags) {
  397|     32|  coap_resource_t *r;
  398|       |
  399|     32|  r = (coap_resource_t *)coap_malloc_type(COAP_RESOURCE, sizeof(coap_resource_t));
  400|     32|  if (r) {
  ------------------
  |  Branch (400:7): [True: 32, False: 0]
  ------------------
  401|     32|    size_t i;
  402|     32|    memset(r, 0, sizeof(coap_resource_t));
  403|       |#if COAP_THREAD_SAFE
  404|       |    coap_lock_init(&r->lock);
  405|       |#endif /* COAP_THREAD_SAFE */
  406|     32|    r->is_proxy_uri = 1;
  407|       |    /* Something unlikely to be used, but it shows up in the logs */
  408|     32|    r->uri_path = coap_new_str_const(coap_proxy_resource_uri, sizeof(coap_proxy_resource_uri)-1);
  409|       |    /* Preset all the handlers */
  410|    256|    for (i = 0; i < (sizeof(r->handler) / sizeof(r->handler[0])); i++) {
  ------------------
  |  Branch (410:17): [True: 224, False: 32]
  ------------------
  411|    224|      r->handler[i] = handler;
  412|    224|    }
  413|     32|    if (host_name_count) {
  ------------------
  |  Branch (413:9): [True: 0, False: 32]
  ------------------
  414|      0|      r->proxy_name_list = coap_malloc_type(COAP_STRING, host_name_count *
  415|      0|                                            sizeof(coap_str_const_t *));
  416|      0|      if (r->proxy_name_list) {
  ------------------
  |  Branch (416:11): [True: 0, False: 0]
  ------------------
  417|      0|        for (i = 0; i < host_name_count; i++) {
  ------------------
  |  Branch (417:21): [True: 0, False: 0]
  ------------------
  418|      0|          r->proxy_name_list[i] =
  419|      0|              coap_new_str_const((const uint8_t *)host_name_list[i],
  420|      0|                                 strlen(host_name_list[i]));
  421|      0|          if (!r->proxy_name_list[i]) {
  ------------------
  |  Branch (421:15): [True: 0, False: 0]
  ------------------
  422|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  423|      0|            if (i == 0) {
  ------------------
  |  Branch (423:17): [True: 0, False: 0]
  ------------------
  424|      0|              coap_free_type(COAP_STRING, r->proxy_name_list);
  425|      0|              r->proxy_name_list = NULL;
  426|      0|            }
  427|      0|            break;
  428|      0|          }
  429|      0|        }
  430|      0|        r->proxy_name_count = i;
  431|      0|      }
  432|      0|    }
  433|     32|    r->flags = flags & ~COAP_RESOURCE_FLAGS_RELEASE_URI;
  ------------------
  |  |   55|     32|#define COAP_RESOURCE_FLAGS_RELEASE_URI 0x1
  ------------------
  434|     32|  } else {
  435|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  436|      0|  }
  437|       |
  438|     32|  return r;
  439|     32|}
coap_add_resource:
  605|     32|coap_add_resource(coap_context_t *context, coap_resource_t *resource) {
  606|     32|  coap_lock_lock(return);
  607|     32|  coap_add_resource_lkd(context, resource);
  608|     32|  coap_lock_unlock();
  609|     32|}
coap_add_resource_lkd:
  612|     32|coap_add_resource_lkd(coap_context_t *context, coap_resource_t *resource) {
  613|     32|  coap_lock_check_locked();
  ------------------
  |  |  638|     32|#define coap_lock_check_locked() {}
  ------------------
  614|     32|  if (resource->is_unknown) {
  ------------------
  |  Branch (614:7): [True: 0, False: 32]
  ------------------
  615|      0|    if (context->unknown_resource)
  ------------------
  |  Branch (615:9): [True: 0, False: 0]
  ------------------
  616|      0|      coap_free_resource(context->unknown_resource, COAP_DELETING_RESOURCE);
  617|      0|    context->unknown_resource = resource;
  618|     32|  } else if (resource->is_proxy_uri) {
  ------------------
  |  Branch (618:14): [True: 32, False: 0]
  ------------------
  619|     32|    if (context->proxy_uri_resource)
  ------------------
  |  Branch (619:9): [True: 0, False: 32]
  ------------------
  620|      0|      coap_free_resource(context->proxy_uri_resource, COAP_DELETING_RESOURCE);
  621|     32|    context->proxy_uri_resource = resource;
  622|     32|  } else {
  623|      0|    coap_resource_t *r = coap_get_resource_from_uri_path_lkd(context,
  624|      0|                                                             resource->uri_path);
  625|       |
  626|      0|    if (r) {
  ------------------
  |  Branch (626:9): [True: 0, False: 0]
  ------------------
  627|      0|      coap_log_warn("coap_add_resource: Duplicate uri_path '%*.*s', old resource deleted\n",
  ------------------
  |  |  108|      0|#define coap_log_warn(...) coap_log(COAP_LOG_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  628|      0|                    (int)resource->uri_path->length, (int)resource->uri_path->length,
  629|      0|                    resource->uri_path->s);
  630|      0|      coap_delete_resource_lkd(r);
  631|      0|    }
  632|      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]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  633|      0|#if COAP_WITH_OBSERVE_PERSIST
  634|      0|    if (context->unknown_pdu && context->dyn_resource_save_file &&
  ------------------
  |  Branch (634:9): [True: 0, False: 0]
  |  Branch (634:33): [True: 0, False: 0]
  ------------------
  635|      0|        context->dyn_resource_added_cb && resource->observable) {
  ------------------
  |  Branch (635:9): [True: 0, False: 0]
  |  Branch (635:43): [True: 0, False: 0]
  ------------------
  636|      0|      coap_bin_const_t raw_packet;
  637|       |
  638|      0|      raw_packet.s = context->unknown_pdu->token -
  639|      0|                     context->unknown_pdu->hdr_size;
  640|      0|      raw_packet.length = context->unknown_pdu->used_size +
  641|      0|                          context->unknown_pdu->hdr_size;
  642|      0|      coap_lock_callback(context->dyn_resource_added_cb(context->unknown_session,
  ------------------
  |  |  651|      0|#define coap_lock_callback(func) func
  ------------------
  643|      0|                                                        resource->uri_path,
  644|      0|                                                        &raw_packet,
  645|      0|                                                        context->observe_user_data));
  646|      0|    }
  647|      0|#endif /* COAP_WITH_OBSERVE_PERSIST */
  648|      0|  }
  649|     32|  assert(resource->context == NULL);
  ------------------
  |  Branch (649:3): [True: 32, False: 0]
  ------------------
  650|     32|  resource->context = context;
  651|     32|}
coap_delete_resource_lkd:
  671|     32|coap_delete_resource_lkd(coap_resource_t *resource) {
  672|     32|  coap_context_t *context;
  673|     32|  coap_deleting_resource_t deleting;
  674|       |
  675|     32|  if (!resource)
  ------------------
  |  Branch (675:7): [True: 0, False: 32]
  ------------------
  676|      0|    return 0;
  677|       |
  678|     32|  context = resource->context;
  679|     32|  coap_lock_check_locked();
  ------------------
  |  |  638|     32|#define coap_lock_check_locked() {}
  ------------------
  680|       |
  681|     32|  if (resource->ref) {
  ------------------
  |  Branch (681:7): [True: 0, False: 32]
  ------------------
  682|      0|    resource->ref--;
  683|      0|    return 1;
  684|      0|  }
  685|     32|  if (context && context->context_going_away) {
  ------------------
  |  Branch (685:7): [True: 32, False: 0]
  |  Branch (685:18): [True: 32, False: 0]
  ------------------
  686|     32|    deleting = COAP_DELETING_RESOURCE_ON_EXIT;
  687|     32|  } else {
  688|      0|    deleting = COAP_DELETING_RESOURCE;
  689|      0|  }
  690|     32|  if (resource->is_unknown) {
  ------------------
  |  Branch (690:7): [True: 0, False: 32]
  ------------------
  691|      0|    if (context && context->unknown_resource == resource) {
  ------------------
  |  Branch (691:9): [True: 0, False: 0]
  |  Branch (691:20): [True: 0, False: 0]
  ------------------
  692|      0|      context->unknown_resource = NULL;
  693|      0|    }
  694|     32|  } else if (resource->is_proxy_uri) {
  ------------------
  |  Branch (694:14): [True: 32, False: 0]
  ------------------
  695|     32|    if (context && context->proxy_uri_resource == resource) {
  ------------------
  |  Branch (695:9): [True: 32, False: 0]
  |  Branch (695:20): [True: 32, False: 0]
  ------------------
  696|     32|      context->proxy_uri_resource = NULL;
  697|     32|    }
  698|     32|  } else if (context) {
  ------------------
  |  Branch (698:14): [True: 0, False: 0]
  ------------------
  699|       |    /* remove resource from list */
  700|      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]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  701|      0|  }
  702|     32|  if (resource->is_dynamic) {
  ------------------
  |  Branch (702:7): [True: 0, False: 32]
  ------------------
  703|      0|    if (context) {
  ------------------
  |  Branch (703:9): [True: 0, False: 0]
  ------------------
  704|      0|      assert(context->dynamic_cur);
  ------------------
  |  Branch (704:7): [True: 0, False: 0]
  ------------------
  705|      0|      context->dynamic_cur--;
  706|      0|    }
  707|      0|  }
  708|       |
  709|       |  /* and free its allocated memory */
  710|     32|  coap_free_resource(resource, deleting);
  711|       |
  712|     32|  return 1;
  713|     32|}
coap_delete_all_resources:
  721|     32|coap_delete_all_resources(coap_context_t *context) {
  722|     32|  coap_resource_t *r;
  723|     32|  coap_resource_t *tmp;
  724|       |
  725|     32|  RESOURCE_ITER_SAFE(context->resources, r, tmp) {
  ------------------
  |  |  197|     32|  for ((el) = (e); (el) && ((rtmp) = (el)->hh.next, 1); (el) = (rtmp))
  |  |  ------------------
  |  |  |  Branch (197:20): [True: 0, False: 32]
  |  |  |  Branch (197:28): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  726|      0|    coap_delete_resource_lkd(r);
  727|      0|  }
  728|       |
  729|     32|  context->resources = NULL;
  730|       |
  731|     32|  if (context->unknown_resource) {
  ------------------
  |  Branch (731:7): [True: 0, False: 32]
  ------------------
  732|      0|    coap_delete_resource_lkd(context->unknown_resource);
  733|      0|    context->unknown_resource = NULL;
  734|      0|  }
  735|     32|  if (context->proxy_uri_resource) {
  ------------------
  |  Branch (735:7): [True: 32, False: 0]
  ------------------
  736|     32|    coap_delete_resource_lkd(context->proxy_uri_resource);
  737|       |    context->proxy_uri_resource = NULL;
  738|     32|  }
  739|     32|}
coap_resource_notify_observers_lkd:
 1545|     32|                                   coap_deleting_resource_t deleting) {
 1546|     32|  coap_lock_check_locked();
  ------------------
  |  |  638|     32|#define coap_lock_check_locked() {}
  ------------------
 1547|     32|  if (!r->observable)
  ------------------
  |  Branch (1547:7): [True: 32, False: 0]
  ------------------
 1548|     32|    return 0;
 1549|      0|  if (!r->subscribers)
  ------------------
  |  Branch (1549:7): [True: 0, False: 0]
  ------------------
 1550|      0|    return 0;
 1551|      0|  r->dirty = 1;
 1552|       |
 1553|       |  /* Increment value for next Observe use. Observe value must be < 2^24 */
 1554|      0|  r->observe = (r->observe + 1) & 0xFFFFFF;
 1555|       |
 1556|      0|  assert(r->context);
  ------------------
  |  Branch (1556:3): [True: 0, False: 0]
  ------------------
 1557|       |
 1558|      0|  if (r->context->track_observe_value_cb) {
  ------------------
  |  Branch (1558:7): [True: 0, False: 0]
  ------------------
 1559|       |    /* Track last used observe value */
 1560|      0|    if ((r->observe % r->context->observe_save_freq) == 0)
  ------------------
  |  Branch (1560:9): [True: 0, False: 0]
  ------------------
 1561|      0|      coap_lock_callback(r->context->track_observe_value_cb(r->context, r->uri_path,
  ------------------
  |  |  651|      0|#define coap_lock_callback(func) func
  ------------------
 1562|      0|                                                            r->observe,
 1563|      0|                                                            r->context->observe_user_data));
 1564|      0|  }
 1565|       |
 1566|      0|  coap_notify_observers(r->context, r, deleting);
 1567|      0|  return 1;
 1568|      0|}
coap_resource.c:coap_free_resource:
  558|     32|coap_free_resource(coap_resource_t *resource, coap_deleting_resource_t deleting) {
  559|     32|  coap_attr_t *attr, *tmp;
  560|     32|  coap_subscription_t *obs, *otmp;
  561|     32|  coap_context_t *context;
  562|       |
  563|     32|  assert(resource);
  ------------------
  |  Branch (563:3): [True: 32, False: 0]
  ------------------
  564|       |
  565|     32|  context = resource->context;
  566|     32|  if (context) {
  ------------------
  |  Branch (566:7): [True: 32, False: 0]
  ------------------
  567|     32|    if (!context->observe_no_clear) {
  ------------------
  |  Branch (567:9): [True: 32, False: 0]
  ------------------
  568|     32|      coap_resource_notify_observers_lkd(resource, deleting);
  569|     32|      coap_notify_observers(context, resource, deleting);
  570|     32|    }
  571|       |
  572|     32|    if (context->resource_deleted_cb)
  ------------------
  |  Branch (572:9): [True: 0, False: 32]
  ------------------
  573|      0|      coap_lock_callback(context->resource_deleted_cb(context,
  ------------------
  |  |  651|     32|#define coap_lock_callback(func) func
  ------------------
  574|     32|                                                      resource->uri_path,
  575|     32|                                                      context->observe_user_data));
  576|       |
  577|     32|    if (context->release_userdata_cb && resource->user_data) {
  ------------------
  |  Branch (577:9): [True: 0, False: 32]
  |  Branch (577:41): [True: 0, False: 0]
  ------------------
  578|      0|      coap_lock_callback(context->release_userdata_cb(resource->user_data));
  ------------------
  |  |  651|      0|#define coap_lock_callback(func) func
  ------------------
  579|      0|    }
  580|     32|  }
  581|       |
  582|       |  /* delete registered attributes */
  583|     32|  LL_FOREACH_SAFE(resource->link_attr, attr, tmp) coap_delete_attr(attr);
  ------------------
  |  |  425|     32|    LL_FOREACH_SAFE2(head,el,tmp,next)
  |  |  ------------------
  |  |  |  |  428|     32|  for ((el) = (head); (el) && ((tmp) = (el)->next, 1); (el) = (tmp))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (428:23): [True: 0, False: 32]
  |  |  |  |  |  Branch (428:31): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  584|       |
  585|       |  /* Either the application provided or libcoap copied - need to delete it */
  586|     32|  coap_delete_str_const(resource->uri_path);
  587|       |
  588|       |  /* free all elements from resource->subscribers */
  589|     32|  LL_FOREACH_SAFE(resource->subscribers, obs, otmp) {
  ------------------
  |  |  425|     32|    LL_FOREACH_SAFE2(head,el,tmp,next)
  |  |  ------------------
  |  |  |  |  428|     32|  for ((el) = (head); (el) && ((tmp) = (el)->next, 1); (el) = (tmp))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (428:23): [True: 0, False: 32]
  |  |  |  |  |  Branch (428:31): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  590|      0|    coap_delete_observer_internal(resource, obs->session, obs);
  591|      0|  }
  592|     32|  if (resource->proxy_name_count && resource->proxy_name_list) {
  ------------------
  |  Branch (592:7): [True: 0, False: 32]
  |  Branch (592:37): [True: 0, False: 0]
  ------------------
  593|      0|    size_t i;
  594|       |
  595|      0|    for (i = 0; i < resource->proxy_name_count; i++) {
  ------------------
  |  Branch (595:17): [True: 0, False: 0]
  ------------------
  596|      0|      coap_delete_str_const(resource->proxy_name_list[i]);
  597|      0|    }
  598|      0|    coap_free_type(COAP_STRING, resource->proxy_name_list);
  599|      0|  }
  600|       |
  601|     32|  coap_free_type(COAP_RESOURCE, resource);
  602|     32|}
coap_resource.c:coap_notify_observers:
 1209|     32|                      coap_deleting_resource_t deleting) {
 1210|     32|  coap_method_handler_t h;
 1211|     32|  coap_subscription_t *obs;
 1212|     32|  coap_pdu_t *response;
 1213|     32|  uint8_t buf[4];
 1214|     32|  coap_string_t *query;
 1215|     32|  coap_block_b_t block;
 1216|     32|  coap_tick_t now;
 1217|       |
 1218|     32|  coap_lock_check_locked();
  ------------------
  |  |  638|     32|#define coap_lock_check_locked() {}
  ------------------
 1219|       |
 1220|     32|  if (r->observable && (r->dirty || r->partiallydirty)) {
  ------------------
  |  Branch (1220:7): [True: 0, False: 32]
  |  Branch (1220:25): [True: 0, False: 0]
  |  Branch (1220:37): [True: 0, False: 0]
  ------------------
 1221|      0|    if (r->list_being_traversed)
  ------------------
  |  Branch (1221:9): [True: 0, False: 0]
  ------------------
 1222|      0|      return;
 1223|      0|    r->list_being_traversed = 1;
 1224|       |
 1225|      0|    coap_resource_reference_lkd(r);
 1226|       |
 1227|      0|    r->partiallydirty = 0;
 1228|       |
 1229|       |    /*
 1230|       |     * Any subscription (not just the one being notified) may get deleted
 1231|       |     * in the callback, by another running thread when executing the
 1232|       |     * callback, or when sending a response (e.g. the session fails and all
 1233|       |     * of its subscriptions are deleted). So no pointer into the list is kept
 1234|       |     * over a notification: the next subscription to visit is looked up again
 1235|       |     * from the head of the list each time.
 1236|       |     */
 1237|      0|    LL_FOREACH(r->subscribers, obs) {
  ------------------
  |  |  419|      0|    LL_FOREACH2(head,el,next)
  |  |  ------------------
  |  |  |  |  422|      0|    for ((el) = (head); el; (el) = (el)->next)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (422:25): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1238|      0|      obs->to_visit = 1;
 1239|      0|    }
 1240|      0|    for (;;) {
 1241|      0|      coap_session_t *obs_session;
 1242|      0|      coap_pdu_t *obs_pdu;
 1243|      0|      coap_mid_t mid = COAP_INVALID_MID;
  ------------------
  |  |  198|      0|#define COAP_INVALID_MID -1
  ------------------
 1244|       |
 1245|      0|      LL_FOREACH(r->subscribers, obs) {
  ------------------
  |  |  419|      0|    LL_FOREACH2(head,el,next)
  |  |  ------------------
  |  |  |  |  422|      0|    for ((el) = (head); el; (el) = (el)->next)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (422:25): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1246|      0|        if (obs->to_visit)
  ------------------
  |  Branch (1246:13): [True: 0, False: 0]
  ------------------
 1247|      0|          break;
 1248|      0|      }
 1249|      0|      if (obs == NULL)
  ------------------
  |  Branch (1249:11): [True: 0, False: 0]
  ------------------
 1250|      0|        break;
 1251|      0|      obs->to_visit = 0;
 1252|       |
 1253|      0|      if ((r->dirty == 0 && obs->dirty == 0) || obs->session->is_rate_limiting) {
  ------------------
  |  Branch (1253:12): [True: 0, False: 0]
  |  Branch (1253:29): [True: 0, False: 0]
  |  Branch (1253:49): [True: 0, False: 0]
  ------------------
 1254|       |        /*
 1255|       |         * running this resource due to partiallydirty, but this observation's
 1256|       |         * notification was already enqueued
 1257|       |         */
 1258|      0|        context->observe_pending = 1;
 1259|      0|        continue;
 1260|      0|      }
 1261|       |
 1262|       |      /*
 1263|       |       * obs may get deleted in the callback, or by another running
 1264|       |       * thread when executing the callback or when sending a response.
 1265|       |       */
 1266|      0|      obs_session = obs->session;
 1267|      0|      obs_pdu = obs->pdu;
 1268|      0|      coap_session_hold_lkd(obs_session);
 1269|      0|      coap_pdu_reference_lkd(obs_pdu);
 1270|       |
 1271|      0|      if (obs->session->con_active >= COAP_NSTART(obs->session) &&
  ------------------
  |  |  876|      0|#define COAP_NSTART(s) ((s)->nstart)
  ------------------
  |  Branch (1271:11): [True: 0, False: 0]
  ------------------
 1272|      0|          ((r->flags & COAP_RESOURCE_FLAGS_NOTIFY_CON) ||
  ------------------
  |  |   69|      0|#define COAP_RESOURCE_FLAGS_NOTIFY_CON  0x2
  ------------------
  |  Branch (1272:12): [True: 0, False: 0]
  ------------------
 1273|      0|           (obs->non_cnt >= COAP_OBS_MAX_NON))) {
  ------------------
  |  |   39|      0|#define COAP_OBS_MAX_NON   5
  ------------------
  |  Branch (1273:12): [True: 0, False: 0]
  ------------------
 1274|       |        /* Waiting for the previous unsolicited response to finish */
 1275|      0|        goto next_one_fail;
 1276|      0|      }
 1277|      0|      coap_ticks(&now);
 1278|      0|      if (obs->session->lg_xmit && obs->session->lg_xmit->last_all_sent == 0 &&
  ------------------
  |  Branch (1278:11): [True: 0, False: 0]
  |  Branch (1278:36): [True: 0, False: 0]
  ------------------
 1279|      0|          obs->session->lg_xmit->last_obs &&
  ------------------
  |  Branch (1279:11): [True: 0, False: 0]
  ------------------
 1280|      0|          (obs->session->lg_xmit->last_obs + 2*COAP_TICKS_PER_SECOND) > now) {
  ------------------
  |  |  164|      0|#define COAP_TICKS_PER_SECOND ((coap_tick_t)(1000U))
  ------------------
  |  Branch (1280:11): [True: 0, False: 0]
  ------------------
 1281|       |        /* Waiting for the previous blocked unsolicited response to finish */
 1282|      0|        goto next_one_fail;
 1283|      0|      }
 1284|       |
 1285|       |      /* Other packets on this session may have changed the local address,
 1286|       |       * including multicast requests from the same peer and source port.
 1287|       |       * Restore it before the handler can register an async response. */
 1288|      0|      coap_address_copy(&obs_session->addr_info.local, &obs->local_if);
 1289|       |
 1290|      0|      obs->dirty = 0;
 1291|       |      /* initialize response */
 1292|      0|      response = coap_pdu_init(COAP_MESSAGE_CON, 0, 0,
 1293|      0|                               coap_session_max_pdu_size_lkd(obs->session));
 1294|      0|      if (!response) {
  ------------------
  |  Branch (1294:11): [True: 0, False: 0]
  ------------------
 1295|      0|        coap_log_debug("coap_check_notify: pdu init failed, resource stays "
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1296|      0|                       "partially dirty\n");
 1297|      0|        goto next_one_fail_no_pending;
 1298|      0|      }
 1299|       |
 1300|      0|      if (!coap_add_token(response, obs->pdu->actual_token.length,
  ------------------
  |  Branch (1300:11): [True: 0, False: 0]
  ------------------
 1301|      0|                          obs->pdu->actual_token.s)) {
 1302|      0|        coap_log_debug("coap_check_notify: cannot add token, resource stays "
  ------------------
  |  |  126|      0|#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1303|      0|                       "partially dirty\n");
 1304|      0|        coap_delete_pdu_lkd(response);
 1305|      0|        goto next_one_fail_no_pending;
 1306|      0|      }
 1307|       |
 1308|      0|      obs->pdu->mid = response->mid = coap_new_message_id_lkd(obs->session);
 1309|       |      /* A lot of the reliable code assumes type is CON */
 1310|      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]
  |  |  ------------------
  ------------------
 1311|      0|          (r->flags & COAP_RESOURCE_FLAGS_NOTIFY_CON) == 0 &&
  ------------------
  |  |   69|      0|#define COAP_RESOURCE_FLAGS_NOTIFY_CON  0x2
  ------------------
  |  Branch (1311:11): [True: 0, False: 0]
  ------------------
 1312|      0|          ((r->flags & COAP_RESOURCE_FLAGS_NOTIFY_NON_ALWAYS) ||
  ------------------
  |  |   79|      0|#define COAP_RESOURCE_FLAGS_NOTIFY_NON_ALWAYS  0x4
  ------------------
  |  Branch (1312:12): [True: 0, False: 0]
  ------------------
 1313|      0|           obs->non_cnt < COAP_OBS_MAX_NON)) {
  ------------------
  |  |   39|      0|#define COAP_OBS_MAX_NON   5
  ------------------
  |  Branch (1313:12): [True: 0, False: 0]
  ------------------
 1314|      0|        response->type = COAP_MESSAGE_NON;
 1315|      0|      } else {
 1316|      0|        response->type = COAP_MESSAGE_CON;
 1317|      0|      }
 1318|      0|      switch (deleting) {
 1319|      0|      case COAP_NOT_DELETING_RESOURCE:
  ------------------
  |  Branch (1319:7): [True: 0, False: 0]
  ------------------
 1320|       |        /* fill with observer-specific data */
 1321|      0|        coap_add_option_internal(response, COAP_OPTION_OBSERVE,
 1322|      0|                                 coap_encode_var_safe(buf, sizeof(buf),
 1323|      0|                                                      r->observe),
 1324|      0|                                 buf);
 1325|      0|        if (coap_get_block_b(obs->session, obs->pdu, COAP_OPTION_BLOCK2,
  ------------------
  |  Branch (1325:13): [True: 0, False: 0]
  ------------------
 1326|      0|                             &block)) {
 1327|       |          /* Will get updated later (e.g. M bit) if appropriate */
 1328|      0|          coap_add_option_internal(response, COAP_OPTION_BLOCK2,
 1329|      0|                                   coap_encode_var_safe(buf, sizeof(buf),
 1330|      0|                                                        ((0 << 4) |
 1331|      0|                                                         (0 << 3) |
 1332|      0|                                                         block.aszx)),
 1333|      0|                                   buf);
 1334|      0|        }
 1335|      0|#if COAP_Q_BLOCK_SUPPORT
 1336|      0|        else if (coap_get_block_b(obs->session, obs->pdu, COAP_OPTION_Q_BLOCK2,
  ------------------
  |  Branch (1336:18): [True: 0, False: 0]
  ------------------
 1337|      0|                                  &block)) {
 1338|       |          /* Will get updated later (e.g. M bit) if appropriate */
 1339|      0|          coap_add_option_internal(response, COAP_OPTION_Q_BLOCK2,
 1340|      0|                                   coap_encode_var_safe(buf, sizeof(buf),
 1341|      0|                                                        ((0 << 4) |
 1342|      0|                                                         (0 << 3) |
 1343|      0|                                                         block.szx)),
 1344|      0|                                   buf);
 1345|      0|        }
 1346|      0|#endif /* COAP_Q_BLOCK_SUPPORT */
 1347|       |
 1348|      0|        h = r->handler[obs->pdu->code - 1];
 1349|      0|        assert(h);      /* we do not allow subscriptions if no
  ------------------
  |  Branch (1349:9): [True: 0, False: 0]
  ------------------
 1350|       |                         * GET/FETCH handler is defined */
 1351|      0|        query = coap_get_query(obs->pdu);
 1352|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1353|      0|        coap_show_pdu(COAP_LOG_DEBUG, obs->pdu);
 1354|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1355|      0|                       (int)r->uri_path->length, (int)r->uri_path->length,
 1356|      0|                       r->uri_path->s);
 1357|       |
 1358|       |        /* obs may get deleted during callback (potentially by another thread) */
 1359|      0|        if (r->flags & COAP_RESOURCE_SAFE_REQUEST_HANDLER) {
  ------------------
  |  |  181|      0|#define COAP_RESOURCE_SAFE_REQUEST_HANDLER 0x4000
  ------------------
  |  Branch (1359:13): [True: 0, False: 0]
  ------------------
 1360|      0|          coap_lock_callback_release(h(r, obs->session, obs->pdu, query, response),
  ------------------
  |  |  680|      0|#define coap_lock_callback_release(func,failed) func
  ------------------
 1361|       |                                     /* context is being freed off */
 1362|      0|                                     coap_delete_string(query);
 1363|      0|                                     coap_delete_pdu_lkd(response);
 1364|      0|                                     coap_session_release_lkd(obs_session);
 1365|      0|                                     coap_pdu_release_lkd(obs_pdu);
 1366|      0|                                     r->list_being_traversed = 0;
 1367|      0|                                     coap_resource_release_lkd(r);
 1368|      0|                                     return);
 1369|      0|        } else {
 1370|      0|          coap_lock_specific_callback_release(&r->lock,
  ------------------
  |  |  692|      0|#define coap_lock_specific_callback_release(lock,func,failed) func
  ------------------
 1371|      0|                                              h(r, obs->session, obs->pdu, query, response),
 1372|       |                                              /* context is being freed off */
 1373|      0|                                              coap_delete_string(query);
 1374|      0|                                              coap_delete_pdu_lkd(response);
 1375|      0|                                              coap_session_release_lkd(obs_session);
 1376|      0|                                              coap_pdu_release_lkd(obs_pdu);
 1377|      0|                                              r->list_being_traversed = 0;
 1378|      0|                                              coap_resource_release_lkd(r);
 1379|      0|                                              return);
 1380|      0|        }
 1381|       |
 1382|       |        /* Check validity of response code */
 1383|      0|        if (!coap_check_code_class(obs_session, response)) {
  ------------------
  |  Branch (1383:13): [True: 0, False: 0]
  ------------------
 1384|      0|          coap_log_warn("handle_request: Invalid PDU response code (%d.%02d)\n",
  ------------------
  |  |  108|      0|#define coap_log_warn(...) coap_log(COAP_LOG_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |  290|      0|#define coap_log(level, ...) do { \
  |  |  |  |  291|      0|    if ((level) < (coap_get_log_level() + 1)) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (291:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  292|      0|      coap_log_impl((level), __VA_ARGS__); \
  |  |  |  |  293|      0|  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (293:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1385|      0|                        COAP_RESPONSE_CLASS(response->code),
 1386|      0|                        response->code & 0x1f);
 1387|      0|          coap_delete_string(query);
 1388|      0|          coap_delete_pdu_lkd(response);
 1389|      0|          coap_session_unhold_lkd(obs_session);
 1390|      0|          coap_pdu_release_lkd(obs_pdu);
 1391|      0|          r->list_being_traversed = 0;
 1392|      0|          coap_resource_release_lkd(r);
 1393|      0|          return;
 1394|      0|        }
 1395|       |
 1396|       |        /* Check if lg_xmit generated and update PDU code if so */
 1397|      0|        coap_check_code_lg_xmit(obs_session, obs_pdu, response, r, query);
 1398|      0|        coap_delete_string(query);
 1399|      0|        if (COAP_RESPONSE_CLASS(response->code) != 2) {
  ------------------
  |  |   99|      0|#define COAP_RESPONSE_CLASS(C) (((C) >> 5) & 0xFF)
  ------------------
  |  Branch (1399:13): [True: 0, False: 0]
  ------------------
 1400|      0|          coap_remove_option(response, COAP_OPTION_OBSERVE);
 1401|      0|        }
 1402|      0|        if (COAP_RESPONSE_CLASS(response->code) > 2) {
  ------------------
  |  |   99|      0|#define COAP_RESPONSE_CLASS(C) (((C) >> 5) & 0xFF)
  ------------------
  |  Branch (1402:13): [True: 0, False: 0]
  ------------------
 1403|      0|          coap_delete_observer(r, obs_session, &obs_pdu->actual_token);
 1404|      0|          obs = NULL;
 1405|      0|        }
 1406|      0|        break;
 1407|      0|      case COAP_DELETING_RESOURCE_ON_EXIT:
  ------------------
  |  Branch (1407:7): [True: 0, False: 0]
  ------------------
 1408|       |        /* Don't worry if it does not get there */
 1409|      0|        response->type = COAP_MESSAGE_NON;
 1410|      0|        response->code = COAP_RESPONSE_CODE(503);
  ------------------
  |  |   96|      0|#define COAP_RESPONSE_CODE(N) (((N)/100 << 5) | (N)%100)
  ------------------
 1411|      0|        coap_add_option_internal(response, COAP_OPTION_MAXAGE,
 1412|      0|                                 coap_encode_var_safe(buf, sizeof(buf),
 1413|      0|                                                      30),
 1414|      0|                                 buf);
 1415|      0|        break;
 1416|      0|      case COAP_DELETING_RESOURCE:
  ------------------
  |  Branch (1416:7): [True: 0, False: 0]
  ------------------
 1417|      0|      default:
  ------------------
  |  Branch (1417:7): [True: 0, False: 0]
  ------------------
 1418|       |        /* Don't worry if it does not get there */
 1419|      0|        response->type = COAP_MESSAGE_NON;
 1420|      0|        response->code = COAP_RESPONSE_CODE(404);
  ------------------
  |  |   96|      0|#define COAP_RESPONSE_CODE(N) (((N)/100 << 5) | (N)%100)
  ------------------
 1421|      0|        break;
 1422|      0|      }
 1423|       |
 1424|      0|      if (obs) {
  ------------------
  |  Branch (1424:11): [True: 0, False: 0]
  ------------------
 1425|      0|        coap_subscription_t *s;
 1426|       |        /*
 1427|       |         * obs may have been deleted in the callback, or by another running
 1428|       |         * thread when executing the callback.
 1429|       |         */
 1430|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1431|      0|          if (s == obs) {
  ------------------
  |  Branch (1431:15): [True: 0, False: 0]
  ------------------
 1432|      0|            break;
 1433|      0|          }
 1434|      0|        }
 1435|      0|        if (s == NULL)
  ------------------
  |  Branch (1435:13): [True: 0, False: 0]
  ------------------
 1436|      0|          obs = NULL;
 1437|      0|      }
 1438|      0|      if (obs) {
  ------------------
  |  Branch (1438:11): [True: 0, False: 0]
  ------------------
 1439|      0|        if (response->type == COAP_MESSAGE_CON ||
  ------------------
  |  Branch (1439:13): [True: 0, False: 0]
  ------------------
 1440|      0|            (r->flags & COAP_RESOURCE_FLAGS_NOTIFY_NON_ALWAYS)) {
  ------------------
  |  |   79|      0|#define COAP_RESOURCE_FLAGS_NOTIFY_NON_ALWAYS  0x4
  ------------------
  |  Branch (1440:13): [True: 0, False: 0]
  ------------------
 1441|      0|          obs->non_cnt = 0;
 1442|      0|        } else {
 1443|      0|          obs->non_cnt++;
 1444|      0|        }
 1445|       |
 1446|      0|#if COAP_Q_BLOCK_SUPPORT
 1447|      0|        if (response->code == COAP_RESPONSE_CODE(205) &&
  ------------------
  |  |   96|      0|#define COAP_RESPONSE_CODE(N) (((N)/100 << 5) | (N)%100)
  ------------------
  |  Branch (1447:13): [True: 0, False: 0]
  ------------------
 1448|      0|            coap_get_block_b(obs_session, response, COAP_OPTION_Q_BLOCK2,
  ------------------
  |  Branch (1448:13): [True: 0, False: 0]
  ------------------
 1449|      0|                             &block) &&
 1450|      0|            block.m) {
  ------------------
  |  Branch (1450:13): [True: 0, False: 0]
  ------------------
 1451|      0|          query = coap_get_query(obs_pdu);
 1452|      0|          mid = coap_send_q_block2(obs_session, r, query, obs_pdu->code,
 1453|      0|                                   block, response, 1);
 1454|      0|          coap_delete_string(query);
 1455|      0|          goto finish;
 1456|      0|        }
 1457|      0|#endif /* COAP_Q_BLOCK_SUPPORT */
 1458|      0|      }
 1459|      0|      if (response->code == COAP_EMPTY_CODE &&
  ------------------
  |  Branch (1459:11): [True: 0, False: 0]
  ------------------
 1460|      0|          (response->type == COAP_MESSAGE_NON ||
  ------------------
  |  Branch (1460:12): [True: 0, False: 0]
  ------------------
 1461|      0|           response->type == COAP_MESSAGE_CON) &&
  ------------------
  |  Branch (1461:12): [True: 0, False: 0]
  ------------------
 1462|      0|          response->actual_token.length != 0) {
  ------------------
  |  Branch (1462:11): [True: 0, False: 0]
  ------------------
 1463|       |        /*
 1464|       |         * If a resource has been updated, triggering the sending of an
 1465|       |         * observer response and the request handler does not set a response
 1466|       |         * code (a coding error condition), then this PDU must be dropped as
 1467|       |         * it is illegally formatted.
 1468|       |         */
 1469|      0|        coap_delete_pdu_lkd(response);
 1470|      0|        mid = (coap_mid_t)COAP_DROPPED_RESPONSE;
  ------------------
  |  |   92|      0|#define COAP_DROPPED_RESPONSE -2
  ------------------
 1471|      0|      } else {
 1472|      0|        mid = coap_send_internal(obs_session, response, NULL);
 1473|      0|      }
 1474|       |
 1475|      0|#if COAP_Q_BLOCK_SUPPORT
 1476|      0|finish:
 1477|      0|#endif /* COAP_Q_BLOCK_SUPPORT */
 1478|      0|      if (COAP_INVALID_MID == mid) {
  ------------------
  |  |  198|      0|#define COAP_INVALID_MID -1
  ------------------
  |  Branch (1478:11): [True: 0, False: 0]
  ------------------
 1479|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1480|      0|                       "partially dirty\n", coap_session_str(obs_session));
 1481|      0|        if (obs) {
  ------------------
  |  Branch (1481:13): [True: 0, False: 0]
  ------------------
 1482|      0|          coap_subscription_t *s;
 1483|       |          /*
 1484|       |           * obs may have been deleted in coap_send_internal() or
 1485|       |           * coap_send_q_block2().
 1486|       |           */
 1487|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1488|      0|            if (s == obs) {
  ------------------
  |  Branch (1488:17): [True: 0, False: 0]
  ------------------
 1489|      0|              break;
 1490|      0|            }
 1491|      0|          }
 1492|      0|          if (s == NULL)
  ------------------
  |  Branch (1492:15): [True: 0, False: 0]
  ------------------
 1493|      0|            obs = NULL;
 1494|      0|        }
 1495|      0|        if (obs)
  ------------------
  |  Branch (1495:13): [True: 0, False: 0]
  ------------------
 1496|      0|          obs->dirty = 1;
 1497|      0|        r->partiallydirty = 1;
 1498|      0|      }
 1499|      0|      goto cleanup;
 1500|       |
 1501|      0|next_one_fail:
 1502|      0|      context->observe_pending = 1;
 1503|      0|next_one_fail_no_pending:
 1504|      0|      r->partiallydirty = 1;
 1505|      0|      if (obs)
  ------------------
  |  Branch (1505:11): [True: 0, False: 0]
  ------------------
 1506|      0|        obs->dirty = 1;
 1507|      0|cleanup:
 1508|      0|      coap_session_unhold_lkd(obs_session);
 1509|      0|      coap_pdu_release_lkd(obs_pdu);
 1510|      0|    }
 1511|      0|    r->list_being_traversed = 0;
 1512|      0|    r->dirty = 0;
 1513|      0|    coap_resource_release_lkd(r);
 1514|       |    /* r may be no more if elsewhere coap_free_resource() has been called */
 1515|     32|  } else {
 1516|     32|    r->dirty = 0;
 1517|     32|  }
 1518|     32|}

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

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

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

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

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

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

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

