pj_crc32_init:
  151|     64|{
  152|     64|    ctx->crc_state = 0;
  153|     64|}
pj_crc32_update:
  158|     64|{
  159|     64|    pj_uint32_t crc = ctx->crc_state ^ CRC32_NEGL;
  ------------------
  |  |   14|     64|#define CRC32_NEGL  0xffffffffL
  ------------------
  160|       |
  161|     64|    for( ; (((unsigned long)(pj_ssize_t)data) & 0x03) && nbytes > 0; --nbytes) {
  ------------------
  |  Branch (161:12): [True: 0, False: 64]
  |  Branch (161:58): [True: 0, False: 0]
  ------------------
  162|      0|        crc = crc_tab[CRC32_INDEX(crc) ^ *data++] ^ CRC32_SHIFTED(crc);
  ------------------
  |  |   22|      0|#define CRC32_INDEX(c)      (c & 0xff)
  ------------------
                      crc = crc_tab[CRC32_INDEX(crc) ^ *data++] ^ CRC32_SHIFTED(crc);
  ------------------
  |  |   23|      0|#define CRC32_SHIFTED(c)    (c >> 8)
  ------------------
  163|      0|    }
  164|       |
  165|  1.10k|    while (nbytes >= 4) {
  ------------------
  |  Branch (165:12): [True: 1.03k, False: 64]
  ------------------
  166|  1.03k|        crc ^= *(const pj_uint32_t *)data;
  167|  1.03k|        crc = crc_tab[CRC32_INDEX(crc)] ^ CRC32_SHIFTED(crc);
  ------------------
  |  |   22|  1.03k|#define CRC32_INDEX(c)      (c & 0xff)
  ------------------
                      crc = crc_tab[CRC32_INDEX(crc)] ^ CRC32_SHIFTED(crc);
  ------------------
  |  |   23|  1.03k|#define CRC32_SHIFTED(c)    (c >> 8)
  ------------------
  168|  1.03k|        crc = crc_tab[CRC32_INDEX(crc)] ^ CRC32_SHIFTED(crc);
  ------------------
  |  |   22|  1.03k|#define CRC32_INDEX(c)      (c & 0xff)
  ------------------
                      crc = crc_tab[CRC32_INDEX(crc)] ^ CRC32_SHIFTED(crc);
  ------------------
  |  |   23|  1.03k|#define CRC32_SHIFTED(c)    (c >> 8)
  ------------------
  169|  1.03k|        crc = crc_tab[CRC32_INDEX(crc)] ^ CRC32_SHIFTED(crc);
  ------------------
  |  |   22|  1.03k|#define CRC32_INDEX(c)      (c & 0xff)
  ------------------
                      crc = crc_tab[CRC32_INDEX(crc)] ^ CRC32_SHIFTED(crc);
  ------------------
  |  |   23|  1.03k|#define CRC32_SHIFTED(c)    (c >> 8)
  ------------------
  170|  1.03k|        crc = crc_tab[CRC32_INDEX(crc)] ^ CRC32_SHIFTED(crc);
  ------------------
  |  |   22|  1.03k|#define CRC32_INDEX(c)      (c & 0xff)
  ------------------
                      crc = crc_tab[CRC32_INDEX(crc)] ^ CRC32_SHIFTED(crc);
  ------------------
  |  |   23|  1.03k|#define CRC32_SHIFTED(c)    (c >> 8)
  ------------------
  171|  1.03k|        nbytes -= 4;
  172|  1.03k|        data += 4;
  173|  1.03k|    }
  174|       |
  175|     64|    for (; nbytes; nbytes--) {
  ------------------
  |  Branch (175:12): [True: 0, False: 64]
  ------------------
  176|      0|        crc = crc_tab[CRC32_INDEX(crc) ^ *data++] ^ CRC32_SHIFTED(crc);
  ------------------
  |  |   22|      0|#define CRC32_INDEX(c)      (c & 0xff)
  ------------------
                      crc = crc_tab[CRC32_INDEX(crc) ^ *data++] ^ CRC32_SHIFTED(crc);
  ------------------
  |  |   23|      0|#define CRC32_SHIFTED(c)    (c >> 8)
  ------------------
  177|      0|    }
  178|       |
  179|     64|    ctx->crc_state = crc ^ CRC32_NEGL;
  ------------------
  |  |   14|     64|#define CRC32_NEGL  0xffffffffL
  ------------------
  180|       |
  181|     64|    return ctx->crc_state;
  182|     64|}
pj_crc32_final:
  185|     64|{
  186|     64|    return CRC32_SWAP(ctx->crc_state);
  ------------------
  |  |   24|     64|#define CRC32_SWAP(c)       (c)
  ------------------
  187|     64|}
pj_crc32_calc:
  235|     64|{
  236|     64|    pj_crc32_context ctx;
  237|       |
  238|     64|    pj_crc32_init(&ctx);
  239|     64|    pj_crc32_update(&ctx, data, nbytes);
  240|     64|    return pj_crc32_final(&ctx);
  241|     64|}

pj_hmac_sha1_init:
   25|  1.47k|{
   26|  1.47k|    pj_uint8_t k_ipad[64];
   27|  1.47k|    pj_uint8_t tk[20];
   28|  1.47k|    unsigned i;
   29|       |
   30|       |    /* if key is longer than 64 bytes reset it to key=SHA1(key) */
   31|  1.47k|    if (key_len > 64) {
  ------------------
  |  Branch (31:9): [True: 0, False: 1.47k]
  ------------------
   32|      0|        pj_sha1_context      tctx;
   33|       |
   34|      0|        pj_sha1_init(&tctx);
   35|      0|        pj_sha1_update(&tctx, key, key_len);
   36|      0|        pj_sha1_final(&tctx, tk);
   37|       |
   38|      0|        key = tk;
   39|      0|        key_len = 20;
   40|      0|    }
   41|       |
   42|       |    /*
   43|       |     * HMAC = H(K XOR opad, H(K XOR ipad, text))
   44|       |     */
   45|       |
   46|       |    /* start out by storing key in pads */
   47|  1.47k|    pj_bzero( k_ipad, sizeof(k_ipad));
   48|  1.47k|    pj_bzero( hctx->k_opad, sizeof(hctx->k_opad));
   49|  1.47k|    pj_memcpy( k_ipad, key, key_len);
   50|  1.47k|    pj_memcpy( hctx->k_opad, key, key_len);
   51|       |
   52|       |    /* XOR key with ipad and opad values */
   53|  95.8k|    for (i=0; i<64; i++) {
  ------------------
  |  Branch (53:15): [True: 94.3k, False: 1.47k]
  ------------------
   54|  94.3k|        k_ipad[i] ^= 0x36;
   55|  94.3k|        hctx->k_opad[i] ^= 0x5c;
   56|  94.3k|    }
   57|       |    /*
   58|       |     * perform inner SHA1
   59|       |     */
   60|  1.47k|    pj_sha1_init(&hctx->context);
   61|  1.47k|    pj_sha1_update(&hctx->context, k_ipad, 64);
   62|  1.47k|}
pj_hmac_sha1_update:
   66|  1.70k|{
   67|  1.70k|    pj_sha1_update(&hctx->context, input, input_len);
   68|  1.70k|}
pj_hmac_sha1_final:
   72|  1.47k|{
   73|  1.47k|    pj_sha1_final(&hctx->context, digest);
   74|       |
   75|       |    /*
   76|       |     * perform outer SHA1
   77|       |     */
   78|  1.47k|    pj_sha1_init(&hctx->context);
   79|  1.47k|    pj_sha1_update(&hctx->context, hctx->k_opad, 64);
   80|  1.47k|    pj_sha1_update(&hctx->context, digest, 20);
   81|  1.47k|    pj_sha1_final(&hctx->context, digest);
   82|  1.47k|}

pj_md5_init:
   58|  1.47k|{
   59|  1.47k|    ctx->buf[0] = 0x67452301;
   60|  1.47k|    ctx->buf[1] = 0xefcdab89;
   61|  1.47k|    ctx->buf[2] = 0x98badcfe;
   62|  1.47k|    ctx->buf[3] = 0x10325476;
   63|       |
   64|  1.47k|    ctx->bits[0] = 0;
   65|  1.47k|    ctx->bits[1] = 0;
   66|  1.47k|}
pj_md5_update:
   74|  7.35k|{
   75|  7.35k|    pj_uint32_t t;
   76|       |
   77|       |    /* Update bitcount */
   78|       |
   79|  7.35k|    t = ctx->bits[0];
   80|  7.35k|    if ((ctx->bits[0] = t + ((pj_uint32_t) len << 3)) < t)
  ------------------
  |  Branch (80:9): [True: 0, False: 7.35k]
  ------------------
   81|      0|        ctx->bits[1]++;         /* Carry from low to high */
   82|  7.35k|    ctx->bits[1] += len >> 29;
   83|       |
   84|  7.35k|    t = (t >> 3) & 0x3f;        /* Bytes already in shsInfo->data */
   85|       |
   86|       |    /* Handle any leading odd-sized chunks */
   87|       |
   88|  7.35k|    if (t) {
  ------------------
  |  Branch (88:9): [True: 5.88k, False: 1.47k]
  ------------------
   89|  5.88k|        unsigned char *p = (unsigned char *) ctx->in + t;
   90|       |
   91|  5.88k|        t = 64 - t;
   92|  5.88k|        if (len < t) {
  ------------------
  |  Branch (92:13): [True: 5.88k, False: 0]
  ------------------
   93|  5.88k|            pj_memcpy(p, buf, len);
   94|  5.88k|            return;
   95|  5.88k|        }
   96|      0|        pj_memcpy(p, buf, t);
   97|      0|        byteReverse(ctx->in, 16);
   98|      0|        MD5Transform(ctx->buf, (pj_uint32_t *) ctx->in);
   99|      0|        buf += t;
  100|      0|        len -= t;
  101|      0|    }
  102|       |    /* Process data in 64-byte chunks */
  103|       |
  104|  1.47k|    while (len >= 64) {
  ------------------
  |  Branch (104:12): [True: 0, False: 1.47k]
  ------------------
  105|      0|        pj_memcpy(ctx->in, buf, 64);
  106|      0|        byteReverse(ctx->in, 16);
  107|      0|        MD5Transform(ctx->buf, (pj_uint32_t *) ctx->in);
  108|      0|        buf += 64;
  109|      0|        len -= 64;
  110|      0|    }
  111|       |
  112|       |    /* Handle any remaining bytes of data. */
  113|       |
  114|  1.47k|    pj_memcpy(ctx->in, buf, len);
  115|  1.47k|}
pj_md5_final:
  122|  1.47k|{
  123|  1.47k|    unsigned count;
  124|  1.47k|    unsigned char *p;
  125|       |
  126|       |    /* Compute number of bytes mod 64 */
  127|  1.47k|    count = (ctx->bits[0] >> 3) & 0x3F;
  128|       |
  129|       |    /* Set the first char of padding to 0x80.  This is safe since there is
  130|       |       always at least one byte free */
  131|  1.47k|    p = ctx->in + count;
  132|  1.47k|    *p++ = 0x80;
  133|       |
  134|       |    /* Bytes of padding needed to make 64 bytes */
  135|  1.47k|    count = 64 - 1 - count;
  136|       |
  137|       |    /* Pad out to 56 mod 64 */
  138|  1.47k|    if (count < 8) {
  ------------------
  |  Branch (138:9): [True: 0, False: 1.47k]
  ------------------
  139|       |        /* Two lots of padding:  Pad the first block to 64 bytes */
  140|      0|        pj_bzero(p, count);
  141|      0|        byteReverse(ctx->in, 16);
  142|      0|        MD5Transform(ctx->buf, (pj_uint32_t *) ctx->in);
  143|       |
  144|       |        /* Now fill the next block with 56 bytes */
  145|      0|        pj_bzero(ctx->in, 56);
  146|  1.47k|    } else {
  147|       |        /* Pad block to 56 bytes */
  148|  1.47k|        pj_bzero(p, count - 8);
  149|  1.47k|    }
  150|  1.47k|    byteReverse(ctx->in, 14);
  151|       |
  152|       |    /* Append length in bits and transform */
  153|       |    //((pj_uint32_t *) ctx->in)[14] = ctx->bits[0];
  154|       |    //((pj_uint32_t *) ctx->in)[15] = ctx->bits[1];
  155|  1.47k|    pj_memcpy(&ctx->in[14 << 2], &ctx->bits[0], sizeof(ctx->bits[0]));
  156|  1.47k|    pj_memcpy(&ctx->in[15 << 2], &ctx->bits[1], sizeof(ctx->bits[1]));
  157|       |
  158|  1.47k|    MD5Transform(ctx->buf, (pj_uint32_t *) ctx->in);
  159|  1.47k|    byteReverse((unsigned char *) ctx->buf, 4);
  160|  1.47k|    pj_memcpy(digest, ctx->buf, 16);
  161|  1.47k|    pj_bzero(ctx, sizeof(*ctx));        /* In case it's sensitive */
  162|  1.47k|}
md5.c:MD5Transform:
  184|  1.47k|{
  185|  1.47k|    register pj_uint32_t a, b, c, d;
  186|       |
  187|  1.47k|    a = buf[0];
  188|  1.47k|    b = buf[1];
  189|  1.47k|    c = buf[2];
  190|  1.47k|    d = buf[3];
  191|       |
  192|  1.47k|    MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7);
  ------------------
  |  |  176|  1.47k|        ( w += f(x, y, z) + data,  w = w<<s | w>>(32-s),  w += x )
  |  |  ------------------
  |  |  |  |  192|  1.47k|    MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7);
  |  |  |  |  ------------------
  |  |  |  |  |  |  169|  1.47k|#define F1(x, y, z) (z ^ (x & (y ^ z)))
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  193|  1.47k|    MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12);
  ------------------
  |  |  176|  1.47k|        ( w += f(x, y, z) + data,  w = w<<s | w>>(32-s),  w += x )
  |  |  ------------------
  |  |  |  |  193|  1.47k|    MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12);
  |  |  |  |  ------------------
  |  |  |  |  |  |  169|  1.47k|#define F1(x, y, z) (z ^ (x & (y ^ z)))
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  194|  1.47k|    MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17);
  ------------------
  |  |  176|  1.47k|        ( w += f(x, y, z) + data,  w = w<<s | w>>(32-s),  w += x )
  |  |  ------------------
  |  |  |  |  194|  1.47k|    MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17);
  |  |  |  |  ------------------
  |  |  |  |  |  |  169|  1.47k|#define F1(x, y, z) (z ^ (x & (y ^ z)))
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  195|  1.47k|    MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22);
  ------------------
  |  |  176|  1.47k|        ( w += f(x, y, z) + data,  w = w<<s | w>>(32-s),  w += x )
  |  |  ------------------
  |  |  |  |  195|  1.47k|    MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22);
  |  |  |  |  ------------------
  |  |  |  |  |  |  169|  1.47k|#define F1(x, y, z) (z ^ (x & (y ^ z)))
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  196|  1.47k|    MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7);
  ------------------
  |  |  176|  1.47k|        ( w += f(x, y, z) + data,  w = w<<s | w>>(32-s),  w += x )
  |  |  ------------------
  |  |  |  |  196|  1.47k|    MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7);
  |  |  |  |  ------------------
  |  |  |  |  |  |  169|  1.47k|#define F1(x, y, z) (z ^ (x & (y ^ z)))
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  197|  1.47k|    MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12);
  ------------------
  |  |  176|  1.47k|        ( w += f(x, y, z) + data,  w = w<<s | w>>(32-s),  w += x )
  |  |  ------------------
  |  |  |  |  197|  1.47k|    MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12);
  |  |  |  |  ------------------
  |  |  |  |  |  |  169|  1.47k|#define F1(x, y, z) (z ^ (x & (y ^ z)))
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  198|  1.47k|    MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17);
  ------------------
  |  |  176|  1.47k|        ( w += f(x, y, z) + data,  w = w<<s | w>>(32-s),  w += x )
  |  |  ------------------
  |  |  |  |  198|  1.47k|    MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17);
  |  |  |  |  ------------------
  |  |  |  |  |  |  169|  1.47k|#define F1(x, y, z) (z ^ (x & (y ^ z)))
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  199|  1.47k|    MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22);
  ------------------
  |  |  176|  1.47k|        ( w += f(x, y, z) + data,  w = w<<s | w>>(32-s),  w += x )
  |  |  ------------------
  |  |  |  |  199|  1.47k|    MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22);
  |  |  |  |  ------------------
  |  |  |  |  |  |  169|  1.47k|#define F1(x, y, z) (z ^ (x & (y ^ z)))
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  200|  1.47k|    MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7);
  ------------------
  |  |  176|  1.47k|        ( w += f(x, y, z) + data,  w = w<<s | w>>(32-s),  w += x )
  |  |  ------------------
  |  |  |  |  200|  1.47k|    MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7);
  |  |  |  |  ------------------
  |  |  |  |  |  |  169|  1.47k|#define F1(x, y, z) (z ^ (x & (y ^ z)))
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  201|  1.47k|    MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12);
  ------------------
  |  |  176|  1.47k|        ( w += f(x, y, z) + data,  w = w<<s | w>>(32-s),  w += x )
  |  |  ------------------
  |  |  |  |  201|  1.47k|    MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12);
  |  |  |  |  ------------------
  |  |  |  |  |  |  169|  1.47k|#define F1(x, y, z) (z ^ (x & (y ^ z)))
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  202|  1.47k|    MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17);
  ------------------
  |  |  176|  1.47k|        ( w += f(x, y, z) + data,  w = w<<s | w>>(32-s),  w += x )
  |  |  ------------------
  |  |  |  |  202|  1.47k|    MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17);
  |  |  |  |  ------------------
  |  |  |  |  |  |  169|  1.47k|#define F1(x, y, z) (z ^ (x & (y ^ z)))
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  203|  1.47k|    MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22);
  ------------------
  |  |  176|  1.47k|        ( w += f(x, y, z) + data,  w = w<<s | w>>(32-s),  w += x )
  |  |  ------------------
  |  |  |  |  203|  1.47k|    MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22);
  |  |  |  |  ------------------
  |  |  |  |  |  |  169|  1.47k|#define F1(x, y, z) (z ^ (x & (y ^ z)))
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  204|  1.47k|    MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7);
  ------------------
  |  |  176|  1.47k|        ( w += f(x, y, z) + data,  w = w<<s | w>>(32-s),  w += x )
  |  |  ------------------
  |  |  |  |  204|  1.47k|    MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7);
  |  |  |  |  ------------------
  |  |  |  |  |  |  169|  1.47k|#define F1(x, y, z) (z ^ (x & (y ^ z)))
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  205|  1.47k|    MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12);
  ------------------
  |  |  176|  1.47k|        ( w += f(x, y, z) + data,  w = w<<s | w>>(32-s),  w += x )
  |  |  ------------------
  |  |  |  |  205|  1.47k|    MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12);
  |  |  |  |  ------------------
  |  |  |  |  |  |  169|  1.47k|#define F1(x, y, z) (z ^ (x & (y ^ z)))
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  206|  1.47k|    MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17);
  ------------------
  |  |  176|  1.47k|        ( w += f(x, y, z) + data,  w = w<<s | w>>(32-s),  w += x )
  |  |  ------------------
  |  |  |  |  206|  1.47k|    MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17);
  |  |  |  |  ------------------
  |  |  |  |  |  |  169|  1.47k|#define F1(x, y, z) (z ^ (x & (y ^ z)))
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  207|  1.47k|    MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22);
  ------------------
  |  |  176|  1.47k|        ( w += f(x, y, z) + data,  w = w<<s | w>>(32-s),  w += x )
  |  |  ------------------
  |  |  |  |  207|  1.47k|    MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22);
  |  |  |  |  ------------------
  |  |  |  |  |  |  169|  1.47k|#define F1(x, y, z) (z ^ (x & (y ^ z)))
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  208|       |
  209|  1.47k|    MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5);
  ------------------
  |  |  176|  1.47k|        ( w += f(x, y, z) + data,  w = w<<s | w>>(32-s),  w += x )
  |  |  ------------------
  |  |  |  |  209|  1.47k|    MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5);
  |  |  |  |  ------------------
  |  |  |  |  |  |  170|  1.47k|#define F2(x, y, z) F1(z, x, y)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  169|  1.47k|#define F1(x, y, z) (z ^ (x & (y ^ z)))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  210|  1.47k|    MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9);
  ------------------
  |  |  176|  1.47k|        ( w += f(x, y, z) + data,  w = w<<s | w>>(32-s),  w += x )
  |  |  ------------------
  |  |  |  |  210|  1.47k|    MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9);
  |  |  |  |  ------------------
  |  |  |  |  |  |  170|  1.47k|#define F2(x, y, z) F1(z, x, y)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  169|  1.47k|#define F1(x, y, z) (z ^ (x & (y ^ z)))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  211|  1.47k|    MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14);
  ------------------
  |  |  176|  1.47k|        ( w += f(x, y, z) + data,  w = w<<s | w>>(32-s),  w += x )
  |  |  ------------------
  |  |  |  |  211|  1.47k|    MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14);
  |  |  |  |  ------------------
  |  |  |  |  |  |  170|  1.47k|#define F2(x, y, z) F1(z, x, y)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  169|  1.47k|#define F1(x, y, z) (z ^ (x & (y ^ z)))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  212|  1.47k|    MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20);
  ------------------
  |  |  176|  1.47k|        ( w += f(x, y, z) + data,  w = w<<s | w>>(32-s),  w += x )
  |  |  ------------------
  |  |  |  |  212|  1.47k|    MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20);
  |  |  |  |  ------------------
  |  |  |  |  |  |  170|  1.47k|#define F2(x, y, z) F1(z, x, y)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  169|  1.47k|#define F1(x, y, z) (z ^ (x & (y ^ z)))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  213|  1.47k|    MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5);
  ------------------
  |  |  176|  1.47k|        ( w += f(x, y, z) + data,  w = w<<s | w>>(32-s),  w += x )
  |  |  ------------------
  |  |  |  |  213|  1.47k|    MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5);
  |  |  |  |  ------------------
  |  |  |  |  |  |  170|  1.47k|#define F2(x, y, z) F1(z, x, y)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  169|  1.47k|#define F1(x, y, z) (z ^ (x & (y ^ z)))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  214|  1.47k|    MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9);
  ------------------
  |  |  176|  1.47k|        ( w += f(x, y, z) + data,  w = w<<s | w>>(32-s),  w += x )
  |  |  ------------------
  |  |  |  |  214|  1.47k|    MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9);
  |  |  |  |  ------------------
  |  |  |  |  |  |  170|  1.47k|#define F2(x, y, z) F1(z, x, y)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  169|  1.47k|#define F1(x, y, z) (z ^ (x & (y ^ z)))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  215|  1.47k|    MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14);
  ------------------
  |  |  176|  1.47k|        ( w += f(x, y, z) + data,  w = w<<s | w>>(32-s),  w += x )
  |  |  ------------------
  |  |  |  |  215|  1.47k|    MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14);
  |  |  |  |  ------------------
  |  |  |  |  |  |  170|  1.47k|#define F2(x, y, z) F1(z, x, y)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  169|  1.47k|#define F1(x, y, z) (z ^ (x & (y ^ z)))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  216|  1.47k|    MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20);
  ------------------
  |  |  176|  1.47k|        ( w += f(x, y, z) + data,  w = w<<s | w>>(32-s),  w += x )
  |  |  ------------------
  |  |  |  |  216|  1.47k|    MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20);
  |  |  |  |  ------------------
  |  |  |  |  |  |  170|  1.47k|#define F2(x, y, z) F1(z, x, y)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  169|  1.47k|#define F1(x, y, z) (z ^ (x & (y ^ z)))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  217|  1.47k|    MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5);
  ------------------
  |  |  176|  1.47k|        ( w += f(x, y, z) + data,  w = w<<s | w>>(32-s),  w += x )
  |  |  ------------------
  |  |  |  |  217|  1.47k|    MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5);
  |  |  |  |  ------------------
  |  |  |  |  |  |  170|  1.47k|#define F2(x, y, z) F1(z, x, y)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  169|  1.47k|#define F1(x, y, z) (z ^ (x & (y ^ z)))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  218|  1.47k|    MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9);
  ------------------
  |  |  176|  1.47k|        ( w += f(x, y, z) + data,  w = w<<s | w>>(32-s),  w += x )
  |  |  ------------------
  |  |  |  |  218|  1.47k|    MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9);
  |  |  |  |  ------------------
  |  |  |  |  |  |  170|  1.47k|#define F2(x, y, z) F1(z, x, y)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  169|  1.47k|#define F1(x, y, z) (z ^ (x & (y ^ z)))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  219|  1.47k|    MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14);
  ------------------
  |  |  176|  1.47k|        ( w += f(x, y, z) + data,  w = w<<s | w>>(32-s),  w += x )
  |  |  ------------------
  |  |  |  |  219|  1.47k|    MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14);
  |  |  |  |  ------------------
  |  |  |  |  |  |  170|  1.47k|#define F2(x, y, z) F1(z, x, y)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  169|  1.47k|#define F1(x, y, z) (z ^ (x & (y ^ z)))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  220|  1.47k|    MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20);
  ------------------
  |  |  176|  1.47k|        ( w += f(x, y, z) + data,  w = w<<s | w>>(32-s),  w += x )
  |  |  ------------------
  |  |  |  |  220|  1.47k|    MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20);
  |  |  |  |  ------------------
  |  |  |  |  |  |  170|  1.47k|#define F2(x, y, z) F1(z, x, y)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  169|  1.47k|#define F1(x, y, z) (z ^ (x & (y ^ z)))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  221|  1.47k|    MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5);
  ------------------
  |  |  176|  1.47k|        ( w += f(x, y, z) + data,  w = w<<s | w>>(32-s),  w += x )
  |  |  ------------------
  |  |  |  |  221|  1.47k|    MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5);
  |  |  |  |  ------------------
  |  |  |  |  |  |  170|  1.47k|#define F2(x, y, z) F1(z, x, y)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  169|  1.47k|#define F1(x, y, z) (z ^ (x & (y ^ z)))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  222|  1.47k|    MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9);
  ------------------
  |  |  176|  1.47k|        ( w += f(x, y, z) + data,  w = w<<s | w>>(32-s),  w += x )
  |  |  ------------------
  |  |  |  |  222|  1.47k|    MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9);
  |  |  |  |  ------------------
  |  |  |  |  |  |  170|  1.47k|#define F2(x, y, z) F1(z, x, y)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  169|  1.47k|#define F1(x, y, z) (z ^ (x & (y ^ z)))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  223|  1.47k|    MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14);
  ------------------
  |  |  176|  1.47k|        ( w += f(x, y, z) + data,  w = w<<s | w>>(32-s),  w += x )
  |  |  ------------------
  |  |  |  |  223|  1.47k|    MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14);
  |  |  |  |  ------------------
  |  |  |  |  |  |  170|  1.47k|#define F2(x, y, z) F1(z, x, y)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  169|  1.47k|#define F1(x, y, z) (z ^ (x & (y ^ z)))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  224|  1.47k|    MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20);
  ------------------
  |  |  176|  1.47k|        ( w += f(x, y, z) + data,  w = w<<s | w>>(32-s),  w += x )
  |  |  ------------------
  |  |  |  |  224|  1.47k|    MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20);
  |  |  |  |  ------------------
  |  |  |  |  |  |  170|  1.47k|#define F2(x, y, z) F1(z, x, y)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  169|  1.47k|#define F1(x, y, z) (z ^ (x & (y ^ z)))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  225|       |
  226|  1.47k|    MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4);
  ------------------
  |  |  176|  1.47k|        ( w += f(x, y, z) + data,  w = w<<s | w>>(32-s),  w += x )
  |  |  ------------------
  |  |  |  |  226|  1.47k|    MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4);
  |  |  |  |  ------------------
  |  |  |  |  |  |  171|  1.47k|#define F3(x, y, z) (x ^ y ^ z)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  227|  1.47k|    MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11);
  ------------------
  |  |  176|  1.47k|        ( w += f(x, y, z) + data,  w = w<<s | w>>(32-s),  w += x )
  |  |  ------------------
  |  |  |  |  227|  1.47k|    MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11);
  |  |  |  |  ------------------
  |  |  |  |  |  |  171|  1.47k|#define F3(x, y, z) (x ^ y ^ z)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  228|  1.47k|    MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16);
  ------------------
  |  |  176|  1.47k|        ( w += f(x, y, z) + data,  w = w<<s | w>>(32-s),  w += x )
  |  |  ------------------
  |  |  |  |  228|  1.47k|    MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16);
  |  |  |  |  ------------------
  |  |  |  |  |  |  171|  1.47k|#define F3(x, y, z) (x ^ y ^ z)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  229|  1.47k|    MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23);
  ------------------
  |  |  176|  1.47k|        ( w += f(x, y, z) + data,  w = w<<s | w>>(32-s),  w += x )
  |  |  ------------------
  |  |  |  |  229|  1.47k|    MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23);
  |  |  |  |  ------------------
  |  |  |  |  |  |  171|  1.47k|#define F3(x, y, z) (x ^ y ^ z)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  230|  1.47k|    MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4);
  ------------------
  |  |  176|  1.47k|        ( w += f(x, y, z) + data,  w = w<<s | w>>(32-s),  w += x )
  |  |  ------------------
  |  |  |  |  230|  1.47k|    MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4);
  |  |  |  |  ------------------
  |  |  |  |  |  |  171|  1.47k|#define F3(x, y, z) (x ^ y ^ z)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  231|  1.47k|    MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11);
  ------------------
  |  |  176|  1.47k|        ( w += f(x, y, z) + data,  w = w<<s | w>>(32-s),  w += x )
  |  |  ------------------
  |  |  |  |  231|  1.47k|    MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11);
  |  |  |  |  ------------------
  |  |  |  |  |  |  171|  1.47k|#define F3(x, y, z) (x ^ y ^ z)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  232|  1.47k|    MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16);
  ------------------
  |  |  176|  1.47k|        ( w += f(x, y, z) + data,  w = w<<s | w>>(32-s),  w += x )
  |  |  ------------------
  |  |  |  |  232|  1.47k|    MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16);
  |  |  |  |  ------------------
  |  |  |  |  |  |  171|  1.47k|#define F3(x, y, z) (x ^ y ^ z)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  233|  1.47k|    MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23);
  ------------------
  |  |  176|  1.47k|        ( w += f(x, y, z) + data,  w = w<<s | w>>(32-s),  w += x )
  |  |  ------------------
  |  |  |  |  233|  1.47k|    MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23);
  |  |  |  |  ------------------
  |  |  |  |  |  |  171|  1.47k|#define F3(x, y, z) (x ^ y ^ z)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  234|  1.47k|    MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4);
  ------------------
  |  |  176|  1.47k|        ( w += f(x, y, z) + data,  w = w<<s | w>>(32-s),  w += x )
  |  |  ------------------
  |  |  |  |  234|  1.47k|    MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4);
  |  |  |  |  ------------------
  |  |  |  |  |  |  171|  1.47k|#define F3(x, y, z) (x ^ y ^ z)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  235|  1.47k|    MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11);
  ------------------
  |  |  176|  1.47k|        ( w += f(x, y, z) + data,  w = w<<s | w>>(32-s),  w += x )
  |  |  ------------------
  |  |  |  |  235|  1.47k|    MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11);
  |  |  |  |  ------------------
  |  |  |  |  |  |  171|  1.47k|#define F3(x, y, z) (x ^ y ^ z)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  236|  1.47k|    MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16);
  ------------------
  |  |  176|  1.47k|        ( w += f(x, y, z) + data,  w = w<<s | w>>(32-s),  w += x )
  |  |  ------------------
  |  |  |  |  236|  1.47k|    MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16);
  |  |  |  |  ------------------
  |  |  |  |  |  |  171|  1.47k|#define F3(x, y, z) (x ^ y ^ z)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  237|  1.47k|    MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23);
  ------------------
  |  |  176|  1.47k|        ( w += f(x, y, z) + data,  w = w<<s | w>>(32-s),  w += x )
  |  |  ------------------
  |  |  |  |  237|  1.47k|    MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23);
  |  |  |  |  ------------------
  |  |  |  |  |  |  171|  1.47k|#define F3(x, y, z) (x ^ y ^ z)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  238|  1.47k|    MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4);
  ------------------
  |  |  176|  1.47k|        ( w += f(x, y, z) + data,  w = w<<s | w>>(32-s),  w += x )
  |  |  ------------------
  |  |  |  |  238|  1.47k|    MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4);
  |  |  |  |  ------------------
  |  |  |  |  |  |  171|  1.47k|#define F3(x, y, z) (x ^ y ^ z)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  239|  1.47k|    MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11);
  ------------------
  |  |  176|  1.47k|        ( w += f(x, y, z) + data,  w = w<<s | w>>(32-s),  w += x )
  |  |  ------------------
  |  |  |  |  239|  1.47k|    MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11);
  |  |  |  |  ------------------
  |  |  |  |  |  |  171|  1.47k|#define F3(x, y, z) (x ^ y ^ z)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  240|  1.47k|    MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16);
  ------------------
  |  |  176|  1.47k|        ( w += f(x, y, z) + data,  w = w<<s | w>>(32-s),  w += x )
  |  |  ------------------
  |  |  |  |  240|  1.47k|    MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16);
  |  |  |  |  ------------------
  |  |  |  |  |  |  171|  1.47k|#define F3(x, y, z) (x ^ y ^ z)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  241|  1.47k|    MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23);
  ------------------
  |  |  176|  1.47k|        ( w += f(x, y, z) + data,  w = w<<s | w>>(32-s),  w += x )
  |  |  ------------------
  |  |  |  |  241|  1.47k|    MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23);
  |  |  |  |  ------------------
  |  |  |  |  |  |  171|  1.47k|#define F3(x, y, z) (x ^ y ^ z)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  242|       |
  243|  1.47k|    MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6);
  ------------------
  |  |  176|  1.47k|        ( w += f(x, y, z) + data,  w = w<<s | w>>(32-s),  w += x )
  |  |  ------------------
  |  |  |  |  243|  1.47k|    MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6);
  |  |  |  |  ------------------
  |  |  |  |  |  |  172|  1.47k|#define F4(x, y, z) (y ^ (x | ~z))
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  244|  1.47k|    MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10);
  ------------------
  |  |  176|  1.47k|        ( w += f(x, y, z) + data,  w = w<<s | w>>(32-s),  w += x )
  |  |  ------------------
  |  |  |  |  244|  1.47k|    MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10);
  |  |  |  |  ------------------
  |  |  |  |  |  |  172|  1.47k|#define F4(x, y, z) (y ^ (x | ~z))
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  245|  1.47k|    MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15);
  ------------------
  |  |  176|  1.47k|        ( w += f(x, y, z) + data,  w = w<<s | w>>(32-s),  w += x )
  |  |  ------------------
  |  |  |  |  245|  1.47k|    MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15);
  |  |  |  |  ------------------
  |  |  |  |  |  |  172|  1.47k|#define F4(x, y, z) (y ^ (x | ~z))
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  246|  1.47k|    MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21);
  ------------------
  |  |  176|  1.47k|        ( w += f(x, y, z) + data,  w = w<<s | w>>(32-s),  w += x )
  |  |  ------------------
  |  |  |  |  246|  1.47k|    MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21);
  |  |  |  |  ------------------
  |  |  |  |  |  |  172|  1.47k|#define F4(x, y, z) (y ^ (x | ~z))
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  247|  1.47k|    MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6);
  ------------------
  |  |  176|  1.47k|        ( w += f(x, y, z) + data,  w = w<<s | w>>(32-s),  w += x )
  |  |  ------------------
  |  |  |  |  247|  1.47k|    MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6);
  |  |  |  |  ------------------
  |  |  |  |  |  |  172|  1.47k|#define F4(x, y, z) (y ^ (x | ~z))
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  248|  1.47k|    MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10);
  ------------------
  |  |  176|  1.47k|        ( w += f(x, y, z) + data,  w = w<<s | w>>(32-s),  w += x )
  |  |  ------------------
  |  |  |  |  248|  1.47k|    MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10);
  |  |  |  |  ------------------
  |  |  |  |  |  |  172|  1.47k|#define F4(x, y, z) (y ^ (x | ~z))
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  249|  1.47k|    MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15);
  ------------------
  |  |  176|  1.47k|        ( w += f(x, y, z) + data,  w = w<<s | w>>(32-s),  w += x )
  |  |  ------------------
  |  |  |  |  249|  1.47k|    MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15);
  |  |  |  |  ------------------
  |  |  |  |  |  |  172|  1.47k|#define F4(x, y, z) (y ^ (x | ~z))
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  250|  1.47k|    MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21);
  ------------------
  |  |  176|  1.47k|        ( w += f(x, y, z) + data,  w = w<<s | w>>(32-s),  w += x )
  |  |  ------------------
  |  |  |  |  250|  1.47k|    MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21);
  |  |  |  |  ------------------
  |  |  |  |  |  |  172|  1.47k|#define F4(x, y, z) (y ^ (x | ~z))
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  251|  1.47k|    MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6);
  ------------------
  |  |  176|  1.47k|        ( w += f(x, y, z) + data,  w = w<<s | w>>(32-s),  w += x )
  |  |  ------------------
  |  |  |  |  251|  1.47k|    MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6);
  |  |  |  |  ------------------
  |  |  |  |  |  |  172|  1.47k|#define F4(x, y, z) (y ^ (x | ~z))
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  252|  1.47k|    MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10);
  ------------------
  |  |  176|  1.47k|        ( w += f(x, y, z) + data,  w = w<<s | w>>(32-s),  w += x )
  |  |  ------------------
  |  |  |  |  252|  1.47k|    MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10);
  |  |  |  |  ------------------
  |  |  |  |  |  |  172|  1.47k|#define F4(x, y, z) (y ^ (x | ~z))
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  253|  1.47k|    MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15);
  ------------------
  |  |  176|  1.47k|        ( w += f(x, y, z) + data,  w = w<<s | w>>(32-s),  w += x )
  |  |  ------------------
  |  |  |  |  253|  1.47k|    MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15);
  |  |  |  |  ------------------
  |  |  |  |  |  |  172|  1.47k|#define F4(x, y, z) (y ^ (x | ~z))
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  254|  1.47k|    MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21);
  ------------------
  |  |  176|  1.47k|        ( w += f(x, y, z) + data,  w = w<<s | w>>(32-s),  w += x )
  |  |  ------------------
  |  |  |  |  254|  1.47k|    MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21);
  |  |  |  |  ------------------
  |  |  |  |  |  |  172|  1.47k|#define F4(x, y, z) (y ^ (x | ~z))
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  255|  1.47k|    MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6);
  ------------------
  |  |  176|  1.47k|        ( w += f(x, y, z) + data,  w = w<<s | w>>(32-s),  w += x )
  |  |  ------------------
  |  |  |  |  255|  1.47k|    MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6);
  |  |  |  |  ------------------
  |  |  |  |  |  |  172|  1.47k|#define F4(x, y, z) (y ^ (x | ~z))
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  256|  1.47k|    MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10);
  ------------------
  |  |  176|  1.47k|        ( w += f(x, y, z) + data,  w = w<<s | w>>(32-s),  w += x )
  |  |  ------------------
  |  |  |  |  256|  1.47k|    MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10);
  |  |  |  |  ------------------
  |  |  |  |  |  |  172|  1.47k|#define F4(x, y, z) (y ^ (x | ~z))
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  257|  1.47k|    MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15);
  ------------------
  |  |  176|  1.47k|        ( w += f(x, y, z) + data,  w = w<<s | w>>(32-s),  w += x )
  |  |  ------------------
  |  |  |  |  257|  1.47k|    MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15);
  |  |  |  |  ------------------
  |  |  |  |  |  |  172|  1.47k|#define F4(x, y, z) (y ^ (x | ~z))
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  258|  1.47k|    MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21);
  ------------------
  |  |  176|  1.47k|        ( w += f(x, y, z) + data,  w = w<<s | w>>(32-s),  w += x )
  |  |  ------------------
  |  |  |  |  258|  1.47k|    MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21);
  |  |  |  |  ------------------
  |  |  |  |  |  |  172|  1.47k|#define F4(x, y, z) (y ^ (x | ~z))
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  259|       |
  260|  1.47k|    buf[0] += a;
  261|  1.47k|    buf[1] += b;
  262|  1.47k|    buf[2] += c;
  263|  1.47k|    buf[3] += d;
  264|  1.47k|}

pj_sha1_init:
  193|  2.94k|{
  194|       |    /* SHA1 initialization constants */
  195|  2.94k|    context->state[0] = 0x67452301;
  196|  2.94k|    context->state[1] = 0xEFCDAB89;
  197|  2.94k|    context->state[2] = 0x98BADCFE;
  198|  2.94k|    context->state[3] = 0x10325476;
  199|  2.94k|    context->state[4] = 0xC3D2E1F0;
  200|  2.94k|    context->count[0] = context->count[1] = 0;
  201|  2.94k|}
pj_sha1_update:
  207|   117k|{
  208|   117k|    pj_size_t i, j;
  209|       |
  210|   117k|    j = (context->count[0] >> 3) & 63;
  211|   117k|    if ((context->count[0] += (pj_uint32_t)len << 3) < (len << 3)) 
  ------------------
  |  Branch (211:9): [True: 0, False: 117k]
  ------------------
  212|      0|        context->count[1]++;
  213|   117k|    context->count[1] += ((pj_uint32_t)len >> 29);
  214|   117k|    if ((j + len) > 63) {
  ------------------
  |  Branch (214:9): [True: 7.45k, False: 109k]
  ------------------
  215|  7.45k|        pj_memcpy(&context->buffer[j], data, (i = 64-j));
  216|  7.45k|        SHA1_Transform(context->state, context->buffer);
  217|  8.39k|        for ( ; i + 63 < len; i += 64) {
  ------------------
  |  Branch (217:17): [True: 944, False: 7.45k]
  ------------------
  218|    944|            pj_uint8_t tmp[64];
  219|    944|            pj_memcpy(tmp, data + i, 64);
  220|    944|            SHA1_Transform(context->state, tmp);
  221|    944|        }
  222|  7.45k|        j = 0;
  223|  7.45k|    }
  224|   109k|    else i = 0;
  225|   117k|    pj_memcpy(&context->buffer[j], &data[i], len - i);
  226|       |
  227|   117k|}
pj_sha1_final:
  233|  2.94k|{
  234|  2.94k|    pj_uint32_t i;
  235|  2.94k|    pj_uint8_t  finalcount[8];
  236|       |
  237|  26.5k|    for (i = 0; i < 8; i++) {
  ------------------
  |  Branch (237:17): [True: 23.5k, False: 2.94k]
  ------------------
  238|  23.5k|        finalcount[i] = (unsigned char)((context->count[(i >= 4 ? 0 : 1)]
  ------------------
  |  Branch (238:58): [True: 11.7k, False: 11.7k]
  ------------------
  239|  23.5k|         >> ((3-(i & 3)) * 8) ) & 255);  /* Endian independent */
  240|  23.5k|    }
  241|  2.94k|    pj_sha1_update(context, (pj_uint8_t *)"\200", 1);
  242|   108k|    while ((context->count[0] & 504) != 448) {
  ------------------
  |  Branch (242:12): [True: 105k, False: 2.94k]
  ------------------
  243|   105k|        pj_sha1_update(context, (pj_uint8_t *)"\0", 1);
  244|   105k|    }
  245|  2.94k|    pj_sha1_update(context, finalcount, 8);  /* Should cause a SHA1_Transform() */
  246|  61.9k|    for (i = 0; i < PJ_SHA1_DIGEST_SIZE; i++) {
  ------------------
  |  |   46|  61.9k|#define PJ_SHA1_DIGEST_SIZE     20
  ------------------
  |  Branch (246:17): [True: 58.9k, False: 2.94k]
  ------------------
  247|  58.9k|        digest[i] = (pj_uint8_t)
  248|  58.9k|         ((context->state[i>>2] >> ((3-(i & 3)) * 8) ) & 255);
  249|  58.9k|    }
  250|       |    
  251|       |    /* Wipe variables */
  252|  2.94k|    i = 0;
  253|  2.94k|    pj_memset(context->buffer, 0, 64);
  254|  2.94k|    pj_memset(context->state, 0, 20);
  255|  2.94k|    pj_memset(context->count, 0, 8);
  256|  2.94k|    pj_memset(finalcount, 0, 8);        /* SWR */
  257|       |
  258|       |#ifdef SHA1HANDSOFF  /* make SHA1Transform overwrite its own static vars */
  259|       |    SHA1_Transform(context->state, context->buffer);
  260|       |#endif
  261|  2.94k|}
sha1.c:SHA1_Transform:
  134|  8.39k|{
  135|  8.39k|    pj_uint32_t a, b, c, d, e;
  136|  8.39k|    typedef union {
  137|  8.39k|        pj_uint8_t c[64];
  138|  8.39k|        pj_uint32_t l[16];
  139|  8.39k|    } CHAR64LONG16;
  140|  8.39k|    CHAR64LONG16* block;
  141|       |
  142|       |#ifdef SHA1HANDSOFF
  143|       |    static pj_uint8_t workspace[64];
  144|       |    block = (CHAR64LONG16*)workspace;
  145|       |    pj_memcpy(block, buffer, 64);
  146|       |#else
  147|  8.39k|    block = (CHAR64LONG16*)buffer;
  148|  8.39k|#endif
  149|       |
  150|       |    /* Copy context->state[] to working vars */
  151|  8.39k|    a = state[0];
  152|  8.39k|    b = state[1];
  153|  8.39k|    c = state[2];
  154|  8.39k|    d = state[3];
  155|  8.39k|    e = state[4];
  156|       |
  157|       |    /* 4 rounds of 20 operations each. Loop unrolled. */
  158|  8.39k|    R0(a,b,c,d,e, 0); R0(e,a,b,c,d, 1); R0(d,e,a,b,c, 2); R0(c,d,e,a,b, 3);
  ------------------
  |  |  125|  8.39k|#define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  118|  8.39k|#define blk0(i) (block->l[i] = (rol(block->l[i],24)&0xFF00FF00) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  |  |  119|  8.39k|    |(rol(block->l[i],8)&0x00FF00FF))
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  |  |               #define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  ------------------
                  R0(a,b,c,d,e, 0); R0(e,a,b,c,d, 1); R0(d,e,a,b,c, 2); R0(c,d,e,a,b, 3);
  ------------------
  |  |  125|  8.39k|#define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  118|  8.39k|#define blk0(i) (block->l[i] = (rol(block->l[i],24)&0xFF00FF00) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  |  |  119|  8.39k|    |(rol(block->l[i],8)&0x00FF00FF))
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  |  |               #define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  ------------------
                  R0(a,b,c,d,e, 0); R0(e,a,b,c,d, 1); R0(d,e,a,b,c, 2); R0(c,d,e,a,b, 3);
  ------------------
  |  |  125|  8.39k|#define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  118|  8.39k|#define blk0(i) (block->l[i] = (rol(block->l[i],24)&0xFF00FF00) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  |  |  119|  8.39k|    |(rol(block->l[i],8)&0x00FF00FF))
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  |  |               #define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  ------------------
                  R0(a,b,c,d,e, 0); R0(e,a,b,c,d, 1); R0(d,e,a,b,c, 2); R0(c,d,e,a,b, 3);
  ------------------
  |  |  125|  8.39k|#define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  118|  8.39k|#define blk0(i) (block->l[i] = (rol(block->l[i],24)&0xFF00FF00) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  |  |  119|  8.39k|    |(rol(block->l[i],8)&0x00FF00FF))
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  |  |               #define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  ------------------
  159|  8.39k|    R0(b,c,d,e,a, 4); R0(a,b,c,d,e, 5); R0(e,a,b,c,d, 6); R0(d,e,a,b,c, 7);
  ------------------
  |  |  125|  8.39k|#define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  118|  8.39k|#define blk0(i) (block->l[i] = (rol(block->l[i],24)&0xFF00FF00) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  |  |  119|  8.39k|    |(rol(block->l[i],8)&0x00FF00FF))
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  |  |               #define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  ------------------
                  R0(b,c,d,e,a, 4); R0(a,b,c,d,e, 5); R0(e,a,b,c,d, 6); R0(d,e,a,b,c, 7);
  ------------------
  |  |  125|  8.39k|#define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  118|  8.39k|#define blk0(i) (block->l[i] = (rol(block->l[i],24)&0xFF00FF00) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  |  |  119|  8.39k|    |(rol(block->l[i],8)&0x00FF00FF))
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  |  |               #define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  ------------------
                  R0(b,c,d,e,a, 4); R0(a,b,c,d,e, 5); R0(e,a,b,c,d, 6); R0(d,e,a,b,c, 7);
  ------------------
  |  |  125|  8.39k|#define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  118|  8.39k|#define blk0(i) (block->l[i] = (rol(block->l[i],24)&0xFF00FF00) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  |  |  119|  8.39k|    |(rol(block->l[i],8)&0x00FF00FF))
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  |  |               #define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  ------------------
                  R0(b,c,d,e,a, 4); R0(a,b,c,d,e, 5); R0(e,a,b,c,d, 6); R0(d,e,a,b,c, 7);
  ------------------
  |  |  125|  8.39k|#define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  118|  8.39k|#define blk0(i) (block->l[i] = (rol(block->l[i],24)&0xFF00FF00) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  |  |  119|  8.39k|    |(rol(block->l[i],8)&0x00FF00FF))
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  |  |               #define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  ------------------
  160|  8.39k|    R0(c,d,e,a,b, 8); R0(b,c,d,e,a, 9); R0(a,b,c,d,e,10); R0(e,a,b,c,d,11);
  ------------------
  |  |  125|  8.39k|#define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  118|  8.39k|#define blk0(i) (block->l[i] = (rol(block->l[i],24)&0xFF00FF00) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  |  |  119|  8.39k|    |(rol(block->l[i],8)&0x00FF00FF))
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  |  |               #define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  ------------------
                  R0(c,d,e,a,b, 8); R0(b,c,d,e,a, 9); R0(a,b,c,d,e,10); R0(e,a,b,c,d,11);
  ------------------
  |  |  125|  8.39k|#define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  118|  8.39k|#define blk0(i) (block->l[i] = (rol(block->l[i],24)&0xFF00FF00) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  |  |  119|  8.39k|    |(rol(block->l[i],8)&0x00FF00FF))
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  |  |               #define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  ------------------
                  R0(c,d,e,a,b, 8); R0(b,c,d,e,a, 9); R0(a,b,c,d,e,10); R0(e,a,b,c,d,11);
  ------------------
  |  |  125|  8.39k|#define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  118|  8.39k|#define blk0(i) (block->l[i] = (rol(block->l[i],24)&0xFF00FF00) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  |  |  119|  8.39k|    |(rol(block->l[i],8)&0x00FF00FF))
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  |  |               #define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  ------------------
                  R0(c,d,e,a,b, 8); R0(b,c,d,e,a, 9); R0(a,b,c,d,e,10); R0(e,a,b,c,d,11);
  ------------------
  |  |  125|  8.39k|#define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  118|  8.39k|#define blk0(i) (block->l[i] = (rol(block->l[i],24)&0xFF00FF00) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  |  |  119|  8.39k|    |(rol(block->l[i],8)&0x00FF00FF))
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  |  |               #define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  ------------------
  161|  8.39k|    R0(d,e,a,b,c,12); R0(c,d,e,a,b,13); R0(b,c,d,e,a,14); R0(a,b,c,d,e,15);
  ------------------
  |  |  125|  8.39k|#define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  118|  8.39k|#define blk0(i) (block->l[i] = (rol(block->l[i],24)&0xFF00FF00) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  |  |  119|  8.39k|    |(rol(block->l[i],8)&0x00FF00FF))
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  |  |               #define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  ------------------
                  R0(d,e,a,b,c,12); R0(c,d,e,a,b,13); R0(b,c,d,e,a,14); R0(a,b,c,d,e,15);
  ------------------
  |  |  125|  8.39k|#define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  118|  8.39k|#define blk0(i) (block->l[i] = (rol(block->l[i],24)&0xFF00FF00) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  |  |  119|  8.39k|    |(rol(block->l[i],8)&0x00FF00FF))
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  |  |               #define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  ------------------
                  R0(d,e,a,b,c,12); R0(c,d,e,a,b,13); R0(b,c,d,e,a,14); R0(a,b,c,d,e,15);
  ------------------
  |  |  125|  8.39k|#define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  118|  8.39k|#define blk0(i) (block->l[i] = (rol(block->l[i],24)&0xFF00FF00) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  |  |  119|  8.39k|    |(rol(block->l[i],8)&0x00FF00FF))
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  |  |               #define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  ------------------
                  R0(d,e,a,b,c,12); R0(c,d,e,a,b,13); R0(b,c,d,e,a,14); R0(a,b,c,d,e,15);
  ------------------
  |  |  125|  8.39k|#define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  118|  8.39k|#define blk0(i) (block->l[i] = (rol(block->l[i],24)&0xFF00FF00) \
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  |  |  119|  8.39k|    |(rol(block->l[i],8)&0x00FF00FF))
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  |  |               #define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  ------------------
  162|  8.39k|    R1(e,a,b,c,d,16); R1(d,e,a,b,c,17); R1(c,d,e,a,b,18); R1(b,c,d,e,a,19);
  ------------------
  |  |  126|  8.39k|#define R1(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk(i)+0x5A827999+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  121|  8.39k|#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  |  |  122|  8.39k|    ^block->l[(i+2)&15]^block->l[i&15],1))
  |  |  ------------------
  |  |               #define R1(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk(i)+0x5A827999+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  |  |               #define R1(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk(i)+0x5A827999+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  ------------------
                  R1(e,a,b,c,d,16); R1(d,e,a,b,c,17); R1(c,d,e,a,b,18); R1(b,c,d,e,a,19);
  ------------------
  |  |  126|  8.39k|#define R1(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk(i)+0x5A827999+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  121|  8.39k|#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  |  |  122|  8.39k|    ^block->l[(i+2)&15]^block->l[i&15],1))
  |  |  ------------------
  |  |               #define R1(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk(i)+0x5A827999+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  |  |               #define R1(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk(i)+0x5A827999+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  ------------------
                  R1(e,a,b,c,d,16); R1(d,e,a,b,c,17); R1(c,d,e,a,b,18); R1(b,c,d,e,a,19);
  ------------------
  |  |  126|  8.39k|#define R1(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk(i)+0x5A827999+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  121|  8.39k|#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  |  |  122|  8.39k|    ^block->l[(i+2)&15]^block->l[i&15],1))
  |  |  ------------------
  |  |               #define R1(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk(i)+0x5A827999+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  |  |               #define R1(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk(i)+0x5A827999+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  ------------------
                  R1(e,a,b,c,d,16); R1(d,e,a,b,c,17); R1(c,d,e,a,b,18); R1(b,c,d,e,a,19);
  ------------------
  |  |  126|  8.39k|#define R1(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk(i)+0x5A827999+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  121|  8.39k|#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  |  |  122|  8.39k|    ^block->l[(i+2)&15]^block->l[i&15],1))
  |  |  ------------------
  |  |               #define R1(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk(i)+0x5A827999+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  |  |               #define R1(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk(i)+0x5A827999+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  ------------------
  163|  8.39k|    R2(a,b,c,d,e,20); R2(e,a,b,c,d,21); R2(d,e,a,b,c,22); R2(c,d,e,a,b,23);
  ------------------
  |  |  127|  8.39k|#define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  121|  8.39k|#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  |  |  122|  8.39k|    ^block->l[(i+2)&15]^block->l[i&15],1))
  |  |  ------------------
  |  |               #define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  |  |               #define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  ------------------
                  R2(a,b,c,d,e,20); R2(e,a,b,c,d,21); R2(d,e,a,b,c,22); R2(c,d,e,a,b,23);
  ------------------
  |  |  127|  8.39k|#define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  121|  8.39k|#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  |  |  122|  8.39k|    ^block->l[(i+2)&15]^block->l[i&15],1))
  |  |  ------------------
  |  |               #define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  |  |               #define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  ------------------
                  R2(a,b,c,d,e,20); R2(e,a,b,c,d,21); R2(d,e,a,b,c,22); R2(c,d,e,a,b,23);
  ------------------
  |  |  127|  8.39k|#define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  121|  8.39k|#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  |  |  122|  8.39k|    ^block->l[(i+2)&15]^block->l[i&15],1))
  |  |  ------------------
  |  |               #define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  |  |               #define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  ------------------
                  R2(a,b,c,d,e,20); R2(e,a,b,c,d,21); R2(d,e,a,b,c,22); R2(c,d,e,a,b,23);
  ------------------
  |  |  127|  8.39k|#define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  121|  8.39k|#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  |  |  122|  8.39k|    ^block->l[(i+2)&15]^block->l[i&15],1))
  |  |  ------------------
  |  |               #define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  |  |               #define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  ------------------
  164|  8.39k|    R2(b,c,d,e,a,24); R2(a,b,c,d,e,25); R2(e,a,b,c,d,26); R2(d,e,a,b,c,27);
  ------------------
  |  |  127|  8.39k|#define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  121|  8.39k|#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  |  |  122|  8.39k|    ^block->l[(i+2)&15]^block->l[i&15],1))
  |  |  ------------------
  |  |               #define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  |  |               #define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  ------------------
                  R2(b,c,d,e,a,24); R2(a,b,c,d,e,25); R2(e,a,b,c,d,26); R2(d,e,a,b,c,27);
  ------------------
  |  |  127|  8.39k|#define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  121|  8.39k|#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  |  |  122|  8.39k|    ^block->l[(i+2)&15]^block->l[i&15],1))
  |  |  ------------------
  |  |               #define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  |  |               #define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  ------------------
                  R2(b,c,d,e,a,24); R2(a,b,c,d,e,25); R2(e,a,b,c,d,26); R2(d,e,a,b,c,27);
  ------------------
  |  |  127|  8.39k|#define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  121|  8.39k|#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  |  |  122|  8.39k|    ^block->l[(i+2)&15]^block->l[i&15],1))
  |  |  ------------------
  |  |               #define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  |  |               #define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  ------------------
                  R2(b,c,d,e,a,24); R2(a,b,c,d,e,25); R2(e,a,b,c,d,26); R2(d,e,a,b,c,27);
  ------------------
  |  |  127|  8.39k|#define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  121|  8.39k|#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  |  |  122|  8.39k|    ^block->l[(i+2)&15]^block->l[i&15],1))
  |  |  ------------------
  |  |               #define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  |  |               #define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  ------------------
  165|  8.39k|    R2(c,d,e,a,b,28); R2(b,c,d,e,a,29); R2(a,b,c,d,e,30); R2(e,a,b,c,d,31);
  ------------------
  |  |  127|  8.39k|#define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  121|  8.39k|#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  |  |  122|  8.39k|    ^block->l[(i+2)&15]^block->l[i&15],1))
  |  |  ------------------
  |  |               #define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  |  |               #define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  ------------------
                  R2(c,d,e,a,b,28); R2(b,c,d,e,a,29); R2(a,b,c,d,e,30); R2(e,a,b,c,d,31);
  ------------------
  |  |  127|  8.39k|#define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  121|  8.39k|#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  |  |  122|  8.39k|    ^block->l[(i+2)&15]^block->l[i&15],1))
  |  |  ------------------
  |  |               #define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  |  |               #define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  ------------------
                  R2(c,d,e,a,b,28); R2(b,c,d,e,a,29); R2(a,b,c,d,e,30); R2(e,a,b,c,d,31);
  ------------------
  |  |  127|  8.39k|#define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  121|  8.39k|#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  |  |  122|  8.39k|    ^block->l[(i+2)&15]^block->l[i&15],1))
  |  |  ------------------
  |  |               #define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  |  |               #define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  ------------------
                  R2(c,d,e,a,b,28); R2(b,c,d,e,a,29); R2(a,b,c,d,e,30); R2(e,a,b,c,d,31);
  ------------------
  |  |  127|  8.39k|#define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  121|  8.39k|#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  |  |  122|  8.39k|    ^block->l[(i+2)&15]^block->l[i&15],1))
  |  |  ------------------
  |  |               #define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  |  |               #define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  ------------------
  166|  8.39k|    R2(d,e,a,b,c,32); R2(c,d,e,a,b,33); R2(b,c,d,e,a,34); R2(a,b,c,d,e,35);
  ------------------
  |  |  127|  8.39k|#define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  121|  8.39k|#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  |  |  122|  8.39k|    ^block->l[(i+2)&15]^block->l[i&15],1))
  |  |  ------------------
  |  |               #define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  |  |               #define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  ------------------
                  R2(d,e,a,b,c,32); R2(c,d,e,a,b,33); R2(b,c,d,e,a,34); R2(a,b,c,d,e,35);
  ------------------
  |  |  127|  8.39k|#define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  121|  8.39k|#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  |  |  122|  8.39k|    ^block->l[(i+2)&15]^block->l[i&15],1))
  |  |  ------------------
  |  |               #define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  |  |               #define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  ------------------
                  R2(d,e,a,b,c,32); R2(c,d,e,a,b,33); R2(b,c,d,e,a,34); R2(a,b,c,d,e,35);
  ------------------
  |  |  127|  8.39k|#define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  121|  8.39k|#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  |  |  122|  8.39k|    ^block->l[(i+2)&15]^block->l[i&15],1))
  |  |  ------------------
  |  |               #define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  |  |               #define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  ------------------
                  R2(d,e,a,b,c,32); R2(c,d,e,a,b,33); R2(b,c,d,e,a,34); R2(a,b,c,d,e,35);
  ------------------
  |  |  127|  8.39k|#define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  121|  8.39k|#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  |  |  122|  8.39k|    ^block->l[(i+2)&15]^block->l[i&15],1))
  |  |  ------------------
  |  |               #define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  |  |               #define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  ------------------
  167|  8.39k|    R2(e,a,b,c,d,36); R2(d,e,a,b,c,37); R2(c,d,e,a,b,38); R2(b,c,d,e,a,39);
  ------------------
  |  |  127|  8.39k|#define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  121|  8.39k|#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  |  |  122|  8.39k|    ^block->l[(i+2)&15]^block->l[i&15],1))
  |  |  ------------------
  |  |               #define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  |  |               #define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  ------------------
                  R2(e,a,b,c,d,36); R2(d,e,a,b,c,37); R2(c,d,e,a,b,38); R2(b,c,d,e,a,39);
  ------------------
  |  |  127|  8.39k|#define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  121|  8.39k|#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  |  |  122|  8.39k|    ^block->l[(i+2)&15]^block->l[i&15],1))
  |  |  ------------------
  |  |               #define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  |  |               #define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  ------------------
                  R2(e,a,b,c,d,36); R2(d,e,a,b,c,37); R2(c,d,e,a,b,38); R2(b,c,d,e,a,39);
  ------------------
  |  |  127|  8.39k|#define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  121|  8.39k|#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  |  |  122|  8.39k|    ^block->l[(i+2)&15]^block->l[i&15],1))
  |  |  ------------------
  |  |               #define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  |  |               #define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  ------------------
                  R2(e,a,b,c,d,36); R2(d,e,a,b,c,37); R2(c,d,e,a,b,38); R2(b,c,d,e,a,39);
  ------------------
  |  |  127|  8.39k|#define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  121|  8.39k|#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  |  |  122|  8.39k|    ^block->l[(i+2)&15]^block->l[i&15],1))
  |  |  ------------------
  |  |               #define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  |  |               #define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  ------------------
  168|  8.39k|    R3(a,b,c,d,e,40); R3(e,a,b,c,d,41); R3(d,e,a,b,c,42); R3(c,d,e,a,b,43);
  ------------------
  |  |  128|  8.39k|#define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  121|  8.39k|#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  |  |  122|  8.39k|    ^block->l[(i+2)&15]^block->l[i&15],1))
  |  |  ------------------
  |  |               #define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  |  |               #define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  ------------------
                  R3(a,b,c,d,e,40); R3(e,a,b,c,d,41); R3(d,e,a,b,c,42); R3(c,d,e,a,b,43);
  ------------------
  |  |  128|  8.39k|#define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  121|  8.39k|#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  |  |  122|  8.39k|    ^block->l[(i+2)&15]^block->l[i&15],1))
  |  |  ------------------
  |  |               #define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  |  |               #define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  ------------------
                  R3(a,b,c,d,e,40); R3(e,a,b,c,d,41); R3(d,e,a,b,c,42); R3(c,d,e,a,b,43);
  ------------------
  |  |  128|  8.39k|#define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  121|  8.39k|#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  |  |  122|  8.39k|    ^block->l[(i+2)&15]^block->l[i&15],1))
  |  |  ------------------
  |  |               #define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  |  |               #define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  ------------------
                  R3(a,b,c,d,e,40); R3(e,a,b,c,d,41); R3(d,e,a,b,c,42); R3(c,d,e,a,b,43);
  ------------------
  |  |  128|  8.39k|#define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  121|  8.39k|#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  |  |  122|  8.39k|    ^block->l[(i+2)&15]^block->l[i&15],1))
  |  |  ------------------
  |  |               #define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  |  |               #define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  ------------------
  169|  8.39k|    R3(b,c,d,e,a,44); R3(a,b,c,d,e,45); R3(e,a,b,c,d,46); R3(d,e,a,b,c,47);
  ------------------
  |  |  128|  8.39k|#define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  121|  8.39k|#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  |  |  122|  8.39k|    ^block->l[(i+2)&15]^block->l[i&15],1))
  |  |  ------------------
  |  |               #define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  |  |               #define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  ------------------
                  R3(b,c,d,e,a,44); R3(a,b,c,d,e,45); R3(e,a,b,c,d,46); R3(d,e,a,b,c,47);
  ------------------
  |  |  128|  8.39k|#define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  121|  8.39k|#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  |  |  122|  8.39k|    ^block->l[(i+2)&15]^block->l[i&15],1))
  |  |  ------------------
  |  |               #define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  |  |               #define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  ------------------
                  R3(b,c,d,e,a,44); R3(a,b,c,d,e,45); R3(e,a,b,c,d,46); R3(d,e,a,b,c,47);
  ------------------
  |  |  128|  8.39k|#define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  121|  8.39k|#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  |  |  122|  8.39k|    ^block->l[(i+2)&15]^block->l[i&15],1))
  |  |  ------------------
  |  |               #define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  |  |               #define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  ------------------
                  R3(b,c,d,e,a,44); R3(a,b,c,d,e,45); R3(e,a,b,c,d,46); R3(d,e,a,b,c,47);
  ------------------
  |  |  128|  8.39k|#define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  121|  8.39k|#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  |  |  122|  8.39k|    ^block->l[(i+2)&15]^block->l[i&15],1))
  |  |  ------------------
  |  |               #define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  |  |               #define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  ------------------
  170|  8.39k|    R3(c,d,e,a,b,48); R3(b,c,d,e,a,49); R3(a,b,c,d,e,50); R3(e,a,b,c,d,51);
  ------------------
  |  |  128|  8.39k|#define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  121|  8.39k|#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  |  |  122|  8.39k|    ^block->l[(i+2)&15]^block->l[i&15],1))
  |  |  ------------------
  |  |               #define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  |  |               #define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  ------------------
                  R3(c,d,e,a,b,48); R3(b,c,d,e,a,49); R3(a,b,c,d,e,50); R3(e,a,b,c,d,51);
  ------------------
  |  |  128|  8.39k|#define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  121|  8.39k|#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  |  |  122|  8.39k|    ^block->l[(i+2)&15]^block->l[i&15],1))
  |  |  ------------------
  |  |               #define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  |  |               #define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  ------------------
                  R3(c,d,e,a,b,48); R3(b,c,d,e,a,49); R3(a,b,c,d,e,50); R3(e,a,b,c,d,51);
  ------------------
  |  |  128|  8.39k|#define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  121|  8.39k|#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  |  |  122|  8.39k|    ^block->l[(i+2)&15]^block->l[i&15],1))
  |  |  ------------------
  |  |               #define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  |  |               #define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  ------------------
                  R3(c,d,e,a,b,48); R3(b,c,d,e,a,49); R3(a,b,c,d,e,50); R3(e,a,b,c,d,51);
  ------------------
  |  |  128|  8.39k|#define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  121|  8.39k|#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  |  |  122|  8.39k|    ^block->l[(i+2)&15]^block->l[i&15],1))
  |  |  ------------------
  |  |               #define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  |  |               #define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  ------------------
  171|  8.39k|    R3(d,e,a,b,c,52); R3(c,d,e,a,b,53); R3(b,c,d,e,a,54); R3(a,b,c,d,e,55);
  ------------------
  |  |  128|  8.39k|#define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  121|  8.39k|#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  |  |  122|  8.39k|    ^block->l[(i+2)&15]^block->l[i&15],1))
  |  |  ------------------
  |  |               #define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  |  |               #define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  ------------------
                  R3(d,e,a,b,c,52); R3(c,d,e,a,b,53); R3(b,c,d,e,a,54); R3(a,b,c,d,e,55);
  ------------------
  |  |  128|  8.39k|#define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  121|  8.39k|#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  |  |  122|  8.39k|    ^block->l[(i+2)&15]^block->l[i&15],1))
  |  |  ------------------
  |  |               #define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  |  |               #define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  ------------------
                  R3(d,e,a,b,c,52); R3(c,d,e,a,b,53); R3(b,c,d,e,a,54); R3(a,b,c,d,e,55);
  ------------------
  |  |  128|  8.39k|#define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  121|  8.39k|#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  |  |  122|  8.39k|    ^block->l[(i+2)&15]^block->l[i&15],1))
  |  |  ------------------
  |  |               #define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  |  |               #define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  ------------------
                  R3(d,e,a,b,c,52); R3(c,d,e,a,b,53); R3(b,c,d,e,a,54); R3(a,b,c,d,e,55);
  ------------------
  |  |  128|  8.39k|#define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  121|  8.39k|#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  |  |  122|  8.39k|    ^block->l[(i+2)&15]^block->l[i&15],1))
  |  |  ------------------
  |  |               #define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  |  |               #define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  ------------------
  172|  8.39k|    R3(e,a,b,c,d,56); R3(d,e,a,b,c,57); R3(c,d,e,a,b,58); R3(b,c,d,e,a,59);
  ------------------
  |  |  128|  8.39k|#define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  121|  8.39k|#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  |  |  122|  8.39k|    ^block->l[(i+2)&15]^block->l[i&15],1))
  |  |  ------------------
  |  |               #define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  |  |               #define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  ------------------
                  R3(e,a,b,c,d,56); R3(d,e,a,b,c,57); R3(c,d,e,a,b,58); R3(b,c,d,e,a,59);
  ------------------
  |  |  128|  8.39k|#define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  121|  8.39k|#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  |  |  122|  8.39k|    ^block->l[(i+2)&15]^block->l[i&15],1))
  |  |  ------------------
  |  |               #define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  |  |               #define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  ------------------
                  R3(e,a,b,c,d,56); R3(d,e,a,b,c,57); R3(c,d,e,a,b,58); R3(b,c,d,e,a,59);
  ------------------
  |  |  128|  8.39k|#define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  121|  8.39k|#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  |  |  122|  8.39k|    ^block->l[(i+2)&15]^block->l[i&15],1))
  |  |  ------------------
  |  |               #define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  |  |               #define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  ------------------
                  R3(e,a,b,c,d,56); R3(d,e,a,b,c,57); R3(c,d,e,a,b,58); R3(b,c,d,e,a,59);
  ------------------
  |  |  128|  8.39k|#define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  121|  8.39k|#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  |  |  122|  8.39k|    ^block->l[(i+2)&15]^block->l[i&15],1))
  |  |  ------------------
  |  |               #define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  |  |               #define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  ------------------
  173|  8.39k|    R4(a,b,c,d,e,60); R4(e,a,b,c,d,61); R4(d,e,a,b,c,62); R4(c,d,e,a,b,63);
  ------------------
  |  |  129|  8.39k|#define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  121|  8.39k|#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  |  |  122|  8.39k|    ^block->l[(i+2)&15]^block->l[i&15],1))
  |  |  ------------------
  |  |               #define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  |  |               #define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  ------------------
                  R4(a,b,c,d,e,60); R4(e,a,b,c,d,61); R4(d,e,a,b,c,62); R4(c,d,e,a,b,63);
  ------------------
  |  |  129|  8.39k|#define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  121|  8.39k|#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  |  |  122|  8.39k|    ^block->l[(i+2)&15]^block->l[i&15],1))
  |  |  ------------------
  |  |               #define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  |  |               #define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  ------------------
                  R4(a,b,c,d,e,60); R4(e,a,b,c,d,61); R4(d,e,a,b,c,62); R4(c,d,e,a,b,63);
  ------------------
  |  |  129|  8.39k|#define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  121|  8.39k|#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  |  |  122|  8.39k|    ^block->l[(i+2)&15]^block->l[i&15],1))
  |  |  ------------------
  |  |               #define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  |  |               #define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  ------------------
                  R4(a,b,c,d,e,60); R4(e,a,b,c,d,61); R4(d,e,a,b,c,62); R4(c,d,e,a,b,63);
  ------------------
  |  |  129|  8.39k|#define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  121|  8.39k|#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  |  |  122|  8.39k|    ^block->l[(i+2)&15]^block->l[i&15],1))
  |  |  ------------------
  |  |               #define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  |  |               #define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  ------------------
  174|  8.39k|    R4(b,c,d,e,a,64); R4(a,b,c,d,e,65); R4(e,a,b,c,d,66); R4(d,e,a,b,c,67);
  ------------------
  |  |  129|  8.39k|#define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  121|  8.39k|#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  |  |  122|  8.39k|    ^block->l[(i+2)&15]^block->l[i&15],1))
  |  |  ------------------
  |  |               #define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  |  |               #define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  ------------------
                  R4(b,c,d,e,a,64); R4(a,b,c,d,e,65); R4(e,a,b,c,d,66); R4(d,e,a,b,c,67);
  ------------------
  |  |  129|  8.39k|#define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  121|  8.39k|#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  |  |  122|  8.39k|    ^block->l[(i+2)&15]^block->l[i&15],1))
  |  |  ------------------
  |  |               #define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  |  |               #define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  ------------------
                  R4(b,c,d,e,a,64); R4(a,b,c,d,e,65); R4(e,a,b,c,d,66); R4(d,e,a,b,c,67);
  ------------------
  |  |  129|  8.39k|#define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  121|  8.39k|#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  |  |  122|  8.39k|    ^block->l[(i+2)&15]^block->l[i&15],1))
  |  |  ------------------
  |  |               #define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  |  |               #define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  ------------------
                  R4(b,c,d,e,a,64); R4(a,b,c,d,e,65); R4(e,a,b,c,d,66); R4(d,e,a,b,c,67);
  ------------------
  |  |  129|  8.39k|#define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  121|  8.39k|#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  |  |  122|  8.39k|    ^block->l[(i+2)&15]^block->l[i&15],1))
  |  |  ------------------
  |  |               #define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  |  |               #define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  ------------------
  175|  8.39k|    R4(c,d,e,a,b,68); R4(b,c,d,e,a,69); R4(a,b,c,d,e,70); R4(e,a,b,c,d,71);
  ------------------
  |  |  129|  8.39k|#define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  121|  8.39k|#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  |  |  122|  8.39k|    ^block->l[(i+2)&15]^block->l[i&15],1))
  |  |  ------------------
  |  |               #define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  |  |               #define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  ------------------
                  R4(c,d,e,a,b,68); R4(b,c,d,e,a,69); R4(a,b,c,d,e,70); R4(e,a,b,c,d,71);
  ------------------
  |  |  129|  8.39k|#define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  121|  8.39k|#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  |  |  122|  8.39k|    ^block->l[(i+2)&15]^block->l[i&15],1))
  |  |  ------------------
  |  |               #define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  |  |               #define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  ------------------
                  R4(c,d,e,a,b,68); R4(b,c,d,e,a,69); R4(a,b,c,d,e,70); R4(e,a,b,c,d,71);
  ------------------
  |  |  129|  8.39k|#define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  121|  8.39k|#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  |  |  122|  8.39k|    ^block->l[(i+2)&15]^block->l[i&15],1))
  |  |  ------------------
  |  |               #define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  |  |               #define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  ------------------
                  R4(c,d,e,a,b,68); R4(b,c,d,e,a,69); R4(a,b,c,d,e,70); R4(e,a,b,c,d,71);
  ------------------
  |  |  129|  8.39k|#define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  121|  8.39k|#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  |  |  122|  8.39k|    ^block->l[(i+2)&15]^block->l[i&15],1))
  |  |  ------------------
  |  |               #define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  |  |               #define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  ------------------
  176|  8.39k|    R4(d,e,a,b,c,72); R4(c,d,e,a,b,73); R4(b,c,d,e,a,74); R4(a,b,c,d,e,75);
  ------------------
  |  |  129|  8.39k|#define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  121|  8.39k|#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  |  |  122|  8.39k|    ^block->l[(i+2)&15]^block->l[i&15],1))
  |  |  ------------------
  |  |               #define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  |  |               #define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  ------------------
                  R4(d,e,a,b,c,72); R4(c,d,e,a,b,73); R4(b,c,d,e,a,74); R4(a,b,c,d,e,75);
  ------------------
  |  |  129|  8.39k|#define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  121|  8.39k|#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  |  |  122|  8.39k|    ^block->l[(i+2)&15]^block->l[i&15],1))
  |  |  ------------------
  |  |               #define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  |  |               #define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  ------------------
                  R4(d,e,a,b,c,72); R4(c,d,e,a,b,73); R4(b,c,d,e,a,74); R4(a,b,c,d,e,75);
  ------------------
  |  |  129|  8.39k|#define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  121|  8.39k|#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  |  |  122|  8.39k|    ^block->l[(i+2)&15]^block->l[i&15],1))
  |  |  ------------------
  |  |               #define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  |  |               #define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  ------------------
                  R4(d,e,a,b,c,72); R4(c,d,e,a,b,73); R4(b,c,d,e,a,74); R4(a,b,c,d,e,75);
  ------------------
  |  |  129|  8.39k|#define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  121|  8.39k|#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  |  |  122|  8.39k|    ^block->l[(i+2)&15]^block->l[i&15],1))
  |  |  ------------------
  |  |               #define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  |  |               #define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  ------------------
  177|  8.39k|    R4(e,a,b,c,d,76); R4(d,e,a,b,c,77); R4(c,d,e,a,b,78); R4(b,c,d,e,a,79);
  ------------------
  |  |  129|  8.39k|#define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  121|  8.39k|#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  |  |  122|  8.39k|    ^block->l[(i+2)&15]^block->l[i&15],1))
  |  |  ------------------
  |  |               #define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  |  |               #define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  ------------------
                  R4(e,a,b,c,d,76); R4(d,e,a,b,c,77); R4(c,d,e,a,b,78); R4(b,c,d,e,a,79);
  ------------------
  |  |  129|  8.39k|#define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  121|  8.39k|#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  |  |  122|  8.39k|    ^block->l[(i+2)&15]^block->l[i&15],1))
  |  |  ------------------
  |  |               #define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  |  |               #define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  ------------------
                  R4(e,a,b,c,d,76); R4(d,e,a,b,c,77); R4(c,d,e,a,b,78); R4(b,c,d,e,a,79);
  ------------------
  |  |  129|  8.39k|#define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  121|  8.39k|#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  |  |  122|  8.39k|    ^block->l[(i+2)&15]^block->l[i&15],1))
  |  |  ------------------
  |  |               #define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  |  |               #define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  ------------------
                  R4(e,a,b,c,d,76); R4(d,e,a,b,c,77); R4(c,d,e,a,b,78); R4(b,c,d,e,a,79);
  ------------------
  |  |  129|  8.39k|#define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  121|  8.39k|#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  |  |  ------------------
  |  |  |  |  122|  8.39k|    ^block->l[(i+2)&15]^block->l[i&15],1))
  |  |  ------------------
  |  |               #define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  |  |               #define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
  |  |  ------------------
  |  |  |  |  109|  8.39k|#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
  |  |  ------------------
  ------------------
  178|       |
  179|       |    /* Add the working vars back into context.state[] */
  180|  8.39k|    state[0] += a;
  181|  8.39k|    state[1] += b;
  182|  8.39k|    state[2] += c;
  183|  8.39k|    state[3] += d;
  184|  8.39k|    state[4] += e;
  185|       |
  186|       |    /* Wipe variables */
  187|  8.39k|    a = b = c = d = e = 0;
  188|  8.39k|}

stun_sock.c:pj_enum_ip_option_default:
   88|    341|{
   89|    341|    pj_bzero(opt, sizeof(*opt));
   90|    341|}

ice_session.c:pj_list_init:
   88|    341|{
   89|    341|    ((pj_list*)node)->next = ((pj_list*)node)->prev = node;
   90|    341|}
stun_session.c:pj_list_init:
   88|  3.15k|{
   89|  3.15k|    ((pj_list*)node)->next = ((pj_list*)node)->prev = node;
   90|  3.15k|}
stun_session.c:pj_list_empty:
  102|  1.36k|{
  103|  1.36k|    return ((pj_list*)node)->next == node;
  104|  1.36k|}
ioqueue_select.c:pj_list_empty:
  102|    682|{
  103|    682|    return ((pj_list*)node)->next == node;
  104|    682|}
ioqueue_select.c:pj_list_init:
   88|  5.41k|{
   89|  5.41k|    ((pj_list*)node)->next = ((pj_list*)node)->prev = node;
   90|  5.41k|}
ioqueue_select.c:pj_list_push_back:
  125|  6.65k|{
  126|  6.65k|    pj_list_insert_before(list, node);
  127|  6.65k|}
list.c:pj_list_init:
   88|  18.8k|{
   89|  18.8k|    ((pj_list*)node)->next = ((pj_list*)node)->prev = node;
   90|  18.8k|}
lock.c:pj_list_init:
   88|  2.47k|{
   89|  2.47k|    ((pj_list*)node)->next = ((pj_list*)node)->prev = node;
   90|  2.47k|}
lock.c:pj_list_push_back:
  125|  4.73k|{
  126|  4.73k|    pj_list_insert_before(list, node);
  127|  4.73k|}
pool.c:pj_list_init:
   88|  8.79k|{
   89|  8.79k|    ((pj_list*)node)->next = ((pj_list*)node)->prev = node;
   90|  8.79k|}
pool_caching.c:pj_list_init:
   88|  21.1k|{
   89|  21.1k|    ((pj_list*)node)->next = ((pj_list*)node)->prev = node;
   90|  21.1k|}
pool_caching.c:pj_list_empty:
  102|  7.55k|{
  103|  7.55k|    return ((pj_list*)node)->next == node;
  104|  7.55k|}

pj_list_insert_after:
   29|  38.9k|{
   30|  38.9k|    ((pj_list*)node)->prev = pos;
   31|  38.9k|    ((pj_list*)node)->next = ((pj_list*)pos)->next;
   32|  38.9k|    ((pj_list*) ((pj_list*)pos)->next) ->prev = node;
   33|  38.9k|    ((pj_list*)pos)->next = node;
   34|  38.9k|}
pj_list_insert_before:
   38|  19.6k|{
   39|  19.6k|    pj_list_insert_after(((pj_list*)pos)->prev, node);
   40|  19.6k|}
pj_list_erase:
   93|  18.8k|{
   94|  18.8k|    pj_link_node( ((pj_list*)node)->prev, ((pj_list*)node)->next);
   95|       |
   96|       |    /* It'll be safer to init the next/prev fields to itself, to
   97|       |     * prevent multiple erase() from corrupting the list. See
   98|       |     * ticket #520 for one sample bug.
   99|       |     */
  100|  18.8k|    pj_list_init(node);
  101|  18.8k|}
list.c:pj_link_node:
   23|  18.8k|{
   24|  18.8k|    ((pj_list*)prev)->next = next;
   25|  18.8k|    ((pj_list*)next)->prev = prev;
   26|  18.8k|}

os_timestamp_common.c:pj_set_timestamp32:
 1423|  1.57k|{
 1424|  1.57k|    t->u32.hi = hi;
 1425|  1.57k|    t->u32.lo = lo;
 1426|  1.57k|}

ice_strans.c:pj_pool_zalloc:
  552|  1.02k|{
  553|  1.02k|    return pj_pool_calloc(pool, 1, size);
  554|  1.02k|}
stun_msg.c:pj_pool_zalloc:
  552|  20.9k|{
  553|  20.9k|    return pj_pool_calloc(pool, 1, size);
  554|  20.9k|}
stun_sock.c:pj_pool_zalloc:
  552|    341|{
  553|    341|    return pj_pool_calloc(pool, 1, size);
  554|    341|}
turn_session.c:pj_pool_zalloc:
  552|    896|{
  553|    896|    return pj_pool_calloc(pool, 1, size);
  554|    896|}
ice_session.c:pj_pool_zalloc:
  552|    682|{
  553|    682|    return pj_pool_calloc(pool, 1, size);
  554|    682|}
stun_session.c:pj_pool_zalloc:
  552|  1.57k|{
  553|  1.57k|    return pj_pool_calloc(pool, 1, size);
  554|  1.57k|}
os_core_unix.c:pj_pool_zalloc:
  552|  1.23k|{
  553|  1.23k|    return pj_pool_calloc(pool, 1, size);
  554|  1.23k|}
ioqueue_select.c:pj_pool_zalloc:
  552|  1.23k|{
  553|  1.23k|    return pj_pool_calloc(pool, 1, size);
  554|  1.23k|}
activesock.c:pj_pool_zalloc:
  552|    341|{
  553|    341|    return pj_pool_calloc(pool, 1, size);
  554|    341|}
lock.c:pj_pool_zalloc:
  552|  5.97k|{
  553|  5.97k|    return pj_pool_calloc(pool, 1, size);
  554|  5.97k|}
timer.c:pj_pool_zalloc:
  552|  1.23k|{
  553|  1.23k|    return pj_pool_calloc(pool, 1, size);
  554|  1.23k|}

pj_pool_get_capacity:
   28|  3.97k|{
   29|  3.97k|    return pool->capacity;
   30|  3.97k|}
pj_pool_alloc_from_block:
   45|   129k|{
   46|   129k|    unsigned char *ptr;
   47|       |
   48|   129k|    pj_assert(PJ_IS_POWER_OF_TWO(alignment));
  ------------------
  |  |   65|   129k|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (48:5): [True: 0, False: 129k]
  |  Branch (48:5): [True: 0, False: 0]
  |  Branch (48:5): [True: 129k, False: 0]
  |  Branch (48:5): [True: 129k, False: 0]
  ------------------
   49|       |    // Size should be already aligned.
   50|       |    // this code was moved up to pj_pool_aligned_alloc. 
   51|       |    // ...and then removed there
   52|       |    //
   53|       |    ///* The operation below is valid for size==0. 
   54|       |    // * When size==0, the function will return the pointer to the pool
   55|       |    // * memory address, but no memory will be allocated.
   56|       |    // */
   57|       |    //if (size & (alignment -1)) {
   58|       |    //    size = (size + alignment) & ~(alignment -1);
   59|       |    //}
   60|   129k|    ptr = PJ_POOL_ALIGN_PTR(block->cur, alignment);
  ------------------
  |  |   23|   129k|#define PJ_POOL_ALIGN_PTR(PTR,ALIGNMENT)    (PTR + (-(pj_ssize_t)(PTR) & (ALIGNMENT-1)))
  ------------------
   61|   129k|    if (block->cur <= ptr && /* check pointer overflow */
  ------------------
  |  Branch (61:9): [True: 129k, False: 0]
  ------------------
   62|   129k|        block->end - ptr >= (pj_ssize_t)size) /* check available size */
  ------------------
  |  Branch (62:9): [True: 91.2k, False: 38.1k]
  ------------------
   63|  91.2k|    {
   64|       |    //if (ptr + size <= block->end &&
   65|       |    //    /* here we check pointer overflow */
   66|       |    //    block->cur <= ptr && ptr <= ptr + size) {
   67|  91.2k|        block->cur = ptr + size;
   68|  91.2k|        return ptr;
   69|  91.2k|    }
   70|  38.1k|    return NULL;
   71|   129k|}
pj_pool_alloc:
   74|  91.2k|{
   75|  91.2k|    return pj_pool_aligned_alloc(pool, 0, size);
   76|  91.2k|}
pj_pool_aligned_alloc:
   80|  91.2k|{
   81|  91.2k|    void *ptr;
   82|       |
   83|  91.2k|    PJ_ASSERT_RETURN(!alignment || PJ_IS_POWER_OF_TWO(alignment), NULL);
  ------------------
  |  |   97|  91.2k|            do { \
  |  |   98|  91.2k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 0, False: 0]
  |  |  |  Branch (98:23): [True: 0, False: 0]
  |  |  |  Branch (98:23): [True: 91.2k, False: 0]
  |  |  ------------------
  |  |   99|  91.2k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 91.2k]
  |  |  ------------------
  ------------------
  |  Branch (83:5): [True: 0, False: 0]
  |  Branch (83:5): [True: 0, False: 0]
  |  Branch (83:5): [True: 0, False: 0]
  |  Branch (83:5): [True: 0, False: 0]
  |  Branch (83:5): [True: 0, False: 0]
  |  Branch (83:5): [True: 0, False: 0]
  ------------------
   84|       |
   85|  91.2k|    if (!alignment)
  ------------------
  |  Branch (85:9): [True: 91.2k, False: 0]
  ------------------
   86|  91.2k|        alignment = pool->alignment;
   87|       |
   88|       |#if 0
   89|       |    //Rounding up is the compiler's job, not the allocator's.
   90|       |
   91|       |    /* The operation below is valid for size==0. 
   92|       |     * When size==0, the function will return the pointer to the pool
   93|       |     * memory address, but no memory will be allocated.
   94|       |     */
   95|       |    if (size & (alignment -1)) {
   96|       |        size = (size + alignment) & ~(alignment -1);
   97|       |    }
   98|       |    pj_assert(PJ_IS_ALIGNED(size, alignment));
   99|       |#endif
  100|       |
  101|  91.2k|    ptr = pj_pool_alloc_from_block(pool->block_list.next, 
  102|  91.2k|                                   alignment, size);
  103|  91.2k|    if (!ptr)
  ------------------
  |  Branch (103:9): [True: 15.3k, False: 75.8k]
  ------------------
  104|  15.3k|        ptr = pj_pool_allocate_find(pool, alignment, size);
  105|  91.2k|    return ptr;
  106|  91.2k|}
pj_pool_calloc:
  110|  41.3k|{
  111|  41.3k|    void *buf = pj_pool_alloc( pool, size*count);
  112|  41.3k|    if (buf)
  ------------------
  |  Branch (112:9): [True: 41.3k, False: 0]
  ------------------
  113|  41.3k|        pj_bzero(buf, size * count);
  114|  41.3k|    return buf;
  115|  41.3k|}
pj_pool_create:
  127|  7.55k|{
  128|  7.55k|    return pj_pool_aligned_create(f, name, initial_size, increment_size, 0, callback);
  129|  7.55k|}
pj_pool_aligned_create:
  137|  7.55k|{
  138|  7.55k|    return (*f->create_pool)(f, name, initial_size, increment_size, alignment, callback);
  139|  7.55k|}
pj_pool_release:
  142|  3.97k|{
  143|       |#if PJ_POOL_RELEASE_WIPE_DATA
  144|       |    pj_pool_block *b;
  145|       |
  146|       |    b = pool->block_list.next;
  147|       |    while (b != &pool->block_list) {
  148|       |        volatile unsigned char *p = b->buf;
  149|       |        while (p < b->end) *p++ = 0;
  150|       |        b = b->next;
  151|       |    }
  152|       |#endif
  153|       |
  154|  3.97k|    if (pool->factory->release_pool)
  ------------------
  |  Branch (154:9): [True: 3.97k, False: 0]
  ------------------
  155|  3.97k|        (*pool->factory->release_pool)(pool->factory, pool);
  156|  3.97k|}
pj_pool_safe_release:
  160|  2.72k|{
  161|  2.72k|    pj_pool_t *pool = *ppool;
  162|  2.72k|    *ppool = NULL;
  163|  2.72k|    if (pool)
  ------------------
  |  Branch (163:9): [True: 2.38k, False: 341]
  ------------------
  164|  2.38k|        pj_pool_release(pool);
  165|  2.72k|}

fuzz-stun.c:pj_bzero:
  820|  8.07k|{
  821|       |#if defined(PJ_HAS_BZERO) && PJ_HAS_BZERO!=0
  822|       |    bzero(dst, size);
  823|       |#else
  824|  8.07k|    memset(dst, 0, size);
  825|  8.07k|#endif
  826|  8.07k|}
fuzz-stun.c:pj_memcpy:
  853|  4.27k|{
  854|  4.27k|    return memcpy(dst, src, size);
  855|  4.27k|}
ice_strans.c:pj_bzero:
  820|  2.72k|{
  821|       |#if defined(PJ_HAS_BZERO) && PJ_HAS_BZERO!=0
  822|       |    bzero(dst, size);
  823|       |#else
  824|  2.72k|    memset(dst, 0, size);
  825|  2.72k|#endif
  826|  2.72k|}
ice_strans.c:pj_memcpy:
  853|  1.36k|{
  854|  1.36k|    return memcpy(dst, src, size);
  855|  1.36k|}
stun_auth.c:pj_memcpy:
  853|    551|{
  854|    551|    return memcpy(dst, src, size);
  855|    551|}
stun_auth.c:pj_bzero:
  820|    958|{
  821|       |#if defined(PJ_HAS_BZERO) && PJ_HAS_BZERO!=0
  822|       |    bzero(dst, size);
  823|       |#else
  824|    958|    memset(dst, 0, size);
  825|    958|#endif
  826|    958|}
stun_auth.c:pj_memcmp:
  881|    231|{
  882|    231|    return memcmp(buf1, buf2, size);
  883|    231|}
stun_auth.c:pj_cstr:
  101|    210|{
  102|    210|    str->ptr = (char*)s;
  103|    210|    str->slen = s ? (pj_ssize_t)strlen(s) : 0;
  ------------------
  |  Branch (103:17): [True: 210, False: 0]
  ------------------
  104|    210|    return str;
  105|    210|}
stun_msg.c:pj_memset:
  839|  3.18k|{
  840|  3.18k|    return memset(dst, c, size);
  841|  3.18k|}
stun_msg.c:pj_memcpy:
  853|  25.5k|{
  854|  25.5k|    return memcpy(dst, src, size);
  855|  25.5k|}
stun_sock.c:pj_bzero:
  820|  1.36k|{
  821|       |#if defined(PJ_HAS_BZERO) && PJ_HAS_BZERO!=0
  822|       |    bzero(dst, size);
  823|       |#else
  824|  1.36k|    memset(dst, 0, size);
  825|  1.36k|#endif
  826|  1.36k|}
stun_sock.c:pj_memcpy:
  853|  1.36k|{
  854|  1.36k|    return memcpy(dst, src, size);
  855|  1.36k|}
turn_session.c:pj_bzero:
  820|  2.13k|{
  821|       |#if defined(PJ_HAS_BZERO) && PJ_HAS_BZERO!=0
  822|       |    bzero(dst, size);
  823|       |#else
  824|  2.13k|    memset(dst, 0, size);
  825|  2.13k|#endif
  826|  2.13k|}
turn_session.c:pj_memcpy:
  853|  2.72k|{
  854|  2.72k|    return memcpy(dst, src, size);
  855|  2.72k|}
turn_sock.c:pj_bzero:
  820|    341|{
  821|       |#if defined(PJ_HAS_BZERO) && PJ_HAS_BZERO!=0
  822|       |    bzero(dst, size);
  823|       |#else
  824|    341|    memset(dst, 0, size);
  825|    341|#endif
  826|    341|}
errno.c:pj_memcpy:
  853|     16|{
  854|     16|    return memcpy(dst, src, size);
  855|     16|}
ice_session.c:pj_memcpy:
  853|  1.36k|{
  854|  1.36k|    return memcpy(dst, src, size);
  855|  1.36k|}
ice_session.c:pj_bzero:
  820|    682|{
  821|       |#if defined(PJ_HAS_BZERO) && PJ_HAS_BZERO!=0
  822|       |    bzero(dst, size);
  823|       |#else
  824|    682|    memset(dst, 0, size);
  825|    682|#endif
  826|    682|}
stun_session.c:pj_memcpy:
  853|  1.57k|{
  854|  1.57k|    return memcpy(dst, src, size);
  855|  1.57k|}
stun_session.c:pj_bzero:
  820|    299|{
  821|       |#if defined(PJ_HAS_BZERO) && PJ_HAS_BZERO!=0
  822|       |    bzero(dst, size);
  823|       |#else
  824|    299|    memset(dst, 0, size);
  825|    299|#endif
  826|    299|}
hmac_sha1.c:pj_bzero:
  820|  2.94k|{
  821|       |#if defined(PJ_HAS_BZERO) && PJ_HAS_BZERO!=0
  822|       |    bzero(dst, size);
  823|       |#else
  824|  2.94k|    memset(dst, 0, size);
  825|  2.94k|#endif
  826|  2.94k|}
hmac_sha1.c:pj_memcpy:
  853|  2.94k|{
  854|  2.94k|    return memcpy(dst, src, size);
  855|  2.94k|}
md5.c:pj_memcpy:
  853|  11.7k|{
  854|  11.7k|    return memcpy(dst, src, size);
  855|  11.7k|}
md5.c:pj_bzero:
  820|  2.94k|{
  821|       |#if defined(PJ_HAS_BZERO) && PJ_HAS_BZERO!=0
  822|       |    bzero(dst, size);
  823|       |#else
  824|  2.94k|    memset(dst, 0, size);
  825|  2.94k|#endif
  826|  2.94k|}
sha1.c:pj_memcpy:
  853|   125k|{
  854|   125k|    return memcpy(dst, src, size);
  855|   125k|}
sha1.c:pj_memset:
  839|  11.7k|{
  840|  11.7k|    return memset(dst, c, size);
  841|  11.7k|}
os_core_unix.c:pj_bzero:
  820|      1|{
  821|       |#if defined(PJ_HAS_BZERO) && PJ_HAS_BZERO!=0
  822|       |    bzero(dst, size);
  823|       |#else
  824|      1|    memset(dst, 0, size);
  825|      1|#endif
  826|      1|}
os_core_unix.c:pj_strlen:
  282|      1|{
  283|      1|    return str->slen;
  284|      1|}
addr_resolv_sock.c:pj_memcpy:
  853|  2.47k|{
  854|  2.47k|    return memcpy(dst, src, size);
  855|  2.47k|}
addr_resolv_sock.c:pj_bzero:
  820|  1.23k|{
  821|       |#if defined(PJ_HAS_BZERO) && PJ_HAS_BZERO!=0
  822|       |    bzero(dst, size);
  823|       |#else
  824|  1.23k|    memset(dst, 0, size);
  825|  1.23k|#endif
  826|  1.23k|}
ioqueue_select.c:pj_bzero:
  820|  1.91k|{
  821|       |#if defined(PJ_HAS_BZERO) && PJ_HAS_BZERO!=0
  822|       |    bzero(dst, size);
  823|       |#else
  824|  1.91k|    memset(dst, 0, size);
  825|  1.91k|#endif
  826|  1.91k|}
ioqueue_select.c:pj_memcpy:
  853|    341|{
  854|    341|    return memcpy(dst, src, size);
  855|    341|}
sock_bsd.c:pj_memcpy:
  853|  1.23k|{
  854|  1.23k|    return memcpy(dst, src, size);
  855|  1.23k|}
activesock.c:pj_bzero:
  820|    682|{
  821|       |#if defined(PJ_HAS_BZERO) && PJ_HAS_BZERO!=0
  822|       |    bzero(dst, size);
  823|       |#else
  824|    682|    memset(dst, 0, size);
  825|    682|#endif
  826|    682|}
activesock.c:pj_memcpy:
  853|    341|{
  854|    341|    return memcpy(dst, src, size);
  855|    341|}
ip_helper_generic.c:pj_bzero:
  820|  1.36k|{
  821|       |#if defined(PJ_HAS_BZERO) && PJ_HAS_BZERO!=0
  822|       |    bzero(dst, size);
  823|       |#else
  824|  1.36k|    memset(dst, 0, size);
  825|  1.36k|#endif
  826|  1.36k|}
ip_helper_generic.c:pj_memcpy:
  853|    682|{
  854|    682|    return memcpy(dst, src, size);
  855|    682|}
lock.c:pj_memcpy:
  853|  10.0k|{
  854|  10.0k|    return memcpy(dst, src, size);
  855|  10.0k|}
pool.c:pj_bzero:
  820|  50.1k|{
  821|       |#if defined(PJ_HAS_BZERO) && PJ_HAS_BZERO!=0
  822|       |    bzero(dst, size);
  823|       |#else
  824|  50.1k|    memset(dst, 0, size);
  825|  50.1k|#endif
  826|  50.1k|}
pool_caching.c:pj_bzero:
  820|  1.24k|{
  821|       |#if defined(PJ_HAS_BZERO) && PJ_HAS_BZERO!=0
  822|       |    bzero(dst, size);
  823|       |#else
  824|  1.24k|    memset(dst, 0, size);
  825|  1.24k|#endif
  826|  1.24k|}
pool_caching.c:pj_memcpy:
  853|  1.24k|{
  854|  1.24k|    return memcpy(dst, src, size);
  855|  1.24k|}
sock_common.c:pj_bzero:
  820|  3.31k|{
  821|       |#if defined(PJ_HAS_BZERO) && PJ_HAS_BZERO!=0
  822|       |    bzero(dst, size);
  823|       |#else
  824|  3.31k|    memset(dst, 0, size);
  825|  3.31k|#endif
  826|  3.31k|}
sock_common.c:pj_memcpy:
  853|  2.38k|{
  854|  2.38k|    return memcpy(dst, src, size);
  855|  2.38k|}
sock_common.c:pj_memcmp:
  881|  2.60k|{
  882|  2.60k|    return memcmp(buf1, buf2, size);
  883|  2.60k|}
sock_qos_common.c:pj_memcpy:
  853|    341|{
  854|    341|    return memcpy(dst, src, size);
  855|    341|}
string.c:pj_memcpy:
  853|  14.0k|{
  854|  14.0k|    return memcpy(dst, src, size);
  855|  14.0k|}
string.c:pj_memcmp:
  881|    641|{
  882|    641|    return memcmp(buf1, buf2, size);
  883|    641|}
timer.c:pj_bzero:
  820|    896|{
  821|       |#if defined(PJ_HAS_BZERO) && PJ_HAS_BZERO!=0
  822|       |    bzero(dst, size);
  823|       |#else
  824|    896|    memset(dst, 0, size);
  825|    896|#endif
  826|    896|}
timer.c:pj_memcpy:
  853|    896|{
  854|    896|    return memcpy(dst, src, size);
  855|    896|}

pj_str:
   24|  12.6k|{
   25|  12.6k|    pj_str_t dst;
   26|  12.6k|    dst.ptr = str;
   27|  12.6k|    dst.slen = str ? pj_ansi_strlen(str) : 0;
  ------------------
  |  |   69|  12.6k|#define pj_ansi_strlen          strlen
  ------------------
  |  Branch (27:16): [True: 12.6k, False: 0]
  ------------------
   28|  12.6k|    return dst;
   29|  12.6k|}
pj_strdup:
   34|  17.2k|{
   35|  17.2k|    pj_assert(src->slen >= 0);
  ------------------
  |  |   65|  17.2k|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (35:5): [True: 0, False: 17.2k]
  |  Branch (35:5): [True: 17.2k, False: 0]
  ------------------
   36|       |
   37|       |    /* Without this, destination will be corrupted */
   38|  17.2k|    if (dst == src)
  ------------------
  |  Branch (38:9): [True: 0, False: 17.2k]
  ------------------
   39|      0|        return dst;
   40|       |
   41|  17.2k|    if (src->slen > 0) {
  ------------------
  |  Branch (41:9): [True: 13.6k, False: 3.52k]
  ------------------
   42|  13.6k|        dst->ptr = (char*)pj_pool_alloc(pool, src->slen);
   43|  13.6k|        pj_memcpy(dst->ptr, src->ptr, src->slen);
   44|  13.6k|    }
   45|  17.2k|    dst->slen = (src->slen < 0)? 0: src->slen;
  ------------------
  |  Branch (45:17): [True: 0, False: 17.2k]
  ------------------
   46|  17.2k|    return dst;
   47|  17.2k|}
pj_strdup2:
   73|    341|{
   74|    341|    dst->slen = src ? pj_ansi_strlen(src) : 0;
  ------------------
  |  |   69|    341|#define pj_ansi_strlen          strlen
  ------------------
  |  Branch (74:17): [True: 341, False: 0]
  ------------------
   75|    341|    if (dst->slen) {
  ------------------
  |  Branch (75:9): [True: 341, False: 0]
  ------------------
   76|    341|        dst->ptr = (char*)pj_pool_alloc(pool, dst->slen);
   77|    341|        pj_memcpy(dst->ptr, src, dst->slen);
   78|    341|    } else {
   79|       |        dst->ptr = NULL;
   80|      0|    }
   81|    341|    return dst;
   82|    341|}
pj_strcmp:
  162|    647|{
  163|    647|    pj_assert(str1->slen >= 0);
  ------------------
  |  |   65|    647|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (163:5): [True: 0, False: 647]
  |  Branch (163:5): [True: 647, False: 0]
  ------------------
  164|    647|    pj_assert(str2->slen >= 0);
  ------------------
  |  |   65|    647|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (164:5): [True: 0, False: 647]
  |  Branch (164:5): [True: 647, False: 0]
  ------------------
  165|       |
  166|    647|    if (str1->slen <= 0) {
  ------------------
  |  Branch (166:9): [True: 6, False: 641]
  ------------------
  167|      6|        return str2->slen<=0 ? 0 : -1;
  ------------------
  |  Branch (167:16): [True: 0, False: 6]
  ------------------
  168|    641|    } else if (str2->slen <= 0) {
  ------------------
  |  Branch (168:16): [True: 0, False: 641]
  ------------------
  169|      0|        return 1;
  170|    641|    } else {
  171|    641|        pj_size_t min = (str1->slen < str2->slen)? str1->slen : str2->slen;
  ------------------
  |  Branch (171:25): [True: 91, False: 550]
  ------------------
  172|    641|        int res = pj_memcmp(str1->ptr, str2->ptr, min);
  173|    641|        if (res == 0) {
  ------------------
  |  Branch (173:13): [True: 484, False: 157]
  ------------------
  174|    484|            return (str1->slen < str2->slen) ? -1 :
  ------------------
  |  Branch (174:20): [True: 3, False: 481]
  ------------------
  175|    484|                    (str1->slen == str2->slen ? 0 : 1);
  ------------------
  |  Branch (175:22): [True: 458, False: 23]
  ------------------
  176|    484|        } else {
  177|    157|            return res;
  178|    157|        }
  179|    641|    }
  180|    647|}
pj_stricmp:
  236|    223|{
  237|    223|    pj_assert(str1->slen >= 0);
  ------------------
  |  |   65|    223|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (237:5): [True: 0, False: 223]
  |  Branch (237:5): [True: 223, False: 0]
  ------------------
  238|    223|    pj_assert(str2->slen >= 0);
  ------------------
  |  |   65|    223|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (238:5): [True: 0, False: 223]
  |  Branch (238:5): [True: 223, False: 0]
  ------------------
  239|       |
  240|    223|    if (str1->slen <= 0) {
  ------------------
  |  Branch (240:9): [True: 1, False: 222]
  ------------------
  241|      1|        return str2->slen<=0 ? 0 : -1;
  ------------------
  |  Branch (241:16): [True: 0, False: 1]
  ------------------
  242|    222|    } else if (str2->slen <= 0) {
  ------------------
  |  Branch (242:16): [True: 0, False: 222]
  ------------------
  243|      0|        return 1;
  244|    222|    } else {
  245|    222|        pj_size_t min = (str1->slen < str2->slen)? str1->slen : str2->slen;
  ------------------
  |  Branch (245:25): [True: 10, False: 212]
  ------------------
  246|    222|        int res = pj_ansi_strnicmp(str1->ptr, str2->ptr, min);
  ------------------
  |  |   96|    222|#define pj_ansi_strnicmp        strncasecmp
  ------------------
  247|    222|        if (res == 0) {
  ------------------
  |  Branch (247:13): [True: 82, False: 140]
  ------------------
  248|     82|            return (str1->slen < str2->slen) ? -1 :
  ------------------
  |  Branch (248:20): [True: 2, False: 80]
  ------------------
  249|     82|                    (str1->slen == str2->slen ? 0 : 1);
  ------------------
  |  Branch (249:22): [True: 65, False: 15]
  ------------------
  250|    140|        } else {
  251|    140|            return res;
  252|    140|        }
  253|    222|    }
  254|    223|}

pj_activesock_cfg_default:
  125|    341|{
  126|    341|    pj_bzero(cfg, sizeof(*cfg));
  127|    341|    cfg->async_cnt = 1;
  128|    341|    cfg->concurrency = -1;
  129|    341|    cfg->whole_data = PJ_TRUE;
  130|    341|    cfg->sock_cloexec = PJ_TRUE;
  131|    341|}
pj_activesock_create:
  199|    341|{
  200|    341|    pj_activesock_t *asock;
  201|    341|    pj_ioqueue_callback ioq_cb;
  202|    341|    pj_status_t status;
  203|       |
  204|    341|    PJ_ASSERT_RETURN(pool && ioqueue && cb && p_asock, PJ_EINVAL);
  ------------------
  |  |   97|    341|            do { \
  |  |   98|  2.04k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 341, False: 0]
  |  |  |  Branch (98:23): [True: 341, False: 0]
  |  |  |  Branch (98:23): [True: 341, False: 0]
  |  |  |  Branch (98:23): [True: 341, False: 0]
  |  |  ------------------
  |  |   99|    341|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 341]
  |  |  ------------------
  ------------------
  |  Branch (204:5): [True: 0, False: 0]
  |  Branch (204:5): [True: 0, False: 0]
  |  Branch (204:5): [True: 0, False: 0]
  |  Branch (204:5): [True: 0, False: 0]
  |  Branch (204:5): [True: 0, False: 0]
  |  Branch (204:5): [True: 0, False: 0]
  |  Branch (204:5): [True: 0, False: 0]
  |  Branch (204:5): [True: 0, False: 0]
  ------------------
  205|    341|    PJ_ASSERT_RETURN(sock>=0 && sock!=PJ_INVALID_SOCKET, PJ_EINVAL);
  ------------------
  |  |   97|    341|            do { \
  |  |   98|    682|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 341, False: 0]
  |  |  |  Branch (98:23): [True: 341, False: 0]
  |  |  ------------------
  |  |   99|    341|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 341]
  |  |  ------------------
  ------------------
  |  Branch (205:5): [True: 0, False: 0]
  |  Branch (205:5): [True: 0, False: 0]
  |  Branch (205:5): [True: 0, False: 0]
  |  Branch (205:5): [True: 0, False: 0]
  ------------------
  206|    341|    PJ_ASSERT_RETURN((sock_type & 0xF)==pj_SOCK_STREAM() ||
  ------------------
  |  |   97|    341|            do { \
  |  |   98|    682|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 0, False: 341]
  |  |  |  Branch (98:23): [True: 341, False: 0]
  |  |  ------------------
  |  |   99|    341|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 341]
  |  |  ------------------
  ------------------
  |  Branch (206:5): [True: 0, False: 0]
  |  Branch (206:5): [True: 0, False: 0]
  |  Branch (206:5): [True: 0, False: 0]
  |  Branch (206:5): [True: 0, False: 0]
  ------------------
  207|    341|                     (sock_type & 0xF)==pj_SOCK_DGRAM(), PJ_EINVAL);
  208|    341|    PJ_ASSERT_RETURN(!opt || opt->async_cnt >= 1, PJ_EINVAL);
  ------------------
  |  |   97|    341|            do { \
  |  |   98|    682|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 0, False: 341]
  |  |  |  Branch (98:23): [True: 341, False: 0]
  |  |  ------------------
  |  |   99|    341|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 341]
  |  |  ------------------
  ------------------
  |  Branch (208:5): [True: 0, False: 0]
  |  Branch (208:5): [True: 0, False: 0]
  |  Branch (208:5): [True: 0, False: 0]
  |  Branch (208:5): [True: 0, False: 0]
  ------------------
  209|       |
  210|    341|    asock = PJ_POOL_ZALLOC_T(pool, pj_activesock_t);
  ------------------
  |  |  583|    341|            ((type*)pj_pool_zalloc(pool, sizeof(type)))
  ------------------
  211|    341|    asock->ioqueue = ioqueue;
  212|    341|    asock->stream_oriented = ((sock_type & 0xF) == pj_SOCK_STREAM());
  ------------------
  |  |  165|    341|#   define pj_SOCK_STREAM() PJ_SOCK_STREAM
  ------------------
  213|    341|    asock->async_count = (opt? opt->async_cnt : 1);
  ------------------
  |  Branch (213:27): [True: 341, False: 0]
  ------------------
  214|    341|    asock->whole_data = (opt? opt->whole_data : 1);
  ------------------
  |  Branch (214:26): [True: 341, False: 0]
  ------------------
  215|    341|    asock->max_loop = PJ_ACTIVESOCK_MAX_LOOP;
  ------------------
  |  |   35|    341|#define PJ_ACTIVESOCK_MAX_LOOP      50
  ------------------
  216|    341|    asock->user_data = user_data;
  217|    341|    pj_memcpy(&asock->cb, cb, sizeof(*cb));
  218|       |
  219|    341|    pj_bzero(&ioq_cb, sizeof(ioq_cb));
  220|    341|    ioq_cb.on_read_complete = &ioqueue_on_read_complete;
  221|    341|    ioq_cb.on_write_complete = &ioqueue_on_write_complete;
  222|    341|#if PJ_HAS_TCP
  223|    341|    ioq_cb.on_connect_complete = &ioqueue_on_connect_complete;
  224|    341|    ioq_cb.on_accept_complete = &ioqueue_on_accept_complete;
  225|    341|#endif
  226|       |
  227|    341|    status = pj_ioqueue_register_sock2(pool, ioqueue, sock,
  228|    341|                                       (opt? opt->grp_lock : NULL),
  ------------------
  |  Branch (228:41): [True: 341, False: 0]
  ------------------
  229|    341|                                       asock, &ioq_cb, &asock->key);
  230|    341|    if (status != PJ_SUCCESS) {
  ------------------
  |  Branch (230:9): [True: 0, False: 341]
  ------------------
  231|      0|        pj_activesock_close(asock);
  232|      0|        return status;
  233|      0|    }
  234|       |    
  235|    341|    if (asock->whole_data) {
  ------------------
  |  Branch (235:9): [True: 341, False: 0]
  ------------------
  236|       |        /* Must disable concurrency otherwise there is a race condition */
  237|    341|        pj_ioqueue_set_concurrency(asock->key, 0);
  238|    341|    } else if (opt && opt->concurrency >= 0) {
  ------------------
  |  Branch (238:16): [True: 0, False: 0]
  |  Branch (238:23): [True: 0, False: 0]
  ------------------
  239|      0|        pj_ioqueue_set_concurrency(asock->key, opt->concurrency);
  240|      0|    }
  241|       |
  242|       |#if defined(PJ_IPHONE_OS_HAS_MULTITASKING_SUPPORT) && \
  243|       |    PJ_IPHONE_OS_HAS_MULTITASKING_SUPPORT!=0
  244|       |    asock->sock = sock;
  245|       |    asock->bg_setting = PJ_ACTIVESOCK_TCP_IPHONE_OS_BG;
  246|       |#endif
  247|       |
  248|    341|    *p_asock = asock;
  249|    341|    return PJ_SUCCESS;
  250|    341|}
pj_activesock_close:
  307|    341|{
  308|    341|    pj_ioqueue_key_t *key;
  309|    341|    pj_bool_t unregister = PJ_FALSE;
  310|       |
  311|    341|    PJ_ASSERT_RETURN(asock, PJ_EINVAL);
  ------------------
  |  |   97|    341|            do { \
  |  |   98|    341|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 341]
  |  |  ------------------
  |  |   99|    341|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 341]
  |  |  ------------------
  ------------------
  |  Branch (311:5): [True: 0, False: 0]
  |  Branch (311:5): [True: 0, False: 0]
  ------------------
  312|    341|    asock->shutdown = SHUT_RX | SHUT_TX;
  313|       |
  314|       |    /* Avoid double unregistration on the key */
  315|    341|    key = asock->key;
  316|    341|    if (key) {
  ------------------
  |  Branch (316:9): [True: 341, False: 0]
  ------------------
  317|    341|        pj_ioqueue_lock_key(key);
  318|    341|        unregister = (asock->key != NULL);
  319|    341|        asock->key = NULL;
  320|    341|        pj_ioqueue_unlock_key(key);
  321|    341|    }
  322|       |
  323|    341|    if (unregister) {
  ------------------
  |  Branch (323:9): [True: 341, False: 0]
  ------------------
  324|    341|        pj_ioqueue_unregister(key);
  325|       |
  326|       |#if defined(PJ_IPHONE_OS_HAS_MULTITASKING_SUPPORT) && \
  327|       |    PJ_IPHONE_OS_HAS_MULTITASKING_SUPPORT!=0
  328|       |        activesock_destroy_iphone_os_stream(asock);
  329|       |#endif  
  330|    341|    }
  331|    341|    return PJ_SUCCESS;
  332|    341|}
pj_activesock_start_recvfrom:
  414|    341|{
  415|    341|    void **readbuf;
  416|    341|    unsigned i;
  417|       |
  418|    341|    PJ_ASSERT_RETURN(asock && pool && buff_size, PJ_EINVAL);
  ------------------
  |  |   97|    341|            do { \
  |  |   98|  1.36k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 341, False: 0]
  |  |  |  Branch (98:23): [True: 341, False: 0]
  |  |  |  Branch (98:23): [True: 341, False: 0]
  |  |  ------------------
  |  |   99|    341|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 341]
  |  |  ------------------
  ------------------
  |  Branch (418:5): [True: 0, False: 0]
  |  Branch (418:5): [True: 0, False: 0]
  |  Branch (418:5): [True: 0, False: 0]
  |  Branch (418:5): [True: 0, False: 0]
  |  Branch (418:5): [True: 0, False: 0]
  |  Branch (418:5): [True: 0, False: 0]
  ------------------
  419|       |
  420|    341|    readbuf = (void**) pj_pool_calloc(pool, asock->async_count, 
  421|    341|                                      sizeof(void*));
  422|       |
  423|    682|    for (i=0; i<asock->async_count; ++i) {
  ------------------
  |  Branch (423:15): [True: 341, False: 341]
  ------------------
  424|    341|        readbuf[i] = pj_pool_alloc(pool, buff_size);
  425|    341|    }
  426|       |
  427|    341|    return pj_activesock_start_recvfrom2(asock, pool, buff_size, 
  428|    341|                                         readbuf, flags);
  429|    341|}
pj_activesock_start_recvfrom2:
  437|    341|{
  438|    341|    unsigned i;
  439|    341|    pj_status_t status;
  440|       |
  441|    341|    PJ_ASSERT_RETURN(asock && pool && buff_size, PJ_EINVAL);
  ------------------
  |  |   97|    341|            do { \
  |  |   98|  1.36k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 341, False: 0]
  |  |  |  Branch (98:23): [True: 341, False: 0]
  |  |  |  Branch (98:23): [True: 341, False: 0]
  |  |  ------------------
  |  |   99|    341|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 341]
  |  |  ------------------
  ------------------
  |  Branch (441:5): [True: 0, False: 0]
  |  Branch (441:5): [True: 0, False: 0]
  |  Branch (441:5): [True: 0, False: 0]
  |  Branch (441:5): [True: 0, False: 0]
  |  Branch (441:5): [True: 0, False: 0]
  |  Branch (441:5): [True: 0, False: 0]
  ------------------
  442|    341|    PJ_ASSERT_RETURN(asock->read_type == TYPE_NONE, PJ_EINVALIDOP);
  ------------------
  |  |   97|    341|            do { \
  |  |   98|    341|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 341]
  |  |  ------------------
  |  |   99|    341|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 341]
  |  |  ------------------
  ------------------
  |  Branch (442:5): [True: 0, False: 0]
  |  Branch (442:5): [True: 0, False: 0]
  ------------------
  443|       |
  444|    341|    asock->read_op = (struct read_op*)
  445|    341|                     pj_pool_calloc(pool, asock->async_count, 
  446|    341|                                    sizeof(struct read_op));
  447|    341|    asock->read_type = TYPE_RECV_FROM;
  448|    341|    asock->read_flags = flags;
  449|       |
  450|    682|    for (i=0; i<asock->async_count; ++i) {
  ------------------
  |  Branch (450:15): [True: 341, False: 341]
  ------------------
  451|    341|        struct read_op *r = &asock->read_op[i];
  452|    341|        pj_ssize_t size_to_read;
  453|       |
  454|    341|        r->pkt = (pj_uint8_t*) readbuf[i];
  455|    341|        size_to_read = r->max_size = buff_size;
  456|    341|        r->src_addr_len = sizeof(r->src_addr);
  457|       |
  458|    341|        status = pj_ioqueue_recvfrom(asock->key, &r->op_key, r->pkt,
  459|    341|                                     &size_to_read, 
  460|    341|                                     PJ_IOQUEUE_ALWAYS_ASYNC | flags,
  ------------------
  |  |  330|    341|#define PJ_IOQUEUE_ALWAYS_ASYNC     ((pj_uint32_t)1 << (pj_uint32_t)31)
  ------------------
  461|    341|                                     &r->src_addr, &r->src_addr_len);
  462|    341|        PJ_ASSERT_RETURN(status != PJ_SUCCESS, PJ_EBUG);
  ------------------
  |  |   97|    341|            do { \
  |  |   98|    341|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 341]
  |  |  ------------------
  |  |   99|    341|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 341]
  |  |  ------------------
  ------------------
  |  Branch (462:9): [True: 0, False: 0]
  |  Branch (462:9): [True: 0, False: 0]
  ------------------
  463|       |
  464|    341|        if (status != PJ_EPENDING)
  ------------------
  |  |  383|    341|#define PJ_EPENDING         (PJ_ERRNO_START_STATUS + 2) /* 70002 */
  |  |  ------------------
  |  |  |  |  521|    341|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|    341|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|    341|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (464:13): [True: 0, False: 341]
  ------------------
  465|      0|            return status;
  466|    341|    }
  467|       |
  468|    341|    return PJ_SUCCESS;
  469|    341|}

pj_getaddrinfo:
   76|  1.23k|{
   77|  1.23k|#if defined(PJ_SOCK_HAS_GETADDRINFO) && PJ_SOCK_HAS_GETADDRINFO!=0
   78|  1.23k|    char nodecopy[PJ_MAX_HOSTNAME];
   79|  1.23k|    pj_bool_t has_addr = PJ_FALSE;
   80|  1.23k|    unsigned i;
   81|       |#if defined(PJ_GETADDRINFO_USE_CFHOST) && PJ_GETADDRINFO_USE_CFHOST!=0
   82|       |    CFStringRef hostname;
   83|       |    CFHostRef hostRef;
   84|       |    pj_status_t status = PJ_SUCCESS;
   85|       |#else
   86|  1.23k|    int rc;
   87|  1.23k|    struct addrinfo hint, *res, *orig_res;
   88|  1.23k|#endif
   89|       |
   90|  1.23k|    PJ_ASSERT_RETURN(nodename && count && *count && ai, PJ_EINVAL);
  ------------------
  |  |   97|  1.23k|            do { \
  |  |   98|  7.42k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 1.23k, False: 0]
  |  |  |  Branch (98:23): [True: 1.23k, False: 0]
  |  |  |  Branch (98:23): [True: 1.23k, False: 0]
  |  |  |  Branch (98:23): [True: 1.23k, False: 0]
  |  |  ------------------
  |  |   99|  1.23k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1.23k]
  |  |  ------------------
  ------------------
  |  Branch (90:5): [True: 0, False: 0]
  |  Branch (90:5): [True: 0, False: 0]
  |  Branch (90:5): [True: 0, False: 0]
  |  Branch (90:5): [True: 0, False: 0]
  |  Branch (90:5): [True: 0, False: 0]
  |  Branch (90:5): [True: 0, False: 0]
  |  Branch (90:5): [True: 0, False: 0]
  |  Branch (90:5): [True: 0, False: 0]
  ------------------
   91|  1.23k|    PJ_ASSERT_RETURN(nodename->ptr && nodename->slen, PJ_EINVAL);
  ------------------
  |  |   97|  1.23k|            do { \
  |  |   98|  2.47k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 1.23k, False: 0]
  |  |  |  Branch (98:23): [True: 1.23k, False: 0]
  |  |  ------------------
  |  |   99|  1.23k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1.23k]
  |  |  ------------------
  ------------------
  |  Branch (91:5): [True: 0, False: 0]
  |  Branch (91:5): [True: 0, False: 0]
  |  Branch (91:5): [True: 0, False: 0]
  |  Branch (91:5): [True: 0, False: 0]
  ------------------
   92|  1.23k|    PJ_ASSERT_RETURN(af==PJ_AF_INET || af==PJ_AF_INET6 ||
  ------------------
  |  |   97|  1.23k|            do { \
  |  |   98|  2.47k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 1.23k, False: 0]
  |  |  |  Branch (98:23): [True: 0, False: 0]
  |  |  |  Branch (98:23): [True: 0, False: 0]
  |  |  ------------------
  |  |   99|  1.23k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1.23k]
  |  |  ------------------
  ------------------
  |  Branch (92:5): [True: 0, False: 0]
  |  Branch (92:5): [True: 0, False: 0]
  |  Branch (92:5): [True: 0, False: 0]
  |  Branch (92:5): [True: 0, False: 0]
  |  Branch (92:5): [True: 0, False: 0]
  |  Branch (92:5): [True: 0, False: 0]
  ------------------
   93|  1.23k|                     af==PJ_AF_UNSPEC, PJ_EINVAL);
   94|       |
   95|       |#if PJ_WIN32_WINCE
   96|       |
   97|       |    /* Check if nodename is IP address */
   98|       |    pj_bzero(&ai[0], sizeof(ai[0]));
   99|       |    if ((af==PJ_AF_INET || af==PJ_AF_UNSPEC) &&
  100|       |        pj_inet_pton(PJ_AF_INET, nodename,
  101|       |                     &ai[0].ai_addr.ipv4.sin_addr) == PJ_SUCCESS)
  102|       |    {
  103|       |        af = PJ_AF_INET;
  104|       |        has_addr = PJ_TRUE;
  105|       |    } else if ((af==PJ_AF_INET6 || af==PJ_AF_UNSPEC) &&
  106|       |               pj_inet_pton(PJ_AF_INET6, nodename,
  107|       |                            &ai[0].ai_addr.ipv6.sin6_addr) == PJ_SUCCESS)
  108|       |    {
  109|       |        af = PJ_AF_INET6;
  110|       |        has_addr = PJ_TRUE;
  111|       |    }
  112|       |
  113|       |    if (has_addr) {
  114|       |        pj_str_t tmp;
  115|       |
  116|       |        tmp.ptr = ai[0].ai_canonname;
  117|       |        pj_strncpy_with_null(&tmp, nodename, PJ_MAX_HOSTNAME);
  118|       |        ai[0].ai_addr.addr.sa_family = (pj_uint16_t)af;
  119|       |        *count = 1;
  120|       |
  121|       |        return PJ_SUCCESS;
  122|       |    }
  123|       |
  124|       |#else /* PJ_WIN32_WINCE */
  125|  1.23k|    PJ_UNUSED_ARG(has_addr);
  ------------------
  |  | 1537|  1.23k|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
  126|  1.23k|#endif
  127|       |
  128|       |    /* Copy node name to null terminated string. */
  129|  1.23k|    if (nodename->slen >= PJ_MAX_HOSTNAME)
  ------------------
  |  |  680|  1.23k|#  define PJ_MAX_HOSTNAME           (254)
  ------------------
  |  Branch (129:9): [True: 0, False: 1.23k]
  ------------------
  130|      0|        return PJ_ENAMETOOLONG;
  ------------------
  |  |  398|      0|#define PJ_ENAMETOOLONG     (PJ_ERRNO_START_STATUS + 5) /* 70005 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  131|  1.23k|    pj_memcpy(nodecopy, nodename->ptr, nodename->slen);
  132|  1.23k|    nodecopy[nodename->slen] = '\0';
  133|       |
  134|       |#if defined(PJ_GETADDRINFO_USE_CFHOST) && PJ_GETADDRINFO_USE_CFHOST!=0
  135|       |    hostname =  CFStringCreateWithCStringNoCopy(kCFAllocatorDefault, nodecopy,
  136|       |                                                kCFStringEncodingASCII,
  137|       |                                                kCFAllocatorNull);
  138|       |    hostRef = CFHostCreateWithName(kCFAllocatorDefault, hostname);
  139|       |    if (CFHostStartInfoResolution(hostRef, kCFHostAddresses, nil)) {
  140|       |        CFArrayRef addrRef = CFHostGetAddressing(hostRef, nil);
  141|       |        i = 0;
  142|       |        if (addrRef != nil) {
  143|       |            CFIndex idx, naddr;
  144|       |            
  145|       |            naddr = CFArrayGetCount(addrRef);
  146|       |            for (idx = 0; idx < naddr && i < *count; idx++) {
  147|       |                struct sockaddr *addr;
  148|       |                size_t addr_size;
  149|       |                
  150|       |                addr = (struct sockaddr *)
  151|       |                       CFDataGetBytePtr(CFArrayGetValueAtIndex(addrRef, idx));
  152|       |                /* This should not happen. */
  153|       |                pj_assert(addr);
  154|       |                
  155|       |                /* Ignore unwanted address families */
  156|       |                if (af!=PJ_AF_UNSPEC && addr->sa_family != af)
  157|       |                    continue;
  158|       |
  159|       |                /* Store canonical name */
  160|       |                pj_ansi_strxcpy(ai[i].ai_canonname, nodecopy, 
  161|       |                                sizeof(ai[i].ai_canonname));
  162|       |                
  163|       |                /* Store address */
  164|       |                addr_size = sizeof(*addr);
  165|       |                if (addr->sa_family == PJ_AF_INET6) {
  166|       |                    addr_size = addr->sa_len;
  167|       |                }
  168|       |                PJ_ASSERT_ON_FAIL(addr_size <= sizeof(pj_sockaddr), continue);
  169|       |                pj_memcpy(&ai[i].ai_addr, addr, addr_size);
  170|       |                PJ_SOCKADDR_RESET_LEN(&ai[i].ai_addr);
  171|       |                
  172|       |                i++;
  173|       |            }
  174|       |        }
  175|       |        
  176|       |        *count = i;
  177|       |        if (*count == 0)
  178|       |            status = PJ_ERESOLVE;
  179|       |
  180|       |    } else {
  181|       |        status = PJ_ERESOLVE;
  182|       |    }
  183|       |    
  184|       |    CFRelease(hostRef);
  185|       |    CFRelease(hostname);
  186|       |    
  187|       |    return status;
  188|       |
  189|       |#elif defined(PJ_GETADDRINFO_USE_ANDROID) && PJ_GETADDRINFO_USE_ANDROID!=0
  190|       |    /* Unlike Android API functions which can be safeguarded with
  191|       |     * __builtin_available, functions from libraries like libc.so
  192|       |     * cannot be loaded directly, even surrounded by a statement
  193|       |     * checking their availability. ns_initparse and ns_parserr are only
  194|       |     * available since Android API 23. This leads to failure of compiling
  195|       |     * for Android API 21. Hence, the two functions are dynamically loaded
  196|       |     * so that the library can be compiled with the minimal API 21.
  197|       |     * Otherwise, PJLIB would only compile with APP_PLATFORM=23 at minimum.
  198|       |     */
  199|       |	 
  200|       |
  201|       |    if (__builtin_available(android 29, *)) {
  202|       |        /* Define function pointers type for ns_initparse and ns_parserr.
  203|       |         * These functions are in libc.so in Android (Bionic) and not
  204|       |         * in libresolv.so like usually in Linux */
  205|       |        typedef int (*ns_initparse_fn)(const unsigned char *, int, void *);
  206|       |        typedef int (*ns_parserr_fn)(const void *, int, int, void *);
  207|       |        /* Initialize function pointers to NULL */
  208|       |        ns_initparse_fn ns_initparse_ptr = NULL;
  209|       |        ns_parserr_fn ns_parserr_ptr = NULL;
  210|       |        /* Load the libc.so library containing network functions */
  211|       |        void *libc_handle = dlopen("libc.so", RTLD_NOW);
  212|       |        if (libc_handle) {
  213|       |            /* Get the ns_initparse, ns_initparse functions from library */
  214|       |            ns_initparse_ptr = (ns_initparse_fn)
  215|       |                               dlsym(libc_handle,
  216|       |                               "ns_initparse");
  217|       |            ns_parserr_ptr = (ns_parserr_fn)
  218|       |                             dlsym(libc_handle,
  219|       |                             "ns_parserr");
  220|       |
  221|       |            /* Non-null pointers mean DNS functions are properly loaded */
  222|       |            if (ns_initparse_ptr &&
  223|       |                ns_parserr_ptr) {
  224|       |                pj_bzero(&hint, sizeof(hint));
  225|       |                hint.ai_family = af;
  226|       |                /* Zero value of ai_socktype means the implementation shall
  227|       |                 * attempt to resolve the service name for all supported
  228|       |                 * socket types */
  229|       |                hint.ai_socktype = SOCK_STREAM;
  230|       |
  231|       |                /* Perform asynchronous DNS resolution
  232|       |                 * Use NETWORK_UNSPECIFIED lets system choose the network */
  233|       |                unsigned int netid = NETWORK_UNSPECIFIED;
  234|       |				/* Buffer for the DNS response */
  235|       |                unsigned char answer[NS_PACKETSZ];
  236|       |                int rcode = -1;
  237|       |                struct addrinfo *result = NULL, *last = NULL;
  238|       |
  239|       |                /* Step 1: Send DNS query */
  240|       |                int resp_handle = android_res_nquery(
  241|       |                                netid, nodecopy, ns_c_in,
  242|       |                                af == PJ_AF_INET ? ns_t_a :
  243|       |                                af == PJ_AF_INET6 ? ns_t_aaaa :
  244|       |                                ns_t_a,
  245|       |                                0);
  246|       |                if (resp_handle < 0) {
  247|       |                    printf("android_res_nquery() failed\n");
  248|       |                    return PJ_ERESOLVE;
  249|       |                }
  250|       |
  251|       |                /* Step 2: Wait for response using poll() */
  252|       |                struct pollfd fds;
  253|       |                fds.fd = resp_handle;
  254|       |                fds.events = POLLIN;
  255|       |                int ret = poll(&fds, 1, ANDROID_DNS_TIMEOUT_MS);
  256|       |
  257|       |                if (ret <= 0) {
  258|       |                    PJ_LOG(4,(THIS_FILE,"Poll timeout or error"));
  259|       |                    android_res_cancel(resp_handle);
  260|       |                    return PJ_ERESOLVE;
  261|       |                }
  262|       |                /* Step 3: Get DNS response */
  263|       |                int response_size = android_res_nresult(
  264|       |                                  resp_handle, &rcode, answer, sizeof(answer));
  265|       |                if (response_size < 0) {
  266|       |                    PJ_LOG(4,(THIS_FILE,
  267|       |                              "android_res_nresult() failed"));
  268|       |                    return PJ_ERESOLVE;
  269|       |                }
  270|       |
  271|       |                /* Step 4: Parse the DNS response */
  272|       |                ns_msg msg;
  273|       |                ns_rr rr;
  274|       |                int num_records, resolved_count = 0;
  275|       |
  276|       |                if (ns_initparse_ptr(answer, response_size, &msg) < 0) {
  277|       |                    PJ_LOG(4,(THIS_FILE,
  278|       |                              "Failed to parse DNS response"));
  279|       |                    return PJ_ERESOLVE;
  280|       |                }
  281|       |
  282|       |                num_records = ns_msg_count(msg, ns_s_an);
  283|       |                if (num_records == 0) {
  284|       |                    PJ_LOG(4,(THIS_FILE,
  285|       |                              "No DNS %s entries found for %s",
  286|       |                              af == PJ_AF_INET ? "A" :
  287|       |                              af == PJ_AF_INET6 ? "AAAA" :
  288|       |                              "A",
  289|       |                              nodecopy));
  290|       |                    return PJ_ERESOLVE;
  291|       |                }
  292|       |
  293|       |                /* Process each answer record */
  294|       |                for (i = 0; i < num_records && resolved_count < *count; i++) {
  295|       |                    if (ns_parserr_ptr(&msg, ns_s_an, i, &rr) < 0) {
  296|       |                        continue;
  297|       |                    }
  298|       |
  299|       |                    int type = ns_rr_type(rr);
  300|       |                    int rdlen = ns_rr_rdlen(rr);
  301|       |                    const unsigned char *rdata = ns_rr_rdata(rr);
  302|       |
  303|       |                    /* We handle A records (IPv4) and AAAA records (IPv6) */
  304|       |                    if ((type == ns_t_a && rdlen == 4) || (type == ns_t_aaaa
  305|       |						&& rdlen == 16)) {
  306|       |
  307|       |                        /* For IPv4, fill a temporary sockaddr_in */
  308|       |                        /* For IPv6 fill a sockaddr_in6. */
  309|       |                        if (type == ns_t_a) {
  310|       |                            struct sockaddr_in addr;
  311|       |                            pj_bzero(&addr, sizeof(addr));
  312|       |                            addr.sin_family = PJ_AF_INET;
  313|       |                            pj_memcpy(&addr.sin_addr, rdata, 4);
  314|       |                            /* Copy the sockaddr into pj_addrinfo.ai_addr */
  315|       |                            pj_memcpy(&ai[resolved_count].ai_addr,
  316|       |                                      &addr, sizeof(addr));
  317|       |                        } else {
  318|       |                            /* type == ns_t_aaaa */
  319|       |                            struct sockaddr_in6 addr6;
  320|       |                            pj_bzero(&addr6, sizeof(addr6));
  321|       |                            addr6.sin6_family = PJ_AF_INET6;
  322|       |                            pj_memcpy(&addr6.sin6_addr, rdata, 16);
  323|       |                            pj_memcpy(&ai[resolved_count].ai_addr,
  324|       |                                      &addr6, sizeof(addr6));
  325|       |                        }
  326|       |
  327|       |                        /* Store canonical name into ai[].ai_canonname */
  328|       |                        pj_ansi_strxcpy(ai[resolved_count].ai_canonname,
  329|       |                                nodename->ptr,
  330|       |                                sizeof(ai[resolved_count].ai_canonname));
  331|       |                        resolved_count++;
  332|       |                    }
  333|       |                }
  334|       |
  335|       |                /* Update the count with the number of valid entries found. */
  336|       |                *count = resolved_count;
  337|       |
  338|       |                if (resolved_count == 0) {
  339|       |                    return PJ_ERESOLVE;
  340|       |                }
  341|       |                return PJ_SUCCESS;
  342|       |            }
  343|       |        }
  344|       |    }
  345|       |    /* Android fallback to getaddrinfo() for API levels < 29 */
  346|       |    pj_bzero(&hint, sizeof(hint));
  347|       |    hint.ai_family = af;
  348|       |    /* Zero value of ai_socktype means the implementation shall attempt
  349|       |     * to resolve the service name for all supported socket types */
  350|       |    hint.ai_socktype = 0;
  351|       |
  352|       |    rc = getaddrinfo(nodecopy, NULL, &hint, &res);
  353|       |    if (rc != 0)
  354|       |        return PJ_ERESOLVE;
  355|       |
  356|       |    orig_res = res;
  357|       |
  358|       |    /* Enumerate each item in the result */
  359|       |    for (i=0; i<*count && res; res=res->ai_next) {
  360|       |        unsigned j;
  361|       |        pj_bool_t duplicate_found = PJ_FALSE;
  362|       |
  363|       |        /* Ignore unwanted address families */
  364|       |        if (af!=PJ_AF_UNSPEC && res->ai_family != af)
  365|       |            continue;
  366|       |
  367|       |        if (res->ai_socktype != pj_SOCK_DGRAM() &&
  368|       |            res->ai_socktype != pj_SOCK_STREAM() &&
  369|       |            /* It is possible that the result's sock type
  370|       |             * is unspecified.
  371|       |             */
  372|       |            res->ai_socktype != 0)
  373|       |            {
  374|       |            continue;
  375|       |            }
  376|       |
  377|       |        /* Add current address in the resulting list if there
  378|       |         * is no duplicates only. */
  379|       |        for (j = 0; j < i; j++) {
  380|       |            if (!pj_sockaddr_cmp(&ai[j].ai_addr, res->ai_addr)) {
  381|       |                duplicate_found = PJ_TRUE;
  382|       |                break;
  383|       |            }
  384|       |        }
  385|       |        if (duplicate_found) {
  386|       |            continue;
  387|       |        }
  388|       |
  389|       |        /* Store canonical name (possibly truncating the name) */
  390|       |        if (res->ai_canonname) {
  391|       |            pj_ansi_strxcpy(ai[i].ai_canonname, res->ai_canonname,
  392|       |                            sizeof(ai[i].ai_canonname));
  393|       |        } else {
  394|       |            pj_ansi_strxcpy(ai[i].ai_canonname, nodecopy,
  395|       |                            sizeof(ai[i].ai_canonname));
  396|       |        }
  397|       |
  398|       |        /* Store address */
  399|       |        PJ_ASSERT_ON_FAIL(res->ai_addrlen <= sizeof(pj_sockaddr), continue);
  400|       |        pj_memcpy(&ai[i].ai_addr, res->ai_addr, res->ai_addrlen);
  401|       |        PJ_SOCKADDR_RESET_LEN(&ai[i].ai_addr);
  402|       |
  403|       |        /* Next slot */
  404|       |        ++i;
  405|       |    }
  406|       |
  407|       |    *count = i;
  408|       |
  409|       |    freeaddrinfo(orig_res);
  410|       |
  411|       |    /* Done */
  412|       |    return (*count > 0? PJ_SUCCESS : PJ_ERESOLVE);
  413|       |
  414|       |#else
  415|       |    /* Call getaddrinfo() */
  416|  1.23k|    pj_bzero(&hint, sizeof(hint));
  417|  1.23k|    hint.ai_family = af;
  418|       |    /* Zero value of ai_socktype means the implementation shall attempt
  419|       |     * to resolve the service name for all supported socket types */
  420|  1.23k|    hint.ai_socktype = 0;
  421|       |
  422|  1.23k|    rc = getaddrinfo(nodecopy, NULL, &hint, &res);
  423|  1.23k|    if (rc != 0)
  ------------------
  |  Branch (423:9): [True: 0, False: 1.23k]
  ------------------
  424|      0|        return PJ_ERESOLVE;
  ------------------
  |  |  464|      0|#define PJ_ERESOLVE         (PJ_ERRNO_START_STATUS + 18)/* 70018 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  425|       |
  426|  1.23k|    orig_res = res;
  427|       |
  428|       |    /* Enumerate each item in the result */
  429|  4.26k|    for (i=0; i<*count && res; res=res->ai_next) {
  ------------------
  |  Branch (429:15): [True: 3.92k, False: 341]
  |  Branch (429:27): [True: 3.02k, False: 896]
  ------------------
  430|  3.02k|        unsigned j;
  431|  3.02k|        pj_bool_t duplicate_found = PJ_FALSE;
  432|       |
  433|       |        /* Ignore unwanted address families */
  434|  3.02k|        if (af!=PJ_AF_UNSPEC && res->ai_family != af)
  ------------------
  |  Branch (434:13): [True: 3.02k, False: 0]
  |  Branch (434:33): [True: 0, False: 3.02k]
  ------------------
  435|      0|            continue;
  436|       |
  437|  3.02k|        if (res->ai_socktype != pj_SOCK_DGRAM() &&
  ------------------
  |  |  167|  6.05k|#   define pj_SOCK_DGRAM()  PJ_SOCK_DGRAM
  ------------------
  |  Branch (437:13): [True: 2.13k, False: 896]
  ------------------
  438|  2.13k|            res->ai_socktype != pj_SOCK_STREAM() &&
  ------------------
  |  |  165|  5.16k|#   define pj_SOCK_STREAM() PJ_SOCK_STREAM
  ------------------
  |  Branch (438:13): [True: 896, False: 1.23k]
  ------------------
  439|       |            /* It is possible that the result's sock type
  440|       |             * is unspecified.
  441|       |             */
  442|    896|            res->ai_socktype != 0)
  ------------------
  |  Branch (442:13): [True: 896, False: 0]
  ------------------
  443|    896|        {
  444|    896|                continue;
  445|    896|        }
  446|       |
  447|       |        /* Add current address in the resulting list if there
  448|       |         * is no duplicates only. */
  449|  2.13k|        for (j = 0; j < i; j++) {
  ------------------
  |  Branch (449:21): [True: 896, False: 1.23k]
  ------------------
  450|    896|            if (!pj_sockaddr_cmp(&ai[j].ai_addr, res->ai_addr)) {
  ------------------
  |  Branch (450:17): [True: 896, False: 0]
  ------------------
  451|    896|                duplicate_found = PJ_TRUE;
  452|    896|                break;
  453|    896|            }
  454|    896|        }
  455|  2.13k|        if (duplicate_found) {
  ------------------
  |  Branch (455:13): [True: 896, False: 1.23k]
  ------------------
  456|    896|            continue;
  457|    896|        }
  458|       |
  459|       |        /* Store canonical name (possibly truncating the name) */
  460|  1.23k|        if (res->ai_canonname) {
  ------------------
  |  Branch (460:13): [True: 0, False: 1.23k]
  ------------------
  461|      0|            pj_ansi_strxcpy(ai[i].ai_canonname, res->ai_canonname,
  462|      0|                            sizeof(ai[i].ai_canonname));
  463|  1.23k|        } else {
  464|  1.23k|            pj_ansi_strxcpy(ai[i].ai_canonname, nodecopy,
  465|  1.23k|                            sizeof(ai[i].ai_canonname));
  466|  1.23k|        }
  467|       |
  468|       |        /* Store address */
  469|  1.23k|        PJ_ASSERT_ON_FAIL(res->ai_addrlen <= sizeof(pj_sockaddr), continue);
  ------------------
  |  |  111|  1.23k|            { \
  |  |  112|  1.23k|                pj_assert(expr); \
  |  |  ------------------
  |  |  |  |   65|  1.23k|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  113|  1.23k|                if (!(expr)) exec_on_fail; \
  |  |  ------------------
  |  |  |  Branch (113:21): [True: 0, False: 1.23k]
  |  |  ------------------
  |  |  114|  1.23k|            }
  ------------------
  |  Branch (469:9): [True: 0, False: 1.23k]
  |  Branch (469:9): [True: 1.23k, False: 0]
  ------------------
  470|  1.23k|        pj_memcpy(&ai[i].ai_addr, res->ai_addr, res->ai_addrlen);
  471|  1.23k|        PJ_SOCKADDR_RESET_LEN(&ai[i].ai_addr);
  472|       |
  473|       |        /* Next slot */
  474|  1.23k|        ++i;
  475|  1.23k|    }
  476|       |
  477|  1.23k|    *count = i;
  478|       |
  479|  1.23k|    freeaddrinfo(orig_res);
  480|       |
  481|       |    /* Done */
  482|  1.23k|    return (*count > 0? PJ_SUCCESS : PJ_ERESOLVE);
  ------------------
  |  |  464|      0|#define PJ_ERESOLVE         (PJ_ERRNO_START_STATUS + 18)/* 70018 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (482:13): [True: 1.23k, False: 0]
  ------------------
  483|  1.23k|#endif
  484|       |
  485|       |#else   /* PJ_SOCK_HAS_GETADDRINFO */
  486|       |    pj_bool_t has_addr = PJ_FALSE;
  487|       |
  488|       |    PJ_ASSERT_RETURN(count && *count, PJ_EINVAL);
  489|       |
  490|       |#if PJ_WIN32_WINCE
  491|       |
  492|       |    /* Check if nodename is IP address */
  493|       |    pj_bzero(&ai[0], sizeof(ai[0]));
  494|       |    if ((af==PJ_AF_INET || af==PJ_AF_UNSPEC) &&
  495|       |        pj_inet_pton(PJ_AF_INET, nodename,
  496|       |                     &ai[0].ai_addr.ipv4.sin_addr) == PJ_SUCCESS)
  497|       |    {
  498|       |        af = PJ_AF_INET;
  499|       |        has_addr = PJ_TRUE;
  500|       |    }
  501|       |    else if ((af==PJ_AF_INET6 || af==PJ_AF_UNSPEC) &&
  502|       |             pj_inet_pton(PJ_AF_INET6, nodename,
  503|       |                          &ai[0].ai_addr.ipv6.sin6_addr) == PJ_SUCCESS)
  504|       |    {
  505|       |        af = PJ_AF_INET6;
  506|       |        has_addr = PJ_TRUE;
  507|       |    }
  508|       |
  509|       |    if (has_addr) {
  510|       |        pj_str_t tmp;
  511|       |
  512|       |        tmp.ptr = ai[0].ai_canonname;
  513|       |        pj_strncpy_with_null(&tmp, nodename, PJ_MAX_HOSTNAME);
  514|       |        ai[0].ai_addr.addr.sa_family = (pj_uint16_t)af;
  515|       |        *count = 1;
  516|       |
  517|       |        return PJ_SUCCESS;
  518|       |    }
  519|       |
  520|       |#else /* PJ_WIN32_WINCE */
  521|       |    PJ_UNUSED_ARG(has_addr);
  522|       |#endif
  523|       |
  524|       |    if (af == PJ_AF_INET || af == PJ_AF_UNSPEC) {
  525|       |        pj_hostent he;
  526|       |        unsigned i, max_count;
  527|       |        pj_status_t status;
  528|       |        
  529|       |        /* VC6 complains that "he" is uninitialized */
  530|       |        #ifdef _MSC_VER
  531|       |        pj_bzero(&he, sizeof(he));
  532|       |        #endif
  533|       |
  534|       |        status = pj_gethostbyname(nodename, &he);
  535|       |        if (status != PJ_SUCCESS)
  536|       |            return status;
  537|       |
  538|       |        max_count = *count;
  539|       |        *count = 0;
  540|       |
  541|       |        pj_bzero(ai, max_count * sizeof(pj_addrinfo));
  542|       |
  543|       |        for (i=0; he.h_addr_list[i] && *count<max_count; ++i) {
  544|       |            pj_ansi_strxcpy(ai[*count].ai_canonname, he.h_name,
  545|       |                            sizeof(ai[*count].ai_canonname));
  546|       |
  547|       |            ai[*count].ai_addr.ipv4.sin_family = PJ_AF_INET;
  548|       |            pj_memcpy(&ai[*count].ai_addr.ipv4.sin_addr,
  549|       |                      he.h_addr_list[i], he.h_length);
  550|       |            PJ_SOCKADDR_RESET_LEN(&ai[*count].ai_addr);
  551|       |
  552|       |            (*count)++;
  553|       |        }
  554|       |
  555|       |        return (*count > 0? PJ_SUCCESS : PJ_ERESOLVE);
  556|       |
  557|       |    } else {
  558|       |        /* IPv6 is not supported */
  559|       |        *count = 0;
  560|       |
  561|       |        return PJ_EIPV6NOTSUP;
  562|       |    }
  563|       |#endif  /* PJ_SOCK_HAS_GETADDRINFO */
  564|  1.23k|}

pj_strerror:
  175|    691|{
  176|    691|    int len = -1;
  177|    691|    pj_str_t errstr;
  178|       |
  179|    691|    pj_assert(buf && bufsize);
  ------------------
  |  |   65|    691|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (179:5): [True: 0, False: 691]
  |  Branch (179:5): [True: 0, False: 0]
  |  Branch (179:5): [True: 691, False: 0]
  |  Branch (179:5): [True: 691, False: 0]
  ------------------
  180|       |
  181|    691|    if (statcode == PJ_SUCCESS) {
  ------------------
  |  Branch (181:9): [True: 0, False: 691]
  ------------------
  182|      0|        len = pj_ansi_snprintf( buf, bufsize, "Success");
  ------------------
  |  |  114|      0|#define pj_ansi_snprintf        snprintf
  ------------------
  183|       |
  184|    691|    } else if (statcode < PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE) {
  ------------------
  |  |  509|    691|#define PJ_ERRNO_START          20000
  ------------------
                  } else if (statcode < PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE) {
  ------------------
  |  |  515|    691|#define PJ_ERRNO_SPACE_SIZE     50000
  ------------------
  |  Branch (184:16): [True: 0, False: 691]
  ------------------
  185|      0|        len = pj_ansi_snprintf( buf, bufsize, "Unknown error %d", statcode);
  ------------------
  |  |  114|      0|#define pj_ansi_snprintf        snprintf
  ------------------
  186|       |
  187|    691|    } else if (statcode < PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE) {
  ------------------
  |  |  521|    691|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  ------------------
  |  |  |  |  509|    691|#define PJ_ERRNO_START          20000
  |  |  ------------------
  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  ------------------
  |  |  |  |  515|    691|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  ------------------
  ------------------
                  } else if (statcode < PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE) {
  ------------------
  |  |  515|    691|#define PJ_ERRNO_SPACE_SIZE     50000
  ------------------
  |  Branch (187:16): [True: 16, False: 675]
  ------------------
  188|     16|        len = pjlib_error(statcode, buf, bufsize);
  189|       |
  190|    675|    } else if (statcode < PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE) {
  ------------------
  |  |  528|    675|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  ------------------
  |  |  |  |  521|    675|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|    675|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|    675|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  ------------------
  |  |  |  |  515|    675|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  ------------------
  ------------------
                  } else if (statcode < PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE) {
  ------------------
  |  |  515|    675|#define PJ_ERRNO_SPACE_SIZE     50000
  ------------------
  |  Branch (190:16): [True: 0, False: 675]
  ------------------
  191|      0|        len = platform_strerror(PJ_STATUS_TO_OS(statcode), buf, bufsize);
  ------------------
  |  |  350|      0|#   define PJ_STATUS_TO_OS(e) (e == 0 ? PJ_SUCCESS : e - PJ_ERRNO_START_SYS)
  |  |  ------------------
  |  |  |  |  528|      0|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (350:32): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  192|       |
  193|    675|    } else {
  194|    675|        unsigned i;
  195|       |
  196|       |        /* Find user handler to get the error message. */
  197|    675|        for (i=0; i<err_msg_hnd_cnt; ++i) {
  ------------------
  |  Branch (197:19): [True: 0, False: 675]
  ------------------
  198|      0|            if (IN_RANGE(statcode, err_msg_hnd[i].begin, err_msg_hnd[i].end)) {
  ------------------
  |  |  116|      0|#define IN_RANGE(val,start,end)     ((val)>=(start) && (val)<(end))
  |  |  ------------------
  |  |  |  Branch (116:38): [True: 0, False: 0]
  |  |  |  Branch (116:56): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  199|      0|                return (*err_msg_hnd[i].strerror)(statcode, buf, bufsize);
  200|      0|            }
  201|      0|        }
  202|       |
  203|       |        /* Handler not found! */
  204|    675|        len = pj_ansi_snprintf( buf, bufsize, "Unknown error %d", statcode);
  ------------------
  |  |  114|    675|#define pj_ansi_snprintf        snprintf
  ------------------
  205|    675|    }
  206|       |
  207|    691|    if (len < 1 || len >= (int)bufsize) {
  ------------------
  |  Branch (207:9): [True: 0, False: 691]
  |  Branch (207:20): [True: 0, False: 691]
  ------------------
  208|      0|        len = (int)(bufsize - 1);
  209|      0|        buf[len] = '\0';
  210|      0|    }
  211|       |
  212|    691|    errstr.ptr = buf;
  213|    691|    errstr.slen = len;
  214|       |
  215|    691|    return errstr;
  216|    691|}
pj_perror_3:
  295|    230|{
  296|    230|    va_list marker;
  297|    230|    va_start(marker, title_fmt);
  298|    230|    pj_perror_imp(3, sender, status, title_fmt, marker);
  299|       |    va_end(marker);
  300|    230|}
pj_perror_5:
  317|    297|{
  318|    297|    va_list marker;
  319|    297|    va_start(marker, title_fmt);
  320|    297|    pj_perror_imp(5, sender, status, title_fmt, marker);
  321|       |    va_end(marker);
  322|    297|}
errno.c:pjlib_error:
   93|     16|{
   94|     16|    int len;
   95|       |
   96|     16|#if defined(PJ_HAS_ERROR_STRING) && PJ_HAS_ERROR_STRING!=0
   97|     16|    unsigned i;
   98|       |
   99|    160|    for (i=0; i<PJ_ARRAY_SIZE(err_str); ++i) {
  ------------------
  |  |  315|    160|#define PJ_ARRAY_SIZE(a)    (sizeof(a)/sizeof(a[0]))
  ------------------
  |  Branch (99:15): [True: 160, False: 0]
  ------------------
  100|    160|        if (err_str[i].code == code) {
  ------------------
  |  Branch (100:13): [True: 16, False: 144]
  ------------------
  101|     16|            pj_size_t len2 = pj_ansi_strlen(err_str[i].msg);
  ------------------
  |  |   69|     16|#define pj_ansi_strlen          strlen
  ------------------
  102|     16|            if (len2 >= size) len2 = size-1;
  ------------------
  |  Branch (102:17): [True: 0, False: 16]
  ------------------
  103|     16|            pj_memcpy(buf, err_str[i].msg, len2);
  104|     16|            buf[len2] = '\0';
  105|     16|            return (int)len2;
  106|     16|        }
  107|    160|    }
  108|      0|#endif
  109|       |
  110|      0|    len = pj_ansi_snprintf( buf, size, "Unknown pjlib error %d", code);
  ------------------
  |  |  114|      0|#define pj_ansi_snprintf        snprintf
  ------------------
  111|      0|    if (len < 1 || len >= (int)size)
  ------------------
  |  Branch (111:9): [True: 0, False: 0]
  |  Branch (111:20): [True: 0, False: 0]
  ------------------
  112|      0|        len = (int)(size - 1);
  113|      0|    return len;
  114|     16|}
errno.c:pj_perror_imp:
  232|    527|{
  233|    527|    char titlebuf[PJ_PERROR_TITLE_BUF_SIZE];
  234|    527|    char errmsg[PJ_ERR_MSG_SIZE];
  235|    527|    int len;
  236|       |
  237|       |    /* Build the title */
  238|    527|    len = pj_ansi_vsnprintf(titlebuf, sizeof(titlebuf), title_fmt, marker);
  ------------------
  |  |  122|    527|#define pj_ansi_vsnprintf       vsnprintf
  ------------------
  239|    527|    if (len < 0) {
  ------------------
  |  Branch (239:9): [True: 0, False: 527]
  ------------------
  240|       |    	/* if you see this message in your log, please increase or set
  241|       |    	   PJ_PERROR_TITLE_BUF_SIZE in your config_site.h */
  242|      0|        len = pj_ansi_snprintf(titlebuf, sizeof(titlebuf),
  ------------------
  |  |  114|      0|#define pj_ansi_snprintf        snprintf
  ------------------
  243|      0|                               "<pj_perror_imp error: msg too long>");
  244|      0|    }
  245|    527|    if (len < 0 || len >= (int)sizeof(titlebuf))
  ------------------
  |  Branch (245:9): [True: 0, False: 527]
  |  Branch (245:20): [True: 0, False: 527]
  ------------------
  246|      0|        pj_ansi_strxcpy(titlebuf, "Error", sizeof(titlebuf));
  247|       |
  248|       |    /* Get the error */
  249|    527|    pj_strerror(status, errmsg, sizeof(errmsg));
  250|       |
  251|       |    /* Send to log */
  252|    527|    invoke_log(sender, log_level, "%s: %s", titlebuf, errmsg);
  253|    527|}
errno.c:invoke_log:
  221|    527|{
  222|    527|    va_list arg;
  223|    527|    va_start(arg, format);
  224|    527|    pj_log(sender, level, format, arg);
  225|       |    va_end(arg);
  226|    527|}

pj_exception_id_alloc:
  104|      1|{
  105|      1|    unsigned i;
  106|       |
  107|      1|    pj_enter_critical_section();
  108|       |
  109|       |    /*
  110|       |     * Start from 1 (not 0)!!!
  111|       |     * Exception 0 is reserved for normal path of setjmp()!!!
  112|       |     */
  113|      1|    for (i=1; i<PJ_MAX_EXCEPTION_ID; ++i) {
  ------------------
  |  |  947|      1|#   define PJ_MAX_EXCEPTION_ID      16
  ------------------
  |  Branch (113:15): [True: 1, False: 0]
  ------------------
  114|      1|        if (exception_id_names[i] == NULL) {
  ------------------
  |  Branch (114:13): [True: 1, False: 0]
  ------------------
  115|      1|            exception_id_names[i] = name;
  116|      1|            *id = i;
  117|      1|            pj_leave_critical_section();
  118|      1|            return PJ_SUCCESS;
  119|      1|        }
  120|      1|    }
  121|       |
  122|      0|    pj_leave_critical_section();
  123|      0|    return PJ_ETOOMANY;
  ------------------
  |  |  423|      0|#define PJ_ETOOMANY         (PJ_ERRNO_START_STATUS + 10)/* 70010 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  124|      1|}

pj_generate_unique_string:
   52|      1|{
   53|      1|    char *p, *end;
   54|       |
   55|      1|    PJ_CHECK_STACK();
   56|       |
   57|      1|    if (guid_chars[0] == '\0') {
  ------------------
  |  Branch (57:9): [True: 1, False: 0]
  ------------------
   58|      1|        pj_enter_critical_section();
   59|      1|        if (guid_chars[0] == '\0') {
  ------------------
  |  Branch (59:13): [True: 1, False: 0]
  ------------------
   60|      1|            init_guid_chars();
   61|      1|        }
   62|      1|        pj_leave_critical_section();
   63|      1|    }
   64|       |
   65|       |    /* This would only work if PJ_GUID_STRING_LENGTH is multiple of 2 bytes */
   66|      1|    pj_assert(PJ_GUID_STRING_LENGTH % 2 == 0);
  ------------------
  |  |   65|      1|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (66:5): [True: 0, Folded]
  |  Branch (66:5): [True: 1, Folded]
  ------------------
   67|       |
   68|      9|    for (p=str->ptr, end=p+PJ_GUID_STRING_LENGTH; p<end; ) {
  ------------------
  |  Branch (68:51): [True: 8, False: 1]
  ------------------
   69|      8|        pj_uint32_t rand_val = pj_rand();
   70|      8|        pj_uint32_t rand_idx = RAND_MAX;
   71|       |
   72|     40|        for ( ; rand_idx>0 && p<end; rand_idx>>=8, rand_val>>=8, p++) {
  ------------------
  |  Branch (72:17): [True: 32, False: 8]
  |  Branch (72:31): [True: 32, False: 0]
  ------------------
   73|     32|            *p = guid_chars[(rand_val & 0xFF) & 63];
   74|     32|        }
   75|      8|    }
   76|       |
   77|      1|    str->slen = PJ_GUID_STRING_LENGTH;
   78|      1|    return str;
   79|      1|}
guid_simple.c:init_guid_chars:
   35|      1|{
   36|      1|    char *p = guid_chars;
   37|      1|    unsigned i;
   38|       |
   39|     11|    for (i=0; i<10; ++i)
  ------------------
  |  Branch (39:15): [True: 10, False: 1]
  ------------------
   40|     10|        *p++ = '0'+i;
   41|       |
   42|     27|    for (i=0; i<26; ++i) {
  ------------------
  |  Branch (42:15): [True: 26, False: 1]
  ------------------
   43|     26|        *p++ = 'a'+i;
   44|     26|        *p++ = 'A'+i;
   45|     26|    }
   46|       |
   47|      1|    *p++ = '-';
   48|      1|    *p++ = '.';
   49|      1|}

pj_hash_create:
   91|  1.79k|{
   92|  1.79k|    pj_hash_table_t *h;
   93|  1.79k|    unsigned table_size;
   94|       |    
   95|       |    /* Check that PJ_HASH_ENTRY_BUF_SIZE is correct. */
   96|  1.79k|    PJ_ASSERT_RETURN(sizeof(pj_hash_entry)<=PJ_HASH_ENTRY_BUF_SIZE, NULL);
  ------------------
  |  |   97|  1.79k|            do { \
  |  |   98|  1.79k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [Folded, False: 1.79k]
  |  |  ------------------
  |  |   99|  1.79k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1.79k]
  |  |  ------------------
  ------------------
  |  Branch (96:5): [True: 0, Folded]
  |  Branch (96:5): [True: 0, Folded]
  ------------------
   97|       |
   98|  1.79k|    h = PJ_POOL_ALLOC_T(pool, pj_hash_table_t);
  ------------------
  |  |  569|  1.79k|            ((type*)pj_pool_alloc(pool, sizeof(type)))
  ------------------
   99|  1.79k|    h->count = 0;
  100|       |
  101|  1.79k|    PJ_LOG( 6, ("hashtbl", "hash table %p created from pool %s", h, pj_pool_getobjname(pool)));
  ------------------
  |  |  106|  1.79k|#define PJ_LOG(level,arg)       do { \
  |  |  107|  1.79k|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|  3.58k|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [Folded, False: 1.79k]
  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  109|      0|                                    } \
  |  |  110|  1.79k|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 1.79k]
  |  |  ------------------
  ------------------
  102|       |
  103|       |    /* size must be 2^n - 1.
  104|       |       round-up the size to this rule, except when size is 2^n, then size
  105|       |       will be round-down to 2^n-1.
  106|       |     */
  107|  1.79k|    table_size = 8;
  108|  1.79k|    do {
  109|  1.79k|        table_size <<= 1;    
  110|  1.79k|    } while (table_size < size);
  ------------------
  |  Branch (110:14): [True: 0, False: 1.79k]
  ------------------
  111|  1.79k|    table_size -= 1;
  112|       |    
  113|  1.79k|    h->rows = table_size;
  114|  1.79k|    h->table = (pj_hash_entry**)
  115|  1.79k|               pj_pool_calloc(pool, table_size+1, sizeof(pj_hash_entry*));
  116|  1.79k|    return h;
  117|  1.79k|}
pj_hash_get:
  214|     19|{
  215|     19|    pj_hash_entry *entry;
  216|     19|    entry = *find_entry( NULL, ht, key, keylen, NULL, hval, NULL, PJ_FALSE);
  217|     19|    return entry ? entry->value : NULL;
  ------------------
  |  Branch (217:12): [True: 0, False: 19]
  ------------------
  218|     19|}
hash.c:find_entry:
  123|     19|{
  124|     19|    pj_uint32_t hash;
  125|     19|    pj_hash_entry **p_entry, *entry;
  126|       |
  127|     19|    if (hval && *hval != 0) {
  ------------------
  |  Branch (127:9): [True: 0, False: 19]
  |  Branch (127:17): [True: 0, False: 0]
  ------------------
  128|      0|        hash = *hval;
  129|      0|        if (keylen==PJ_HASH_KEY_STRING) {
  ------------------
  |  |   45|      0|#define PJ_HASH_KEY_STRING      ((unsigned)-1)
  ------------------
  |  Branch (129:13): [True: 0, False: 0]
  ------------------
  130|      0|            keylen = (unsigned)pj_ansi_strlen((const char*)key);
  ------------------
  |  |   69|      0|#define pj_ansi_strlen          strlen
  ------------------
  131|      0|        }
  132|     19|    } else {
  133|       |        /* This slightly differs with pj_hash_calc() because we need 
  134|       |         * to get the keylen when keylen is PJ_HASH_KEY_STRING.
  135|       |         */
  136|     19|        hash=0;
  137|     19|        if (keylen==PJ_HASH_KEY_STRING) {
  ------------------
  |  |   45|     19|#define PJ_HASH_KEY_STRING      ((unsigned)-1)
  ------------------
  |  Branch (137:13): [True: 0, False: 19]
  ------------------
  138|      0|            const pj_uint8_t *p = (const pj_uint8_t*)key;
  139|      0|            for ( ; *p; ++p ) {
  ------------------
  |  Branch (139:21): [True: 0, False: 0]
  ------------------
  140|      0|                if (lower)
  ------------------
  |  Branch (140:21): [True: 0, False: 0]
  ------------------
  141|      0|                    hash = hash * PJ_HASH_MULTIPLIER + pj_tolower(*p);
  ------------------
  |  |   30|      0|#define PJ_HASH_MULTIPLIER      33
  ------------------
  142|      0|                else 
  143|      0|                    hash = hash * PJ_HASH_MULTIPLIER + *p;
  ------------------
  |  |   30|      0|#define PJ_HASH_MULTIPLIER      33
  ------------------
  144|      0|            }
  145|      0|            keylen = (unsigned)(p - (const unsigned char*)key);
  146|     19|        } else {
  147|     19|            const pj_uint8_t *p = (const pj_uint8_t*)key,
  148|     19|                                  *end = p + keylen;
  149|     57|            for ( ; p!=end; ++p) {
  ------------------
  |  Branch (149:21): [True: 38, False: 19]
  ------------------
  150|     38|                if (lower)
  ------------------
  |  Branch (150:21): [True: 0, False: 38]
  ------------------
  151|      0|                    hash = hash * PJ_HASH_MULTIPLIER + pj_tolower(*p);
  ------------------
  |  |   30|      0|#define PJ_HASH_MULTIPLIER      33
  ------------------
  152|     38|                else
  153|     38|                    hash = hash * PJ_HASH_MULTIPLIER + *p;
  ------------------
  |  |   30|     38|#define PJ_HASH_MULTIPLIER      33
  ------------------
  154|     38|            }
  155|     19|        }
  156|       |
  157|       |        /* Report back the computed hash. */
  158|     19|        if (hval)
  ------------------
  |  Branch (158:13): [True: 0, False: 19]
  ------------------
  159|      0|            *hval = hash;
  160|     19|    }
  161|       |
  162|       |    /* scan the linked list */
  163|     19|    for (p_entry = &ht->table[hash & ht->rows], entry=*p_entry; 
  164|     19|         entry; 
  ------------------
  |  Branch (164:10): [True: 0, False: 19]
  ------------------
  165|     19|         p_entry = &entry->next, entry = *p_entry)
  166|      0|    {
  167|      0|        if (entry->hash==hash && entry->keylen==keylen &&
  ------------------
  |  Branch (167:13): [True: 0, False: 0]
  |  Branch (167:34): [True: 0, False: 0]
  ------------------
  168|      0|            ((lower && pj_ansi_strnicmp((const char*)entry->key,
  ------------------
  |  |   96|      0|#define pj_ansi_strnicmp        strncasecmp
  ------------------
  |  Branch (168:15): [True: 0, False: 0]
  |  Branch (168:24): [True: 0, False: 0]
  ------------------
  169|      0|                                        (const char*)key, keylen)==0) ||
  170|      0|             (!lower && pj_memcmp(entry->key, key, keylen)==0)))
  ------------------
  |  Branch (170:15): [True: 0, False: 0]
  |  Branch (170:25): [True: 0, False: 0]
  ------------------
  171|      0|        {
  172|      0|            break;
  173|      0|        }
  174|      0|    }
  175|       |
  176|     19|    if (entry || val==NULL)
  ------------------
  |  Branch (176:9): [True: 0, False: 19]
  |  Branch (176:18): [True: 19, False: 0]
  ------------------
  177|     19|        return p_entry;
  178|       |
  179|       |    /* Entry not found, create a new one. 
  180|       |     * If entry_buf is specified, use it. Otherwise allocate from pool.
  181|       |     */
  182|      0|    if (entry_buf) {
  ------------------
  |  Branch (182:9): [True: 0, False: 0]
  ------------------
  183|      0|        entry = (pj_hash_entry*)entry_buf;
  184|      0|    } else {
  185|       |        /* Pool must be specified! */
  186|      0|        PJ_ASSERT_RETURN(pool != NULL, NULL);
  ------------------
  |  |   97|      0|            do { \
  |  |   98|      0|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 0]
  |  |  ------------------
  |  |   99|      0|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (186:9): [True: 0, False: 0]
  |  Branch (186:9): [True: 0, False: 0]
  ------------------
  187|       |
  188|      0|        entry = PJ_POOL_ALLOC_T(pool, pj_hash_entry);
  ------------------
  |  |  569|      0|            ((type*)pj_pool_alloc(pool, sizeof(type)))
  ------------------
  189|      0|        PJ_LOG(6, ("hashtbl", 
  ------------------
  |  |  106|      0|#define PJ_LOG(level,arg)       do { \
  |  |  107|      0|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|      0|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [Folded, False: 0]
  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  109|      0|                                    } \
  |  |  110|      0|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 0]
  |  |  ------------------
  ------------------
  190|      0|                   "%p: New p_entry %p created, pool used=%lu, cap=%lu", 
  191|      0|                   ht, entry,  (unsigned long)pj_pool_get_used_size(pool),
  192|      0|                   (unsigned long)pj_pool_get_capacity(pool)));
  193|      0|    }
  194|      0|    entry->next = NULL;
  195|      0|    entry->hash = hash;
  196|      0|    if (pool) {
  ------------------
  |  Branch (196:9): [True: 0, False: 0]
  ------------------
  197|      0|        entry->key = pj_pool_alloc(pool, keylen);
  198|      0|        pj_memcpy(entry->key, key, keylen);
  199|      0|    } else {
  200|      0|        entry->key = (void*)key;
  201|      0|    }
  202|      0|    entry->keylen = keylen;
  203|      0|    entry->value = val;
  204|      0|    *p_entry = entry;
  205|       |    
  206|      0|    ++ht->count;
  207|       |    
  208|      0|    return p_entry;
  209|      0|}

pj_ioqueue_cfg_default:
   40|  1.23k|{
   41|  1.23k|    pj_bzero(cfg, sizeof(*cfg));
   42|  1.23k|    cfg->epoll_flags = PJ_IOQUEUE_DEFAULT_EPOLL_FLAGS;
  ------------------
  |  |  810|  1.23k|#   define PJ_IOQUEUE_DEFAULT_EPOLL_FLAGS PJ_IOQUEUE_EPOLL_AUTO
  ------------------
   43|  1.23k|    cfg->default_concurrency = PJ_IOQUEUE_DEFAULT_ALLOW_CONCURRENCY;
  ------------------
  |  |  775|  1.23k|#   define PJ_IOQUEUE_DEFAULT_ALLOW_CONCURRENCY   1
  ------------------
   44|  1.23k|}
pj_ioqueue_set_lock:
   68|  1.23k|{
   69|  1.23k|    PJ_ASSERT_RETURN(ioqueue && lock, PJ_EINVAL);
  ------------------
  |  |   97|  1.23k|            do { \
  |  |   98|  2.47k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 1.23k, False: 0]
  |  |  |  Branch (98:23): [True: 1.23k, False: 0]
  |  |  ------------------
  |  |   99|  1.23k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1.23k]
  |  |  ------------------
  ------------------
  |  Branch (69:5): [True: 0, False: 0]
  |  Branch (69:5): [True: 0, False: 0]
  |  Branch (69:5): [True: 0, False: 0]
  |  Branch (69:5): [True: 0, False: 0]
  ------------------
   70|       |
   71|  1.23k|    if (ioqueue->auto_delete_lock && ioqueue->lock) {
  ------------------
  |  Branch (71:9): [True: 0, False: 1.23k]
  |  Branch (71:38): [True: 0, False: 0]
  ------------------
   72|      0|        pj_lock_destroy(ioqueue->lock);
   73|      0|    }
   74|       |
   75|  1.23k|    ioqueue->lock = lock;
   76|  1.23k|    ioqueue->auto_delete_lock = auto_delete;
   77|       |
   78|  1.23k|    return PJ_SUCCESS;
   79|  1.23k|}
pj_ioqueue_recvfrom:
  964|    341|{
  965|    341|    struct read_operation *read_op;
  966|       |
  967|    341|    PJ_ASSERT_RETURN(key && op_key && buffer && length, PJ_EINVAL);
  ------------------
  |  |   97|    341|            do { \
  |  |   98|  2.04k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 341, False: 0]
  |  |  |  Branch (98:23): [True: 341, False: 0]
  |  |  |  Branch (98:23): [True: 341, False: 0]
  |  |  |  Branch (98:23): [True: 341, False: 0]
  |  |  ------------------
  |  |   99|    341|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 341]
  |  |  ------------------
  ------------------
  |  Branch (967:5): [True: 0, False: 0]
  |  Branch (967:5): [True: 0, False: 0]
  |  Branch (967:5): [True: 0, False: 0]
  |  Branch (967:5): [True: 0, False: 0]
  |  Branch (967:5): [True: 0, False: 0]
  |  Branch (967:5): [True: 0, False: 0]
  |  Branch (967:5): [True: 0, False: 0]
  |  Branch (967:5): [True: 0, False: 0]
  ------------------
  968|    341|    PJ_CHECK_STACK();
  969|       |
  970|       |    /* Check if key is closing. */
  971|    341|    if (IS_CLOSING(key))
  ------------------
  |  |  200|    341|#define IS_CLOSING(key) (key->closing)
  |  |  ------------------
  |  |  |  Branch (200:25): [True: 0, False: 341]
  |  |  ------------------
  ------------------
  972|      0|        return PJ_ECANCELLED;
  ------------------
  |  |  443|      0|#define PJ_ECANCELLED       (PJ_ERRNO_START_STATUS + 14)/* 70014 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  973|       |
  974|    341|    read_op = (struct read_operation*)op_key;
  975|    341|    PJ_ASSERT_RETURN(read_op->op == PJ_IOQUEUE_OP_NONE, PJ_EPENDING);
  ------------------
  |  |   97|    341|            do { \
  |  |   98|    341|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 341]
  |  |  ------------------
  |  |   99|    341|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 341]
  |  |  ------------------
  ------------------
  |  Branch (975:5): [True: 0, False: 0]
  |  Branch (975:5): [True: 0, False: 0]
  ------------------
  976|       |
  977|       |    /* Try to see if there's data immediately available. 
  978|       |     */
  979|    341|    if ((flags & PJ_IOQUEUE_ALWAYS_ASYNC) == 0) {
  ------------------
  |  |  330|    341|#define PJ_IOQUEUE_ALWAYS_ASYNC     ((pj_uint32_t)1 << (pj_uint32_t)31)
  ------------------
  |  Branch (979:9): [True: 0, False: 341]
  ------------------
  980|      0|        pj_status_t status;
  981|      0|        pj_ssize_t size;
  982|       |
  983|      0|        size = *length;
  984|      0|        status = pj_sock_recvfrom(key->fd, buffer, &size, flags,
  985|      0|                                  addr, addrlen);
  986|      0|        if (status == PJ_SUCCESS) {
  ------------------
  |  Branch (986:13): [True: 0, False: 0]
  ------------------
  987|       |            /* Yes! Data is available! */
  988|      0|            *length = size;
  989|      0|            return PJ_SUCCESS;
  990|      0|        } else {
  991|       |            /* If error is not EWOULDBLOCK (or EAGAIN on Linux), report
  992|       |             * the error to caller.
  993|       |             */
  994|      0|            if (status != PJ_STATUS_FROM_OS(PJ_BLOCKING_ERROR_VAL))
  ------------------
  |  |  334|      0|#   define PJ_STATUS_FROM_OS(e) (e == 0 ? PJ_SUCCESS : e + PJ_ERRNO_START_SYS)
  |  |  ------------------
  |  |  |  |  528|      0|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (334:34): [Folded, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (994:17): [True: 0, False: 0]
  ------------------
  995|      0|                return status;
  996|      0|        }
  997|      0|    }
  998|       |
  999|    341|    flags &= ~(PJ_IOQUEUE_ALWAYS_ASYNC);
  ------------------
  |  |  330|    341|#define PJ_IOQUEUE_ALWAYS_ASYNC     ((pj_uint32_t)1 << (pj_uint32_t)31)
  ------------------
 1000|       |
 1001|    341|    pj_ioqueue_lock_key(key);
 1002|       |    /* Check again. Handle may have been closed after the previous check
 1003|       |     * in multithreaded app. If we add bad handle to the set it will
 1004|       |     * corrupt the ioqueue set. See #913
 1005|       |     */
 1006|    341|    if (IS_CLOSING(key)) {
  ------------------
  |  |  200|    341|#define IS_CLOSING(key) (key->closing)
  |  |  ------------------
  |  |  |  Branch (200:25): [True: 0, False: 341]
  |  |  ------------------
  ------------------
 1007|      0|        pj_ioqueue_unlock_key(key);
 1008|      0|        return PJ_ECANCELLED;
  ------------------
  |  |  443|      0|#define PJ_ECANCELLED       (PJ_ERRNO_START_STATUS + 14)/* 70014 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1009|      0|    }
 1010|       |
 1011|       |    /* Also check read_op->op again, this time while holding lock. */
 1012|    341|    PJ_ASSERT_ON_FAIL(read_op->op == PJ_IOQUEUE_OP_NONE,
  ------------------
  |  |  111|    341|            { \
  |  |  112|    341|                pj_assert(expr); \
  |  |  ------------------
  |  |  |  |   65|    341|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  113|    341|                if (!(expr)) exec_on_fail; \
  |  |  ------------------
  |  |  |  Branch (113:21): [True: 0, False: 341]
  |  |  ------------------
  |  |  114|    341|            }
  ------------------
  |  Branch (1012:5): [True: 0, False: 341]
  |  Branch (1012:5): [True: 341, False: 0]
  ------------------
 1013|    341|                      {pj_ioqueue_unlock_key(key); return PJ_EPENDING;});
 1014|       |    /*
 1015|       |     * No data is immediately available.
 1016|       |     * Must schedule asynchronous operation to the ioqueue.
 1017|       |     */
 1018|    341|    read_op->op = PJ_IOQUEUE_OP_RECV_FROM;
 1019|    341|    read_op->buf = buffer;
 1020|    341|    read_op->size = *length;
 1021|    341|    read_op->flags = flags;
 1022|    341|    read_op->rmt_addr = addr;
 1023|    341|    read_op->rmt_addrlen = addrlen;
 1024|       |
 1025|    341|    pj_list_insert_before(&key->read_list, read_op);
 1026|    341|    ioqueue_add_to_set(key->ioqueue, key, READABLE_EVENT);
 1027|    341|    pj_ioqueue_unlock_key(key);
 1028|       |
 1029|    341|    return PJ_EPENDING;
  ------------------
  |  |  383|    341|#define PJ_EPENDING         (PJ_ERRNO_START_STATUS + 2) /* 70002 */
  |  |  ------------------
  |  |  |  |  521|    341|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|    341|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|    341|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1030|    682|}
pj_ioqueue_op_key_init:
 1444|    682|{
 1445|    682|    pj_bzero(op_key, size);
 1446|    682|}
pj_ioqueue_set_concurrency:
 1633|    682|{
 1634|    682|    PJ_ASSERT_RETURN(key, PJ_EINVAL);
  ------------------
  |  |   97|    682|            do { \
  |  |   98|    682|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 682]
  |  |  ------------------
  |  |   99|    682|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 682]
  |  |  ------------------
  ------------------
  |  Branch (1634:5): [True: 0, False: 0]
  |  Branch (1634:5): [True: 0, False: 0]
  ------------------
 1635|       |
 1636|       |    /* PJ_IOQUEUE_HAS_SAFE_UNREG must be enabled if concurrency is
 1637|       |     * disabled.
 1638|       |     */
 1639|    682|    PJ_ASSERT_RETURN(allow || PJ_IOQUEUE_HAS_SAFE_UNREG, PJ_EINVAL);
  ------------------
  |  |   97|    682|            do { \
  |  |   98|  1.02k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 341, False: 341]
  |  |  |  Branch (98:23): [True: 341, Folded]
  |  |  ------------------
  |  |   99|    682|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 682]
  |  |  ------------------
  ------------------
  |  Branch (1639:5): [True: 0, False: 0]
  |  Branch (1639:5): [True: 0, Folded]
  |  Branch (1639:5): [True: 0, False: 0]
  |  Branch (1639:5): [True: 0, Folded]
  ------------------
 1640|       |
 1641|    682|    key->allow_concurrent = allow;
 1642|    682|    return PJ_SUCCESS;
 1643|    682|}
pj_ioqueue_lock_key:
 1646|  1.02k|{
 1647|  1.02k|    if (key->grp_lock)
  ------------------
  |  Branch (1647:9): [True: 1.02k, False: 0]
  ------------------
 1648|  1.02k|        return pj_grp_lock_acquire(key->grp_lock);
 1649|      0|    else
 1650|      0|        return pj_lock_acquire(key->lock);
 1651|  1.02k|}
pj_ioqueue_unlock_key:
 1662|  1.02k|{
 1663|  1.02k|    if (key->grp_lock)
  ------------------
  |  Branch (1663:9): [True: 1.02k, False: 0]
  ------------------
 1664|  1.02k|        return pj_grp_lock_release(key->grp_lock);
 1665|      0|    else
 1666|      0|        return pj_lock_release(key->lock);
 1667|  1.02k|}
ioqueue_select.c:ioqueue_init:
   47|  1.23k|{
   48|       |    ioqueue->lock = NULL;
   49|  1.23k|    ioqueue->auto_delete_lock = 0;
   50|  1.23k|}
ioqueue_select.c:ioqueue_destroy:
   53|  1.23k|{
   54|  1.23k|    if (ioqueue->auto_delete_lock && ioqueue->lock ) {
  ------------------
  |  Branch (54:9): [True: 1.23k, False: 0]
  |  Branch (54:38): [True: 1.23k, False: 0]
  ------------------
   55|  1.23k|        pj_lock_release(ioqueue->lock);
   56|  1.23k|        return pj_lock_destroy(ioqueue->lock);
   57|  1.23k|    }
   58|       |    
   59|      0|    return PJ_SUCCESS;
   60|  1.23k|}
ioqueue_select.c:ioqueue_init_key:
   88|    341|{
   89|    341|    pj_status_t rc;
   90|    341|    int optlen;
   91|       |
   92|    341|    PJ_UNUSED_ARG(pool);
  ------------------
  |  | 1537|    341|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
   93|       |
   94|    341|    key->ioqueue = ioqueue;
   95|    341|    key->fd = sock;
   96|    341|    key->user_data = user_data;
   97|    341|    pj_list_init(&key->read_list);
   98|    341|    pj_list_init(&key->write_list);
   99|    341|#if PJ_HAS_TCP
  100|    341|    pj_list_init(&key->accept_list);
  101|    341|    key->connecting = 0;
  102|    341|#endif
  103|    341|    pj_list_init(&key->read_cb_list);
  104|    341|    key->read_callback_thread = NULL;
  105|    341|    pj_list_init(&key->write_cb_list);
  106|    341|    key->write_callback_thread = NULL;
  107|    341|    key->closing = 0;
  108|       |
  109|       |    /* Save callback. */
  110|    341|    pj_memcpy(&key->cb, cb, sizeof(pj_ioqueue_callback));
  111|       |
  112|    341|#if PJ_IOQUEUE_HAS_SAFE_UNREG
  113|       |    /* Set initial reference count to 1 */
  114|    341|    pj_assert(key->ref_count == 0);
  ------------------
  |  |   65|    341|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (114:5): [True: 0, False: 341]
  |  Branch (114:5): [True: 341, False: 0]
  ------------------
  115|    341|    ++key->ref_count;
  116|    341|#endif
  117|       |
  118|    341|    rc = pj_ioqueue_set_concurrency(key, ioqueue->cfg.default_concurrency);
  119|    341|    if (rc != PJ_SUCCESS)
  ------------------
  |  Branch (119:9): [True: 0, False: 341]
  ------------------
  120|      0|        return rc;
  121|       |
  122|       |    /* Get socket type. When socket type is datagram, some optimization
  123|       |     * will be performed during send to allow parallel send operations.
  124|       |     */
  125|    341|    optlen = sizeof(key->fd_type);
  126|    341|    rc = pj_sock_getsockopt(sock, pj_SOL_SOCKET(), pj_SO_TYPE(),
  ------------------
  |  |  211|    341|#   define pj_SOL_SOCKET()  PJ_SOL_SOCKET
  ------------------
                  rc = pj_sock_getsockopt(sock, pj_SOL_SOCKET(), pj_SO_TYPE(),
  ------------------
  |  |  381|    341|#   define pj_SO_TYPE()     PJ_SO_TYPE
  ------------------
  127|    341|                            &key->fd_type, &optlen);
  128|    341|    if (rc != PJ_SUCCESS)
  ------------------
  |  Branch (128:9): [True: 0, False: 341]
  ------------------
  129|      0|        key->fd_type = pj_SOCK_STREAM();
  ------------------
  |  |  165|      0|#   define pj_SOCK_STREAM() PJ_SOCK_STREAM
  ------------------
  130|       |
  131|       |    /* Create mutex for the key. */
  132|       |#if !PJ_IOQUEUE_HAS_SAFE_UNREG
  133|       |    rc = pj_lock_create_simple_mutex(pool, NULL, &key->lock);
  134|       |    if (rc != PJ_SUCCESS)
  135|       |        return rc;
  136|       |#endif
  137|       |
  138|       |    /* Group lock */
  139|    341|    key->grp_lock = grp_lock;
  140|    341|    if (key->grp_lock) {
  ------------------
  |  Branch (140:9): [True: 341, False: 0]
  ------------------
  141|    341|        pj_grp_lock_add_ref_dbg(key->grp_lock, "ioqueue", 0);
  ------------------
  |  |  351|    341|#define pj_grp_lock_add_ref_dbg(grp_lock, x, y) pj_grp_lock_add_ref(grp_lock)
  ------------------
  142|    341|    }
  143|       |    
  144|    341|    return PJ_SUCCESS;
  145|    341|}

pj_ioqueue_create:
  196|  1.23k|{
  197|       |    return pj_ioqueue_create2(pool, max_fd, NULL, p_ioqueue);
  198|  1.23k|}
pj_ioqueue_create2:
  210|  1.23k|{
  211|  1.23k|    pj_ioqueue_t *ioqueue;
  212|  1.23k|    pj_lock_t *lock;
  213|  1.23k|    pj_size_t i;
  214|  1.23k|    pj_status_t rc;
  215|       |
  216|       |    /* Check that arguments are valid. */
  217|  1.23k|    PJ_ASSERT_RETURN(pool != NULL && p_ioqueue != NULL && 
  ------------------
  |  |   97|  1.23k|            do { \
  |  |   98|  7.42k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 1.23k, False: 0]
  |  |  |  Branch (98:23): [True: 1.23k, False: 0]
  |  |  |  Branch (98:23): [True: 1.23k, False: 0]
  |  |  |  Branch (98:23): [True: 1.23k, False: 0]
  |  |  ------------------
  |  |   99|  1.23k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1.23k]
  |  |  ------------------
  ------------------
  |  Branch (217:5): [True: 0, False: 0]
  |  Branch (217:5): [True: 0, False: 0]
  |  Branch (217:5): [True: 0, False: 0]
  |  Branch (217:5): [True: 0, False: 0]
  |  Branch (217:5): [True: 0, False: 0]
  |  Branch (217:5): [True: 0, False: 0]
  |  Branch (217:5): [True: 0, False: 0]
  |  Branch (217:5): [True: 0, False: 0]
  ------------------
  218|  1.23k|                     max_fd > 0 && max_fd <= PJ_IOQUEUE_MAX_HANDLES, 
  219|  1.23k|                     PJ_EINVAL);
  220|       |
  221|       |    /* Check that size of pj_ioqueue_op_key_t is sufficient */
  222|  1.23k|    PJ_ASSERT_RETURN(sizeof(pj_ioqueue_op_key_t)-sizeof(void*) >=
  ------------------
  |  |   97|  1.23k|            do { \
  |  |   98|  1.23k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [Folded, False: 1.23k]
  |  |  ------------------
  |  |   99|  1.23k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1.23k]
  |  |  ------------------
  ------------------
  |  Branch (222:5): [True: 0, Folded]
  |  Branch (222:5): [True: 0, Folded]
  ------------------
  223|  1.23k|                     sizeof(union operation_key), PJ_EBUG);
  224|       |
  225|       |    /* Create and init common ioqueue stuffs */
  226|  1.23k|    ioqueue = PJ_POOL_ZALLOC_T(pool, pj_ioqueue_t);
  ------------------
  |  |  583|  1.23k|            ((type*)pj_pool_zalloc(pool, sizeof(type)))
  ------------------
  227|  1.23k|    ioqueue_init(ioqueue);
  228|       |
  229|  1.23k|    if (cfg)
  ------------------
  |  Branch (229:9): [True: 0, False: 1.23k]
  ------------------
  230|      0|        pj_memcpy(&ioqueue->cfg, cfg, sizeof(*cfg));
  231|  1.23k|    else
  232|  1.23k|        pj_ioqueue_cfg_default(&ioqueue->cfg);
  233|  1.23k|    ioqueue->max = (unsigned)max_fd;
  234|  1.23k|    ioqueue->count = 0;
  235|  1.23k|    PJ_FD_ZERO(&ioqueue->rfdset);
  236|  1.23k|    PJ_FD_ZERO(&ioqueue->wfdset);
  237|  1.23k|#if PJ_HAS_TCP
  238|  1.23k|    PJ_FD_ZERO(&ioqueue->xfdset);
  239|  1.23k|#endif
  240|  1.23k|    pj_list_init(&ioqueue->active_list);
  241|       |
  242|  1.23k|    rescan_fdset(ioqueue);
  243|       |
  244|  1.23k|#if PJ_IOQUEUE_HAS_SAFE_UNREG
  245|       |    /* When safe unregistration is used (the default), we pre-create
  246|       |     * all keys and put them in the free list.
  247|       |     */
  248|       |
  249|       |    /* Mutex to protect key's reference counter 
  250|       |     * We don't want to use key's mutex or ioqueue's mutex because
  251|       |     * that would create deadlock situation in some cases.
  252|       |     */
  253|  1.23k|    rc = pj_mutex_create_simple(pool, NULL, &ioqueue->ref_cnt_mutex);
  254|  1.23k|    if (rc != PJ_SUCCESS)
  ------------------
  |  Branch (254:9): [True: 0, False: 1.23k]
  ------------------
  255|      0|        return rc;
  256|       |
  257|       |
  258|       |    /* Init key list */
  259|  1.23k|    pj_list_init(&ioqueue->free_list);
  260|  1.23k|    pj_list_init(&ioqueue->closing_list);
  261|       |
  262|       |
  263|       |    /* Pre-create all keys according to max_fd */
  264|  7.54k|    for (i=0; i<max_fd; ++i) {
  ------------------
  |  Branch (264:15): [True: 6.31k, False: 1.23k]
  ------------------
  265|  6.31k|        pj_ioqueue_key_t *key;
  266|       |
  267|  6.31k|        key = PJ_POOL_ALLOC_T(pool, pj_ioqueue_key_t);
  ------------------
  |  |  569|  6.31k|            ((type*)pj_pool_alloc(pool, sizeof(type)))
  ------------------
  268|  6.31k|        key->ref_count = 0;
  269|  6.31k|        rc = pj_lock_create_recursive_mutex(pool, NULL, &key->lock);
  270|  6.31k|        if (rc != PJ_SUCCESS) {
  ------------------
  |  Branch (270:13): [True: 0, False: 6.31k]
  ------------------
  271|      0|            key = ioqueue->free_list.next;
  272|      0|            while (key != &ioqueue->free_list) {
  ------------------
  |  Branch (272:20): [True: 0, False: 0]
  ------------------
  273|      0|                pj_lock_destroy(key->lock);
  274|      0|                key = key->next;
  275|      0|            }
  276|      0|            pj_mutex_destroy(ioqueue->ref_cnt_mutex);
  277|      0|            return rc;
  278|      0|        }
  279|       |
  280|  6.31k|        pj_list_push_back(&ioqueue->free_list, key);
  281|  6.31k|    }
  282|  1.23k|#endif
  283|       |
  284|       |    /* Create and init ioqueue mutex */
  285|  1.23k|    rc = pj_lock_create_simple_mutex(pool, "ioq%p", &lock);
  286|  1.23k|    if (rc != PJ_SUCCESS)
  ------------------
  |  Branch (286:9): [True: 0, False: 1.23k]
  ------------------
  287|      0|        return rc;
  288|       |
  289|  1.23k|    rc = pj_ioqueue_set_lock(ioqueue, lock, PJ_TRUE);
  290|  1.23k|    if (rc != PJ_SUCCESS)
  ------------------
  |  Branch (290:9): [True: 0, False: 1.23k]
  ------------------
  291|      0|        return rc;
  292|       |
  293|  1.23k|    PJ_LOG(4, ("pjlib", "select() I/O Queue created (%p)", ioqueue));
  ------------------
  |  |  106|  1.23k|#define PJ_LOG(level,arg)       do { \
  |  |  107|  1.23k|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|  2.47k|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 1.23k, Folded]
  |  |  |  Branch (107:70): [True: 0, False: 1.23k]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  480|      0|    #define pj_log_wrapper_4(arg)       pj_log_4 arg
  |  |  ------------------
  |  |  109|      0|                                    } \
  |  |  110|  1.23k|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 1.23k]
  |  |  ------------------
  ------------------
  294|       |
  295|  1.23k|    *p_ioqueue = ioqueue;
  296|  1.23k|    return PJ_SUCCESS;
  297|  1.23k|}
pj_ioqueue_destroy:
  305|  1.23k|{
  306|  1.23k|    pj_ioqueue_key_t *key;
  307|       |
  308|  1.23k|    PJ_ASSERT_RETURN(ioqueue, PJ_EINVAL);
  ------------------
  |  |   97|  1.23k|            do { \
  |  |   98|  1.23k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 1.23k]
  |  |  ------------------
  |  |   99|  1.23k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1.23k]
  |  |  ------------------
  ------------------
  |  Branch (308:5): [True: 0, False: 0]
  |  Branch (308:5): [True: 0, False: 0]
  ------------------
  309|       |
  310|  1.23k|    pj_lock_acquire(ioqueue->lock);
  311|       |
  312|  1.23k|#if PJ_IOQUEUE_HAS_SAFE_UNREG
  313|       |    /* Destroy reference counters */
  314|  1.23k|    key = ioqueue->active_list.next;
  315|  1.23k|    while (key != &ioqueue->active_list) {
  ------------------
  |  Branch (315:12): [True: 0, False: 1.23k]
  ------------------
  316|      0|        pj_lock_destroy(key->lock);
  317|      0|        key = key->next;
  318|      0|    }
  319|       |
  320|  1.23k|    key = ioqueue->closing_list.next;
  321|  1.57k|    while (key != &ioqueue->closing_list) {
  ------------------
  |  Branch (321:12): [True: 341, False: 1.23k]
  ------------------
  322|    341|        pj_lock_destroy(key->lock);
  323|    341|        key = key->next;
  324|    341|    }
  325|       |
  326|  1.23k|    key = ioqueue->free_list.next;
  327|  7.20k|    while (key != &ioqueue->free_list) {
  ------------------
  |  Branch (327:12): [True: 5.97k, False: 1.23k]
  ------------------
  328|  5.97k|        pj_lock_destroy(key->lock);
  329|  5.97k|        key = key->next;
  330|  5.97k|    }
  331|       |
  332|  1.23k|    pj_mutex_destroy(ioqueue->ref_cnt_mutex);
  333|  1.23k|#endif
  334|       |
  335|  1.23k|    return ioqueue_destroy(ioqueue);
  336|  1.23k|}
pj_ioqueue_register_sock2:
  351|    341|{
  352|    341|    pj_ioqueue_key_t *key = NULL;
  353|       |#if defined(PJ_WIN32) && PJ_WIN32!=0 || \
  354|       |    defined(PJ_WIN64) && PJ_WIN64 != 0 || \
  355|       |    defined(PJ_WIN32_WINCE) && PJ_WIN32_WINCE!=0
  356|       |    u_long value;
  357|       |#else
  358|    341|    pj_uint32_t value;
  359|    341|#endif
  360|    341|    pj_status_t rc = PJ_SUCCESS;
  361|       |    
  362|    341|    PJ_ASSERT_RETURN(pool && ioqueue && sock != PJ_INVALID_SOCKET &&
  ------------------
  |  |   97|    341|            do { \
  |  |   98|  2.72k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 341, False: 0]
  |  |  |  Branch (98:23): [True: 341, False: 0]
  |  |  |  Branch (98:23): [True: 341, False: 0]
  |  |  |  Branch (98:23): [True: 341, False: 0]
  |  |  |  Branch (98:23): [True: 341, False: 0]
  |  |  ------------------
  |  |   99|    341|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 341]
  |  |  ------------------
  ------------------
  |  Branch (362:5): [True: 0, False: 0]
  |  Branch (362:5): [True: 0, False: 0]
  |  Branch (362:5): [True: 0, False: 0]
  |  Branch (362:5): [True: 0, False: 0]
  |  Branch (362:5): [True: 0, False: 0]
  |  Branch (362:5): [True: 0, False: 0]
  |  Branch (362:5): [True: 0, False: 0]
  |  Branch (362:5): [True: 0, False: 0]
  |  Branch (362:5): [True: 0, False: 0]
  |  Branch (362:5): [True: 0, False: 0]
  ------------------
  363|    341|                     cb && p_key, PJ_EINVAL);
  364|       |
  365|       |    /* On platforms with fd_set containing fd bitmap such as *nix family,
  366|       |     * avoid potential memory corruption caused by select() when given
  367|       |     * an fd that is higher than FD_SETSIZE.
  368|       |     */
  369|    341|    if (sizeof(fd_set) < FD_SETSIZE && sock >= FD_SETSIZE) {
  ------------------
  |  Branch (369:9): [True: 341, Folded]
  |  Branch (369:40): [True: 0, False: 341]
  ------------------
  370|      0|        PJ_LOG(4, ("pjlib", "Failed to register socket to ioqueue because "
  ------------------
  |  |  106|      0|#define PJ_LOG(level,arg)       do { \
  |  |  107|      0|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|      0|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 0, Folded]
  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  480|      0|    #define pj_log_wrapper_4(arg)       pj_log_4 arg
  |  |  ------------------
  |  |  109|      0|                                    } \
  |  |  110|      0|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 0]
  |  |  ------------------
  ------------------
  371|      0|                            "socket fd is too big (fd=%ld/FD_SETSIZE=%d)",
  372|      0|                            sock, FD_SETSIZE));
  373|      0|        return PJ_ETOOBIG;
  ------------------
  |  |  458|      0|#define PJ_ETOOBIG          (PJ_ERRNO_START_STATUS + 17)/* 70017 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  374|      0|    }
  375|       |
  376|    341|    pj_lock_acquire(ioqueue->lock);
  377|       |
  378|    341|    if (ioqueue->count >= ioqueue->max) {
  ------------------
  |  Branch (378:9): [True: 0, False: 341]
  ------------------
  379|      0|        rc = PJ_ETOOMANY;
  ------------------
  |  |  423|      0|#define PJ_ETOOMANY         (PJ_ERRNO_START_STATUS + 10)/* 70010 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  380|      0|        goto on_return;
  381|      0|    }
  382|       |
  383|       |    /* If safe unregistration (PJ_IOQUEUE_HAS_SAFE_UNREG) is used, get
  384|       |     * the key from the free list. Otherwise allocate a new one. 
  385|       |     */
  386|    341|#if PJ_IOQUEUE_HAS_SAFE_UNREG
  387|       |
  388|       |    /* Scan closing_keys first to let them come back to free_list */
  389|    341|    scan_closing_keys(ioqueue);
  390|       |
  391|    341|    pj_assert(!pj_list_empty(&ioqueue->free_list));
  ------------------
  |  |   65|    341|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (391:5): [True: 0, False: 341]
  |  Branch (391:5): [True: 341, False: 0]
  ------------------
  392|    341|    if (pj_list_empty(&ioqueue->free_list)) {
  ------------------
  |  Branch (392:9): [True: 0, False: 341]
  ------------------
  393|      0|        rc = PJ_ETOOMANY;
  ------------------
  |  |  423|      0|#define PJ_ETOOMANY         (PJ_ERRNO_START_STATUS + 10)/* 70010 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  394|      0|        goto on_return;
  395|      0|    }
  396|       |
  397|    341|    key = ioqueue->free_list.next;
  398|    341|    pj_list_erase(key);
  399|       |#else
  400|       |    key = (pj_ioqueue_key_t*)pj_pool_zalloc(pool, sizeof(pj_ioqueue_key_t));
  401|       |#endif
  402|       |
  403|    341|    rc = ioqueue_init_key(pool, ioqueue, key, sock, grp_lock, user_data, cb);
  404|    341|    if (rc != PJ_SUCCESS) {
  ------------------
  |  Branch (404:9): [True: 0, False: 341]
  ------------------
  405|      0|        key = NULL;
  406|      0|        goto on_return;
  407|      0|    }
  408|       |
  409|       |    /* Set socket to nonblocking. */
  410|    341|    value = 1;
  411|       |#if defined(PJ_WIN32) && PJ_WIN32!=0 || \
  412|       |    defined(PJ_WIN64) && PJ_WIN64 != 0 || \
  413|       |    defined(PJ_WIN32_WINCE) && PJ_WIN32_WINCE!=0
  414|       |    if (ioctlsocket(sock, FIONBIO, &value)) {
  415|       |#else
  416|    341|    if (ioctl(sock, FIONBIO, &value)) {
  ------------------
  |  Branch (416:9): [True: 0, False: 341]
  ------------------
  417|      0|#endif
  418|      0|        rc = pj_get_netos_error();
  419|      0|        goto on_return;
  420|      0|    }
  421|       |
  422|       |
  423|       |    /* Put in active list. */
  424|    341|    pj_list_insert_before(&ioqueue->active_list, key);
  425|    341|    ++ioqueue->count;
  426|       |
  427|       |    /* Rescan fdset to get max descriptor */
  428|    341|    rescan_fdset(ioqueue);
  429|       |
  430|    341|on_return:
  431|       |    /* On error, socket may be left in non-blocking mode. */
  432|    341|    if (rc != PJ_SUCCESS) {
  ------------------
  |  Branch (432:9): [True: 0, False: 341]
  ------------------
  433|      0|        if (key && key->grp_lock)
  ------------------
  |  Branch (433:13): [True: 0, False: 0]
  |  Branch (433:20): [True: 0, False: 0]
  ------------------
  434|      0|            pj_grp_lock_dec_ref_dbg(key->grp_lock, "ioqueue", 0);
  ------------------
  |  |  382|      0|#define pj_grp_lock_dec_ref_dbg(grp_lock, x, y) pj_grp_lock_dec_ref(grp_lock)
  ------------------
  435|      0|    }
  436|    341|    *p_key = key;
  437|    341|    pj_lock_release(ioqueue->lock);
  438|       |    
  439|    341|    return rc;
  440|    341|}
pj_ioqueue_unregister:
  496|    341|{
  497|    341|    pj_ioqueue_t *ioqueue;
  498|       |
  499|    341|    PJ_ASSERT_RETURN(key, PJ_EINVAL);
  ------------------
  |  |   97|    341|            do { \
  |  |   98|    341|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 341]
  |  |  ------------------
  |  |   99|    341|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 341]
  |  |  ------------------
  ------------------
  |  Branch (499:5): [True: 0, False: 0]
  |  Branch (499:5): [True: 0, False: 0]
  ------------------
  500|       |
  501|    341|    ioqueue = key->ioqueue;
  502|       |
  503|       |    /* Lock the key to make sure no callback is simultaneously modifying
  504|       |     * the key. We need to lock the key before ioqueue here to prevent
  505|       |     * deadlock.
  506|       |     */
  507|    341|    pj_ioqueue_lock_key(key);
  508|       |
  509|       |    /* Best effort to avoid double key-unregistration */
  510|    341|    if (IS_CLOSING(key)) {
  ------------------
  |  |  200|    341|#define IS_CLOSING(key) (key->closing)
  |  |  ------------------
  |  |  |  Branch (200:25): [True: 0, False: 341]
  |  |  ------------------
  ------------------
  511|      0|        pj_ioqueue_unlock_key(key);
  512|      0|        return PJ_SUCCESS;
  513|      0|    }
  514|       |
  515|       |    /* Also lock ioqueue */
  516|    341|    pj_lock_acquire(ioqueue->lock);
  517|       |
  518|       |    /* Avoid "negative" ioqueue count */
  519|    341|    if (ioqueue->count > 0) {
  ------------------
  |  Branch (519:9): [True: 341, False: 0]
  ------------------
  520|    341|        --ioqueue->count;
  521|    341|    } else {
  522|       |        /* If this happens, very likely there is double unregistration
  523|       |         * of a key.
  524|       |         */
  525|      0|        pj_assert(!"Bad ioqueue count in key unregistration!");
  ------------------
  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (525:9): [Folded, False: 0]
  |  Branch (525:9): [Folded, False: 0]
  ------------------
  526|      0|        PJ_LOG(1,(THIS_FILE, "Bad ioqueue count in key unregistration!"));
  ------------------
  |  |  106|      0|#define PJ_LOG(level,arg)       do { \
  |  |  107|      0|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|      0|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 0, Folded]
  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  432|      0|    #define pj_log_wrapper_1(arg)       pj_log_1 arg
  |  |  ------------------
  |  |  109|      0|                                    } \
  |  |  110|      0|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 0]
  |  |  ------------------
  ------------------
  527|      0|    }
  528|       |
  529|       |#if !PJ_IOQUEUE_HAS_SAFE_UNREG
  530|       |    /* Ticket #520, key will be erased more than once */
  531|       |    pj_list_erase(key);
  532|       |#endif
  533|       |
  534|       |    /* Remove socket from sets and close socket. */
  535|    341|    if (key->fd != PJ_INVALID_SOCKET) {
  ------------------
  |  |  492|    341|#define PJ_INVALID_SOCKET   (-1)
  ------------------
  |  Branch (535:9): [True: 341, False: 0]
  ------------------
  536|    341|        PJ_FD_CLR(key->fd, &ioqueue->rfdset);
  537|    341|        PJ_FD_CLR(key->fd, &ioqueue->wfdset);
  538|    341|#if PJ_HAS_TCP
  539|    341|        PJ_FD_CLR(key->fd, &ioqueue->xfdset);
  540|    341|#endif
  541|       |
  542|    341|        pj_sock_close(key->fd);
  543|    341|        key->fd = PJ_INVALID_SOCKET;
  ------------------
  |  |  492|    341|#define PJ_INVALID_SOCKET   (-1)
  ------------------
  544|    341|    }
  545|       |
  546|       |    /* Clear callback */
  547|    341|    key->cb.on_accept_complete = NULL;
  548|    341|    key->cb.on_connect_complete = NULL;
  549|    341|    key->cb.on_read_complete = NULL;
  550|    341|    key->cb.on_write_complete = NULL;
  551|       |
  552|       |    /* Must release ioqueue lock first before decrementing counter, to
  553|       |     * prevent deadlock.
  554|       |     */
  555|    341|    pj_lock_release(ioqueue->lock);
  556|       |
  557|       |    /* Mark key is closing. */
  558|    341|    key->closing = 1;
  559|       |
  560|    341|    pj_ioqueue_unlock_key(key);
  561|       |
  562|    341|#if PJ_IOQUEUE_HAS_SAFE_UNREG
  563|       |    /* Decrement counter. */
  564|    341|    decrement_counter(key);
  565|       |#else
  566|       |    /* Destroy the key lock */
  567|       |    pj_lock_destroy(key->lock);
  568|       |#endif
  569|       |
  570|       |    /* Done. */
  571|    341|    if (key->grp_lock) {
  ------------------
  |  Branch (571:9): [True: 341, False: 0]
  ------------------
  572|    341|        pj_grp_lock_dec_ref_dbg(key->grp_lock, "ioqueue", 0);
  ------------------
  |  |  382|    341|#define pj_grp_lock_dec_ref_dbg(grp_lock, x, y) pj_grp_lock_dec_ref(grp_lock)
  ------------------
  573|    341|    }
  574|       |
  575|    341|    return PJ_SUCCESS;
  576|    341|}
ioqueue_select.c:rescan_fdset:
  182|  1.91k|{
  183|       |    ioqueue->nfds = FD_SETSIZE-1;
  184|  1.91k|}
ioqueue_select.c:decrement_counter:
  468|    341|{
  469|    341|    pj_lock_acquire(key->ioqueue->lock);
  470|    341|    pj_mutex_lock(key->ioqueue->ref_cnt_mutex);
  471|    341|    --key->ref_count;
  472|    341|    if (key->ref_count == 0) {
  ------------------
  |  Branch (472:9): [True: 341, False: 0]
  ------------------
  473|       |
  474|    341|        pj_assert(key->closing == 1);
  ------------------
  |  |   65|    341|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (474:9): [True: 0, False: 341]
  |  Branch (474:9): [True: 341, False: 0]
  ------------------
  475|    341|        pj_gettickcount(&key->free_time);
  476|    341|        key->free_time.msec += PJ_IOQUEUE_KEY_FREE_DELAY;
  ------------------
  |  |  799|    341|#   define PJ_IOQUEUE_KEY_FREE_DELAY    500
  ------------------
  477|    341|        pj_time_val_normalize(&key->free_time);
  478|       |
  479|    341|        pj_list_erase(key);
  480|    341|        pj_list_push_back(&key->ioqueue->closing_list, key);
  481|       |        /* Rescan fdset to get max descriptor */
  482|    341|        rescan_fdset(key->ioqueue);
  483|    341|    }
  484|    341|    pj_mutex_unlock(key->ioqueue->ref_cnt_mutex);
  485|    341|    pj_lock_release(key->ioqueue->lock);
  486|    341|}
ioqueue_select.c:ioqueue_add_to_set:
  677|    341|{
  678|    341|    ioqueue_add_to_set2(ioqueue, key, event_type);
  679|    341|}
ioqueue_select.c:ioqueue_add_to_set2:
  684|    341|{
  685|    341|    pj_lock_acquire(ioqueue->lock);
  686|       |
  687|    341|    if (event_types & READABLE_EVENT)
  ------------------
  |  Branch (687:9): [True: 341, False: 0]
  ------------------
  688|    341|        PJ_FD_SET((pj_sock_t)key->fd, &ioqueue->rfdset);
  689|    341|    if (event_types & WRITEABLE_EVENT)
  ------------------
  |  Branch (689:9): [True: 0, False: 341]
  ------------------
  690|      0|        PJ_FD_SET((pj_sock_t)key->fd, &ioqueue->wfdset);
  691|    341|#if defined(PJ_HAS_TCP) && PJ_HAS_TCP!=0
  692|    341|    if (event_types & EXCEPTION_EVENT)
  ------------------
  |  Branch (692:9): [True: 0, False: 341]
  ------------------
  693|      0|        PJ_FD_SET((pj_sock_t)key->fd, &ioqueue->xfdset);
  694|    341|#endif
  695|       |
  696|    341|    pj_lock_release(ioqueue->lock);
  697|    341|}
ioqueue_select.c:scan_closing_keys:
  702|    341|{
  703|    341|    pj_time_val now;
  704|    341|    pj_ioqueue_key_t *h;
  705|       |
  706|    341|    pj_gettickcount(&now);
  707|    341|    h = ioqueue->closing_list.next;
  708|    341|    while (h != &ioqueue->closing_list) {
  ------------------
  |  Branch (708:12): [True: 0, False: 341]
  ------------------
  709|      0|        pj_ioqueue_key_t *next = h->next;
  710|       |
  711|      0|        pj_assert(h->closing != 0);
  ------------------
  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (711:9): [True: 0, False: 0]
  |  Branch (711:9): [True: 0, False: 0]
  ------------------
  712|       |
  713|      0|        if (PJ_TIME_VAL_GTE(now, h->free_time)) {
  ------------------
  |  |  508|      0|#define PJ_TIME_VAL_GTE(t1, t2) (PJ_TIME_VAL_GT(t1,t2) || \
  |  |  ------------------
  |  |  |  |  497|      0|#define PJ_TIME_VAL_GT(t1, t2)  ((t1).sec>(t2).sec || \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (497:34): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  498|      0|                                ((t1).sec==(t2).sec && (t1).msec>(t2).msec))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (498:34): [True: 0, False: 0]
  |  |  |  |  |  Branch (498:56): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  509|      0|                                 PJ_TIME_VAL_EQ(t1,t2))
  |  |  ------------------
  |  |  |  |  487|      0|#define PJ_TIME_VAL_EQ(t1, t2)  ((t1).sec==(t2).sec && (t1).msec==(t2).msec)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (487:34): [True: 0, False: 0]
  |  |  |  |  |  Branch (487:56): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  714|      0|            pj_list_erase(h);
  715|       |            // Don't set grp_lock to NULL otherwise the other thread
  716|       |            // will crash. Just leave it as dangling pointer, but this
  717|       |            // should be safe
  718|       |            //h->grp_lock = NULL;
  719|      0|            pj_list_push_back(&ioqueue->free_list, h);
  720|      0|        }
  721|      0|        h = next;
  722|      0|    }
  723|    341|}

pj_enum_ip_interface:
  420|    682|{
  421|    682|    unsigned start;
  422|    682|    pj_status_t status;
  423|       |
  424|    682|    PJ_ASSERT_RETURN(p_cnt && *p_cnt > 0 && ifs, PJ_EINVAL);
  ------------------
  |  |   97|    682|            do { \
  |  |   98|  2.72k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 682, False: 0]
  |  |  |  Branch (98:23): [True: 682, False: 0]
  |  |  |  Branch (98:23): [True: 682, False: 0]
  |  |  ------------------
  |  |   99|    682|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 682]
  |  |  ------------------
  ------------------
  |  Branch (424:5): [True: 0, False: 0]
  |  Branch (424:5): [True: 0, False: 0]
  |  Branch (424:5): [True: 0, False: 0]
  |  Branch (424:5): [True: 0, False: 0]
  |  Branch (424:5): [True: 0, False: 0]
  |  Branch (424:5): [True: 0, False: 0]
  ------------------
  425|    682|    pj_bzero(ifs, sizeof(ifs[0]) * (*p_cnt));
  426|       |
  427|    682|    start = 0;
  428|    682|    if (af==PJ_AF_INET6 || af==PJ_AF_UNSPEC) {
  ------------------
  |  Branch (428:9): [True: 0, False: 682]
  |  Branch (428:28): [True: 0, False: 682]
  ------------------
  429|      0|        unsigned max = *p_cnt;
  430|      0|        status = if_enum_by_af(PJ_AF_INET6, &max, &ifs[start]);
  431|      0|        if (status == PJ_SUCCESS) {
  ------------------
  |  Branch (431:13): [True: 0, False: 0]
  ------------------
  432|      0|            start += max;
  433|      0|            (*p_cnt) -= max;
  434|      0|        }
  435|      0|    }
  436|       |
  437|    682|    if (af==PJ_AF_INET || af==PJ_AF_UNSPEC) {
  ------------------
  |  Branch (437:9): [True: 682, False: 0]
  |  Branch (437:27): [True: 0, False: 0]
  ------------------
  438|    682|        unsigned max = *p_cnt;
  439|    682|        status = if_enum_by_af(PJ_AF_INET, &max, &ifs[start]);
  440|    682|        if (status == PJ_SUCCESS) {
  ------------------
  |  Branch (440:13): [True: 682, False: 0]
  ------------------
  441|    682|            start += max;
  442|    682|            (*p_cnt) -= max;
  443|    682|        }
  444|    682|    }
  445|       |
  446|    682|    *p_cnt = start;
  447|       |
  448|    682|    return (*p_cnt != 0) ? PJ_SUCCESS : PJ_ENOTFOUND;
  ------------------
  |  |  403|      0|#define PJ_ENOTFOUND        (PJ_ERRNO_START_STATUS + 6) /* 70006 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (448:12): [True: 682, False: 0]
  ------------------
  449|    682|}
pj_enum_ip_interface2:
  597|    341|{
  598|    341|    pj_enum_ip_option opt_;
  599|       |
  600|    341|    if (opt)
  ------------------
  |  Branch (600:9): [True: 341, False: 0]
  ------------------
  601|    341|        opt_ = *opt;
  602|      0|    else
  603|      0|        pj_enum_ip_option_default(&opt_);
  604|       |
  605|    341|    if (opt_.af != pj_AF_INET() && opt_.omit_deprecated_ipv6) {
  ------------------
  |  |  113|    682|#   define pj_AF_INET()     PJ_AF_INET
  ------------------
  |  Branch (605:9): [True: 0, False: 341]
  |  Branch (605:36): [True: 0, False: 0]
  ------------------
  606|       |
  607|      0|#if defined(PJ_LINUX) && PJ_LINUX!=0
  608|      0|        pj_sockaddr addrs[*p_cnt];
  609|      0|        pj_sockaddr deprecatedAddrs[*p_cnt];
  610|      0|        unsigned deprecatedCount = *p_cnt;
  611|      0|        unsigned cnt = 0;
  612|      0|        unsigned i;
  613|      0|        pj_status_t status;
  614|       |
  615|      0|        status = get_ipv6_deprecated(&deprecatedCount, deprecatedAddrs);
  616|      0|        if (status != PJ_SUCCESS)
  ------------------
  |  Branch (616:13): [True: 0, False: 0]
  ------------------
  617|      0|            return status;
  618|       |
  619|      0|        status = pj_enum_ip_interface(opt_.af, p_cnt, addrs);
  620|      0|        if (status != PJ_SUCCESS)
  ------------------
  |  Branch (620:13): [True: 0, False: 0]
  ------------------
  621|      0|            return status;
  622|       |
  623|      0|        for (i = 0; i < *p_cnt; ++i) {
  ------------------
  |  Branch (623:21): [True: 0, False: 0]
  ------------------
  624|      0|            unsigned j;
  625|       |
  626|      0|            ifs[cnt++] = addrs[i];
  627|       |
  628|      0|            if (addrs[i].addr.sa_family != pj_AF_INET6())
  ------------------
  |  |  115|      0|#   define pj_AF_INET6()    PJ_AF_INET6
  ------------------
  |  Branch (628:17): [True: 0, False: 0]
  ------------------
  629|      0|                continue;
  630|       |
  631|      0|            for (j = 0; j < deprecatedCount; ++j) {
  ------------------
  |  Branch (631:25): [True: 0, False: 0]
  ------------------
  632|      0|                if (pj_sockaddr_cmp(&addrs[i], &deprecatedAddrs[j]) == 0) {
  ------------------
  |  Branch (632:21): [True: 0, False: 0]
  ------------------
  633|      0|                    cnt--;
  634|      0|                    break;
  635|      0|                }
  636|      0|            }
  637|      0|        }
  638|       |
  639|      0|        *p_cnt = cnt;
  640|      0|        return *p_cnt ? PJ_SUCCESS : PJ_ENOTFOUND;
  ------------------
  |  |  403|      0|#define PJ_ENOTFOUND        (PJ_ERRNO_START_STATUS + 6) /* 70006 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (640:16): [True: 0, False: 0]
  ------------------
  641|       |#else
  642|       |        return PJ_ENOTSUP;
  643|       |#endif
  644|      0|    }
  645|       |
  646|    341|    return pj_enum_ip_interface(opt_.af, p_cnt, ifs);
  647|    341|}
ip_helper_generic.c:if_enum_by_af:
   72|    682|{
   73|    682|    struct ifaddrs *ifap = NULL, *it;
   74|    682|    unsigned max;
   75|       |
   76|    682|    PJ_ASSERT_RETURN(af==PJ_AF_INET || af==PJ_AF_INET6, PJ_EINVAL);
  ------------------
  |  |   97|    682|            do { \
  |  |   98|    682|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 682, False: 0]
  |  |  |  Branch (98:23): [True: 0, False: 0]
  |  |  ------------------
  |  |   99|    682|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 682]
  |  |  ------------------
  ------------------
  |  Branch (76:5): [True: 0, False: 0]
  |  Branch (76:5): [True: 0, False: 0]
  |  Branch (76:5): [True: 0, False: 0]
  |  Branch (76:5): [True: 0, False: 0]
  ------------------
   77|       |    
   78|    682|    TRACE_((THIS_FILE, "Starting interface enum with getifaddrs() for af=%d",
   79|    682|            af));
   80|       |
   81|    682|    if (getifaddrs(&ifap) != 0) {
  ------------------
  |  Branch (81:9): [True: 0, False: 682]
  ------------------
   82|      0|        TRACE_((THIS_FILE, " getifarrds() failed: %s", get_os_errmsg()));
   83|      0|        return PJ_RETURN_OS_ERROR(pj_get_netos_error());
  ------------------
  |  |  319|      0|#   define PJ_RETURN_OS_ERROR(os_code)   (os_code ? \
  |  |  ------------------
  |  |  |  Branch (319:43): [True: 0, False: 0]
  |  |  ------------------
  |  |  320|      0|                                            PJ_STATUS_FROM_OS(os_code) : -1)
  |  |  ------------------
  |  |  |  |  334|      0|#   define PJ_STATUS_FROM_OS(e) (e == 0 ? PJ_SUCCESS : e + PJ_ERRNO_START_SYS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  528|      0|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (334:34): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   84|      0|    }
   85|       |
   86|    682|    it = ifap;
   87|    682|    max = *p_cnt;
   88|    682|    *p_cnt = 0;
   89|  3.41k|    for (; it!=NULL && *p_cnt < max; it = it->ifa_next) {
  ------------------
  |  Branch (89:12): [True: 2.72k, False: 682]
  |  Branch (89:24): [True: 2.72k, False: 0]
  ------------------
   90|  2.72k|        struct sockaddr *ad = it->ifa_addr;
   91|       |
   92|  2.72k|        TRACE_((THIS_FILE, " checking %s", it->ifa_name));
   93|       |
   94|  2.72k|        if ((it->ifa_flags & IFF_UP)==0) {
  ------------------
  |  Branch (94:13): [True: 0, False: 2.72k]
  ------------------
   95|      0|            TRACE_((THIS_FILE, "  interface is down"));
   96|      0|            continue; /* Skip when interface is down */
   97|      0|        }
   98|       |
   99|  2.72k|        if ((it->ifa_flags & IFF_RUNNING)==0) {
  ------------------
  |  Branch (99:13): [True: 0, False: 2.72k]
  ------------------
  100|      0|            TRACE_((THIS_FILE, "  interface is not running"));
  101|      0|            continue; /* Skip when interface is not running */
  102|      0|        }
  103|       |
  104|  2.72k|#if PJ_IP_HELPER_IGNORE_LOOPBACK_IF
  105|  2.72k|        if (it->ifa_flags & IFF_LOOPBACK) {
  ------------------
  |  Branch (105:13): [True: 1.36k, False: 1.36k]
  ------------------
  106|  1.36k|            TRACE_((THIS_FILE, "  loopback interface"));
  107|  1.36k|            continue; /* Skip loopback interface */
  108|  1.36k|        }
  109|  1.36k|#endif
  110|       |
  111|  1.36k|        if (ad==NULL) {
  ------------------
  |  Branch (111:13): [True: 0, False: 1.36k]
  ------------------
  112|      0|            TRACE_((THIS_FILE, "  NULL address ignored"));
  113|      0|            continue; /* reported to happen on Linux 2.6.25.9 
  114|       |                         with ppp interface */
  115|      0|        }
  116|       |
  117|  1.36k|        if (ad->sa_family != af) {
  ------------------
  |  Branch (117:13): [True: 682, False: 682]
  ------------------
  118|    682|            TRACE_((THIS_FILE, "  address %s ignored (af=%d)", 
  119|    682|                    get_addr(ad), ad->sa_family));
  120|    682|            continue; /* Skip when interface is down */
  121|    682|        }
  122|       |
  123|       |        /* Ignore 192.0.0.0/29 address.
  124|       |         * Ref: https://datatracker.ietf.org/doc/html/rfc7335#section-4
  125|       |         */
  126|    682|        if (af==pj_AF_INET() &&
  ------------------
  |  |  113|  1.36k|#   define pj_AF_INET()     PJ_AF_INET
  ------------------
  |  Branch (126:13): [True: 682, False: 0]
  ------------------
  127|    682|            (pj_ntohl(((pj_sockaddr_in*)ad)->sin_addr.s_addr) >> 4) ==
  ------------------
  |  Branch (127:13): [True: 0, False: 682]
  ------------------
  128|    682|             201326592) /* 0b1100000000000000000000000000 which is
  129|       |                           192.0.0.0 >> 4 */
  130|      0|        {
  131|      0|            TRACE_((THIS_FILE, "  address %s ignored (192.0.0.0/29 class)",
  132|      0|                    get_addr(ad), ad->sa_family));
  133|      0|            continue;
  134|      0|        }
  135|       |
  136|       |        /* Ignore 0.0.0.0/8 address. This is a special address
  137|       |         * which doesn't seem to have practical use.
  138|       |         */
  139|    682|        if (af==pj_AF_INET() &&
  ------------------
  |  |  113|  1.36k|#   define pj_AF_INET()     PJ_AF_INET
  ------------------
  |  Branch (139:13): [True: 682, False: 0]
  ------------------
  140|    682|            (pj_ntohl(((pj_sockaddr_in*)ad)->sin_addr.s_addr) >> 24) == 0)
  ------------------
  |  Branch (140:13): [True: 0, False: 682]
  ------------------
  141|      0|        {
  142|      0|            TRACE_((THIS_FILE, "  address %s ignored (0.0.0.0/8 class)", 
  143|      0|                    get_addr(ad), ad->sa_family));
  144|      0|            continue;
  145|      0|        }
  146|       |
  147|    682|        TRACE_((THIS_FILE, "  address %s (af=%d) added at index %d", 
  148|    682|                get_addr(ad), ad->sa_family, *p_cnt));
  149|       |
  150|    682|        pj_bzero(&ifs[*p_cnt], sizeof(ifs[0]));
  151|    682|        pj_memcpy(&ifs[*p_cnt], ad, pj_sockaddr_get_len(ad));
  152|    682|        PJ_SOCKADDR_RESET_LEN(&ifs[*p_cnt]);
  153|    682|        (*p_cnt)++;
  154|    682|    }
  155|       |
  156|    682|    freeifaddrs(ifap);
  157|    682|    TRACE_((THIS_FILE, "done, found %d address(es)", *p_cnt));
  158|    682|    return (*p_cnt != 0) ? PJ_SUCCESS : PJ_ENOTFOUND;
  ------------------
  |  |  403|      0|#define PJ_ENOTFOUND        (PJ_ERRNO_START_STATUS + 6) /* 70006 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (158:12): [True: 682, False: 0]
  ------------------
  159|    682|}

pj_lock_create_simple_mutex:
   87|  2.48k|{
   88|  2.48k|    return create_mutex_lock(pool, name, PJ_MUTEX_SIMPLE, lock);
   89|  2.48k|}
pj_lock_create_recursive_mutex:
   94|  7.54k|{
   95|  7.54k|    return create_mutex_lock(pool, name, PJ_MUTEX_RECURSE, lock);
   96|  7.54k|}
pj_lock_create_null_mutex:
  120|  1.24k|{
  121|  1.24k|    PJ_UNUSED_ARG(name);
  ------------------
  |  | 1537|  1.24k|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
  122|  1.24k|    PJ_UNUSED_ARG(pool);
  ------------------
  |  | 1537|  1.24k|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
  123|       |
  124|  1.24k|    PJ_ASSERT_RETURN(lock, PJ_EINVAL);
  ------------------
  |  |   97|  1.24k|            do { \
  |  |   98|  1.24k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 1.24k]
  |  |  ------------------
  |  |   99|  1.24k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1.24k]
  |  |  ------------------
  ------------------
  |  Branch (124:5): [True: 0, False: 0]
  |  Branch (124:5): [True: 0, False: 0]
  ------------------
  125|       |
  126|  1.24k|    *lock = &null_lock_template;
  127|  1.24k|    return PJ_SUCCESS;
  128|  1.24k|}
pj_lock_acquire:
  177|  28.8k|{
  178|  28.8k|    PJ_ASSERT_RETURN(lock != NULL, PJ_EINVAL);
  ------------------
  |  |   97|  28.8k|            do { \
  |  |   98|  28.8k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 28.8k]
  |  |  ------------------
  |  |   99|  28.8k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 28.8k]
  |  |  ------------------
  ------------------
  |  Branch (178:5): [True: 0, False: 0]
  |  Branch (178:5): [True: 0, False: 0]
  ------------------
  179|  28.8k|    return (*lock->acquire)(lock->lock_object);
  180|  28.8k|}
pj_lock_release:
  189|  28.8k|{
  190|  28.8k|    PJ_ASSERT_RETURN(lock != NULL, PJ_EINVAL);
  ------------------
  |  |   97|  28.8k|            do { \
  |  |   98|  28.8k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 28.8k]
  |  |  ------------------
  |  |   99|  28.8k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 28.8k]
  |  |  ------------------
  ------------------
  |  Branch (190:5): [True: 0, False: 0]
  |  Branch (190:5): [True: 0, False: 0]
  ------------------
  191|  28.8k|    return (*lock->release)(lock->lock_object);
  192|  28.8k|}
pj_lock_destroy:
  195|  9.13k|{
  196|  9.13k|    PJ_ASSERT_RETURN(lock != NULL, PJ_EINVAL);
  ------------------
  |  |   97|  9.13k|            do { \
  |  |   98|  9.13k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 9.13k]
  |  |  ------------------
  |  |   99|  9.13k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 9.13k]
  |  |  ------------------
  ------------------
  |  Branch (196:5): [True: 0, False: 0]
  |  Branch (196:5): [True: 0, False: 0]
  ------------------
  197|  9.13k|    return (*lock->destroy)(lock->lock_object);
  198|  9.13k|}
pj_grp_lock_create:
  413|  1.23k|{
  414|  1.23k|    pj_grp_lock_t *glock;
  415|  1.23k|    grp_lock_item *own_lock;
  416|  1.23k|    pj_status_t status;
  417|       |
  418|  1.23k|    PJ_ASSERT_RETURN(pool && p_grp_lock, PJ_EINVAL);
  ------------------
  |  |   97|  1.23k|            do { \
  |  |   98|  2.47k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 1.23k, False: 0]
  |  |  |  Branch (98:23): [True: 1.23k, False: 0]
  |  |  ------------------
  |  |   99|  1.23k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1.23k]
  |  |  ------------------
  ------------------
  |  Branch (418:5): [True: 0, False: 0]
  |  Branch (418:5): [True: 0, False: 0]
  |  Branch (418:5): [True: 0, False: 0]
  |  Branch (418:5): [True: 0, False: 0]
  ------------------
  419|       |
  420|  1.23k|    PJ_UNUSED_ARG(cfg);
  ------------------
  |  | 1537|  1.23k|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
  421|       |
  422|  1.23k|    pool = pj_pool_create(pool->factory, "glck%p", 512, 512, NULL);
  423|  1.23k|    if (!pool)
  ------------------
  |  Branch (423:9): [True: 0, False: 1.23k]
  ------------------
  424|      0|        return PJ_ENOMEM;
  ------------------
  |  |  408|      0|#define PJ_ENOMEM           (PJ_ERRNO_START_STATUS + 7) /* 70007 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  425|       |
  426|  1.23k|    glock = PJ_POOL_ZALLOC_T(pool, pj_grp_lock_t);
  ------------------
  |  |  583|  1.23k|            ((type*)pj_pool_zalloc(pool, sizeof(type)))
  ------------------
  427|  1.23k|    glock->base.lock_object = glock;
  428|  1.23k|    glock->base.acquire = &grp_lock_acquire;
  429|  1.23k|    glock->base.tryacquire = &grp_lock_tryacquire;
  430|  1.23k|    glock->base.release = &grp_lock_release;
  431|  1.23k|    glock->base.destroy = &grp_lock_destroy;
  432|       |
  433|  1.23k|    glock->pool = pool;
  434|  1.23k|    pj_list_init(&glock->lock_list);
  435|  1.23k|    pj_list_init(&glock->destroy_list);
  436|       |#if PJ_GRP_LOCK_DEBUG
  437|       |    pj_list_init(&glock->ref_list);
  438|       |    pj_list_init(&glock->ref_free_list);
  439|       |#endif
  440|       |
  441|  1.23k|    status = pj_atomic_create(pool, 0, &glock->ref_cnt);
  442|  1.23k|    if (status != PJ_SUCCESS)
  ------------------
  |  Branch (442:9): [True: 0, False: 1.23k]
  ------------------
  443|      0|        goto on_error;
  444|       |
  445|  1.23k|    status = pj_lock_create_recursive_mutex(pool, pool->obj_name,
  446|  1.23k|                                            &glock->own_lock);
  447|  1.23k|    if (status != PJ_SUCCESS)
  ------------------
  |  Branch (447:9): [True: 0, False: 1.23k]
  ------------------
  448|      0|        goto on_error;
  449|       |
  450|  1.23k|    own_lock = PJ_POOL_ZALLOC_T(pool, grp_lock_item);
  ------------------
  |  |  583|  1.23k|            ((type*)pj_pool_zalloc(pool, sizeof(type)))
  ------------------
  451|  1.23k|    own_lock->lock = glock->own_lock;
  452|  1.23k|    pj_list_push_back(&glock->lock_list, own_lock);
  453|       |
  454|  1.23k|    *p_grp_lock = glock;
  455|  1.23k|    return PJ_SUCCESS;
  456|       |
  457|      0|on_error:
  458|      0|    grp_lock_destroy(glock);
  459|      0|    return status;
  460|  1.23k|}
pj_grp_lock_acquire:
  485|  11.2k|{
  486|  11.2k|    return grp_lock_acquire(grp_lock);
  487|  11.2k|}
pj_grp_lock_release:
  495|  11.2k|{
  496|  11.2k|    return grp_lock_release(grp_lock);
  497|  11.2k|}
pj_grp_lock_add_handler:
  527|  3.49k|{
  528|  3.49k|    return grp_lock_add_handler(glock, pool, comp, destroy, PJ_TRUE);
  529|  3.49k|}
pj_grp_lock_add_ref:
  648|  19.4k|{
  649|  19.4k|    return grp_lock_add_ref(glock);
  650|  19.4k|}
pj_grp_lock_dec_ref:
  653|  16.7k|{
  654|  16.7k|    return grp_lock_dec_ref(glock);
  655|  16.7k|}
lock.c:create_mutex_lock:
   62|  10.0k|{
   63|  10.0k|    pj_lock_t *p_lock;
   64|  10.0k|    pj_mutex_t *mutex;
   65|  10.0k|    pj_status_t rc;
   66|       |
   67|  10.0k|    PJ_ASSERT_RETURN(pool && lock, PJ_EINVAL);
  ------------------
  |  |   97|  10.0k|            do { \
  |  |   98|  20.0k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 10.0k, False: 0]
  |  |  |  Branch (98:23): [True: 10.0k, False: 0]
  |  |  ------------------
  |  |   99|  10.0k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 10.0k]
  |  |  ------------------
  ------------------
  |  Branch (67:5): [True: 0, False: 0]
  |  Branch (67:5): [True: 0, False: 0]
  |  Branch (67:5): [True: 0, False: 0]
  |  Branch (67:5): [True: 0, False: 0]
  ------------------
   68|       |
   69|  10.0k|    p_lock = PJ_POOL_ALLOC_T(pool, pj_lock_t);
  ------------------
  |  |  569|  10.0k|            ((type*)pj_pool_alloc(pool, sizeof(type)))
  ------------------
   70|  10.0k|    if (!p_lock)
  ------------------
  |  Branch (70:9): [True: 0, False: 10.0k]
  ------------------
   71|      0|        return PJ_ENOMEM;
  ------------------
  |  |  408|      0|#define PJ_ENOMEM           (PJ_ERRNO_START_STATUS + 7) /* 70007 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   72|       |
   73|  10.0k|    pj_memcpy(p_lock, &mutex_lock_template, sizeof(pj_lock_t));
   74|  10.0k|    rc = pj_mutex_create(pool, name, type, &mutex);
   75|  10.0k|    if (rc != PJ_SUCCESS)
  ------------------
  |  Branch (75:9): [True: 0, False: 10.0k]
  ------------------
   76|      0|        return rc;
   77|       |
   78|  10.0k|    p_lock->lock_object = mutex;
   79|  10.0k|    *lock = p_lock;
   80|  10.0k|    return PJ_SUCCESS;
   81|  10.0k|}
lock.c:grp_lock_acquire:
  289|  14.7k|{
  290|  14.7k|    pj_grp_lock_t *glock = (pj_grp_lock_t*)p;
  291|  14.7k|    grp_lock_item *lck;
  292|       |
  293|  14.7k|    pj_assert(pj_atomic_get(glock->ref_cnt) > 0);
  ------------------
  |  |   65|  14.7k|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (293:5): [True: 0, False: 14.7k]
  |  Branch (293:5): [True: 14.7k, False: 0]
  ------------------
  294|       |
  295|  14.7k|    lck = glock->lock_list.next;
  296|  29.4k|    while (lck != &glock->lock_list) {
  ------------------
  |  Branch (296:12): [True: 14.7k, False: 14.7k]
  ------------------
  297|  14.7k|        pj_lock_acquire(lck->lock);
  298|  14.7k|        lck = lck->next;
  299|  14.7k|    }
  300|  14.7k|    grp_lock_set_owner_thread(glock);
  301|  14.7k|    pj_grp_lock_add_ref(glock);
  302|  14.7k|    return PJ_SUCCESS;
  303|  14.7k|}
lock.c:grp_lock_set_owner_thread:
  260|  14.7k|{
  261|  14.7k|    if (!glock->owner) {
  ------------------
  |  Branch (261:9): [True: 9.10k, False: 5.61k]
  ------------------
  262|  9.10k|#if PJ_HAS_THREADS
  263|  9.10k|        glock->owner = pj_thread_this();
  264|       |#else
  265|       |        glock->owner = (pj_thread_t *) -1;
  266|       |#endif
  267|  9.10k|        glock->owner_cnt = 1;
  268|  9.10k|    } else {
  269|  5.61k|#if PJ_HAS_THREADS
  270|  5.61k|        pj_assert(glock->owner == pj_thread_this());
  ------------------
  |  |   65|  5.61k|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (270:9): [True: 0, False: 5.61k]
  |  Branch (270:9): [True: 5.61k, False: 0]
  ------------------
  271|  5.61k|#endif
  272|  5.61k|        glock->owner_cnt++;
  273|  5.61k|    }
  274|  14.7k|}
lock.c:grp_lock_release:
  331|  14.7k|{
  332|  14.7k|    pj_grp_lock_t *glock = (pj_grp_lock_t*)p;
  333|  14.7k|    grp_lock_item *lck;
  334|       |
  335|  14.7k|    grp_lock_unset_owner_thread(glock);
  336|       |
  337|  14.7k|    lck = glock->lock_list.prev;
  338|  29.4k|    while (lck != &glock->lock_list) {
  ------------------
  |  Branch (338:12): [True: 14.7k, False: 14.7k]
  ------------------
  339|  14.7k|        pj_lock_release(lck->lock);
  340|  14.7k|        lck = lck->prev;
  341|  14.7k|    }
  342|  14.7k|    return pj_grp_lock_dec_ref(glock);
  343|  14.7k|}
lock.c:grp_lock_unset_owner_thread:
  277|  14.7k|{
  278|  14.7k|#if PJ_HAS_THREADS
  279|  14.7k|    pj_assert(glock->owner == pj_thread_this());
  ------------------
  |  |   65|  14.7k|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (279:5): [True: 0, False: 14.7k]
  |  Branch (279:5): [True: 14.7k, False: 0]
  ------------------
  280|  14.7k|#endif
  281|  14.7k|    pj_assert(glock->owner_cnt > 0);
  ------------------
  |  |   65|  14.7k|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (281:5): [True: 0, False: 14.7k]
  |  Branch (281:5): [True: 14.7k, False: 0]
  ------------------
  282|  14.7k|    if (--glock->owner_cnt <= 0) {
  ------------------
  |  Branch (282:9): [True: 9.10k, False: 5.61k]
  ------------------
  283|       |        glock->owner = NULL;
  284|  9.10k|        glock->owner_cnt = 0;
  285|  9.10k|    }
  286|  14.7k|}
lock.c:grp_lock_destroy:
  371|    341|{
  372|    341|    pj_grp_lock_t *glock = (pj_grp_lock_t*)p;
  373|    341|    pj_pool_t *pool = glock->pool;
  374|    341|    grp_lock_item *lck;
  375|    341|    grp_destroy_callback *cb;
  376|       |
  377|    341|    if (!glock->pool) {
  ------------------
  |  Branch (377:9): [True: 0, False: 341]
  ------------------
  378|       |        /* already destroyed?! */
  379|      0|        return PJ_EINVAL;
  ------------------
  |  |  393|      0|#define PJ_EINVAL           (PJ_ERRNO_START_STATUS + 4) /* 70004 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  380|      0|    }
  381|       |
  382|       |    /* Release all chained locks */
  383|    341|    lck = glock->lock_list.next;
  384|    682|    while (lck != &glock->lock_list) {
  ------------------
  |  Branch (384:12): [True: 341, False: 341]
  ------------------
  385|    341|        if (lck->lock != glock->own_lock) {
  ------------------
  |  Branch (385:13): [True: 0, False: 341]
  ------------------
  386|      0|            int i;
  387|      0|            for (i=0; i<glock->owner_cnt; ++i)
  ------------------
  |  Branch (387:23): [True: 0, False: 0]
  ------------------
  388|      0|                pj_lock_release(lck->lock);
  389|      0|        }
  390|    341|        lck = lck->next;
  391|    341|    }
  392|       |
  393|       |    /* Call callbacks */
  394|    341|    cb = glock->destroy_list.next;
  395|  2.04k|    while (cb != &glock->destroy_list) {
  ------------------
  |  Branch (395:12): [True: 1.70k, False: 341]
  ------------------
  396|  1.70k|        grp_destroy_callback *next = cb->next;
  397|  1.70k|        cb->handler(cb->comp);
  398|  1.70k|        cb = next;
  399|  1.70k|    }
  400|       |
  401|    341|    pj_lock_destroy(glock->own_lock);
  402|    341|    pj_atomic_destroy(glock->ref_cnt);
  403|    341|    glock->pool = NULL;
  404|    341|    pj_pool_release(pool);
  405|       |
  406|    341|    return PJ_SUCCESS;
  407|    341|}
lock.c:grp_lock_add_handler:
  350|  3.49k|{
  351|  3.49k|    grp_destroy_callback *cb;
  352|       |
  353|  3.49k|    if (acquire_lock)
  ------------------
  |  Branch (353:9): [True: 3.49k, False: 0]
  ------------------
  354|  3.49k|        grp_lock_acquire(glock);
  355|       |
  356|  3.49k|    if (pool == NULL)
  ------------------
  |  Branch (356:9): [True: 0, False: 3.49k]
  ------------------
  357|      0|        pool = glock->pool;
  358|       |
  359|  3.49k|    cb = PJ_POOL_ZALLOC_T(pool, grp_destroy_callback);
  ------------------
  |  |  583|  3.49k|            ((type*)pj_pool_zalloc(pool, sizeof(type)))
  ------------------
  360|  3.49k|    cb->comp = comp;
  361|  3.49k|    cb->handler = destroy;
  362|  3.49k|    pj_list_push_back(&glock->destroy_list, cb);
  363|       |
  364|  3.49k|    if (acquire_lock)
  ------------------
  |  Branch (364:9): [True: 3.49k, False: 0]
  ------------------
  365|  3.49k|        grp_lock_release(glock);
  366|       |
  367|  3.49k|    return PJ_SUCCESS;
  368|  3.49k|}
lock.c:grp_lock_add_ref:
  554|  19.4k|{
  555|  19.4k|    pj_atomic_inc(glock->ref_cnt);
  556|  19.4k|    return PJ_SUCCESS;
  557|  19.4k|}
lock.c:grp_lock_dec_ref:
  560|  16.7k|{
  561|  16.7k|    int cnt; /* for debugging */
  562|  16.7k|    if ((cnt=pj_atomic_dec_and_get(glock->ref_cnt)) == 0) {
  ------------------
  |  Branch (562:9): [True: 341, False: 16.4k]
  ------------------
  563|    341|        grp_lock_destroy(glock);
  564|    341|        return PJ_EGONE;
  ------------------
  |  |  489|    341|#define PJ_EGONE            (PJ_ERRNO_START_STATUS + 23)/* 70023 */
  |  |  ------------------
  |  |  |  |  521|    341|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|    341|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|    341|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  565|    341|    }
  566|  16.4k|    pj_assert(cnt > 0);
  ------------------
  |  |   65|  16.4k|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (566:5): [True: 0, False: 16.4k]
  |  Branch (566:5): [True: 16.4k, False: 0]
  ------------------
  567|  16.4k|    return PJ_SUCCESS;
  568|  16.4k|}

pj_log_set_indent:
  104|  2.61k|{
  105|  2.61k|    if (indent < 0) indent = 0;
  ------------------
  |  Branch (105:9): [True: 0, False: 2.61k]
  ------------------
  106|  2.61k|    pj_thread_local_set(thread_indent_tls_id, (void*)(pj_ssize_t)indent);
  107|  2.61k|}
pj_log_get_indent:
  128|      1|{
  129|      1|    int indent = log_get_raw_indent();
  130|      1|    return indent > LOG_MAX_INDENT ? LOG_MAX_INDENT : indent;
  ------------------
  |  |   84|      1|#define LOG_MAX_INDENT          80
  ------------------
                  return indent > LOG_MAX_INDENT ? LOG_MAX_INDENT : indent;
  ------------------
  |  |   84|      0|#define LOG_MAX_INDENT          80
  ------------------
  |  Branch (130:12): [True: 0, False: 1]
  ------------------
  131|      1|}
pj_log_add_indent:
  134|  2.61k|{
  135|  2.61k|    pj_log_set_indent(log_get_raw_indent() + indent);
  136|  2.61k|}
pj_log_push_indent:
  139|  1.30k|{
  140|  1.30k|    pj_log_add_indent(PJ_LOG_INDENT_SIZE);
  ------------------
  |  |  460|  1.30k|#   define PJ_LOG_INDENT_SIZE        1
  ------------------
  141|  1.30k|}
pj_log_pop_indent:
  144|  1.30k|{
  145|  1.30k|    pj_log_add_indent(-PJ_LOG_INDENT_SIZE);
  ------------------
  |  |  460|  1.30k|#   define PJ_LOG_INDENT_SIZE        1
  ------------------
  146|  1.30k|}
pj_log_init:
  149|      1|{
  150|      1|#if PJ_HAS_THREADS
  151|      1|    if (thread_suspended_tls_id == -1) {
  ------------------
  |  Branch (151:9): [True: 1, False: 0]
  ------------------
  152|      1|        pj_status_t status;
  153|      1|        status = pj_thread_local_alloc(&thread_suspended_tls_id);
  154|      1|        if (status != PJ_SUCCESS) {
  ------------------
  |  Branch (154:13): [True: 0, False: 1]
  ------------------
  155|      0|            thread_suspended_tls_id = -1;
  156|      0|            return status;
  157|      0|        }
  158|       |
  159|      1|#  if PJ_LOG_ENABLE_INDENT
  160|      1|        status = pj_thread_local_alloc(&thread_indent_tls_id);
  161|      1|        if (status != PJ_SUCCESS) {
  ------------------
  |  Branch (161:13): [True: 0, False: 1]
  ------------------
  162|      0|            pj_thread_local_free(thread_suspended_tls_id);
  163|      0|            thread_suspended_tls_id = -1;
  164|      0|            thread_indent_tls_id = -1;
  165|      0|            return status;
  166|      0|        }
  167|      1|#  endif
  168|      1|        pj_atexit(&logging_shutdown);
  169|      1|    }
  170|      1|#endif
  171|      1|    g_last_thread = NULL;
  172|       |
  173|       |    /* Normalize log decor, e.g: unset thread flags when threading is
  174|       |     * disabled.
  175|       |     */
  176|      1|    pj_log_set_decor(pj_log_get_decor());
  177|       |
  178|      1|    return PJ_SUCCESS;
  179|      1|}
pj_log_set_decor:
  182|      1|{
  183|      1|    log_decor = decor;
  184|       |
  185|       |#if !PJ_HAS_THREADS
  186|       |    /* Unset thread related flags */
  187|       |    if (log_decor & PJ_LOG_HAS_THREAD_ID) {
  188|       |       log_decor &= ~(PJ_LOG_HAS_THREAD_ID);
  189|       |    }
  190|       |    if (log_decor & PJ_LOG_HAS_THREAD_SWC) {
  191|       |       log_decor &= ~(PJ_LOG_HAS_THREAD_SWC);
  192|       |    }
  193|       |#endif
  194|      1|}
pj_log_get_decor:
  197|      2|{
  198|      2|    return log_decor;
  199|      2|}
pj_log_set_level:
  252|  1.24k|{
  253|  1.24k|    pj_log_max_level = level;
  254|  1.24k|}
pj_log_get_level:
  258|  19.0k|{
  259|  19.0k|    return pj_log_max_level;
  260|  19.0k|}
pj_log:
  340|    528|{
  341|    528|    pj_time_val now;
  342|    528|    pj_parsed_time ptime;
  343|    528|    char *pre;
  344|    528|#if PJ_LOG_USE_STACK_BUFFER
  345|    528|    char log_buffer[PJ_LOG_MAX_SIZE];
  346|    528|#endif
  347|    528|    int saved_level, len, print_len;
  348|       |
  349|    528|    PJ_CHECK_STACK();
  350|       |
  351|    528|    if (level > pj_log_max_level)
  ------------------
  |  Branch (351:9): [True: 527, False: 1]
  ------------------
  352|    527|        return;
  353|       |
  354|      1|    if (is_logging_suspended())
  ------------------
  |  Branch (354:9): [True: 0, False: 1]
  ------------------
  355|      0|        return;
  356|       |
  357|       |    /* Temporarily disable logging for this thread. Some of PJLIB APIs that
  358|       |     * this function calls below will recursively call the logging function 
  359|       |     * back, hence it will cause infinite recursive calls if we allow that.
  360|       |     */
  361|      1|    suspend_logging(&saved_level);
  362|       |
  363|       |    /* Get current date/time. */
  364|      1|    pj_gettimeofday(&now);
  365|      1|    pj_time_decode(&now, &ptime);
  366|       |
  367|      1|    pre = log_buffer;
  368|      1|    if (log_decor & PJ_LOG_HAS_LEVEL_TEXT) {
  ------------------
  |  Branch (368:9): [True: 0, False: 1]
  ------------------
  369|      0|        static const char *ltexts[] = { "FATAL:", "ERROR:", " WARN:", 
  370|      0|                              " INFO:", "DEBUG:", "TRACE:", "DETRC:"};
  371|      0|        pj_ansi_strxcpy(pre, ltexts[level], PJ_LOG_MAX_SIZE);
  ------------------
  |  |  429|      0|#  define PJ_LOG_MAX_SIZE           4000
  ------------------
  372|      0|        pre += 6;
  373|      0|    }
  374|      1|    if (log_decor & PJ_LOG_HAS_DAY_NAME) {
  ------------------
  |  Branch (374:9): [True: 0, False: 1]
  ------------------
  375|      0|        static const char *wdays[] = { "Sun", "Mon", "Tue", "Wed",
  376|      0|                                       "Thu", "Fri", "Sat"};
  377|      0|        pj_ansi_strxcpy(pre, wdays[ptime.wday], PJ_LOG_MAX_SIZE-6);
  ------------------
  |  |  429|      0|#  define PJ_LOG_MAX_SIZE           4000
  ------------------
  378|      0|        pre += 3;
  379|      0|    }
  380|      1|    if (log_decor & PJ_LOG_HAS_YEAR) {
  ------------------
  |  Branch (380:9): [True: 0, False: 1]
  ------------------
  381|      0|        if (pre!=log_buffer) *pre++ = ' ';
  ------------------
  |  Branch (381:13): [True: 0, False: 0]
  ------------------
  382|      0|        pre += pj_utoa(ptime.year, pre);
  383|      0|    }
  384|      1|    if (log_decor & PJ_LOG_HAS_MONTH) {
  ------------------
  |  Branch (384:9): [True: 0, False: 1]
  ------------------
  385|      0|        *pre++ = '-';
  386|      0|        pre += pj_utoa_pad(ptime.mon+1, pre, 2, '0');
  387|      0|    }
  388|      1|    if (log_decor & PJ_LOG_HAS_DAY_OF_MON) {
  ------------------
  |  Branch (388:9): [True: 0, False: 1]
  ------------------
  389|      0|        *pre++ = '-';
  390|      0|        pre += pj_utoa_pad(ptime.day, pre, 2, '0');
  391|      0|    }
  392|      1|    if (log_decor & PJ_LOG_HAS_TIME) {
  ------------------
  |  Branch (392:9): [True: 1, False: 0]
  ------------------
  393|      1|        if (pre!=log_buffer) *pre++ = ' ';
  ------------------
  |  Branch (393:13): [True: 0, False: 1]
  ------------------
  394|      1|        pre += pj_utoa_pad(ptime.hour, pre, 2, '0');
  395|      1|        *pre++ = ':';
  396|      1|        pre += pj_utoa_pad(ptime.min, pre, 2, '0');
  397|      1|        *pre++ = ':';
  398|      1|        pre += pj_utoa_pad(ptime.sec, pre, 2, '0');
  399|      1|    }
  400|      1|    if (log_decor & PJ_LOG_HAS_MICRO_SEC) {
  ------------------
  |  Branch (400:9): [True: 1, False: 0]
  ------------------
  401|      1|        *pre++ = '.';
  402|      1|        pre += pj_utoa_pad(ptime.msec, pre, 3, '0');
  403|      1|    }
  404|      1|    if (log_decor & PJ_LOG_HAS_SENDER) {
  ------------------
  |  Branch (404:9): [True: 1, False: 0]
  ------------------
  405|      1|        enum { SENDER_WIDTH = PJ_LOG_SENDER_WIDTH };
  406|      1|        pj_size_t sender_len = strlen(sender);
  407|      1|        if (pre!=log_buffer) *pre++ = ' ';
  ------------------
  |  Branch (407:13): [True: 1, False: 0]
  ------------------
  408|      1|        if (sender_len <= SENDER_WIDTH) {
  ------------------
  |  Branch (408:13): [True: 1, False: 0]
  ------------------
  409|      9|            while (sender_len < SENDER_WIDTH)
  ------------------
  |  Branch (409:20): [True: 8, False: 1]
  ------------------
  410|      8|                *pre++ = ' ', ++sender_len;
  411|     15|            while (*sender)
  ------------------
  |  Branch (411:20): [True: 14, False: 1]
  ------------------
  412|     14|                *pre++ = *sender++;
  413|      1|        } else {
  414|      0|            int i;
  415|      0|            for (i=0; i<SENDER_WIDTH; ++i)
  ------------------
  |  Branch (415:23): [True: 0, False: 0]
  ------------------
  416|      0|                *pre++ = *sender++;
  417|      0|        }
  418|      1|    }
  419|      1|    if (log_decor & PJ_LOG_HAS_THREAD_ID) {
  ------------------
  |  Branch (419:9): [True: 0, False: 1]
  ------------------
  420|      0|        enum { THREAD_WIDTH = PJ_LOG_THREAD_WIDTH };
  421|      0|        const char *thread_name = pj_thread_get_name(pj_thread_this());
  422|      0|        pj_size_t thread_len = strlen(thread_name);
  423|      0|        *pre++ = ' ';
  424|      0|        if (thread_len <= THREAD_WIDTH) {
  ------------------
  |  Branch (424:13): [True: 0, False: 0]
  ------------------
  425|      0|            while (thread_len < THREAD_WIDTH)
  ------------------
  |  Branch (425:20): [True: 0, False: 0]
  ------------------
  426|      0|                *pre++ = ' ', ++thread_len;
  427|      0|            while (*thread_name)
  ------------------
  |  Branch (427:20): [True: 0, False: 0]
  ------------------
  428|      0|                *pre++ = *thread_name++;
  429|      0|        } else {
  430|      0|            int i;
  431|      0|            for (i=0; i<THREAD_WIDTH; ++i)
  ------------------
  |  Branch (431:23): [True: 0, False: 0]
  ------------------
  432|      0|                *pre++ = *thread_name++;
  433|      0|        }
  434|      0|    }
  435|       |
  436|      1|    if (log_decor != 0 && log_decor != PJ_LOG_HAS_NEWLINE)
  ------------------
  |  Branch (436:9): [True: 1, False: 0]
  |  Branch (436:27): [True: 1, False: 0]
  ------------------
  437|      1|        *pre++ = ' ';
  438|       |
  439|      1|    if (log_decor & PJ_LOG_HAS_THREAD_SWC) {
  ------------------
  |  Branch (439:9): [True: 1, False: 0]
  ------------------
  440|      1|        void *current_thread = (void*)pj_thread_this();
  441|      1|        if (current_thread != g_last_thread) {
  ------------------
  |  Branch (441:13): [True: 1, False: 0]
  ------------------
  442|      1|            *pre++ = '!';
  443|      1|            g_last_thread = current_thread;
  444|      1|        } else {
  445|      0|            *pre++ = ' ';
  446|      0|        }
  447|      1|    } else if (log_decor & PJ_LOG_HAS_SPACE) {
  ------------------
  |  Branch (447:16): [True: 0, False: 0]
  ------------------
  448|      0|        *pre++ = ' ';
  449|      0|    }
  450|       |
  451|      1|#if PJ_LOG_ENABLE_INDENT
  452|      1|    if (log_decor & PJ_LOG_HAS_INDENT) {
  ------------------
  |  Branch (452:9): [True: 1, False: 0]
  ------------------
  453|      1|        int indent = pj_log_get_indent();
  454|      1|        if (indent > 0) {
  ------------------
  |  Branch (454:13): [True: 0, False: 1]
  ------------------
  455|      0|            pj_memset(pre, PJ_LOG_INDENT_CHAR, indent);
  ------------------
  |  |  469|      0|#   define PJ_LOG_INDENT_CHAR       '.'
  ------------------
  456|      0|            pre += indent;
  457|      0|        }
  458|      1|    }
  459|      1|#endif
  460|       |
  461|      1|    len = (int)(pre - log_buffer);
  462|       |
  463|       |    /* Print the whole message to the string log_buffer. */
  464|      1|    print_len = pj_ansi_vsnprintf(pre, sizeof(log_buffer)-len, format, 
  ------------------
  |  |  122|      1|#define pj_ansi_vsnprintf       vsnprintf
  ------------------
  465|      1|                                  marker);
  466|      1|    if (print_len < 0) {
  ------------------
  |  Branch (466:9): [True: 0, False: 1]
  ------------------
  467|      0|        level = 1;
  468|      0|        print_len = pj_ansi_snprintf(pre, sizeof(log_buffer)-len, 
  ------------------
  |  |  114|      0|#define pj_ansi_snprintf        snprintf
  ------------------
  469|      0|                                     "<logging error: msg too long>");
  470|      0|    }
  471|      1|    if (print_len < 0 || print_len >= (int)(sizeof(log_buffer)-len)) {
  ------------------
  |  Branch (471:9): [True: 0, False: 1]
  |  Branch (471:26): [True: 0, False: 1]
  ------------------
  472|      0|        print_len = sizeof(log_buffer) - len - 1;
  473|      0|    }
  474|      1|    len = len + print_len;
  475|      1|    if (len >= 0 && len < (int)sizeof(log_buffer)-2) {
  ------------------
  |  Branch (475:9): [True: 1, False: 0]
  |  Branch (475:21): [True: 1, False: 0]
  ------------------
  476|      1|        if (log_decor & PJ_LOG_HAS_CR) {
  ------------------
  |  Branch (476:13): [True: 0, False: 1]
  ------------------
  477|      0|            log_buffer[len++] = '\r';
  478|      0|        }
  479|      1|        if (log_decor & PJ_LOG_HAS_NEWLINE) {
  ------------------
  |  Branch (479:13): [True: 1, False: 0]
  ------------------
  480|      1|            log_buffer[len++] = '\n';
  481|      1|        }
  482|      1|        log_buffer[len] = '\0';
  483|      1|    } else {
  484|      0|        len = sizeof(log_buffer)-1;
  485|      0|        if (log_decor & PJ_LOG_HAS_CR) {
  ------------------
  |  Branch (485:13): [True: 0, False: 0]
  ------------------
  486|      0|            log_buffer[sizeof(log_buffer)-3] = '\r';
  487|      0|        }
  488|      0|        if (log_decor & PJ_LOG_HAS_NEWLINE) {
  ------------------
  |  Branch (488:13): [True: 0, False: 0]
  ------------------
  489|      0|            log_buffer[sizeof(log_buffer)-2] = '\n';
  490|      0|        }
  491|      0|        log_buffer[sizeof(log_buffer)-1] = '\0';
  492|      0|    }
  493|       |
  494|       |    /* It should be safe to resume logging at this point. Application can
  495|       |     * recursively call the logging function inside the callback.
  496|       |     */
  497|      1|    resume_logging(&saved_level);
  498|       |
  499|      1|    if (log_writer)
  ------------------
  |  Branch (499:9): [True: 1, False: 0]
  ------------------
  500|      1|        (*log_writer)(level, log_buffer, len);
  501|      1|}
pj_log_4:
  548|      1|{
  549|      1|    va_list arg;
  550|      1|    va_start(arg, format);
  551|      1|    pj_log(obj, 4, format, arg);
  552|       |    va_end(arg);
  553|      1|}
log.c:log_get_raw_indent:
  110|  2.61k|{
  111|  2.61k|    return (long)(pj_ssize_t)pj_thread_local_get(thread_indent_tls_id);
  112|  2.61k|}
log.c:is_logging_suspended:
  323|      1|{
  324|      1|#if PJ_HAS_THREADS
  325|      1|    if (thread_suspended_tls_id != -1) 
  ------------------
  |  Branch (325:9): [True: 1, False: 0]
  ------------------
  326|      1|    {
  327|      1|        pj_ssize_t *ils;
  328|      1|        ils = (pj_ssize_t *)pj_thread_local_get(thread_suspended_tls_id);
  329|      1|        return (ils? (*ils == PJ_TRUE): PJ_FALSE);
  ------------------
  |  Branch (329:17): [True: 0, False: 1]
  ------------------
  330|      1|    }
  331|      0|    else
  332|      0|#endif
  333|      0|    {
  334|      0|        return pj_log_max_level == 0;
  335|      0|    }
  336|      1|}
log.c:suspend_logging:
  280|      1|{
  281|       |    /* Save the level regardless, just in case PJLIB is shutdown
  282|       |     * between suspend and resume.
  283|       |     */
  284|      1|    *saved_level = pj_log_max_level;
  285|       |
  286|      1|#if PJ_HAS_THREADS
  287|      1|    if (thread_suspended_tls_id != -1) 
  ------------------
  |  Branch (287:9): [True: 1, False: 0]
  ------------------
  288|      1|    {
  289|      1|        static pj_ssize_t suspend_log = PJ_TRUE;
  290|      1|        pj_thread_local_set(thread_suspended_tls_id, 
  291|      1|                            (void*)&suspend_log);
  292|      1|    } 
  293|      0|    else
  294|      0|#endif
  295|      0|    {
  296|      0|        pj_log_max_level = 0;
  297|      0|    }
  298|      1|}
log.c:resume_logging:
  302|      1|{
  303|      1|#if PJ_HAS_THREADS
  304|      1|    if (thread_suspended_tls_id != -1) 
  ------------------
  |  Branch (304:9): [True: 1, False: 0]
  ------------------
  305|      1|    {
  306|      1|        static pj_ssize_t suspend_log = PJ_FALSE;
  307|      1|        pj_thread_local_set(thread_suspended_tls_id, 
  308|      1|                            (void*)&suspend_log);
  309|      1|    }
  310|      0|    else
  311|      0|#endif
  312|      0|    {
  313|       |        /* Only revert the level if application doesn't change the
  314|       |         * logging level between suspend and resume.
  315|       |         */
  316|      0|        if (pj_log_max_level==0 && *saved_level)
  ------------------
  |  Branch (316:13): [True: 0, False: 0]
  |  Branch (316:36): [True: 0, False: 0]
  ------------------
  317|      0|            pj_log_max_level = *saved_level;
  318|      0|    }
  319|      1|}

pj_log_write:
   43|      1|{
   44|      1|    PJ_CHECK_STACK();
   45|      1|    PJ_UNUSED_ARG(len);
  ------------------
  |  | 1537|      1|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
   46|       |
   47|       |    /* Copy to terminal/file. */
   48|      1|    if (pj_log_get_decor() & PJ_LOG_HAS_COLOR) {
  ------------------
  |  Branch (48:9): [True: 0, False: 1]
  ------------------
   49|      0|        term_set_color(level);
   50|      0|        printf("%s", buffer);
   51|      0|        term_restore_color();
   52|      1|    } else {
   53|      1|        printf("%s", buffer);
   54|      1|    }
   55|      1|}

pj_init:
  202|  1.24k|{
  203|  1.24k|    char dummy_guid[PJ_GUID_MAX_LENGTH];
  204|  1.24k|    pj_str_t guid;
  205|  1.24k|    pj_status_t rc;
  206|       |
  207|       |    /* Check if PJLIB have been initialized */
  208|  1.24k|    if (initialized) {
  ------------------
  |  Branch (208:9): [True: 1.24k, False: 1]
  ------------------
  209|  1.24k|        ++initialized;
  210|  1.24k|        return PJ_SUCCESS;
  211|  1.24k|    }
  212|       |
  213|       |    /* Init logging */
  214|      1|    pj_log_init();
  215|       |
  216|      1|#if PJ_HAS_THREADS
  217|       |    /* Init this thread's TLS. */
  218|      1|    if ((rc=pj_thread_init()) != 0) {
  ------------------
  |  Branch (218:9): [True: 0, False: 1]
  ------------------
  219|      0|        return rc;
  220|      0|    }
  221|       |
  222|       |    /* Critical section. */
  223|      1|    if ((rc=init_mutex(&critical_section, "critsec", PJ_MUTEX_RECURSE)) != 0)
  ------------------
  |  Branch (223:9): [True: 0, False: 1]
  ------------------
  224|      0|        return rc;
  225|       |
  226|      1|#endif
  227|       |
  228|       |    /* Initialize exception ID for the pool.
  229|       |     * Must do so after critical section is configured.
  230|       |     */
  231|      1|    rc = pj_exception_id_alloc("PJLIB/No memory", &PJ_NO_MEMORY_EXCEPTION);
  232|      1|    if (rc != PJ_SUCCESS)
  ------------------
  |  Branch (232:9): [True: 0, False: 1]
  ------------------
  233|      0|        return rc;
  234|       |
  235|       |    /* Init random seed. */
  236|       |    /* Or probably not. Let application in charge of this */
  237|       |    /* pj_srand( clock() ); */
  238|       |
  239|       |    /* Startup GUID. */
  240|      1|    guid.ptr = dummy_guid;
  241|      1|    pj_generate_unique_string( &guid );
  242|       |
  243|       |    /* Startup timestamp */
  244|      1|#if defined(PJ_HAS_HIGH_RES_TIMER) && PJ_HAS_HIGH_RES_TIMER != 0
  245|      1|    {
  246|      1|        pj_timestamp dummy_ts;
  247|      1|        if ((rc=pj_get_timestamp(&dummy_ts)) != 0) {
  ------------------
  |  Branch (247:13): [True: 0, False: 1]
  ------------------
  248|      0|            return rc;
  249|      0|        }
  250|      1|    }
  251|      1|#endif
  252|       |
  253|       |    /* Flag PJLIB as initialized */
  254|      1|    ++initialized;
  255|      1|    pj_assert(initialized == 1);
  ------------------
  |  |   65|      1|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (255:5): [True: 0, False: 1]
  |  Branch (255:5): [True: 1, False: 0]
  ------------------
  256|       |
  257|      1|    PJ_LOG(4,(THIS_FILE, "pjlib %s for POSIX initialized",
  ------------------
  |  |  106|      1|#define PJ_LOG(level,arg)       do { \
  |  |  107|      1|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|      2|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 1, Folded]
  |  |  |  Branch (107:70): [True: 1, False: 0]
  |  |  ------------------
  |  |  108|      1|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  480|      1|    #define pj_log_wrapper_4(arg)       pj_log_4 arg
  |  |  ------------------
  |  |  109|      1|                                    } \
  |  |  110|      1|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 1]
  |  |  ------------------
  ------------------
  258|      1|              PJ_VERSION));
  259|       |
  260|      1|    return PJ_SUCCESS;
  261|      1|}
pj_atexit:
  267|      2|{
  268|      2|    if (atexit_count >= PJ_ARRAY_SIZE(atexit_func))
  ------------------
  |  |  315|      2|#define PJ_ARRAY_SIZE(a)    (sizeof(a)/sizeof(a[0]))
  ------------------
  |  Branch (268:9): [True: 0, False: 2]
  ------------------
  269|      0|        return PJ_ETOOMANY;
  ------------------
  |  |  423|      0|#define PJ_ETOOMANY         (PJ_ERRNO_START_STATUS + 10)/* 70010 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  270|       |
  271|      2|    atexit_func[atexit_count++] = func;
  272|      2|    return PJ_SUCCESS;
  273|      2|}
pj_getpid:
  322|  1.24k|{
  323|  1.24k|    PJ_CHECK_STACK();
  324|  1.24k|    return getpid();
  325|  1.24k|}
pj_thread_register:
  608|      1|{
  609|      1|#if PJ_HAS_THREADS
  610|      1|    char stack_ptr;
  611|      1|    pj_status_t rc;
  612|      1|    pj_thread_t *thread = (pj_thread_t *)desc;
  613|      1|    pj_str_t thread_name = pj_str((char*)cstr_thread_name);
  614|       |
  615|       |    /* Size sanity check. */
  616|      1|    if (sizeof(pj_thread_desc) < sizeof(pj_thread_t)) {
  ------------------
  |  Branch (616:9): [Folded, False: 1]
  ------------------
  617|      0|        pj_assert(!"Not enough pj_thread_desc size!");
  ------------------
  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (617:9): [Folded, False: 0]
  |  Branch (617:9): [Folded, False: 0]
  ------------------
  618|      0|        return PJ_EBUG;
  ------------------
  |  |  413|      0|#define PJ_EBUG             (PJ_ERRNO_START_STATUS + 8) /* 70008 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  619|      0|    }
  620|       |
  621|       |    /* Warn if this thread has been registered before */
  622|      1|    if (pj_thread_local_get (thread_tls_id) != 0) {
  ------------------
  |  Branch (622:9): [True: 0, False: 1]
  ------------------
  623|       |        // 2006-02-26 bennylp:
  624|       |        //  This wouldn't work in all cases!.
  625|       |        //  If thread is created by external module (e.g. sound thread),
  626|       |        //  thread may be reused while the pool used for the thread descriptor
  627|       |        //  has been deleted by application.
  628|       |        //*thread_ptr = (pj_thread_t*)pj_thread_local_get (thread_tls_id);
  629|       |        //return PJ_SUCCESS;
  630|      0|        PJ_LOG(4,(THIS_FILE, "Info: possibly re-registering existing "
  ------------------
  |  |  106|      0|#define PJ_LOG(level,arg)       do { \
  |  |  107|      0|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|      0|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 0, Folded]
  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  480|      0|    #define pj_log_wrapper_4(arg)       pj_log_4 arg
  |  |  ------------------
  |  |  109|      0|                                    } \
  |  |  110|      0|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 0]
  |  |  ------------------
  ------------------
  631|      0|                             "thread"));
  632|      0|    }
  633|       |
  634|       |    /* On the other hand, also warn if the thread descriptor buffer seem to
  635|       |     * have been used to register other threads.
  636|       |     */
  637|      1|    pj_assert(thread->signature1 != SIGNATURE1 ||
  ------------------
  |  |   65|      1|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (637:5): [True: 1, False: 0]
  |  Branch (637:5): [True: 0, False: 0]
  |  Branch (637:5): [True: 0, False: 0]
  |  Branch (637:5): [True: 1, False: 0]
  |  Branch (637:5): [True: 0, False: 0]
  |  Branch (637:5): [True: 0, False: 0]
  ------------------
  638|      1|              thread->signature2 != SIGNATURE2 ||
  639|      1|              (thread->thread == pthread_self()));
  640|       |
  641|       |    /* Initialize and set the thread entry. */
  642|      1|    pj_bzero(desc, sizeof(struct pj_thread_t));
  643|      1|    thread->thread = pthread_self();
  644|      1|    thread->signature1 = SIGNATURE1;
  ------------------
  |  |   70|      1|#define SIGNATURE1  0xDEAFBEEF
  ------------------
  645|      1|    thread->signature2 = SIGNATURE2;
  ------------------
  |  |   71|      1|#define SIGNATURE2  0xDEADC0DE
  ------------------
  646|       |
  647|      1|    if(cstr_thread_name && pj_strlen(&thread_name) < sizeof(thread->obj_name)-1)
  ------------------
  |  Branch (647:8): [True: 1, False: 0]
  |  Branch (647:28): [True: 1, False: 0]
  ------------------
  648|      1|        pj_ansi_snprintf(thread->obj_name, sizeof(thread->obj_name),
  ------------------
  |  |  114|      1|#define pj_ansi_snprintf        snprintf
  ------------------
  649|      1|                         cstr_thread_name, thread->thread);
  650|      0|    else
  651|      0|        pj_ansi_snprintf(thread->obj_name, sizeof(thread->obj_name),
  ------------------
  |  |  114|      0|#define pj_ansi_snprintf        snprintf
  ------------------
  652|      0|                         "thr%p", (void*)thread->thread);
  653|       |
  654|      1|    rc = pj_thread_local_set(thread_tls_id, thread);
  655|      1|    if (rc != PJ_SUCCESS) {
  ------------------
  |  Branch (655:9): [True: 0, False: 1]
  ------------------
  656|      0|        pj_bzero(desc, sizeof(struct pj_thread_t));
  657|      0|        return rc;
  658|      0|    }
  659|       |
  660|       |#if defined(PJ_OS_HAS_CHECK_STACK) && PJ_OS_HAS_CHECK_STACK!=0
  661|       |    thread->stk_start = &stack_ptr;
  662|       |    thread->stk_size = 0xFFFFFFFFUL;
  663|       |    thread->stk_max_usage = 0;
  664|       |#else
  665|      1|    PJ_UNUSED_ARG(stack_ptr);
  ------------------
  |  | 1537|      1|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
  666|      1|#endif
  667|       |
  668|      1|    *ptr_thread = thread;
  669|      1|    return PJ_SUCCESS;
  670|       |#else
  671|       |    pj_thread_t *thread = (pj_thread_t*)desc;
  672|       |    *ptr_thread = thread;
  673|       |    return PJ_SUCCESS;
  674|       |#endif
  675|      1|}
pj_thread_init:
  681|      1|{
  682|      1|#if PJ_HAS_THREADS
  683|      1|    pj_status_t rc;
  684|      1|    pj_thread_t *dummy;
  685|       |
  686|      1|    rc = pj_thread_local_alloc(&thread_tls_id );
  687|      1|    if (rc != PJ_SUCCESS) {
  ------------------
  |  Branch (687:9): [True: 0, False: 1]
  ------------------
  688|      0|        return rc;
  689|      0|    }
  690|      1|    return pj_thread_register("thr%p", main_thread_desc, &dummy);
  691|       |#else
  692|       |    PJ_LOG(2,(THIS_FILE, "Thread init error. Threading is not enabled!"));
  693|       |    return PJ_EINVALIDOP;
  694|       |#endif
  695|      1|}
pj_thread_this:
  967|  87.8k|{
  968|  87.8k|#if PJ_HAS_THREADS
  969|  87.8k|    pj_thread_t *rec = (pj_thread_t*)pj_thread_local_get(thread_tls_id);
  970|       |
  971|  87.8k|    if (rec == NULL) {
  ------------------
  |  Branch (971:9): [True: 0, False: 87.8k]
  ------------------
  972|      0|        pj_assert(!"Calling pjlib from unknown/external thread. You must "
  ------------------
  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (972:9): [Folded, False: 0]
  |  Branch (972:9): [Folded, False: 0]
  ------------------
  973|      0|                   "register external threads with pj_thread_register() "
  974|      0|                   "before calling any pjlib functions.");
  975|      0|    }
  976|       |
  977|       |    /*
  978|       |     * MUST NOT check stack because this function is called
  979|       |     * by PJ_CHECK_STACK() itself!!!
  980|       |     *
  981|       |     */
  982|       |
  983|  87.8k|    return rec;
  984|       |#else
  985|       |    pj_assert(!"Threading is not enabled!");
  986|       |    return NULL;
  987|       |#endif
  988|  87.8k|}
pj_atomic_create:
 1183|  1.23k|{
 1184|       |#if EMULATE_ATOMICS
 1185|       |    pj_status_t rc;
 1186|       |#endif
 1187|  1.23k|    pj_atomic_t *atomic_var;
 1188|       |
 1189|  1.23k|    atomic_var = PJ_POOL_ZALLOC_T(pool, pj_atomic_t);
  ------------------
  |  |  583|  1.23k|            ((type*)pj_pool_zalloc(pool, sizeof(type)))
  ------------------
 1190|       |
 1191|  1.23k|    PJ_ASSERT_RETURN(atomic_var, PJ_ENOMEM);
  ------------------
  |  |   97|  1.23k|            do { \
  |  |   98|  1.23k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 1.23k]
  |  |  ------------------
  |  |   99|  1.23k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1.23k]
  |  |  ------------------
  ------------------
  |  Branch (1191:5): [True: 0, False: 0]
  |  Branch (1191:5): [True: 0, False: 0]
  ------------------
 1192|       |
 1193|  1.23k|#if HAS_STD_ATOMICS
 1194|  1.23k|    atomic_init(&atomic_var->value, initial);
 1195|       |#elif EMULATE_ATOMICS
 1196|       |    rc = pj_mutex_create(pool, "atm%p", PJ_MUTEX_SIMPLE, &atomic_var->mutex);
 1197|       |    if (rc != PJ_SUCCESS)
 1198|       |        return rc;
 1199|       |    atomic_var->value = initial;
 1200|       |#else
 1201|       |    atomic_var->value = initial;
 1202|       |#endif
 1203|       |
 1204|  1.23k|    *ptr_atomic = atomic_var;
 1205|  1.23k|    return PJ_SUCCESS;
 1206|  1.23k|}
pj_atomic_destroy:
 1212|    341|{
 1213|       |#if EMULATE_ATOMICS
 1214|       |    pj_status_t status;
 1215|       |#endif
 1216|       |
 1217|    341|    PJ_ASSERT_RETURN(atomic_var, PJ_EINVAL);
  ------------------
  |  |   97|    341|            do { \
  |  |   98|    341|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 341]
  |  |  ------------------
  |  |   99|    341|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 341]
  |  |  ------------------
  ------------------
  |  Branch (1217:5): [True: 0, False: 0]
  |  Branch (1217:5): [True: 0, False: 0]
  ------------------
 1218|       |
 1219|       |#if EMULATE_ATOMICS
 1220|       |    status = pj_mutex_destroy( atomic_var->mutex );
 1221|       |    if (status == PJ_SUCCESS) {
 1222|       |        atomic_var->mutex = NULL;
 1223|       |    }
 1224|       |    return status;
 1225|       |#else
 1226|    341|    return 0;
 1227|    341|#endif
 1228|    341|}
pj_atomic_get:
 1260|  14.7k|{
 1261|  14.7k|    pj_atomic_value_t oldval;
 1262|       |
 1263|  14.7k|    PJ_CHECK_STACK();
 1264|       |
 1265|  14.7k|#if HAS_STD_ATOMICS
 1266|  14.7k|    oldval = atomic_load(&atomic_var->value);
 1267|       |#elif EMULATE_ATOMICS
 1268|       |    pj_mutex_lock( atomic_var->mutex );
 1269|       |    oldval = atomic_var->value;
 1270|       |    pj_mutex_unlock( atomic_var->mutex);
 1271|       |#else
 1272|       |    oldval = atomic_var->value;
 1273|       |#endif
 1274|       |
 1275|  14.7k|    return oldval;
 1276|  14.7k|}
pj_atomic_inc_and_get:
 1282|  19.4k|{
 1283|  19.4k|    pj_atomic_value_t new_value;
 1284|       |
 1285|  19.4k|    PJ_CHECK_STACK();
 1286|       |
 1287|  19.4k|#if HAS_STD_ATOMICS
 1288|  19.4k|    new_value = atomic_fetch_add(&atomic_var->value, 1) + 1;
 1289|       |#elif EMULATE_ATOMICS
 1290|       |    pj_mutex_lock( atomic_var->mutex );
 1291|       |    new_value = ++atomic_var->value;
 1292|       |    pj_mutex_unlock( atomic_var->mutex);
 1293|       |#else
 1294|       |    new_value = ++atomic_var->value;
 1295|       |#endif
 1296|       |
 1297|  19.4k|    return new_value;
 1298|  19.4k|}
pj_atomic_inc:
 1303|  19.4k|{
 1304|  19.4k|    PJ_ASSERT_ON_FAIL(atomic_var, return);
  ------------------
  |  |  111|  19.4k|            { \
  |  |  112|  19.4k|                pj_assert(expr); \
  |  |  ------------------
  |  |  |  |   65|  19.4k|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  113|  19.4k|                if (!(expr)) exec_on_fail; \
  |  |  ------------------
  |  |  |  Branch (113:21): [True: 0, False: 19.4k]
  |  |  ------------------
  |  |  114|  19.4k|            }
  ------------------
  |  Branch (1304:5): [True: 0, False: 19.4k]
  |  Branch (1304:5): [True: 19.4k, False: 0]
  ------------------
 1305|  19.4k|    pj_atomic_inc_and_get(atomic_var);
 1306|  19.4k|}
pj_atomic_dec_and_get:
 1312|  16.7k|{
 1313|  16.7k|    pj_atomic_value_t new_value;
 1314|       |
 1315|  16.7k|    PJ_CHECK_STACK();
 1316|       |
 1317|  16.7k|#if HAS_STD_ATOMICS
 1318|  16.7k|    new_value = atomic_fetch_sub(&atomic_var->value, 1) - 1;
 1319|       |#elif EMULATE_ATOMICS
 1320|       |    pj_mutex_lock( atomic_var->mutex );
 1321|       |    new_value = --atomic_var->value;
 1322|       |    pj_mutex_unlock( atomic_var->mutex);
 1323|       |#else
 1324|       |    new_value = --atomic_var->value;
 1325|       |#endif
 1326|       |
 1327|  16.7k|    return new_value;
 1328|  16.7k|}
pj_thread_local_alloc:
 1375|      4|{
 1376|      4|#if PJ_HAS_THREADS
 1377|      4|    pthread_key_t key;
 1378|      4|    int rc;
 1379|       |
 1380|      4|    PJ_ASSERT_RETURN(p_index != NULL, PJ_EINVAL);
  ------------------
  |  |   97|      4|            do { \
  |  |   98|      4|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 4]
  |  |  ------------------
  |  |   99|      4|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 4]
  |  |  ------------------
  ------------------
  |  Branch (1380:5): [True: 0, False: 0]
  |  Branch (1380:5): [True: 0, False: 0]
  ------------------
 1381|       |
 1382|      4|    pj_assert( sizeof(pthread_key_t) <= sizeof(long));
  ------------------
  |  |   65|      4|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (1382:5): [True: 0, Folded]
  |  Branch (1382:5): [True: 4, Folded]
  ------------------
 1383|      4|    if ((rc=pthread_key_create(&key, NULL)) != 0)
  ------------------
  |  Branch (1383:9): [True: 0, False: 4]
  ------------------
 1384|      0|        return PJ_RETURN_OS_ERROR(rc);
  ------------------
  |  |  319|      0|#   define PJ_RETURN_OS_ERROR(os_code)   (os_code ? \
  |  |  ------------------
  |  |  |  Branch (319:43): [True: 0, False: 0]
  |  |  ------------------
  |  |  320|      0|                                            PJ_STATUS_FROM_OS(os_code) : -1)
  |  |  ------------------
  |  |  |  |  334|      0|#   define PJ_STATUS_FROM_OS(e) (e == 0 ? PJ_SUCCESS : e + PJ_ERRNO_START_SYS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  528|      0|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (334:34): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1385|       |
 1386|      4|    *p_index = key;
 1387|      4|    return PJ_SUCCESS;
 1388|       |#else
 1389|       |    int i;
 1390|       |    for (i=0; i<MAX_THREADS; ++i) {
 1391|       |        if (tls_flag[i] == 0)
 1392|       |            break;
 1393|       |    }
 1394|       |    if (i == MAX_THREADS)
 1395|       |        return PJ_ETOOMANY;
 1396|       |
 1397|       |    tls_flag[i] = 1;
 1398|       |    tls[i] = NULL;
 1399|       |
 1400|       |    *p_index = i;
 1401|       |    return PJ_SUCCESS;
 1402|       |#endif
 1403|      4|}
pj_thread_local_set:
 1422|  5.10k|{
 1423|       |    //Can't check stack because this function is called in the
 1424|       |    //beginning before main thread is initialized.
 1425|       |    //PJ_CHECK_STACK();
 1426|  5.10k|#if PJ_HAS_THREADS
 1427|  5.10k|    int rc=pthread_setspecific(index, value);
 1428|  5.10k|    return rc==0 ? PJ_SUCCESS : PJ_RETURN_OS_ERROR(rc);
  ------------------
  |  |  319|      0|#   define PJ_RETURN_OS_ERROR(os_code)   (os_code ? \
  |  |  ------------------
  |  |  |  Branch (319:43): [True: 0, False: 0]
  |  |  ------------------
  |  |  320|      0|                                            PJ_STATUS_FROM_OS(os_code) : -1)
  |  |  ------------------
  |  |  |  |  334|      0|#   define PJ_STATUS_FROM_OS(e) (e == 0 ? PJ_SUCCESS : e + PJ_ERRNO_START_SYS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  528|      0|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (334:34): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (1428:12): [True: 5.10k, False: 0]
  ------------------
 1429|       |#else
 1430|       |    pj_assert(index >= 0 && index < MAX_THREADS);
 1431|       |    tls[index] = value;
 1432|       |    return PJ_SUCCESS;
 1433|       |#endif
 1434|  5.10k|}
pj_thread_local_get:
 1437|  91.6k|{
 1438|       |    //Can't check stack because this function is called
 1439|       |    //by PJ_CHECK_STACK() itself!!!
 1440|       |    //PJ_CHECK_STACK();
 1441|  91.6k|#if PJ_HAS_THREADS
 1442|  91.6k|    return pthread_getspecific(index);
 1443|       |#else
 1444|       |    pj_assert(index >= 0 && index < MAX_THREADS);
 1445|       |    return tls[index];
 1446|       |#endif
 1447|  91.6k|}
pj_enter_critical_section:
 1451|      2|{
 1452|      2|#if PJ_HAS_THREADS
 1453|      2|    pj_mutex_lock(&critical_section);
 1454|      2|#endif
 1455|      2|}
pj_leave_critical_section:
 1458|      2|{
 1459|      2|#if PJ_HAS_THREADS
 1460|      2|    pj_mutex_unlock(&critical_section);
 1461|      2|#endif
 1462|      2|}
pj_mutex_create:
 1562|  11.2k|{
 1563|  11.2k|#if PJ_HAS_THREADS
 1564|  11.2k|    pj_status_t rc;
 1565|  11.2k|    pj_mutex_t *mutex;
 1566|       |
 1567|  11.2k|    PJ_ASSERT_RETURN(pool && ptr_mutex, PJ_EINVAL);
  ------------------
  |  |   97|  11.2k|            do { \
  |  |   98|  22.5k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 11.2k, False: 0]
  |  |  |  Branch (98:23): [True: 11.2k, False: 0]
  |  |  ------------------
  |  |   99|  11.2k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 11.2k]
  |  |  ------------------
  ------------------
  |  Branch (1567:5): [True: 0, False: 0]
  |  Branch (1567:5): [True: 0, False: 0]
  |  Branch (1567:5): [True: 0, False: 0]
  |  Branch (1567:5): [True: 0, False: 0]
  ------------------
 1568|       |
 1569|  11.2k|    mutex = PJ_POOL_ALLOC_T(pool, pj_mutex_t);
  ------------------
  |  |  569|  11.2k|            ((type*)pj_pool_alloc(pool, sizeof(type)))
  ------------------
 1570|  11.2k|    PJ_ASSERT_RETURN(mutex, PJ_ENOMEM);
  ------------------
  |  |   97|  11.2k|            do { \
  |  |   98|  11.2k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 11.2k]
  |  |  ------------------
  |  |   99|  11.2k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 11.2k]
  |  |  ------------------
  ------------------
  |  Branch (1570:5): [True: 0, False: 0]
  |  Branch (1570:5): [True: 0, False: 0]
  ------------------
 1571|       |
 1572|  11.2k|    if ((rc=init_mutex(mutex, name, type)) != PJ_SUCCESS)
  ------------------
  |  Branch (1572:9): [True: 0, False: 11.2k]
  ------------------
 1573|      0|        return rc;
 1574|       |
 1575|  11.2k|    *ptr_mutex = mutex;
 1576|  11.2k|    return PJ_SUCCESS;
 1577|       |#else /* PJ_HAS_THREADS */
 1578|       |    *ptr_mutex = (pj_mutex_t*)1;
 1579|       |    return PJ_SUCCESS;
 1580|       |#endif
 1581|  11.2k|}
pj_mutex_create_simple:
 1589|  1.23k|{
 1590|  1.23k|    return pj_mutex_create(pool, name, PJ_MUTEX_SIMPLE, mutex);
 1591|  1.23k|}
pj_mutex_lock:
 1607|  29.1k|{
 1608|  29.1k|#if PJ_HAS_THREADS
 1609|  29.1k|    pj_status_t status;
 1610|       |
 1611|  29.1k|    PJ_CHECK_STACK();
 1612|  29.1k|    PJ_ASSERT_RETURN(mutex, PJ_EINVAL);
  ------------------
  |  |   97|  29.1k|            do { \
  |  |   98|  29.1k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 29.1k]
  |  |  ------------------
  |  |   99|  29.1k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 29.1k]
  |  |  ------------------
  ------------------
  |  Branch (1612:5): [True: 0, False: 0]
  |  Branch (1612:5): [True: 0, False: 0]
  ------------------
 1613|       |
 1614|  29.1k|#if PJ_DEBUG
 1615|  29.1k|    PJ_LOG(6,(mutex->obj_name, "Mutex: thread %s is waiting (mutex owner=%s)",
  ------------------
  |  |  106|  29.1k|#define PJ_LOG(level,arg)       do { \
  |  |  107|  29.1k|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|  58.3k|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [Folded, False: 29.1k]
  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  109|      0|                                    } \
  |  |  110|  29.1k|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 29.1k]
  |  |  ------------------
  ------------------
 1616|  29.1k|                                pj_thread_this()->obj_name,
 1617|  29.1k|                                mutex->owner_name));
 1618|       |#else
 1619|       |    PJ_LOG(6,(mutex->obj_name, "Mutex: thread %s is waiting",
 1620|       |                                pj_thread_this()->obj_name));
 1621|       |#endif
 1622|       |
 1623|  29.1k|    status = pthread_mutex_lock( &mutex->mutex );
 1624|       |
 1625|       |
 1626|  29.1k|#if PJ_DEBUG
 1627|  29.1k|    if (status == PJ_SUCCESS) {
  ------------------
  |  Branch (1627:9): [True: 29.1k, False: 0]
  ------------------
 1628|  29.1k|        mutex->owner = pj_thread_this();
 1629|  29.1k|        pj_ansi_strxcpy(mutex->owner_name, mutex->owner->obj_name,
 1630|  29.1k|                        sizeof(mutex->owner_name));
 1631|  29.1k|        ++mutex->nesting_level;
 1632|  29.1k|    }
 1633|       |
 1634|  29.1k|    PJ_LOG(6,(mutex->obj_name,
  ------------------
  |  |  106|  29.1k|#define PJ_LOG(level,arg)       do { \
  |  |  107|  29.1k|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|  58.3k|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [Folded, False: 29.1k]
  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  109|      0|                                    } \
  |  |  110|  29.1k|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 29.1k]
  |  |  ------------------
  ------------------
 1635|  29.1k|              (status==0 ?
 1636|  29.1k|                "Mutex acquired by thread %s (level=%d)" :
 1637|  29.1k|                "Mutex acquisition FAILED by %s (level=%d)"),
 1638|  29.1k|              pj_thread_this()->obj_name,
 1639|  29.1k|              mutex->nesting_level));
 1640|       |#else
 1641|       |    PJ_LOG(6,(mutex->obj_name,
 1642|       |              (status==0 ? "Mutex acquired by thread %s" : "FAILED by %s"),
 1643|       |              pj_thread_this()->obj_name));
 1644|       |#endif
 1645|       |
 1646|  29.1k|    if (status == 0)
  ------------------
  |  Branch (1646:9): [True: 29.1k, False: 0]
  ------------------
 1647|  29.1k|        return PJ_SUCCESS;
 1648|      0|    else
 1649|      0|        return PJ_RETURN_OS_ERROR(status);
  ------------------
  |  |  319|      0|#   define PJ_RETURN_OS_ERROR(os_code)   (os_code ? \
  |  |  ------------------
  |  |  |  Branch (319:43): [True: 0, False: 0]
  |  |  ------------------
  |  |  320|      0|                                            PJ_STATUS_FROM_OS(os_code) : -1)
  |  |  ------------------
  |  |  |  |  334|      0|#   define PJ_STATUS_FROM_OS(e) (e == 0 ? PJ_SUCCESS : e + PJ_ERRNO_START_SYS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  528|      0|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (334:34): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1650|       |#else   /* PJ_HAS_THREADS */
 1651|       |    pj_assert( mutex == (pj_mutex_t*)1 );
 1652|       |    return PJ_SUCCESS;
 1653|       |#endif
 1654|  29.1k|}
pj_mutex_unlock:
 1660|  29.1k|{
 1661|  29.1k|#if PJ_HAS_THREADS
 1662|  29.1k|    pj_status_t status;
 1663|       |
 1664|  29.1k|    PJ_CHECK_STACK();
 1665|  29.1k|    PJ_ASSERT_RETURN(mutex, PJ_EINVAL);
  ------------------
  |  |   97|  29.1k|            do { \
  |  |   98|  29.1k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 29.1k]
  |  |  ------------------
  |  |   99|  29.1k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 29.1k]
  |  |  ------------------
  ------------------
  |  Branch (1665:5): [True: 0, False: 0]
  |  Branch (1665:5): [True: 0, False: 0]
  ------------------
 1666|       |
 1667|  29.1k|#if PJ_DEBUG
 1668|  29.1k|    pj_assert(mutex->owner == pj_thread_this());
  ------------------
  |  |   65|  29.1k|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (1668:5): [True: 0, False: 29.1k]
  |  Branch (1668:5): [True: 29.1k, False: 0]
  ------------------
 1669|  29.1k|    if (--mutex->nesting_level == 0) {
  ------------------
  |  Branch (1669:9): [True: 23.5k, False: 5.61k]
  ------------------
 1670|  23.5k|        mutex->owner = NULL;
 1671|  23.5k|        mutex->owner_name[0] = '\0';
 1672|  23.5k|    }
 1673|       |
 1674|  29.1k|    PJ_LOG(6,(mutex->obj_name, "Mutex released by thread %s (level=%d)",
  ------------------
  |  |  106|  29.1k|#define PJ_LOG(level,arg)       do { \
  |  |  107|  29.1k|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|  58.3k|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [Folded, False: 29.1k]
  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  109|      0|                                    } \
  |  |  110|  29.1k|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 29.1k]
  |  |  ------------------
  ------------------
 1675|  29.1k|                                pj_thread_this()->obj_name,
 1676|  29.1k|                                mutex->nesting_level));
 1677|       |#else
 1678|       |    PJ_LOG(6,(mutex->obj_name, "Mutex released by thread %s",
 1679|       |                                pj_thread_this()->obj_name));
 1680|       |#endif
 1681|       |
 1682|  29.1k|    status = pthread_mutex_unlock( &mutex->mutex );
 1683|  29.1k|    if (status == 0)
  ------------------
  |  Branch (1683:9): [True: 29.1k, False: 0]
  ------------------
 1684|  29.1k|        return PJ_SUCCESS;
 1685|      0|    else
 1686|      0|        return PJ_RETURN_OS_ERROR(status);
  ------------------
  |  |  319|      0|#   define PJ_RETURN_OS_ERROR(os_code)   (os_code ? \
  |  |  ------------------
  |  |  |  Branch (319:43): [True: 0, False: 0]
  |  |  ------------------
  |  |  320|      0|                                            PJ_STATUS_FROM_OS(os_code) : -1)
  |  |  ------------------
  |  |  |  |  334|      0|#   define PJ_STATUS_FROM_OS(e) (e == 0 ? PJ_SUCCESS : e + PJ_ERRNO_START_SYS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  528|      0|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (334:34): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1687|       |
 1688|       |#else /* PJ_HAS_THREADS */
 1689|       |    pj_assert( mutex == (pj_mutex_t*)1 );
 1690|       |    return PJ_SUCCESS;
 1691|       |#endif
 1692|  29.1k|}
pj_mutex_destroy:
 1743|  10.3k|{
 1744|  10.3k|    enum { RETRY = 4 };
 1745|  10.3k|    int status = 0;
 1746|  10.3k|    unsigned retry;
 1747|       |
 1748|  10.3k|    PJ_CHECK_STACK();
 1749|  10.3k|    PJ_ASSERT_RETURN(mutex, PJ_EINVAL);
  ------------------
  |  |   97|  10.3k|            do { \
  |  |   98|  10.3k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 10.3k]
  |  |  ------------------
  |  |   99|  10.3k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 10.3k]
  |  |  ------------------
  ------------------
  |  Branch (1749:5): [True: 0, False: 0]
  |  Branch (1749:5): [True: 0, False: 0]
  ------------------
 1750|       |
 1751|  10.3k|#if PJ_HAS_THREADS
 1752|  10.3k|    PJ_LOG(6,(mutex->obj_name, "Mutex destroyed by thread %s",
  ------------------
  |  |  106|  10.3k|#define PJ_LOG(level,arg)       do { \
  |  |  107|  10.3k|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|  20.7k|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [Folded, False: 10.3k]
  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  109|      0|                                    } \
  |  |  110|  10.3k|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 10.3k]
  |  |  ------------------
  ------------------
 1753|  10.3k|                               pj_thread_this()->obj_name));
 1754|       |
 1755|  10.3k|    for (retry=0; retry<RETRY; ++retry) {
  ------------------
  |  Branch (1755:19): [True: 10.3k, False: 0]
  ------------------
 1756|  10.3k|        status = pthread_mutex_destroy( &mutex->mutex );
 1757|  10.3k|        if (status == PJ_SUCCESS)
  ------------------
  |  Branch (1757:13): [True: 10.3k, False: 0]
  ------------------
 1758|  10.3k|            break;
 1759|      0|        else if (retry<RETRY-1 && status == EBUSY)
  ------------------
  |  Branch (1759:18): [True: 0, False: 0]
  |  Branch (1759:35): [True: 0, False: 0]
  ------------------
 1760|      0|            pthread_mutex_unlock(&mutex->mutex);
 1761|  10.3k|    }
 1762|       |
 1763|  10.3k|    if (status == 0)
  ------------------
  |  Branch (1763:9): [True: 10.3k, False: 0]
  ------------------
 1764|  10.3k|        return PJ_SUCCESS;
 1765|      0|    else {
 1766|      0|        return PJ_RETURN_OS_ERROR(status);
  ------------------
  |  |  319|      0|#   define PJ_RETURN_OS_ERROR(os_code)   (os_code ? \
  |  |  ------------------
  |  |  |  Branch (319:43): [True: 0, False: 0]
  |  |  ------------------
  |  |  320|      0|                                            PJ_STATUS_FROM_OS(os_code) : -1)
  |  |  ------------------
  |  |  |  |  334|      0|#   define PJ_STATUS_FROM_OS(e) (e == 0 ? PJ_SUCCESS : e + PJ_ERRNO_START_SYS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  528|      0|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (334:34): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1767|      0|    }
 1768|       |#else
 1769|       |    pj_assert( mutex == (pj_mutex_t*)1 );
 1770|       |    status = PJ_SUCCESS;
 1771|       |    return status;
 1772|       |#endif
 1773|  10.3k|}
os_core_unix.c:init_mutex:
 1473|  11.2k|{
 1474|  11.2k|#if PJ_HAS_THREADS
 1475|  11.2k|    pthread_mutexattr_t attr;
 1476|  11.2k|    int rc;
 1477|       |
 1478|  11.2k|    PJ_CHECK_STACK();
 1479|       |
 1480|  11.2k|    rc = pthread_mutexattr_init(&attr);
 1481|  11.2k|    if (rc != 0)
  ------------------
  |  Branch (1481:9): [True: 0, False: 11.2k]
  ------------------
 1482|      0|        return PJ_RETURN_OS_ERROR(rc);
  ------------------
  |  |  319|      0|#   define PJ_RETURN_OS_ERROR(os_code)   (os_code ? \
  |  |  ------------------
  |  |  |  Branch (319:43): [True: 0, False: 0]
  |  |  ------------------
  |  |  320|      0|                                            PJ_STATUS_FROM_OS(os_code) : -1)
  |  |  ------------------
  |  |  |  |  334|      0|#   define PJ_STATUS_FROM_OS(e) (e == 0 ? PJ_SUCCESS : e + PJ_ERRNO_START_SYS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  528|      0|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (334:34): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1483|       |
 1484|  11.2k|    if (type == PJ_MUTEX_SIMPLE) {
  ------------------
  |  Branch (1484:9): [True: 3.71k, False: 7.55k]
  ------------------
 1485|  3.71k|#if (defined(PJ_LINUX) && PJ_LINUX!=0) || \
 1486|  3.71k|    defined(PJ_HAS_PTHREAD_MUTEXATTR_SETTYPE)
 1487|  3.71k|        rc = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_NORMAL);
 1488|       |#elif (defined(PJ_RTEMS) && PJ_RTEMS!=0) || \
 1489|       |       defined(PJ_PTHREAD_MUTEXATTR_T_HAS_RECURSIVE)
 1490|       |        /* Nothing to do, default is simple */
 1491|       |#else
 1492|       |        rc = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_NORMAL);
 1493|       |#endif
 1494|  7.55k|    } else {
 1495|  7.55k|#if (defined(PJ_LINUX) && PJ_LINUX!=0) || \
 1496|  7.55k|     defined(PJ_HAS_PTHREAD_MUTEXATTR_SETTYPE)
 1497|  7.55k|        rc = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
 1498|       |#elif (defined(PJ_RTEMS) && PJ_RTEMS!=0) || \
 1499|       |       defined(PJ_PTHREAD_MUTEXATTR_T_HAS_RECURSIVE)
 1500|       |        // Phil Torre <ptorre@zetron.com>:
 1501|       |        // The RTEMS implementation of POSIX mutexes doesn't include
 1502|       |        // pthread_mutexattr_settype(), so what follows is a hack
 1503|       |        // until I get RTEMS patched to support the set/get functions.
 1504|       |        //
 1505|       |        // More info:
 1506|       |        //   newlib's pthread also lacks pthread_mutexattr_settype(),
 1507|       |        //   but it seems to have mutexattr.recursive.
 1508|       |        PJ_TODO(FIX_RTEMS_RECURSIVE_MUTEX_TYPE)
 1509|       |        attr.recursive = 1;
 1510|       |#else
 1511|       |        rc = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
 1512|       |#endif
 1513|  7.55k|    }
 1514|       |
 1515|  11.2k|    if (rc != 0) {
  ------------------
  |  Branch (1515:9): [True: 0, False: 11.2k]
  ------------------
 1516|      0|        return PJ_RETURN_OS_ERROR(rc);
  ------------------
  |  |  319|      0|#   define PJ_RETURN_OS_ERROR(os_code)   (os_code ? \
  |  |  ------------------
  |  |  |  Branch (319:43): [True: 0, False: 0]
  |  |  ------------------
  |  |  320|      0|                                            PJ_STATUS_FROM_OS(os_code) : -1)
  |  |  ------------------
  |  |  |  |  334|      0|#   define PJ_STATUS_FROM_OS(e) (e == 0 ? PJ_SUCCESS : e + PJ_ERRNO_START_SYS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  528|      0|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (334:34): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1517|      0|    }
 1518|       |
 1519|  11.2k|    rc = pthread_mutex_init(&mutex->mutex, &attr);
 1520|  11.2k|    if (rc != 0) {
  ------------------
  |  Branch (1520:9): [True: 0, False: 11.2k]
  ------------------
 1521|      0|        return PJ_RETURN_OS_ERROR(rc);
  ------------------
  |  |  319|      0|#   define PJ_RETURN_OS_ERROR(os_code)   (os_code ? \
  |  |  ------------------
  |  |  |  Branch (319:43): [True: 0, False: 0]
  |  |  ------------------
  |  |  320|      0|                                            PJ_STATUS_FROM_OS(os_code) : -1)
  |  |  ------------------
  |  |  |  |  334|      0|#   define PJ_STATUS_FROM_OS(e) (e == 0 ? PJ_SUCCESS : e + PJ_ERRNO_START_SYS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  528|      0|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (334:34): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1522|      0|    }
 1523|       |
 1524|  11.2k|    rc = pthread_mutexattr_destroy(&attr);
 1525|  11.2k|    if (rc != 0) {
  ------------------
  |  Branch (1525:9): [True: 0, False: 11.2k]
  ------------------
 1526|      0|        pj_status_t status = PJ_RETURN_OS_ERROR(rc);
  ------------------
  |  |  319|      0|#   define PJ_RETURN_OS_ERROR(os_code)   (os_code ? \
  |  |  ------------------
  |  |  |  Branch (319:43): [True: 0, False: 0]
  |  |  ------------------
  |  |  320|      0|                                            PJ_STATUS_FROM_OS(os_code) : -1)
  |  |  ------------------
  |  |  |  |  334|      0|#   define PJ_STATUS_FROM_OS(e) (e == 0 ? PJ_SUCCESS : e + PJ_ERRNO_START_SYS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  528|      0|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (334:34): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1527|      0|        pthread_mutex_destroy(&mutex->mutex);
 1528|      0|        return status;
 1529|      0|    }
 1530|       |
 1531|  11.2k|#if PJ_DEBUG
 1532|       |    /* Set owner. */
 1533|  11.2k|    mutex->nesting_level = 0;
 1534|  11.2k|    mutex->owner = NULL;
 1535|  11.2k|    mutex->owner_name[0] = '\0';
 1536|  11.2k|#endif
 1537|       |
 1538|       |    /* Set name. */
 1539|  11.2k|    if (!name) {
  ------------------
  |  Branch (1539:9): [True: 7.54k, False: 3.71k]
  ------------------
 1540|  7.54k|        name = "mtx%p";
 1541|  7.54k|    }
 1542|  11.2k|    if (strchr(name, '%')) {
  ------------------
  |  Branch (1542:9): [True: 8.78k, False: 2.48k]
  ------------------
 1543|  8.78k|        pj_ansi_snprintf(mutex->obj_name, PJ_MAX_OBJ_NAME, name, mutex);
  ------------------
  |  |  114|  8.78k|#define pj_ansi_snprintf        snprintf
  ------------------
                      pj_ansi_snprintf(mutex->obj_name, PJ_MAX_OBJ_NAME, name, mutex);
  ------------------
  |  |  320|  8.78k|#define PJ_MAX_OBJ_NAME 32
  ------------------
 1544|  8.78k|    } else {
 1545|  2.48k|        pj_ansi_strxcpy(mutex->obj_name, name, PJ_MAX_OBJ_NAME);
  ------------------
  |  |  320|  2.48k|#define PJ_MAX_OBJ_NAME 32
  ------------------
 1546|  2.48k|    }
 1547|       |
 1548|  11.2k|    PJ_LOG(6, (mutex->obj_name, "Mutex created"));
  ------------------
  |  |  106|  11.2k|#define PJ_LOG(level,arg)       do { \
  |  |  107|  11.2k|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|  22.5k|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [Folded, False: 11.2k]
  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  109|      0|                                    } \
  |  |  110|  11.2k|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 11.2k]
  |  |  ------------------
  ------------------
 1549|  11.2k|    return PJ_SUCCESS;
 1550|       |#else /* PJ_HAS_THREADS */
 1551|       |    return PJ_SUCCESS;
 1552|       |#endif
 1553|  11.2k|}

pj_time_decode:
   29|      1|{
   30|      1|    struct tm local_time;
   31|      1|    time_t sec = tv->sec; // time_t might be 64 bit even when long int is 32 bit, (time_t*) dangerous
   32|       |
   33|      1|    PJ_CHECK_STACK();
   34|       |
   35|      1|#if defined(PJ_HAS_LOCALTIME_R) && PJ_HAS_LOCALTIME_R != 0
   36|      1|    localtime_r(&sec, &local_time);
   37|       |#else
   38|       |    /* localtime() is NOT thread-safe. */
   39|       |    local_time = *localtime(&sec);
   40|       |#endif
   41|       |
   42|      1|    pt->year = local_time.tm_year+1900;
   43|      1|    pt->mon = local_time.tm_mon;
   44|      1|    pt->day = local_time.tm_mday;
   45|      1|    pt->hour = local_time.tm_hour;
   46|      1|    pt->min = local_time.tm_min;
   47|      1|    pt->sec = local_time.tm_sec;
   48|      1|    pt->wday = local_time.tm_wday;
   49|      1|    pt->msec = tv->msec;
   50|       |
   51|      1|    return PJ_SUCCESS;
   52|      1|}

pj_gettimeofday:
   32|      1|{
   33|      1|    struct timeval the_time;
   34|      1|    int rc;
   35|       |
   36|      1|    PJ_CHECK_STACK();
   37|       |
   38|      1|    rc = gettimeofday(&the_time, NULL);
   39|      1|    if (rc != 0)
  ------------------
  |  Branch (39:9): [True: 0, False: 1]
  ------------------
   40|      0|        return PJ_RETURN_OS_ERROR(pj_get_native_os_error());
  ------------------
  |  |  319|      0|#   define PJ_RETURN_OS_ERROR(os_code)   (os_code ? \
  |  |  ------------------
  |  |  |  Branch (319:43): [True: 0, False: 0]
  |  |  ------------------
  |  |  320|      0|                                            PJ_STATUS_FROM_OS(os_code) : -1)
  |  |  ------------------
  |  |  |  |  334|      0|#   define PJ_STATUS_FROM_OS(e) (e == 0 ? PJ_SUCCESS : e + PJ_ERRNO_START_SYS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  528|      0|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (334:34): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   41|       |
   42|      1|    p_tv->sec = the_time.tv_sec;
   43|      1|    p_tv->msec = the_time.tv_usec / 1000;
   44|      1|    return PJ_SUCCESS;
   45|      1|}

pj_elapsed_time:
  165|  1.57k|{
  166|  1.57k|    pj_highprec_t elapsed = elapsed_msec(start, stop);
  167|  1.57k|    pj_time_val tv_elapsed;
  168|       |
  169|  1.57k|    if (PJ_HIGHPREC_VALUE_IS_ZERO(elapsed)) {
  ------------------
  |  |   30|  1.57k|#   define PJ_HIGHPREC_VALUE_IS_ZERO(a)     (a==0)
  |  |  ------------------
  |  |  |  Branch (30:45): [True: 0, False: 1.57k]
  |  |  ------------------
  ------------------
  170|      0|        tv_elapsed.sec = tv_elapsed.msec = 0;
  171|      0|        return tv_elapsed;
  172|  1.57k|    } else {
  173|  1.57k|        pj_highprec_t sec, msec;
  174|       |
  175|  1.57k|        sec = elapsed;
  176|  1.57k|        pj_highprec_div(sec, MSEC);
  ------------------
  |  |   64|  1.57k|#   define pj_highprec_div(a1,a2)   (a1 = a1 / a2)
  ------------------
  177|  1.57k|        tv_elapsed.sec = (long)sec;
  178|       |
  179|  1.57k|        msec = elapsed;
  180|  1.57k|        pj_highprec_mod(msec, MSEC);
  ------------------
  |  |   31|  1.57k|#   define pj_highprec_mod(a,b)             (a=fmod(a,b))
  ------------------
  181|  1.57k|        tv_elapsed.msec = (long)msec;
  182|       |
  183|  1.57k|        return tv_elapsed;
  184|  1.57k|    }
  185|  1.57k|}
pj_gettickcount:
  194|  1.57k|{
  195|  1.57k|    pj_timestamp ts, start;
  196|  1.57k|    pj_status_t status;
  197|       |
  198|  1.57k|    if ((status = pj_get_timestamp(&ts)) != PJ_SUCCESS)
  ------------------
  |  Branch (198:9): [True: 0, False: 1.57k]
  ------------------
  199|      0|        return status;
  200|       |
  201|  1.57k|    pj_set_timestamp32(&start, 0, 0);
  202|  1.57k|    *tv = pj_elapsed_time(&start, &ts);
  203|       |
  204|  1.57k|    return PJ_SUCCESS;
  205|  1.57k|}
os_timestamp_common.c:get_elapsed:
   33|  1.57k|{
   34|  1.57k|#if defined(PJ_HAS_INT64) && PJ_HAS_INT64!=0
   35|  1.57k|    return u64tohighprec(stop->u64 - start->u64);
  ------------------
  |  |   29|  1.57k|#define u64tohighprec(u64)      ((pj_highprec_t)((pj_int64_t)(u64)))
  ------------------
   36|       |#else
   37|       |    pj_highprec_t elapsed_hi, elapsed_lo;
   38|       |
   39|       |    elapsed_hi = stop->u32.hi - start->u32.hi;
   40|       |    elapsed_lo = stop->u32.lo - start->u32.lo;
   41|       |
   42|       |    /* elapsed_hi = elapsed_hi * U32MAX */
   43|       |    pj_highprec_mul(elapsed_hi, U32MAX);
   44|       |
   45|       |    return elapsed_hi + elapsed_lo;
   46|       |#endif
   47|  1.57k|}
os_timestamp_common.c:elapsed_msec:
   51|  1.57k|{
   52|  1.57k|    pj_timestamp ts_freq;
   53|  1.57k|    pj_highprec_t freq, elapsed;
   54|       |
   55|  1.57k|    if (pj_get_timestamp_freq(&ts_freq) != PJ_SUCCESS)
  ------------------
  |  Branch (55:9): [True: 0, False: 1.57k]
  ------------------
   56|      0|        return 0;
   57|       |
   58|       |    /* Convert frequency timestamp */
   59|  1.57k|#if defined(PJ_HAS_INT64) && PJ_HAS_INT64!=0
   60|  1.57k|    freq = u64tohighprec(ts_freq.u64);
  ------------------
  |  |   29|  1.57k|#define u64tohighprec(u64)      ((pj_highprec_t)((pj_int64_t)(u64)))
  ------------------
   61|       |#else
   62|       |    freq = ts_freq.u32.hi;
   63|       |    pj_highprec_mul(freq, U32MAX);
   64|       |    freq += ts_freq.u32.lo;
   65|       |#endif
   66|       |
   67|       |    /* Get elapsed time in cycles. */
   68|  1.57k|    elapsed = get_elapsed(start, stop);
   69|       |
   70|       |    /* usec = elapsed * MSEC / freq */
   71|  1.57k|    pj_highprec_div(freq, MSEC);
  ------------------
  |  |   64|  1.57k|#   define pj_highprec_div(a1,a2)   (a1 = a1 / a2)
  ------------------
   72|       |     
   73|       |    /* Avoid division by zero. */
   74|  1.57k|    if (freq == 0) {
  ------------------
  |  Branch (74:9): [True: 0, False: 1.57k]
  ------------------
   75|       |      /* Regard freq = 1 */
   76|      0|      pj_highprec_mul(elapsed, MSEC);
  ------------------
  |  |   55|      0|#   define pj_highprec_mul(a1,a2)   (a1 = a1 * a2)
  ------------------
   77|  1.57k|    } else {
   78|  1.57k|      pj_highprec_div(elapsed, freq);
  ------------------
  |  |   64|  1.57k|#   define pj_highprec_div(a1,a2)   (a1 = a1 / a2)
  ------------------
   79|  1.57k|    }
   80|  1.57k|    return elapsed;
   81|  1.57k|}

pj_get_timestamp:
  228|  1.57k|{
  229|  1.57k|    struct timespec tp;
  230|       |
  231|  1.57k|    if (clock_gettime(CLOCK_MONOTONIC, &tp) != 0) {
  ------------------
  |  Branch (231:9): [True: 0, False: 1.57k]
  ------------------
  232|      0|        return PJ_RETURN_OS_ERROR(pj_get_native_os_error());
  ------------------
  |  |  319|      0|#   define PJ_RETURN_OS_ERROR(os_code)   (os_code ? \
  |  |  ------------------
  |  |  |  Branch (319:43): [True: 0, False: 0]
  |  |  ------------------
  |  |  320|      0|                                            PJ_STATUS_FROM_OS(os_code) : -1)
  |  |  ------------------
  |  |  |  |  334|      0|#   define PJ_STATUS_FROM_OS(e) (e == 0 ? PJ_SUCCESS : e + PJ_ERRNO_START_SYS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  528|      0|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (334:34): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  233|      0|    }
  234|       |
  235|  1.57k|    ts->u64 = tp.tv_sec;
  236|  1.57k|    ts->u64 *= NSEC_PER_SEC;
  ------------------
  |  |  225|  1.57k|#define NSEC_PER_SEC    1000000000
  ------------------
  237|  1.57k|    ts->u64 += tp.tv_nsec;
  238|       |
  239|  1.57k|    return PJ_SUCCESS;
  240|  1.57k|}
pj_get_timestamp_freq:
  243|  1.57k|{
  244|  1.57k|    freq->u32.hi = 0;
  245|  1.57k|    freq->u32.lo = NSEC_PER_SEC;
  ------------------
  |  |  225|  1.57k|#define NSEC_PER_SEC    1000000000
  ------------------
  246|       |
  247|  1.57k|    return PJ_SUCCESS;
  248|  1.57k|}

pj_pool_allocate_find:
   94|  15.3k|{
   95|  15.3k|    pj_pool_block *block = pool->block_list.next;
   96|  15.3k|    void *p;
   97|  15.3k|    pj_size_t block_size;
   98|  15.3k|    unsigned i = 0;
   99|       |
  100|  15.3k|    PJ_CHECK_STACK();
  101|  15.3k|    pj_assert(PJ_IS_POWER_OF_TWO(alignment));
  ------------------
  |  |   65|  15.3k|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (101:5): [True: 0, False: 15.3k]
  |  Branch (101:5): [True: 0, False: 0]
  |  Branch (101:5): [True: 15.3k, False: 0]
  |  Branch (101:5): [True: 15.3k, False: 0]
  ------------------
  102|       |
  103|  38.1k|    while (block != &pool->block_list) {
  ------------------
  |  Branch (103:12): [True: 27.5k, False: 10.5k]
  ------------------
  104|  27.5k|        p = pj_pool_alloc_from_block(block, alignment, size);
  105|  27.5k|        if (p != NULL)
  ------------------
  |  Branch (105:13): [True: 4.78k, False: 22.7k]
  ------------------
  106|  4.78k|            return p;
  107|       |
  108|  22.7k|#if PJ_POOL_MAX_SEARCH_BLOCK_COUNT > 0
  109|  22.7k|        if (i >= PJ_POOL_MAX_SEARCH_BLOCK_COUNT) {
  ------------------
  |  |  559|  22.7k|#   define PJ_POOL_MAX_SEARCH_BLOCK_COUNT 5
  ------------------
  |  Branch (109:13): [True: 9, False: 22.7k]
  ------------------
  110|      9|            break;
  111|      9|        }
  112|  22.7k|#endif
  113|       |
  114|  22.7k|        i++;
  115|  22.7k|        block = block->next;
  116|  22.7k|    }
  117|       |    /* No available space in all blocks. */
  118|       |
  119|       |    /* If pool is configured NOT to expand, return error. */
  120|  10.5k|    if (pool->increment_size == 0) {
  ------------------
  |  Branch (120:9): [True: 0, False: 10.5k]
  ------------------
  121|      0|        LOG((pool->obj_name, "Can't expand pool to allocate %lu bytes "
  ------------------
  |  |   33|      0|#define LOG(expr)                   PJ_LOG(6,expr)
  |  |  ------------------
  |  |  |  |  106|      0|#define PJ_LOG(level,arg)       do { \
  |  |  |  |  107|      0|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |  417|      0|#  define PJ_LOG_MAX_LEVEL   5
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (107:41): [Folded, False: 0]
  |  |  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  |  |  109|      0|                                    } \
  |  |  |  |  110|      0|                                } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (110:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  122|      0|             "(used=%lu, cap=%lu)",
  123|      0|             (unsigned long)size, (unsigned long)pj_pool_get_used_size(pool),
  124|      0|             (unsigned long)pool->capacity));
  125|      0|        (*pool->callback)(pool, size);
  126|      0|        return NULL;
  127|      0|    }
  128|       |
  129|       |    /* If pool is configured to expand, but the increment size
  130|       |     * is less than the required size, expand the pool by multiple
  131|       |     * increment size. Also count the size wasted due to aligning
  132|       |     * the block.
  133|       |     */
  134|  10.5k|    if (pool->increment_size < 
  ------------------
  |  Branch (134:9): [True: 6.32k, False: 4.25k]
  ------------------
  135|  10.5k|            sizeof(pj_pool_block)+ /*block header, itself may be unaligned*/
  136|  10.5k|            alignment-1 + /* gap [0:alignment-1] to align first allocation*/
  137|  10.5k|            size)                  /* allocation size (NOT aligned!)      */
  138|  6.32k|    {
  139|  6.32k|        pj_size_t count;
  140|  6.32k|        count = (pool->increment_size + 
  141|  6.32k|                 sizeof(pj_pool_block) + alignment-1 + size) /
  142|  6.32k|                pool->increment_size;
  143|  6.32k|        block_size = count * pool->increment_size;
  144|  6.32k|    } else {
  145|  4.25k|        block_size = pool->increment_size;
  146|  4.25k|    }
  147|       |
  148|  10.5k|    LOG((pool->obj_name, 
  ------------------
  |  |   33|  10.5k|#define LOG(expr)                   PJ_LOG(6,expr)
  |  |  ------------------
  |  |  |  |  106|  10.5k|#define PJ_LOG(level,arg)       do { \
  |  |  |  |  107|  10.5k|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |  417|  21.1k|#  define PJ_LOG_MAX_LEVEL   5
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (107:41): [Folded, False: 10.5k]
  |  |  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  |  |  109|      0|                                    } \
  |  |  |  |  110|  10.5k|                                } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (110:42): [Folded, False: 10.5k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  149|  10.5k|         "%lu bytes requested, resizing pool by %lu bytes (used=%lu, cap=%lu)",
  150|  10.5k|         (unsigned long)size, (unsigned long)block_size,
  151|  10.5k|         (unsigned long)pj_pool_get_used_size(pool),
  152|  10.5k|         (unsigned long)pool->capacity));
  153|       |
  154|  10.5k|    block = pj_pool_create_block(pool, block_size);
  155|  10.5k|    if (!block)
  ------------------
  |  Branch (155:9): [True: 0, False: 10.5k]
  ------------------
  156|      0|        return NULL;
  157|       |
  158|  10.5k|    p = pj_pool_alloc_from_block(block, alignment, size);
  159|  10.5k|    pj_assert(p != NULL);
  ------------------
  |  |   65|  10.5k|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (159:5): [True: 0, False: 10.5k]
  |  Branch (159:5): [True: 10.5k, False: 0]
  ------------------
  160|  10.5k|#if PJ_DEBUG
  161|  10.5k|    if (p == NULL) {
  ------------------
  |  Branch (161:9): [True: 0, False: 10.5k]
  ------------------
  162|      0|        PJ_UNUSED_ARG(p);
  ------------------
  |  | 1537|      0|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
  163|      0|    }
  164|  10.5k|#endif
  165|  10.5k|    return p;
  166|  10.5k|}
pj_pool_init_int:
  176|  8.79k|{
  177|       |
  178|  8.79k|    PJ_CHECK_STACK();
  179|  8.79k|    pj_assert(!alignment || PJ_IS_POWER_OF_TWO(alignment));
  ------------------
  |  |   65|  8.79k|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (179:5): [True: 0, False: 0]
  |  Branch (179:5): [True: 0, False: 0]
  |  Branch (179:5): [True: 8.79k, False: 0]
  |  Branch (179:5): [True: 1.24k, False: 0]
  |  Branch (179:5): [True: 1.24k, False: 0]
  |  Branch (179:5): [True: 7.55k, False: 1.24k]
  ------------------
  180|       |
  181|  8.79k|    pool->increment_size = increment_size;
  182|  8.79k|    pool->callback = callback;
  183|  8.79k|    pool->alignment = !alignment ? PJ_POOL_ALIGNMENT : alignment;
  ------------------
  |  |  182|  7.55k|#define PJ_POOL_ALIGNMENT 8
  ------------------
  |  Branch (183:23): [True: 7.55k, False: 1.24k]
  ------------------
  184|       |
  185|  8.79k|    if (name) {
  ------------------
  |  Branch (185:9): [True: 8.79k, False: 0]
  ------------------
  186|  8.79k|        char *p = pj_ansi_strchr(name, '%');
  ------------------
  |  |   92|  8.79k|#define pj_ansi_strchr          strchr
  ------------------
  187|  8.79k|        if (p && *(p+1)=='p' && *(p+2)=='\0') {
  ------------------
  |  Branch (187:13): [True: 2.26k, False: 6.53k]
  |  Branch (187:18): [True: 2.26k, False: 0]
  |  Branch (187:33): [True: 2.26k, False: 0]
  ------------------
  188|       |            /* Special name with "%p" suffix */
  189|  2.26k|            pj_ansi_snprintf(pool->obj_name, sizeof(pool->obj_name), 
  ------------------
  |  |  114|  2.26k|#define pj_ansi_snprintf        snprintf
  ------------------
  190|  2.26k|                             name, pool);
  191|  6.53k|        } else {
  192|  6.53k|            pj_ansi_strxcpy(pool->obj_name, name, PJ_MAX_OBJ_NAME);
  ------------------
  |  |  320|  6.53k|#define PJ_MAX_OBJ_NAME 32
  ------------------
  193|  6.53k|        }
  194|  8.79k|    } else {
  195|      0|        pool->obj_name[0] = '\0';
  196|      0|    }
  197|  8.79k|}
pj_pool_create_int:
  207|  8.79k|{
  208|  8.79k|    pj_pool_t *pool;
  209|  8.79k|    pj_pool_block *block;
  210|  8.79k|    pj_uint8_t *buffer;
  211|       |
  212|  8.79k|    PJ_CHECK_STACK();
  213|       |
  214|       |    /* Size must be at least sizeof(pj_pool)+sizeof(pj_pool_block) */
  215|  8.79k|    PJ_ASSERT_RETURN(initial_size >= sizeof(pj_pool_t)+sizeof(pj_pool_block),
  ------------------
  |  |   97|  8.79k|            do { \
  |  |   98|  8.79k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 8.79k]
  |  |  ------------------
  |  |   99|  8.79k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 8.79k]
  |  |  ------------------
  ------------------
  |  Branch (215:5): [True: 0, False: 0]
  |  Branch (215:5): [True: 0, False: 0]
  ------------------
  216|  8.79k|                     NULL);
  217|  8.79k|    PJ_ASSERT_RETURN(!alignment || PJ_IS_POWER_OF_TWO(alignment), NULL);
  ------------------
  |  |   97|  8.79k|            do { \
  |  |   98|  12.5k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 1.24k, False: 0]
  |  |  |  Branch (98:23): [True: 1.24k, False: 0]
  |  |  |  Branch (98:23): [True: 7.55k, False: 1.24k]
  |  |  ------------------
  |  |   99|  8.79k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 8.79k]
  |  |  ------------------
  ------------------
  |  Branch (217:5): [True: 0, False: 0]
  |  Branch (217:5): [True: 0, False: 0]
  |  Branch (217:5): [True: 0, False: 0]
  |  Branch (217:5): [True: 0, False: 0]
  |  Branch (217:5): [True: 0, False: 0]
  |  Branch (217:5): [True: 0, False: 0]
  ------------------
  218|       |
  219|       |    /* If callback is NULL, set calback from the policy */
  220|  8.79k|    if (callback == NULL)
  ------------------
  |  Branch (220:9): [True: 0, False: 8.79k]
  ------------------
  221|      0|        callback = f->policy.callback;
  222|       |
  223|       |    /* Allocate initial block */
  224|  8.79k|    buffer = (pj_uint8_t*) (*f->policy.block_alloc)(f, initial_size);
  225|  8.79k|    if (!buffer)
  ------------------
  |  Branch (225:9): [True: 0, False: 8.79k]
  ------------------
  226|      0|        return NULL;
  227|       |
  228|       |    /* Set pool administrative data. */
  229|  8.79k|    pool = (pj_pool_t*)buffer;
  230|  8.79k|    pj_bzero(pool, sizeof(*pool));
  231|       |
  232|  8.79k|    pj_list_init(&pool->block_list);
  233|  8.79k|    pool->factory = f;
  234|       |
  235|       |    /* Create the first block from the memory. */
  236|  8.79k|    block = (pj_pool_block*) (buffer + sizeof(*pool));
  237|  8.79k|    block->buf = ((unsigned char*)block) + sizeof(pj_pool_block);
  238|  8.79k|    block->end = buffer + initial_size;
  239|       |
  240|       |    /* Set the start pointer, unaligned! */
  241|  8.79k|    block->cur = block->buf;
  242|       |
  243|  8.79k|    pj_list_insert_after(&pool->block_list, block);
  244|       |
  245|  8.79k|    pj_pool_init_int(pool, name, increment_size, alignment, callback);
  246|       |
  247|       |    /* Pool initial capacity and used size */
  248|  8.79k|    pool->capacity = initial_size;
  249|       |
  250|  8.79k|    LOG((pool->obj_name, "pool created, size=%lu",
  ------------------
  |  |   33|  8.79k|#define LOG(expr)                   PJ_LOG(6,expr)
  |  |  ------------------
  |  |  |  |  106|  8.79k|#define PJ_LOG(level,arg)       do { \
  |  |  |  |  107|  8.79k|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |  417|  17.5k|#  define PJ_LOG_MAX_LEVEL   5
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (107:41): [Folded, False: 8.79k]
  |  |  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  |  |  109|      0|                                    } \
  |  |  |  |  110|  8.79k|                                } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (110:42): [Folded, False: 8.79k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  251|  8.79k|                         (unsigned long)pool->capacity));
  252|  8.79k|    return pool;
  253|  8.79k|}
pj_pool_reset:
  295|    624|{
  296|    624|    LOG((pool->obj_name, "reset(): cap=%lu, used=%lu(%lu%%)", 
  ------------------
  |  |   33|    624|#define LOG(expr)                   PJ_LOG(6,expr)
  |  |  ------------------
  |  |  |  |  106|    624|#define PJ_LOG(level,arg)       do { \
  |  |  |  |  107|    624|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |  417|  1.24k|#  define PJ_LOG_MAX_LEVEL   5
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (107:41): [Folded, False: 624]
  |  |  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  |  |  109|      0|                                    } \
  |  |  |  |  110|    624|                                } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (110:42): [Folded, False: 624]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  297|    624|        (unsigned long)pool->capacity,
  298|    624|        (unsigned long)pj_pool_get_used_size(pool), 
  299|    624|        (unsigned long)(pj_pool_get_used_size(pool)*100/pool->capacity)));
  300|       |
  301|    624|    reset_pool(pool);
  302|    624|}
pj_pool_destroy_int:
  308|  7.55k|{
  309|  7.55k|    pj_size_t initial_size;
  310|       |
  311|  7.55k|    LOG((pool->obj_name, "destroy(): cap=%lu, used=%lu(%lu%%), block0=%p-%p", 
  ------------------
  |  |   33|  7.55k|#define LOG(expr)                   PJ_LOG(6,expr)
  |  |  ------------------
  |  |  |  |  106|  7.55k|#define PJ_LOG(level,arg)       do { \
  |  |  |  |  107|  7.55k|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |  417|  15.1k|#  define PJ_LOG_MAX_LEVEL   5
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (107:41): [Folded, False: 7.55k]
  |  |  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  |  |  109|      0|                                    } \
  |  |  |  |  110|  7.55k|                                } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (110:42): [Folded, False: 7.55k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  312|  7.55k|        (unsigned long)pool->capacity,
  313|  7.55k|        (unsigned long)pj_pool_get_used_size(pool),
  314|  7.55k|        (unsigned long)(pj_pool_get_used_size(pool)*100/pool->capacity),
  315|  7.55k|        ((pj_pool_block*)pool->block_list.next)->buf, 
  316|  7.55k|        ((pj_pool_block*)pool->block_list.next)->end));
  317|       |
  318|  7.55k|    reset_pool(pool);
  319|  7.55k|    initial_size = ((pj_pool_block*)pool->block_list.next)->end - 
  320|  7.55k|                   (unsigned char*)pool;
  321|  7.55k|    if (pool->factory->policy.block_free)
  ------------------
  |  Branch (321:9): [True: 7.55k, False: 0]
  ------------------
  322|  7.55k|        (*pool->factory->policy.block_free)(pool->factory, pool, initial_size);
  323|  7.55k|}
pool.c:pj_pool_create_block:
   48|  10.5k|{
   49|  10.5k|    pj_pool_block *block;
   50|       |
   51|  10.5k|    PJ_CHECK_STACK();
   52|  10.5k|    pj_assert(size >= sizeof(pj_pool_block));
  ------------------
  |  |   65|  10.5k|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (52:5): [True: 0, False: 10.5k]
  |  Branch (52:5): [True: 10.5k, False: 0]
  ------------------
   53|       |
   54|  10.5k|    LOG((pool->obj_name, "create_block(sz=%lu), cur.cap=%lu, cur.used=%lu", 
  ------------------
  |  |   33|  10.5k|#define LOG(expr)                   PJ_LOG(6,expr)
  |  |  ------------------
  |  |  |  |  106|  10.5k|#define PJ_LOG(level,arg)       do { \
  |  |  |  |  107|  10.5k|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |  417|  21.1k|#  define PJ_LOG_MAX_LEVEL   5
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (107:41): [Folded, False: 10.5k]
  |  |  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  |  |  109|      0|                                    } \
  |  |  |  |  110|  10.5k|                                } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (110:42): [Folded, False: 10.5k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   55|  10.5k|         (unsigned long)size, (unsigned long)pool->capacity,
   56|  10.5k|         (unsigned long)pj_pool_get_used_size(pool)));
   57|       |
   58|       |    /* Request memory from allocator. */
   59|  10.5k|    block = (pj_pool_block*) 
   60|  10.5k|        (*pool->factory->policy.block_alloc)(pool->factory, size);
   61|  10.5k|    if (block == NULL) {
  ------------------
  |  Branch (61:9): [True: 0, False: 10.5k]
  ------------------
   62|      0|        (*pool->callback)(pool, size);
   63|      0|        return NULL;
   64|      0|    }
   65|       |
   66|       |    /* Add capacity. */
   67|  10.5k|    pool->capacity += size;
   68|       |
   69|       |    /* Set start and end of buffer. */
   70|  10.5k|    block->buf = ((unsigned char*)block) + sizeof(pj_pool_block);
   71|  10.5k|    block->end = ((unsigned char*)block) + size;
   72|       |
   73|       |    /* Set the start pointer, unaligned! */
   74|  10.5k|    block->cur = block->buf;
   75|       |
   76|       |    /* Insert in the front of the list. */
   77|  10.5k|    pj_list_insert_after(&pool->block_list, block);
   78|       |
   79|  10.5k|    LOG((pool->obj_name," block created, buffer=%p-%p",block->buf, block->end));
  ------------------
  |  |   33|  10.5k|#define LOG(expr)                   PJ_LOG(6,expr)
  |  |  ------------------
  |  |  |  |  106|  10.5k|#define PJ_LOG(level,arg)       do { \
  |  |  |  |  107|  10.5k|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |  417|  21.1k|#  define PJ_LOG_MAX_LEVEL   5
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (107:41): [Folded, False: 10.5k]
  |  |  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  |  |  109|      0|                                    } \
  |  |  |  |  110|  10.5k|                                } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (110:42): [Folded, False: 10.5k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   80|       |
   81|  10.5k|    return block;
   82|  10.5k|}
pool.c:reset_pool:
  261|  8.17k|{
  262|  8.17k|    pj_pool_block *block;
  263|       |
  264|  8.17k|    PJ_CHECK_STACK();
  265|       |
  266|  8.17k|    block = pool->block_list.prev;
  267|  8.17k|    if (block == &pool->block_list)
  ------------------
  |  Branch (267:9): [True: 0, False: 8.17k]
  ------------------
  268|      0|        return;
  269|       |
  270|       |    /* Skip the first block because it is occupying the same memory
  271|       |       as the pool itself.
  272|       |    */
  273|  8.17k|    block = block->prev;
  274|       |    
  275|  18.7k|    while (block != &pool->block_list) {
  ------------------
  |  Branch (275:12): [True: 10.5k, False: 8.17k]
  ------------------
  276|  10.5k|        pj_pool_block *prev = block->prev;
  277|  10.5k|        pj_list_erase(block);
  278|  10.5k|        (*pool->factory->policy.block_free)(pool->factory, block, 
  279|  10.5k|                                            block->end - (unsigned char*)block);
  280|  10.5k|        block = prev;
  281|  10.5k|    }
  282|       |
  283|  8.17k|    block = pool->block_list.next;
  284|       |
  285|       |    /* Set the start pointer, unaligned! */
  286|  8.17k|    block->cur = block->buf;
  287|       |
  288|  8.17k|    pool->capacity = block->end - (unsigned char*)pool;
  289|  8.17k|}

pj_pool_create_on_buf:
   82|  1.24k|{
   83|  1.24k|#if PJ_HAS_POOL_ALT_API == 0
   84|  1.24k|    struct creation_param param;
   85|  1.24k|    pj_size_t align_diff;
   86|       |
   87|  1.24k|    PJ_ASSERT_RETURN(buf && size, NULL);
  ------------------
  |  |   97|  1.24k|            do { \
  |  |   98|  2.48k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 1.24k, False: 0]
  |  |  |  Branch (98:23): [True: 1.24k, False: 0]
  |  |  ------------------
  |  |   99|  1.24k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1.24k]
  |  |  ------------------
  ------------------
  |  Branch (87:5): [True: 0, False: 0]
  |  Branch (87:5): [True: 0, False: 0]
  |  Branch (87:5): [True: 0, False: 0]
  |  Branch (87:5): [True: 0, False: 0]
  ------------------
   88|       |
   89|  1.24k|    if (!is_initialized) {
  ------------------
  |  Branch (89:9): [True: 1, False: 1.24k]
  ------------------
   90|      1|        if (pool_buf_initialize() != PJ_SUCCESS)
  ------------------
  |  Branch (90:13): [True: 0, False: 1]
  ------------------
   91|      0|            return NULL;
   92|      1|        is_initialized = 1;
   93|      1|    }
   94|       |
   95|       |    /* Check and align buffer */
   96|  1.24k|    align_diff = (pj_size_t)buf;
   97|  1.24k|    if (align_diff & (PJ_POOL_ALIGNMENT-1)) {
  ------------------
  |  |  182|  1.24k|#define PJ_POOL_ALIGNMENT 8
  ------------------
  |  Branch (97:9): [True: 0, False: 1.24k]
  ------------------
   98|      0|        align_diff &= (PJ_POOL_ALIGNMENT-1);
  ------------------
  |  |  182|      0|#define PJ_POOL_ALIGNMENT 8
  ------------------
   99|      0|        buf = (void*) (((char*)buf) + align_diff);
  100|      0|        size -= align_diff;
  101|      0|    }
  102|       |
  103|  1.24k|    param.stack_buf = buf;
  104|  1.24k|    param.size = size;
  105|  1.24k|    pj_thread_local_set(tls, &param);
  106|       |
  107|  1.24k|    return pj_pool_create_int(&stack_based_factory, name, size, 0, 
  108|  1.24k|                              PJ_POOL_ALIGNMENT,
  ------------------
  |  |  182|  1.24k|#define PJ_POOL_ALIGNMENT 8
  ------------------
  109|  1.24k|                              pj_pool_factory_default_policy.callback);
  110|       |#else
  111|       |    PJ_UNUSED_ARG(buf);
  112|       |    PJ_UNUSED_ARG(pool_buf_initialize);
  113|       |    return pj_pool_create(NULL, name, size, size, NULL);
  114|       |#endif
  115|  1.24k|}
pool_buf.c:pool_buf_initialize:
   46|      1|{
   47|      1|    pj_atexit(&pool_buf_cleanup);
   48|       |
   49|      1|    stack_based_factory.policy.block_alloc = &stack_alloc;
   50|      1|    return pj_thread_local_alloc(&tls);
   51|      1|}
pool_buf.c:stack_alloc:
   54|  1.24k|{
   55|  1.24k|    struct creation_param *param;
   56|  1.24k|    void *buf;
   57|       |
   58|  1.24k|    PJ_UNUSED_ARG(factory);
  ------------------
  |  | 1537|  1.24k|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
   59|       |
   60|  1.24k|    param = (struct creation_param*) pj_thread_local_get(tls);
   61|  1.24k|    if (param == NULL) {
  ------------------
  |  Branch (61:9): [True: 0, False: 1.24k]
  ------------------
   62|       |        /* Don't assert(), this is normal no-memory situation */
   63|      0|        return NULL;
   64|      0|    }
   65|       |
   66|  1.24k|    pj_thread_local_set(tls, NULL);
   67|       |
   68|  1.24k|    PJ_ASSERT_RETURN(size <= param->size, NULL);
  ------------------
  |  |   97|  1.24k|            do { \
  |  |   98|  1.24k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 1.24k]
  |  |  ------------------
  |  |   99|  1.24k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1.24k]
  |  |  ------------------
  ------------------
  |  Branch (68:5): [True: 0, False: 0]
  |  Branch (68:5): [True: 0, False: 0]
  ------------------
   69|       |
   70|  1.24k|    buf = param->stack_buf;
   71|       |
   72|       |    /* Prevent the buffer from being reused */
   73|  1.24k|    param->stack_buf = NULL;
   74|       |
   75|  1.24k|    return buf;
   76|  1.24k|}

pj_caching_pool_init:
   57|  1.24k|{
   58|  1.24k|    int i;
   59|  1.24k|    pj_pool_t *pool;
   60|  1.24k|    pj_status_t status;
   61|       |
   62|  1.24k|    PJ_CHECK_STACK();
   63|       |
   64|  1.24k|    pj_bzero(cp, sizeof(*cp));
   65|       |    
   66|  1.24k|    cp->max_capacity = max_capacity;
   67|  1.24k|    pj_list_init(&cp->used_list);
   68|  21.1k|    for (i=0; i<PJ_CACHING_POOL_ARRAY_SIZE; ++i)
  ------------------
  |  |  889|  21.1k|#define PJ_CACHING_POOL_ARRAY_SIZE      16
  ------------------
  |  Branch (68:15): [True: 19.8k, False: 1.24k]
  ------------------
   69|  19.8k|        pj_list_init(&cp->free_list[i]);
   70|       |
   71|  1.24k|    if (policy == NULL) {
  ------------------
  |  Branch (71:9): [True: 0, False: 1.24k]
  ------------------
   72|      0|        policy = &pj_pool_factory_default_policy;
   73|      0|    }
   74|       |    
   75|  1.24k|    pj_memcpy(&cp->factory.policy, policy, sizeof(pj_pool_factory_policy));
   76|  1.24k|    cp->factory.create_pool = &cpool_create_pool;
   77|  1.24k|    cp->factory.release_pool = &cpool_release_pool;
   78|  1.24k|    cp->factory.dump_status = &cpool_dump_status;
   79|       |
   80|       |    /* Deprecated, these callbacks are only used for updating cp.used_size &
   81|       |     * cp.peak_used_size which are no longer used.
   82|       |     */
   83|       |    //cp->factory.on_block_alloc = &cpool_on_block_alloc;
   84|       |    //cp->factory.on_block_free = &cpool_on_block_free;
   85|  1.24k|    PJ_UNUSED_ARG(cpool_on_block_alloc);
  ------------------
  |  | 1537|  1.24k|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
   86|  1.24k|    PJ_UNUSED_ARG(cpool_on_block_free);
  ------------------
  |  | 1537|  1.24k|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
   87|       |
   88|  1.24k|    pool = pj_pool_create_on_buf("cachingpool", cp->pool_buf, sizeof(cp->pool_buf));
   89|  1.24k|    status = pj_lock_create_simple_mutex(pool, "cachingpool", &cp->lock);
   90|       |    /* This mostly serves to silent coverity warning about unchecked 
   91|       |     * return value. There's not much we can do if it fails. */
   92|  1.24k|    PJ_ASSERT_ON_FAIL(status==PJ_SUCCESS, return);
  ------------------
  |  |  111|  1.24k|            { \
  |  |  112|  1.24k|                pj_assert(expr); \
  |  |  ------------------
  |  |  |  |   65|  1.24k|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  113|  1.24k|                if (!(expr)) exec_on_fail; \
  |  |  ------------------
  |  |  |  Branch (113:21): [True: 0, False: 1.24k]
  |  |  ------------------
  |  |  114|  1.24k|            }
  ------------------
  |  Branch (92:5): [True: 0, False: 1.24k]
  |  Branch (92:5): [True: 1.24k, False: 0]
  ------------------
   93|  1.24k|}
pj_caching_pool_destroy:
   96|  1.24k|{
   97|  1.24k|    int i;
   98|  1.24k|    pj_pool_t *pool;
   99|       |
  100|  1.24k|    PJ_CHECK_STACK();
  101|       |
  102|       |    /* Delete all pool in free list */
  103|  21.1k|    for (i=0; i < PJ_CACHING_POOL_ARRAY_SIZE; ++i) {
  ------------------
  |  |  889|  21.1k|#define PJ_CACHING_POOL_ARRAY_SIZE      16
  ------------------
  |  Branch (103:15): [True: 19.8k, False: 1.24k]
  ------------------
  104|  19.8k|        pj_pool_t *next;
  105|  19.8k|        pool = (pj_pool_t*) cp->free_list[i].next;
  106|  19.8k|        for (; pool != (void*)&cp->free_list[i]; pool = next) {
  ------------------
  |  Branch (106:16): [True: 0, False: 19.8k]
  ------------------
  107|      0|            next = pool->next;
  108|      0|            pj_list_erase(pool);
  109|      0|            pj_pool_destroy_int(pool);
  110|      0|        }
  111|  19.8k|    }
  112|       |
  113|       |    /* Delete all pools in used list */
  114|  1.24k|    pool = (pj_pool_t*) cp->used_list.next;
  115|  4.82k|    while (pool != (pj_pool_t*) &cp->used_list) {
  ------------------
  |  Branch (115:12): [True: 3.58k, False: 1.24k]
  ------------------
  116|  3.58k|        pj_pool_t *next = pool->next;
  117|  3.58k|        pj_list_erase(pool);
  118|  3.58k|        PJ_LOG(4,(pool->obj_name, 
  ------------------
  |  |  106|  3.58k|#define PJ_LOG(level,arg)       do { \
  |  |  107|  3.58k|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|  7.16k|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 3.58k, Folded]
  |  |  |  Branch (107:70): [True: 0, False: 3.58k]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  480|      0|    #define pj_log_wrapper_4(arg)       pj_log_4 arg
  |  |  ------------------
  |  |  109|      0|                                    } \
  |  |  110|  3.58k|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 3.58k]
  |  |  ------------------
  ------------------
  119|  3.58k|                  "Pool is not released by application, releasing now"));
  120|  3.58k|        pj_pool_destroy_int(pool);
  121|  3.58k|        pool = next;
  122|  3.58k|    }
  123|       |
  124|  1.24k|    if (cp->lock) {
  ------------------
  |  Branch (124:9): [True: 1.24k, False: 0]
  ------------------
  125|  1.24k|        pj_status_t status;
  126|  1.24k|        pj_lock_destroy(cp->lock);
  127|  1.24k|        status = pj_lock_create_null_mutex(NULL, "cachingpool", &cp->lock);
  128|  1.24k|        PJ_ASSERT_ON_FAIL(status==PJ_SUCCESS, return);
  ------------------
  |  |  111|  1.24k|            { \
  |  |  112|  1.24k|                pj_assert(expr); \
  |  |  ------------------
  |  |  |  |   65|  1.24k|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  113|  1.24k|                if (!(expr)) exec_on_fail; \
  |  |  ------------------
  |  |  |  Branch (113:21): [True: 0, False: 1.24k]
  |  |  ------------------
  |  |  114|  1.24k|            }
  ------------------
  |  Branch (128:9): [True: 0, False: 1.24k]
  |  Branch (128:9): [True: 1.24k, False: 0]
  ------------------
  129|  1.24k|    }
  130|  1.24k|}
pool_caching.c:cpool_create_pool:
  138|  7.55k|{
  139|  7.55k|    pj_caching_pool *cp = (pj_caching_pool*)pf;
  140|  7.55k|    pj_pool_t *pool;
  141|  7.55k|    int idx;
  142|       |
  143|  7.55k|    PJ_CHECK_STACK();
  144|       |
  145|  7.55k|    pj_lock_acquire(cp->lock);
  146|       |
  147|       |    /* Use pool factory's policy when callback is NULL */
  148|  7.55k|    if (callback == NULL) {
  ------------------
  |  Branch (148:9): [True: 7.55k, False: 0]
  ------------------
  149|  7.55k|        callback = pf->policy.callback;
  150|  7.55k|    }
  151|       |
  152|       |    /* Search the suitable size for the pool. 
  153|       |     * We'll just do linear search to the size array, as the array size itself
  154|       |     * is only a few elements. Binary search I suspect will be less efficient
  155|       |     * for this purpose.
  156|       |     */
  157|  7.55k|    if (initial_size <= pool_sizes[START_SIZE]) {
  ------------------
  |  |   51|  7.55k|#define START_SIZE  5
  ------------------
  |  Branch (157:9): [True: 7.55k, False: 0]
  ------------------
  158|  7.55k|        for (idx=START_SIZE-1; 
  ------------------
  |  |   51|  7.55k|#define START_SIZE  5
  ------------------
  159|  29.9k|             idx >= 0 && pool_sizes[idx] >= initial_size;
  ------------------
  |  Branch (159:14): [True: 29.6k, False: 341]
  |  Branch (159:26): [True: 22.4k, False: 7.21k]
  ------------------
  160|  22.4k|             --idx)
  161|  22.4k|            ;
  162|  7.55k|        ++idx;
  163|  7.55k|    } else {
  164|      0|        for (idx=START_SIZE+1; 
  ------------------
  |  |   51|      0|#define START_SIZE  5
  ------------------
  165|      0|             idx < PJ_CACHING_POOL_ARRAY_SIZE && 
  ------------------
  |  |  889|      0|#define PJ_CACHING_POOL_ARRAY_SIZE      16
  ------------------
  |  Branch (165:14): [True: 0, False: 0]
  ------------------
  166|      0|                  pool_sizes[idx] < initial_size;
  ------------------
  |  Branch (166:19): [True: 0, False: 0]
  ------------------
  167|      0|             ++idx)
  168|      0|            ;
  169|      0|    }
  170|       |
  171|       |    /* Check whether there's a pool in the list. */
  172|  7.55k|    if (idx==PJ_CACHING_POOL_ARRAY_SIZE || pj_list_empty(&cp->free_list[idx])) {
  ------------------
  |  |  889|  15.1k|#define PJ_CACHING_POOL_ARRAY_SIZE      16
  ------------------
  |  Branch (172:9): [True: 0, False: 7.55k]
  |  Branch (172:44): [True: 7.55k, False: 0]
  ------------------
  173|       |        /* No pool is available. */
  174|       |        /* Set minimum size. */
  175|  7.55k|        if (idx < PJ_CACHING_POOL_ARRAY_SIZE)
  ------------------
  |  |  889|  7.55k|#define PJ_CACHING_POOL_ARRAY_SIZE      16
  ------------------
  |  Branch (175:13): [True: 7.55k, False: 0]
  ------------------
  176|  7.55k|            initial_size =  pool_sizes[idx];
  177|       |
  178|       |        /* Create new pool */
  179|  7.55k|        pool = pj_pool_create_int(&cp->factory, name, initial_size, 
  180|  7.55k|                                  increment_sz, alignment, callback);
  181|  7.55k|        if (!pool) {
  ------------------
  |  Branch (181:13): [True: 0, False: 7.55k]
  ------------------
  182|      0|            pj_lock_release(cp->lock);
  183|      0|            return NULL;
  184|      0|        }
  185|       |
  186|  7.55k|    } else {
  187|       |        /* Get one pool from the list. */
  188|      0|        pool = (pj_pool_t*) cp->free_list[idx].next;
  189|      0|        pj_list_erase(pool);
  190|       |
  191|       |        /* Initialize the pool. */
  192|      0|        pj_pool_init_int(pool, name, increment_sz, alignment, callback);
  193|       |
  194|       |        /* Update pool manager's free capacity. */
  195|      0|        if (cp->capacity > pj_pool_get_capacity(pool)) {
  ------------------
  |  Branch (195:13): [True: 0, False: 0]
  ------------------
  196|      0|            cp->capacity -= pj_pool_get_capacity(pool);
  197|      0|        } else {
  198|      0|            cp->capacity = 0;
  199|      0|        }
  200|       |
  201|      0|        PJ_LOG(6, (pool->obj_name, "pool reused, size=%lu",
  ------------------
  |  |  106|      0|#define PJ_LOG(level,arg)       do { \
  |  |  107|      0|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|      0|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [Folded, False: 0]
  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  109|      0|                                    } \
  |  |  110|      0|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 0]
  |  |  ------------------
  ------------------
  202|      0|                   (unsigned long)pool->capacity));
  203|      0|    }
  204|       |
  205|       |    /* Put in used list. */
  206|  7.55k|    pj_list_insert_before( &cp->used_list, pool );
  207|       |
  208|       |    /* Mark factory data */
  209|  7.55k|    pool->factory_data = (void*) (pj_ssize_t) idx;
  210|       |
  211|       |    /* Increment used count. */
  212|  7.55k|    ++cp->used_count;
  213|       |
  214|  7.55k|    pj_lock_release(cp->lock);
  215|  7.55k|    return pool;
  216|  7.55k|}
pool_caching.c:cpool_release_pool:
  219|  3.97k|{
  220|  3.97k|    pj_caching_pool *cp = (pj_caching_pool*)pf;
  221|  3.97k|    pj_size_t pool_capacity;
  222|  3.97k|    unsigned i;
  223|       |
  224|  3.97k|    PJ_CHECK_STACK();
  225|       |
  226|  3.97k|    PJ_ASSERT_ON_FAIL(pf && pool, return);
  ------------------
  |  |  111|  3.97k|            { \
  |  |  112|  3.97k|                pj_assert(expr); \
  |  |  ------------------
  |  |  |  |   65|  3.97k|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  113|  7.94k|                if (!(expr)) exec_on_fail; \
  |  |  ------------------
  |  |  |  Branch (113:23): [True: 3.97k, False: 0]
  |  |  |  Branch (113:23): [True: 3.97k, False: 0]
  |  |  ------------------
  |  |  114|  3.97k|            }
  ------------------
  |  Branch (226:5): [True: 0, False: 3.97k]
  |  Branch (226:5): [True: 0, False: 0]
  |  Branch (226:5): [True: 3.97k, False: 0]
  |  Branch (226:5): [True: 3.97k, False: 0]
  ------------------
  227|       |
  228|  3.97k|    pj_lock_acquire(cp->lock);
  229|       |
  230|       |#if PJ_SAFE_POOL
  231|       |    /* Make sure pool is still in our used list */
  232|       |    if (pj_list_find_node(&cp->used_list, pool) != pool) {
  233|       |        pj_lock_release(cp->lock);
  234|       |        pj_assert(!"Attempt to destroy pool that has been destroyed before");
  235|       |        return;
  236|       |    }
  237|       |#endif
  238|       |
  239|       |    /* Erase from the used list. */
  240|  3.97k|    pj_list_erase(pool);
  241|       |
  242|       |    /* Decrement used count. */
  243|  3.97k|    --cp->used_count;
  244|       |
  245|  3.97k|    pool_capacity = pj_pool_get_capacity(pool);
  246|       |
  247|       |    /* Destroy the pool if the size is greater than our size or if the total
  248|       |     * capacity in our recycle list (plus the size of the pool) exceeds 
  249|       |     * maximum capacity.
  250|       |   . */
  251|  3.97k|    if (pool_capacity > pool_sizes[PJ_CACHING_POOL_ARRAY_SIZE-1] ||
  ------------------
  |  |  889|  3.97k|#define PJ_CACHING_POOL_ARRAY_SIZE      16
  ------------------
  |  Branch (251:9): [True: 0, False: 3.97k]
  ------------------
  252|  3.97k|        cp->capacity + pool_capacity > cp->max_capacity)
  ------------------
  |  Branch (252:9): [True: 3.97k, False: 0]
  ------------------
  253|  3.97k|    {
  254|  3.97k|        pj_pool_destroy_int(pool);
  255|  3.97k|        pj_lock_release(cp->lock);
  256|  3.97k|        return;
  257|  3.97k|    }
  258|       |
  259|       |    /* Reset pool. */
  260|      0|    PJ_LOG(6, (pool->obj_name, "recycle(): cap=%lu, used=%lu(%lu%%)", 
  ------------------
  |  |  106|      0|#define PJ_LOG(level,arg)       do { \
  |  |  107|      0|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|      0|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [Folded, False: 0]
  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  109|      0|                                    } \
  |  |  110|      0|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 0]
  |  |  ------------------
  ------------------
  261|      0|               (unsigned long)pool_capacity,
  262|      0|               (unsigned long)pj_pool_get_used_size(pool), 
  263|      0|               (unsigned long)(pj_pool_get_used_size(pool)*100/
  264|      0|                               pool_capacity)));
  265|      0|    pj_pool_reset(pool);
  266|       |
  267|      0|    pool_capacity = pj_pool_get_capacity(pool);
  268|       |
  269|       |    /*
  270|       |     * Otherwise put the pool in our recycle list.
  271|       |     */
  272|      0|    i = (unsigned) (unsigned long) (pj_ssize_t) pool->factory_data;
  273|       |
  274|      0|    pj_assert(i<PJ_CACHING_POOL_ARRAY_SIZE);
  ------------------
  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (274:5): [True: 0, False: 0]
  |  Branch (274:5): [True: 0, False: 0]
  ------------------
  275|      0|    if (i >= PJ_CACHING_POOL_ARRAY_SIZE ) {
  ------------------
  |  |  889|      0|#define PJ_CACHING_POOL_ARRAY_SIZE      16
  ------------------
  |  Branch (275:9): [True: 0, False: 0]
  ------------------
  276|       |        /* Something has gone wrong with the pool. */
  277|      0|        pj_pool_destroy_int(pool);
  278|      0|        pj_lock_release(cp->lock);
  279|      0|        return;
  280|      0|    }
  281|       |
  282|      0|    pj_list_insert_after(&cp->free_list[i], pool);
  283|      0|    cp->capacity += pool_capacity;
  284|       |
  285|      0|    pj_lock_release(cp->lock);
  286|      0|}

pool_policy_malloc.c:default_block_alloc:
   33|  18.1k|{
   34|  18.1k|    void *p;
   35|       |
   36|  18.1k|    PJ_CHECK_STACK();
   37|       |
   38|  18.1k|    if (factory->on_block_alloc) {
  ------------------
  |  Branch (38:9): [True: 0, False: 18.1k]
  ------------------
   39|      0|        int rc;
   40|      0|        rc = factory->on_block_alloc(factory, size);
   41|      0|        if (!rc)
  ------------------
  |  Branch (41:13): [True: 0, False: 0]
  ------------------
   42|      0|            return NULL;
   43|      0|    }
   44|       |
   45|  18.1k|    p = malloc(size+(SIG_SIZE << 1));
  ------------------
  |  |   64|  18.1k|#   define SIG_SIZE         0
  ------------------
   46|       |
   47|  18.1k|    if (p == NULL) {
  ------------------
  |  Branch (47:9): [True: 0, False: 18.1k]
  ------------------
   48|      0|        if (factory->on_block_free) 
  ------------------
  |  Branch (48:13): [True: 0, False: 0]
  ------------------
   49|      0|            factory->on_block_free(factory, size);
   50|  18.1k|    } else {
   51|       |        /* Apply signature when PJ_SAFE_POOL is set. It will move
   52|       |         * "p" pointer forward.
   53|       |         */
   54|  18.1k|        APPLY_SIG(p, size);
   55|  18.1k|    }
   56|       |
   57|  18.1k|    return p;
   58|  18.1k|}
pool_policy_malloc.c:default_block_free:
   62|  18.1k|{
   63|  18.1k|    PJ_CHECK_STACK();
   64|       |
   65|  18.1k|    if (factory->on_block_free) 
  ------------------
  |  Branch (65:9): [True: 0, False: 18.1k]
  ------------------
   66|      0|        factory->on_block_free(factory, size);
   67|       |
   68|       |    /* Check and remove signature when PJ_SAFE_POOL is set. It will
   69|       |     * move "mem" pointer backward.
   70|       |     */
   71|  18.1k|    REMOVE_SIG(mem, size);
   72|       |
   73|       |    /* Note that when PJ_SAFE_POOL is set, the actual size of the block
   74|       |     * is size + SIG_SIZE*2.
   75|       |     */
   76|       |
   77|  18.1k|    free(mem);
   78|  18.1k|}

pj_rand:
   30|  3.98k|{
   31|  3.98k|    PJ_CHECK_STACK();
   32|  3.98k|    return platform_rand();
  ------------------
  |  |   43|  3.98k|#      define platform_rand rand
  ------------------
   33|  3.98k|}

pj_ntohs:
  226|  10.0k|{
  227|       |    return ntohs(netshort);
  228|  10.0k|}
pj_htons:
  234|  8.40k|{
  235|       |    return htons(hostshort);
  236|  8.40k|}
pj_ntohl:
  242|  4.54k|{
  243|       |    return ntohl(netlong);
  244|  4.54k|}
pj_htonl:
  250|  2.66k|{
  251|       |    return htonl(hostlong);
  252|  2.66k|}
pj_inet_pton:
  309|  1.23k|{
  310|  1.23k|    char tempaddr[PJ_INET6_ADDRSTRLEN];
  311|       |
  312|  1.23k|    PJ_ASSERT_RETURN(af==PJ_AF_INET || af==PJ_AF_INET6, PJ_EAFNOTSUP);
  ------------------
  |  |   97|  1.23k|            do { \
  |  |   98|  1.23k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 1.23k, False: 0]
  |  |  |  Branch (98:23): [True: 0, False: 0]
  |  |  ------------------
  |  |   99|  1.23k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1.23k]
  |  |  ------------------
  ------------------
  |  Branch (312:5): [True: 0, False: 0]
  |  Branch (312:5): [True: 0, False: 0]
  |  Branch (312:5): [True: 0, False: 0]
  |  Branch (312:5): [True: 0, False: 0]
  ------------------
  313|  1.23k|    PJ_ASSERT_RETURN(src && src->slen && dst, PJ_EINVAL);
  ------------------
  |  |   97|  1.23k|            do { \
  |  |   98|  4.94k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 1.23k, False: 0]
  |  |  |  Branch (98:23): [True: 1.23k, False: 0]
  |  |  |  Branch (98:23): [True: 1.23k, False: 0]
  |  |  ------------------
  |  |   99|  1.23k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1.23k]
  |  |  ------------------
  ------------------
  |  Branch (313:5): [True: 0, False: 0]
  |  Branch (313:5): [True: 0, False: 0]
  |  Branch (313:5): [True: 0, False: 0]
  |  Branch (313:5): [True: 0, False: 0]
  |  Branch (313:5): [True: 0, False: 0]
  |  Branch (313:5): [True: 0, False: 0]
  ------------------
  314|       |
  315|       |    /* Initialize output with PJ_IN_ADDR_NONE for IPv4 (to be 
  316|       |     * compatible with pj_inet_aton()
  317|       |     */
  318|  1.23k|    if (af==PJ_AF_INET) {
  ------------------
  |  Branch (318:9): [True: 1.23k, False: 0]
  ------------------
  319|  1.23k|        ((pj_in_addr*)dst)->s_addr = PJ_INADDR_NONE;
  ------------------
  |  |  472|  1.23k|#define PJ_INADDR_NONE      ((pj_uint32_t)0xffffffff)
  ------------------
  320|  1.23k|    }
  321|       |
  322|       |    /* Caution:
  323|       |     *  this function might be called with cp->slen >= 46
  324|       |     *  (i.e. when called with hostname to check if it's an IP addr).
  325|       |     */
  326|  1.23k|    if (src->slen >= PJ_INET6_ADDRSTRLEN) {
  ------------------
  |  |  522|  1.23k|#define PJ_INET6_ADDRSTRLEN     46
  ------------------
  |  Branch (326:9): [True: 0, False: 1.23k]
  ------------------
  327|      0|        return PJ_ENAMETOOLONG;
  ------------------
  |  |  398|      0|#define PJ_ENAMETOOLONG     (PJ_ERRNO_START_STATUS + 5) /* 70005 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  328|      0|    }
  329|       |
  330|  1.23k|    pj_memcpy(tempaddr, src->ptr, src->slen);
  331|  1.23k|    tempaddr[src->slen] = '\0';
  332|       |
  333|  1.23k|#if defined(PJ_SOCK_HAS_INET_PTON) && PJ_SOCK_HAS_INET_PTON != 0
  334|       |    /*
  335|       |     * Implementation using inet_pton()
  336|       |     */
  337|  1.23k|    if (inet_pton(af, tempaddr, dst) != 1) {
  ------------------
  |  Branch (337:9): [True: 0, False: 1.23k]
  ------------------
  338|      0|        pj_status_t status = pj_get_netos_error();
  339|      0|        if (status == PJ_SUCCESS)
  ------------------
  |  Branch (339:13): [True: 0, False: 0]
  ------------------
  340|      0|            status = PJ_EUNKNOWN;
  ------------------
  |  |  378|      0|#define PJ_EUNKNOWN         (PJ_ERRNO_START_STATUS + 1) /* 70001 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  341|       |
  342|      0|        return status;
  343|      0|    }
  344|       |
  345|  1.23k|    return PJ_SUCCESS;
  346|       |
  347|       |#elif defined(PJ_WIN32) || defined(PJ_WIN64) || defined(PJ_WIN32_WINCE)
  348|       |    /*
  349|       |     * Implementation on Windows, using WSAStringToAddress().
  350|       |     * Should also work on Unicode systems.
  351|       |     */
  352|       |    {
  353|       |        PJ_DECL_UNICODE_TEMP_BUF(wtempaddr,PJ_INET6_ADDRSTRLEN)
  354|       |        pj_sockaddr sock_addr;
  355|       |        int addr_len = sizeof(sock_addr);
  356|       |        int rc;
  357|       |
  358|       |        sock_addr.addr.sa_family = (pj_uint16_t)af;
  359|       |        rc = WSAStringToAddress(
  360|       |                PJ_STRING_TO_NATIVE(tempaddr,wtempaddr,sizeof(wtempaddr)), 
  361|       |                af, NULL, (LPSOCKADDR)&sock_addr, &addr_len);
  362|       |        if (rc != 0) {
  363|       |            /* If you get rc 130022 Invalid argument (WSAEINVAL) with IPv6,
  364|       |             * check that you have IPv6 enabled (install it in the network
  365|       |             * adapter).
  366|       |             */
  367|       |            pj_status_t status = pj_get_netos_error();
  368|       |            if (status == PJ_SUCCESS)
  369|       |                status = PJ_EUNKNOWN;
  370|       |
  371|       |            return status;
  372|       |        }
  373|       |
  374|       |        if (sock_addr.addr.sa_family == PJ_AF_INET) {
  375|       |            pj_memcpy(dst, &sock_addr.ipv4.sin_addr, 4);
  376|       |            return PJ_SUCCESS;
  377|       |        } else if (sock_addr.addr.sa_family == PJ_AF_INET6) {
  378|       |            pj_memcpy(dst, &sock_addr.ipv6.sin6_addr, 16);
  379|       |            return PJ_SUCCESS;
  380|       |        } else {
  381|       |            pj_assert(!"Shouldn't happen");
  382|       |            return PJ_EBUG;
  383|       |        }
  384|       |    }
  385|       |#elif !defined(PJ_HAS_IPV6) || PJ_HAS_IPV6==0
  386|       |    /* IPv6 support is disabled, just return error without raising assertion */
  387|       |    return PJ_EIPV6NOTSUP;
  388|       |#else
  389|       |    pj_assert(!"Not supported");
  390|       |    return PJ_EIPV6NOTSUP;
  391|       |#endif
  392|  1.23k|}
pj_inet_ntop:
  400|  1.13k|{
  401|  1.13k|    PJ_ASSERT_RETURN(src && dst && size, PJ_EINVAL);
  ------------------
  |  |   97|  1.13k|            do { \
  |  |   98|  4.54k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 1.13k, False: 0]
  |  |  |  Branch (98:23): [True: 1.13k, False: 0]
  |  |  |  Branch (98:23): [True: 1.13k, False: 0]
  |  |  ------------------
  |  |   99|  1.13k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1.13k]
  |  |  ------------------
  ------------------
  |  Branch (401:5): [True: 0, False: 0]
  |  Branch (401:5): [True: 0, False: 0]
  |  Branch (401:5): [True: 0, False: 0]
  |  Branch (401:5): [True: 0, False: 0]
  |  Branch (401:5): [True: 0, False: 0]
  |  Branch (401:5): [True: 0, False: 0]
  ------------------
  402|       |
  403|  1.13k|    *dst = '\0';
  404|       |
  405|  1.13k|    PJ_ASSERT_RETURN(af==PJ_AF_INET || af==PJ_AF_INET6, PJ_EAFNOTSUP);
  ------------------
  |  |   97|  1.13k|            do { \
  |  |   98|  1.13k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 1.13k, False: 0]
  |  |  |  Branch (98:23): [True: 0, False: 0]
  |  |  ------------------
  |  |   99|  1.13k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1.13k]
  |  |  ------------------
  ------------------
  |  Branch (405:5): [True: 0, False: 0]
  |  Branch (405:5): [True: 0, False: 0]
  |  Branch (405:5): [True: 0, False: 0]
  |  Branch (405:5): [True: 0, False: 0]
  ------------------
  406|       |
  407|  1.13k|#if defined(PJ_SOCK_HAS_INET_NTOP) && PJ_SOCK_HAS_INET_NTOP != 0
  408|       |    /*
  409|       |     * Implementation using inet_ntop()
  410|       |     */
  411|  1.13k|    if (inet_ntop(af, src, dst, size) == NULL) {
  ------------------
  |  Branch (411:9): [True: 0, False: 1.13k]
  ------------------
  412|      0|        pj_status_t status = pj_get_netos_error();
  413|      0|        if (status == PJ_SUCCESS)
  ------------------
  |  Branch (413:13): [True: 0, False: 0]
  ------------------
  414|      0|            status = PJ_EUNKNOWN;
  ------------------
  |  |  378|      0|#define PJ_EUNKNOWN         (PJ_ERRNO_START_STATUS + 1) /* 70001 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  415|       |
  416|      0|        return status;
  417|      0|    }
  418|       |
  419|  1.13k|    return PJ_SUCCESS;
  420|       |
  421|       |#elif defined(PJ_WIN32) || defined(PJ_WIN64) || defined(PJ_WIN32_WINCE)
  422|       |    /*
  423|       |     * Implementation on Windows, using WSAAddressToString().
  424|       |     * Should also work on Unicode systems.
  425|       |     */
  426|       |    {
  427|       |        PJ_DECL_UNICODE_TEMP_BUF(wtempaddr,PJ_INET6_ADDRSTRLEN)
  428|       |        pj_sockaddr sock_addr;
  429|       |        DWORD addr_len, addr_str_len;
  430|       |        int rc;
  431|       |
  432|       |        pj_bzero(&sock_addr, sizeof(sock_addr));
  433|       |        sock_addr.addr.sa_family = (pj_uint16_t)af;
  434|       |        if (af == PJ_AF_INET) {
  435|       |            if (size < PJ_INET_ADDRSTRLEN)
  436|       |                return PJ_ETOOSMALL;
  437|       |            pj_memcpy(&sock_addr.ipv4.sin_addr, src, 4);
  438|       |            addr_len = sizeof(pj_sockaddr_in);
  439|       |            addr_str_len = PJ_INET_ADDRSTRLEN;
  440|       |        } else if (af == PJ_AF_INET6) {
  441|       |            if (size < PJ_INET6_ADDRSTRLEN)
  442|       |                return PJ_ETOOSMALL;
  443|       |            pj_memcpy(&sock_addr.ipv6.sin6_addr, src, 16);
  444|       |            addr_len = sizeof(pj_sockaddr_in6);
  445|       |            addr_str_len = PJ_INET6_ADDRSTRLEN;
  446|       |        } else {
  447|       |            pj_assert(!"Unsupported address family");
  448|       |            return PJ_EAFNOTSUP;
  449|       |        }
  450|       |
  451|       |#if PJ_NATIVE_STRING_IS_UNICODE
  452|       |        rc = WSAAddressToString((LPSOCKADDR)&sock_addr, addr_len,
  453|       |                                NULL, wtempaddr, &addr_str_len);
  454|       |        if (rc == 0) {
  455|       |            pj_unicode_to_ansi(wtempaddr, wcslen(wtempaddr), dst, size);
  456|       |        }
  457|       |#else
  458|       |        rc = WSAAddressToString((LPSOCKADDR)&sock_addr, addr_len,
  459|       |                                NULL, dst, &addr_str_len);
  460|       |#endif
  461|       |
  462|       |        if (rc != 0) {
  463|       |            pj_status_t status = pj_get_netos_error();
  464|       |            if (status == PJ_SUCCESS)
  465|       |                status = PJ_EUNKNOWN;
  466|       |
  467|       |            return status;
  468|       |        }
  469|       |
  470|       |        return PJ_SUCCESS;
  471|       |    }
  472|       |
  473|       |#elif !defined(PJ_HAS_IPV6) || PJ_HAS_IPV6==0
  474|       |    /* IPv6 support is disabled, just return error without raising assertion */
  475|       |    return PJ_EIPV6NOTSUP;
  476|       |#else
  477|       |    pj_assert(!"Not supported");
  478|       |    return PJ_EIPV6NOTSUP;
  479|       |#endif
  480|  1.13k|}
pj_gethostname:
  486|    341|{
  487|    341|    static char buf[PJ_MAX_HOSTNAME];
  488|    341|    static pj_str_t hostname;
  489|       |
  490|    341|    PJ_CHECK_STACK();
  491|       |
  492|    341|    if (hostname.ptr == NULL) {
  ------------------
  |  Branch (492:9): [True: 1, False: 340]
  ------------------
  493|      1|        hostname.ptr = buf;
  494|      1|        if (gethostname(buf, sizeof(buf)) != 0) {
  ------------------
  |  Branch (494:13): [True: 0, False: 1]
  ------------------
  495|      0|            hostname.ptr[0] = '\0';
  496|      0|            hostname.slen = 0;
  497|      1|        } else {
  498|      1|            hostname.slen = strlen(buf);
  499|      1|        }
  500|      1|    }
  501|    341|    return &hostname;
  502|    341|}
pj_sock_socket:
  562|    682|{
  563|    682|    int type0 = type;
  564|       |
  565|    682|    PJ_CHECK_STACK();
  566|       |
  567|       |    /* Sanity checks. */
  568|    682|    PJ_ASSERT_RETURN(sock!=NULL, PJ_EINVAL);
  ------------------
  |  |   97|    682|            do { \
  |  |   98|    682|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 682]
  |  |  ------------------
  |  |   99|    682|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 682]
  |  |  ------------------
  ------------------
  |  Branch (568:5): [True: 0, False: 0]
  |  Branch (568:5): [True: 0, False: 0]
  ------------------
  569|    682|    PJ_ASSERT_RETURN(PJ_INVALID_SOCKET==-1, 
  ------------------
  |  |   97|    682|            do { \
  |  |   98|    682|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [Folded, False: 682]
  |  |  ------------------
  |  |   99|    682|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 682]
  |  |  ------------------
  ------------------
  |  Branch (569:5): [True: 0, Folded]
  |  Branch (569:5): [True: 0, Folded]
  ------------------
  570|    682|                     (*sock=PJ_INVALID_SOCKET, PJ_EINVAL));
  571|       |
  572|       |#if !defined(SOCK_CLOEXEC)
  573|       |    if ((type0 & pj_SOCK_CLOEXEC()) == pj_SOCK_CLOEXEC())
  574|       |        type &= ~pj_SOCK_CLOEXEC();
  575|       |#else
  576|    682|    PJ_UNUSED_ARG(type0);
  ------------------
  |  | 1537|    682|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
  577|    682|#endif
  578|       |
  579|    682|    *sock = socket(af, type, proto);
  580|    682|    TRACE_((THIS_FILE, "Created new socket of type %d: %ld", type, *sock));
  581|    682|    if (*sock == PJ_INVALID_SOCKET)
  ------------------
  |  |  492|    682|#define PJ_INVALID_SOCKET   (-1)
  ------------------
  |  Branch (581:9): [True: 0, False: 682]
  ------------------
  582|      0|        return PJ_RETURN_OS_ERROR(pj_get_native_netos_error());
  ------------------
  |  |  319|      0|#   define PJ_RETURN_OS_ERROR(os_code)   (os_code ? \
  |  |  ------------------
  |  |  |  Branch (319:43): [True: 0, False: 0]
  |  |  ------------------
  |  |  320|      0|                                            PJ_STATUS_FROM_OS(os_code) : -1)
  |  |  ------------------
  |  |  |  |  334|      0|#   define PJ_STATUS_FROM_OS(e) (e == 0 ? PJ_SUCCESS : e + PJ_ERRNO_START_SYS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  528|      0|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (334:34): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  583|    682|    else {
  584|    682|        pj_int32_t val = 1;
  585|    682|        if ((type & 0xF) == pj_SOCK_STREAM()) {
  ------------------
  |  |  165|    682|#   define pj_SOCK_STREAM() PJ_SOCK_STREAM
  ------------------
  |  Branch (585:13): [True: 0, False: 682]
  ------------------
  586|      0|            pj_sock_setsockopt(*sock, pj_SOL_SOCKET(), pj_SO_NOSIGPIPE(),
  ------------------
  |  |  211|      0|#   define pj_SOL_SOCKET()  PJ_SOL_SOCKET
  ------------------
                          pj_sock_setsockopt(*sock, pj_SOL_SOCKET(), pj_SO_NOSIGPIPE(),
  ------------------
  |  |  396|      0|#   define pj_SO_NOSIGPIPE() PJ_SO_NOSIGPIPE
  ------------------
  587|      0|                               &val, sizeof(val));
  588|      0|        }
  589|    682|#if defined(PJ_SOCK_HAS_IPV6_V6ONLY) && PJ_SOCK_HAS_IPV6_V6ONLY != 0
  590|    682|        if (af == PJ_AF_INET6) {
  ------------------
  |  Branch (590:13): [True: 0, False: 682]
  ------------------
  591|      0|            pj_sock_setsockopt(*sock, PJ_SOL_IPV6, IPV6_V6ONLY,
  592|      0|                               &val, sizeof(val));
  593|      0|        }
  594|    682|#endif
  595|       |#if defined(PJ_IPHONE_OS_HAS_MULTITASKING_SUPPORT) && \
  596|       |    PJ_IPHONE_OS_HAS_MULTITASKING_SUPPORT!=0
  597|       |        if ((type & 0xF) == pj_SOCK_DGRAM()) {
  598|       |            pj_sock_setsockopt(*sock, pj_SOL_SOCKET(), SO_NOSIGPIPE, 
  599|       |                               &val, sizeof(val));
  600|       |        }
  601|       |#endif
  602|       |
  603|       |#if !defined(SOCK_CLOEXEC)
  604|       |        if ((type0 & pj_SOCK_CLOEXEC()) == pj_SOCK_CLOEXEC())
  605|       |            pj_set_cloexec_flag((int)(*sock));
  606|       |#endif
  607|    682|        return PJ_SUCCESS;
  608|    682|    }
  609|    682|}
pj_sock_bind:
  618|    341|{
  619|    341|    PJ_CHECK_STACK();
  620|       |
  621|    341|    PJ_ASSERT_RETURN(addr && len >= (int)sizeof(struct sockaddr_in), PJ_EINVAL);
  ------------------
  |  |   97|    341|            do { \
  |  |   98|    682|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 341, False: 0]
  |  |  |  Branch (98:23): [True: 341, False: 0]
  |  |  ------------------
  |  |   99|    341|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 341]
  |  |  ------------------
  ------------------
  |  Branch (621:5): [True: 0, False: 0]
  |  Branch (621:5): [True: 0, False: 0]
  |  Branch (621:5): [True: 0, False: 0]
  |  Branch (621:5): [True: 0, False: 0]
  ------------------
  622|       |
  623|    341|    CHECK_ADDR_LEN(addr, len);
  624|       |
  625|    341|    if (bind(sock, (struct sockaddr*)addr, len) != 0)
  ------------------
  |  Branch (625:9): [True: 0, False: 341]
  ------------------
  626|      0|        return PJ_RETURN_OS_ERROR(pj_get_native_netos_error());
  ------------------
  |  |  319|      0|#   define PJ_RETURN_OS_ERROR(os_code)   (os_code ? \
  |  |  ------------------
  |  |  |  Branch (319:43): [True: 0, False: 0]
  |  |  ------------------
  |  |  320|      0|                                            PJ_STATUS_FROM_OS(os_code) : -1)
  |  |  ------------------
  |  |  |  |  334|      0|#   define PJ_STATUS_FROM_OS(e) (e == 0 ? PJ_SUCCESS : e + PJ_ERRNO_START_SYS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  528|      0|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (334:34): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  627|    341|    else
  628|    341|        return PJ_SUCCESS;
  629|    341|}
pj_sock_close:
  657|    682|{
  658|    682|    int rc;
  659|       |
  660|    682|    PJ_CHECK_STACK();
  661|       |#if defined(PJ_WIN32) && PJ_WIN32!=0 || \
  662|       |    defined(PJ_WIN64) && PJ_WIN64 != 0 || \
  663|       |    defined(PJ_WIN32_WINCE) && PJ_WIN32_WINCE!=0
  664|       |    rc = closesocket(sock);
  665|       |#else
  666|    682|    rc = close(sock);
  667|    682|#endif
  668|       |
  669|    682|    if (rc != 0)
  ------------------
  |  Branch (669:9): [True: 0, False: 682]
  ------------------
  670|      0|        return PJ_RETURN_OS_ERROR(pj_get_native_netos_error());
  ------------------
  |  |  319|      0|#   define PJ_RETURN_OS_ERROR(os_code)   (os_code ? \
  |  |  ------------------
  |  |  |  Branch (319:43): [True: 0, False: 0]
  |  |  ------------------
  |  |  320|      0|                                            PJ_STATUS_FROM_OS(os_code) : -1)
  |  |  ------------------
  |  |  |  |  334|      0|#   define PJ_STATUS_FROM_OS(e) (e == 0 ? PJ_SUCCESS : e + PJ_ERRNO_START_SYS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  528|      0|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (334:34): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  671|    682|    else
  672|    682|        return PJ_SUCCESS;
  673|    682|}
pj_sock_getsockname:
  697|    682|{
  698|    682|    PJ_CHECK_STACK();
  699|    682|    if (getsockname(sock, (struct sockaddr*)addr, (socklen_t*)namelen) != 0)
  ------------------
  |  Branch (699:9): [True: 0, False: 682]
  ------------------
  700|      0|        return PJ_RETURN_OS_ERROR(pj_get_native_netos_error());
  ------------------
  |  |  319|      0|#   define PJ_RETURN_OS_ERROR(os_code)   (os_code ? \
  |  |  ------------------
  |  |  |  Branch (319:43): [True: 0, False: 0]
  |  |  ------------------
  |  |  320|      0|                                            PJ_STATUS_FROM_OS(os_code) : -1)
  |  |  ------------------
  |  |  |  |  334|      0|#   define PJ_STATUS_FROM_OS(e) (e == 0 ? PJ_SUCCESS : e + PJ_ERRNO_START_SYS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  528|      0|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (334:34): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  701|    682|    else {
  702|    682|        PJ_SOCKADDR_RESET_LEN(addr);
  703|    682|        return PJ_SUCCESS;
  704|    682|    }
  705|    682|}
pj_sock_getsockopt:
  814|    341|{
  815|    341|    PJ_CHECK_STACK();
  816|    341|    PJ_ASSERT_RETURN(optval && optlen, PJ_EINVAL);
  ------------------
  |  |   97|    341|            do { \
  |  |   98|    682|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 341, False: 0]
  |  |  |  Branch (98:23): [True: 341, False: 0]
  |  |  ------------------
  |  |   99|    341|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 341]
  |  |  ------------------
  ------------------
  |  Branch (816:5): [True: 0, False: 0]
  |  Branch (816:5): [True: 0, False: 0]
  |  Branch (816:5): [True: 0, False: 0]
  |  Branch (816:5): [True: 0, False: 0]
  ------------------
  817|       |
  818|    341|    if (getsockopt(sock, level, optname, (char*)optval, (socklen_t*)optlen)!=0)
  ------------------
  |  Branch (818:9): [True: 0, False: 341]
  ------------------
  819|      0|        return PJ_RETURN_OS_ERROR(pj_get_native_netos_error());
  ------------------
  |  |  319|      0|#   define PJ_RETURN_OS_ERROR(os_code)   (os_code ? \
  |  |  ------------------
  |  |  |  Branch (319:43): [True: 0, False: 0]
  |  |  ------------------
  |  |  320|      0|                                            PJ_STATUS_FROM_OS(os_code) : -1)
  |  |  ------------------
  |  |  |  |  334|      0|#   define PJ_STATUS_FROM_OS(e) (e == 0 ? PJ_SUCCESS : e + PJ_ERRNO_START_SYS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  528|      0|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (334:34): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  820|    341|    else
  821|    341|        return PJ_SUCCESS;
  822|    341|}
pj_sock_connect:
  888|    341|{
  889|    341|    PJ_CHECK_STACK();
  890|    341|    if (connect(sock, (struct sockaddr*)addr, namelen) != 0)
  ------------------
  |  Branch (890:9): [True: 0, False: 341]
  ------------------
  891|      0|        return PJ_RETURN_OS_ERROR(pj_get_native_netos_error());
  ------------------
  |  |  319|      0|#   define PJ_RETURN_OS_ERROR(os_code)   (os_code ? \
  |  |  ------------------
  |  |  |  Branch (319:43): [True: 0, False: 0]
  |  |  ------------------
  |  |  320|      0|                                            PJ_STATUS_FROM_OS(os_code) : -1)
  |  |  ------------------
  |  |  |  |  334|      0|#   define PJ_STATUS_FROM_OS(e) (e == 0 ? PJ_SUCCESS : e + PJ_ERRNO_START_SYS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  528|      0|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (334:34): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  892|    341|    else
  893|    341|        return PJ_SUCCESS;
  894|    341|}

pj_sockaddr_print:
   79|  1.13k|{
   80|  1.13k|    enum {
   81|  1.13k|        WITH_PORT = 1,
   82|  1.13k|        WITH_BRACKETS = 2
   83|  1.13k|    };
   84|       |
   85|  1.13k|    char txt[PJ_INET6_ADDRSTRLEN];
   86|  1.13k|    char port[32];
   87|  1.13k|    const pj_addr_hdr *h = (const pj_addr_hdr*)addr;
   88|  1.13k|    char *bquote, *equote;
   89|  1.13k|    pj_status_t status;
   90|       |
   91|  1.13k|    status = pj_inet_ntop(h->sa_family, pj_sockaddr_get_addr(addr),
   92|  1.13k|                          txt, sizeof(txt));
   93|  1.13k|    if (status != PJ_SUCCESS)
  ------------------
  |  Branch (93:9): [True: 0, False: 1.13k]
  ------------------
   94|      0|        return "";
   95|       |
   96|  1.13k|    if (h->sa_family != PJ_AF_INET6 || (flags & WITH_BRACKETS)==0) {
  ------------------
  |  Branch (96:9): [True: 1.13k, False: 0]
  |  Branch (96:40): [True: 0, False: 0]
  ------------------
   97|  1.13k|        bquote = ""; equote = "";
   98|  1.13k|    } else {
   99|      0|        bquote = "["; equote = "]";
  100|      0|    }
  101|       |
  102|  1.13k|    if (flags & WITH_PORT) {
  ------------------
  |  Branch (102:9): [True: 795, False: 341]
  ------------------
  103|    795|        pj_ansi_snprintf(port, sizeof(port), ":%d",
  ------------------
  |  |  114|    795|#define pj_ansi_snprintf        snprintf
  ------------------
  104|    795|                         pj_sockaddr_get_port(addr));
  105|    795|    } else {
  106|    341|        port[0] = '\0';
  107|    341|    }
  108|       |
  109|  1.13k|    pj_ansi_snprintf(buf, size, "%s%s%s%s",
  ------------------
  |  |  114|  1.13k|#define pj_ansi_snprintf        snprintf
  ------------------
  110|  1.13k|                     bquote, txt, equote, port);
  111|       |
  112|  1.13k|    return buf;
  113|  1.13k|}
pj_sockaddr_in_set_str_addr:
  124|    844|{
  125|    844|    PJ_CHECK_STACK();
  126|       |
  127|    844|    PJ_ASSERT_RETURN(!str_addr || str_addr->slen < PJ_MAX_HOSTNAME, 
  ------------------
  |  |   97|    844|            do { \
  |  |   98|    844|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 844, False: 0]
  |  |  |  Branch (98:23): [True: 0, False: 0]
  |  |  ------------------
  |  |   99|    844|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 844]
  |  |  ------------------
  ------------------
  |  Branch (127:5): [True: 0, False: 0]
  |  Branch (127:5): [True: 0, False: 0]
  |  Branch (127:5): [True: 0, False: 0]
  |  Branch (127:5): [True: 0, False: 0]
  ------------------
  128|    844|                     (addr->sin_addr.s_addr=PJ_INADDR_NONE, PJ_EINVAL));
  129|       |
  130|    844|    PJ_SOCKADDR_RESET_LEN(addr);
  131|    844|    addr->sin_family = PJ_AF_INET;
  132|    844|    pj_bzero(addr->sin_zero_pad, sizeof(addr->sin_zero_pad));
  133|       |
  134|    844|    if (str_addr && str_addr->slen) {
  ------------------
  |  Branch (134:9): [True: 0, False: 844]
  |  Branch (134:21): [True: 0, False: 0]
  ------------------
  135|      0|        addr->sin_addr = pj_inet_addr(str_addr);
  136|      0|        if (addr->sin_addr.s_addr == PJ_INADDR_NONE) {
  ------------------
  |  |  472|      0|#define PJ_INADDR_NONE      ((pj_uint32_t)0xffffffff)
  ------------------
  |  Branch (136:13): [True: 0, False: 0]
  ------------------
  137|      0|            pj_addrinfo ai;
  138|      0|            unsigned count = 1;
  139|      0|            pj_status_t status;
  140|       |
  141|      0|            status = pj_getaddrinfo(pj_AF_INET(), str_addr, &count, &ai);
  ------------------
  |  |  113|      0|#   define pj_AF_INET()     PJ_AF_INET
  ------------------
  142|      0|            if (status==PJ_SUCCESS) {
  ------------------
  |  Branch (142:17): [True: 0, False: 0]
  ------------------
  143|      0|                pj_memcpy(&addr->sin_addr, &ai.ai_addr.ipv4.sin_addr,
  144|      0|                          sizeof(addr->sin_addr));
  145|      0|            } else {
  146|      0|                return status;
  147|      0|            }
  148|      0|        }
  149|       |
  150|    844|    } else {
  151|    844|        addr->sin_addr.s_addr = 0;
  152|    844|    }
  153|       |
  154|    844|    return PJ_SUCCESS;
  155|    844|}
pj_sockaddr_set_str_addr:
  161|    608|{
  162|    608|    pj_status_t status;
  163|       |
  164|    608|    if (af == PJ_AF_INET) {
  ------------------
  |  Branch (164:9): [True: 0, False: 608]
  ------------------
  165|      0|        return pj_sockaddr_in_set_str_addr(&addr->ipv4, str_addr);
  166|      0|    }
  167|       |
  168|    608|    PJ_ASSERT_RETURN(af==PJ_AF_INET6, PJ_EAFNOTSUP);
  ------------------
  |  |   97|    608|            do { \
  |  |   98|    608|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 608]
  |  |  ------------------
  |  |   99|    608|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 608]
  |  |  ------------------
  ------------------
  |  Branch (168:5): [True: 0, False: 0]
  |  Branch (168:5): [True: 0, False: 0]
  ------------------
  169|       |
  170|       |    /* IPv6 specific */
  171|       |
  172|    608|    addr->ipv6.sin6_family = PJ_AF_INET6;
  173|    608|    PJ_SOCKADDR_RESET_LEN(addr);
  174|       |
  175|    608|    if (str_addr && str_addr->slen) {
  ------------------
  |  Branch (175:9): [True: 0, False: 608]
  |  Branch (175:21): [True: 0, False: 0]
  ------------------
  176|       |#if defined(PJ_SOCKADDR_USE_GETADDRINFO) && PJ_SOCKADDR_USE_GETADDRINFO!=0
  177|       |        if (1) {
  178|       |#else
  179|      0|        status = pj_inet_pton(PJ_AF_INET6, str_addr, &addr->ipv6.sin6_addr);
  180|      0|        if (status != PJ_SUCCESS) {
  ------------------
  |  Branch (180:13): [True: 0, False: 0]
  ------------------
  181|      0|#endif
  182|      0|            pj_addrinfo ai;
  183|      0|            unsigned count = 1;
  184|       |
  185|      0|            status = pj_getaddrinfo(PJ_AF_INET6, str_addr, &count, &ai);
  186|      0|            if (status==PJ_SUCCESS) {
  ------------------
  |  Branch (186:17): [True: 0, False: 0]
  ------------------
  187|      0|                pj_memcpy(&addr->ipv6.sin6_addr, &ai.ai_addr.ipv6.sin6_addr,
  188|      0|                          sizeof(addr->ipv6.sin6_addr));
  189|      0|                addr->ipv6.sin6_scope_id = ai.ai_addr.ipv6.sin6_scope_id;
  190|      0|            }
  191|      0|        }
  192|    608|    } else {
  193|    608|        status = PJ_SUCCESS;
  194|    608|    }
  195|       |
  196|    608|    return status;
  197|    608|}
pj_sockaddr_in_init:
  208|    844|{
  209|    844|    PJ_ASSERT_RETURN(addr, PJ_EINVAL);
  ------------------
  |  |   97|    844|            do { \
  |  |   98|    844|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 844]
  |  |  ------------------
  |  |   99|    844|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 844]
  |  |  ------------------
  ------------------
  |  Branch (209:5): [True: 0, False: 0]
  |  Branch (209:5): [True: 0, False: 0]
  ------------------
  210|       |
  211|    844|    PJ_SOCKADDR_RESET_LEN(addr);
  212|    844|    addr->sin_family = PJ_AF_INET;
  213|    844|    pj_bzero(addr->sin_zero_pad, sizeof(addr->sin_zero_pad));
  214|    844|    pj_sockaddr_in_set_port(addr, port);
  215|    844|    return pj_sockaddr_in_set_str_addr(addr, str_addr);
  216|    844|}
pj_sockaddr_init:
  225|  1.45k|{
  226|  1.45k|    pj_status_t status;
  227|       |
  228|  1.45k|    if (af == PJ_AF_INET) {
  ------------------
  |  Branch (228:9): [True: 844, False: 608]
  ------------------
  229|    844|        return pj_sockaddr_in_init(&addr->ipv4, cp, port);
  230|    844|    }
  231|       |
  232|       |    /* IPv6 specific */
  233|    608|    PJ_ASSERT_RETURN(af==PJ_AF_INET6, PJ_EAFNOTSUP);
  ------------------
  |  |   97|    608|            do { \
  |  |   98|    608|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 608]
  |  |  ------------------
  |  |   99|    608|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 608]
  |  |  ------------------
  ------------------
  |  Branch (233:5): [True: 0, False: 0]
  |  Branch (233:5): [True: 0, False: 0]
  ------------------
  234|       |
  235|    608|    pj_bzero(addr, sizeof(pj_sockaddr_in6));
  236|    608|    addr->addr.sa_family = PJ_AF_INET6;
  237|       |    
  238|    608|    status = pj_sockaddr_set_str_addr(af, addr, cp);
  239|    608|    if (status != PJ_SUCCESS)
  ------------------
  |  Branch (239:9): [True: 0, False: 608]
  ------------------
  240|      0|        return status;
  241|       |
  242|    608|    addr->ipv6.sin6_port = pj_htons(port);
  243|    608|    return PJ_SUCCESS;
  244|    608|}
pj_sockaddr_cmp:
  251|  2.26k|{
  252|  2.26k|    const pj_sockaddr *a1 = (const pj_sockaddr*) addr1;
  253|  2.26k|    const pj_sockaddr *a2 = (const pj_sockaddr*) addr2;
  254|  2.26k|    int port1, port2;
  255|  2.26k|    int result;
  256|       |
  257|       |    /* Compare address family */
  258|  2.26k|    if (a1->addr.sa_family < a2->addr.sa_family)
  ------------------
  |  Branch (258:9): [True: 0, False: 2.26k]
  ------------------
  259|      0|        return -1;
  260|  2.26k|    else if (a1->addr.sa_family > a2->addr.sa_family)
  ------------------
  |  Branch (260:14): [True: 0, False: 2.26k]
  ------------------
  261|      0|        return 1;
  262|       |
  263|       |    /* Compare addresses */
  264|  2.26k|    result = pj_memcmp(pj_sockaddr_get_addr(a1),
  265|  2.26k|                       pj_sockaddr_get_addr(a2),
  266|  2.26k|                       pj_sockaddr_get_addr_len(a1));
  267|  2.26k|    if (result != 0)
  ------------------
  |  Branch (267:9): [True: 0, False: 2.26k]
  ------------------
  268|      0|        return result;
  269|       |
  270|       |    /* Compare port number */
  271|  2.26k|    port1 = pj_sockaddr_get_port(a1);
  272|  2.26k|    port2 = pj_sockaddr_get_port(a2);
  273|       |
  274|  2.26k|    if (port1 < port2)
  ------------------
  |  Branch (274:9): [True: 0, False: 2.26k]
  ------------------
  275|      0|        return -1;
  276|  2.26k|    else if (port1 > port2)
  ------------------
  |  Branch (276:14): [True: 0, False: 2.26k]
  ------------------
  277|      0|        return 1;
  278|       |
  279|       |    /* TODO:
  280|       |     *  Do we need to compare flow label and scope id in IPv6? 
  281|       |     */
  282|       |    
  283|       |    /* Looks equal */
  284|  2.26k|    return 0;
  285|  2.26k|}
pj_sockaddr_get_addr:
  311|  8.68k|{
  312|  8.68k|    const pj_sockaddr *a = (const pj_sockaddr*)addr;
  313|       |
  314|  8.68k|    PJ_ASSERT_RETURN(a->addr.sa_family == PJ_AF_INET ||
  ------------------
  |  |   97|  8.68k|            do { \
  |  |   98|  9.29k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 8.07k, False: 608]
  |  |  |  Branch (98:23): [True: 608, False: 0]
  |  |  ------------------
  |  |   99|  8.68k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 8.68k]
  |  |  ------------------
  ------------------
  |  Branch (314:5): [True: 0, False: 0]
  |  Branch (314:5): [True: 0, False: 0]
  |  Branch (314:5): [True: 0, False: 0]
  |  Branch (314:5): [True: 0, False: 0]
  ------------------
  315|  8.68k|                     a->addr.sa_family == PJ_AF_INET6, NULL);
  316|       |
  317|  8.68k|    if (a->addr.sa_family == PJ_AF_INET6)
  ------------------
  |  Branch (317:9): [True: 608, False: 8.07k]
  ------------------
  318|    608|        return (void*) &a->ipv6.sin6_addr;
  319|  8.07k|    else
  320|  8.07k|        return (void*) &a->ipv4.sin_addr;
  321|  8.68k|}
pj_sockaddr_has_addr:
  327|  1.02k|{
  328|  1.02k|    const pj_sockaddr *a = (const pj_sockaddr*)addr;
  329|       |
  330|       |    /* It's probably not wise to raise assertion here if
  331|       |     * the address doesn't contain a valid address family, and
  332|       |     * just return PJ_FALSE instead.
  333|       |     * 
  334|       |     * The reason is because application may need to distinguish 
  335|       |     * these three conditions with sockaddr:
  336|       |     *  a) sockaddr is not initialized. This is by convention
  337|       |     *     indicated by sa_family==0.
  338|       |     *  b) sockaddr is initialized with zero address. This is
  339|       |     *     indicated with the address field having zero address.
  340|       |     *  c) sockaddr is initialized with valid address/port.
  341|       |     *
  342|       |     * If we enable this assertion, then application will loose
  343|       |     * the capability to specify condition a), since it will be
  344|       |     * forced to always initialize sockaddr (even with zero address).
  345|       |     * This may break some parts of upper layer libraries.
  346|       |     */
  347|       |    //PJ_ASSERT_RETURN(a->addr.sa_family == PJ_AF_INET ||
  348|       |    //               a->addr.sa_family == PJ_AF_INET6, PJ_FALSE);
  349|       |
  350|  1.02k|    if (a->addr.sa_family!=PJ_AF_INET && a->addr.sa_family!=PJ_AF_INET6) {
  ------------------
  |  Branch (350:9): [True: 341, False: 682]
  |  Branch (350:42): [True: 341, False: 0]
  ------------------
  351|    341|        return PJ_FALSE;
  352|    682|    } else if (a->addr.sa_family == PJ_AF_INET6) {
  ------------------
  |  Branch (352:16): [True: 0, False: 682]
  ------------------
  353|      0|        pj_uint8_t zero[24];
  354|      0|        pj_bzero(zero, sizeof(zero));
  355|      0|        return pj_memcmp(a->ipv6.sin6_addr.s6_addr, zero, 
  356|      0|                         sizeof(pj_in6_addr)) != 0;
  357|      0|    } else
  358|    682|        return a->ipv4.sin_addr.s_addr != PJ_INADDR_ANY;
  ------------------
  |  |  469|    682|#define PJ_INADDR_ANY       ((pj_uint32_t)0)
  ------------------
  359|  1.02k|}
pj_sockaddr_get_port:
  365|  5.99k|{
  366|  5.99k|    const pj_sockaddr *a = (const pj_sockaddr*) addr;
  367|       |
  368|  5.99k|    PJ_ASSERT_RETURN(a->addr.sa_family == PJ_AF_INET ||
  ------------------
  |  |   97|  5.99k|            do { \
  |  |   98|  5.99k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 5.99k, False: 0]
  |  |  |  Branch (98:23): [True: 0, False: 0]
  |  |  ------------------
  |  |   99|  5.99k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 5.99k]
  |  |  ------------------
  ------------------
  |  Branch (368:5): [True: 0, False: 0]
  |  Branch (368:5): [True: 0, False: 0]
  |  Branch (368:5): [True: 0, False: 0]
  |  Branch (368:5): [True: 0, False: 0]
  ------------------
  369|  5.99k|                     a->addr.sa_family == PJ_AF_INET6, (pj_uint16_t)0xFFFF);
  370|       |
  371|  5.99k|    return pj_ntohs((pj_uint16_t)(a->addr.sa_family == PJ_AF_INET6 ?
  ------------------
  |  Branch (371:35): [True: 0, False: 5.99k]
  ------------------
  372|  5.99k|                                    a->ipv6.sin6_port : a->ipv4.sin_port));
  373|  5.99k|}
pj_sockaddr_get_addr_len:
  379|  5.76k|{
  380|  5.76k|    const pj_sockaddr *a = (const pj_sockaddr*) addr;
  381|  5.76k|    PJ_ASSERT_RETURN(a->addr.sa_family == PJ_AF_INET ||
  ------------------
  |  |   97|  5.76k|            do { \
  |  |   98|  5.76k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 5.76k, False: 0]
  |  |  |  Branch (98:23): [True: 0, False: 0]
  |  |  ------------------
  |  |   99|  5.76k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 5.76k]
  |  |  ------------------
  ------------------
  |  Branch (381:5): [True: 0, False: 0]
  |  Branch (381:5): [True: 0, False: 0]
  |  Branch (381:5): [True: 0, False: 0]
  |  Branch (381:5): [True: 0, False: 0]
  ------------------
  382|  5.76k|                     a->addr.sa_family == PJ_AF_INET6, 0);
  383|  5.76k|    return a->addr.sa_family == PJ_AF_INET6 ?
  ------------------
  |  Branch (383:12): [True: 0, False: 5.76k]
  ------------------
  384|  5.76k|            sizeof(pj_in6_addr) : sizeof(pj_in_addr);
  385|  5.76k|}
pj_sockaddr_get_len:
  391|  3.41k|{
  392|  3.41k|    const pj_sockaddr *a = (const pj_sockaddr*) addr;
  393|  3.41k|    PJ_ASSERT_RETURN(a->addr.sa_family == PJ_AF_INET ||
  ------------------
  |  |   97|  3.41k|            do { \
  |  |   98|  3.41k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 3.41k, False: 1]
  |  |  |  Branch (98:23): [True: 1, False: 0]
  |  |  ------------------
  |  |   99|  3.41k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 3.41k]
  |  |  ------------------
  ------------------
  |  Branch (393:5): [True: 0, False: 0]
  |  Branch (393:5): [True: 0, False: 0]
  |  Branch (393:5): [True: 0, False: 0]
  |  Branch (393:5): [True: 0, False: 0]
  ------------------
  394|  3.41k|                     a->addr.sa_family == PJ_AF_INET6, 0);
  395|  3.41k|    return a->addr.sa_family == PJ_AF_INET6 ?
  ------------------
  |  Branch (395:12): [True: 1, False: 3.41k]
  ------------------
  396|  3.41k|            sizeof(pj_sockaddr_in6) : sizeof(pj_sockaddr_in);
  397|  3.41k|}
pj_sockaddr_copy_addr:
  404|    682|{
  405|       |    /* Destination sockaddr might not be initialized */
  406|    682|    const char *srcbuf = (char*)pj_sockaddr_get_addr(src);
  407|    682|    char *dstbuf = ((char*)dst) + (srcbuf - (char*)src);
  408|    682|    pj_memcpy(dstbuf, srcbuf, pj_sockaddr_get_addr_len(src));
  409|    682|}
pj_sockaddr_cp:
  415|  1.70k|{
  416|  1.70k|    pj_memcpy(dst, src, pj_sockaddr_get_len(src));
  417|  1.70k|}
pj_sockaddr_in_set_port:
  458|    844|{
  459|    844|    addr->sin_port = pj_htons(hostport);
  460|    844|}
pj_sockaddr_set_port:
  467|  3.37k|{
  468|  3.37k|    int af = addr->addr.sa_family;
  469|       |
  470|  3.37k|    PJ_ASSERT_RETURN(af==PJ_AF_INET || af==PJ_AF_INET6, PJ_EINVAL);
  ------------------
  |  |   97|  3.37k|            do { \
  |  |   98|  3.97k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 2.76k, False: 608]
  |  |  |  Branch (98:23): [True: 608, False: 0]
  |  |  ------------------
  |  |   99|  3.37k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 3.37k]
  |  |  ------------------
  ------------------
  |  Branch (470:5): [True: 0, False: 0]
  |  Branch (470:5): [True: 0, False: 0]
  |  Branch (470:5): [True: 0, False: 0]
  |  Branch (470:5): [True: 0, False: 0]
  ------------------
  471|       |
  472|  3.37k|    if (af == PJ_AF_INET6)
  ------------------
  |  Branch (472:9): [True: 608, False: 2.76k]
  ------------------
  473|    608|        addr->ipv6.sin6_port = pj_htons(hostport);
  474|  2.76k|    else
  475|  2.76k|        addr->ipv4.sin_port = pj_htons(hostport);
  476|       |
  477|  3.37k|    return PJ_SUCCESS;
  478|  3.37k|}
pj_gethostip:
  737|    341|{
  738|    341|    unsigned i, count, cand_cnt;
  739|    341|    enum {
  740|    341|        CAND_CNT = 8,
  741|       |
  742|       |        /* Weighting to be applied to found addresses */
  743|    341|        WEIGHT_HOSTNAME = 1,    /* hostname IP is not always valid! */
  744|    341|        WEIGHT_DEF_ROUTE = 2,
  745|    341|        WEIGHT_INTERFACE = 1,
  746|    341|        WEIGHT_LOOPBACK = -5,
  747|    341|        WEIGHT_LINK_LOCAL = -4,
  748|    341|        WEIGHT_DISABLED = -50,
  749|       |
  750|    341|        MIN_WEIGHT = WEIGHT_DISABLED+1  /* minimum weight to use */
  751|    341|    };
  752|       |    /* candidates: */
  753|    341|    pj_sockaddr cand_addr[CAND_CNT];
  754|    341|    int         cand_weight[CAND_CNT];
  755|    341|    int         selected_cand;
  756|    341|    char        strip[PJ_INET6_ADDRSTRLEN+10];
  757|       |    /* Special IPv4 addresses. */
  758|    341|    struct spec_ipv4_t
  759|    341|    {
  760|    341|        pj_uint32_t addr;
  761|    341|        pj_uint32_t mask;
  762|    341|        int         weight;
  763|    341|    } spec_ipv4[] =
  764|    341|    {
  765|       |        /* 127.0.0.0/8, loopback addr will be used if there is no other
  766|       |         * addresses.
  767|       |         */
  768|    341|        { 0x7f000000, 0xFF000000, WEIGHT_LOOPBACK },
  769|       |
  770|       |        /* 0.0.0.0/8, special IP that doesn't seem to be practically useful */
  771|    341|        { 0x00000000, 0xFF000000, WEIGHT_DISABLED },
  772|       |
  773|       |        /* 169.254.0.0/16, a zeroconf/link-local address, which has higher
  774|       |         * priority than loopback and will be used if there is no other
  775|       |         * valid addresses.
  776|       |         */
  777|    341|        { 0xa9fe0000, 0xFFFF0000, WEIGHT_LINK_LOCAL }
  778|    341|    };
  779|       |    /* Special IPv6 addresses */
  780|    341|    struct spec_ipv6_t
  781|    341|    {
  782|    341|        pj_uint8_t addr[16];
  783|    341|        pj_uint8_t mask[16];
  784|    341|        int        weight;
  785|    341|    } spec_ipv6[] =
  786|    341|    {
  787|       |        /* Loopback address, ::1/128 */
  788|    341|        { {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
  789|    341|          {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
  790|    341|           0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},
  791|    341|          WEIGHT_LOOPBACK
  792|    341|        },
  793|       |
  794|       |        /* Link local, fe80::/10 */
  795|    341|        { {0xfe,0x80,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
  796|    341|          {0xff,0xc0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
  797|    341|          WEIGHT_LINK_LOCAL
  798|    341|        },
  799|       |
  800|       |        /* Disabled, ::/128 */
  801|    341|        { {0x0,0x0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
  802|    341|        { 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
  803|    341|          0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},
  804|    341|          WEIGHT_DISABLED
  805|    341|        }
  806|    341|    };
  807|    341|    pj_addrinfo ai;
  808|    341|    pj_status_t status;
  809|       |
  810|       |    /* May not be used if TRACE_ is disabled */
  811|    341|    PJ_UNUSED_ARG(strip);
  ------------------
  |  | 1537|    341|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
  812|       |
  813|       |#ifdef _MSC_VER
  814|       |    /* Get rid of "uninitialized he variable" with MS compilers */
  815|       |    pj_bzero(&ai, sizeof(ai));
  816|       |#endif
  817|       |
  818|    341|    cand_cnt = 0;
  819|    341|    pj_bzero(cand_addr, sizeof(cand_addr));
  820|    341|    pj_bzero(cand_weight, sizeof(cand_weight));
  821|  3.06k|    for (i=0; i<PJ_ARRAY_SIZE(cand_addr); ++i) {
  ------------------
  |  |  315|  3.06k|#define PJ_ARRAY_SIZE(a)    (sizeof(a)/sizeof(a[0]))
  ------------------
  |  Branch (821:15): [True: 2.72k, False: 341]
  ------------------
  822|  2.72k|        cand_addr[i].addr.sa_family = (pj_uint16_t)af;
  823|  2.72k|        PJ_SOCKADDR_RESET_LEN(&cand_addr[i]);
  824|  2.72k|    }
  825|       |
  826|    341|    addr->addr.sa_family = (pj_uint16_t)af;
  827|    341|    PJ_SOCKADDR_RESET_LEN(addr);
  828|       |
  829|    341|#if !defined(PJ_GETHOSTIP_DISABLE_LOCAL_RESOLUTION) || \
  830|    341|    PJ_GETHOSTIP_DISABLE_LOCAL_RESOLUTION == 0
  831|       |    /* Get hostname's IP address */
  832|    341|    {
  833|    341|        const pj_str_t *hostname = pj_gethostname();
  834|    341|        count = 1;
  835|       |
  836|    341|        if (hostname->slen > 0)
  ------------------
  |  Branch (836:13): [True: 341, False: 0]
  ------------------
  837|    341|            status = pj_getaddrinfo(af, hostname, &count, &ai);
  838|      0|        else
  839|      0|            status = PJ_ERESOLVE;
  ------------------
  |  |  464|      0|#define PJ_ERESOLVE         (PJ_ERRNO_START_STATUS + 18)/* 70018 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  840|       |
  841|    341|        if (status == PJ_SUCCESS) {
  ------------------
  |  Branch (841:13): [True: 341, False: 0]
  ------------------
  842|    341|            pj_assert(ai.ai_addr.addr.sa_family == (pj_uint16_t)af);
  ------------------
  |  |   65|    341|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (842:13): [True: 0, False: 341]
  |  Branch (842:13): [True: 341, False: 0]
  ------------------
  843|    341|            pj_sockaddr_copy_addr(&cand_addr[cand_cnt], &ai.ai_addr);
  844|    341|            pj_sockaddr_set_port(&cand_addr[cand_cnt], 0);
  845|    341|            cand_weight[cand_cnt] += WEIGHT_HOSTNAME;
  846|    341|            ++cand_cnt;
  847|       |
  848|    341|            TRACE_((THIS_FILE, "hostname IP is %s",
  849|    341|                    pj_sockaddr_print(&ai.ai_addr, strip, sizeof(strip), 3)));
  850|    341|        }
  851|    341|    }
  852|       |#else
  853|       |    PJ_UNUSED_ARG(ai);
  854|       |#endif
  855|       |
  856|       |    /* Get default interface (interface for default route) */
  857|    341|    if (cand_cnt < PJ_ARRAY_SIZE(cand_addr)) {
  ------------------
  |  |  315|    341|#define PJ_ARRAY_SIZE(a)    (sizeof(a)/sizeof(a[0]))
  ------------------
  |  Branch (857:9): [True: 341, False: 0]
  ------------------
  858|    341|        status = pj_getdefaultipinterface(af, addr);
  859|    341|        if (status == PJ_SUCCESS) {
  ------------------
  |  Branch (859:13): [True: 341, False: 0]
  ------------------
  860|    341|            TRACE_((THIS_FILE, "default IP is %s",
  861|    341|                    pj_sockaddr_print(addr, strip, sizeof(strip), 3)));
  862|       |
  863|    341|            pj_sockaddr_set_port(addr, 0);
  864|    341|            for (i=0; i<cand_cnt; ++i) {
  ------------------
  |  Branch (864:23): [True: 341, False: 0]
  ------------------
  865|    341|                if (pj_sockaddr_cmp(&cand_addr[i], addr)==0)
  ------------------
  |  Branch (865:21): [True: 341, False: 0]
  ------------------
  866|    341|                    break;
  867|    341|            }
  868|       |
  869|    341|            cand_weight[i] += WEIGHT_DEF_ROUTE;
  870|    341|            if (i >= cand_cnt) {
  ------------------
  |  Branch (870:17): [True: 0, False: 341]
  ------------------
  871|      0|                pj_sockaddr_copy_addr(&cand_addr[i], addr);
  872|      0|                ++cand_cnt;
  873|      0|            }
  874|    341|        }
  875|    341|    }
  876|       |
  877|       |
  878|       |    /* Enumerate IP interfaces */
  879|    341|    if (cand_cnt < PJ_ARRAY_SIZE(cand_addr)) {
  ------------------
  |  |  315|    341|#define PJ_ARRAY_SIZE(a)    (sizeof(a)/sizeof(a[0]))
  ------------------
  |  Branch (879:9): [True: 341, False: 0]
  ------------------
  880|    341|        unsigned start_if = cand_cnt;
  881|    341|        count = PJ_ARRAY_SIZE(cand_addr) - start_if;
  ------------------
  |  |  315|    341|#define PJ_ARRAY_SIZE(a)    (sizeof(a)/sizeof(a[0]))
  ------------------
  882|       |
  883|    341|        status = pj_enum_ip_interface(af, &count, &cand_addr[start_if]);
  884|    341|        if (status == PJ_SUCCESS && count) {
  ------------------
  |  Branch (884:13): [True: 341, False: 0]
  |  Branch (884:37): [True: 341, False: 0]
  ------------------
  885|       |            /* Clear the port number */
  886|    682|            for (i=0; i<count; ++i)
  ------------------
  |  Branch (886:23): [True: 341, False: 341]
  ------------------
  887|    341|                pj_sockaddr_set_port(&cand_addr[start_if+i], 0);
  888|       |
  889|       |            /* For each candidate that we found so far (that is the hostname
  890|       |             * address and default interface address, check if they're found
  891|       |             * in the interface list. If found, add the weight, and if not,
  892|       |             * decrease the weight.
  893|       |             */
  894|    682|            for (i=0; i<cand_cnt; ++i) {
  ------------------
  |  Branch (894:23): [True: 341, False: 341]
  ------------------
  895|    341|                unsigned j;
  896|    341|                for (j=0; j<count; ++j) {
  ------------------
  |  Branch (896:27): [True: 341, False: 0]
  ------------------
  897|    341|                    if (pj_sockaddr_cmp(&cand_addr[i], 
  ------------------
  |  Branch (897:25): [True: 341, False: 0]
  ------------------
  898|    341|                                        &cand_addr[start_if+j])==0)
  899|    341|                        break;
  900|    341|                }
  901|       |
  902|    341|                if (j == count) {
  ------------------
  |  Branch (902:21): [True: 0, False: 341]
  ------------------
  903|       |                    /* Not found */
  904|      0|                    cand_weight[i] -= WEIGHT_INTERFACE;
  905|    341|                } else {
  906|    341|                    cand_weight[i] += WEIGHT_INTERFACE;
  907|    341|                }
  908|    341|            }
  909|       |
  910|       |            /* Add remaining interface to candidate list. */
  911|    682|            for (i=0; i<count; ++i) {
  ------------------
  |  Branch (911:23): [True: 341, False: 341]
  ------------------
  912|    341|                unsigned j;
  913|    341|                for (j=0; j<cand_cnt; ++j) {
  ------------------
  |  Branch (913:27): [True: 341, False: 0]
  ------------------
  914|    341|                    if (pj_sockaddr_cmp(&cand_addr[start_if+i], 
  ------------------
  |  Branch (914:25): [True: 341, False: 0]
  ------------------
  915|    341|                                        &cand_addr[j])==0)
  916|    341|                        break;
  917|    341|                }
  918|       |
  919|    341|                if (j == cand_cnt) {
  ------------------
  |  Branch (919:21): [True: 0, False: 341]
  ------------------
  920|      0|                    if (cand_cnt != (start_if + i)) {
  ------------------
  |  Branch (920:25): [True: 0, False: 0]
  ------------------
  921|      0|                        pj_sockaddr_copy_addr(&cand_addr[cand_cnt],
  922|      0|                                              &cand_addr[start_if + i]);
  923|      0|                    }
  924|      0|                    cand_weight[cand_cnt] += WEIGHT_INTERFACE;
  925|      0|                    ++cand_cnt;
  926|      0|                }
  927|    341|            }
  928|    341|        }
  929|    341|    }
  930|       |
  931|       |    /* Apply weight adjustment for special IPv4/IPv6 addresses
  932|       |     * See https://github.com/pjsip/pjproject/issues/1046
  933|       |     */
  934|    341|    if (af == PJ_AF_INET) {
  ------------------
  |  Branch (934:9): [True: 341, False: 0]
  ------------------
  935|    682|        for (i=0; i<cand_cnt; ++i) {
  ------------------
  |  Branch (935:19): [True: 341, False: 341]
  ------------------
  936|    341|            unsigned j;
  937|  1.36k|            for (j=0; j<PJ_ARRAY_SIZE(spec_ipv4); ++j) {
  ------------------
  |  |  315|  1.36k|#define PJ_ARRAY_SIZE(a)    (sizeof(a)/sizeof(a[0]))
  ------------------
  |  Branch (937:23): [True: 1.02k, False: 341]
  ------------------
  938|  1.02k|                    pj_uint32_t a = pj_ntohl(cand_addr[i].ipv4.sin_addr.s_addr);
  939|  1.02k|                    pj_uint32_t pa = spec_ipv4[j].addr;
  940|  1.02k|                    pj_uint32_t pm = spec_ipv4[j].mask;
  941|       |
  942|  1.02k|                    if ((a & pm) == pa) {
  ------------------
  |  Branch (942:25): [True: 0, False: 1.02k]
  ------------------
  943|      0|                        cand_weight[i] += spec_ipv4[j].weight;
  944|      0|                        break;
  945|      0|                    }
  946|  1.02k|            }
  947|    341|        }
  948|    341|    } else if (af == PJ_AF_INET6) {
  ------------------
  |  Branch (948:16): [True: 0, False: 0]
  ------------------
  949|      0|        for (i=0; i<PJ_ARRAY_SIZE(spec_ipv6); ++i) {
  ------------------
  |  |  315|      0|#define PJ_ARRAY_SIZE(a)    (sizeof(a)/sizeof(a[0]))
  ------------------
  |  Branch (949:19): [True: 0, False: 0]
  ------------------
  950|      0|                unsigned j;
  951|      0|                for (j=0; j<cand_cnt; ++j) {
  ------------------
  |  Branch (951:27): [True: 0, False: 0]
  ------------------
  952|      0|                    pj_uint8_t *a = cand_addr[j].ipv6.sin6_addr.s6_addr;
  953|      0|                    pj_uint8_t am[16];
  954|      0|                    pj_uint8_t *pa = spec_ipv6[i].addr;
  955|      0|                    pj_uint8_t *pm = spec_ipv6[i].mask;
  956|      0|                    unsigned k;
  957|       |
  958|      0|                    for (k=0; k<16; ++k) {
  ------------------
  |  Branch (958:31): [True: 0, False: 0]
  ------------------
  959|      0|                        am[k] = (pj_uint8_t)((a[k] & pm[k]) & 0xFF);
  960|      0|                    }
  961|       |
  962|      0|                    if (pj_memcmp(am, pa, 16)==0) {
  ------------------
  |  Branch (962:25): [True: 0, False: 0]
  ------------------
  963|      0|                        cand_weight[j] += spec_ipv6[i].weight;
  964|      0|                    }
  965|      0|                }
  966|      0|        }
  967|      0|    } else {
  968|      0|        return PJ_EAFNOTSUP;
  ------------------
  |  |  484|      0|#define PJ_EAFNOTSUP        (PJ_ERRNO_START_STATUS + 22)/* 70022 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  969|      0|    }
  970|       |
  971|       |    /* Enumerate candidates to get the best IP address to choose */
  972|    341|    selected_cand = -1;
  973|    682|    for (i=0; i<cand_cnt; ++i) {
  ------------------
  |  Branch (973:15): [True: 341, False: 341]
  ------------------
  974|    341|        TRACE_((THIS_FILE, "Checking candidate IP %s, weight=%d",
  975|    341|                pj_sockaddr_print(&cand_addr[i], strip, sizeof(strip), 3),
  976|    341|                cand_weight[i]));
  977|       |
  978|    341|        if (cand_weight[i] < MIN_WEIGHT) {
  ------------------
  |  Branch (978:13): [True: 0, False: 341]
  ------------------
  979|      0|            continue;
  980|      0|        }
  981|       |
  982|    341|        if (selected_cand == -1)
  ------------------
  |  Branch (982:13): [True: 341, False: 0]
  ------------------
  983|    341|            selected_cand = i;
  984|      0|        else if (cand_weight[i] > cand_weight[selected_cand])
  ------------------
  |  Branch (984:18): [True: 0, False: 0]
  ------------------
  985|      0|            selected_cand = i;
  986|    341|    }
  987|       |
  988|       |    /* If else fails, returns loopback interface as the last resort */
  989|    341|    if (selected_cand == -1) {
  ------------------
  |  Branch (989:9): [True: 0, False: 341]
  ------------------
  990|      0|        if (af==PJ_AF_INET) {
  ------------------
  |  Branch (990:13): [True: 0, False: 0]
  ------------------
  991|      0|            addr->ipv4.sin_addr.s_addr = pj_htonl (0x7f000001);
  992|      0|        } else {
  993|      0|            pj_in6_addr *s6_addr_;
  994|       |
  995|      0|            s6_addr_ = (pj_in6_addr*) pj_sockaddr_get_addr(addr);
  996|      0|            pj_bzero(s6_addr_, sizeof(pj_in6_addr));
  997|      0|            s6_addr_->s6_addr[15] = 1;
  998|      0|        }
  999|      0|        TRACE_((THIS_FILE, "Loopback IP %s returned",
 1000|      0|                pj_sockaddr_print(addr, strip, sizeof(strip), 3)));
 1001|    341|    } else {
 1002|    341|        pj_sockaddr_copy_addr(addr, &cand_addr[selected_cand]);
 1003|    341|        TRACE_((THIS_FILE, "Candidate %s selected",
 1004|    341|                pj_sockaddr_print(addr, strip, sizeof(strip), 3)));
 1005|    341|    }
 1006|       |
 1007|    341|    return PJ_SUCCESS;
 1008|    341|}
pj_getipinterface:
 1016|    341|{
 1017|    341|    pj_sockaddr dst_addr;
 1018|    341|    pj_sock_t fd;
 1019|    341|    int len;
 1020|    341|    pj_uint8_t zero[64];
 1021|    341|    pj_status_t status;
 1022|       |
 1023|    341|    pj_sockaddr_init(af, &dst_addr, NULL, 53);
 1024|    341|    status = pj_inet_pton(af, dst, pj_sockaddr_get_addr(&dst_addr));
 1025|    341|    if (status != PJ_SUCCESS) {
  ------------------
  |  Branch (1025:9): [True: 0, False: 341]
  ------------------
 1026|       |        /* "dst" is not an IP address. */
 1027|      0|        if (allow_resolve) {
  ------------------
  |  Branch (1027:13): [True: 0, False: 0]
  ------------------
 1028|      0|            status = pj_sockaddr_init(af, &dst_addr, dst, 53);
 1029|      0|        } else {
 1030|      0|            pj_str_t cp;
 1031|       |
 1032|      0|            if (af == PJ_AF_INET) {
  ------------------
  |  Branch (1032:17): [True: 0, False: 0]
  ------------------
 1033|      0|                cp = pj_str("1.1.1.1");
 1034|      0|            } else {
 1035|      0|                cp = pj_str("1::1");
 1036|      0|            }
 1037|      0|            status = pj_sockaddr_init(af, &dst_addr, &cp, 53);
 1038|      0|        }
 1039|       |
 1040|      0|        if (status != PJ_SUCCESS)
  ------------------
  |  Branch (1040:13): [True: 0, False: 0]
  ------------------
 1041|      0|            return status;
 1042|      0|    }
 1043|       |
 1044|       |    /* Create UDP socket and connect() to the destination IP */
 1045|    341|    status = pj_sock_socket(af, pj_SOCK_DGRAM(), 0, &fd);
  ------------------
  |  |  167|    341|#   define pj_SOCK_DGRAM()  PJ_SOCK_DGRAM
  ------------------
 1046|    341|    if (status != PJ_SUCCESS) {
  ------------------
  |  Branch (1046:9): [True: 0, False: 341]
  ------------------
 1047|      0|        return status;
 1048|      0|    }
 1049|       |
 1050|    341|    status = pj_sock_connect(fd, &dst_addr, pj_sockaddr_get_len(&dst_addr));
 1051|    341|    if (status != PJ_SUCCESS) {
  ------------------
  |  Branch (1051:9): [True: 0, False: 341]
  ------------------
 1052|      0|        pj_sock_close(fd);
 1053|      0|        return status;
 1054|      0|    }
 1055|       |
 1056|    341|    len = sizeof(*itf_addr);
 1057|    341|    status = pj_sock_getsockname(fd, itf_addr, &len);
 1058|    341|    if (status != PJ_SUCCESS) {
  ------------------
  |  Branch (1058:9): [True: 0, False: 341]
  ------------------
 1059|      0|        pj_sock_close(fd);
 1060|      0|        return status;
 1061|      0|    }
 1062|       |
 1063|    341|    pj_sock_close(fd);
 1064|       |
 1065|       |    /* Check that the address returned is not zero */
 1066|    341|    pj_bzero(zero, sizeof(zero));
 1067|    341|    if (pj_memcmp(pj_sockaddr_get_addr(itf_addr), zero,
  ------------------
  |  Branch (1067:9): [True: 0, False: 341]
  ------------------
 1068|    341|                  pj_sockaddr_get_addr_len(itf_addr))==0)
 1069|      0|    {
 1070|      0|        return PJ_ENOTFOUND;
  ------------------
  |  |  403|      0|#define PJ_ENOTFOUND        (PJ_ERRNO_START_STATUS + 6) /* 70006 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1071|      0|    }
 1072|       |
 1073|       |#if defined(PJ_HAS_IPV6) && PJ_HAS_IPV6
 1074|       |    /* Check if the local address is link-local but the destination
 1075|       |     * is not link-local.
 1076|       |     */
 1077|       |    if (af == pj_AF_INET6() &&
 1078|       |        IN6_IS_ADDR_LINKLOCAL(&itf_addr->ipv6.sin6_addr) &&
 1079|       |        (!IN6_IS_ADDR_LINKLOCAL(&dst_addr.ipv6.sin6_addr)))
 1080|       |    {
 1081|       |        TRACE_((THIS_FILE, "Local interface address is link-local and "
 1082|       |                           "the destination host is external"));
 1083|       |
 1084|       |        return PJ_ENOTFOUND;
 1085|       |    }
 1086|       |#endif
 1087|       |
 1088|    341|    if (p_dst_addr)
  ------------------
  |  Branch (1088:9): [True: 0, False: 341]
  ------------------
 1089|      0|        *p_dst_addr = dst_addr;
 1090|       |
 1091|    341|    return PJ_SUCCESS;
 1092|    341|}
pj_getdefaultipinterface:
 1096|    341|{
 1097|    341|    pj_str_t cp;
 1098|       |
 1099|    341|    if (af == PJ_AF_INET) {
  ------------------
  |  Branch (1099:9): [True: 341, False: 0]
  ------------------
 1100|    341|        cp = pj_str("1.1.1.1");
 1101|    341|    } else {
 1102|      0|        cp = pj_str("1::1");
 1103|      0|    }
 1104|       |
 1105|       |    return pj_getipinterface(af, &cp, addr, PJ_FALSE, NULL);
 1106|    341|}
pj_sock_bind_random:
 1116|    341|{
 1117|    341|    pj_sockaddr bind_addr;
 1118|    341|    int addr_len;
 1119|    341|    pj_uint16_t base_port;
 1120|    341|    pj_status_t status = PJ_SUCCESS;
 1121|       |
 1122|    341|    PJ_CHECK_STACK();
 1123|       |
 1124|    341|    PJ_ASSERT_RETURN(addr, PJ_EINVAL);
  ------------------
  |  |   97|    341|            do { \
  |  |   98|    341|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 341]
  |  |  ------------------
  |  |   99|    341|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 341]
  |  |  ------------------
  ------------------
  |  Branch (1124:5): [True: 0, False: 0]
  |  Branch (1124:5): [True: 0, False: 0]
  ------------------
 1125|       |
 1126|    341|    pj_sockaddr_cp(&bind_addr, addr);
 1127|    341|    addr_len = pj_sockaddr_get_len(addr);
 1128|    341|    base_port = pj_sockaddr_get_port(addr);
 1129|       |
 1130|    341|    if (base_port == 0 || port_range == 0) {
  ------------------
  |  Branch (1130:9): [True: 341, False: 0]
  |  Branch (1130:27): [True: 0, False: 0]
  ------------------
 1131|    341|        return pj_sock_bind(sockfd, &bind_addr, addr_len);
 1132|    341|    }
 1133|       |
 1134|      0|    for (; max_try; --max_try) {
  ------------------
  |  Branch (1134:12): [True: 0, False: 0]
  ------------------
 1135|      0|        pj_uint16_t port;
 1136|      0|        port = (pj_uint16_t)(base_port + pj_rand() % (port_range + 1));
 1137|      0|        pj_sockaddr_set_port(&bind_addr, port);
 1138|      0|        status = pj_sock_bind(sockfd, &bind_addr, addr_len);
 1139|      0|        if (status == PJ_SUCCESS)
  ------------------
  |  Branch (1139:13): [True: 0, False: 0]
  ------------------
 1140|      0|            break;
 1141|      0|    }
 1142|       |
 1143|      0|    return status;
 1144|    341|}

pj_sock_apply_qos:
  100|    341|{
  101|    341|    pj_status_t qos_type_rc = PJ_SUCCESS,
  102|    341|                qos_params_rc = PJ_SUCCESS;
  103|       |
  104|    341|    if (!log_sender)
  ------------------
  |  Branch (104:9): [True: 0, False: 341]
  ------------------
  105|      0|        log_sender = THIS_FILE;
  ------------------
  |  |   24|      0|#define THIS_FILE   "sock_qos_common.c"
  ------------------
  106|    341|    if (!sock_name)
  ------------------
  |  Branch (106:9): [True: 341, False: 0]
  ------------------
  107|    341|        sock_name = "socket";
  108|       |
  109|    341|    if (qos_type != PJ_QOS_TYPE_BEST_EFFORT) {
  ------------------
  |  Branch (109:9): [True: 0, False: 341]
  ------------------
  110|      0|        qos_type_rc = pj_sock_set_qos_type(sock, qos_type);
  111|       |
  112|      0|        if (qos_type_rc != PJ_SUCCESS) {
  ------------------
  |  Branch (112:13): [True: 0, False: 0]
  ------------------
  113|      0|            pj_perror(log_level, log_sender,  qos_type_rc, 
  114|      0|                      "Error setting QoS type %d to %s", 
  115|      0|                      qos_type, sock_name);
  116|      0|        }
  117|      0|    }
  118|       |
  119|    341|    if (qos_params && qos_params->flags) {
  ------------------
  |  Branch (119:9): [True: 341, False: 0]
  |  Branch (119:23): [True: 0, False: 341]
  ------------------
  120|      0|        qos_params_rc = pj_sock_set_qos_params(sock, qos_params);
  121|      0|        if (qos_params_rc != PJ_SUCCESS) {
  ------------------
  |  Branch (121:13): [True: 0, False: 0]
  ------------------
  122|      0|            pj_perror(log_level, log_sender,  qos_params_rc, 
  123|      0|                      "Error setting QoS params (flags=%d) to %s", 
  124|      0|                      qos_params->flags, sock_name);
  125|      0|            if (qos_type_rc != PJ_SUCCESS)
  ------------------
  |  Branch (125:17): [True: 0, False: 0]
  ------------------
  126|      0|                return qos_params_rc;
  127|      0|        }
  128|    341|    } else if (qos_type_rc != PJ_SUCCESS)
  ------------------
  |  Branch (128:16): [True: 0, False: 341]
  ------------------
  129|      0|        return qos_type_rc;
  130|       |
  131|    341|    return PJ_SUCCESS;
  132|    341|}
pj_sock_apply_qos2:
  141|    341|{
  142|    341|    pj_qos_params qos_params_buf, *qos_params_copy = NULL;
  143|       |
  144|    341|    if (qos_params) {
  ------------------
  |  Branch (144:9): [True: 341, False: 0]
  ------------------
  145|    341|        pj_memcpy(&qos_params_buf, qos_params, sizeof(*qos_params));
  146|    341|        qos_params_copy = &qos_params_buf;
  147|    341|    }
  148|       |
  149|    341|    return pj_sock_apply_qos(sock, qos_type, qos_params_copy,
  150|    341|                             log_level, log_sender, sock_name);
  151|    341|}

PJ_FD_ZERO:
   43|  3.71k|{
   44|  3.71k|    PJ_CHECK_STACK();
   45|  3.71k|    pj_assert(sizeof(pj_fd_set_t)-sizeof(pj_sock_t) >= sizeof(fd_set));
  ------------------
  |  |   65|  3.71k|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (45:5): [True: 0, Folded]
  |  Branch (45:5): [True: 3.71k, Folded]
  ------------------
   46|       |
   47|  3.71k|    FD_ZERO(PART_FDSET(fdsetp));
  ------------------
  |  Branch (47:5): [Folded, False: 3.71k]
  ------------------
   48|  3.71k|    PART_COUNT(fdsetp) = 0;
  ------------------
  |  |   40|  3.71k|#define PART_COUNT(ps)          (ps->data[0])
  ------------------
   49|  3.71k|}
PJ_FD_SET:
   53|    341|{
   54|    341|    PJ_CHECK_STACK();
   55|    341|    pj_assert(sizeof(pj_fd_set_t)-sizeof(pj_sock_t) >= sizeof(fd_set));
  ------------------
  |  |   65|    341|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (55:5): [True: 0, Folded]
  |  Branch (55:5): [True: 341, Folded]
  ------------------
   56|       |
   57|    341|    if (!PJ_FD_ISSET(fd, fdsetp))
  ------------------
  |  Branch (57:9): [True: 341, False: 0]
  ------------------
   58|    341|        ++PART_COUNT(fdsetp);
  ------------------
  |  |   40|    341|#define PART_COUNT(ps)          (ps->data[0])
  ------------------
   59|       |    FD_SET(fd, PART_FDSET(fdsetp));
   60|    341|}
PJ_FD_CLR:
   64|  1.02k|{
   65|  1.02k|    PJ_CHECK_STACK();
   66|  1.02k|    pj_assert(sizeof(pj_fd_set_t)-sizeof(pj_sock_t) >= sizeof(fd_set));
  ------------------
  |  |   65|  1.02k|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (66:5): [True: 0, Folded]
  |  Branch (66:5): [True: 1.02k, Folded]
  ------------------
   67|       |
   68|  1.02k|    if (PJ_FD_ISSET(fd, fdsetp))
  ------------------
  |  Branch (68:9): [True: 341, False: 682]
  ------------------
   69|    341|        --PART_COUNT(fdsetp);
  ------------------
  |  |   40|    341|#define PART_COUNT(ps)          (ps->data[0])
  ------------------
   70|       |    FD_CLR(fd, PART_FDSET(fdsetp));
   71|  1.02k|}
PJ_FD_ISSET:
   75|  1.36k|{
   76|  1.36k|    PJ_CHECK_STACK();
   77|  1.36k|    PJ_ASSERT_RETURN(sizeof(pj_fd_set_t)-sizeof(pj_sock_t) >= sizeof(fd_set),
  ------------------
  |  |   97|  1.36k|            do { \
  |  |   98|  1.36k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [Folded, False: 1.36k]
  |  |  ------------------
  |  |   99|  1.36k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1.36k]
  |  |  ------------------
  ------------------
  |  Branch (77:5): [True: 0, Folded]
  |  Branch (77:5): [True: 0, Folded]
  ------------------
   78|  1.36k|                     0);
   79|       |
   80|  1.36k|    return FD_ISSET(fd, PART_FDSET(fdsetp));
   81|  1.36k|}

pj_utoa_pad:
  561|      4|{
  562|      4|    char *p;
  563|      4|    int len;
  564|       |
  565|      4|    PJ_CHECK_STACK();
  566|       |
  567|      4|    p = buf;
  568|      8|    do {
  569|      8|        unsigned long digval = (unsigned long) (val % 10);
  570|      8|        val /= 10;
  571|      8|        *p++ = (char) (digval + '0');
  572|      8|    } while (val > 0);
  ------------------
  |  Branch (572:14): [True: 4, False: 4]
  ------------------
  573|       |
  574|      4|    len = (int)(p-buf);
  575|      5|    while (len < min_dig) {
  ------------------
  |  Branch (575:12): [True: 1, False: 4]
  ------------------
  576|      1|        *p++ = (char)pad;
  577|      1|        ++len;
  578|      1|    }
  579|      4|    *p-- = '\0';
  580|       |
  581|      4|    do {
  582|      4|        char temp = *p;
  583|      4|        *p = *buf;
  584|      4|        *buf = temp;
  585|      4|        --p;
  586|      4|        ++buf;
  587|      4|    } while (buf < p);
  ------------------
  |  Branch (587:14): [True: 0, False: 4]
  ------------------
  588|       |
  589|      4|    return len;
  590|      4|}
pj_ansi_strxcpy:
  631|  39.7k|{
  632|  39.7k|    char *odst = dst;
  633|       |
  634|  39.7k|    PJ_ASSERT_RETURN(dst && src, -PJ_EINVAL);
  ------------------
  |  |   97|  39.7k|            do { \
  |  |   98|  79.5k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 39.7k, False: 0]
  |  |  |  Branch (98:23): [True: 39.7k, False: 0]
  |  |  ------------------
  |  |   99|  39.7k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 39.7k]
  |  |  ------------------
  ------------------
  |  Branch (634:5): [True: 0, False: 0]
  |  Branch (634:5): [True: 0, False: 0]
  |  Branch (634:5): [True: 0, False: 0]
  |  Branch (634:5): [True: 0, False: 0]
  ------------------
  635|       |
  636|  39.7k|    if (dst_size==0)
  ------------------
  |  Branch (636:9): [True: 0, False: 39.7k]
  ------------------
  637|      0|        return -PJ_ETOOBIG;
  ------------------
  |  |  458|      0|#define PJ_ETOOBIG          (PJ_ERRNO_START_STATUS + 17)/* 70017 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  638|       |
  639|   656k|    while (--dst_size && (*dst=*src) != 0) {
  ------------------
  |  Branch (639:12): [True: 656k, False: 0]
  |  Branch (639:26): [True: 616k, False: 39.7k]
  ------------------
  640|   616k|        ++dst;
  641|   616k|        ++src;
  642|   616k|    }
  643|       |
  644|  39.7k|    if (!*dst && !*src) {
  ------------------
  |  Branch (644:9): [True: 39.7k, False: 0]
  |  Branch (644:18): [True: 39.7k, False: 0]
  ------------------
  645|  39.7k|        return (int)(dst-odst);
  646|  39.7k|    } else {
  647|      0|        *dst = '\0';
  648|      0|        return *src? -PJ_ETOOBIG : (int)(dst-odst);
  ------------------
  |  |  458|      0|#define PJ_ETOOBIG          (PJ_ERRNO_START_STATUS + 17)/* 70017 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (648:16): [True: 0, False: 0]
  ------------------
  649|      0|    }
  650|  39.7k|}

pj_timer_heap_create:
  592|  1.23k|{
  593|  1.23k|    pj_timer_heap_t *ht;
  594|  1.23k|    pj_size_t i;
  595|       |
  596|  1.23k|    PJ_ASSERT_RETURN(pool && p_heap, PJ_EINVAL);
  ------------------
  |  |   97|  1.23k|            do { \
  |  |   98|  2.47k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 1.23k, False: 0]
  |  |  |  Branch (98:23): [True: 1.23k, False: 0]
  |  |  ------------------
  |  |   99|  1.23k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1.23k]
  |  |  ------------------
  ------------------
  |  Branch (596:5): [True: 0, False: 0]
  |  Branch (596:5): [True: 0, False: 0]
  |  Branch (596:5): [True: 0, False: 0]
  |  Branch (596:5): [True: 0, False: 0]
  ------------------
  597|       |
  598|  1.23k|    *p_heap = NULL;
  599|       |
  600|       |    /* Magic? */
  601|  1.23k|    size += 2;
  602|       |
  603|       |    /* Allocate timer heap data structure from the pool */
  604|  1.23k|    ht = PJ_POOL_ZALLOC_T(pool, pj_timer_heap_t);
  ------------------
  |  |  583|  1.23k|            ((type*)pj_pool_zalloc(pool, sizeof(type)))
  ------------------
  605|  1.23k|    if (!ht)
  ------------------
  |  Branch (605:9): [True: 0, False: 1.23k]
  ------------------
  606|      0|        return PJ_ENOMEM;
  ------------------
  |  |  408|      0|#define PJ_ENOMEM           (PJ_ERRNO_START_STATUS + 7) /* 70007 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  607|       |
  608|       |    /* Initialize timer heap sizes */
  609|  1.23k|    ht->max_size = size;
  610|  1.23k|    ht->cur_size = 0;
  611|  1.23k|    ht->max_entries_per_poll = DEFAULT_MAX_TIMED_OUT_PER_POLL;
  ------------------
  |  |   46|  1.23k|#define DEFAULT_MAX_TIMED_OUT_PER_POLL  (64)
  ------------------
  612|  1.23k|    ht->timer_ids_freelist = 1;
  613|  1.23k|    ht->pool = pool;
  614|       |
  615|       |    /* Lock. */
  616|  1.23k|    ht->lock = NULL;
  617|  1.23k|    ht->auto_delete_lock = 0;
  618|       |
  619|       |    // Create the heap array.
  620|  1.23k|    ht->heap = (pj_timer_entry_dup**)
  621|  1.23k|               pj_pool_calloc(pool, (unsigned)size,
  622|  1.23k|                              sizeof(pj_timer_entry_dup*));
  623|  1.23k|    if (!ht->heap)
  ------------------
  |  Branch (623:9): [True: 0, False: 1.23k]
  ------------------
  624|      0|        return PJ_ENOMEM;
  ------------------
  |  |  408|      0|#define PJ_ENOMEM           (PJ_ERRNO_START_STATUS + 7) /* 70007 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  625|       |
  626|  1.23k|#if PJ_TIMER_USE_COPY
  627|       |    // Create the timer entry copies array.
  628|  1.23k|    ht->timer_dups = (pj_timer_entry_dup*)
  629|  1.23k|                     pj_pool_alloc(pool, sizeof(pj_timer_entry_dup) * size);
  630|  1.23k|    if (!ht->timer_dups)
  ------------------
  |  Branch (630:9): [True: 0, False: 1.23k]
  ------------------
  631|      0|        return PJ_ENOMEM;
  ------------------
  |  |  408|      0|#define PJ_ENOMEM           (PJ_ERRNO_START_STATUS + 7) /* 70007 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  632|  1.23k|#endif
  633|       |
  634|       |    // Create the parallel
  635|  1.23k|    ht->timer_ids = (pj_timer_id_t *)
  636|  1.23k|                    pj_pool_alloc( pool, sizeof(pj_timer_id_t) * size);
  637|  1.23k|    if (!ht->timer_ids)
  ------------------
  |  Branch (637:9): [True: 0, False: 1.23k]
  ------------------
  638|      0|        return PJ_ENOMEM;
  ------------------
  |  |  408|      0|#define PJ_ENOMEM           (PJ_ERRNO_START_STATUS + 7) /* 70007 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  639|       |
  640|       |    // Initialize the "freelist," which uses negative values to
  641|       |    // distinguish freelist elements from "pointers" into the <heap_>
  642|       |    // array.
  643|  28.9k|    for (i=0; i<size; ++i)
  ------------------
  |  Branch (643:15): [True: 27.7k, False: 1.23k]
  ------------------
  644|  27.7k|        ht->timer_ids[i] = -((pj_timer_id_t) (i + 1));
  645|       |
  646|       |#if PJ_TIMER_USE_LINKED_LIST
  647|       |    pj_list_init(&ht->head_list);
  648|       |#endif
  649|       |
  650|  1.23k|    *p_heap = ht;
  651|  1.23k|    return PJ_SUCCESS;
  652|  1.23k|}
pj_timer_heap_destroy:
  655|  1.23k|{
  656|  1.23k|    if (ht->lock && ht->auto_delete_lock) {
  ------------------
  |  Branch (656:9): [True: 0, False: 1.23k]
  |  Branch (656:21): [True: 0, False: 0]
  ------------------
  657|      0|        pj_lock_destroy(ht->lock);
  658|       |        ht->lock = NULL;
  659|      0|    }
  660|  1.23k|}
pj_timer_entry_init:
  686|  1.23k|{
  687|  1.23k|    pj_assert(entry && cb);
  ------------------
  |  |   65|  1.23k|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (687:5): [True: 0, False: 1.23k]
  |  Branch (687:5): [True: 0, False: 0]
  |  Branch (687:5): [True: 1.23k, False: 0]
  |  Branch (687:5): [True: 1.23k, False: 0]
  ------------------
  688|       |
  689|  1.23k|    entry->_timer_id = -1;
  690|  1.23k|    entry->id = id;
  691|  1.23k|    entry->user_data = user_data;
  692|  1.23k|    entry->cb = cb;
  693|       |#if !PJ_TIMER_USE_COPY
  694|       |    entry->_grp_lock = NULL;
  695|       |#endif
  696|       |
  697|  1.23k|    return entry;
  698|  1.23k|}
pj_timer_entry_running:
  701|    896|{
  702|    896|    return (entry->_timer_id >= 1);
  703|    896|}
pj_timer_heap_schedule_w_grp_lock_dbg:
  785|    896|{
  786|    896|    return schedule_w_grp_lock_dbg(ht, entry, delay, PJ_TRUE, id_val,
  787|    896|                                   grp_lock, src_file, src_line);
  788|    896|}
pj_timer_heap_cancel_if_active:
  854|  1.91k|{
  855|  1.91k|    return cancel_timer(ht, entry, F_SET_ID | F_DONT_ASSERT, id_val);
  856|  1.91k|}
timer.c:schedule_w_grp_lock_dbg:
  722|    896|{
  723|    896|    pj_status_t status;
  724|    896|    pj_time_val expires;
  725|       |
  726|    896|    PJ_ASSERT_RETURN(ht && entry && delay, PJ_EINVAL);
  ------------------
  |  |   97|    896|            do { \
  |  |   98|  3.58k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 896, False: 0]
  |  |  |  Branch (98:23): [True: 896, False: 0]
  |  |  |  Branch (98:23): [True: 896, False: 0]
  |  |  ------------------
  |  |   99|    896|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 896]
  |  |  ------------------
  ------------------
  |  Branch (726:5): [True: 0, False: 0]
  |  Branch (726:5): [True: 0, False: 0]
  |  Branch (726:5): [True: 0, False: 0]
  |  Branch (726:5): [True: 0, False: 0]
  |  Branch (726:5): [True: 0, False: 0]
  |  Branch (726:5): [True: 0, False: 0]
  ------------------
  727|    896|    PJ_ASSERT_RETURN(entry->cb != NULL, PJ_EINVAL);
  ------------------
  |  |   97|    896|            do { \
  |  |   98|    896|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 896]
  |  |  ------------------
  |  |   99|    896|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 896]
  |  |  ------------------
  ------------------
  |  Branch (727:5): [True: 0, False: 0]
  |  Branch (727:5): [True: 0, False: 0]
  ------------------
  728|       |
  729|       |    /* Prevent same entry from being scheduled more than once */
  730|       |    //PJ_ASSERT_RETURN(entry->_timer_id < 1, PJ_EINVALIDOP);
  731|       |
  732|    896|    pj_gettickcount(&expires);
  733|    896|    PJ_TIME_VAL_ADD(expires, *delay);
  ------------------
  |  |  539|    896|#define PJ_TIME_VAL_ADD(t1, t2)     do {                            \
  |  |  540|    896|                                        (t1).sec += (t2).sec;       \
  |  |  541|    896|                                        (t1).msec += (t2).msec;     \
  |  |  542|    896|                                        pj_time_val_normalize(&(t1)); \
  |  |  543|    896|                                    } while (0)
  |  |  ------------------
  |  |  |  Branch (543:46): [Folded, False: 896]
  |  |  ------------------
  ------------------
  734|       |
  735|    896|    lock_timer_heap(ht);
  736|       |
  737|       |    /* Prevent same entry from being scheduled more than once */
  738|    896|    if (pj_timer_entry_running(entry)) {
  ------------------
  |  Branch (738:9): [True: 0, False: 896]
  ------------------
  739|      0|        unlock_timer_heap(ht);
  740|      0|        PJ_LOG(3,(THIS_FILE, "Warning! Rescheduling outstanding entry (%p)",
  ------------------
  |  |  106|      0|#define PJ_LOG(level,arg)       do { \
  |  |  107|      0|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|      0|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 0, Folded]
  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  464|      0|    #define pj_log_wrapper_3(arg)       pj_log_3 arg
  |  |  ------------------
  |  |  109|      0|                                    } \
  |  |  110|      0|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 0]
  |  |  ------------------
  ------------------
  741|      0|                  entry));
  742|      0|        return PJ_EINVALIDOP;
  ------------------
  |  |  438|      0|#define PJ_EINVALIDOP       (PJ_ERRNO_START_STATUS + 13)/* 70013 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  743|      0|    }
  744|       |
  745|    896|    status = schedule_entry(ht, entry, &expires);
  746|    896|    if (status == PJ_SUCCESS) {
  ------------------
  |  Branch (746:9): [True: 896, False: 0]
  ------------------
  747|    896|        pj_timer_entry_dup *timer_copy = GET_TIMER(ht, entry);
  ------------------
  |  |  105|    896|#define GET_TIMER(ht, node) &ht->timer_dups[node->_timer_id]
  ------------------
  748|       |
  749|    896|        if (set_id)
  ------------------
  |  Branch (749:13): [True: 896, False: 0]
  ------------------
  750|    896|            GET_FIELD(timer_copy, id) = entry->id = id_val;
  ------------------
  |  |  107|    896|#define GET_FIELD(node, _timer_id) node->dup._timer_id
  ------------------
  751|    896|        timer_copy->_grp_lock = grp_lock;
  752|    896|        if (timer_copy->_grp_lock) {
  ------------------
  |  Branch (752:13): [True: 896, False: 0]
  ------------------
  753|    896|            pj_grp_lock_add_ref(timer_copy->_grp_lock);
  754|    896|        }
  755|    896|#if PJ_TIMER_DEBUG
  756|    896|        timer_copy->src_file = src_file;
  757|    896|        timer_copy->src_line = src_line;
  758|    896|#endif
  759|    896|    }
  760|    896|    unlock_timer_heap(ht);
  761|       |
  762|    896|    return status;
  763|    896|}
timer.c:schedule_entry:
  517|    896|{
  518|    896|    if (ht->cur_size < ht->max_size)
  ------------------
  |  Branch (518:9): [True: 896, False: 0]
  ------------------
  519|    896|    {
  520|       |        // Obtain the next unique sequence number.
  521|       |        // Set the entry
  522|    896|        entry->_timer_id = pop_freelist(ht);
  523|       |
  524|    896|        return insert_node( ht, entry, future_time );
  525|    896|    }
  526|      0|    else
  527|      0|        return -1;
  528|    896|}
timer.c:pop_freelist:
  216|    896|{
  217|       |    // We need to truncate this to <int> for backwards compatibility.
  218|    896|    pj_timer_id_t new_id = ht->timer_ids_freelist;
  219|       |
  220|    896|    PJ_CHECK_STACK();
  221|       |
  222|       |    // The freelist values in the <timer_ids_> are negative, so we need
  223|       |    // to negate them to get the next freelist "pointer."
  224|    896|    ht->timer_ids_freelist =
  225|    896|        -ht->timer_ids[ht->timer_ids_freelist];
  226|       |
  227|    896|    return new_id;
  228|       |
  229|    896|}
timer.c:insert_node:
  456|    896|{
  457|    896|    pj_timer_entry_dup *timer_copy;
  458|       |
  459|       |#if PJ_TIMER_USE_LINKED_LIST
  460|       |    pj_timer_entry_dup *tmp_node = NULL;
  461|       |#endif
  462|       |
  463|    896|    if (ht->cur_size + 2 >= ht->max_size) {
  ------------------
  |  Branch (463:9): [True: 0, False: 896]
  ------------------
  464|      0|        pj_status_t status = grow_heap(ht);
  465|      0|        if (status != PJ_SUCCESS)
  ------------------
  |  Branch (465:13): [True: 0, False: 0]
  ------------------
  466|      0|            return status;
  467|      0|    }
  468|       |
  469|    896|    timer_copy = GET_TIMER(ht, new_node);
  ------------------
  |  |  105|    896|#define GET_TIMER(ht, node) &ht->timer_dups[node->_timer_id]
  ------------------
  470|    896|#if PJ_TIMER_USE_COPY
  471|       |    // Create a duplicate of the timer entry.
  472|    896|    pj_bzero(timer_copy, sizeof(*timer_copy));
  473|    896|    pj_memcpy(&timer_copy->dup, new_node, sizeof(*new_node));
  474|    896|    timer_copy->entry = new_node;
  475|    896|#endif
  476|       |
  477|       |#if PJ_TIMER_USE_LINKED_LIST
  478|       |    pj_list_init(timer_copy);
  479|       |#endif
  480|       |
  481|    896|    timer_copy->_timer_value = *future_time;
  482|       |
  483|    896|#if !PJ_TIMER_USE_LINKED_LIST
  484|    896|    reheap_up(ht, timer_copy, ht->cur_size, HEAP_PARENT(ht->cur_size));
  ------------------
  |  |   42|    896|#define HEAP_PARENT(X)  (X == 0 ? 0 : (((X) - 1) / 2))
  |  |  ------------------
  |  |  |  Branch (42:26): [True: 896, False: 0]
  |  |  ------------------
  ------------------
  485|       |#else
  486|       |    if (ht->cur_size == 0) {
  487|       |        pj_list_push_back(&ht->head_list, timer_copy);
  488|       |    } else if (PJ_TIME_VAL_GTE(*future_time,
  489|       |                               ht->head_list.prev->_timer_value))
  490|       |    {
  491|       |        /* Insert the max value to the end of the list. */
  492|       |        pj_list_insert_before(&ht->head_list, timer_copy);
  493|       |    } else {
  494|       |        tmp_node = ht->head_list.next;
  495|       |        while (tmp_node->next != &ht->head_list &&
  496|       |               PJ_TIME_VAL_GT(*future_time, tmp_node->_timer_value))
  497|       |        {
  498|       |            tmp_node = tmp_node->next;
  499|       |        }
  500|       |        if (PJ_TIME_VAL_LT(*future_time, tmp_node->_timer_value)) {
  501|       |            pj_list_insert_before(tmp_node, timer_copy);
  502|       |        } else {
  503|       |            pj_list_insert_after(tmp_node, timer_copy);
  504|       |        }
  505|       |    }
  506|       |    copy_node(ht, new_node->_timer_id-1, timer_copy);
  507|       |#endif
  508|    896|    ht->cur_size++;
  509|       |
  510|    896|    return PJ_SUCCESS;
  511|    896|}
timer.c:reheap_up:
  278|    896|{
  279|       |    // Restore the heap property after an insertion.
  280|       |
  281|    896|    while (slot > 0)
  ------------------
  |  Branch (281:12): [True: 0, False: 896]
  ------------------
  282|      0|    {
  283|       |        // If the parent node is greater than the <moved_node> we need
  284|       |        // to copy it down.
  285|      0|        if (PJ_TIME_VAL_LT(moved_node->_timer_value,
  ------------------
  |  |  519|      0|#define PJ_TIME_VAL_LT(t1, t2)  (!(PJ_TIME_VAL_GTE(t1,t2)))
  |  |  ------------------
  |  |  |  |  508|      0|#define PJ_TIME_VAL_GTE(t1, t2) (PJ_TIME_VAL_GT(t1,t2) || \
  |  |  |  |  ------------------
  |  |  |  |  |  |  497|      0|#define PJ_TIME_VAL_GT(t1, t2)  ((t1).sec>(t2).sec || \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (497:34): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  498|      0|                                ((t1).sec==(t2).sec && (t1).msec>(t2).msec))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (498:34): [True: 0, False: 0]
  |  |  |  |  |  |  |  Branch (498:56): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  509|      0|                                 PJ_TIME_VAL_EQ(t1,t2))
  |  |  |  |  ------------------
  |  |  |  |  |  |  487|      0|#define PJ_TIME_VAL_EQ(t1, t2)  ((t1).sec==(t2).sec && (t1).msec==(t2).msec)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (487:34): [True: 0, False: 0]
  |  |  |  |  |  |  |  Branch (487:56): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  286|      0|                           ht->heap[parent]->_timer_value))
  287|      0|        {
  288|      0|            copy_node(ht, slot, ht->heap[parent]);
  289|      0|            slot = parent;
  290|      0|            parent = HEAP_PARENT(slot);
  ------------------
  |  |   42|      0|#define HEAP_PARENT(X)  (X == 0 ? 0 : (((X) - 1) / 2))
  |  |  ------------------
  |  |  |  Branch (42:26): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  291|      0|        }
  292|      0|        else
  293|      0|            break;
  294|      0|    }
  295|       |
  296|       |    // Insert the new node into its proper resting place in the heap and
  297|       |    // update the corresponding slot in the parallel <timer_ids> array.
  298|    896|    copy_node(ht, slot, moved_node);
  299|    896|}
timer.c:copy_node:
  205|    896|{
  206|    896|    PJ_CHECK_STACK();
  207|       |
  208|       |    // Insert <moved_node> into its new location in the heap.
  209|    896|    ht->heap[slot] = moved_node;
  210|       |
  211|       |    // Update the corresponding slot in the parallel <timer_ids_> array.
  212|    896|    ht->timer_ids[GET_FIELD(moved_node, _timer_id)] = (int)slot;
  ------------------
  |  |  107|    896|#define GET_FIELD(node, _timer_id) node->dup._timer_id
  ------------------
  213|    896|}
timer.c:cancel_timer:
  812|  1.91k|{
  813|  1.91k|    pj_timer_entry_dup *timer_copy;
  814|  1.91k|    pj_grp_lock_t *grp_lock;
  815|  1.91k|    int count;
  816|       |
  817|  1.91k|    PJ_ASSERT_RETURN(ht && entry, PJ_EINVAL);
  ------------------
  |  |   97|  1.91k|            do { \
  |  |   98|  3.83k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 1.91k, False: 0]
  |  |  |  Branch (98:23): [True: 1.91k, False: 0]
  |  |  ------------------
  |  |   99|  1.91k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1.91k]
  |  |  ------------------
  ------------------
  |  Branch (817:5): [True: 0, False: 0]
  |  Branch (817:5): [True: 0, False: 0]
  |  Branch (817:5): [True: 0, False: 0]
  |  Branch (817:5): [True: 0, False: 0]
  ------------------
  818|       |
  819|  1.91k|    lock_timer_heap(ht);
  820|       |
  821|       |    // Check to see if the timer_id is out of range
  822|  1.91k|    if (entry->_timer_id < 1 || (pj_size_t)entry->_timer_id >= ht->max_size) {
  ------------------
  |  Branch (822:9): [True: 1.91k, False: 0]
  |  Branch (822:33): [True: 0, False: 0]
  ------------------
  823|  1.91k|        unlock_timer_heap(ht);
  824|  1.91k|        return 0;
  825|  1.91k|    }
  826|       |
  827|      0|    timer_copy = GET_TIMER(ht, entry);
  ------------------
  |  |  105|      0|#define GET_TIMER(ht, node) &ht->timer_dups[node->_timer_id]
  ------------------
  828|      0|    grp_lock = timer_copy->_grp_lock;
  829|       |
  830|      0|    count = cancel(ht, entry, flags | F_DONT_CALL);
  831|      0|    if (count > 0) {
  ------------------
  |  Branch (831:9): [True: 0, False: 0]
  ------------------
  832|       |        /* Timer entry found & cancelled */
  833|      0|        if (flags & F_SET_ID) {
  ------------------
  |  Branch (833:13): [True: 0, False: 0]
  ------------------
  834|      0|            entry->id = id_val;
  835|      0|        }
  836|      0|        if (grp_lock) {
  ------------------
  |  Branch (836:13): [True: 0, False: 0]
  ------------------
  837|      0|            pj_grp_lock_dec_ref(grp_lock);
  838|      0|        }
  839|      0|    }
  840|      0|    unlock_timer_heap(ht);
  841|       |
  842|      0|    return count;
  843|  1.91k|}
timer.c:lock_timer_heap:
  189|  2.81k|{
  190|  2.81k|    if (ht->lock) {
  ------------------
  |  Branch (190:9): [True: 0, False: 2.81k]
  ------------------
  191|      0|        pj_lock_acquire(ht->lock);
  192|      0|    }
  193|  2.81k|}
timer.c:unlock_timer_heap:
  196|  2.81k|{
  197|  2.81k|    if (ht->lock) {
  ------------------
  |  Branch (197:9): [True: 0, False: 2.81k]
  ------------------
  198|      0|        pj_lock_release(ht->lock);
  199|      0|    }
  200|  2.81k|}

pj_time_val_normalize:
   23|  1.23k|{
   24|  1.23k|    PJ_CHECK_STACK();
   25|       |
   26|  1.23k|    if (t->msec >= 1000) {
  ------------------
  |  Branch (26:9): [True: 0, False: 1.23k]
  ------------------
   27|      0|        t->sec += (t->msec / 1000);
   28|      0|        t->msec = (t->msec % 1000);
   29|      0|    }
   30|  1.23k|    else if (t->msec <= -1000) {
  ------------------
  |  Branch (30:14): [True: 0, False: 1.23k]
  ------------------
   31|      0|        do {
   32|      0|            t->sec--;
   33|      0|            t->msec += 1000;
   34|      0|        } while (t->msec <= -1000);
  ------------------
  |  Branch (34:18): [True: 0, False: 0]
  ------------------
   35|      0|    }
   36|       |
   37|  1.23k|    if (t->sec >= 1 && t->msec < 0) {
  ------------------
  |  Branch (37:9): [True: 1.23k, False: 0]
  |  Branch (37:24): [True: 0, False: 1.23k]
  ------------------
   38|      0|        t->sec--;
   39|      0|        t->msec += 1000;
   40|       |
   41|  1.23k|    } else if (t->sec < 0 && t->msec > 0) {
  ------------------
  |  Branch (41:16): [True: 0, False: 1.23k]
  |  Branch (41:30): [True: 0, False: 0]
  ------------------
   42|      0|        t->sec++;
   43|      0|        t->msec -= 1000;
   44|      0|    }
   45|  1.23k|}

fuzz-stun.c:pj_stun_config_init:
  102|  1.23k|{
  103|  1.23k|    pj_bzero(cfg, sizeof(*cfg));
  104|       |
  105|  1.23k|    cfg->pf = factory;
  106|  1.23k|    cfg->options = options;
  107|  1.23k|    cfg->ioqueue = ioqueue;
  108|  1.23k|    cfg->timer_heap = timer_heap;
  109|  1.23k|    cfg->rto_msec = PJ_STUN_RTO_VALUE;
  ------------------
  |  |   75|  1.23k|#   define PJ_STUN_RTO_VALUE                        100
  ------------------
  110|  1.23k|    cfg->res_cache_msec = PJ_STUN_RES_CACHE_DURATION;
  ------------------
  |  |  107|  1.23k|#   define PJ_STUN_RES_CACHE_DURATION               10000
  ------------------
  111|  1.23k|    cfg->software_name = pj_str((char*)PJNATH_STUN_SOFTWARE_NAME);
  ------------------
  |  |  603|  1.23k|#   define PJNATH_STUN_SOFTWARE_NAME        PJNATH_MAKE_SW_NAME2( \
  |  |  ------------------
  |  |  |  |  601|  1.23k|#   define PJNATH_MAKE_SW_NAME2(a,b,c,d)    PJNATH_MAKE_SW_NAME(a,b,c,d)
  |  |  |  |  ------------------
  |  |  |  |  |  |  599|  1.23k|#   define PJNATH_MAKE_SW_NAME(a,b,c,d)     "pjnath-" #a "." #b "." #c d
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  604|  1.23k|                                                    PJ_VERSION_NUM_MAJOR, \
  |  |  605|  1.23k|                                                    PJ_VERSION_NUM_MINOR, \
  |  |  606|  1.23k|                                                    PJ_VERSION_NUM_REV, \
  |  |  607|  1.23k|                                                    PJ_VERSION_NUM_EXTRA)
  ------------------
  112|  1.23k|}
ice_strans.c:pj_stun_config_init:
  102|    341|{
  103|    341|    pj_bzero(cfg, sizeof(*cfg));
  104|       |
  105|    341|    cfg->pf = factory;
  106|    341|    cfg->options = options;
  107|    341|    cfg->ioqueue = ioqueue;
  108|    341|    cfg->timer_heap = timer_heap;
  109|    341|    cfg->rto_msec = PJ_STUN_RTO_VALUE;
  ------------------
  |  |   75|    341|#   define PJ_STUN_RTO_VALUE                        100
  ------------------
  110|    341|    cfg->res_cache_msec = PJ_STUN_RES_CACHE_DURATION;
  ------------------
  |  |  107|    341|#   define PJ_STUN_RES_CACHE_DURATION               10000
  ------------------
  111|    341|    cfg->software_name = pj_str((char*)PJNATH_STUN_SOFTWARE_NAME);
  ------------------
  |  |  603|    341|#   define PJNATH_STUN_SOFTWARE_NAME        PJNATH_MAKE_SW_NAME2( \
  |  |  ------------------
  |  |  |  |  601|    341|#   define PJNATH_MAKE_SW_NAME2(a,b,c,d)    PJNATH_MAKE_SW_NAME(a,b,c,d)
  |  |  |  |  ------------------
  |  |  |  |  |  |  599|    341|#   define PJNATH_MAKE_SW_NAME(a,b,c,d)     "pjnath-" #a "." #b "." #c d
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  604|    341|                                                    PJ_VERSION_NUM_MAJOR, \
  |  |  605|    341|                                                    PJ_VERSION_NUM_MINOR, \
  |  |  606|    341|                                                    PJ_VERSION_NUM_REV, \
  |  |  607|    341|                                                    PJ_VERSION_NUM_EXTRA)
  ------------------
  112|    341|}
ice_strans.c:pj_stun_config_check_valid:
  119|    341|{
  120|    341|    PJ_ASSERT_RETURN(cfg->ioqueue && cfg->pf && cfg->timer_heap &&
  ------------------
  |  |   97|    341|            do { \
  |  |   98|  2.72k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 341, False: 0]
  |  |  |  Branch (98:23): [True: 341, False: 0]
  |  |  |  Branch (98:23): [True: 341, False: 0]
  |  |  |  Branch (98:23): [True: 341, False: 0]
  |  |  |  Branch (98:23): [True: 341, False: 0]
  |  |  ------------------
  |  |   99|    341|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 341]
  |  |  ------------------
  ------------------
  |  Branch (120:5): [True: 0, False: 0]
  |  Branch (120:5): [True: 0, False: 0]
  |  Branch (120:5): [True: 0, False: 0]
  |  Branch (120:5): [True: 0, False: 0]
  |  Branch (120:5): [True: 0, False: 0]
  |  Branch (120:5): [True: 0, False: 0]
  |  Branch (120:5): [True: 0, False: 0]
  |  Branch (120:5): [True: 0, False: 0]
  |  Branch (120:5): [True: 0, False: 0]
  |  Branch (120:5): [True: 0, False: 0]
  ------------------
  121|    341|                     cfg->rto_msec && cfg->res_cache_msec, PJ_EINVAL);
  122|    341|    return PJ_SUCCESS;
  123|    341|}
stun_sock.c:pj_stun_config_check_valid:
  119|    341|{
  120|    341|    PJ_ASSERT_RETURN(cfg->ioqueue && cfg->pf && cfg->timer_heap &&
  ------------------
  |  |   97|    341|            do { \
  |  |   98|  2.72k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 341, False: 0]
  |  |  |  Branch (98:23): [True: 341, False: 0]
  |  |  |  Branch (98:23): [True: 341, False: 0]
  |  |  |  Branch (98:23): [True: 341, False: 0]
  |  |  |  Branch (98:23): [True: 341, False: 0]
  |  |  ------------------
  |  |   99|    341|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 341]
  |  |  ------------------
  ------------------
  |  Branch (120:5): [True: 0, False: 0]
  |  Branch (120:5): [True: 0, False: 0]
  |  Branch (120:5): [True: 0, False: 0]
  |  Branch (120:5): [True: 0, False: 0]
  |  Branch (120:5): [True: 0, False: 0]
  |  Branch (120:5): [True: 0, False: 0]
  |  Branch (120:5): [True: 0, False: 0]
  |  Branch (120:5): [True: 0, False: 0]
  |  Branch (120:5): [True: 0, False: 0]
  |  Branch (120:5): [True: 0, False: 0]
  ------------------
  121|    341|                     cfg->rto_msec && cfg->res_cache_msec, PJ_EINVAL);
  122|    341|    return PJ_SUCCESS;
  123|    341|}

pj_ice_calc_foundation:
  247|    341|{
  248|    341|#if PJNATH_ICE_PRIO_STD
  249|    341|    char buf[64];
  250|    341|    pj_uint32_t val;
  251|       |
  252|    341|    if (base_addr->addr.sa_family == pj_AF_INET()) {
  ------------------
  |  |  113|    341|#   define pj_AF_INET()     PJ_AF_INET
  ------------------
  |  Branch (252:9): [True: 341, False: 0]
  ------------------
  253|    341|        val = pj_ntohl(base_addr->ipv4.sin_addr.s_addr);
  254|    341|    } else {
  255|      0|        val = pj_hash_calc(0, pj_sockaddr_get_addr(base_addr),
  256|      0|                           pj_sockaddr_get_addr_len(base_addr));
  257|      0|    }
  258|    341|    pj_ansi_snprintf(buf, sizeof(buf), "%c%x",
  ------------------
  |  |  114|    341|#define pj_ansi_snprintf        snprintf
  ------------------
  259|    341|                     get_type_prefix(type), val);
  260|    341|    pj_strdup2(pool, foundation, buf);
  261|       |#else
  262|       |    /* Much shorter version, valid for candidates added by
  263|       |     * pj_ice_strans.
  264|       |     */
  265|       |    foundation->ptr = (char*) pj_pool_alloc(pool, 1);
  266|       |    *foundation->ptr = (char)get_type_prefix(type);
  267|       |    foundation->slen = 1;
  268|       |
  269|       |    PJ_UNUSED_ARG(base_addr);
  270|       |#endif
  271|    341|}
pj_ice_sess_options_default:
  322|    682|{
  323|    682|    opt->aggressive = PJ_TRUE;
  324|    682|    opt->nominated_check_delay = PJ_ICE_NOMINATED_CHECK_DELAY;
  ------------------
  |  |  404|    682|#   define PJ_ICE_NOMINATED_CHECK_DELAY             (4*PJ_STUN_RTO_VALUE)
  |  |  ------------------
  |  |  |  |   75|    682|#   define PJ_STUN_RTO_VALUE                        100
  |  |  ------------------
  ------------------
  325|    682|    opt->controlled_agent_want_nom_timeout = 
  326|    682|        ICE_CONTROLLED_AGENT_WAIT_NOMINATION_TIMEOUT;
  ------------------
  |  |  392|    682|#   define ICE_CONTROLLED_AGENT_WAIT_NOMINATION_TIMEOUT 10000
  ------------------
  327|    682|    opt->trickle = PJ_ICE_SESS_TRICKLE_DISABLED;
  328|    682|    opt->check_src_addr = PJ_ICE_SESS_CHECK_SRC_ADDR;
  ------------------
  |  |  415|    682|#   define PJ_ICE_SESS_CHECK_SRC_ADDR               1
  ------------------
  329|    682|}
pj_ice_sess_create:
  343|    341|{
  344|    341|    pj_pool_t *pool;
  345|    341|    pj_ice_sess *ice;
  346|    341|    unsigned i;
  347|    341|    pj_status_t status;
  348|       |
  349|    341|    PJ_ASSERT_RETURN(stun_cfg && cb && p_ice, PJ_EINVAL);
  ------------------
  |  |   97|    341|            do { \
  |  |   98|  1.36k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 341, False: 0]
  |  |  |  Branch (98:23): [True: 341, False: 0]
  |  |  |  Branch (98:23): [True: 341, False: 0]
  |  |  ------------------
  |  |   99|    341|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 341]
  |  |  ------------------
  ------------------
  |  Branch (349:5): [True: 0, False: 0]
  |  Branch (349:5): [True: 0, False: 0]
  |  Branch (349:5): [True: 0, False: 0]
  |  Branch (349:5): [True: 0, False: 0]
  |  Branch (349:5): [True: 0, False: 0]
  |  Branch (349:5): [True: 0, False: 0]
  ------------------
  350|       |
  351|    341|    if (name == NULL)
  ------------------
  |  Branch (351:9): [True: 0, False: 341]
  ------------------
  352|      0|        name = "icess%p";
  353|       |
  354|    341|    pool = pj_pool_create(stun_cfg->pf, name, PJNATH_POOL_LEN_ICE_SESS, 
  ------------------
  |  |  528|    341|#   define PJNATH_POOL_LEN_ICE_SESS                 512
  ------------------
  355|    341|                          PJNATH_POOL_INC_ICE_SESS, NULL);
  ------------------
  |  |  533|    341|#   define PJNATH_POOL_INC_ICE_SESS                 512
  ------------------
  356|    341|    ice = PJ_POOL_ZALLOC_T(pool, pj_ice_sess);
  ------------------
  |  |  583|    341|            ((type*)pj_pool_zalloc(pool, sizeof(type)))
  ------------------
  357|    341|    ice->pool = pool;
  358|    341|    ice->role = role;
  359|    341|    ice->tie_breaker.u32.hi = pj_rand();
  360|    341|    ice->tie_breaker.u32.lo = pj_rand();
  361|    341|    ice->prefs = cand_type_prefs;
  362|    341|    pj_ice_sess_options_default(&ice->opt);
  363|       |
  364|    341|    pj_timer_entry_init(&ice->timer, TIMER_NONE, (void*)ice, &on_timer);
  365|       |
  366|    341|    pj_ansi_snprintf(ice->obj_name, sizeof(ice->obj_name),
  ------------------
  |  |  114|    341|#define pj_ansi_snprintf        snprintf
  ------------------
  367|    341|                     name, ice);
  368|       |
  369|    341|    if (grp_lock) {
  ------------------
  |  Branch (369:9): [True: 341, False: 0]
  ------------------
  370|    341|        ice->grp_lock = grp_lock;
  371|    341|    } else {
  372|      0|        status = pj_grp_lock_create(pool, NULL, &ice->grp_lock);
  373|      0|        if (status != PJ_SUCCESS) {
  ------------------
  |  Branch (373:13): [True: 0, False: 0]
  ------------------
  374|      0|            pj_pool_release(pool);
  375|      0|            return status;
  376|      0|        }
  377|      0|    }
  378|       |
  379|    341|    pj_grp_lock_add_ref(ice->grp_lock);
  380|    341|    pj_grp_lock_add_handler(ice->grp_lock, pool, ice,
  381|    341|                            &ice_on_destroy);
  382|       |
  383|    341|    pj_memcpy(&ice->cb, cb, sizeof(*cb));
  384|    341|    pj_memcpy(&ice->stun_cfg, stun_cfg, sizeof(*stun_cfg));
  385|       |
  386|    341|    ice->comp_cnt = comp_cnt;
  387|    682|    for (i=0; i<comp_cnt; ++i) {
  ------------------
  |  Branch (387:15): [True: 341, False: 341]
  ------------------
  388|    341|        pj_ice_sess_comp *comp;
  389|    341|        comp = &ice->comp[i];
  390|    341|        comp->valid_check = NULL;
  391|    341|        comp->nominated_check = NULL;
  392|       |
  393|    341|        status = init_comp(ice, i+1, comp);
  394|    341|        if (status != PJ_SUCCESS) {
  ------------------
  |  Branch (394:13): [True: 0, False: 341]
  ------------------
  395|      0|            destroy_ice(ice, status);
  396|      0|            return status;
  397|      0|        }
  398|    341|    }
  399|       |
  400|       |    /* Initialize transport datas */
  401|  2.04k|    for (i=0; i<PJ_ARRAY_SIZE(ice->tp_data); ++i) {
  ------------------
  |  |  315|  2.04k|#define PJ_ARRAY_SIZE(a)    (sizeof(a)/sizeof(a[0]))
  ------------------
  |  Branch (401:15): [True: 1.70k, False: 341]
  ------------------
  402|  1.70k|        ice->tp_data[i].transport_id = 0;
  403|  1.70k|        ice->tp_data[i].has_req_data = PJ_FALSE;
  404|  1.70k|    }
  405|       |
  406|    341|    if (local_ufrag == NULL) {
  ------------------
  |  Branch (406:9): [True: 0, False: 341]
  ------------------
  407|      0|        ice->rx_ufrag.ptr = (char*) pj_pool_alloc(ice->pool, PJ_ICE_UFRAG_LEN);
  ------------------
  |  |  476|      0|#   define PJ_ICE_UFRAG_LEN                         8
  ------------------
  408|      0|        pj_create_random_string(ice->rx_ufrag.ptr, PJ_ICE_UFRAG_LEN);
  ------------------
  |  |  476|      0|#   define PJ_ICE_UFRAG_LEN                         8
  ------------------
  409|      0|        ice->rx_ufrag.slen = PJ_ICE_UFRAG_LEN;
  ------------------
  |  |  476|      0|#   define PJ_ICE_UFRAG_LEN                         8
  ------------------
  410|    341|    } else {
  411|    341|        pj_strdup(ice->pool, &ice->rx_ufrag, local_ufrag);
  412|    341|    }
  413|       |
  414|    341|    if (local_passwd == NULL) {
  ------------------
  |  Branch (414:9): [True: 0, False: 341]
  ------------------
  415|      0|        ice->rx_pass.ptr = (char*) pj_pool_alloc(ice->pool, PJ_ICE_PWD_LEN);
  ------------------
  |  |  487|      0|#   define PJ_ICE_PWD_LEN                           24
  ------------------
  416|      0|        pj_create_random_string(ice->rx_pass.ptr, PJ_ICE_PWD_LEN);
  ------------------
  |  |  487|      0|#   define PJ_ICE_PWD_LEN                           24
  ------------------
  417|      0|        ice->rx_pass.slen = PJ_ICE_PWD_LEN;
  ------------------
  |  |  487|      0|#   define PJ_ICE_PWD_LEN                           24
  ------------------
  418|    341|    } else {
  419|    341|        pj_strdup(ice->pool, &ice->rx_pass, local_passwd);
  420|    341|    }
  421|       |
  422|    341|    pj_list_init(&ice->early_check);
  423|       |
  424|    341|    ice->valid_pair_found = PJ_FALSE;
  425|       |
  426|       |    /* Done */
  427|    341|    *p_ice = ice;
  428|       |
  429|    341|    LOG4((ice->obj_name, 
  ------------------
  |  |  101|    341|#define LOG4(expr)              PJ_LOG(4,expr)
  |  |  ------------------
  |  |  |  |  106|    341|#define PJ_LOG(level,arg)       do { \
  |  |  |  |  107|    341|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |  417|    682|#  define PJ_LOG_MAX_LEVEL   5
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (107:41): [True: 341, Folded]
  |  |  |  |  |  Branch (107:70): [True: 0, False: 341]
  |  |  |  |  ------------------
  |  |  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  480|      0|    #define pj_log_wrapper_4(arg)       pj_log_4 arg
  |  |  |  |  ------------------
  |  |  |  |  109|      0|                                    } \
  |  |  |  |  110|    341|                                } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (110:42): [Folded, False: 341]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  430|    341|         "ICE session created, comp_cnt=%d, role is %s agent",
  431|    341|         comp_cnt, role_names[ice->role]));
  432|       |
  433|    341|    return PJ_SUCCESS;
  434|    341|}
pj_ice_sess_set_options:
  453|    341|{
  454|    341|    PJ_ASSERT_RETURN(ice && opt, PJ_EINVAL);
  ------------------
  |  |   97|    341|            do { \
  |  |   98|    682|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 341, False: 0]
  |  |  |  Branch (98:23): [True: 341, False: 0]
  |  |  ------------------
  |  |   99|    341|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 341]
  |  |  ------------------
  ------------------
  |  Branch (454:5): [True: 0, False: 0]
  |  Branch (454:5): [True: 0, False: 0]
  |  Branch (454:5): [True: 0, False: 0]
  |  Branch (454:5): [True: 0, False: 0]
  ------------------
  455|    341|    pj_memcpy(&ice->opt, opt, sizeof(*opt));
  456|    341|    ice->is_trickling = (ice->opt.trickle != PJ_ICE_SESS_TRICKLE_DISABLED);
  457|    341|    if (ice->is_trickling) {
  ------------------
  |  Branch (457:9): [True: 0, False: 341]
  ------------------
  458|      0|        LOG5((ice->obj_name, "Trickle ICE is active (%s mode)",
  ------------------
  |  |  102|      0|#define LOG5(expr)              PJ_LOG(4,expr)
  |  |  ------------------
  |  |  |  |  106|      0|#define PJ_LOG(level,arg)       do { \
  |  |  |  |  107|      0|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |  417|      0|#  define PJ_LOG_MAX_LEVEL   5
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (107:41): [True: 0, Folded]
  |  |  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  480|      0|    #define pj_log_wrapper_4(arg)       pj_log_4 arg
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (480:50): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  109|      0|                                    } \
  |  |  |  |  110|      0|                                } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (110:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  459|      0|              (ice->opt.trickle==PJ_ICE_SESS_TRICKLE_HALF? "half":"full")));
  460|       |
  461|      0|        if (ice->opt.aggressive) {
  ------------------
  |  Branch (461:13): [True: 0, False: 0]
  ------------------
  462|       |            /* Disable aggressive when ICE trickle is active */
  463|      0|            ice->opt.aggressive = PJ_FALSE;
  464|      0|            LOG4((ice->obj_name, "Warning: aggressive nomination is disabled"
  ------------------
  |  |  101|      0|#define LOG4(expr)              PJ_LOG(4,expr)
  |  |  ------------------
  |  |  |  |  106|      0|#define PJ_LOG(level,arg)       do { \
  |  |  |  |  107|      0|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |  417|      0|#  define PJ_LOG_MAX_LEVEL   5
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (107:41): [True: 0, Folded]
  |  |  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  480|      0|    #define pj_log_wrapper_4(arg)       pj_log_4 arg
  |  |  |  |  ------------------
  |  |  |  |  109|      0|                                    } \
  |  |  |  |  110|      0|                                } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (110:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  465|      0|                                 " as trickle ICE is active"));
  466|      0|        }
  467|      0|    }
  468|       |
  469|    341|    LOG5((ice->obj_name, "ICE nomination type set to %s",
  ------------------
  |  |  102|    341|#define LOG5(expr)              PJ_LOG(4,expr)
  |  |  ------------------
  |  |  |  |  106|    341|#define PJ_LOG(level,arg)       do { \
  |  |  |  |  107|    341|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |  417|    682|#  define PJ_LOG_MAX_LEVEL   5
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (107:41): [True: 341, Folded]
  |  |  |  |  |  Branch (107:70): [True: 0, False: 341]
  |  |  |  |  ------------------
  |  |  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  480|      0|    #define pj_log_wrapper_4(arg)       pj_log_4 arg
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (480:50): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  109|      0|                                    } \
  |  |  |  |  110|    341|                                } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (110:42): [Folded, False: 341]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  470|    341|          (ice->opt.aggressive ? "aggressive" : "regular")));
  471|    341|    return PJ_SUCCESS;
  472|    341|}
pj_ice_sess_destroy:
  531|    341|{
  532|    341|    PJ_ASSERT_RETURN(ice, PJ_EINVAL);
  ------------------
  |  |   97|    341|            do { \
  |  |   98|    341|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 341]
  |  |  ------------------
  |  |   99|    341|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 341]
  |  |  ------------------
  ------------------
  |  Branch (532:5): [True: 0, False: 0]
  |  Branch (532:5): [True: 0, False: 0]
  ------------------
  533|    341|    destroy_ice(ice, PJ_SUCCESS);
  534|    341|    return PJ_SUCCESS;
  535|    341|}
pj_ice_sess_add_cand:
  753|    341|{
  754|    341|    pj_ice_sess_cand *lcand;
  755|    341|    pj_status_t status = PJ_SUCCESS;
  756|    341|    char address[PJ_INET6_ADDRSTRLEN];
  757|    341|    unsigned i;
  758|       |
  759|    341|    PJ_ASSERT_RETURN(ice && comp_id && 
  ------------------
  |  |   97|    341|            do { \
  |  |   98|  3.41k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 341, False: 0]
  |  |  |  Branch (98:23): [True: 341, False: 0]
  |  |  |  Branch (98:23): [True: 341, False: 0]
  |  |  |  Branch (98:23): [True: 341, False: 0]
  |  |  |  Branch (98:23): [True: 341, False: 0]
  |  |  |  Branch (98:23): [True: 341, False: 0]
  |  |  ------------------
  |  |   99|    341|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 341]
  |  |  ------------------
  ------------------
  |  Branch (759:5): [True: 0, False: 0]
  |  Branch (759:5): [True: 0, False: 0]
  |  Branch (759:5): [True: 0, False: 0]
  |  Branch (759:5): [True: 0, False: 0]
  |  Branch (759:5): [True: 0, False: 0]
  |  Branch (759:5): [True: 0, False: 0]
  |  Branch (759:5): [True: 0, False: 0]
  |  Branch (759:5): [True: 0, False: 0]
  |  Branch (759:5): [True: 0, False: 0]
  |  Branch (759:5): [True: 0, False: 0]
  |  Branch (759:5): [True: 0, False: 0]
  |  Branch (759:5): [True: 0, False: 0]
  ------------------
  760|    341|                     foundation && addr && base_addr && addr_len,
  761|    341|                     PJ_EINVAL);
  762|    341|    PJ_ASSERT_RETURN(comp_id <= ice->comp_cnt, PJ_EINVAL);
  ------------------
  |  |   97|    341|            do { \
  |  |   98|    341|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 341]
  |  |  ------------------
  |  |   99|    341|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 341]
  |  |  ------------------
  ------------------
  |  Branch (762:5): [True: 0, False: 0]
  |  Branch (762:5): [True: 0, False: 0]
  ------------------
  763|       |
  764|    341|    pj_grp_lock_acquire(ice->grp_lock);
  765|       |
  766|    341|    if (ice->lcand_cnt >= PJ_ARRAY_SIZE(ice->lcand)) {
  ------------------
  |  |  315|    341|#define PJ_ARRAY_SIZE(a)    (sizeof(a)/sizeof(a[0]))
  ------------------
  |  Branch (766:9): [True: 0, False: 341]
  ------------------
  767|      0|        status = PJ_ETOOMANY;
  ------------------
  |  |  423|      0|#define PJ_ETOOMANY         (PJ_ERRNO_START_STATUS + 10)/* 70010 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  768|      0|        goto on_return;
  769|      0|    }
  770|       |
  771|    341|    if (ice->opt.trickle != PJ_ICE_SESS_TRICKLE_DISABLED) {
  ------------------
  |  Branch (771:9): [True: 0, False: 341]
  ------------------
  772|       |        /* Trickle ICE:
  773|       |         * Make sure that candidate has not been added
  774|       |         */
  775|      0|        for (i=0; i<ice->lcand_cnt; ++i) {
  ------------------
  |  Branch (775:19): [True: 0, False: 0]
  ------------------
  776|      0|            const pj_ice_sess_cand *c = &ice->lcand[i];
  777|      0|            if (c->comp_id==comp_id && c->type == type &&
  ------------------
  |  Branch (777:17): [True: 0, False: 0]
  |  Branch (777:40): [True: 0, False: 0]
  ------------------
  778|      0|                pj_sockaddr_cmp(&c->addr, addr)==0 &&
  ------------------
  |  Branch (778:17): [True: 0, False: 0]
  ------------------
  779|      0|                pj_sockaddr_cmp(&c->base_addr, base_addr)==0)
  ------------------
  |  Branch (779:17): [True: 0, False: 0]
  ------------------
  780|      0|            {
  781|      0|                break;
  782|      0|            }
  783|      0|        }
  784|       |
  785|       |        /* Skip candidate, it has been added */
  786|      0|        if (i < ice->lcand_cnt) {
  ------------------
  |  Branch (786:13): [True: 0, False: 0]
  ------------------
  787|      0|            if (p_cand_id)
  ------------------
  |  Branch (787:17): [True: 0, False: 0]
  ------------------
  788|      0|                *p_cand_id = i;
  789|      0|            goto on_return;
  790|      0|        }
  791|      0|    }
  792|       |
  793|    341|    lcand = &ice->lcand[ice->lcand_cnt];
  794|    341|    lcand->id = ice->lcand_cnt;
  795|    341|    lcand->comp_id = (pj_uint8_t)comp_id;
  796|    341|    lcand->transport_id = (pj_uint8_t)transport_id;
  797|    341|    lcand->type = type;
  798|    341|    pj_strdup(ice->pool, &lcand->foundation, foundation);
  799|    341|    lcand->local_pref = local_pref;
  800|    341|    lcand->prio = CALC_CAND_PRIO(ice, type, local_pref, lcand->comp_id);
  801|    341|    pj_sockaddr_cp(&lcand->addr, addr);
  802|    341|    pj_sockaddr_cp(&lcand->base_addr, base_addr);
  803|    341|    if (rel_addr == NULL)
  ------------------
  |  Branch (803:9): [True: 0, False: 341]
  ------------------
  804|      0|        rel_addr = base_addr;
  805|    341|    pj_memcpy(&lcand->rel_addr, rel_addr, addr_len);
  806|       |
  807|       |    /* Update transport data */
  808|    341|    for (i = 0; i < PJ_ARRAY_SIZE(ice->tp_data); ++i) {
  ------------------
  |  |  315|    341|#define PJ_ARRAY_SIZE(a)    (sizeof(a)/sizeof(a[0]))
  ------------------
  |  Branch (808:17): [True: 341, False: 0]
  ------------------
  809|       |        /* Check if this transport has been registered */
  810|    341|        if (ice->tp_data[i].transport_id == transport_id)
  ------------------
  |  Branch (810:13): [True: 0, False: 341]
  ------------------
  811|      0|            break;
  812|       |
  813|    341|        if (ice->tp_data[i].transport_id == 0) {
  ------------------
  |  Branch (813:13): [True: 341, False: 0]
  ------------------
  814|       |            /* Found an empty slot, register this transport here */
  815|    341|            ice->tp_data[i].transport_id = transport_id;
  816|    341|            break;
  817|    341|        }
  818|    341|    }
  819|    341|    pj_assert(i < PJ_ARRAY_SIZE(ice->tp_data) &&
  ------------------
  |  |   65|    341|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (819:5): [True: 0, False: 341]
  |  Branch (819:5): [True: 0, False: 0]
  |  Branch (819:5): [True: 341, False: 0]
  |  Branch (819:5): [True: 341, False: 0]
  ------------------
  820|    341|              ice->tp_data[i].transport_id == transport_id);
  821|       |
  822|    341|    pj_ansi_strxcpy(ice->tmp.txt, pj_sockaddr_print(&lcand->addr, address,
  823|    341|                                                    sizeof(address), 2),
  824|    341|                    sizeof(ice->tmp.txt));
  825|    341|    LOG4((ice->obj_name, 
  ------------------
  |  |  101|    341|#define LOG4(expr)              PJ_LOG(4,expr)
  |  |  ------------------
  |  |  |  |  106|    341|#define PJ_LOG(level,arg)       do { \
  |  |  |  |  107|    341|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |  417|    682|#  define PJ_LOG_MAX_LEVEL   5
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (107:41): [True: 341, Folded]
  |  |  |  |  |  Branch (107:70): [True: 0, False: 341]
  |  |  |  |  ------------------
  |  |  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  480|      0|    #define pj_log_wrapper_4(arg)       pj_log_4 arg
  |  |  |  |  ------------------
  |  |  |  |  109|      0|                                    } \
  |  |  |  |  110|    341|                                } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (110:42): [Folded, False: 341]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  826|    341|         "Candidate %d added: comp_id=%d, type=%s, foundation=%.*s, "
  827|    341|         "addr=%s:%d, base=%s:%d, prio=0x%x (%u)",
  828|    341|         lcand->id,
  829|    341|         lcand->comp_id, 
  830|    341|         cand_type_names[lcand->type],
  831|    341|         (int)lcand->foundation.slen,
  832|    341|         lcand->foundation.ptr,
  833|    341|         ice->tmp.txt, 
  834|    341|          pj_sockaddr_get_port(&lcand->addr),
  835|    341|          pj_sockaddr_print(&lcand->base_addr, address, sizeof(address), 2),
  836|    341|          pj_sockaddr_get_port(&lcand->base_addr),
  837|    341|         lcand->prio, lcand->prio));
  838|       |
  839|    341|    if (p_cand_id)
  ------------------
  |  Branch (839:9): [True: 341, False: 0]
  ------------------
  840|    341|        *p_cand_id = lcand->id;
  841|       |
  842|    341|    ++ice->lcand_cnt;
  843|       |
  844|    341|on_return:
  845|    341|    pj_grp_lock_release(ice->grp_lock);
  846|    341|    return status;
  847|    341|}
ice_session.c:get_type_prefix:
  225|    341|{
  226|    341|    switch (type) {
  227|    341|    case PJ_ICE_CAND_TYPE_HOST:     return 'H';
  ------------------
  |  Branch (227:5): [True: 341, False: 0]
  ------------------
  228|      0|    case PJ_ICE_CAND_TYPE_SRFLX:    return 'S';
  ------------------
  |  Branch (228:5): [True: 0, False: 341]
  ------------------
  229|      0|    case PJ_ICE_CAND_TYPE_PRFLX:    return 'P';
  ------------------
  |  Branch (229:5): [True: 0, False: 341]
  ------------------
  230|      0|    case PJ_ICE_CAND_TYPE_RELAYED:  return 'R';
  ------------------
  |  Branch (230:5): [True: 0, False: 341]
  ------------------
  231|      0|    default:
  ------------------
  |  Branch (231:5): [True: 0, False: 341]
  ------------------
  232|      0|        pj_assert(!"Invalid type");
  ------------------
  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (232:9): [Folded, False: 0]
  |  Branch (232:9): [Folded, False: 0]
  ------------------
  233|      0|        return 'U';
  234|    341|    }
  235|    341|}
ice_session.c:init_comp:
  278|    341|{
  279|    341|    pj_stun_session_cb sess_cb;
  280|    341|    pj_stun_auth_cred auth_cred;
  281|    341|    stun_data *sd;
  282|    341|    pj_status_t status;
  283|       |
  284|       |    /* Init STUN callbacks */
  285|    341|    pj_bzero(&sess_cb, sizeof(sess_cb));
  286|    341|    sess_cb.on_request_complete = &on_stun_request_complete;
  287|    341|    sess_cb.on_rx_indication = &on_stun_rx_indication;
  288|    341|    sess_cb.on_rx_request = &on_stun_rx_request;
  289|    341|    sess_cb.on_send_msg = &on_stun_send_msg;
  290|       |
  291|       |    /* Create STUN session for this candidate */
  292|    341|    status = pj_stun_session_create(&ice->stun_cfg, NULL, 
  293|    341|                                    &sess_cb, PJ_TRUE,
  294|    341|                                    ice->grp_lock,
  295|    341|                                    &comp->stun_sess);
  296|    341|    if (status != PJ_SUCCESS)
  ------------------
  |  Branch (296:9): [True: 0, False: 341]
  ------------------
  297|      0|        return status;
  298|       |
  299|       |    /* Associate data with this STUN session */
  300|    341|    sd = PJ_POOL_ZALLOC_T(ice->pool, struct stun_data);
  ------------------
  |  |  583|    341|            ((type*)pj_pool_zalloc(pool, sizeof(type)))
  ------------------
  301|    341|    sd->ice = ice;
  302|    341|    sd->comp_id = comp_id;
  303|    341|    sd->comp = comp;
  304|    341|    pj_stun_session_set_user_data(comp->stun_sess, sd);
  305|       |
  306|       |    /* Init STUN authentication credential */
  307|    341|    pj_bzero(&auth_cred, sizeof(auth_cred));
  308|    341|    auth_cred.type = PJ_STUN_AUTH_CRED_DYNAMIC;
  309|    341|    auth_cred.data.dyn_cred.get_auth = &stun_auth_get_auth;
  310|    341|    auth_cred.data.dyn_cred.get_cred = &stun_auth_get_cred;
  311|    341|    auth_cred.data.dyn_cred.get_password = &stun_auth_get_password;
  312|    341|    auth_cred.data.dyn_cred.user_data = comp->stun_sess;
  313|    341|    pj_stun_session_set_credential(comp->stun_sess, PJ_STUN_AUTH_SHORT_TERM,
  314|    341|                                   &auth_cred);
  315|       |
  316|    341|    return PJ_SUCCESS;
  317|    341|}
ice_session.c:ice_on_destroy:
  479|    341|{
  480|    341|    pj_ice_sess *ice = (pj_ice_sess*) obj;
  481|       |
  482|    341|    pj_pool_safe_release(&ice->pool);
  483|       |
  484|    341|    LOG4((THIS_FILE, "ICE session %p destroyed", ice));
  ------------------
  |  |  101|    341|#define LOG4(expr)              PJ_LOG(4,expr)
  |  |  ------------------
  |  |  |  |  106|    341|#define PJ_LOG(level,arg)       do { \
  |  |  |  |  107|    341|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |  417|    682|#  define PJ_LOG_MAX_LEVEL   5
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (107:41): [True: 341, Folded]
  |  |  |  |  |  Branch (107:70): [True: 0, False: 341]
  |  |  |  |  ------------------
  |  |  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  480|      0|    #define pj_log_wrapper_4(arg)       pj_log_4 arg
  |  |  |  |  ------------------
  |  |  |  |  109|      0|                                    } \
  |  |  |  |  110|    341|                                } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (110:42): [Folded, False: 341]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  485|    341|}
ice_session.c:destroy_ice:
  492|    341|{
  493|    341|    unsigned i;
  494|       |
  495|    341|    if (reason == PJ_SUCCESS) {
  ------------------
  |  Branch (495:9): [True: 341, False: 0]
  ------------------
  496|    341|        LOG4((ice->obj_name, "Destroying ICE session %p", ice));
  ------------------
  |  |  101|    341|#define LOG4(expr)              PJ_LOG(4,expr)
  |  |  ------------------
  |  |  |  |  106|    341|#define PJ_LOG(level,arg)       do { \
  |  |  |  |  107|    341|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |  417|    682|#  define PJ_LOG_MAX_LEVEL   5
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (107:41): [True: 341, Folded]
  |  |  |  |  |  Branch (107:70): [True: 0, False: 341]
  |  |  |  |  ------------------
  |  |  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  480|      0|    #define pj_log_wrapper_4(arg)       pj_log_4 arg
  |  |  |  |  ------------------
  |  |  |  |  109|      0|                                    } \
  |  |  |  |  110|    341|                                } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (110:42): [Folded, False: 341]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  497|    341|    }
  498|       |
  499|    341|    pj_grp_lock_acquire(ice->grp_lock);
  500|       |
  501|    341|    if (ice->is_destroying) {
  ------------------
  |  Branch (501:9): [True: 0, False: 341]
  ------------------
  502|      0|        pj_grp_lock_release(ice->grp_lock);
  503|      0|        return;
  504|      0|    }
  505|       |
  506|    341|    ice->is_destroying = PJ_TRUE;
  507|       |
  508|    341|    pj_timer_heap_cancel_if_active(ice->stun_cfg.timer_heap,
  509|    341|                                   &ice->timer, PJ_FALSE);
  510|       |
  511|    682|    for (i=0; i<ice->comp_cnt; ++i) {
  ------------------
  |  Branch (511:15): [True: 341, False: 341]
  ------------------
  512|    341|        if (ice->comp[i].stun_sess) {
  ------------------
  |  Branch (512:13): [True: 341, False: 0]
  ------------------
  513|    341|            pj_stun_session_destroy(ice->comp[i].stun_sess);
  514|    341|            ice->comp[i].stun_sess = NULL;
  515|    341|        }
  516|    341|    }
  517|       |
  518|    341|    pj_timer_heap_cancel_if_active(ice->stun_cfg.timer_heap,
  519|    341|                                   &ice->clist.timer,
  520|    341|                                   PJ_FALSE);
  521|       |
  522|    341|    pj_grp_lock_dec_ref(ice->grp_lock);
  523|    341|    pj_grp_lock_release(ice->grp_lock);
  524|    341|}
ice_session.c:CALC_CAND_PRIO:
  714|    341|{
  715|    341|#if PJNATH_ICE_PRIO_STD
  716|    341|    return ((ice->prefs[type] & 0xFF) << 24) + 
  717|    341|           ((local_pref & 0xFFFF)    << 8) +
  718|    341|           (((256 - comp_id) & 0xFF) << 0);
  719|       |#else
  720|       |    enum {
  721|       |        type_mask   = ((1 << PJ_ICE_CAND_TYPE_PREF_BITS) - 1),
  722|       |        local_mask  = ((1 << PJ_ICE_LOCAL_PREF_BITS) - 1),
  723|       |        comp_mask   = ((1 << PJ_ICE_COMP_BITS) - 1),
  724|       |
  725|       |        comp_shift  = 0,
  726|       |        local_shift = (PJ_ICE_COMP_BITS),
  727|       |        type_shift  = (comp_shift + local_shift),
  728|       |
  729|       |        max_comp    = (2<<PJ_ICE_COMP_BITS),
  730|       |    };
  731|       |
  732|       |    return ((ice->prefs[type] & type_mask) << type_shift) + 
  733|       |           ((local_pref & local_mask) << local_shift) +
  734|       |           (((max_comp - comp_id) & comp_mask) << comp_shift);
  735|       |#endif
  736|    341|}

pj_ice_strans_cfg_default:
  267|    341|{
  268|    341|    pj_bzero(cfg, sizeof(*cfg));
  269|       |
  270|    341|    cfg->af = pj_AF_INET();
  ------------------
  |  |  113|    341|#   define pj_AF_INET()     PJ_AF_INET
  ------------------
  271|    341|    pj_stun_config_init(&cfg->stun_cfg, NULL, 0, NULL, NULL);
  272|    341|    pj_ice_strans_stun_cfg_default(&cfg->stun);
  273|    341|    pj_ice_strans_turn_cfg_default(&cfg->turn);
  274|    341|    pj_ice_sess_options_default(&cfg->opt);
  275|       |
  276|    341|    cfg->num_send_buf = 4;
  277|    341|}
pj_ice_strans_stun_cfg_default:
  284|    341|{
  285|    341|    pj_bzero(cfg, sizeof(*cfg));
  286|       |
  287|    341|    cfg->af = pj_AF_INET();
  ------------------
  |  |  113|    341|#   define pj_AF_INET()     PJ_AF_INET
  ------------------
  288|    341|    cfg->port = PJ_STUN_PORT;
  ------------------
  |  |  122|    341|#define PJ_STUN_PORT                                3478
  ------------------
  289|    341|    cfg->max_host_cands = 64;
  290|    341|    cfg->ignore_stun_error = PJ_FALSE;
  291|    341|    pj_stun_sock_cfg_default(&cfg->cfg);
  292|    341|}
pj_ice_strans_turn_cfg_default:
  299|    341|{
  300|    341|    pj_bzero(cfg, sizeof(*cfg));
  301|       |
  302|    341|    cfg->af = pj_AF_INET();
  ------------------
  |  |  113|    341|#   define pj_AF_INET()     PJ_AF_INET
  ------------------
  303|    341|    cfg->conn_type = PJ_TURN_TP_UDP;
  304|    341|    pj_turn_alloc_param_default(&cfg->alloc_param);
  305|    341|    pj_turn_sock_cfg_default(&cfg->cfg);
  306|    341|}
pj_ice_strans_cfg_copy:
  315|    341|{
  316|    341|    unsigned i;
  317|       |
  318|    341|    pj_memcpy(dst, src, sizeof(*src));
  319|       |
  320|    341|    if (src->stun.server.slen)
  ------------------
  |  Branch (320:9): [True: 0, False: 341]
  ------------------
  321|      0|        pj_strdup(pool, &dst->stun.server, &src->stun.server);
  322|       |
  323|    341|    for (i = 0; i < src->stun_tp_cnt; ++i) {
  ------------------
  |  Branch (323:17): [True: 0, False: 341]
  ------------------
  324|      0|        if (src->stun_tp[i].server.slen)
  ------------------
  |  Branch (324:13): [True: 0, False: 0]
  ------------------
  325|      0|            pj_strdup(pool, &dst->stun_tp[i].server,
  326|      0|                      &src->stun_tp[i].server);
  327|      0|    }
  328|       |
  329|    341|    if (src->turn.server.slen)
  ------------------
  |  Branch (329:9): [True: 0, False: 341]
  ------------------
  330|      0|        pj_strdup(pool, &dst->turn.server, &src->turn.server);
  331|    341|    pj_stun_auth_cred_dup(pool, &dst->turn.auth_cred, &src->turn.auth_cred);
  332|       |
  333|    341|    for (i = 0; i < src->turn_tp_cnt; ++i) {
  ------------------
  |  Branch (333:17): [True: 0, False: 341]
  ------------------
  334|      0|        if (src->turn_tp[i].server.slen)
  ------------------
  |  Branch (334:13): [True: 0, False: 0]
  ------------------
  335|      0|            pj_strdup(pool, &dst->turn_tp[i].server,
  336|      0|                      &src->turn_tp[i].server);
  337|      0|        pj_stun_auth_cred_dup(pool, &dst->turn_tp[i].auth_cred,
  338|      0|                              &src->turn_tp[i].auth_cred);
  339|      0|    }
  340|    341|}
pj_ice_strans_create:
  930|    341|{
  931|    341|    pj_pool_t *pool;
  932|    341|    pj_ice_strans *ice_st;
  933|    341|    unsigned i;
  934|    341|    pj_status_t status;
  935|       |
  936|    341|    status = pj_ice_strans_cfg_check_valid(cfg);
  937|    341|    if (status != PJ_SUCCESS)
  ------------------
  |  Branch (937:9): [True: 0, False: 341]
  ------------------
  938|      0|        return status;
  939|       |
  940|    341|    PJ_ASSERT_RETURN(comp_cnt && cb && p_ice_st &&
  ------------------
  |  |   97|    341|            do { \
  |  |   98|  2.04k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 341, False: 0]
  |  |  |  Branch (98:23): [True: 341, False: 0]
  |  |  |  Branch (98:23): [True: 341, False: 0]
  |  |  |  Branch (98:23): [True: 341, False: 0]
  |  |  ------------------
  |  |   99|    341|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 341]
  |  |  ------------------
  ------------------
  |  Branch (940:5): [True: 0, False: 0]
  |  Branch (940:5): [True: 0, False: 0]
  |  Branch (940:5): [True: 0, False: 0]
  |  Branch (940:5): [True: 0, False: 0]
  |  Branch (940:5): [True: 0, False: 0]
  |  Branch (940:5): [True: 0, False: 0]
  |  Branch (940:5): [True: 0, False: 0]
  |  Branch (940:5): [True: 0, False: 0]
  ------------------
  941|    341|                     comp_cnt <= PJ_ICE_MAX_COMP , PJ_EINVAL);
  942|       |
  943|    341|    if (name == NULL)
  ------------------
  |  Branch (943:9): [True: 0, False: 341]
  ------------------
  944|      0|        name = "ice%p";
  945|       |
  946|    341|    pool = pj_pool_create(cfg->stun_cfg.pf, name, PJNATH_POOL_LEN_ICE_STRANS,
  ------------------
  |  |  538|    341|#   define PJNATH_POOL_LEN_ICE_STRANS               1000
  ------------------
  947|    341|                          PJNATH_POOL_INC_ICE_STRANS, NULL);
  ------------------
  |  |  543|    341|#   define PJNATH_POOL_INC_ICE_STRANS               512
  ------------------
  948|    341|    ice_st = PJ_POOL_ZALLOC_T(pool, pj_ice_strans);
  ------------------
  |  |  583|    341|            ((type*)pj_pool_zalloc(pool, sizeof(type)))
  ------------------
  949|    341|    ice_st->pool = pool;
  950|    341|    ice_st->pf = cfg->stun_cfg.pf;
  951|    341|    ice_st->obj_name = pool->obj_name;
  952|    341|    ice_st->user_data = user_data;
  953|       |
  954|    341|    PJ_LOG(4,(ice_st->obj_name,
  ------------------
  |  |  106|    341|#define PJ_LOG(level,arg)       do { \
  |  |  107|    341|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|    682|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 341, Folded]
  |  |  |  Branch (107:70): [True: 0, False: 341]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  480|      0|    #define pj_log_wrapper_4(arg)       pj_log_4 arg
  |  |  ------------------
  |  |  109|      0|                                    } \
  |  |  110|    341|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 341]
  |  |  ------------------
  ------------------
  955|    341|              "Creating ICE stream transport with %d component(s)",
  956|    341|              comp_cnt));
  957|    341|    pj_log_push_indent();
  958|       |
  959|    341|    status = pj_grp_lock_create(pool, NULL, &ice_st->grp_lock);
  960|    341|    if (status != PJ_SUCCESS) {
  ------------------
  |  Branch (960:9): [True: 0, False: 341]
  ------------------
  961|      0|        pj_pool_release(pool);
  962|      0|        pj_log_pop_indent();
  963|      0|        return status;
  964|      0|    }
  965|       |
  966|       |    /* Allocate send buffer */
  967|    341|    ice_st->num_buf = cfg->num_send_buf;
  968|    341|    status = alloc_send_buf(ice_st, cfg->send_buf_size);
  969|    341|    if (status != PJ_SUCCESS) {
  ------------------
  |  Branch (969:9): [True: 0, False: 341]
  ------------------
  970|      0|        pj_grp_lock_destroy(ice_st->grp_lock);
  971|      0|        pj_pool_release(pool);
  972|      0|        pj_log_pop_indent();
  973|      0|        return status;
  974|      0|    }
  975|       |
  976|    341|    pj_grp_lock_add_ref(ice_st->grp_lock);
  977|    341|    pj_grp_lock_add_handler(ice_st->grp_lock, pool, ice_st,
  978|    341|                            &ice_st_on_destroy);
  979|       |
  980|    341|    pj_ice_strans_cfg_copy(pool, &ice_st->cfg, cfg);
  981|       |
  982|       |    /* To maintain backward compatibility, check if old/deprecated setting is set
  983|       |     * and the new setting is not, copy the value to the new setting.
  984|       |     */
  985|    341|    if (cfg->stun_tp_cnt == 0 && 
  ------------------
  |  Branch (985:9): [True: 341, False: 0]
  ------------------
  986|    341|        (cfg->stun.server.slen || cfg->stun.max_host_cands))
  ------------------
  |  Branch (986:10): [True: 0, False: 341]
  |  Branch (986:35): [True: 341, False: 0]
  ------------------
  987|    341|    {
  988|    341|        ice_st->cfg.stun_tp_cnt = 1;
  989|    341|        ice_st->cfg.stun_tp[0] = ice_st->cfg.stun;
  990|    341|    }
  991|    341|    if (cfg->turn_tp_cnt == 0 && cfg->turn.server.slen) {
  ------------------
  |  Branch (991:9): [True: 341, False: 0]
  |  Branch (991:34): [True: 0, False: 341]
  ------------------
  992|      0|        ice_st->cfg.turn_tp_cnt = 1;
  993|      0|        ice_st->cfg.turn_tp[0] = ice_st->cfg.turn;
  994|      0|    }
  995|       |
  996|    682|    for (i=0; i<ice_st->cfg.stun_tp_cnt; ++i)
  ------------------
  |  Branch (996:15): [True: 341, False: 341]
  ------------------
  997|    341|        ice_st->cfg.stun_tp[i].cfg.grp_lock = ice_st->grp_lock;
  998|    341|    for (i=0; i<ice_st->cfg.turn_tp_cnt; ++i)
  ------------------
  |  Branch (998:15): [True: 0, False: 341]
  ------------------
  999|      0|        ice_st->cfg.turn_tp[i].cfg.grp_lock = ice_st->grp_lock;
 1000|    341|    pj_memcpy(&ice_st->cb, cb, sizeof(*cb));
 1001|       |
 1002|    341|    ice_st->comp_cnt = comp_cnt;
 1003|    341|    ice_st->comp = (pj_ice_strans_comp**)
 1004|    341|                   pj_pool_calloc(pool, comp_cnt, sizeof(pj_ice_strans_comp*));
 1005|       |
 1006|       |    /* Move state to candidate gathering */
 1007|    341|    ice_st->state = PJ_ICE_STRANS_STATE_INIT;
 1008|       |
 1009|       |    /* Acquire initialization mutex to prevent callback to be
 1010|       |     * called before we finish initialization.
 1011|       |     */
 1012|    341|    pj_grp_lock_acquire(ice_st->grp_lock);
 1013|       |
 1014|    682|    for (i=0; i<comp_cnt; ++i) {
  ------------------
  |  Branch (1014:15): [True: 341, False: 341]
  ------------------
 1015|    341|        status = create_comp(ice_st, i+1);
 1016|    341|        if (status != PJ_SUCCESS) {
  ------------------
  |  Branch (1016:13): [True: 0, False: 341]
  ------------------
 1017|      0|            pj_grp_lock_release(ice_st->grp_lock);
 1018|      0|            destroy_ice_st(ice_st);
 1019|      0|            pj_log_pop_indent();
 1020|      0|            return status;
 1021|      0|        }
 1022|    341|    }
 1023|       |
 1024|       |    /* Done with initialization */
 1025|    341|    pj_grp_lock_release(ice_st->grp_lock);
 1026|       |
 1027|    341|    PJ_LOG(4,(ice_st->obj_name, "ICE stream transport %p created", ice_st));
  ------------------
  |  |  106|    341|#define PJ_LOG(level,arg)       do { \
  |  |  107|    341|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|    682|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 341, Folded]
  |  |  |  Branch (107:70): [True: 0, False: 341]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  480|      0|    #define pj_log_wrapper_4(arg)       pj_log_4 arg
  |  |  ------------------
  |  |  109|      0|                                    } \
  |  |  110|    341|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 341]
  |  |  ------------------
  ------------------
 1028|       |
 1029|    341|    *p_ice_st = ice_st;
 1030|       |
 1031|       |    /* Check if all candidates are ready (this may call callback) */
 1032|    341|    sess_init_update(ice_st);
 1033|       |
 1034|       |    /* If ICE init done, notify app about end of candidate gathering via
 1035|       |     * on_new_candidate() callback.
 1036|       |     */
 1037|    341|    if (ice_st->state==PJ_ICE_STRANS_STATE_READY &&
  ------------------
  |  Branch (1037:9): [True: 341, False: 0]
  ------------------
 1038|    341|        ice_st->cb.on_new_candidate)
  ------------------
  |  Branch (1038:9): [True: 0, False: 341]
  ------------------
 1039|      0|    {
 1040|      0|        (*ice_st->cb.on_new_candidate)(ice_st, NULL, PJ_TRUE);
 1041|      0|    }
 1042|       |
 1043|    341|    pj_log_pop_indent();
 1044|       |
 1045|    341|    return PJ_SUCCESS;
 1046|    341|}
pj_ice_strans_get_state:
 1124|    341|{
 1125|    341|    return ice_st->state;
 1126|    341|}
pj_ice_strans_destroy:
 1236|    341|{
 1237|    341|    destroy_ice_st(ice_st);
 1238|    341|    return PJ_SUCCESS;
 1239|    341|}
pj_ice_strans_init_ice:
 1335|    341|{
 1336|    341|    pj_status_t status;
 1337|    341|    unsigned i;
 1338|    341|    pj_ice_sess_cb ice_cb;
 1339|       |    //const pj_uint8_t srflx_prio[4] = { 100, 126, 110, 0 };
 1340|       |
 1341|       |    /* Check arguments */
 1342|    341|    PJ_ASSERT_RETURN(ice_st, PJ_EINVAL);
  ------------------
  |  |   97|    341|            do { \
  |  |   98|    341|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 341]
  |  |  ------------------
  |  |   99|    341|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 341]
  |  |  ------------------
  ------------------
  |  Branch (1342:5): [True: 0, False: 0]
  |  Branch (1342:5): [True: 0, False: 0]
  ------------------
 1343|       |    /* Must not have ICE */
 1344|    341|    PJ_ASSERT_RETURN(ice_st->ice == NULL, PJ_EINVALIDOP);
  ------------------
  |  |   97|    341|            do { \
  |  |   98|    341|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 341]
  |  |  ------------------
  |  |   99|    341|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 341]
  |  |  ------------------
  ------------------
  |  Branch (1344:5): [True: 0, False: 0]
  |  Branch (1344:5): [True: 0, False: 0]
  ------------------
 1345|       |    /* Components must have been created */
 1346|    341|    PJ_ASSERT_RETURN(ice_st->comp[0] != NULL, PJ_EINVALIDOP);
  ------------------
  |  |   97|    341|            do { \
  |  |   98|    341|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 341]
  |  |  ------------------
  |  |   99|    341|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 341]
  |  |  ------------------
  ------------------
  |  Branch (1346:5): [True: 0, False: 0]
  |  Branch (1346:5): [True: 0, False: 0]
  ------------------
 1347|       |
 1348|       |    /* Init callback */
 1349|    341|    pj_bzero(&ice_cb, sizeof(ice_cb));
 1350|    341|    ice_cb.on_valid_pair   = &on_valid_pair;
 1351|    341|    ice_cb.on_ice_complete = &on_ice_complete;
 1352|    341|    ice_cb.on_rx_data = &ice_rx_data;
 1353|    341|    ice_cb.on_tx_pkt = &ice_tx_pkt;
 1354|       |
 1355|       |    /* Release the pool of previous ICE session to avoid memory bloat,
 1356|       |     * as otherwise it will only be released after ICE strans is destroyed
 1357|       |     * (due to group lock).
 1358|       |     */
 1359|    341|    if (ice_st->ice_prev) {
  ------------------
  |  Branch (1359:9): [True: 0, False: 341]
  ------------------
 1360|      0|        (*ice_st->ice_prev_hndlr)(ice_st->ice_prev);
 1361|      0|        ice_st->ice_prev = NULL;
 1362|      0|    }
 1363|       |
 1364|       |    /* Create! */
 1365|    341|    status = pj_ice_sess_create(&ice_st->cfg.stun_cfg, ice_st->obj_name, role,
 1366|    341|                                ice_st->comp_cnt, &ice_cb,
 1367|    341|                                local_ufrag, local_passwd,
 1368|    341|                                ice_st->grp_lock,
 1369|    341|                                &ice_st->ice);
 1370|    341|    if (status != PJ_SUCCESS)
  ------------------
  |  Branch (1370:9): [True: 0, False: 341]
  ------------------
 1371|      0|        return status;
 1372|       |
 1373|       |    /* Associate user data */
 1374|    341|    ice_st->ice->user_data = (void*)ice_st;
 1375|       |
 1376|       |    /* Set options */
 1377|    341|    pj_ice_sess_set_options(ice_st->ice, &ice_st->cfg.opt);
 1378|       |
 1379|       |    /* If default candidate for components are SRFLX one, upload a custom
 1380|       |     * type priority to ICE session so that SRFLX candidates will get
 1381|       |     * checked first.
 1382|       |     */
 1383|    341|    if (ice_st->comp[0]->cand_list[ice_st->comp[0]->default_cand].type
  ------------------
  |  Branch (1383:9): [True: 0, False: 341]
  ------------------
 1384|    341|            == PJ_ICE_CAND_TYPE_SRFLX)
 1385|      0|    {
 1386|      0|        pj_ice_sess_set_prefs(ice_st->ice, srflx_pref_table);
 1387|      0|    }
 1388|       |
 1389|       |    /* Add components/candidates */
 1390|    682|    for (i=0; i<ice_st->comp_cnt; ++i) {
  ------------------
  |  Branch (1390:15): [True: 341, False: 341]
  ------------------
 1391|    341|        unsigned j;
 1392|    341|        pj_ice_strans_comp *comp = ice_st->comp[i];
 1393|       |
 1394|       |        /* Re-enable logging for Send/Data indications */
 1395|    341|        if (ice_st->cfg.turn_tp_cnt) {
  ------------------
  |  Branch (1395:13): [True: 0, False: 341]
  ------------------
 1396|      0|            PJ_LOG(5,(ice_st->obj_name,
  ------------------
  |  |  106|      0|#define PJ_LOG(level,arg)       do { \
  |  |  107|      0|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|      0|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 0, Folded]
  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  496|      0|    #define pj_log_wrapper_5(arg)       pj_log_5 arg
  |  |  ------------------
  |  |  109|      0|                                    } \
  |  |  110|      0|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1397|      0|                      "Enabling STUN Indication logging for "
 1398|      0|                      "component %d", i+1));
 1399|      0|        }
 1400|    341|        for (j = 0; j < ice_st->cfg.turn_tp_cnt; ++j) {
  ------------------
  |  Branch (1400:21): [True: 0, False: 341]
  ------------------
 1401|      0|            if (comp->turn[j].sock) {
  ------------------
  |  Branch (1401:17): [True: 0, False: 0]
  ------------------
 1402|      0|                pj_turn_sock_set_log(comp->turn[j].sock, 0xFFFF);
 1403|      0|                comp->turn[j].log_off = PJ_FALSE;
 1404|      0|            }
 1405|      0|        }
 1406|       |
 1407|    682|        for (j=0; j<comp->cand_cnt; ++j) {
  ------------------
  |  Branch (1407:19): [True: 341, False: 341]
  ------------------
 1408|    341|            pj_ice_sess_cand *cand = &comp->cand_list[j];
 1409|    341|            unsigned ice_cand_id;
 1410|       |
 1411|       |            /* Skip if candidate is not ready */
 1412|    341|            if (cand->status != PJ_SUCCESS) {
  ------------------
  |  Branch (1412:17): [True: 0, False: 341]
  ------------------
 1413|      0|                PJ_LOG(5,(ice_st->obj_name,
  ------------------
  |  |  106|      0|#define PJ_LOG(level,arg)       do { \
  |  |  107|      0|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|      0|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 0, Folded]
  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  496|      0|    #define pj_log_wrapper_5(arg)       pj_log_5 arg
  |  |  ------------------
  |  |  109|      0|                                    } \
  |  |  110|      0|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1414|      0|                          "Candidate %d of comp %d is not added (pending)",
 1415|      0|                          j, i));
 1416|      0|                continue;
 1417|      0|            }
 1418|       |
 1419|       |            /* Must have address */
 1420|    341|            pj_assert(pj_sockaddr_has_addr(&cand->addr));
  ------------------
  |  |   65|    341|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (1420:13): [True: 0, False: 341]
  |  Branch (1420:13): [True: 341, False: 0]
  ------------------
 1421|       |
 1422|       |            /* Skip if we are mapped to IPv4 address and this candidate
 1423|       |             * is not IPv4.
 1424|       |             */
 1425|    341|            if (comp->ipv4_mapped &&
  ------------------
  |  Branch (1425:17): [True: 0, False: 341]
  ------------------
 1426|      0|                cand->addr.addr.sa_family != pj_AF_INET())
  ------------------
  |  |  113|      0|#   define pj_AF_INET()     PJ_AF_INET
  ------------------
  |  Branch (1426:17): [True: 0, False: 0]
  ------------------
 1427|      0|            {
 1428|      0|                continue;
 1429|      0|            }
 1430|       |
 1431|       |            /* Add the candidate */
 1432|    341|            status = pj_ice_sess_add_cand(ice_st->ice, comp->comp_id,
 1433|    341|                                          cand->transport_id, cand->type,
 1434|    341|                                          cand->local_pref,
 1435|    341|                                          &cand->foundation, &cand->addr,
 1436|    341|                                          &cand->base_addr,  &cand->rel_addr,
 1437|    341|                                          pj_sockaddr_get_len(&cand->addr),
 1438|    341|                                          (unsigned*)&ice_cand_id);
 1439|    341|            if (status != PJ_SUCCESS)
  ------------------
  |  Branch (1439:17): [True: 0, False: 341]
  ------------------
 1440|      0|                goto on_error;
 1441|    341|        }
 1442|    341|    }
 1443|       |
 1444|       |    /* ICE session is ready for negotiation */
 1445|    341|    ice_st->state = PJ_ICE_STRANS_STATE_SESS_READY;
 1446|       |
 1447|    341|    return PJ_SUCCESS;
 1448|       |
 1449|      0|on_error:
 1450|      0|    pj_ice_strans_stop_ice(ice_st);
 1451|      0|    return status;
 1452|    341|}
pj_ice_strans_has_sess:
 1458|    341|{
 1459|    341|    PJ_ASSERT_RETURN(ice_st, PJ_FALSE);
  ------------------
  |  |   97|    341|            do { \
  |  |   98|    341|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 341]
  |  |  ------------------
  |  |   99|    341|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 341]
  |  |  ------------------
  ------------------
  |  Branch (1459:5): [True: 0, False: 0]
  |  Branch (1459:5): [True: 0, False: 0]
  ------------------
 1460|    341|    return ice_st->ice != NULL;
 1461|    341|}
pj_ice_strans_sess_is_running:
 1467|    341|{
 1468|       |    // Trickle ICE can start ICE before remote candidate list is received
 1469|    341|    return ice_st && ice_st->ice && /* ice_st->ice->rcand_cnt && */
  ------------------
  |  Branch (1469:12): [True: 341, False: 0]
  |  Branch (1469:22): [True: 341, False: 0]
  ------------------
 1470|    341|           ice_st->ice->clist.state == PJ_ICE_SESS_CHECKLIST_ST_RUNNING &&
  ------------------
  |  Branch (1470:12): [True: 0, False: 341]
  ------------------
 1471|      0|           !pj_ice_strans_sess_is_complete(ice_st);
  ------------------
  |  Branch (1471:12): [True: 0, False: 0]
  ------------------
 1472|    341|}
pj_ice_strans_sess_is_complete:
 1479|    341|{
 1480|    341|    return ice_st && ice_st->ice && ice_st->ice->is_complete;
  ------------------
  |  Branch (1480:12): [True: 341, False: 0]
  |  Branch (1480:22): [True: 341, False: 0]
  |  Branch (1480:37): [True: 0, False: 341]
  ------------------
 1481|    341|}
pj_ice_strans_enum_cands:
 1551|    341|{
 1552|    341|    unsigned i, cnt;
 1553|       |
 1554|    341|    PJ_ASSERT_RETURN(ice_st && ice_st->ice && comp_id &&
  ------------------
  |  |   97|    341|            do { \
  |  |   98|  3.41k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 341, False: 0]
  |  |  |  Branch (98:23): [True: 341, False: 0]
  |  |  |  Branch (98:23): [True: 341, False: 0]
  |  |  |  Branch (98:23): [True: 341, False: 0]
  |  |  |  Branch (98:23): [True: 341, False: 0]
  |  |  |  Branch (98:23): [True: 341, False: 0]
  |  |  ------------------
  |  |   99|    341|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 341]
  |  |  ------------------
  ------------------
  |  Branch (1554:5): [True: 0, False: 0]
  |  Branch (1554:5): [True: 0, False: 0]
  |  Branch (1554:5): [True: 0, False: 0]
  |  Branch (1554:5): [True: 0, False: 0]
  |  Branch (1554:5): [True: 0, False: 0]
  |  Branch (1554:5): [True: 0, False: 0]
  |  Branch (1554:5): [True: 0, False: 0]
  |  Branch (1554:5): [True: 0, False: 0]
  |  Branch (1554:5): [True: 0, False: 0]
  |  Branch (1554:5): [True: 0, False: 0]
  |  Branch (1554:5): [True: 0, False: 0]
  |  Branch (1554:5): [True: 0, False: 0]
  ------------------
 1555|    341|                     comp_id <= ice_st->comp_cnt && count && cand, PJ_EINVAL);
 1556|       |
 1557|    341|    cnt = 0;
 1558|    682|    for (i=0; i<ice_st->ice->lcand_cnt && cnt<*count; ++i) {
  ------------------
  |  Branch (1558:15): [True: 341, False: 341]
  |  Branch (1558:43): [True: 341, False: 0]
  ------------------
 1559|    341|        if (ice_st->ice->lcand[i].comp_id != comp_id)
  ------------------
  |  Branch (1559:13): [True: 0, False: 341]
  ------------------
 1560|      0|            continue;
 1561|    341|        pj_memcpy(&cand[cnt], &ice_st->ice->lcand[i],
 1562|    341|                  sizeof(pj_ice_sess_cand));
 1563|    341|        ++cnt;
 1564|    341|    }
 1565|       |
 1566|    341|    *count = cnt;
 1567|    341|    return PJ_SUCCESS;
 1568|    341|}
pj_ice_strans_get_def_cand:
 1576|    341|{
 1577|    341|    const pj_ice_sess_check *valid_pair;
 1578|       |
 1579|    341|    PJ_ASSERT_RETURN(ice_st && comp_id && comp_id <= ice_st->comp_cnt &&
  ------------------
  |  |   97|    341|            do { \
  |  |   98|  2.04k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 341, False: 0]
  |  |  |  Branch (98:23): [True: 341, False: 0]
  |  |  |  Branch (98:23): [True: 341, False: 0]
  |  |  |  Branch (98:23): [True: 341, False: 0]
  |  |  ------------------
  |  |   99|    341|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 341]
  |  |  ------------------
  ------------------
  |  Branch (1579:5): [True: 0, False: 0]
  |  Branch (1579:5): [True: 0, False: 0]
  |  Branch (1579:5): [True: 0, False: 0]
  |  Branch (1579:5): [True: 0, False: 0]
  |  Branch (1579:5): [True: 0, False: 0]
  |  Branch (1579:5): [True: 0, False: 0]
  |  Branch (1579:5): [True: 0, False: 0]
  |  Branch (1579:5): [True: 0, False: 0]
  ------------------
 1580|    341|                      cand, PJ_EINVAL);
 1581|       |
 1582|    341|    valid_pair = pj_ice_strans_get_valid_pair(ice_st, comp_id);
 1583|    341|    if (valid_pair) {
  ------------------
  |  Branch (1583:9): [True: 0, False: 341]
  ------------------
 1584|      0|        pj_memcpy(cand, valid_pair->lcand, sizeof(pj_ice_sess_cand));
 1585|    341|    } else {
 1586|    341|        pj_ice_strans_comp *comp = ice_st->comp[comp_id - 1];
 1587|    341|        pj_assert(comp->default_cand<comp->cand_cnt);
  ------------------
  |  |   65|    341|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (1587:9): [True: 0, False: 341]
  |  Branch (1587:9): [True: 341, False: 0]
  ------------------
 1588|    341|        pj_memcpy(cand, &comp->cand_list[comp->default_cand],
 1589|    341|                  sizeof(pj_ice_sess_cand));
 1590|    341|    }
 1591|    341|    return PJ_SUCCESS;
 1592|    341|}
pj_ice_strans_get_valid_pair:
 1785|    341|{
 1786|    341|    PJ_ASSERT_RETURN(ice_st && comp_id && comp_id <= ice_st->comp_cnt,
  ------------------
  |  |   97|    341|            do { \
  |  |   98|  1.36k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 341, False: 0]
  |  |  |  Branch (98:23): [True: 341, False: 0]
  |  |  |  Branch (98:23): [True: 341, False: 0]
  |  |  ------------------
  |  |   99|    341|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 341]
  |  |  ------------------
  ------------------
  |  Branch (1786:5): [True: 0, False: 0]
  |  Branch (1786:5): [True: 0, False: 0]
  |  Branch (1786:5): [True: 0, False: 0]
  |  Branch (1786:5): [True: 0, False: 0]
  |  Branch (1786:5): [True: 0, False: 0]
  |  Branch (1786:5): [True: 0, False: 0]
  ------------------
 1787|    341|                     NULL);
 1788|       |
 1789|    341|    if (ice_st->ice == NULL)
  ------------------
  |  Branch (1789:9): [True: 0, False: 341]
  ------------------
 1790|      0|        return NULL;
 1791|       |
 1792|    341|    return ice_st->ice->comp[comp_id-1].valid_check;
 1793|    341|}
ice_strans.c:pj_ice_strans_cfg_check_valid:
  252|    341|{
  253|    341|    pj_status_t status;
  254|       |
  255|    341|    status = pj_stun_config_check_valid(&cfg->stun_cfg);
  256|    341|    if (!status)
  ------------------
  |  Branch (256:9): [True: 341, False: 0]
  ------------------
  257|    341|        return status;
  258|       |
  259|      0|    return PJ_SUCCESS;
  260|    341|}
ice_strans.c:alloc_send_buf:
  891|    341|{
  892|    341|    if (buf_size > ice_st->buf_size) {
  ------------------
  |  Branch (892:9): [True: 0, False: 341]
  ------------------
  893|      0|        unsigned i;
  894|       |        
  895|      0|        if (ice_st->is_pending) {
  ------------------
  |  Branch (895:13): [True: 0, False: 0]
  ------------------
  896|       |            /* The current buffer is insufficient, but still currently used.*/
  897|      0|            return PJ_EBUSY;
  ------------------
  |  |  428|      0|#define PJ_EBUSY            (PJ_ERRNO_START_STATUS + 11)/* 70011 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  898|      0|        }
  899|       |
  900|      0|        pj_pool_safe_release(&ice_st->buf_pool);
  901|       |
  902|      0|        ice_st->buf_pool = pj_pool_create(ice_st->pf, "ice_buf",
  903|      0|                               (buf_size + sizeof(pending_send)) *
  904|      0|                               ice_st->num_buf, 512, NULL);
  905|      0|        if (!ice_st->buf_pool)
  ------------------
  |  Branch (905:13): [True: 0, False: 0]
  ------------------
  906|      0|            return PJ_ENOMEM;
  ------------------
  |  |  408|      0|#define PJ_ENOMEM           (PJ_ERRNO_START_STATUS + 7) /* 70007 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  907|       |
  908|      0|        ice_st->buf_size = buf_size;
  909|      0|        ice_st->send_buf = pj_pool_calloc(ice_st->buf_pool, ice_st->num_buf,
  910|      0|                                          sizeof(pending_send));
  911|      0|        for (i = 0; i < ice_st->num_buf; i++) {
  ------------------
  |  Branch (911:21): [True: 0, False: 0]
  ------------------
  912|      0|            ice_st->send_buf[i].buffer = pj_pool_alloc(ice_st->buf_pool,
  913|      0|                                                       buf_size);
  914|      0|        }
  915|      0|        ice_st->buf_idx = ice_st->empty_idx = 0;
  916|      0|    }
  917|       |    
  918|    341|    return PJ_SUCCESS;
  919|    341|}
ice_strans.c:create_comp:
  817|    341|{
  818|    341|    pj_ice_strans_comp *comp = NULL;
  819|    341|    unsigned i;
  820|    341|    pj_status_t status;
  821|       |
  822|       |    /* Verify arguments */
  823|    341|    PJ_ASSERT_RETURN(ice_st && comp_id, PJ_EINVAL);
  ------------------
  |  |   97|    341|            do { \
  |  |   98|    682|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 341, False: 0]
  |  |  |  Branch (98:23): [True: 341, False: 0]
  |  |  ------------------
  |  |   99|    341|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 341]
  |  |  ------------------
  ------------------
  |  Branch (823:5): [True: 0, False: 0]
  |  Branch (823:5): [True: 0, False: 0]
  |  Branch (823:5): [True: 0, False: 0]
  |  Branch (823:5): [True: 0, False: 0]
  ------------------
  824|       |
  825|       |    /* Check that component ID present */
  826|    341|    PJ_ASSERT_RETURN(comp_id <= ice_st->comp_cnt, PJNATH_EICEINCOMPID);
  ------------------
  |  |   97|    341|            do { \
  |  |   98|    341|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 341]
  |  |  ------------------
  |  |   99|    341|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 341]
  |  |  ------------------
  ------------------
  |  Branch (826:5): [True: 0, False: 0]
  |  Branch (826:5): [True: 0, False: 0]
  ------------------
  827|       |
  828|       |    /* Create component */
  829|    341|    comp = PJ_POOL_ZALLOC_T(ice_st->pool, pj_ice_strans_comp);
  ------------------
  |  |  583|    341|            ((type*)pj_pool_zalloc(pool, sizeof(type)))
  ------------------
  830|    341|    comp->ice_st = ice_st;
  831|    341|    comp->comp_id = comp_id;
  832|    341|    comp->creating = PJ_TRUE;
  833|       |
  834|    341|    ice_st->comp[comp_id-1] = comp;
  835|       |
  836|       |    /* Initialize default candidate */
  837|    341|    comp->default_cand = 0;
  838|       |
  839|       |    /* Create STUN transport if configured */
  840|    682|    for (i=0; i<ice_st->cfg.stun_tp_cnt; ++i) {
  ------------------
  |  Branch (840:15): [True: 341, False: 341]
  ------------------
  841|    341|        unsigned max_cand_cnt = PJ_ICE_ST_MAX_CAND - comp->cand_cnt -
  ------------------
  |  |  260|    341|#   define PJ_ICE_ST_MAX_CAND                       8
  ------------------
  842|    341|                                ice_st->cfg.turn_tp_cnt;
  843|       |
  844|    341|        status = PJ_ETOOSMALL;
  ------------------
  |  |  469|    341|#define PJ_ETOOSMALL        (PJ_ERRNO_START_STATUS + 19)/* 70019 */
  |  |  ------------------
  |  |  |  |  521|    341|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|    341|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|    341|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  845|       |
  846|    341|        if ((max_cand_cnt > 0) && (max_cand_cnt <= PJ_ICE_ST_MAX_CAND))
  ------------------
  |  |  260|    341|#   define PJ_ICE_ST_MAX_CAND                       8
  ------------------
  |  Branch (846:13): [True: 341, False: 0]
  |  Branch (846:35): [True: 341, False: 0]
  ------------------
  847|    341|            status = add_stun_and_host(ice_st, comp, i, max_cand_cnt);
  848|       |
  849|    341|        if (status != PJ_SUCCESS) {
  ------------------
  |  Branch (849:13): [True: 0, False: 341]
  ------------------
  850|      0|            PJ_PERROR(3,(ice_st->obj_name, status,
  ------------------
  |  |  189|      0|#define PJ_PERROR(level,arg)    do { \
  |  |  190|      0|                                    pj_perror_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  595|      0|    #define pj_perror_wrapper_3(arg)    pj_perror_3 arg
  |  |  ------------------
  |  |  191|      0|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (191:42): [Folded, False: 0]
  |  |  ------------------
  ------------------
  851|      0|                         "Failed creating STUN transport #%d for comp %d",
  852|      0|                         i, comp->comp_id));
  853|       |            //return status;
  854|      0|        }
  855|    341|    }
  856|       |
  857|       |    /* Create TURN relay if configured. */
  858|    341|    for (i=0; i<ice_st->cfg.turn_tp_cnt; ++i) {
  ------------------
  |  Branch (858:15): [True: 0, False: 341]
  ------------------
  859|      0|        unsigned max_cand_cnt = PJ_ICE_ST_MAX_CAND - comp->cand_cnt;
  ------------------
  |  |  260|      0|#   define PJ_ICE_ST_MAX_CAND                       8
  ------------------
  860|       |
  861|      0|        status = PJ_ETOOSMALL;
  ------------------
  |  |  469|      0|#define PJ_ETOOSMALL        (PJ_ERRNO_START_STATUS + 19)/* 70019 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  862|       |
  863|      0|        if ((max_cand_cnt > 0) && (max_cand_cnt <= PJ_ICE_ST_MAX_CAND))
  ------------------
  |  |  260|      0|#   define PJ_ICE_ST_MAX_CAND                       8
  ------------------
  |  Branch (863:13): [True: 0, False: 0]
  |  Branch (863:35): [True: 0, False: 0]
  ------------------
  864|      0|            status = add_update_turn(ice_st, comp, i, max_cand_cnt);
  865|       |
  866|      0|        if (status != PJ_SUCCESS) {
  ------------------
  |  Branch (866:13): [True: 0, False: 0]
  ------------------
  867|      0|            PJ_PERROR(3,(ice_st->obj_name, status,
  ------------------
  |  |  189|      0|#define PJ_PERROR(level,arg)    do { \
  |  |  190|      0|                                    pj_perror_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  595|      0|    #define pj_perror_wrapper_3(arg)    pj_perror_3 arg
  |  |  ------------------
  |  |  191|      0|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (191:42): [Folded, False: 0]
  |  |  ------------------
  ------------------
  868|      0|                         "Failed creating TURN transport #%d for comp %d",
  869|      0|                         i, comp->comp_id));
  870|       |
  871|       |            //return status;
  872|      0|        } else if (max_cand_cnt > 0) {
  ------------------
  |  Branch (872:20): [True: 0, False: 0]
  ------------------
  873|      0|            max_cand_cnt = PJ_ICE_ST_MAX_CAND - comp->cand_cnt;
  ------------------
  |  |  260|      0|#   define PJ_ICE_ST_MAX_CAND                       8
  ------------------
  874|      0|        }
  875|      0|    }
  876|       |
  877|       |    /* Done creating all the candidates */
  878|    341|    comp->creating = PJ_FALSE;
  879|       |
  880|       |    /* It's possible that we end up without any candidates */
  881|    341|    if (comp->cand_cnt == 0) {
  ------------------
  |  Branch (881:9): [True: 0, False: 341]
  ------------------
  882|      0|        PJ_LOG(4,(ice_st->obj_name,
  ------------------
  |  |  106|      0|#define PJ_LOG(level,arg)       do { \
  |  |  107|      0|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|      0|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 0, Folded]
  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  480|      0|    #define pj_log_wrapper_4(arg)       pj_log_4 arg
  |  |  ------------------
  |  |  109|      0|                                    } \
  |  |  110|      0|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 0]
  |  |  ------------------
  ------------------
  883|      0|                  "Error: no candidate is created due to settings"));
  884|      0|        return PJ_EINVAL;
  ------------------
  |  |  393|      0|#define PJ_EINVAL           (PJ_ERRNO_START_STATUS + 4) /* 70004 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  885|      0|    }
  886|       |
  887|    341|    return PJ_SUCCESS;
  888|    341|}
ice_strans.c:add_stun_and_host:
  510|    341|{
  511|    341|    pj_ice_sess_cand *cand;
  512|    341|    pj_ice_strans_stun_cfg *stun_cfg = &ice_st->cfg.stun_tp[idx];
  513|    341|    pj_stun_sock_cfg *sock_cfg  = &stun_cfg->cfg;
  514|    341|    unsigned comp_idx = comp->comp_id - 1;
  515|    341|    pj_stun_sock_cb stun_sock_cb;
  516|    341|    sock_user_data *data;
  517|    341|    pj_status_t status;
  518|       |
  519|    341|    PJ_ASSERT_RETURN(max_cand_cnt > 0, PJ_ETOOSMALL);
  ------------------
  |  |   97|    341|            do { \
  |  |   98|    341|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 341]
  |  |  ------------------
  |  |   99|    341|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 341]
  |  |  ------------------
  ------------------
  |  Branch (519:5): [True: 0, False: 0]
  |  Branch (519:5): [True: 0, False: 0]
  ------------------
  520|       |
  521|       |    /* Check if STUN transport or host candidate is configured */
  522|    341|    if (stun_cfg->server.slen == 0 && stun_cfg->max_host_cands == 0)
  ------------------
  |  Branch (522:9): [True: 341, False: 0]
  |  Branch (522:39): [True: 0, False: 341]
  ------------------
  523|      0|        return PJ_SUCCESS;
  524|       |
  525|       |    /* Initialize STUN socket callback */
  526|    341|    pj_bzero(&stun_sock_cb, sizeof(stun_sock_cb));
  527|    341|    stun_sock_cb.on_rx_data = &stun_on_rx_data;
  528|    341|    stun_sock_cb.on_status = &stun_on_status;
  529|    341|    stun_sock_cb.on_data_sent = &stun_on_data_sent;
  530|       |
  531|       |    /* Override component specific QoS settings, if any */
  532|    341|    if (ice_st->cfg.comp[comp_idx].qos_type) {
  ------------------
  |  Branch (532:9): [True: 0, False: 341]
  ------------------
  533|      0|        sock_cfg->qos_type = ice_st->cfg.comp[comp_idx].qos_type;
  534|      0|    }
  535|    341|    if (ice_st->cfg.comp[comp_idx].qos_params.flags) {
  ------------------
  |  Branch (535:9): [True: 0, False: 341]
  ------------------
  536|      0|        pj_memcpy(&sock_cfg->qos_params,
  537|      0|                  &ice_st->cfg.comp[comp_idx].qos_params,
  538|      0|                  sizeof(sock_cfg->qos_params));
  539|      0|    }
  540|       |
  541|       |    /* Override component specific socket buffer size settings, if any */
  542|    341|    if (ice_st->cfg.comp[comp_idx].so_rcvbuf_size > 0) {
  ------------------
  |  Branch (542:9): [True: 0, False: 341]
  ------------------
  543|      0|        sock_cfg->so_rcvbuf_size = ice_st->cfg.comp[comp_idx].so_rcvbuf_size;
  544|      0|    }
  545|    341|    if (ice_st->cfg.comp[comp_idx].so_sndbuf_size > 0) {
  ------------------
  |  Branch (545:9): [True: 0, False: 341]
  ------------------
  546|      0|        sock_cfg->so_sndbuf_size = ice_st->cfg.comp[comp_idx].so_sndbuf_size;
  547|      0|    }
  548|       |
  549|       |    /* Prepare srflx candidate with pending status. */
  550|    341|    cand = &comp->cand_list[comp->cand_cnt];
  551|    341|    cand->type = PJ_ICE_CAND_TYPE_SRFLX;
  552|    341|    cand->status = PJ_EPENDING;
  ------------------
  |  |  383|    341|#define PJ_EPENDING         (PJ_ERRNO_START_STATUS + 2) /* 70002 */
  |  |  ------------------
  |  |  |  |  521|    341|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|    341|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|    341|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  553|    341|    cand->local_pref = (pj_uint16_t)(SRFLX_PREF - idx);
  ------------------
  |  |   62|    341|#   define SRFLX_PREF  65535
  ------------------
  554|    341|    cand->transport_id = CREATE_TP_ID(TP_STUN, idx);
  ------------------
  |  |   51|    341|#define CREATE_TP_ID(type, idx)     (pj_uint8_t)((type << 6) | idx)
  ------------------
  555|    341|    cand->comp_id = (pj_uint8_t) comp->comp_id;
  556|       |
  557|       |    /* Allocate and initialize STUN socket data */
  558|    341|    data = PJ_POOL_ZALLOC_T(ice_st->pool, sock_user_data);
  ------------------
  |  |  583|    341|            ((type*)pj_pool_zalloc(pool, sizeof(type)))
  ------------------
  559|    341|    data->comp = comp;
  560|    341|    data->transport_id = cand->transport_id;
  561|       |
  562|       |    /* Create the STUN transport */
  563|    341|    status = pj_stun_sock_create(&ice_st->cfg.stun_cfg, NULL,
  564|    341|                                 stun_cfg->af, &stun_sock_cb,
  565|    341|                                 sock_cfg, data, &comp->stun[idx].sock);
  566|    341|    if (status != PJ_SUCCESS)
  ------------------
  |  Branch (566:9): [True: 0, False: 341]
  ------------------
  567|      0|        return status;
  568|       |
  569|       |    /* Start STUN Binding resolution and add srflx candidate only if server
  570|       |     * is set. When any error occur during STUN Binding resolution, let's
  571|       |     * just skip it and generate host candidates.
  572|       |     */
  573|    341|    while (stun_cfg->server.slen) {
  ------------------
  |  Branch (573:12): [True: 0, False: 341]
  ------------------
  574|      0|        pj_stun_sock_info stun_sock_info;
  575|       |
  576|       |        /* Add pending job */
  577|       |        ///sess_add_ref(ice_st);
  578|       |
  579|      0|        PJ_LOG(4,(ice_st->obj_name,
  ------------------
  |  |  106|      0|#define PJ_LOG(level,arg)       do { \
  |  |  107|      0|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|      0|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 0, Folded]
  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  480|      0|    #define pj_log_wrapper_4(arg)       pj_log_4 arg
  |  |  ------------------
  |  |  109|      0|                                    } \
  |  |  110|      0|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 0]
  |  |  ------------------
  ------------------
  580|      0|                  "Comp %d: srflx candidate (tpid=%d) starts "
  581|      0|                  "Binding discovery",
  582|      0|                  comp->comp_id, cand->transport_id));
  583|       |
  584|      0|        pj_log_push_indent();
  585|       |
  586|       |        /* Start Binding resolution */
  587|      0|        status = pj_stun_sock_start(comp->stun[idx].sock, &stun_cfg->server,
  588|      0|                                    stun_cfg->port, ice_st->cfg.resolver);
  589|      0|        if (status != PJ_SUCCESS) {
  ------------------
  |  Branch (589:13): [True: 0, False: 0]
  ------------------
  590|       |            ///sess_dec_ref(ice_st);
  591|      0|            PJ_PERROR(5,(ice_st->obj_name, status,
  ------------------
  |  |  189|      0|#define PJ_PERROR(level,arg)    do { \
  |  |  190|      0|                                    pj_perror_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  627|      0|    #define pj_perror_wrapper_5(arg)    pj_perror_5 arg
  |  |  ------------------
  |  |  191|      0|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (191:42): [Folded, False: 0]
  |  |  ------------------
  ------------------
  592|      0|                         "Comp %d: srflx candidate (tpid=%d) failed in "
  593|      0|                         "pj_stun_sock_start()",
  594|      0|                         comp->comp_id, cand->transport_id));
  595|      0|            pj_log_pop_indent();
  596|      0|            break;
  597|      0|        }
  598|       |
  599|       |        /* Enumerate addresses */
  600|      0|        status = pj_stun_sock_get_info(comp->stun[idx].sock, &stun_sock_info);
  601|      0|        if (status != PJ_SUCCESS) {
  ------------------
  |  Branch (601:13): [True: 0, False: 0]
  ------------------
  602|       |            ///sess_dec_ref(ice_st);
  603|      0|            PJ_PERROR(5,(ice_st->obj_name, status,
  ------------------
  |  |  189|      0|#define PJ_PERROR(level,arg)    do { \
  |  |  190|      0|                                    pj_perror_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  627|      0|    #define pj_perror_wrapper_5(arg)    pj_perror_5 arg
  |  |  ------------------
  |  |  191|      0|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (191:42): [Folded, False: 0]
  |  |  ------------------
  ------------------
  604|      0|                         "Comp %d: srflx candidate (tpid=%d) failed in "
  605|      0|                         "pj_stun_sock_get_info()",
  606|      0|                         comp->comp_id, cand->transport_id));
  607|      0|            pj_log_pop_indent();
  608|      0|            break;
  609|      0|        }
  610|       |
  611|       |        /* Update and commit the srflx candidate. */
  612|      0|        pj_sockaddr_cp(&cand->base_addr, &stun_sock_info.aliases[0]);
  613|      0|        pj_sockaddr_cp(&cand->rel_addr, &cand->base_addr);
  614|      0|        pj_ice_calc_foundation(ice_st->pool, &cand->foundation,
  615|      0|                               cand->type, &cand->base_addr);
  616|      0|        comp->cand_cnt++;
  617|      0|        max_cand_cnt--;
  618|       |
  619|       |        /* Set default candidate to srflx */
  620|      0|        if (comp->cand_list[comp->default_cand].type != PJ_ICE_CAND_TYPE_SRFLX
  ------------------
  |  Branch (620:13): [True: 0, False: 0]
  ------------------
  621|      0|            || (ice_st->cfg.af != pj_AF_UNSPEC() &&
  ------------------
  |  |  109|      0|#   define pj_AF_UNSPEC()   PJ_AF_UNSPEC
  ------------------
  |  Branch (621:17): [True: 0, False: 0]
  ------------------
  622|      0|                comp->cand_list[comp->default_cand].base_addr.addr.sa_family
  ------------------
  |  Branch (622:17): [True: 0, False: 0]
  ------------------
  623|      0|                != ice_st->cfg.af))
  624|      0|        {
  625|      0|            comp->default_cand = (unsigned)(cand - comp->cand_list);
  626|      0|        }
  627|       |
  628|      0|        pj_log_pop_indent();
  629|       |
  630|       |        /* Not really a loop, just trying to avoid complex 'if' blocks */
  631|      0|        break;
  632|      0|    }
  633|       |
  634|       |    /* Add local addresses to host candidates, unless max_host_cands
  635|       |     * is set to zero.
  636|       |     */
  637|    341|    if (stun_cfg->max_host_cands) {
  ------------------
  |  Branch (637:9): [True: 341, False: 0]
  ------------------
  638|    341|        pj_stun_sock_info stun_sock_info;
  639|    341|        unsigned i, cand_cnt = 0;
  640|       |
  641|       |        /* Enumerate addresses */
  642|    341|        status = pj_stun_sock_get_info(comp->stun[idx].sock, &stun_sock_info);
  643|    341|        if (status != PJ_SUCCESS) {
  ------------------
  |  Branch (643:13): [True: 0, False: 341]
  ------------------
  644|      0|            PJ_PERROR(4,(ice_st->obj_name, status,
  ------------------
  |  |  189|      0|#define PJ_PERROR(level,arg)    do { \
  |  |  190|      0|                                    pj_perror_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  611|      0|    #define pj_perror_wrapper_4(arg)    pj_perror_4 arg
  |  |  ------------------
  |  |  191|      0|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (191:42): [Folded, False: 0]
  |  |  ------------------
  ------------------
  645|      0|                         "Failed in querying STUN socket info"));
  646|      0|            return status;
  647|      0|        }
  648|       |
  649|    682|        for (i = 0; i < stun_sock_info.alias_cnt &&
  ------------------
  |  Branch (649:21): [True: 341, False: 341]
  ------------------
  650|    341|                    cand_cnt < stun_cfg->max_host_cands; ++i)
  ------------------
  |  Branch (650:21): [True: 341, False: 0]
  ------------------
  651|    341|        {
  652|    341|            unsigned j;
  653|    341|            pj_bool_t cand_duplicate = PJ_FALSE;
  654|    341|            char addrinfo[PJ_INET6_ADDRSTRLEN+10];
  655|    341|            const pj_sockaddr *addr = &stun_sock_info.aliases[i];
  656|    341|            pj_bool_t manual_host_added = PJ_FALSE;
  657|       |
  658|    341|            if (max_cand_cnt==0) {
  ------------------
  |  Branch (658:17): [True: 0, False: 341]
  ------------------
  659|      0|                PJ_LOG(4,(ice_st->obj_name, "Too many host candidates"));
  ------------------
  |  |  106|      0|#define PJ_LOG(level,arg)       do { \
  |  |  107|      0|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|      0|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 0, Folded]
  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  480|      0|    #define pj_log_wrapper_4(arg)       pj_log_4 arg
  |  |  ------------------
  |  |  109|      0|                                    } \
  |  |  110|      0|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 0]
  |  |  ------------------
  ------------------
  660|      0|                break;
  661|      0|            }
  662|       |
  663|       |            /* Ignore loopback addresses if cfg->stun.loop_addr is unset */
  664|    341|            if (stun_cfg->loop_addr==PJ_FALSE) {
  ------------------
  |  Branch (664:17): [True: 341, False: 0]
  ------------------
  665|    341|                if (stun_cfg->af == pj_AF_INET() && 
  ------------------
  |  |  113|    682|#   define pj_AF_INET()     PJ_AF_INET
  ------------------
  |  Branch (665:21): [True: 341, False: 0]
  ------------------
  666|    341|                    (pj_ntohl(addr->ipv4.sin_addr.s_addr)>>24)==127)
  ------------------
  |  Branch (666:21): [True: 0, False: 341]
  ------------------
  667|      0|                {
  668|      0|                    continue;
  669|      0|                }
  670|    341|                else if (stun_cfg->af == pj_AF_INET6()) {
  ------------------
  |  |  115|    341|#   define pj_AF_INET6()    PJ_AF_INET6
  ------------------
  |  Branch (670:26): [True: 0, False: 341]
  ------------------
  671|      0|                    pj_in6_addr in6addr = {{{0}}};
  672|      0|                    in6addr.s6_addr[15] = 1;
  673|      0|                    if (pj_memcmp(&in6addr, &addr->ipv6.sin6_addr,
  ------------------
  |  Branch (673:25): [True: 0, False: 0]
  ------------------
  674|      0|                                  sizeof(in6addr))==0)
  675|      0|                    {
  676|      0|                        continue;
  677|      0|                    }
  678|      0|                }
  679|    341|            }
  680|       |
  681|       |            /* Ignore IPv6 link-local address, unless it is the default
  682|       |             * address (first alias).
  683|       |             */
  684|    341|            if (stun_cfg->af == pj_AF_INET6() && i != 0) {
  ------------------
  |  |  115|    682|#   define pj_AF_INET6()    PJ_AF_INET6
  ------------------
  |  Branch (684:17): [True: 0, False: 341]
  |  Branch (684:50): [True: 0, False: 0]
  ------------------
  685|      0|                const pj_in6_addr *a = &addr->ipv6.sin6_addr;
  686|      0|                if (a->s6_addr[0] == 0xFE && (a->s6_addr[1] & 0xC0) == 0x80)
  ------------------
  |  Branch (686:21): [True: 0, False: 0]
  |  Branch (686:46): [True: 0, False: 0]
  ------------------
  687|      0|                    continue;
  688|      0|            }
  689|       |
  690|       |            /* Add manual host candidates. */
  691|    341|            if (!manual_host_added && stun_cfg->manual_host_cnt) {
  ------------------
  |  Branch (691:17): [True: 341, False: 0]
  |  Branch (691:39): [True: 0, False: 341]
  ------------------
  692|      0|                manual_host_added = PJ_TRUE;
  693|       |
  694|      0|                pj_assert(stun_cfg->manual_host_cnt < PJ_ARRAY_SIZE(
  ------------------
  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (694:17): [True: 0, False: 0]
  |  Branch (694:17): [True: 0, False: 0]
  ------------------
  695|      0|                                                      stun_cfg->manual_host));
  696|      0|                for (j=0; j<stun_cfg->manual_host_cnt &&
  ------------------
  |  Branch (696:27): [True: 0, False: 0]
  ------------------
  697|      0|                          max_cand_cnt && cand_cnt < stun_cfg->max_host_cands;
  ------------------
  |  Branch (697:27): [True: 0, False: 0]
  |  Branch (697:43): [True: 0, False: 0]
  ------------------
  698|      0|                     j++)
  699|      0|                {
  700|       |
  701|       |                    /* Only add the same address family */
  702|      0|                    if (stun_cfg->manual_host[j].addr.sa_family !=
  ------------------
  |  Branch (702:25): [True: 0, False: 0]
  ------------------
  703|      0|                        stun_cfg->af ||
  704|      0|                        !pj_sockaddr_has_addr(&stun_cfg->manual_host[j]))
  ------------------
  |  Branch (704:25): [True: 0, False: 0]
  ------------------
  705|      0|                    {
  706|      0|                        continue;
  707|      0|                    }
  708|       |
  709|      0|                    cand = &comp->cand_list[comp->cand_cnt];
  710|       |
  711|      0|                    cand->type = PJ_ICE_CAND_TYPE_HOST;
  712|      0|                    cand->status = PJ_SUCCESS;
  713|      0|                    cand->local_pref = (pj_uint16_t)(HOST_PREF - cand_cnt);
  ------------------
  |  |   63|      0|#   define HOST_PREF   65535
  ------------------
  714|      0|                    cand->transport_id = CREATE_TP_ID(TP_STUN, idx);
  ------------------
  |  |   51|      0|#define CREATE_TP_ID(type, idx)     (pj_uint8_t)((type << 6) | idx)
  ------------------
  715|      0|                    cand->comp_id = (pj_uint8_t) comp->comp_id;
  716|      0|                    pj_sockaddr_cp(&cand->addr, &stun_cfg->manual_host[j]);
  717|      0|                    pj_sockaddr_set_port(&cand->addr,
  718|      0|                                         pj_sockaddr_get_port(addr));
  719|      0|                    pj_sockaddr_cp(&cand->base_addr, addr);
  720|      0|                    pj_bzero(&cand->rel_addr, sizeof(cand->rel_addr));
  721|       |
  722|      0|                    comp->cand_cnt+=1;
  723|      0|                    cand_cnt++;
  724|      0|                    max_cand_cnt--;
  725|      0|                    pj_ice_calc_foundation(ice_st->pool, &cand->foundation,
  726|      0|                                           cand->type, &cand->base_addr);
  727|       |
  728|       |                    /* Set default candidate with the preferred default
  729|       |                     * address family
  730|       |                     */
  731|      0|                    if (comp->ice_st->cfg.af != pj_AF_UNSPEC() &&
  ------------------
  |  |  109|      0|#   define pj_AF_UNSPEC()   PJ_AF_UNSPEC
  ------------------
  |  Branch (731:25): [True: 0, False: 0]
  ------------------
  732|      0|                        cand->addr.addr.sa_family == comp->ice_st->cfg.af &&
  ------------------
  |  Branch (732:25): [True: 0, False: 0]
  ------------------
  733|      0|                        comp->cand_list[comp->default_cand].base_addr.addr.
  ------------------
  |  Branch (733:25): [True: 0, False: 0]
  ------------------
  734|      0|                                                sa_family != ice_st->cfg.af)
  735|      0|                    {
  736|      0|                        comp->default_cand = (unsigned)
  737|      0|                                             (cand - comp->cand_list);
  738|      0|                    }
  739|       |
  740|      0|                    PJ_LOG(4,(ice_st->obj_name,
  ------------------
  |  |  106|      0|#define PJ_LOG(level,arg)       do { \
  |  |  107|      0|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|      0|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 0, Folded]
  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  480|      0|    #define pj_log_wrapper_4(arg)       pj_log_4 arg
  |  |  ------------------
  |  |  109|      0|                                    } \
  |  |  110|      0|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 0]
  |  |  ------------------
  ------------------
  741|      0|                              "Comp %d/%d: host candidate %s (tpid=%d) added",
  742|      0|                              comp->comp_id, comp->cand_cnt-1, 
  743|      0|                              pj_sockaddr_print(&cand->addr, addrinfo,
  744|      0|                                                sizeof(addrinfo), 3),
  745|      0|                                                cand->transport_id));
  746|      0|                }
  747|       |
  748|      0|                if (max_cand_cnt == 0 || cand_cnt >= stun_cfg->max_host_cands)
  ------------------
  |  Branch (748:21): [True: 0, False: 0]
  |  Branch (748:42): [True: 0, False: 0]
  ------------------
  749|      0|                    break;
  750|      0|            }
  751|       |
  752|    341|            cand = &comp->cand_list[comp->cand_cnt];
  753|       |
  754|    341|            cand->type = PJ_ICE_CAND_TYPE_HOST;
  755|    341|            cand->status = PJ_SUCCESS;
  756|    341|            cand->local_pref = (pj_uint16_t)(HOST_PREF - cand_cnt);
  ------------------
  |  |   63|    341|#   define HOST_PREF   65535
  ------------------
  757|    341|            cand->transport_id = CREATE_TP_ID(TP_STUN, idx);
  ------------------
  |  |   51|    341|#define CREATE_TP_ID(type, idx)     (pj_uint8_t)((type << 6) | idx)
  ------------------
  758|    341|            cand->comp_id = (pj_uint8_t) comp->comp_id;
  759|    341|            pj_sockaddr_cp(&cand->addr, addr);
  760|    341|            pj_sockaddr_cp(&cand->base_addr, addr);
  761|    341|            pj_bzero(&cand->rel_addr, sizeof(cand->rel_addr));
  762|       |            
  763|       |            /* Check if not already in list */
  764|    341|            for (j=0; j<comp->cand_cnt; j++) {
  ------------------
  |  Branch (764:23): [True: 0, False: 341]
  ------------------
  765|      0|                if (ice_cand_equals(cand, &comp->cand_list[j])) {
  ------------------
  |  Branch (765:21): [True: 0, False: 0]
  ------------------
  766|      0|                    cand_duplicate = PJ_TRUE;
  767|      0|                    break;
  768|      0|                }
  769|      0|            }
  770|       |
  771|    341|            if (cand_duplicate) {
  ------------------
  |  Branch (771:17): [True: 0, False: 341]
  ------------------
  772|      0|                PJ_LOG(4, (ice_st->obj_name,
  ------------------
  |  |  106|      0|#define PJ_LOG(level,arg)       do { \
  |  |  107|      0|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|      0|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 0, Folded]
  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  480|      0|    #define pj_log_wrapper_4(arg)       pj_log_4 arg
  |  |  ------------------
  |  |  109|      0|                                    } \
  |  |  110|      0|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 0]
  |  |  ------------------
  ------------------
  773|      0|                       "Comp %d: host candidate %s (tpid=%d) is a duplicate",
  774|      0|                       comp->comp_id, pj_sockaddr_print(&cand->addr, addrinfo,
  775|      0|                       sizeof(addrinfo), 3), cand->transport_id));
  776|       |
  777|      0|                pj_bzero(&cand->addr, sizeof(cand->addr));
  778|      0|                pj_bzero(&cand->base_addr, sizeof(cand->base_addr));
  779|      0|                continue;
  780|    341|            } else {
  781|    341|                comp->cand_cnt+=1;
  782|    341|                cand_cnt++;
  783|    341|                max_cand_cnt--;
  784|    341|            }
  785|       |            
  786|    341|            pj_ice_calc_foundation(ice_st->pool, &cand->foundation,
  787|    341|                                   cand->type, &cand->base_addr);
  788|       |
  789|       |            /* Set default candidate with the preferred default
  790|       |             * address family
  791|       |             */
  792|    341|            if (comp->ice_st->cfg.af != pj_AF_UNSPEC() &&
  ------------------
  |  |  109|    682|#   define pj_AF_UNSPEC()   PJ_AF_UNSPEC
  ------------------
  |  Branch (792:17): [True: 341, False: 0]
  ------------------
  793|    341|                addr->addr.sa_family == comp->ice_st->cfg.af &&
  ------------------
  |  Branch (793:17): [True: 341, False: 0]
  ------------------
  794|    341|                comp->cand_list[comp->default_cand].base_addr.addr.sa_family !=
  ------------------
  |  Branch (794:17): [True: 0, False: 341]
  ------------------
  795|    341|                ice_st->cfg.af)
  796|      0|            {
  797|      0|                comp->default_cand = (unsigned)(cand - comp->cand_list);
  798|      0|            }
  799|       |
  800|    341|            PJ_LOG(4,(ice_st->obj_name,
  ------------------
  |  |  106|    341|#define PJ_LOG(level,arg)       do { \
  |  |  107|    341|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|    682|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 341, Folded]
  |  |  |  Branch (107:70): [True: 0, False: 341]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  480|      0|    #define pj_log_wrapper_4(arg)       pj_log_4 arg
  |  |  ------------------
  |  |  109|      0|                                    } \
  |  |  110|    341|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 341]
  |  |  ------------------
  ------------------
  801|    341|                      "Comp %d/%d: host candidate %s (tpid=%d) added",
  802|    341|                      comp->comp_id, comp->cand_cnt-1, 
  803|    341|                      pj_sockaddr_print(&cand->addr, addrinfo,
  804|    341|                                        sizeof(addrinfo), 3),
  805|    341|                                        cand->transport_id));
  806|    341|        }
  807|    341|    }
  808|       |
  809|    341|    return status;
  810|    341|}
ice_strans.c:ice_st_on_destroy:
 1050|    341|{
 1051|    341|    pj_ice_strans *ice_st = (pj_ice_strans*)obj;
 1052|       |
 1053|       |    /* Destroy any previous ICE session */
 1054|    341|    if (ice_st->ice_prev) {
  ------------------
  |  Branch (1054:9): [True: 0, False: 341]
  ------------------
 1055|      0|        (*ice_st->ice_prev_hndlr)(ice_st->ice_prev);
 1056|      0|        ice_st->ice_prev = NULL;
 1057|      0|    }
 1058|       |
 1059|    341|    PJ_LOG(4,(ice_st->obj_name, "ICE stream transport %p destroyed", obj));
  ------------------
  |  |  106|    341|#define PJ_LOG(level,arg)       do { \
  |  |  107|    341|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|    682|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 341, Folded]
  |  |  |  Branch (107:70): [True: 0, False: 341]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  480|      0|    #define pj_log_wrapper_4(arg)       pj_log_4 arg
  |  |  ------------------
  |  |  109|      0|                                    } \
  |  |  110|    341|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 341]
  |  |  ------------------
  ------------------
 1060|       |
 1061|       |    /* Done */
 1062|    341|    pj_pool_safe_release(&ice_st->buf_pool);
 1063|    341|    pj_pool_safe_release(&ice_st->pool);
 1064|    341|}
ice_strans.c:destroy_ice_st:
 1068|    341|{
 1069|    341|    unsigned i;
 1070|       |
 1071|    341|    PJ_LOG(5,(ice_st->obj_name, "ICE stream transport %p destroy request..",
  ------------------
  |  |  106|    341|#define PJ_LOG(level,arg)       do { \
  |  |  107|    341|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|    682|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 341, Folded]
  |  |  |  Branch (107:70): [True: 0, False: 341]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  496|      0|    #define pj_log_wrapper_5(arg)       pj_log_5 arg
  |  |  ------------------
  |  |  109|      0|                                    } \
  |  |  110|    341|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 341]
  |  |  ------------------
  ------------------
 1072|    341|              ice_st));
 1073|    341|    pj_log_push_indent();
 1074|       |
 1075|       |    /* Reset callback and user data */
 1076|    341|    pj_bzero(&ice_st->cb, sizeof(ice_st->cb));
 1077|    341|    ice_st->user_data = NULL;
 1078|       |
 1079|    341|    pj_grp_lock_acquire(ice_st->grp_lock);
 1080|       |
 1081|    341|    if (ice_st->destroy_req) {
  ------------------
  |  Branch (1081:9): [True: 0, False: 341]
  ------------------
 1082|      0|        pj_grp_lock_release(ice_st->grp_lock);
 1083|      0|        pj_log_pop_indent();
 1084|      0|        return;
 1085|      0|    }
 1086|       |
 1087|    341|    ice_st->destroy_req = PJ_TRUE;
 1088|       |
 1089|       |    /* Destroy ICE if we have ICE */
 1090|    341|    if (ice_st->ice) {
  ------------------
  |  Branch (1090:9): [True: 341, False: 0]
  ------------------
 1091|    341|        pj_ice_sess *ice = ice_st->ice;
 1092|    341|        ice_st->ice = NULL;
 1093|    341|        pj_ice_sess_destroy(ice);
 1094|    341|    }
 1095|       |
 1096|       |    /* Destroy all components */
 1097|    682|    for (i=0; i<ice_st->comp_cnt; ++i) {
  ------------------
  |  Branch (1097:15): [True: 341, False: 341]
  ------------------
 1098|    341|        if (ice_st->comp[i]) {
  ------------------
  |  Branch (1098:13): [True: 341, False: 0]
  ------------------
 1099|    341|            pj_ice_strans_comp *comp = ice_st->comp[i];
 1100|    341|            unsigned j;
 1101|    682|            for (j = 0; j < ice_st->cfg.stun_tp_cnt; ++j) {
  ------------------
  |  Branch (1101:25): [True: 341, False: 341]
  ------------------
 1102|    341|                if (comp->stun[j].sock) {
  ------------------
  |  Branch (1102:21): [True: 341, False: 0]
  ------------------
 1103|    341|                    pj_stun_sock_destroy(comp->stun[j].sock);
 1104|    341|                    comp->stun[j].sock = NULL;
 1105|    341|                }
 1106|    341|            }
 1107|    341|            for (j = 0; j < ice_st->cfg.turn_tp_cnt; ++j) {
  ------------------
  |  Branch (1107:25): [True: 0, False: 341]
  ------------------
 1108|      0|                if (comp->turn[j].sock) {
  ------------------
  |  Branch (1108:21): [True: 0, False: 0]
  ------------------
 1109|      0|                    pj_turn_sock_destroy(comp->turn[j].sock);
 1110|      0|                    comp->turn[j].sock = NULL;
 1111|      0|                }
 1112|      0|            }
 1113|    341|        }
 1114|    341|    }
 1115|       |
 1116|    341|    pj_grp_lock_dec_ref(ice_st->grp_lock);
 1117|    341|    pj_grp_lock_release(ice_st->grp_lock);
 1118|       |
 1119|    341|    pj_log_pop_indent();
 1120|    341|}
ice_strans.c:sess_init_update:
 1168|    341|{
 1169|    341|    unsigned i;
 1170|    341|    pj_status_t status = PJ_EUNKNOWN;
  ------------------
  |  |  378|    341|#define PJ_EUNKNOWN         (PJ_ERRNO_START_STATUS + 1) /* 70001 */
  |  |  ------------------
  |  |  |  |  521|    341|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|    341|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|    341|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1171|       |
 1172|       |    /* Ignore if ICE is destroying or init callback has been called */
 1173|    341|    if (ice_st->destroy_req || ice_st->cb_called)
  ------------------
  |  Branch (1173:9): [True: 0, False: 341]
  |  Branch (1173:32): [True: 0, False: 341]
  ------------------
 1174|      0|        return;
 1175|       |
 1176|       |    /* Notify application when all candidates have been gathered */
 1177|    682|    for (i=0; i<ice_st->comp_cnt; ++i) {
  ------------------
  |  Branch (1177:15): [True: 341, False: 341]
  ------------------
 1178|    341|        unsigned j;
 1179|    341|        pj_ice_strans_comp *comp = ice_st->comp[i];
 1180|       |
 1181|       |        /* This function can be called when all components or candidates
 1182|       |         * have not been created.
 1183|       |         */
 1184|    341|        if (!comp || comp->creating) {
  ------------------
  |  Branch (1184:13): [True: 0, False: 341]
  |  Branch (1184:22): [True: 0, False: 341]
  ------------------
 1185|      0|            PJ_LOG(5, (ice_st->obj_name, "ICE init update: creating comp %d",
  ------------------
  |  |  106|      0|#define PJ_LOG(level,arg)       do { \
  |  |  107|      0|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|      0|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 0, Folded]
  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  496|      0|    #define pj_log_wrapper_5(arg)       pj_log_5 arg
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (496:50): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  109|      0|                                    } \
  |  |  110|      0|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1186|      0|                       (comp?comp->comp_id:(i+1)) ));
 1187|      0|            return;
 1188|      0|        }
 1189|       |
 1190|    341|        status = PJ_EUNKNOWN;
  ------------------
  |  |  378|    341|#define PJ_EUNKNOWN         (PJ_ERRNO_START_STATUS + 1) /* 70001 */
  |  |  ------------------
  |  |  |  |  521|    341|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|    341|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|    341|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1191|    682|        for (j=0; j<comp->cand_cnt; ++j) {
  ------------------
  |  Branch (1191:19): [True: 341, False: 341]
  ------------------
 1192|    341|            pj_ice_sess_cand *cand = &comp->cand_list[j];
 1193|       |
 1194|    341|            if (cand->status == PJ_EPENDING) {
  ------------------
  |  |  383|    341|#define PJ_EPENDING         (PJ_ERRNO_START_STATUS + 2) /* 70002 */
  |  |  ------------------
  |  |  |  |  521|    341|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|    341|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|    341|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (1194:17): [True: 0, False: 341]
  ------------------
 1195|      0|                PJ_LOG(5, (ice_st->obj_name, "ICE init update: "
  ------------------
  |  |  106|      0|#define PJ_LOG(level,arg)       do { \
  |  |  107|      0|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|      0|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 0, Folded]
  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  496|      0|    #define pj_log_wrapper_5(arg)       pj_log_5 arg
  |  |  ------------------
  |  |  109|      0|                                    } \
  |  |  110|      0|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1196|      0|                           "comp %d/%d[%s] is pending",
 1197|      0|                           comp->comp_id, j,
 1198|      0|                           pj_ice_get_cand_type_name(cand->type)));
 1199|      0|                return;
 1200|      0|            }
 1201|       |            
 1202|    341|            if (status == PJ_EUNKNOWN) {
  ------------------
  |  |  378|    341|#define PJ_EUNKNOWN         (PJ_ERRNO_START_STATUS + 1) /* 70001 */
  |  |  ------------------
  |  |  |  |  521|    341|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|    341|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|    341|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (1202:17): [True: 341, False: 0]
  ------------------
 1203|    341|                status = cand->status;
 1204|    341|            } else {
 1205|       |                /* We only need one successful candidate. */
 1206|      0|                if (cand->status == PJ_SUCCESS)
  ------------------
  |  Branch (1206:21): [True: 0, False: 0]
  ------------------
 1207|      0|                    status = PJ_SUCCESS;
 1208|      0|            }
 1209|    341|        }
 1210|       |        
 1211|    341|        if (status != PJ_SUCCESS)
  ------------------
  |  Branch (1211:13): [True: 0, False: 341]
  ------------------
 1212|      0|            break;
 1213|    341|    }
 1214|       |
 1215|       |    /* All candidates have been gathered or there's no successful
 1216|       |     * candidate for a component.
 1217|       |     */
 1218|    341|    ice_st->cb_called = PJ_TRUE;
 1219|    341|    ice_st->state = PJ_ICE_STRANS_STATE_READY;
 1220|    341|    if (ice_st->cb.on_ice_complete)
  ------------------
  |  Branch (1220:9): [True: 341, False: 0]
  ------------------
 1221|    341|        (*ice_st->cb.on_ice_complete)(ice_st, PJ_ICE_STRANS_OP_INIT,
 1222|    341|                                      status);
 1223|       |
 1224|       |    /* Tell ICE session that trickling is done */
 1225|    341|    ice_st->loc_cand_end = PJ_TRUE;
 1226|    341|    if (ice_st->ice && ice_st->ice->is_trickling && ice_st->rem_cand_end) {
  ------------------
  |  Branch (1226:9): [True: 0, False: 341]
  |  Branch (1226:24): [True: 0, False: 0]
  |  Branch (1226:53): [True: 0, False: 0]
  ------------------
 1227|      0|        pj_ice_sess_update_check_list(ice_st->ice, NULL, NULL, 0, NULL,
 1228|      0|                                      PJ_TRUE);
 1229|      0|    }
 1230|    341|}

pj_stun_auth_cred_dup:
   35|  1.57k|{
   36|  1.57k|    dst->type = src->type;
   37|       |
   38|  1.57k|    switch (src->type) {
  ------------------
  |  Branch (38:13): [True: 1.57k, False: 0]
  ------------------
   39|  1.23k|    case PJ_STUN_AUTH_CRED_STATIC:
  ------------------
  |  Branch (39:5): [True: 1.23k, False: 341]
  ------------------
   40|  1.23k|        pj_strdup(pool, &dst->data.static_cred.realm,
   41|  1.23k|                        &src->data.static_cred.realm);
   42|  1.23k|        pj_strdup(pool, &dst->data.static_cred.username,
   43|  1.23k|                        &src->data.static_cred.username);
   44|  1.23k|        dst->data.static_cred.data_type = src->data.static_cred.data_type;
   45|  1.23k|        pj_strdup(pool, &dst->data.static_cred.data,
   46|  1.23k|                        &src->data.static_cred.data);
   47|  1.23k|        pj_strdup(pool, &dst->data.static_cred.nonce,
   48|  1.23k|                        &src->data.static_cred.nonce);
   49|  1.23k|        break;
   50|    341|    case PJ_STUN_AUTH_CRED_DYNAMIC:
  ------------------
  |  Branch (50:5): [True: 341, False: 1.23k]
  ------------------
   51|    341|        pj_memcpy(&dst->data.dyn_cred, &src->data.dyn_cred, 
   52|    341|                  sizeof(src->data.dyn_cred));
   53|    341|        break;
   54|  1.57k|    }
   55|  1.57k|}
pj_stun_create_key:
  133|  1.68k|{
  134|  1.68k|    PJ_ASSERT_ON_FAIL(pool && key && username && data, return);
  ------------------
  |  |  111|  1.68k|            { \
  |  |  112|  1.68k|                pj_assert(expr); \
  |  |  ------------------
  |  |  |  |   65|  1.68k|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  113|  10.0k|                if (!(expr)) exec_on_fail; \
  |  |  ------------------
  |  |  |  Branch (113:23): [True: 1.68k, False: 0]
  |  |  |  Branch (113:23): [True: 1.68k, False: 0]
  |  |  |  Branch (113:23): [True: 1.68k, False: 0]
  |  |  |  Branch (113:23): [True: 1.68k, False: 0]
  |  |  ------------------
  |  |  114|  1.68k|            }
  ------------------
  |  Branch (134:5): [True: 0, False: 1.68k]
  |  Branch (134:5): [True: 0, False: 0]
  |  Branch (134:5): [True: 0, False: 0]
  |  Branch (134:5): [True: 0, False: 0]
  |  Branch (134:5): [True: 1.68k, False: 0]
  |  Branch (134:5): [True: 1.68k, False: 0]
  |  Branch (134:5): [True: 1.68k, False: 0]
  |  Branch (134:5): [True: 1.68k, False: 0]
  ------------------
  135|       |
  136|  1.68k|    if (realm && realm->slen) {
  ------------------
  |  Branch (136:9): [True: 1.68k, False: 0]
  |  Branch (136:18): [True: 1.47k, False: 211]
  ------------------
  137|  1.47k|        if (data_type == PJ_STUN_PASSWD_PLAIN) {
  ------------------
  |  Branch (137:13): [True: 1.47k, False: 0]
  ------------------
  138|  1.47k|            key->ptr = (char*) pj_pool_alloc(pool, 16);
  139|  1.47k|            calc_md5_key((pj_uint8_t*)key->ptr, realm, username, data);
  140|  1.47k|            key->slen = 16;
  141|  1.47k|        } else {
  142|      0|            pj_strdup(pool, key, data);
  143|      0|        }
  144|  1.47k|    } else {
  145|    211|        pj_assert(data_type == PJ_STUN_PASSWD_PLAIN);
  ------------------
  |  |   65|    211|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (145:9): [True: 0, False: 211]
  |  Branch (145:9): [True: 211, False: 0]
  ------------------
  146|    211|        pj_strdup(pool, key, data);
  147|    211|    }
  148|  1.68k|}
pj_stun_authenticate_request:
  221|    958|{
  222|    958|    pj_stun_req_cred_info tmp_info;
  223|    958|    const pj_stun_msgint_attr *amsgi;
  224|    958|    unsigned i, amsgi_pos;
  225|    958|    pj_bool_t has_attr_beyond_mi;
  226|    958|    const pj_stun_username_attr *auser;
  227|    958|    const pj_stun_realm_attr *arealm;
  228|    958|    const pj_stun_realm_attr *anonce;
  229|    958|    pj_hmac_sha1_context ctx;
  230|    958|    pj_uint8_t digest[PJ_SHA1_DIGEST_SIZE];
  231|    958|    pj_stun_status err_code;
  232|    958|    const char *err_text = NULL;
  233|    958|    pj_status_t status;
  234|       |
  235|       |    /* msg and credential MUST be specified */
  236|    958|    PJ_ASSERT_RETURN(pkt && pkt_len && msg && cred, PJ_EINVAL);
  ------------------
  |  |   97|    958|            do { \
  |  |   98|  5.74k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 958, False: 0]
  |  |  |  Branch (98:23): [True: 958, False: 0]
  |  |  |  Branch (98:23): [True: 958, False: 0]
  |  |  |  Branch (98:23): [True: 958, False: 0]
  |  |  ------------------
  |  |   99|    958|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 958]
  |  |  ------------------
  ------------------
  |  Branch (236:5): [True: 0, False: 0]
  |  Branch (236:5): [True: 0, False: 0]
  |  Branch (236:5): [True: 0, False: 0]
  |  Branch (236:5): [True: 0, False: 0]
  |  Branch (236:5): [True: 0, False: 0]
  |  Branch (236:5): [True: 0, False: 0]
  |  Branch (236:5): [True: 0, False: 0]
  |  Branch (236:5): [True: 0, False: 0]
  ------------------
  237|       |
  238|       |    /* If p_response is specified, pool MUST be specified. */
  239|    958|    PJ_ASSERT_RETURN(!p_response || pool, PJ_EINVAL);
  ------------------
  |  |   97|    958|            do { \
  |  |   98|  1.25k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 659, False: 299]
  |  |  |  Branch (98:23): [True: 299, False: 0]
  |  |  ------------------
  |  |   99|    958|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 958]
  |  |  ------------------
  ------------------
  |  Branch (239:5): [True: 0, False: 0]
  |  Branch (239:5): [True: 0, False: 0]
  |  Branch (239:5): [True: 0, False: 0]
  |  Branch (239:5): [True: 0, False: 0]
  ------------------
  240|       |
  241|    958|    if (p_response)
  ------------------
  |  Branch (241:9): [True: 299, False: 659]
  ------------------
  242|    299|        *p_response = NULL;
  243|       |
  244|    958|    if (!PJ_STUN_IS_REQUEST(msg->hdr.type))
  ------------------
  |  |  153|    958|#define PJ_STUN_IS_REQUEST(msg_type)    (((msg_type) & 0x0110) == 0x0000)
  ------------------
  |  Branch (244:9): [True: 151, False: 807]
  ------------------
  245|    151|        p_response = NULL;
  246|       |
  247|    958|    if (p_info == NULL)
  ------------------
  |  Branch (247:9): [True: 659, False: 299]
  ------------------
  248|    659|        p_info = &tmp_info;
  249|       |
  250|    958|    pj_bzero(p_info, sizeof(pj_stun_req_cred_info));
  251|       |
  252|       |    /* Get realm and nonce from credential */
  253|    958|    p_info->realm.slen = p_info->nonce.slen = 0;
  254|    958|    if (cred->type == PJ_STUN_AUTH_CRED_STATIC) {
  ------------------
  |  Branch (254:9): [True: 958, False: 0]
  ------------------
  255|    958|        p_info->realm = cred->data.static_cred.realm;
  256|    958|        p_info->nonce = cred->data.static_cred.nonce;
  257|    958|    } else if (cred->type == PJ_STUN_AUTH_CRED_DYNAMIC) {
  ------------------
  |  Branch (257:16): [True: 0, False: 0]
  ------------------
  258|      0|        status = cred->data.dyn_cred.get_auth(cred->data.dyn_cred.user_data,
  259|      0|                                              pool, &p_info->realm, 
  260|      0|                                              &p_info->nonce);
  261|      0|        if (status != PJ_SUCCESS)
  ------------------
  |  Branch (261:13): [True: 0, False: 0]
  ------------------
  262|      0|            return status;
  263|      0|    } else {
  264|      0|        pj_assert(!"Invalid credential type");
  ------------------
  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (264:9): [Folded, False: 0]
  |  Branch (264:9): [Folded, False: 0]
  ------------------
  265|      0|        return PJ_EBUG;
  ------------------
  |  |  413|      0|#define PJ_EBUG             (PJ_ERRNO_START_STATUS + 8) /* 70008 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  266|      0|    }
  267|       |
  268|       |    /* Look for MESSAGE-INTEGRITY while counting the position */
  269|    958|    amsgi_pos = 0;
  270|    958|    has_attr_beyond_mi = PJ_FALSE;
  271|    958|    amsgi = NULL;
  272|  4.29k|    for (i=0; i<msg->attr_count; ++i) {
  ------------------
  |  Branch (272:15): [True: 3.90k, False: 393]
  ------------------
  273|  3.90k|        if (msg->attr[i]->type == PJ_STUN_ATTR_MESSAGE_INTEGRITY) {
  ------------------
  |  Branch (273:13): [True: 677, False: 3.22k]
  ------------------
  274|    677|            amsgi = (const pj_stun_msgint_attr*) msg->attr[i];
  275|  3.22k|        } else if (amsgi) {
  ------------------
  |  Branch (275:20): [True: 565, False: 2.65k]
  ------------------
  276|    565|            has_attr_beyond_mi = PJ_TRUE;
  277|    565|            break;
  278|  2.65k|        } else {
  279|  2.65k|            amsgi_pos += ((msg->attr[i]->length+3) & ~0x03) + 4;
  280|  2.65k|        }
  281|  3.90k|    }
  282|       |
  283|    958|    if (amsgi == NULL) {
  ------------------
  |  Branch (283:9): [True: 281, False: 677]
  ------------------
  284|       |        /* According to rfc3489bis-10 Sec 10.1.2/10.2.2, we should return 400
  285|       |           for short term, and 401 for long term.
  286|       |           The rule has been changed from rfc3489bis-06
  287|       |        */
  288|    281|        err_code = p_info->realm.slen ? PJ_STUN_SC_UNAUTHORIZED : 
  ------------------
  |  Branch (288:20): [True: 244, False: 37]
  ------------------
  289|    281|                    PJ_STUN_SC_BAD_REQUEST;
  290|    281|        goto on_auth_failed;
  291|    281|    }
  292|       |
  293|       |    /* Next check that USERNAME is present */
  294|    677|    auser = (const pj_stun_username_attr*)
  295|    677|            pj_stun_msg_find_attr(msg, PJ_STUN_ATTR_USERNAME, 0);
  296|    677|    if (auser == NULL) {
  ------------------
  |  Branch (296:9): [True: 6, False: 671]
  ------------------
  297|       |        /* According to rfc3489bis-10 Sec 10.1.2/10.2.2, we should return 400
  298|       |           for both short and long term, since M-I is present.
  299|       |           The rule has been changed from rfc3489bis-06
  300|       |        */
  301|      6|        err_code = PJ_STUN_SC_BAD_REQUEST;
  302|      6|        err_text = "Missing USERNAME";
  303|      6|        goto on_auth_failed;
  304|      6|    }
  305|       |
  306|       |    /* Get REALM, if any */
  307|    671|    arealm = (const pj_stun_realm_attr*)
  308|    671|             pj_stun_msg_find_attr(msg, PJ_STUN_ATTR_REALM, 0);
  309|       |
  310|       |    /* Reject with 400 if we have long term credential and the request
  311|       |     * is missing REALM attribute.
  312|       |     */
  313|    671|    if (p_info->realm.slen && arealm==NULL) {
  ------------------
  |  Branch (313:9): [True: 410, False: 261]
  |  Branch (313:31): [True: 89, False: 321]
  ------------------
  314|     89|        err_code = PJ_STUN_SC_BAD_REQUEST;
  315|     89|        err_text = "Missing REALM";
  316|     89|        goto on_auth_failed;
  317|     89|    }
  318|       |
  319|       |    /* Check if username match */
  320|    582|    if (cred->type == PJ_STUN_AUTH_CRED_STATIC) {
  ------------------
  |  Branch (320:9): [True: 582, False: 0]
  ------------------
  321|    582|        pj_bool_t username_ok;
  322|    582|        username_ok = !pj_strcmp(&auser->value, 
  323|    582|                                 &cred->data.static_cred.username);
  324|    582|        if (username_ok) {
  ------------------
  |  Branch (324:13): [True: 438, False: 144]
  ------------------
  325|    438|            pj_strdup(pool, &p_info->username, 
  326|    438|                      &cred->data.static_cred.username);
  327|    438|            pj_stun_create_key(pool, &p_info->auth_key, &p_info->realm,
  328|    438|                               &auser->value, cred->data.static_cred.data_type,
  329|    438|                               &cred->data.static_cred.data);
  330|       |            /* Unlikely to happen but this makes static analyzers happy */
  331|    438|            PJ_ASSERT_RETURN(p_info->auth_key.ptr, PJ_EBUG);
  ------------------
  |  |   97|    438|            do { \
  |  |   98|    438|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 438]
  |  |  ------------------
  |  |   99|    438|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 438]
  |  |  ------------------
  ------------------
  |  Branch (331:13): [True: 0, False: 0]
  |  Branch (331:13): [True: 0, False: 0]
  ------------------
  332|    438|        } else {
  333|       |            /* Username mismatch */
  334|       |            /* According to rfc3489bis-10 Sec 10.1.2/10.2.2, we should 
  335|       |             * return 401 
  336|       |             */
  337|    144|            err_code = PJ_STUN_SC_UNAUTHORIZED;
  338|    144|            goto on_auth_failed;
  339|    144|        }
  340|    582|    } else if (cred->type == PJ_STUN_AUTH_CRED_DYNAMIC) {
  ------------------
  |  Branch (340:16): [True: 0, False: 0]
  ------------------
  341|      0|        pj_stun_passwd_type data_type = PJ_STUN_PASSWD_PLAIN;
  342|      0|        pj_str_t password;
  343|      0|        pj_status_t rc;
  344|       |
  345|      0|        rc = cred->data.dyn_cred.get_password(msg, 
  346|      0|                                              cred->data.dyn_cred.user_data,
  347|      0|                                              (arealm?&arealm->value:NULL),
  ------------------
  |  Branch (347:48): [True: 0, False: 0]
  ------------------
  348|      0|                                              &auser->value, pool,
  349|      0|                                              &data_type, &password);
  350|      0|        if (rc == PJ_SUCCESS) {
  ------------------
  |  Branch (350:13): [True: 0, False: 0]
  ------------------
  351|      0|            pj_strdup(pool, &p_info->username, &auser->value);
  352|      0|            pj_stun_create_key(pool, &p_info->auth_key, 
  353|      0|                               (arealm?&arealm->value:NULL), &auser->value, 
  ------------------
  |  Branch (353:33): [True: 0, False: 0]
  ------------------
  354|      0|                               data_type, &password);
  355|       |            /* Unlikely to happen but this makes static analyzers happy */
  356|      0|            PJ_ASSERT_RETURN(p_info->auth_key.ptr, PJ_EBUG);
  ------------------
  |  |   97|      0|            do { \
  |  |   98|      0|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 0]
  |  |  ------------------
  |  |   99|      0|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (356:13): [True: 0, False: 0]
  |  Branch (356:13): [True: 0, False: 0]
  ------------------
  357|      0|        } else {
  358|      0|            err_code = PJ_STUN_SC_UNAUTHORIZED;
  359|      0|            goto on_auth_failed;
  360|      0|        }
  361|      0|    } else {
  362|      0|        pj_assert(!"Invalid credential type");
  ------------------
  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (362:9): [Folded, False: 0]
  |  Branch (362:9): [Folded, False: 0]
  ------------------
  363|      0|        return PJ_EBUG;
  ------------------
  |  |  413|      0|#define PJ_EBUG             (PJ_ERRNO_START_STATUS + 8) /* 70008 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  364|      0|    }
  365|       |
  366|       |
  367|       |
  368|       |    /* Get NONCE attribute */
  369|    438|    anonce = (pj_stun_nonce_attr*)
  370|    438|             pj_stun_msg_find_attr(msg, PJ_STUN_ATTR_NONCE, 0);
  371|       |
  372|       |    /* Check for long term/short term requirements. */
  373|    438|    if (p_info->realm.slen != 0 && arealm == NULL) {
  ------------------
  |  Branch (373:9): [True: 227, False: 211]
  |  Branch (373:36): [True: 0, False: 227]
  ------------------
  374|       |        /* Long term credential is required and REALM is not present */
  375|      0|        err_code = PJ_STUN_SC_BAD_REQUEST;
  376|      0|        err_text = "Missing REALM";
  377|      0|        goto on_auth_failed;
  378|       |
  379|    438|    } else if (p_info->realm.slen != 0 && arealm != NULL) {
  ------------------
  |  Branch (379:16): [True: 227, False: 211]
  |  Branch (379:43): [True: 227, False: 0]
  ------------------
  380|       |        /* We want long term, and REALM is present */
  381|       |
  382|       |        /* NONCE must be present. */
  383|    227|        if (anonce == NULL && p_info->nonce.slen) {
  ------------------
  |  Branch (383:13): [True: 4, False: 223]
  |  Branch (383:31): [True: 4, False: 0]
  ------------------
  384|      4|            err_code = PJ_STUN_SC_BAD_REQUEST;
  385|      4|            err_text = "Missing NONCE";
  386|      4|            goto on_auth_failed;
  387|      4|        }
  388|       |
  389|       |        /* Verify REALM matches */
  390|    223|        if (pj_stricmp(&arealm->value, &p_info->realm)) {
  ------------------
  |  Branch (390:13): [True: 158, False: 65]
  ------------------
  391|       |            /* REALM doesn't match */
  392|    158|            err_code = PJ_STUN_SC_UNAUTHORIZED;
  393|    158|            err_text = "Invalid REALM";
  394|    158|            goto on_auth_failed;
  395|    158|        }
  396|       |
  397|       |        /* Valid case, will validate the message integrity later */
  398|       |
  399|    223|    } else if (p_info->realm.slen == 0 && arealm != NULL) {
  ------------------
  |  Branch (399:16): [True: 211, False: 0]
  |  Branch (399:43): [True: 143, False: 68]
  ------------------
  400|       |        /* We want to use short term credential, but client uses long
  401|       |         * term credential. The draft doesn't mention anything about
  402|       |         * switching between long term and short term.
  403|       |         */
  404|       |        
  405|       |        /* For now just accept the credential, anyway it will probably
  406|       |         * cause wrong message integrity value later.
  407|       |         */
  408|    143|    } else if (p_info->realm.slen==0 && arealm == NULL) {
  ------------------
  |  Branch (408:16): [True: 68, False: 0]
  |  Branch (408:41): [True: 68, False: 0]
  ------------------
  409|       |        /* Short term authentication is wanted, and one is supplied */
  410|       |
  411|       |        /* Application MAY request NONCE to be supplied */
  412|     68|        if (p_info->nonce.slen != 0) {
  ------------------
  |  Branch (412:13): [True: 0, False: 68]
  ------------------
  413|      0|            err_code = PJ_STUN_SC_UNAUTHORIZED;
  414|      0|            err_text = "NONCE required";
  415|      0|            goto on_auth_failed;
  416|      0|        }
  417|     68|    }
  418|       |
  419|       |    /* If NONCE is present, validate it */
  420|    276|    if (anonce) {
  ------------------
  |  Branch (420:9): [True: 207, False: 69]
  ------------------
  421|    207|        pj_bool_t ok;
  422|       |
  423|    207|        if (cred->type == PJ_STUN_AUTH_CRED_DYNAMIC &&
  ------------------
  |  Branch (423:13): [True: 0, False: 207]
  ------------------
  424|      0|            cred->data.dyn_cred.verify_nonce != NULL) 
  ------------------
  |  Branch (424:13): [True: 0, False: 0]
  ------------------
  425|      0|        {
  426|      0|            ok=cred->data.dyn_cred.verify_nonce(msg, 
  427|      0|                                                cred->data.dyn_cred.user_data,
  428|      0|                                                (arealm?&arealm->value:NULL),
  ------------------
  |  Branch (428:50): [True: 0, False: 0]
  ------------------
  429|      0|                                                &auser->value,
  430|      0|                                                &anonce->value);
  431|    207|        } else if (cred->type == PJ_STUN_AUTH_CRED_DYNAMIC) {
  ------------------
  |  Branch (431:20): [True: 0, False: 207]
  ------------------
  432|      0|            ok = PJ_TRUE;
  433|    207|        } else {
  434|    207|            if (p_info->nonce.slen) {
  ------------------
  |  Branch (434:17): [True: 65, False: 142]
  ------------------
  435|     65|                ok = !pj_strcmp(&anonce->value, &p_info->nonce);
  436|    142|            } else {
  437|    142|                ok = PJ_TRUE;
  438|    142|            }
  439|    207|        }
  440|       |
  441|    207|        if (!ok) {
  ------------------
  |  Branch (441:13): [True: 45, False: 162]
  ------------------
  442|     45|            err_code = PJ_STUN_SC_STALE_NONCE;
  443|     45|            goto on_auth_failed;
  444|     45|        }
  445|    207|    }
  446|       |
  447|       |    /* Now calculate HMAC of the message. */
  448|    231|    pj_hmac_sha1_init(&ctx, (pj_uint8_t*)p_info->auth_key.ptr, 
  449|    231|                      (unsigned)p_info->auth_key.slen);
  450|       |
  451|       |#if PJ_STUN_OLD_STYLE_MI_FINGERPRINT
  452|       |    /* Pre rfc3489bis-06 style of calculation */
  453|       |    pj_hmac_sha1_update(&ctx, pkt, 20);
  454|       |#else
  455|       |    /* First calculate HMAC for the header.
  456|       |     * The calculation is different depending on whether FINGERPRINT attribute
  457|       |     * is present in the message.
  458|       |     */
  459|    231|    if (has_attr_beyond_mi) {
  ------------------
  |  Branch (459:9): [True: 210, False: 21]
  ------------------
  460|    210|        pj_uint8_t hdr_copy[20];
  461|    210|        pj_memcpy(hdr_copy, pkt, 20);
  462|    210|        PUT_VAL16(hdr_copy, 2, (pj_uint16_t)(amsgi_pos + 24));
  463|    210|        pj_hmac_sha1_update(&ctx, hdr_copy, 20);
  464|    210|    } else {
  465|     21|        pj_hmac_sha1_update(&ctx, pkt, 20);
  466|     21|    }
  467|    231|#endif  /* PJ_STUN_OLD_STYLE_MI_FINGERPRINT */
  468|       |
  469|       |    /* Now update with the message body */
  470|    231|    pj_hmac_sha1_update(&ctx, pkt+20, amsgi_pos);
  471|       |#if PJ_STUN_OLD_STYLE_MI_FINGERPRINT
  472|       |    // This is no longer necessary as per rfc3489bis-08
  473|       |    if ((amsgi_pos+20) & 0x3F) {
  474|       |        pj_uint8_t zeroes[64];
  475|       |        pj_bzero(zeroes, sizeof(zeroes));
  476|       |        pj_hmac_sha1_update(&ctx, zeroes, 64-((amsgi_pos+20) & 0x3F));
  477|       |    }
  478|       |#endif
  479|    231|    pj_hmac_sha1_final(&ctx, digest);
  480|       |
  481|       |
  482|       |    /* Compare HMACs */
  483|    231|    if (pj_memcmp(amsgi->hmac, digest, 20)) {
  ------------------
  |  Branch (483:9): [True: 228, False: 3]
  ------------------
  484|       |        /* HMAC value mismatch */
  485|       |        /* According to rfc3489bis-10 Sec 10.1.2 we should return 401 */
  486|    228|        err_code = PJ_STUN_SC_UNAUTHORIZED;
  487|    228|        err_text = "MESSAGE-INTEGRITY mismatch";
  488|    228|        goto on_auth_failed;
  489|    228|    }
  490|       |
  491|       |    /* Everything looks okay! */
  492|      3|    return PJ_SUCCESS;
  493|       |
  494|    955|on_auth_failed:
  495|    955|    if (p_response) {
  ------------------
  |  Branch (495:9): [True: 297, False: 658]
  ------------------
  496|    297|        create_challenge(pool, msg, err_code, err_text,
  497|    297|                         &p_info->realm, &p_info->nonce, p_response);
  498|    297|    }
  499|    955|    return PJ_STATUS_FROM_STUN_CODE(err_code);
  ------------------
  |  |   50|    955|#define PJ_STATUS_FROM_STUN_CODE(code)  (PJNATH_ERRNO_START+code)
  |  |  ------------------
  |  |  |  |   40|    955|#define PJNATH_ERRNO_START    (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*4)
  |  |  |  |  ------------------
  |  |  |  |  |  |  535|    955|#define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  528|    955|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  521|    955|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  509|    955|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  515|    955|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  515|    955|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  515|    955|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define PJNATH_ERRNO_START    (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*4)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|    955|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  500|    231|}
pj_stun_auth_valid_for_msg:
  505|    401|{
  506|    401|    unsigned msg_type = msg->hdr.type;
  507|    401|    const pj_stun_errcode_attr *err_attr;
  508|       |
  509|       |    /* STUN requests and success response can be authenticated */
  510|    401|    if (!PJ_STUN_IS_ERROR_RESPONSE(msg_type) && 
  ------------------
  |  |  170|    802|#define PJ_STUN_IS_ERROR_RESPONSE(msg_type) (((msg_type) & 0x0110) == 0x0110)
  ------------------
  |  Branch (510:9): [True: 0, False: 401]
  ------------------
  511|      0|        !PJ_STUN_IS_INDICATION(msg_type))
  ------------------
  |  |  186|      0|#define PJ_STUN_IS_INDICATION(msg_type) (((msg_type) & 0x0110) == 0x0010)
  ------------------
  |  Branch (511:9): [True: 0, False: 0]
  ------------------
  512|      0|    {
  513|      0|        return PJ_TRUE;
  514|      0|    }
  515|       |
  516|       |    /* STUN Indication cannot be authenticated */
  517|    401|    if (PJ_STUN_IS_INDICATION(msg_type))
  ------------------
  |  |  186|    401|#define PJ_STUN_IS_INDICATION(msg_type) (((msg_type) & 0x0110) == 0x0010)
  |  |  ------------------
  |  |  |  Branch (186:41): [True: 0, False: 401]
  |  |  ------------------
  ------------------
  518|      0|        return PJ_FALSE;
  519|       |
  520|       |    /* Authentication for STUN error responses depend on the error
  521|       |     * code.
  522|       |     */
  523|    401|    err_attr = (const pj_stun_errcode_attr*)
  524|    401|               pj_stun_msg_find_attr(msg, PJ_STUN_ATTR_ERROR_CODE, 0);
  525|    401|    if (err_attr == NULL) {
  ------------------
  |  Branch (525:9): [True: 0, False: 401]
  ------------------
  526|      0|        PJ_LOG(4,(THIS_FILE, "STUN error code attribute not present in "
  ------------------
  |  |  106|      0|#define PJ_LOG(level,arg)       do { \
  |  |  107|      0|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|      0|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 0, Folded]
  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  480|      0|    #define pj_log_wrapper_4(arg)       pj_log_4 arg
  |  |  ------------------
  |  |  109|      0|                                    } \
  |  |  110|      0|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 0]
  |  |  ------------------
  ------------------
  527|      0|                             "error response"));
  528|      0|        return PJ_TRUE;
  529|      0|    }
  530|       |
  531|    401|    switch (err_attr->err_code) {
  532|    129|    case PJ_STUN_SC_BAD_REQUEST:            /* 400 (Bad Request)            */
  ------------------
  |  Branch (532:5): [True: 129, False: 272]
  ------------------
  533|    388|    case PJ_STUN_SC_UNAUTHORIZED:           /* 401 (Unauthorized)           */
  ------------------
  |  Branch (533:5): [True: 259, False: 142]
  ------------------
  534|    388|    case PJ_STUN_SC_STALE_NONCE:            /* 438 (Stale Nonce)            */
  ------------------
  |  Branch (534:5): [True: 0, False: 401]
  ------------------
  535|       |
  536|       |    /* Due to the way this response is generated here, we can't really
  537|       |     * authenticate 420 (Unknown Attribute) response                        */
  538|    396|    case PJ_STUN_SC_UNKNOWN_ATTRIBUTE:
  ------------------
  |  Branch (538:5): [True: 8, False: 393]
  ------------------
  539|    396|        return PJ_FALSE;
  540|      5|    default:
  ------------------
  |  Branch (540:5): [True: 5, False: 396]
  ------------------
  541|      5|        return PJ_TRUE;
  542|    401|    }
  543|    401|}
stun_auth.c:calc_md5_key:
   79|  1.47k|{
   80|       |    /* The 16-byte key for MESSAGE-INTEGRITY HMAC is formed by taking
   81|       |     * the MD5 hash of the result of concatenating the following five
   82|       |     * fields: (1) The username, with any quotes and trailing nulls
   83|       |     * removed, (2) A single colon, (3) The realm, with any quotes and
   84|       |     * trailing nulls removed, (4) A single colon, and (5) The 
   85|       |     * password, with any trailing nulls removed.
   86|       |     */
   87|  1.47k|    pj_md5_context ctx;
   88|  1.47k|    pj_str_t s;
   89|       |
   90|  1.47k|    pj_md5_init(&ctx);
   91|       |
   92|  1.47k|#define REMOVE_QUOTE(s) if (s.slen && *s.ptr=='"') \
   93|  1.47k|                            s.ptr++, s.slen--; \
   94|  1.47k|                        if (s.slen && s.ptr[s.slen-1]=='"') \
   95|  1.47k|                            s.slen--;
   96|       |
   97|       |    /* Add username */
   98|  1.47k|    s = *username;
   99|  1.47k|    REMOVE_QUOTE(s);
  ------------------
  |  |   92|  1.47k|#define REMOVE_QUOTE(s) if (s.slen && *s.ptr=='"') \
  |  |  ------------------
  |  |  |  Branch (92:29): [True: 1.47k, False: 0]
  |  |  |  Branch (92:39): [True: 0, False: 1.47k]
  |  |  ------------------
  |  |   93|  1.47k|                            s.ptr++, s.slen--; \
  |  |   94|  1.47k|                        if (s.slen && s.ptr[s.slen-1]=='"') \
  |  |  ------------------
  |  |  |  Branch (94:29): [True: 1.47k, False: 0]
  |  |  |  Branch (94:39): [True: 0, False: 1.47k]
  |  |  ------------------
  |  |   95|  1.47k|                            s.slen--;
  ------------------
  100|  1.47k|    pj_md5_update(&ctx, (pj_uint8_t*)s.ptr, (unsigned)s.slen);
  101|       |
  102|       |    /* Add single colon */
  103|  1.47k|    pj_md5_update(&ctx, (pj_uint8_t*)":", 1);
  104|       |
  105|       |    /* Add realm */
  106|  1.47k|    s = *realm;
  107|  1.47k|    REMOVE_QUOTE(s);
  ------------------
  |  |   92|  1.47k|#define REMOVE_QUOTE(s) if (s.slen && *s.ptr=='"') \
  |  |  ------------------
  |  |  |  Branch (92:29): [True: 1.47k, False: 0]
  |  |  |  Branch (92:39): [True: 0, False: 1.47k]
  |  |  ------------------
  |  |   93|  1.47k|                            s.ptr++, s.slen--; \
  |  |   94|  1.47k|                        if (s.slen && s.ptr[s.slen-1]=='"') \
  |  |  ------------------
  |  |  |  Branch (94:29): [True: 1.47k, False: 0]
  |  |  |  Branch (94:39): [True: 0, False: 1.47k]
  |  |  ------------------
  |  |   95|  1.47k|                            s.slen--;
  ------------------
  108|  1.47k|    pj_md5_update(&ctx, (pj_uint8_t*)s.ptr, (unsigned)s.slen);
  109|       |
  110|  1.47k|#undef REMOVE_QUOTE
  111|       |
  112|       |    /* Another colon */
  113|  1.47k|    pj_md5_update(&ctx, (pj_uint8_t*)":", 1);
  114|       |
  115|       |    /* Add password */
  116|  1.47k|    pj_md5_update(&ctx, (pj_uint8_t*)passwd->ptr, (unsigned)passwd->slen);
  117|       |
  118|       |    /* Done */
  119|  1.47k|    pj_md5_final(&ctx, digest);
  120|  1.47k|}
stun_auth.c:PUT_VAL16:
  158|    210|{
  159|    210|    buf[pos+0] = (pj_uint8_t) ((hval & 0xFF00) >> 8);
  160|    210|    buf[pos+1] = (pj_uint8_t) ((hval & 0x00FF) >> 0);
  161|    210|}
stun_auth.c:create_challenge:
  172|    297|{
  173|    297|    pj_stun_msg *response;
  174|    297|    pj_str_t tmp_nonce;
  175|    297|    pj_str_t err_msg;
  176|    297|    pj_status_t rc;
  177|       |
  178|    297|    rc = pj_stun_msg_create_response(pool, msg, err_code, 
  179|    297|                                     (errstr?pj_cstr(&err_msg, errstr):NULL), 
  ------------------
  |  Branch (179:39): [True: 210, False: 87]
  ------------------
  180|    297|                                     &response);
  181|    297|    if (rc != PJ_SUCCESS)
  ------------------
  |  Branch (181:9): [True: 0, False: 297]
  ------------------
  182|      0|        return rc;
  183|       |
  184|       |    /* SHOULD NOT add REALM, NONCE, USERNAME, and M-I on 400 response */
  185|    297|    if (err_code!=400 && realm && realm->slen) {
  ------------------
  |  Branch (185:9): [True: 259, False: 38]
  |  Branch (185:26): [True: 259, False: 0]
  |  Branch (185:35): [True: 0, False: 259]
  ------------------
  186|      0|        rc = pj_stun_msg_add_string_attr(pool, response,
  187|      0|                                         PJ_STUN_ATTR_REALM, 
  188|      0|                                         realm);
  189|      0|        if (rc != PJ_SUCCESS)
  ------------------
  |  Branch (189:13): [True: 0, False: 0]
  ------------------
  190|      0|            return rc;
  191|       |
  192|       |        /* long term must include nonce */
  193|      0|        if (!nonce || nonce->slen == 0) {
  ------------------
  |  Branch (193:13): [True: 0, False: 0]
  |  Branch (193:23): [True: 0, False: 0]
  ------------------
  194|      0|            tmp_nonce = pj_str("pjstun");
  195|      0|            nonce = &tmp_nonce;
  196|      0|        }
  197|      0|    }
  198|       |
  199|    297|    if (err_code!=400 && nonce && nonce->slen) {
  ------------------
  |  Branch (199:9): [True: 259, False: 38]
  |  Branch (199:26): [True: 259, False: 0]
  |  Branch (199:35): [True: 0, False: 259]
  ------------------
  200|      0|        rc = pj_stun_msg_add_string_attr(pool, response,
  201|      0|                                         PJ_STUN_ATTR_NONCE, 
  202|      0|                                         nonce);
  203|      0|        if (rc != PJ_SUCCESS)
  ------------------
  |  Branch (203:13): [True: 0, False: 0]
  ------------------
  204|      0|            return rc;
  205|      0|    }
  206|       |
  207|    297|    *p_response = response;
  208|       |
  209|    297|    return PJ_SUCCESS;
  210|    297|}

pj_stun_get_attr_name:
  678|    202|{
  679|    202|    const struct attr_desc *attr_desc;
  680|       |
  681|    202|    attr_desc = find_attr_desc(attr_type);
  682|    202|    if (!attr_desc || attr_desc->name==NULL)
  ------------------
  |  Branch (682:9): [True: 138, False: 64]
  |  Branch (682:23): [True: 0, False: 64]
  ------------------
  683|    138|        return "???";
  684|       |
  685|     64|    return attr_desc->name;
  686|    202|}
pj_stun_get_err_reason:
  693|    105|{
  694|       |#if 0
  695|       |    /* Find error using linear search */
  696|       |    unsigned i;
  697|       |
  698|       |    for (i=0; i<PJ_ARRAY_SIZE(stun_err_msg_map); ++i) {
  699|       |        if (stun_err_msg_map[i].err_code == err_code)
  700|       |            return pj_str((char*)stun_err_msg_map[i].err_msg);
  701|       |    }
  702|       |    return pj_str(NULL);
  703|       |#else
  704|       |    /* Find error message using binary search */
  705|    105|    int first = 0;
  706|    105|    int n = PJ_ARRAY_SIZE(stun_err_msg_map);
  ------------------
  |  |  315|    105|#define PJ_ARRAY_SIZE(a)    (sizeof(a)/sizeof(a[0]))
  ------------------
  707|       |
  708|    354|    while (n > 0) {
  ------------------
  |  Branch (708:12): [True: 354, False: 0]
  ------------------
  709|    354|        int half = n/2;
  710|    354|        int mid = first + half;
  711|       |
  712|    354|        if (stun_err_msg_map[mid].err_code < err_code) {
  ------------------
  |  Branch (712:13): [True: 10, False: 344]
  ------------------
  713|     10|            first = mid+1;
  714|     10|            n -= (half+1);
  715|    344|        } else if (stun_err_msg_map[mid].err_code > err_code) {
  ------------------
  |  Branch (715:20): [True: 239, False: 105]
  ------------------
  716|    239|            n = half;
  717|    239|        } else {
  718|    105|            first = mid;
  719|    105|            break;
  720|    105|        }
  721|    354|    }
  722|       |
  723|       |
  724|    105|    if (stun_err_msg_map[first].err_code == err_code) {
  ------------------
  |  Branch (724:9): [True: 105, False: 0]
  ------------------
  725|    105|        return pj_str((char*)stun_err_msg_map[first].err_msg);
  726|    105|    } else {
  727|       |        return pj_str(NULL);
  728|      0|    }
  729|    105|#endif
  730|    105|}
pj_stun_sockaddr_attr_init:
  823|  2.48k|{
  824|  2.48k|    unsigned attr_len;
  825|       |
  826|  2.48k|    PJ_ASSERT_RETURN(attr && addr_len && addr, PJ_EINVAL);
  ------------------
  |  |   97|  2.48k|            do { \
  |  |   98|  9.94k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 2.48k, False: 0]
  |  |  |  Branch (98:23): [True: 2.48k, False: 0]
  |  |  |  Branch (98:23): [True: 2.48k, False: 0]
  |  |  ------------------
  |  |   99|  2.48k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 2.48k]
  |  |  ------------------
  ------------------
  |  Branch (826:5): [True: 0, False: 0]
  |  Branch (826:5): [True: 0, False: 0]
  |  Branch (826:5): [True: 0, False: 0]
  |  Branch (826:5): [True: 0, False: 0]
  |  Branch (826:5): [True: 0, False: 0]
  |  Branch (826:5): [True: 0, False: 0]
  ------------------
  827|  2.48k|    PJ_ASSERT_RETURN(addr_len == sizeof(pj_sockaddr_in) ||
  ------------------
  |  |   97|  2.48k|            do { \
  |  |   98|  2.48k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 2.48k, False: 0]
  |  |  |  Branch (98:23): [True: 0, False: 0]
  |  |  ------------------
  |  |   99|  2.48k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 2.48k]
  |  |  ------------------
  ------------------
  |  Branch (827:5): [True: 0, False: 0]
  |  Branch (827:5): [True: 0, False: 0]
  |  Branch (827:5): [True: 0, False: 0]
  |  Branch (827:5): [True: 0, False: 0]
  ------------------
  828|  2.48k|                     addr_len == sizeof(pj_sockaddr_in6), PJ_EINVAL);
  829|       |
  830|  2.48k|    attr_len = pj_sockaddr_get_addr_len(addr) + 4;
  831|  2.48k|    INIT_ATTR(attr, attr_type, attr_len);
  ------------------
  |  |  747|  2.48k|#define INIT_ATTR(a,t,l)    (a)->hdr.type=(pj_uint16_t)(t), \
  |  |  748|  2.48k|                            (a)->hdr.length=(pj_uint16_t)(l)
  ------------------
  832|       |
  833|  2.48k|    pj_memcpy(&attr->sockaddr, addr, addr_len);
  834|  2.48k|    attr->xor_ed = xor_ed;
  835|       |
  836|  2.48k|    return PJ_SUCCESS;
  837|  2.48k|}
pj_stun_sockaddr_attr_create:
  849|  2.48k|{
  850|  2.48k|    pj_stun_sockaddr_attr *attr;
  851|       |
  852|  2.48k|    PJ_ASSERT_RETURN(pool && p_attr, PJ_EINVAL);
  ------------------
  |  |   97|  2.48k|            do { \
  |  |   98|  4.97k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 2.48k, False: 0]
  |  |  |  Branch (98:23): [True: 2.48k, False: 0]
  |  |  ------------------
  |  |   99|  2.48k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 2.48k]
  |  |  ------------------
  ------------------
  |  Branch (852:5): [True: 0, False: 0]
  |  Branch (852:5): [True: 0, False: 0]
  |  Branch (852:5): [True: 0, False: 0]
  |  Branch (852:5): [True: 0, False: 0]
  ------------------
  853|  2.48k|    attr = PJ_POOL_ZALLOC_T(pool, pj_stun_sockaddr_attr);
  ------------------
  |  |  583|  2.48k|            ((type*)pj_pool_zalloc(pool, sizeof(type)))
  ------------------
  854|  2.48k|    *p_attr = attr;
  855|  2.48k|    return pj_stun_sockaddr_attr_init(attr, attr_type, xor_ed, 
  856|  2.48k|                                      addr, addr_len);
  857|  2.48k|}
pj_stun_msg_add_sockaddr_attr:
  869|  2.48k|{
  870|  2.48k|    pj_stun_sockaddr_attr *attr;
  871|  2.48k|    pj_status_t status;
  872|       |
  873|  2.48k|    status = pj_stun_sockaddr_attr_create(pool, attr_type, xor_ed,
  874|  2.48k|                                                 addr, addr_len, &attr);
  875|  2.48k|    if (status != PJ_SUCCESS)
  ------------------
  |  Branch (875:9): [True: 0, False: 2.48k]
  ------------------
  876|      0|        return status;
  877|       |
  878|  2.48k|    return pj_stun_msg_add_attr(msg, &attr->hdr);
  879|  2.48k|}
pj_stun_string_attr_init:
 1141|  5.37k|{
 1142|  5.37k|    if (value && value->slen) {
  ------------------
  |  Branch (1142:9): [True: 5.37k, False: 0]
  |  Branch (1142:18): [True: 5.37k, False: 0]
  ------------------
 1143|  5.37k|        INIT_ATTR(attr, attr_type, value->slen);
  ------------------
  |  |  747|  5.37k|#define INIT_ATTR(a,t,l)    (a)->hdr.type=(pj_uint16_t)(t), \
  |  |  748|  5.37k|                            (a)->hdr.length=(pj_uint16_t)(l)
  ------------------
 1144|  5.37k|        attr->value.slen = value->slen;
 1145|  5.37k|        pj_strdup(pool, &attr->value, value);
 1146|  5.37k|    } else {
 1147|      0|        INIT_ATTR(attr, attr_type, 0);
  ------------------
  |  |  747|      0|#define INIT_ATTR(a,t,l)    (a)->hdr.type=(pj_uint16_t)(t), \
  |  |  748|      0|                            (a)->hdr.length=(pj_uint16_t)(l)
  ------------------
 1148|      0|    }
 1149|  5.37k|    return PJ_SUCCESS;
 1150|  5.37k|}
pj_stun_string_attr_create:
 1160|  5.37k|{
 1161|  5.37k|    pj_stun_string_attr *attr;
 1162|       |
 1163|  5.37k|    PJ_ASSERT_RETURN(pool && value && p_attr, PJ_EINVAL);
  ------------------
  |  |   97|  5.37k|            do { \
  |  |   98|  21.4k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 5.37k, False: 0]
  |  |  |  Branch (98:23): [True: 5.37k, False: 0]
  |  |  |  Branch (98:23): [True: 5.37k, False: 0]
  |  |  ------------------
  |  |   99|  5.37k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 5.37k]
  |  |  ------------------
  ------------------
  |  Branch (1163:5): [True: 0, False: 0]
  |  Branch (1163:5): [True: 0, False: 0]
  |  Branch (1163:5): [True: 0, False: 0]
  |  Branch (1163:5): [True: 0, False: 0]
  |  Branch (1163:5): [True: 0, False: 0]
  |  Branch (1163:5): [True: 0, False: 0]
  ------------------
 1164|       |
 1165|  5.37k|    attr = PJ_POOL_ZALLOC_T(pool, pj_stun_string_attr);
  ------------------
  |  |  583|  5.37k|            ((type*)pj_pool_zalloc(pool, sizeof(type)))
  ------------------
 1166|  5.37k|    *p_attr = attr;
 1167|       |
 1168|  5.37k|    return pj_stun_string_attr_init(attr, pool, attr_type, value);
 1169|  5.37k|}
pj_stun_msg_add_string_attr:
 1179|  5.37k|{
 1180|  5.37k|    pj_stun_string_attr *attr = NULL;
 1181|  5.37k|    pj_status_t status;
 1182|       |
 1183|  5.37k|    status = pj_stun_string_attr_create(pool, attr_type, value, 
 1184|  5.37k|                                                &attr);
 1185|  5.37k|    if (status != PJ_SUCCESS)
  ------------------
  |  Branch (1185:9): [True: 0, False: 5.37k]
  ------------------
 1186|      0|        return status;
 1187|       |
 1188|  5.37k|    return pj_stun_msg_add_attr(msg, &attr->hdr);
 1189|  5.37k|}
pj_stun_msgint_attr_create:
 1601|  1.24k|{
 1602|  1.24k|    pj_stun_msgint_attr *attr;
 1603|       |
 1604|  1.24k|    PJ_ASSERT_RETURN(pool && p_attr, PJ_EINVAL);
  ------------------
  |  |   97|  1.24k|            do { \
  |  |   98|  2.48k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 1.24k, False: 0]
  |  |  |  Branch (98:23): [True: 1.24k, False: 0]
  |  |  ------------------
  |  |   99|  1.24k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1.24k]
  |  |  ------------------
  ------------------
  |  Branch (1604:5): [True: 0, False: 0]
  |  Branch (1604:5): [True: 0, False: 0]
  |  Branch (1604:5): [True: 0, False: 0]
  |  Branch (1604:5): [True: 0, False: 0]
  ------------------
 1605|       |
 1606|  1.24k|    attr = PJ_POOL_ZALLOC_T(pool, pj_stun_msgint_attr);
  ------------------
  |  |  583|  1.24k|            ((type*)pj_pool_zalloc(pool, sizeof(type)))
  ------------------
 1607|  1.24k|    INIT_ATTR(attr, PJ_STUN_ATTR_MESSAGE_INTEGRITY, 20);
  ------------------
  |  |  747|  1.24k|#define INIT_ATTR(a,t,l)    (a)->hdr.type=(pj_uint16_t)(t), \
  |  |  748|  1.24k|                            (a)->hdr.length=(pj_uint16_t)(l)
  ------------------
 1608|       |
 1609|  1.24k|    *p_attr = attr;
 1610|       |
 1611|  1.24k|    return PJ_SUCCESS;
 1612|  1.24k|}
pj_stun_msg_add_msgint_attr:
 1617|  1.24k|{
 1618|  1.24k|    pj_stun_msgint_attr *attr = NULL;
 1619|  1.24k|    pj_status_t status;
 1620|       |
 1621|  1.24k|    status = pj_stun_msgint_attr_create(pool, &attr);
 1622|  1.24k|    if (status != PJ_SUCCESS)
  ------------------
  |  Branch (1622:9): [True: 0, False: 1.24k]
  ------------------
 1623|      0|        return status;
 1624|       |
 1625|  1.24k|    return pj_stun_msg_add_attr(msg, &attr->hdr);
 1626|  1.24k|}
pj_stun_errcode_attr_create:
 1702|  1.46k|{
 1703|  1.46k|    pj_stun_errcode_attr *attr;
 1704|  1.46k|    char err_buf[80];
 1705|  1.46k|    pj_str_t str;
 1706|       |
 1707|  1.46k|    PJ_ASSERT_RETURN(pool && err_code && p_attr, PJ_EINVAL);
  ------------------
  |  |   97|  1.46k|            do { \
  |  |   98|  5.87k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 1.46k, False: 0]
  |  |  |  Branch (98:23): [True: 1.46k, False: 0]
  |  |  |  Branch (98:23): [True: 1.46k, False: 0]
  |  |  ------------------
  |  |   99|  1.46k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1.46k]
  |  |  ------------------
  ------------------
  |  Branch (1707:5): [True: 0, False: 0]
  |  Branch (1707:5): [True: 0, False: 0]
  |  Branch (1707:5): [True: 0, False: 0]
  |  Branch (1707:5): [True: 0, False: 0]
  |  Branch (1707:5): [True: 0, False: 0]
  |  Branch (1707:5): [True: 0, False: 0]
  ------------------
 1708|       |
 1709|  1.46k|    if (err_reason == NULL) {
  ------------------
  |  Branch (1709:9): [True: 105, False: 1.36k]
  ------------------
 1710|    105|        str = pj_stun_get_err_reason(err_code);
 1711|    105|        if (str.slen == 0) {
  ------------------
  |  Branch (1711:13): [True: 0, False: 105]
  ------------------
 1712|      0|            str.slen = pj_ansi_snprintf(err_buf, sizeof(err_buf),
  ------------------
  |  |  114|      0|#define pj_ansi_snprintf        snprintf
  ------------------
 1713|      0|                                        "Unknown error %d", err_code);
 1714|      0|            str.ptr = err_buf;
 1715|      0|        }
 1716|    105|        err_reason = &str;
 1717|    105|    }
 1718|       |
 1719|  1.46k|    attr = PJ_POOL_ZALLOC_T(pool, pj_stun_errcode_attr);
  ------------------
  |  |  583|  1.46k|            ((type*)pj_pool_zalloc(pool, sizeof(type)))
  ------------------
 1720|  1.46k|    INIT_ATTR(attr, PJ_STUN_ATTR_ERROR_CODE, 4+err_reason->slen);
  ------------------
  |  |  747|  1.46k|#define INIT_ATTR(a,t,l)    (a)->hdr.type=(pj_uint16_t)(t), \
  |  |  748|  1.46k|                            (a)->hdr.length=(pj_uint16_t)(l)
  ------------------
 1721|  1.46k|    attr->err_code = err_code;
 1722|  1.46k|    pj_strdup(pool, &attr->reason, err_reason);
 1723|       |
 1724|  1.46k|    *p_attr = attr;
 1725|       |
 1726|  1.46k|    return PJ_SUCCESS;
 1727|  1.46k|}
pj_stun_msg_add_errcode_attr:
 1734|  1.46k|{
 1735|  1.46k|    pj_stun_errcode_attr *err_attr = NULL;
 1736|  1.46k|    pj_status_t status;
 1737|       |
 1738|  1.46k|    status = pj_stun_errcode_attr_create(pool, err_code, err_reason,
 1739|  1.46k|                                         &err_attr);
 1740|  1.46k|    if (status != PJ_SUCCESS)
  ------------------
  |  Branch (1740:9): [True: 0, False: 1.46k]
  ------------------
 1741|      0|        return status;
 1742|       |
 1743|  1.46k|    return pj_stun_msg_add_attr(msg, &err_attr->hdr);
 1744|  1.46k|}
pj_stun_unknown_attr_create:
 1849|    371|{
 1850|    371|    pj_stun_unknown_attr *attr;
 1851|    371|    unsigned i;
 1852|       |
 1853|    371|    PJ_ASSERT_RETURN(pool && attr_cnt < PJ_STUN_MAX_ATTR && p_attr, PJ_EINVAL);
  ------------------
  |  |   97|    371|            do { \
  |  |   98|  1.48k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 371, False: 0]
  |  |  |  Branch (98:23): [True: 371, False: 0]
  |  |  |  Branch (98:23): [True: 371, False: 0]
  |  |  ------------------
  |  |   99|    371|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 371]
  |  |  ------------------
  ------------------
  |  Branch (1853:5): [True: 0, False: 0]
  |  Branch (1853:5): [True: 0, False: 0]
  |  Branch (1853:5): [True: 0, False: 0]
  |  Branch (1853:5): [True: 0, False: 0]
  |  Branch (1853:5): [True: 0, False: 0]
  |  Branch (1853:5): [True: 0, False: 0]
  ------------------
 1854|       |
 1855|    371|    attr = PJ_POOL_ZALLOC_T(pool, pj_stun_unknown_attr);
  ------------------
  |  |  583|    371|            ((type*)pj_pool_zalloc(pool, sizeof(type)))
  ------------------
 1856|    371|    INIT_ATTR(attr, PJ_STUN_ATTR_UNKNOWN_ATTRIBUTES, attr_cnt * 2);
  ------------------
  |  |  747|    371|#define INIT_ATTR(a,t,l)    (a)->hdr.type=(pj_uint16_t)(t), \
  |  |  748|    371|                            (a)->hdr.length=(pj_uint16_t)(l)
  ------------------
 1857|       |
 1858|    371|    attr->attr_count = attr_cnt;
 1859|  1.27k|    for (i=0; i<attr_cnt; ++i) {
  ------------------
  |  Branch (1859:15): [True: 908, False: 371]
  ------------------
 1860|    908|        attr->attrs[i] = attr_array[i];
 1861|    908|    }
 1862|       |
 1863|       |    /* If the number of unknown attributes is an odd number, one of the
 1864|       |     * attributes MUST be repeated in the list.
 1865|       |     */
 1866|       |    /* No longer necessary
 1867|       |    if ((attr_cnt & 0x01)) {
 1868|       |        attr->attrs[attr_cnt] = attr_array[attr_cnt-1];
 1869|       |    }
 1870|       |    */
 1871|       |
 1872|    371|    *p_attr = attr;
 1873|       |
 1874|    371|    return PJ_SUCCESS;
 1875|    371|}
pj_stun_msg_add_unknown_attr:
 1883|    371|{
 1884|    371|    pj_stun_unknown_attr *attr = NULL;
 1885|    371|    pj_status_t status;
 1886|       |
 1887|    371|    status = pj_stun_unknown_attr_create(pool, attr_cnt, attr_type, &attr);
 1888|    371|    if (status != PJ_SUCCESS)
  ------------------
  |  Branch (1888:9): [True: 0, False: 371]
  ------------------
 1889|      0|        return status;
 1890|       |
 1891|    371|    return pj_stun_msg_add_attr(msg, &attr->hdr);
 1892|    371|}
pj_stun_binary_attr_init:
 1989|  1.26k|{
 1990|  1.26k|    PJ_ASSERT_RETURN(attr_type, PJ_EINVAL);
  ------------------
  |  |   97|  1.26k|            do { \
  |  |   98|  1.26k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 1.26k]
  |  |  ------------------
  |  |   99|  1.26k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1.26k]
  |  |  ------------------
  ------------------
  |  Branch (1990:5): [True: 0, False: 0]
  |  Branch (1990:5): [True: 0, False: 0]
  ------------------
 1991|       |
 1992|  1.26k|    INIT_ATTR(attr, attr_type, length);
  ------------------
  |  |  747|  1.26k|#define INIT_ATTR(a,t,l)    (a)->hdr.type=(pj_uint16_t)(t), \
  |  |  748|  1.26k|                            (a)->hdr.length=(pj_uint16_t)(l)
  ------------------
 1993|       |
 1994|  1.26k|    attr->magic = PJ_STUN_MAGIC;
  ------------------
  |  |   46|  1.26k|#define PJ_STUN_MAGIC                       0x2112A442
  ------------------
 1995|       |
 1996|  1.26k|    if (data && length) {
  ------------------
  |  Branch (1996:9): [True: 1.26k, False: 0]
  |  Branch (1996:17): [True: 390, False: 874]
  ------------------
 1997|    390|        attr->length = length;
 1998|    390|        attr->data = (pj_uint8_t*) pj_pool_alloc(pool, length);
 1999|    390|        pj_memcpy(attr->data, data, length);
 2000|    874|    } else {
 2001|    874|        attr->data = NULL;
 2002|    874|        attr->length = 0;
 2003|    874|    }
 2004|       |
 2005|  1.26k|    return PJ_SUCCESS;
 2006|  1.26k|}
pj_stun_binary_attr_create:
 2017|  1.26k|{
 2018|  1.26k|    pj_stun_binary_attr *attr;
 2019|       |
 2020|  1.26k|    PJ_ASSERT_RETURN(pool && attr_type && p_attr, PJ_EINVAL);
  ------------------
  |  |   97|  1.26k|            do { \
  |  |   98|  5.05k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 1.26k, False: 0]
  |  |  |  Branch (98:23): [True: 1.26k, False: 0]
  |  |  |  Branch (98:23): [True: 1.26k, False: 0]
  |  |  ------------------
  |  |   99|  1.26k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1.26k]
  |  |  ------------------
  ------------------
  |  Branch (2020:5): [True: 0, False: 0]
  |  Branch (2020:5): [True: 0, False: 0]
  |  Branch (2020:5): [True: 0, False: 0]
  |  Branch (2020:5): [True: 0, False: 0]
  |  Branch (2020:5): [True: 0, False: 0]
  |  Branch (2020:5): [True: 0, False: 0]
  ------------------
 2021|  1.26k|    attr = PJ_POOL_ZALLOC_T(pool, pj_stun_binary_attr);
  ------------------
  |  |  583|  1.26k|            ((type*)pj_pool_zalloc(pool, sizeof(type)))
  ------------------
 2022|  1.26k|    *p_attr = attr;
 2023|  1.26k|    return pj_stun_binary_attr_init(attr, pool, attr_type, data, length);
 2024|  1.26k|}
pj_stun_msg_init:
 2131|  2.15k|{
 2132|  2.15k|    PJ_ASSERT_RETURN(msg && msg_type, PJ_EINVAL);
  ------------------
  |  |   97|  2.15k|            do { \
  |  |   98|  4.30k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 2.15k, False: 0]
  |  |  |  Branch (98:23): [True: 2.15k, False: 0]
  |  |  ------------------
  |  |   99|  2.15k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 2.15k]
  |  |  ------------------
  ------------------
  |  Branch (2132:5): [True: 0, False: 0]
  |  Branch (2132:5): [True: 0, False: 0]
  |  Branch (2132:5): [True: 0, False: 0]
  |  Branch (2132:5): [True: 0, False: 0]
  ------------------
 2133|       |
 2134|  2.15k|    msg->hdr.type = (pj_uint16_t) msg_type;
 2135|  2.15k|    msg->hdr.length = 0;
 2136|  2.15k|    msg->hdr.magic = magic;
 2137|  2.15k|    msg->attr_count = 0;
 2138|       |
 2139|  2.15k|    if (tsx_id) {
  ------------------
  |  Branch (2139:9): [True: 909, False: 1.24k]
  ------------------
 2140|    909|        pj_memcpy(&msg->hdr.tsx_id, tsx_id, sizeof(msg->hdr.tsx_id));
 2141|  1.24k|    } else {
 2142|  1.24k|        struct transaction_id
 2143|  1.24k|        {
 2144|  1.24k|            pj_uint32_t     proc_id;
 2145|  1.24k|            pj_uint32_t     random;
 2146|  1.24k|            pj_uint32_t     counter;
 2147|  1.24k|        } id;
 2148|  1.24k|        static pj_uint32_t pj_stun_tsx_id_counter;
 2149|       |
 2150|  1.24k|        if (!pj_stun_tsx_id_counter)
  ------------------
  |  Branch (2150:13): [True: 1, False: 1.24k]
  ------------------
 2151|      1|            pj_stun_tsx_id_counter = pj_rand();
 2152|       |
 2153|  1.24k|        id.proc_id = pj_getpid();
 2154|  1.24k|        id.random = pj_rand();
 2155|  1.24k|        id.counter = pj_stun_tsx_id_counter++;
 2156|       |
 2157|  1.24k|        pj_memcpy(&msg->hdr.tsx_id, &id, sizeof(msg->hdr.tsx_id));
 2158|  1.24k|    }
 2159|       |
 2160|  2.15k|    return PJ_SUCCESS;
 2161|  2.15k|}
pj_stun_msg_create:
 2172|  2.15k|{
 2173|  2.15k|    pj_stun_msg *msg;
 2174|       |
 2175|  2.15k|    PJ_ASSERT_RETURN(pool && msg_type && p_msg, PJ_EINVAL);
  ------------------
  |  |   97|  2.15k|            do { \
  |  |   98|  8.60k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 2.15k, False: 0]
  |  |  |  Branch (98:23): [True: 2.15k, False: 0]
  |  |  |  Branch (98:23): [True: 2.15k, False: 0]
  |  |  ------------------
  |  |   99|  2.15k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 2.15k]
  |  |  ------------------
  ------------------
  |  Branch (2175:5): [True: 0, False: 0]
  |  Branch (2175:5): [True: 0, False: 0]
  |  Branch (2175:5): [True: 0, False: 0]
  |  Branch (2175:5): [True: 0, False: 0]
  |  Branch (2175:5): [True: 0, False: 0]
  |  Branch (2175:5): [True: 0, False: 0]
  ------------------
 2176|       |
 2177|  2.15k|    msg = PJ_POOL_ZALLOC_T(pool, pj_stun_msg);
  ------------------
  |  |  583|  2.15k|            ((type*)pj_pool_zalloc(pool, sizeof(type)))
  ------------------
 2178|  2.15k|    *p_msg = msg;
 2179|  2.15k|    return pj_stun_msg_init(msg, msg_type, magic, tsx_id);
 2180|  2.15k|}
pj_stun_msg_add_attr:
 2213|  10.9k|{
 2214|  10.9k|    PJ_ASSERT_RETURN(msg && attr, PJ_EINVAL);
  ------------------
  |  |   97|  10.9k|            do { \
  |  |   98|  21.8k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 10.9k, False: 0]
  |  |  |  Branch (98:23): [True: 10.9k, False: 0]
  |  |  ------------------
  |  |   99|  10.9k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 10.9k]
  |  |  ------------------
  ------------------
  |  Branch (2214:5): [True: 0, False: 0]
  |  Branch (2214:5): [True: 0, False: 0]
  |  Branch (2214:5): [True: 0, False: 0]
  |  Branch (2214:5): [True: 0, False: 0]
  ------------------
 2215|  10.9k|    PJ_ASSERT_RETURN(msg->attr_count < PJ_STUN_MAX_ATTR, PJ_ETOOMANY);
  ------------------
  |  |   97|  10.9k|            do { \
  |  |   98|  10.9k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 10.9k]
  |  |  ------------------
  |  |   99|  10.9k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 10.9k]
  |  |  ------------------
  ------------------
  |  Branch (2215:5): [True: 0, False: 0]
  |  Branch (2215:5): [True: 0, False: 0]
  ------------------
 2216|       |
 2217|  10.9k|    msg->attr[msg->attr_count++] = attr;
 2218|  10.9k|    return PJ_SUCCESS;
 2219|  10.9k|}
pj_stun_msg_check:
 2227|  1.86k|{
 2228|  1.86k|    pj_uint32_t msg_len;
 2229|       |
 2230|  1.86k|    PJ_ASSERT_RETURN(pdu, PJ_EINVAL);
  ------------------
  |  |   97|  1.86k|            do { \
  |  |   98|  1.86k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 1.86k]
  |  |  ------------------
  |  |   99|  1.86k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1.86k]
  |  |  ------------------
  ------------------
  |  Branch (2230:5): [True: 0, False: 0]
  |  Branch (2230:5): [True: 0, False: 0]
  ------------------
 2231|       |
 2232|  1.86k|    if (pdu_len < sizeof(pj_stun_msg_hdr))
  ------------------
  |  Branch (2232:9): [True: 0, False: 1.86k]
  ------------------
 2233|      0|        return PJNATH_EINSTUNMSGLEN;
  ------------------
  |  |   61|      0|#define PJNATH_EINSTUNMSGLEN        (PJNATH_ERRNO_START+2)  /* 370002 */
  |  |  ------------------
  |  |  |  |   40|      0|#define PJNATH_ERRNO_START    (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*4)
  |  |  |  |  ------------------
  |  |  |  |  |  |  535|      0|#define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  528|      0|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define PJNATH_ERRNO_START    (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*4)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2234|       |
 2235|       |    /* First byte of STUN message is always 0x00 or 0x01. */
 2236|  1.86k|    if (*pdu != 0x00 && *pdu != 0x01)
  ------------------
  |  Branch (2236:9): [True: 204, False: 1.66k]
  |  Branch (2236:25): [True: 83, False: 121]
  ------------------
 2237|     83|        return PJNATH_EINSTUNMSGTYPE;
  ------------------
  |  |   66|     83|#define PJNATH_EINSTUNMSGTYPE       (PJNATH_ERRNO_START+3)  /* 370003 */
  |  |  ------------------
  |  |  |  |   40|     83|#define PJNATH_ERRNO_START    (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*4)
  |  |  |  |  ------------------
  |  |  |  |  |  |  535|     83|#define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  528|     83|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  521|     83|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  509|     83|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  515|     83|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  515|     83|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  515|     83|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define PJNATH_ERRNO_START    (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*4)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|     83|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2238|       |
 2239|       |    /* Check the PDU length */
 2240|  1.78k|    msg_len = GETVAL16H(pdu, 2);
 2241|  1.78k|    if ((msg_len + 20 > pdu_len) || 
  ------------------
  |  Branch (2241:9): [True: 102, False: 1.68k]
  ------------------
 2242|  1.68k|        ((options & PJ_STUN_IS_DATAGRAM) && msg_len + 20 != pdu_len))
  ------------------
  |  Branch (2242:10): [True: 1.68k, False: 0]
  |  Branch (2242:45): [True: 126, False: 1.55k]
  ------------------
 2243|    228|    {
 2244|    228|        return PJNATH_EINSTUNMSGLEN;
  ------------------
  |  |   61|    228|#define PJNATH_EINSTUNMSGLEN        (PJNATH_ERRNO_START+2)  /* 370002 */
  |  |  ------------------
  |  |  |  |   40|    228|#define PJNATH_ERRNO_START    (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*4)
  |  |  |  |  ------------------
  |  |  |  |  |  |  535|    228|#define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  528|    228|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  521|    228|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  509|    228|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  515|    228|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  515|    228|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  515|    228|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define PJNATH_ERRNO_START    (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*4)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|    228|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2245|    228|    }
 2246|       |
 2247|       |    /* STUN message is always padded to the nearest 4 bytes, thus
 2248|       |     * the last two bits of the length field are always zero.
 2249|       |     */
 2250|  1.55k|    if ((msg_len & 0x03) != 0) {
  ------------------
  |  Branch (2250:9): [True: 4, False: 1.55k]
  ------------------
 2251|      4|        return PJNATH_EINSTUNMSGLEN;
  ------------------
  |  |   61|      4|#define PJNATH_EINSTUNMSGLEN        (PJNATH_ERRNO_START+2)  /* 370002 */
  |  |  ------------------
  |  |  |  |   40|      4|#define PJNATH_ERRNO_START    (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*4)
  |  |  |  |  ------------------
  |  |  |  |  |  |  535|      4|#define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  528|      4|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  521|      4|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  509|      4|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  515|      4|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  515|      4|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  515|      4|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define PJNATH_ERRNO_START    (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*4)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      4|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2252|      4|    }
 2253|       |
 2254|       |    /* If magic is set, then there is great possibility that this is
 2255|       |     * a STUN message.
 2256|       |     */
 2257|  1.55k|    if (GETVAL32H(pdu, 4) == PJ_STUN_MAGIC) {
  ------------------
  |  |   46|  1.55k|#define PJ_STUN_MAGIC                       0x2112A442
  ------------------
  |  Branch (2257:9): [True: 142, False: 1.41k]
  ------------------
 2258|       |
 2259|       |        /* Check if FINGERPRINT attribute is present */
 2260|    142|        if ((options & PJ_STUN_NO_FINGERPRINT_CHECK )==0 && 
  ------------------
  |  Branch (2260:13): [True: 124, False: 18]
  ------------------
 2261|    124|            GETVAL16H(pdu, msg_len + 20 - 8) == PJ_STUN_ATTR_FINGERPRINT) 
  ------------------
  |  Branch (2261:13): [True: 82, False: 42]
  ------------------
 2262|     82|        {
 2263|     82|            pj_uint16_t attr_len = GETVAL16H(pdu, msg_len + 20 - 8 + 2);
 2264|     82|            pj_uint32_t fingerprint = GETVAL32H(pdu, msg_len + 20 - 8 + 4);
 2265|     82|            pj_uint32_t crc;
 2266|       |
 2267|     82|            if (attr_len != 4)
  ------------------
  |  Branch (2267:17): [True: 18, False: 64]
  ------------------
 2268|     18|                return PJNATH_ESTUNINATTRLEN;
  ------------------
  |  |   83|     18|#define PJNATH_ESTUNINATTRLEN       (PJNATH_ERRNO_START+22) /* 370022 */
  |  |  ------------------
  |  |  |  |   40|     18|#define PJNATH_ERRNO_START    (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*4)
  |  |  |  |  ------------------
  |  |  |  |  |  |  535|     18|#define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  528|     18|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  521|     18|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  509|     18|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  515|     18|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  515|     18|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  515|     18|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define PJNATH_ERRNO_START    (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*4)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|     18|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2269|       |
 2270|     64|            crc = pj_crc32_calc(pdu, msg_len + 20 - 8);
 2271|     64|            crc ^= STUN_XOR_FINGERPRINT;
  ------------------
  |  |   31|     64|#define STUN_XOR_FINGERPRINT    0x5354554eL
  ------------------
 2272|       |
 2273|     64|            if (crc != fingerprint)
  ------------------
  |  Branch (2273:17): [True: 63, False: 1]
  ------------------
 2274|     63|                return PJNATH_ESTUNFINGERPRINT;
  ------------------
  |  |   94|     63|#define PJNATH_ESTUNFINGERPRINT     (PJNATH_ERRNO_START+30) /* 370030 */
  |  |  ------------------
  |  |  |  |   40|     63|#define PJNATH_ERRNO_START    (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*4)
  |  |  |  |  ------------------
  |  |  |  |  |  |  535|     63|#define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  528|     63|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  521|     63|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  509|     63|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  515|     63|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  515|     63|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  515|     63|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define PJNATH_ERRNO_START    (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*4)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|     63|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2275|     64|        }
 2276|    142|    }
 2277|       |
 2278|       |    /* Could be a STUN message */
 2279|  1.47k|    return PJ_SUCCESS;
 2280|  1.55k|}
pj_stun_msg_create_response:
 2289|    909|{
 2290|    909|    unsigned msg_type = req_msg->hdr.type;
 2291|    909|    pj_stun_msg *response = NULL;
 2292|    909|    pj_status_t status;
 2293|       |
 2294|    909|    PJ_ASSERT_RETURN(pool && p_response, PJ_EINVAL);
  ------------------
  |  |   97|    909|            do { \
  |  |   98|  1.81k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 909, False: 0]
  |  |  |  Branch (98:23): [True: 909, False: 0]
  |  |  ------------------
  |  |   99|    909|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 909]
  |  |  ------------------
  ------------------
  |  Branch (2294:5): [True: 0, False: 0]
  |  Branch (2294:5): [True: 0, False: 0]
  |  Branch (2294:5): [True: 0, False: 0]
  |  Branch (2294:5): [True: 0, False: 0]
  ------------------
 2295|       |
 2296|    909|    PJ_ASSERT_RETURN(PJ_STUN_IS_REQUEST(msg_type), 
  ------------------
  |  |   97|    909|            do { \
  |  |   98|    909|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 909]
  |  |  ------------------
  |  |   99|    909|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 909]
  |  |  ------------------
  ------------------
  |  Branch (2296:5): [True: 0, False: 0]
  |  Branch (2296:5): [True: 0, False: 0]
  ------------------
 2297|    909|                     PJNATH_EINSTUNMSGTYPE);
 2298|       |
 2299|       |    /* Create response or error response */
 2300|    909|    if (err_code)
  ------------------
  |  Branch (2300:9): [True: 909, False: 0]
  ------------------
 2301|    909|        msg_type |= PJ_STUN_ERROR_RESPONSE_BIT;
  ------------------
  |  |  175|    909|#define PJ_STUN_ERROR_RESPONSE_BIT      (0x0110)
  ------------------
 2302|      0|    else
 2303|      0|        msg_type |= PJ_STUN_SUCCESS_RESPONSE_BIT;
  ------------------
  |  |  164|      0|#define PJ_STUN_SUCCESS_RESPONSE_BIT    (0x0100)
  ------------------
 2304|       |
 2305|    909|    status = pj_stun_msg_create(pool, msg_type, req_msg->hdr.magic, 
 2306|    909|                                req_msg->hdr.tsx_id, &response);
 2307|    909|    if (status != PJ_SUCCESS) {
  ------------------
  |  Branch (2307:9): [True: 0, False: 909]
  ------------------
 2308|      0|        return status;
 2309|      0|    }
 2310|       |
 2311|       |    /* Add error code attribute */
 2312|    909|    if (err_code) {
  ------------------
  |  Branch (2312:9): [True: 909, False: 0]
  ------------------
 2313|    909|        status = pj_stun_msg_add_errcode_attr(pool, response, 
 2314|    909|                                              err_code, err_msg);
 2315|    909|        if (status != PJ_SUCCESS) {
  ------------------
  |  Branch (2315:13): [True: 0, False: 909]
  ------------------
 2316|      0|            return status;
 2317|      0|        }
 2318|    909|    }
 2319|       |
 2320|    909|    *p_response = response;
 2321|    909|    return PJ_SUCCESS;
 2322|    909|}
pj_stun_msg_decode:
 2335|  1.86k|{
 2336|       |    
 2337|  1.86k|    pj_stun_msg *msg;
 2338|  1.86k|    const pj_uint8_t *start_pdu = pdu;
 2339|  1.86k|    pj_bool_t has_msg_int = PJ_FALSE;
 2340|  1.86k|    pj_bool_t has_fingerprint = PJ_FALSE;
 2341|  1.86k|    pj_status_t status;
 2342|       |
 2343|  1.86k|    PJ_UNUSED_ARG(options);
  ------------------
  |  | 1537|  1.86k|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
 2344|       |
 2345|  1.86k|    PJ_ASSERT_RETURN(pool && pdu && pdu_len && p_msg, PJ_EINVAL);
  ------------------
  |  |   97|  1.86k|            do { \
  |  |   98|  11.2k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 1.86k, False: 0]
  |  |  |  Branch (98:23): [True: 1.86k, False: 0]
  |  |  |  Branch (98:23): [True: 1.86k, False: 0]
  |  |  |  Branch (98:23): [True: 1.86k, False: 0]
  |  |  ------------------
  |  |   99|  1.86k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1.86k]
  |  |  ------------------
  ------------------
  |  Branch (2345:5): [True: 0, False: 0]
  |  Branch (2345:5): [True: 0, False: 0]
  |  Branch (2345:5): [True: 0, False: 0]
  |  Branch (2345:5): [True: 0, False: 0]
  |  Branch (2345:5): [True: 0, False: 0]
  |  Branch (2345:5): [True: 0, False: 0]
  |  Branch (2345:5): [True: 0, False: 0]
  |  Branch (2345:5): [True: 0, False: 0]
  ------------------
 2346|  1.86k|    PJ_ASSERT_RETURN(sizeof(pj_stun_msg_hdr) == 20, PJ_EBUG);
  ------------------
  |  |   97|  1.86k|            do { \
  |  |   98|  1.86k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [Folded, False: 1.86k]
  |  |  ------------------
  |  |   99|  1.86k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1.86k]
  |  |  ------------------
  ------------------
  |  Branch (2346:5): [True: 0, Folded]
  |  Branch (2346:5): [True: 0, Folded]
  ------------------
 2347|       |
 2348|  1.86k|    if (p_parsed_len)
  ------------------
  |  Branch (2348:9): [True: 624, False: 1.24k]
  ------------------
 2349|    624|        *p_parsed_len = 0;
 2350|  1.86k|    if (p_response)
  ------------------
  |  Branch (2350:9): [True: 624, False: 1.24k]
  ------------------
 2351|    624|        *p_response = NULL;
 2352|       |
 2353|       |    /* Check if this is a STUN message, if necessary */
 2354|  1.86k|    if (options & PJ_STUN_CHECK_PACKET) {
  ------------------
  |  Branch (2354:9): [True: 1.86k, False: 0]
  ------------------
 2355|  1.86k|        status = pj_stun_msg_check(pdu, pdu_len, options);
 2356|  1.86k|        if (status != PJ_SUCCESS)
  ------------------
  |  Branch (2356:13): [True: 396, False: 1.47k]
  ------------------
 2357|    396|            return status;
 2358|  1.86k|    } else {
 2359|       |        /* For safety, verify packet length at least */
 2360|      0|        pj_uint32_t msg_len = GETVAL16H(pdu, 2) + 20;
 2361|      0|        if (msg_len > pdu_len ||
  ------------------
  |  Branch (2361:13): [True: 0, False: 0]
  ------------------
 2362|      0|            ((options & PJ_STUN_IS_DATAGRAM) && msg_len != pdu_len))
  ------------------
  |  Branch (2362:14): [True: 0, False: 0]
  |  Branch (2362:49): [True: 0, False: 0]
  ------------------
 2363|      0|        {
 2364|      0|            return PJNATH_EINSTUNMSGLEN;
  ------------------
  |  |   61|      0|#define PJNATH_EINSTUNMSGLEN        (PJNATH_ERRNO_START+2)  /* 370002 */
  |  |  ------------------
  |  |  |  |   40|      0|#define PJNATH_ERRNO_START    (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*4)
  |  |  |  |  ------------------
  |  |  |  |  |  |  535|      0|#define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  528|      0|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define PJNATH_ERRNO_START    (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*4)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2365|      0|        }
 2366|      0|    }
 2367|       |
 2368|       |    /* Create the message, copy the header, and convert to host byte order */
 2369|  1.47k|    msg = PJ_POOL_ZALLOC_T(pool, pj_stun_msg);
  ------------------
  |  |  583|  1.47k|            ((type*)pj_pool_zalloc(pool, sizeof(type)))
  ------------------
 2370|  1.47k|    pj_memcpy(&msg->hdr, pdu, sizeof(pj_stun_msg_hdr));
 2371|  1.47k|    msg->hdr.type = pj_ntohs(msg->hdr.type);
 2372|  1.47k|    msg->hdr.length = pj_ntohs(msg->hdr.length);
 2373|  1.47k|    msg->hdr.magic = pj_ntohl(msg->hdr.magic);
 2374|       |
 2375|  1.47k|    pdu += sizeof(pj_stun_msg_hdr);
 2376|       |    /* pdu_len -= sizeof(pj_stun_msg_hdr); */
 2377|  1.47k|    pdu_len = msg->hdr.length;
 2378|       |
 2379|       |    /* No need to create response if this is not a request */
 2380|  1.47k|    if (!PJ_STUN_IS_REQUEST(msg->hdr.type))
  ------------------
  |  |  153|  1.47k|#define PJ_STUN_IS_REQUEST(msg_type)    (((msg_type) & 0x0110) == 0x0000)
  ------------------
  |  Branch (2380:9): [True: 337, False: 1.13k]
  ------------------
 2381|    337|        p_response = NULL;
 2382|       |
 2383|       |    /* Parse attributes */
 2384|  7.65k|    while (pdu_len >= ATTR_HDR_LEN) {
  ------------------
  |  |  749|  7.65k|#define ATTR_HDR_LEN        sizeof(pj_stun_attr_hdr)
  ------------------
  |  Branch (2384:12): [True: 6.60k, False: 1.05k]
  ------------------
 2385|  6.60k|        unsigned attr_type, attr_val_len;
 2386|  6.60k|        const struct attr_desc *adesc;
 2387|       |
 2388|       |        /* Get attribute type and length. If length is not aligned
 2389|       |         * to 4 bytes boundary, add padding.
 2390|       |         */
 2391|  6.60k|        attr_type = GETVAL16H(pdu, 0);
 2392|  6.60k|        attr_val_len = GETVAL16H(pdu, 2);
 2393|  6.60k|        attr_val_len = (attr_val_len + 3) & (~3);
 2394|       |
 2395|       |        /* Check length */
 2396|  6.60k|        if (pdu_len < attr_val_len + ATTR_HDR_LEN) {
  ------------------
  |  |  749|  6.60k|#define ATTR_HDR_LEN        sizeof(pj_stun_attr_hdr)
  ------------------
  |  Branch (2396:13): [True: 165, False: 6.43k]
  ------------------
 2397|    165|            pj_str_t err_msg;
 2398|    165|            char err_msg_buf[80];
 2399|       |
 2400|    165|            err_msg.ptr = err_msg_buf;
 2401|    165|            err_msg.slen = pj_ansi_snprintf(err_msg_buf, sizeof(err_msg_buf),
  ------------------
  |  |  114|    165|#define pj_ansi_snprintf        snprintf
  ------------------
 2402|    165|                                            "Attribute %s has invalid length",
 2403|    165|                                            pj_stun_get_attr_name(attr_type));
 2404|       |
 2405|    165|            PJ_LOG(4,(THIS_FILE, "Error decoding message: %.*s",
  ------------------
  |  |  106|    165|#define PJ_LOG(level,arg)       do { \
  |  |  107|    165|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|    330|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 165, Folded]
  |  |  |  Branch (107:70): [True: 0, False: 165]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  480|      0|    #define pj_log_wrapper_4(arg)       pj_log_4 arg
  |  |  ------------------
  |  |  109|      0|                                    } \
  |  |  110|    165|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 165]
  |  |  ------------------
  ------------------
 2406|    165|                      (int)err_msg.slen, err_msg.ptr));
 2407|       |
 2408|    165|            if (p_response) {
  ------------------
  |  Branch (2408:17): [True: 47, False: 118]
  ------------------
 2409|     47|                pj_stun_msg_create_response(pool, msg, 
 2410|     47|                                            PJ_STUN_SC_BAD_REQUEST, 
 2411|     47|                                            &err_msg, p_response);
 2412|     47|            }
 2413|    165|            return PJNATH_ESTUNINATTRLEN;
  ------------------
  |  |   83|    165|#define PJNATH_ESTUNINATTRLEN       (PJNATH_ERRNO_START+22) /* 370022 */
  |  |  ------------------
  |  |  |  |   40|    165|#define PJNATH_ERRNO_START    (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*4)
  |  |  |  |  ------------------
  |  |  |  |  |  |  535|    165|#define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  528|    165|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  521|    165|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  509|    165|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  515|    165|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  515|    165|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  515|    165|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define PJNATH_ERRNO_START    (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*4)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|    165|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2414|    165|        }
 2415|       |
 2416|       |        /* Get the attribute descriptor */
 2417|  6.43k|        adesc = find_attr_desc(attr_type);
 2418|       |
 2419|  6.43k|        if (adesc == NULL) {
  ------------------
  |  Branch (2419:13): [True: 1.31k, False: 5.12k]
  ------------------
 2420|       |            /* Unrecognized attribute */
 2421|  1.31k|            pj_stun_binary_attr *attr = NULL;
 2422|       |
 2423|  1.31k|            PJ_LOG(5,(THIS_FILE, "Unrecognized attribute type 0x%x", 
  ------------------
  |  |  106|  1.31k|#define PJ_LOG(level,arg)       do { \
  |  |  107|  1.31k|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|  2.63k|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 1.31k, Folded]
  |  |  |  Branch (107:70): [True: 0, False: 1.31k]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  496|      0|    #define pj_log_wrapper_5(arg)       pj_log_5 arg
  |  |  ------------------
  |  |  109|      0|                                    } \
  |  |  110|  1.31k|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 1.31k]
  |  |  ------------------
  ------------------
 2424|  1.31k|                      attr_type));
 2425|       |
 2426|       |            /* Is this a fatal condition? */
 2427|  1.31k|            if (attr_type <= 0x7FFF) {
  ------------------
  |  Branch (2427:17): [True: 46, False: 1.26k]
  ------------------
 2428|       |                /* This is a mandatory attribute, we must return error
 2429|       |                 * if we don't understand the attribute.
 2430|       |                 */
 2431|     46|                if (p_response) {
  ------------------
  |  Branch (2431:21): [True: 8, False: 38]
  ------------------
 2432|      8|                    unsigned err_code = PJ_STUN_SC_UNKNOWN_ATTRIBUTE;
 2433|       |
 2434|      8|                    status = pj_stun_msg_create_response(pool, msg,
 2435|      8|                                                         err_code, NULL, 
 2436|      8|                                                         p_response);
 2437|      8|                    if (status==PJ_SUCCESS) {
  ------------------
  |  Branch (2437:25): [True: 8, False: 0]
  ------------------
 2438|      8|                        pj_uint16_t d = (pj_uint16_t)attr_type;
 2439|      8|                        pj_stun_msg_add_unknown_attr(pool, *p_response, 1, &d);
 2440|      8|                    }
 2441|      8|                }
 2442|       |
 2443|     46|                return PJ_STATUS_FROM_STUN_CODE(PJ_STUN_SC_UNKNOWN_ATTRIBUTE);
  ------------------
  |  |   50|     46|#define PJ_STATUS_FROM_STUN_CODE(code)  (PJNATH_ERRNO_START+code)
  |  |  ------------------
  |  |  |  |   40|     46|#define PJNATH_ERRNO_START    (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*4)
  |  |  |  |  ------------------
  |  |  |  |  |  |  535|     46|#define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  528|     46|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  521|     46|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  509|     46|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  515|     46|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  515|     46|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  515|     46|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define PJNATH_ERRNO_START    (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*4)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|     46|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2444|     46|            }
 2445|       |
 2446|       |            /* Make sure we have rooms for the new attribute */
 2447|  1.26k|            if (msg->attr_count >= PJ_STUN_MAX_ATTR) {
  ------------------
  |  |   63|  1.26k|#   define PJ_STUN_MAX_ATTR                         16
  ------------------
  |  Branch (2447:17): [True: 5, False: 1.26k]
  ------------------
 2448|      5|                if (p_response) {
  ------------------
  |  Branch (2448:21): [True: 1, False: 4]
  ------------------
 2449|      1|                    pj_stun_msg_create_response(pool, msg,
 2450|      1|                                                PJ_STUN_SC_SERVER_ERROR,
 2451|      1|                                                NULL, p_response);
 2452|      1|                }
 2453|      5|                return PJNATH_ESTUNTOOMANYATTR;
  ------------------
  |  |   78|      5|#define PJNATH_ESTUNTOOMANYATTR     (PJNATH_ERRNO_START+21) /* 370021 */
  |  |  ------------------
  |  |  |  |   40|      5|#define PJNATH_ERRNO_START    (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*4)
  |  |  |  |  ------------------
  |  |  |  |  |  |  535|      5|#define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  528|      5|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  521|      5|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  509|      5|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  515|      5|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  515|      5|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  515|      5|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define PJNATH_ERRNO_START    (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*4)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      5|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2454|      5|            }
 2455|       |
 2456|       |            /* Create binary attribute to represent this */
 2457|  1.26k|            status = pj_stun_binary_attr_create(pool, attr_type, pdu+4, 
 2458|  1.26k|                                                GETVAL16H(pdu, 2), &attr);
 2459|  1.26k|            if (status != PJ_SUCCESS) {
  ------------------
  |  Branch (2459:17): [True: 0, False: 1.26k]
  ------------------
 2460|      0|                if (p_response) {
  ------------------
  |  Branch (2460:21): [True: 0, False: 0]
  ------------------
 2461|      0|                    pj_stun_msg_create_response(pool, msg,
 2462|      0|                                                PJ_STUN_SC_SERVER_ERROR,
 2463|      0|                                                NULL, p_response);
 2464|      0|                }
 2465|       |
 2466|      0|                PJ_LOG(4,(THIS_FILE, 
  ------------------
  |  |  106|      0|#define PJ_LOG(level,arg)       do { \
  |  |  107|      0|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|      0|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 0, Folded]
  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  480|      0|    #define pj_log_wrapper_4(arg)       pj_log_4 arg
  |  |  ------------------
  |  |  109|      0|                                    } \
  |  |  110|      0|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2467|      0|                          "Error parsing unknown STUN attribute type %d",
 2468|      0|                          attr_type));
 2469|       |
 2470|      0|                return status;
 2471|      0|            }
 2472|       |
 2473|       |            /* Add the attribute */
 2474|  1.26k|            msg->attr[msg->attr_count++] = &attr->hdr;
 2475|       |
 2476|  5.12k|        } else {
 2477|  5.12k|            void *attr;
 2478|  5.12k|            char err_msg1[PJ_ERR_MSG_SIZE],
 2479|  5.12k|                 err_msg2[PJ_ERR_MSG_SIZE];
 2480|       |
 2481|       |            /* Parse the attribute */
 2482|  5.12k|            status = (adesc->decode_attr)(pool, pdu, &msg->hdr, &attr);
 2483|       |
 2484|  5.12k|            if (status != PJ_SUCCESS) {
  ------------------
  |  Branch (2484:17): [True: 164, False: 4.95k]
  ------------------
 2485|    164|                pj_strerror(status, err_msg1, sizeof(err_msg1));
 2486|       |
 2487|    164|                if (p_response) {
  ------------------
  |  Branch (2487:21): [True: 37, False: 127]
  ------------------
 2488|     37|                    pj_str_t e;
 2489|       |
 2490|     37|                    e.ptr = err_msg2;
 2491|     37|                    e.slen= pj_ansi_snprintf(err_msg2, sizeof(err_msg2),
  ------------------
  |  |  114|     37|#define pj_ansi_snprintf        snprintf
  ------------------
 2492|     37|                                             "%s in %s",
 2493|     37|                                             err_msg1,
 2494|     37|                                             pj_stun_get_attr_name(attr_type));
 2495|     37|                    if (e.slen < 1 || e.slen >= (int)sizeof(err_msg2))
  ------------------
  |  Branch (2495:25): [True: 0, False: 37]
  |  Branch (2495:39): [True: 0, False: 37]
  ------------------
 2496|      0|                        e.slen = sizeof(err_msg2) - 1;
 2497|     37|                    pj_stun_msg_create_response(pool, msg,
 2498|     37|                                                PJ_STUN_SC_BAD_REQUEST,
 2499|     37|                                                &e, p_response);
 2500|     37|                }
 2501|       |
 2502|    164|                PJ_LOG(4,(THIS_FILE, 
  ------------------
  |  |  106|    164|#define PJ_LOG(level,arg)       do { \
  |  |  107|    164|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|    328|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 164, Folded]
  |  |  |  Branch (107:70): [True: 0, False: 164]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  480|      0|    #define pj_log_wrapper_4(arg)       pj_log_4 arg
  |  |  ------------------
  |  |  109|      0|                                    } \
  |  |  110|    164|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 164]
  |  |  ------------------
  ------------------
 2503|    164|                          "Error parsing STUN attribute %s: %s",
 2504|    164|                          pj_stun_get_attr_name(attr_type), 
 2505|    164|                          err_msg1));
 2506|       |
 2507|    164|                return status;
 2508|    164|            }
 2509|       |
 2510|  4.95k|            if (attr_type == PJ_STUN_ATTR_MESSAGE_INTEGRITY && 
  ------------------
  |  Branch (2510:17): [True: 748, False: 4.21k]
  ------------------
 2511|    748|                !has_fingerprint) 
  ------------------
  |  Branch (2511:17): [True: 745, False: 3]
  ------------------
 2512|    745|            {
 2513|    745|                if (has_msg_int) {
  ------------------
  |  Branch (2513:21): [True: 5, False: 740]
  ------------------
 2514|       |                    /* Already has MESSAGE-INTEGRITY */
 2515|      5|                    if (p_response) {
  ------------------
  |  Branch (2515:25): [True: 1, False: 4]
  ------------------
 2516|      1|                        pj_stun_msg_create_response(pool, msg,
 2517|      1|                                                    PJ_STUN_SC_BAD_REQUEST,
 2518|      1|                                                    NULL, p_response);
 2519|      1|                    }
 2520|      5|                    return PJNATH_ESTUNDUPATTR;
  ------------------
  |  |   88|      5|#define PJNATH_ESTUNDUPATTR         (PJNATH_ERRNO_START+23) /* 370023 */
  |  |  ------------------
  |  |  |  |   40|      5|#define PJNATH_ERRNO_START    (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*4)
  |  |  |  |  ------------------
  |  |  |  |  |  |  535|      5|#define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  528|      5|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  521|      5|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  509|      5|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  515|      5|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  515|      5|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  515|      5|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define PJNATH_ERRNO_START    (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*4)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      5|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2521|      5|                }
 2522|    740|                has_msg_int = PJ_TRUE;
 2523|       |
 2524|  4.21k|            } else if (attr_type == PJ_STUN_ATTR_FINGERPRINT) {
  ------------------
  |  Branch (2524:24): [True: 31, False: 4.18k]
  ------------------
 2525|     31|                if (has_fingerprint) {
  ------------------
  |  Branch (2525:21): [True: 8, False: 23]
  ------------------
 2526|       |                    /* Already has FINGERPRINT */
 2527|      8|                    if (p_response) {
  ------------------
  |  Branch (2527:25): [True: 2, False: 6]
  ------------------
 2528|      2|                        pj_stun_msg_create_response(pool, msg,
 2529|      2|                                                    PJ_STUN_SC_BAD_REQUEST,
 2530|      2|                                                    NULL, p_response);
 2531|      2|                    }
 2532|      8|                    return PJNATH_ESTUNDUPATTR;
  ------------------
  |  |   88|      8|#define PJNATH_ESTUNDUPATTR         (PJNATH_ERRNO_START+23) /* 370023 */
  |  |  ------------------
  |  |  |  |   40|      8|#define PJNATH_ERRNO_START    (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*4)
  |  |  |  |  ------------------
  |  |  |  |  |  |  535|      8|#define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  528|      8|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  521|      8|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  509|      8|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  515|      8|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  515|      8|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  515|      8|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define PJNATH_ERRNO_START    (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*4)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      8|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2533|      8|                }
 2534|     23|                has_fingerprint = PJ_TRUE;
 2535|  4.18k|            } else {
 2536|  4.18k|                if (has_fingerprint) {
  ------------------
  |  Branch (2536:21): [True: 12, False: 4.17k]
  ------------------
 2537|       |                    /* Another attribute is found which is not FINGERPRINT
 2538|       |                     * after FINGERPRINT. Note that non-FINGERPRINT is
 2539|       |                     * allowed to appear after M-I
 2540|       |                     */
 2541|     12|                    if (p_response) {
  ------------------
  |  Branch (2541:25): [True: 2, False: 10]
  ------------------
 2542|      2|                        pj_stun_msg_create_response(pool, msg,
 2543|      2|                                                    PJ_STUN_SC_BAD_REQUEST,
 2544|      2|                                                    NULL, p_response);
 2545|      2|                    }
 2546|     12|                    return PJNATH_ESTUNFINGERPOS;
  ------------------
  |  |  104|     12|#define PJNATH_ESTUNFINGERPOS       (PJNATH_ERRNO_START+33) /* 370033 */
  |  |  ------------------
  |  |  |  |   40|     12|#define PJNATH_ERRNO_START    (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*4)
  |  |  |  |  ------------------
  |  |  |  |  |  |  535|     12|#define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  528|     12|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  521|     12|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  509|     12|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  515|     12|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  515|     12|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  515|     12|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define PJNATH_ERRNO_START    (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*4)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|     12|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2547|     12|                }
 2548|  4.18k|            }
 2549|       |
 2550|       |            /* Make sure we have rooms for the new attribute */
 2551|  4.93k|            if (msg->attr_count >= PJ_STUN_MAX_ATTR) {
  ------------------
  |  |   63|  4.93k|#   define PJ_STUN_MAX_ATTR                         16
  ------------------
  |  Branch (2551:17): [True: 13, False: 4.92k]
  ------------------
 2552|     13|                if (p_response) {
  ------------------
  |  Branch (2552:21): [True: 4, False: 9]
  ------------------
 2553|      4|                    pj_stun_msg_create_response(pool, msg,
 2554|      4|                                                PJ_STUN_SC_SERVER_ERROR,
 2555|      4|                                                NULL, p_response);
 2556|      4|                }
 2557|     13|                return PJNATH_ESTUNTOOMANYATTR;
  ------------------
  |  |   78|     13|#define PJNATH_ESTUNTOOMANYATTR     (PJNATH_ERRNO_START+21) /* 370021 */
  |  |  ------------------
  |  |  |  |   40|     13|#define PJNATH_ERRNO_START    (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*4)
  |  |  |  |  ------------------
  |  |  |  |  |  |  535|     13|#define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  528|     13|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  521|     13|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  509|     13|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  515|     13|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  515|     13|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  515|     13|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define PJNATH_ERRNO_START    (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*4)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|     13|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2558|     13|            }
 2559|       |
 2560|       |            /* Add the attribute */
 2561|  4.92k|            msg->attr[msg->attr_count++] = (pj_stun_attr_hdr*)attr;
 2562|  4.92k|        }
 2563|       |
 2564|       |        /* Next attribute */
 2565|  6.18k|        if (attr_val_len + 4 >= pdu_len) {
  ------------------
  |  Branch (2565:13): [True: 972, False: 5.21k]
  ------------------
 2566|    972|            pdu += pdu_len;
 2567|    972|            pdu_len = 0;
 2568|  5.21k|        } else {
 2569|  5.21k|            pdu += (attr_val_len + 4);
 2570|  5.21k|            pdu_len -= (attr_val_len + 4);
 2571|  5.21k|        }
 2572|  6.18k|    }
 2573|       |
 2574|  1.05k|    if (pdu_len > 0) {
  ------------------
  |  Branch (2574:9): [True: 0, False: 1.05k]
  ------------------
 2575|       |        /* Stray trailing bytes */
 2576|      0|        PJ_LOG(4,(THIS_FILE, 
  ------------------
  |  |  106|      0|#define PJ_LOG(level,arg)       do { \
  |  |  107|      0|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|      0|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 0, Folded]
  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  480|      0|    #define pj_log_wrapper_4(arg)       pj_log_4 arg
  |  |  ------------------
  |  |  109|      0|                                    } \
  |  |  110|      0|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2577|      0|                  "Error decoding STUN message: unparsed trailing %lu bytes",
 2578|      0|                  (unsigned long)pdu_len));
 2579|      0|        return PJNATH_EINSTUNMSGLEN;
  ------------------
  |  |   61|      0|#define PJNATH_EINSTUNMSGLEN        (PJNATH_ERRNO_START+2)  /* 370002 */
  |  |  ------------------
  |  |  |  |   40|      0|#define PJNATH_ERRNO_START    (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*4)
  |  |  |  |  ------------------
  |  |  |  |  |  |  535|      0|#define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  528|      0|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define PJNATH_ERRNO_START    (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*4)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2580|      0|    }
 2581|       |
 2582|  1.05k|    *p_msg = msg;
 2583|       |
 2584|  1.05k|    if (p_parsed_len)
  ------------------
  |  Branch (2584:9): [True: 394, False: 659]
  ------------------
 2585|    394|        *p_parsed_len = (pdu - start_pdu);
 2586|       |
 2587|  1.05k|    return PJ_SUCCESS;
 2588|  1.05k|}
pj_stun_msg_encode:
 2624|  1.64k|{
 2625|  1.64k|    pj_uint8_t *start = buf;
 2626|  1.64k|    pj_stun_msgint_attr *amsgint = NULL;
 2627|  1.64k|    pj_stun_fingerprint_attr *afingerprint = NULL;
 2628|  1.64k|    unsigned printed = 0, body_len;
 2629|  1.64k|    pj_status_t status;
 2630|  1.64k|    unsigned i;
 2631|       |
 2632|       |
 2633|  1.64k|    PJ_ASSERT_RETURN(msg && buf && buf_size, PJ_EINVAL);
  ------------------
  |  |   97|  1.64k|            do { \
  |  |   98|  6.57k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 1.64k, False: 0]
  |  |  |  Branch (98:23): [True: 1.64k, False: 0]
  |  |  |  Branch (98:23): [True: 1.64k, False: 0]
  |  |  ------------------
  |  |   99|  1.64k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1.64k]
  |  |  ------------------
  ------------------
  |  Branch (2633:5): [True: 0, False: 0]
  |  Branch (2633:5): [True: 0, False: 0]
  |  Branch (2633:5): [True: 0, False: 0]
  |  Branch (2633:5): [True: 0, False: 0]
  |  Branch (2633:5): [True: 0, False: 0]
  |  Branch (2633:5): [True: 0, False: 0]
  ------------------
 2634|       |
 2635|  1.64k|    PJ_UNUSED_ARG(options);
  ------------------
  |  | 1537|  1.64k|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
 2636|  1.64k|    PJ_ASSERT_RETURN(options == 0, PJ_EINVAL);
  ------------------
  |  |   97|  1.64k|            do { \
  |  |   98|  1.64k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 1.64k]
  |  |  ------------------
  |  |   99|  1.64k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1.64k]
  |  |  ------------------
  ------------------
  |  Branch (2636:5): [True: 0, False: 0]
  |  Branch (2636:5): [True: 0, False: 0]
  ------------------
 2637|       |
 2638|       |    /* Copy the message header part and convert the header fields to
 2639|       |     * network byte order
 2640|       |     */
 2641|  1.64k|    if (buf_size < sizeof(pj_stun_msg_hdr))
  ------------------
  |  Branch (2641:9): [True: 0, False: 1.64k]
  ------------------
 2642|      0|        return PJ_ETOOSMALL;
  ------------------
  |  |  469|      0|#define PJ_ETOOSMALL        (PJ_ERRNO_START_STATUS + 19)/* 70019 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2643|       |    
 2644|  1.64k|    PUTVAL16H(buf, 0, msg->hdr.type);
 2645|  1.64k|    PUTVAL16H(buf, 2, 0);   /* length will be calculated later */
 2646|  1.64k|    PUTVAL32H(buf, 4, msg->hdr.magic);
 2647|  1.64k|    pj_memcpy(buf+8, msg->hdr.tsx_id, sizeof(msg->hdr.tsx_id));
 2648|       |
 2649|  1.64k|    buf += sizeof(pj_stun_msg_hdr);
 2650|  1.64k|    buf_size -= sizeof(pj_stun_msg_hdr);
 2651|       |
 2652|       |    /* Encode each attribute to the message */
 2653|  10.8k|    for (i=0; i<msg->attr_count; ++i) {
  ------------------
  |  Branch (2653:15): [True: 10.4k, False: 401]
  ------------------
 2654|  10.4k|        const struct attr_desc *adesc;
 2655|  10.4k|        const pj_stun_attr_hdr *attr_hdr = msg->attr[i];
 2656|       |
 2657|  10.4k|        if (attr_hdr->type == PJ_STUN_ATTR_MESSAGE_INTEGRITY) {
  ------------------
  |  Branch (2657:13): [True: 1.24k, False: 9.19k]
  ------------------
 2658|  1.24k|            pj_assert(amsgint == NULL);
  ------------------
  |  |   65|  1.24k|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (2658:13): [True: 0, False: 1.24k]
  |  Branch (2658:13): [True: 1.24k, False: 0]
  ------------------
 2659|  1.24k|            amsgint = (pj_stun_msgint_attr*) attr_hdr;
 2660|       |
 2661|       |            /* Stop when encountering MESSAGE-INTEGRITY */
 2662|  1.24k|            break;
 2663|       |
 2664|  9.19k|        } else if (attr_hdr->type == PJ_STUN_ATTR_FINGERPRINT) {
  ------------------
  |  Branch (2664:20): [True: 0, False: 9.19k]
  ------------------
 2665|      0|            afingerprint = (pj_stun_fingerprint_attr*) attr_hdr;
 2666|      0|            break;
 2667|      0|        }
 2668|       |
 2669|  9.19k|        adesc = find_attr_desc(attr_hdr->type);
 2670|  9.19k|        if (adesc) {
  ------------------
  |  Branch (2670:13): [True: 9.19k, False: 0]
  ------------------
 2671|  9.19k|            status = adesc->encode_attr(attr_hdr, buf, (unsigned)buf_size, 
 2672|  9.19k|                                        &msg->hdr, &printed);
 2673|  9.19k|        } else {
 2674|       |            /* This may be a generic attribute */
 2675|      0|            const pj_stun_binary_attr *bin_attr = (const pj_stun_binary_attr*) 
 2676|      0|                                                   attr_hdr;
 2677|      0|            PJ_ASSERT_RETURN(bin_attr->magic == PJ_STUN_MAGIC, PJ_EBUG);
  ------------------
  |  |   97|      0|            do { \
  |  |   98|      0|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 0]
  |  |  ------------------
  |  |   99|      0|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (2677:13): [True: 0, False: 0]
  |  Branch (2677:13): [True: 0, False: 0]
  ------------------
 2678|      0|            status = encode_binary_attr(bin_attr, buf, (unsigned)buf_size, 
 2679|      0|                                        &msg->hdr, &printed);
 2680|      0|        }
 2681|       |
 2682|  9.19k|        if (status != PJ_SUCCESS)
  ------------------
  |  Branch (2682:13): [True: 0, False: 9.19k]
  ------------------
 2683|      0|            return status;
 2684|       |
 2685|  9.19k|        buf += printed;
 2686|  9.19k|        buf_size -= printed;
 2687|  9.19k|    }
 2688|       |
 2689|       |    /* We may have stopped printing attribute because we found
 2690|       |     * MESSAGE-INTEGRITY or FINGERPRINT. Scan the rest of the
 2691|       |     * attributes.
 2692|       |     */
 2693|  1.64k|    for ( ++i; i<msg->attr_count; ++i) {
  ------------------
  |  Branch (2693:16): [True: 0, False: 1.64k]
  ------------------
 2694|      0|        const pj_stun_attr_hdr *attr_hdr = msg->attr[i];
 2695|       |
 2696|       |        /* There mustn't any attribute after FINGERPRINT */
 2697|      0|        PJ_ASSERT_RETURN(afingerprint == NULL, PJNATH_ESTUNFINGERPOS);
  ------------------
  |  |   97|      0|            do { \
  |  |   98|      0|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 0]
  |  |  ------------------
  |  |   99|      0|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (2697:9): [True: 0, False: 0]
  |  Branch (2697:9): [True: 0, False: 0]
  ------------------
 2698|       |
 2699|      0|        if (attr_hdr->type == PJ_STUN_ATTR_MESSAGE_INTEGRITY) {
  ------------------
  |  Branch (2699:13): [True: 0, False: 0]
  ------------------
 2700|       |            /* There mustn't be MESSAGE-INTEGRITY before */
 2701|      0|            PJ_ASSERT_RETURN(amsgint == NULL, 
  ------------------
  |  |   97|      0|            do { \
  |  |   98|      0|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 0]
  |  |  ------------------
  |  |   99|      0|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (2701:13): [True: 0, False: 0]
  |  Branch (2701:13): [True: 0, False: 0]
  ------------------
 2702|      0|                             PJNATH_ESTUNMSGINTPOS);
 2703|      0|            amsgint = (pj_stun_msgint_attr*) attr_hdr;
 2704|       |
 2705|      0|        } else if (attr_hdr->type == PJ_STUN_ATTR_FINGERPRINT) {
  ------------------
  |  Branch (2705:20): [True: 0, False: 0]
  ------------------
 2706|      0|            afingerprint = (pj_stun_fingerprint_attr*) attr_hdr;
 2707|      0|        }
 2708|      0|    }
 2709|       |
 2710|       |#if PJ_STUN_OLD_STYLE_MI_FINGERPRINT
 2711|       |    /*
 2712|       |     * This is the old style MESSAGE-INTEGRITY and FINGERPRINT
 2713|       |     * calculation, used in rfc3489bis-06 and older.
 2714|       |     */
 2715|       |    /* We MUST update the message length in the header NOW before
 2716|       |     * calculating MESSAGE-INTEGRITY and FINGERPRINT. 
 2717|       |     * Note that length is not including the 20 bytes header.
 2718|       |      */
 2719|       |    if (amsgint && afingerprint) {
 2720|       |        body_len = (pj_uint16_t)((buf - start) - 20 + 24 + 8);
 2721|       |    } else if (amsgint) {
 2722|       |        body_len = (pj_uint16_t)((buf - start) - 20 + 24);
 2723|       |    } else if (afingerprint) {
 2724|       |        body_len = (pj_uint16_t)((buf - start) - 20 + 8);
 2725|       |    } else {
 2726|       |        body_len = (pj_uint16_t)((buf - start) - 20);
 2727|       |    }
 2728|       |#else
 2729|       |    /* If MESSAGE-INTEGRITY is present, include the M-I attribute
 2730|       |     * in message length before calculating M-I
 2731|       |     */
 2732|  1.64k|    if (amsgint) {
  ------------------
  |  Branch (2732:9): [True: 1.24k, False: 401]
  ------------------
 2733|  1.24k|        body_len = (pj_uint16_t)((buf - start) - 20 + 24);
 2734|  1.24k|    } else {
 2735|    401|        body_len = (pj_uint16_t)((buf - start) - 20);
 2736|    401|    }
 2737|  1.64k|#endif  /* PJ_STUN_OLD_STYLE_MI_FINGERPRINT */
 2738|       |
 2739|       |    /* hdr->length = pj_htons(length); */
 2740|  1.64k|    PUTVAL16H(start, 2, (pj_uint16_t)body_len);
 2741|       |
 2742|       |    /* Calculate message integrity, if present */
 2743|  1.64k|    if (amsgint != NULL) {
  ------------------
  |  Branch (2743:9): [True: 1.24k, False: 401]
  ------------------
 2744|  1.24k|        pj_hmac_sha1_context ctx;
 2745|       |
 2746|       |        /* Key MUST be specified */
 2747|  1.24k|        PJ_ASSERT_RETURN(key, PJ_EINVALIDOP);
  ------------------
  |  |   97|  1.24k|            do { \
  |  |   98|  1.24k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 1.24k]
  |  |  ------------------
  |  |   99|  1.24k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1.24k]
  |  |  ------------------
  ------------------
  |  Branch (2747:9): [True: 0, False: 0]
  |  Branch (2747:9): [True: 0, False: 0]
  ------------------
 2748|       |
 2749|       |        /* MESSAGE-INTEGRITY must be the last attribute in the message, or
 2750|       |         * the last attribute before FINGERPRINT.
 2751|       |         */
 2752|  1.24k|        if (msg->attr_count>1 && i < msg->attr_count-2) {
  ------------------
  |  Branch (2752:13): [True: 1.24k, False: 0]
  |  Branch (2752:34): [True: 0, False: 1.24k]
  ------------------
 2753|       |            /* Should not happen for message generated by us */
 2754|      0|            pj_assert(PJ_FALSE);
  ------------------
  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (2754:13): [Folded, False: 0]
  |  Branch (2754:13): [Folded, False: 0]
  ------------------
 2755|      0|            return PJNATH_ESTUNMSGINTPOS;
  ------------------
  |  |   99|      0|#define PJNATH_ESTUNMSGINTPOS       (PJNATH_ERRNO_START+31) /* 370031 */
  |  |  ------------------
  |  |  |  |   40|      0|#define PJNATH_ERRNO_START    (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*4)
  |  |  |  |  ------------------
  |  |  |  |  |  |  535|      0|#define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  528|      0|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define PJNATH_ERRNO_START    (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*4)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2756|       |
 2757|  1.24k|        } else if (i == msg->attr_count-2)  {
  ------------------
  |  Branch (2757:20): [True: 0, False: 1.24k]
  ------------------
 2758|      0|            if (msg->attr[i+1]->type != PJ_STUN_ATTR_FINGERPRINT) {
  ------------------
  |  Branch (2758:17): [True: 0, False: 0]
  ------------------
 2759|       |                /* Should not happen for message generated by us */
 2760|      0|                pj_assert(PJ_FALSE);
  ------------------
  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (2760:17): [Folded, False: 0]
  |  Branch (2760:17): [Folded, False: 0]
  ------------------
 2761|      0|                return PJNATH_ESTUNMSGINTPOS;
  ------------------
  |  |   99|      0|#define PJNATH_ESTUNMSGINTPOS       (PJNATH_ERRNO_START+31) /* 370031 */
  |  |  ------------------
  |  |  |  |   40|      0|#define PJNATH_ERRNO_START    (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*4)
  |  |  |  |  ------------------
  |  |  |  |  |  |  535|      0|#define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  528|      0|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define PJNATH_ERRNO_START    (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*4)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2762|      0|            } else {
 2763|      0|                afingerprint = (pj_stun_fingerprint_attr*) msg->attr[i+1];
 2764|      0|            }
 2765|      0|        }
 2766|       |
 2767|       |        /* Calculate HMAC-SHA1 digest, add zero padding to input
 2768|       |         * if necessary to make the input 64 bytes aligned.
 2769|       |         */
 2770|  1.24k|        pj_hmac_sha1_init(&ctx, (const pj_uint8_t*)key->ptr, 
 2771|  1.24k|                          (unsigned)key->slen);
 2772|  1.24k|        pj_hmac_sha1_update(&ctx, (const pj_uint8_t*)start, 
 2773|  1.24k|                            (unsigned)(buf-start));
 2774|       |#if PJ_STUN_OLD_STYLE_MI_FINGERPRINT
 2775|       |        // These are obsoleted in rfc3489bis-08
 2776|       |        if ((buf-start) & 0x3F) {
 2777|       |            pj_uint8_t zeroes[64];
 2778|       |            pj_bzero(zeroes, sizeof(zeroes));
 2779|       |            pj_hmac_sha1_update(&ctx, zeroes, 64-((buf-start) & 0x3F));
 2780|       |        }
 2781|       |#endif  /* PJ_STUN_OLD_STYLE_MI_FINGERPRINT */
 2782|  1.24k|        pj_hmac_sha1_final(&ctx, amsgint->hmac);
 2783|       |
 2784|       |        /* Put this attribute in the message */
 2785|  1.24k|        status = encode_msgint_attr(amsgint, buf, (unsigned)buf_size, 
 2786|  1.24k|                                    &msg->hdr, &printed);
 2787|  1.24k|        if (status != PJ_SUCCESS)
  ------------------
  |  Branch (2787:13): [True: 0, False: 1.24k]
  ------------------
 2788|      0|            return status;
 2789|       |
 2790|  1.24k|        buf += printed;
 2791|  1.24k|        buf_size -= printed;
 2792|  1.24k|    }
 2793|       |
 2794|       |    /* Calculate FINGERPRINT if present */
 2795|  1.64k|    if (afingerprint != NULL) {
  ------------------
  |  Branch (2795:9): [True: 0, False: 1.64k]
  ------------------
 2796|       |
 2797|      0|#if !PJ_STUN_OLD_STYLE_MI_FINGERPRINT
 2798|       |        /* Update message length */
 2799|      0|        PUTVAL16H(start, 2, 
 2800|      0|                 (pj_uint16_t)(GETVAL16H(start, 2)+8));
 2801|      0|#endif
 2802|       |
 2803|      0|        afingerprint->value = pj_crc32_calc(start, buf-start);
 2804|      0|        afingerprint->value ^= STUN_XOR_FINGERPRINT;
  ------------------
  |  |   31|      0|#define STUN_XOR_FINGERPRINT    0x5354554eL
  ------------------
 2805|       |
 2806|       |        /* Put this attribute in the message */
 2807|      0|        status = encode_uint_attr(afingerprint, buf, (unsigned)buf_size, 
 2808|      0|                                  &msg->hdr, &printed);
 2809|      0|        if (status != PJ_SUCCESS)
  ------------------
  |  Branch (2809:13): [True: 0, False: 0]
  ------------------
 2810|      0|            return status;
 2811|       |
 2812|      0|        buf += printed;
 2813|      0|        buf_size -= printed;
 2814|      0|    }
 2815|       |
 2816|       |    /* Update message length. */
 2817|  1.64k|    msg->hdr.length = (pj_uint16_t) ((buf - start) - 20);
 2818|       |
 2819|       |    /* Return the length */
 2820|  1.64k|    if (p_msg_len)
  ------------------
  |  Branch (2820:9): [True: 1.64k, False: 0]
  ------------------
 2821|  1.64k|        *p_msg_len = (buf - start);
 2822|       |
 2823|  1.64k|    return PJ_SUCCESS;
 2824|  1.64k|}
pj_stun_msg_find_attr:
 2834|  6.40k|{
 2835|  6.40k|    PJ_ASSERT_RETURN(msg, NULL);
  ------------------
  |  |   97|  6.40k|            do { \
  |  |   98|  6.40k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 6.40k]
  |  |  ------------------
  |  |   99|  6.40k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 6.40k]
  |  |  ------------------
  ------------------
  |  Branch (2835:5): [True: 0, False: 0]
  |  Branch (2835:5): [True: 0, False: 0]
  ------------------
 2836|       |
 2837|  21.3k|    for (; index < msg->attr_count; ++index) {
  ------------------
  |  Branch (2837:12): [True: 20.6k, False: 720]
  ------------------
 2838|  20.6k|        if (msg->attr[index]->type == attr_type)
  ------------------
  |  Branch (2838:13): [True: 5.68k, False: 14.9k]
  ------------------
 2839|  5.68k|            return (pj_stun_attr_hdr*) msg->attr[index];
 2840|  20.6k|    }
 2841|       |
 2842|    720|    return NULL;
 2843|  6.40k|}
stun_msg.c:find_attr_desc:
  649|  15.8k|{
  650|  15.8k|    struct attr_desc *desc;
  651|       |
  652|       |    /* Check that attr_desc array is valid */
  653|  15.8k|    pj_assert(PJ_ARRAY_SIZE(mandatory_attr_desc)==
  ------------------
  |  |   65|  15.8k|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (653:5): [True: 0, Folded]
  |  Branch (653:5): [True: 15.8k, Folded]
  ------------------
  654|  15.8k|              PJ_STUN_ATTR_END_MANDATORY_ATTR+1);
  655|  15.8k|    pj_assert(mandatory_attr_desc[PJ_STUN_ATTR_END_MANDATORY_ATTR].decode_attr
  ------------------
  |  |   65|  15.8k|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (655:5): [True: 0, False: 15.8k]
  |  Branch (655:5): [True: 15.8k, False: 0]
  ------------------
  656|  15.8k|              == NULL);
  657|  15.8k|    pj_assert(mandatory_attr_desc[PJ_STUN_ATTR_USE_CANDIDATE].decode_attr 
  ------------------
  |  |   65|  15.8k|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (657:5): [True: 0, False: 15.8k]
  |  Branch (657:5): [True: 15.8k, False: 0]
  ------------------
  658|  15.8k|              == &decode_empty_attr);
  659|  15.8k|    pj_assert(PJ_ARRAY_SIZE(extended_attr_desc) ==
  ------------------
  |  |   65|  15.8k|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (659:5): [True: 0, Folded]
  |  Branch (659:5): [True: 15.8k, Folded]
  ------------------
  660|  15.8k|              PJ_STUN_ATTR_END_EXTENDED_ATTR-PJ_STUN_ATTR_START_EXTENDED_ATTR);
  661|       |
  662|  15.8k|    if (attr_type < PJ_STUN_ATTR_END_MANDATORY_ATTR)
  ------------------
  |  Branch (662:9): [True: 12.6k, False: 3.15k]
  ------------------
  663|  12.6k|        desc = &mandatory_attr_desc[attr_type];
  664|  3.15k|    else if (attr_type >= PJ_STUN_ATTR_START_EXTENDED_ATTR &&
  ------------------
  |  Branch (664:14): [True: 2.93k, False: 225]
  ------------------
  665|  2.93k|             attr_type < PJ_STUN_ATTR_END_EXTENDED_ATTR)
  ------------------
  |  Branch (665:14): [True: 2.04k, False: 891]
  ------------------
  666|  2.04k|        desc = &extended_attr_desc[attr_type-PJ_STUN_ATTR_START_EXTENDED_ATTR];
  667|  1.11k|    else
  668|  1.11k|        return NULL;
  669|       |
  670|  14.7k|    return desc->decode_attr == NULL ? NULL : desc;
  ------------------
  |  Branch (670:12): [True: 337, False: 14.3k]
  ------------------
  671|  15.8k|}
stun_msg.c:decode_sockaddr_attr:
  885|    831|{
  886|    831|    pj_stun_sockaddr_attr *attr;
  887|    831|    int af;
  888|    831|    unsigned addr_len;
  889|    831|    pj_uint32_t val;
  890|       |
  891|    831|    PJ_CHECK_STACK();
  892|       |    
  893|    831|    PJ_UNUSED_ARG(msghdr);
  ------------------
  |  | 1537|    831|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
  894|       |
  895|       |    /* Create the attribute */
  896|    831|    attr = PJ_POOL_ZALLOC_T(pool, pj_stun_sockaddr_attr);
  ------------------
  |  |  583|    831|            ((type*)pj_pool_zalloc(pool, sizeof(type)))
  ------------------
  897|    831|    GETATTRHDR(buf, &attr->hdr);
  898|       |
  899|       |    /* Check that the attribute length is valid */
  900|    831|    if (attr->hdr.length != STUN_GENERIC_IPV4_ADDR_LEN &&
  ------------------
  |  |  812|  1.66k|#define STUN_GENERIC_IPV4_ADDR_LEN      8
  ------------------
  |  Branch (900:9): [True: 648, False: 183]
  ------------------
  901|    648|        attr->hdr.length != STUN_GENERIC_IPV6_ADDR_LEN)
  ------------------
  |  |  813|    648|#define STUN_GENERIC_IPV6_ADDR_LEN      20
  ------------------
  |  Branch (901:9): [True: 37, False: 611]
  ------------------
  902|     37|    {
  903|     37|        return PJNATH_ESTUNINATTRLEN;
  ------------------
  |  |   83|     37|#define PJNATH_ESTUNINATTRLEN       (PJNATH_ERRNO_START+22) /* 370022 */
  |  |  ------------------
  |  |  |  |   40|     37|#define PJNATH_ERRNO_START    (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*4)
  |  |  |  |  ------------------
  |  |  |  |  |  |  535|     37|#define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  528|     37|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  521|     37|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  509|     37|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  515|     37|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  515|     37|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  515|     37|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define PJNATH_ERRNO_START    (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*4)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|     37|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  904|     37|    }
  905|       |
  906|       |    /* Check address family */
  907|    794|    val = *(pj_uint8_t*)(buf + ATTR_HDR_LEN + 1);
  ------------------
  |  |  749|    794|#define ATTR_HDR_LEN        sizeof(pj_stun_attr_hdr)
  ------------------
  908|       |
  909|       |    /* Check address family is valid */
  910|    794|    if (val == 1) {
  ------------------
  |  Branch (910:9): [True: 165, False: 629]
  ------------------
  911|    165|        if (attr->hdr.length != STUN_GENERIC_IPV4_ADDR_LEN)
  ------------------
  |  |  812|    165|#define STUN_GENERIC_IPV4_ADDR_LEN      8
  ------------------
  |  Branch (911:13): [True: 3, False: 162]
  ------------------
  912|      3|            return PJNATH_ESTUNINATTRLEN;
  ------------------
  |  |   83|      3|#define PJNATH_ESTUNINATTRLEN       (PJNATH_ERRNO_START+22) /* 370022 */
  |  |  ------------------
  |  |  |  |   40|      3|#define PJNATH_ERRNO_START    (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*4)
  |  |  |  |  ------------------
  |  |  |  |  |  |  535|      3|#define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  528|      3|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  521|      3|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  509|      3|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  515|      3|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  515|      3|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  515|      3|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define PJNATH_ERRNO_START    (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*4)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      3|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  913|    162|        af = pj_AF_INET();
  ------------------
  |  |  113|    162|#   define pj_AF_INET()     PJ_AF_INET
  ------------------
  914|    162|        addr_len = 4;
  915|    629|    } else if (val == 2) {
  ------------------
  |  Branch (915:16): [True: 611, False: 18]
  ------------------
  916|    611|        if (attr->hdr.length != STUN_GENERIC_IPV6_ADDR_LEN)
  ------------------
  |  |  813|    611|#define STUN_GENERIC_IPV6_ADDR_LEN      20
  ------------------
  |  Branch (916:13): [True: 3, False: 608]
  ------------------
  917|      3|            return PJNATH_ESTUNINATTRLEN;
  ------------------
  |  |   83|      3|#define PJNATH_ESTUNINATTRLEN       (PJNATH_ERRNO_START+22) /* 370022 */
  |  |  ------------------
  |  |  |  |   40|      3|#define PJNATH_ERRNO_START    (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*4)
  |  |  |  |  ------------------
  |  |  |  |  |  |  535|      3|#define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  528|      3|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  521|      3|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  509|      3|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  515|      3|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  515|      3|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  515|      3|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define PJNATH_ERRNO_START    (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*4)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      3|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  918|    608|        af = pj_AF_INET6();
  ------------------
  |  |  115|    608|#   define pj_AF_INET6()    PJ_AF_INET6
  ------------------
  919|    608|        addr_len = 16;
  920|    608|    } else {
  921|       |        /* Invalid address family */
  922|     18|        return PJNATH_EINVAF;
  ------------------
  |  |  121|     18|#define PJNATH_EINVAF               (PJNATH_ERRNO_START+42) /* 370042 */
  |  |  ------------------
  |  |  |  |   40|     18|#define PJNATH_ERRNO_START    (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*4)
  |  |  |  |  ------------------
  |  |  |  |  |  |  535|     18|#define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  528|     18|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  521|     18|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  509|     18|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  515|     18|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  515|     18|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  515|     18|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define PJNATH_ERRNO_START    (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*4)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|     18|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  923|     18|    }
  924|       |
  925|       |    /* Get port and address */
  926|    770|    pj_sockaddr_init(af, &attr->sockaddr, NULL, 0);
  927|    770|    pj_sockaddr_set_port(&attr->sockaddr, 
  928|    770|                         GETVAL16H(buf, ATTR_HDR_LEN+2));
  ------------------
  |  |  749|    770|#define ATTR_HDR_LEN        sizeof(pj_stun_attr_hdr)
  ------------------
  929|    770|    pj_memcpy(pj_sockaddr_get_addr(&attr->sockaddr),
  930|    770|              buf+ATTR_HDR_LEN+4,
  ------------------
  |  |  749|    770|#define ATTR_HDR_LEN        sizeof(pj_stun_attr_hdr)
  ------------------
  931|    770|              addr_len);
  932|       |
  933|       |    /* Done */
  934|    770|    *p_attr = (void*)attr;
  935|       |
  936|    770|    return PJ_SUCCESS;
  937|    794|}
stun_msg.c:GETATTRHDR:
  803|  5.12k|{
  804|  5.12k|    hdr->type = GETVAL16H(buf, 0);
  805|  5.12k|    hdr->length = GETVAL16H(buf, 2);
  806|  5.12k|}
stun_msg.c:encode_sockaddr_attr:
  995|  2.48k|{
  996|  2.48k|    pj_uint8_t *start_buf = buf;
  997|  2.48k|    const pj_stun_sockaddr_attr *ca = 
  998|  2.48k|        (const pj_stun_sockaddr_attr *)a;
  999|       |
 1000|  2.48k|    PJ_CHECK_STACK();
 1001|       |    
 1002|       |    /* Common: attribute type */
 1003|  2.48k|    PUTVAL16H(buf, 0, ca->hdr.type);
 1004|       |
 1005|  2.48k|    if (ca->sockaddr.addr.sa_family == pj_AF_INET()) {
  ------------------
  |  |  113|  2.48k|#   define pj_AF_INET()     PJ_AF_INET
  ------------------
  |  Branch (1005:9): [True: 2.48k, False: 0]
  ------------------
 1006|  2.48k|        enum {
 1007|  2.48k|            ATTR_LEN = ATTR_HDR_LEN + STUN_GENERIC_IPV4_ADDR_LEN
 1008|  2.48k|        };
 1009|       |
 1010|  2.48k|        if (len < ATTR_LEN) 
  ------------------
  |  Branch (1010:13): [True: 0, False: 2.48k]
  ------------------
 1011|      0|            return PJ_ETOOSMALL;
  ------------------
  |  |  469|      0|#define PJ_ETOOSMALL        (PJ_ERRNO_START_STATUS + 19)/* 70019 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1012|       |
 1013|       |        /* attribute len */
 1014|  2.48k|        PUTVAL16H(buf, 2, STUN_GENERIC_IPV4_ADDR_LEN);
  ------------------
  |  |  812|  2.48k|#define STUN_GENERIC_IPV4_ADDR_LEN      8
  ------------------
 1015|  2.48k|        buf += ATTR_HDR_LEN;
  ------------------
  |  |  749|  2.48k|#define ATTR_HDR_LEN        sizeof(pj_stun_attr_hdr)
  ------------------
 1016|       |    
 1017|       |        /* Ignored */
 1018|  2.48k|        *buf++ = '\0';
 1019|       |
 1020|       |        /* Address family, 1 for IPv4 */
 1021|  2.48k|        *buf++ = 1;
 1022|       |
 1023|       |        /* IPv4 address */
 1024|  2.48k|        if (ca->xor_ed) {
  ------------------
  |  Branch (1024:13): [True: 1.24k, False: 1.24k]
  ------------------
 1025|  1.24k|            pj_uint32_t addr;
 1026|  1.24k|            pj_uint16_t port;
 1027|       |
 1028|  1.24k|            addr = ca->sockaddr.ipv4.sin_addr.s_addr;
 1029|  1.24k|            port = ca->sockaddr.ipv4.sin_port;
 1030|       |
 1031|  1.24k|            port ^= pj_htons(PJ_STUN_MAGIC >> 16);
  ------------------
  |  |   46|  1.24k|#define PJ_STUN_MAGIC                       0x2112A442
  ------------------
 1032|  1.24k|            addr ^= pj_htonl(PJ_STUN_MAGIC);
  ------------------
  |  |   46|  1.24k|#define PJ_STUN_MAGIC                       0x2112A442
  ------------------
 1033|       |
 1034|       |            /* Port */
 1035|  1.24k|            pj_memcpy(buf, &port, 2);
 1036|  1.24k|            buf += 2;
 1037|       |
 1038|       |            /* Address */
 1039|  1.24k|            pj_memcpy(buf, &addr, 4);
 1040|  1.24k|            buf += 4;
 1041|       |
 1042|  1.24k|        } else {
 1043|       |            /* Port */
 1044|  1.24k|            pj_memcpy(buf, &ca->sockaddr.ipv4.sin_port, 2);
 1045|  1.24k|            buf += 2;
 1046|       |
 1047|       |            /* Address */
 1048|  1.24k|            pj_memcpy(buf, &ca->sockaddr.ipv4.sin_addr, 4);
 1049|  1.24k|            buf += 4;
 1050|  1.24k|        }
 1051|       |
 1052|  2.48k|        pj_assert(buf - start_buf == ATTR_LEN);
  ------------------
  |  |   65|  2.48k|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (1052:9): [True: 0, False: 2.48k]
  |  Branch (1052:9): [True: 2.48k, False: 0]
  ------------------
 1053|       |
 1054|  2.48k|    } else if (ca->sockaddr.addr.sa_family == pj_AF_INET6()) {
  ------------------
  |  |  115|      0|#   define pj_AF_INET6()    PJ_AF_INET6
  ------------------
  |  Branch (1054:16): [True: 0, False: 0]
  ------------------
 1055|       |        /* IPv6 address */
 1056|      0|        enum {
 1057|      0|            ATTR_LEN = ATTR_HDR_LEN + STUN_GENERIC_IPV6_ADDR_LEN
 1058|      0|        };
 1059|       |
 1060|      0|        if (len < ATTR_LEN) 
  ------------------
  |  Branch (1060:13): [True: 0, False: 0]
  ------------------
 1061|      0|            return PJ_ETOOSMALL;
  ------------------
  |  |  469|      0|#define PJ_ETOOSMALL        (PJ_ERRNO_START_STATUS + 19)/* 70019 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1062|       |
 1063|       |        /* attribute len */
 1064|      0|        PUTVAL16H(buf, 2, STUN_GENERIC_IPV6_ADDR_LEN);
  ------------------
  |  |  813|      0|#define STUN_GENERIC_IPV6_ADDR_LEN      20
  ------------------
 1065|      0|        buf += ATTR_HDR_LEN;
  ------------------
  |  |  749|      0|#define ATTR_HDR_LEN        sizeof(pj_stun_attr_hdr)
  ------------------
 1066|       |    
 1067|       |        /* Ignored */
 1068|      0|        *buf++ = '\0';
 1069|       |
 1070|       |        /* Address family, 2 for IPv6 */
 1071|      0|        *buf++ = 2;
 1072|       |
 1073|       |        /* IPv6 address */
 1074|      0|        if (ca->xor_ed) {
  ------------------
  |  Branch (1074:13): [True: 0, False: 0]
  ------------------
 1075|      0|            unsigned i;
 1076|      0|            pj_uint8_t *dst;
 1077|      0|            const pj_uint8_t *src;
 1078|      0|            pj_uint32_t magic = pj_htonl(PJ_STUN_MAGIC);
  ------------------
  |  |   46|      0|#define PJ_STUN_MAGIC                       0x2112A442
  ------------------
 1079|      0|            pj_uint16_t port = ca->sockaddr.ipv6.sin6_port;
 1080|       |
 1081|       |            /* Port */
 1082|      0|            port ^= pj_htons(PJ_STUN_MAGIC >> 16);
  ------------------
  |  |   46|      0|#define PJ_STUN_MAGIC                       0x2112A442
  ------------------
 1083|      0|            pj_memcpy(buf, &port, 2);
 1084|      0|            buf += 2;
 1085|       |
 1086|       |            /* Address */
 1087|      0|            dst = buf;
 1088|      0|            src = (const pj_uint8_t*) &ca->sockaddr.ipv6.sin6_addr;
 1089|      0|            for (i=0; i<4; ++i) {
  ------------------
  |  Branch (1089:23): [True: 0, False: 0]
  ------------------
 1090|      0|                dst[i] = (pj_uint8_t)(src[i] ^ ((const pj_uint8_t*)&magic)[i]);
 1091|      0|            }
 1092|      0|            pj_assert(sizeof(msghdr->tsx_id[0]) == 1);
  ------------------
  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (1092:13): [True: 0, Folded]
  |  Branch (1092:13): [True: 0, Folded]
  ------------------
 1093|      0|            for (i=0; i<12; ++i) {
  ------------------
  |  Branch (1093:23): [True: 0, False: 0]
  ------------------
 1094|      0|                dst[i+4] = (pj_uint8_t)(src[i+4] ^ msghdr->tsx_id[i]);
 1095|      0|            }
 1096|       |
 1097|      0|            buf += 16;
 1098|       |
 1099|      0|        } else {
 1100|       |            /* Port */
 1101|      0|            pj_memcpy(buf, &ca->sockaddr.ipv6.sin6_port, 2);
 1102|      0|            buf += 2;
 1103|       |
 1104|       |            /* Address */
 1105|      0|            pj_memcpy(buf, &ca->sockaddr.ipv6.sin6_addr, 16);
 1106|      0|            buf += 16;
 1107|      0|        }
 1108|       |
 1109|      0|        pj_assert(buf - start_buf == ATTR_LEN);
  ------------------
  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (1109:9): [True: 0, False: 0]
  |  Branch (1109:9): [True: 0, False: 0]
  ------------------
 1110|       |
 1111|      0|    } else {
 1112|      0|        return PJNATH_EINVAF;
  ------------------
  |  |  121|      0|#define PJNATH_EINVAF               (PJNATH_ERRNO_START+42) /* 370042 */
  |  |  ------------------
  |  |  |  |   40|      0|#define PJNATH_ERRNO_START    (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*4)
  |  |  |  |  ------------------
  |  |  |  |  |  |  535|      0|#define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  528|      0|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define PJNATH_ERRNO_START    (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*4)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1113|      0|    }
 1114|       |
 1115|       |    /* Done */
 1116|  2.48k|    *printed = (unsigned)(buf - start_buf);
 1117|       |
 1118|  2.48k|    return PJ_SUCCESS;
 1119|  2.48k|}
stun_msg.c:decode_uint_attr:
 1432|    135|{
 1433|    135|    pj_stun_uint_attr *attr;
 1434|       |
 1435|    135|    PJ_UNUSED_ARG(msghdr);
  ------------------
  |  | 1537|    135|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
 1436|       |
 1437|       |    /* Create the attribute */
 1438|    135|    attr = PJ_POOL_ZALLOC_T(pool, pj_stun_uint_attr);
  ------------------
  |  |  583|    135|            ((type*)pj_pool_zalloc(pool, sizeof(type)))
  ------------------
 1439|    135|    GETATTRHDR(buf, &attr->hdr);
 1440|       |
 1441|       |    /* Check that the attribute length is valid */
 1442|    135|    if (attr->hdr.length != 4)
  ------------------
  |  Branch (1442:9): [True: 30, False: 105]
  ------------------
 1443|     30|        return PJNATH_ESTUNINATTRLEN;
  ------------------
  |  |   83|     30|#define PJNATH_ESTUNINATTRLEN       (PJNATH_ERRNO_START+22) /* 370022 */
  |  |  ------------------
  |  |  |  |   40|     30|#define PJNATH_ERRNO_START    (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*4)
  |  |  |  |  ------------------
  |  |  |  |  |  |  535|     30|#define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  528|     30|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  521|     30|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  509|     30|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  515|     30|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  515|     30|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  515|     30|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define PJNATH_ERRNO_START    (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*4)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|     30|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1444|       |
 1445|    105|    attr->value = GETVAL32H(buf, 4);
 1446|       |
 1447|       |    /* Done */
 1448|    105|    *p_attr = attr;
 1449|       |
 1450|    105|    return PJ_SUCCESS;
 1451|    135|}
stun_msg.c:decode_string_attr:
 1196|  2.08k|{
 1197|  2.08k|    pj_stun_string_attr *attr;
 1198|  2.08k|    pj_str_t value;
 1199|       |
 1200|  2.08k|    PJ_UNUSED_ARG(msghdr);
  ------------------
  |  | 1537|  2.08k|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
 1201|       |
 1202|       |    /* Create the attribute */
 1203|  2.08k|    attr = PJ_POOL_ZALLOC_T(pool, pj_stun_string_attr);
  ------------------
  |  |  583|  2.08k|            ((type*)pj_pool_zalloc(pool, sizeof(type)))
  ------------------
 1204|  2.08k|    GETATTRHDR(buf, &attr->hdr);
 1205|       |
 1206|       |    /* Get pointer to the string in the message */
 1207|  2.08k|    value.ptr = ((char*)buf + ATTR_HDR_LEN);
  ------------------
  |  |  749|  2.08k|#define ATTR_HDR_LEN        sizeof(pj_stun_attr_hdr)
  ------------------
 1208|  2.08k|    value.slen = attr->hdr.length;
 1209|       |
 1210|       |    /* Copy the string to the attribute */
 1211|  2.08k|    pj_strdup(pool, &attr->value, &value);
 1212|       |
 1213|       |    /* Done */
 1214|  2.08k|    *p_attr = attr;
 1215|       |
 1216|  2.08k|    return PJ_SUCCESS;
 1217|       |
 1218|  2.08k|}
stun_msg.c:encode_string_attr:
 1225|  5.37k|{
 1226|  5.37k|    const pj_stun_string_attr *ca = 
 1227|  5.37k|        (const pj_stun_string_attr*)a;
 1228|       |
 1229|  5.37k|    PJ_CHECK_STACK();
 1230|       |    
 1231|  5.37k|    PJ_UNUSED_ARG(msghdr);
  ------------------
  |  | 1537|  5.37k|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
 1232|       |
 1233|       |    /* Calculated total attr_len (add padding if necessary) */
 1234|  5.37k|    *printed = ((unsigned)ca->value.slen + ATTR_HDR_LEN + 3) & (~3);
  ------------------
  |  |  749|  5.37k|#define ATTR_HDR_LEN        sizeof(pj_stun_attr_hdr)
  ------------------
 1235|  5.37k|    if (len < *printed) {
  ------------------
  |  Branch (1235:9): [True: 0, False: 5.37k]
  ------------------
 1236|      0|        *printed = 0;
 1237|      0|        return PJ_ETOOSMALL;
  ------------------
  |  |  469|      0|#define PJ_ETOOSMALL        (PJ_ERRNO_START_STATUS + 19)/* 70019 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1238|      0|    }
 1239|       |
 1240|  5.37k|    PUTVAL16H(buf, 0, ca->hdr.type);
 1241|       |
 1242|       |    /* Special treatment for SOFTWARE attribute:
 1243|       |     * This attribute had caused interop problem when talking to 
 1244|       |     * legacy RFC 3489 STUN servers, due to different "length"
 1245|       |     * rules with RFC 5389.
 1246|       |     */
 1247|  5.37k|    if (msghdr->magic != PJ_STUN_MAGIC ||
  ------------------
  |  |   46|  10.7k|#define PJ_STUN_MAGIC                       0x2112A442
  ------------------
  |  Branch (1247:9): [True: 386, False: 4.98k]
  ------------------
 1248|  4.98k|        ca->hdr.type == PJ_STUN_ATTR_SOFTWARE)
  ------------------
  |  Branch (1248:9): [True: 1.25k, False: 3.72k]
  ------------------
 1249|  1.64k|    {
 1250|       |        /* Set the length to be 4-bytes aligned so that we can
 1251|       |         * communicate with RFC 3489 endpoints
 1252|       |         */
 1253|  1.64k|        PUTVAL16H(buf, 2, (pj_uint16_t)((ca->value.slen + 3) & (~3)));
 1254|  3.72k|    } else {
 1255|       |        /* Use RFC 5389 rule */
 1256|  3.72k|        PUTVAL16H(buf, 2, (pj_uint16_t)ca->value.slen);
 1257|  3.72k|    }
 1258|       |
 1259|       |    /* Copy the string */
 1260|  5.37k|    pj_memcpy(buf+ATTR_HDR_LEN, ca->value.ptr, ca->value.slen);
  ------------------
  |  |  749|  5.37k|#define ATTR_HDR_LEN        sizeof(pj_stun_attr_hdr)
  ------------------
 1261|       |
 1262|       |    /* Add padding character, if string is not 4-bytes aligned. */
 1263|  5.37k|    if (ca->value.slen & 0x03) {
  ------------------
  |  Branch (1263:9): [True: 2.16k, False: 3.21k]
  ------------------
 1264|  2.16k|        pj_uint8_t pad[3];
 1265|  2.16k|        pj_memset(pad, padding_char, sizeof(pad));
 1266|  2.16k|        pj_memcpy(buf+ATTR_HDR_LEN+ca->value.slen, pad,
  ------------------
  |  |  749|  2.16k|#define ATTR_HDR_LEN        sizeof(pj_stun_attr_hdr)
  ------------------
 1267|  2.16k|                  4-(ca->value.slen & 0x03));
 1268|  2.16k|    }
 1269|       |
 1270|       |    /* Done */
 1271|  5.37k|    return PJ_SUCCESS;
 1272|  5.37k|}
stun_msg.c:decode_msgint_attr:
 1632|    759|{
 1633|    759|    pj_stun_msgint_attr *attr;
 1634|       |
 1635|    759|    PJ_UNUSED_ARG(msghdr);
  ------------------
  |  | 1537|    759|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
 1636|       |
 1637|       |    /* Create attribute */
 1638|    759|    attr = PJ_POOL_ZALLOC_T(pool, pj_stun_msgint_attr);
  ------------------
  |  |  583|    759|            ((type*)pj_pool_zalloc(pool, sizeof(type)))
  ------------------
 1639|    759|    GETATTRHDR(buf, &attr->hdr);
 1640|       |
 1641|       |    /* Check that the attribute length is valid */
 1642|    759|    if (attr->hdr.length != 20)
  ------------------
  |  Branch (1642:9): [True: 11, False: 748]
  ------------------
 1643|     11|        return PJNATH_ESTUNINATTRLEN;
  ------------------
  |  |   83|     11|#define PJNATH_ESTUNINATTRLEN       (PJNATH_ERRNO_START+22) /* 370022 */
  |  |  ------------------
  |  |  |  |   40|     11|#define PJNATH_ERRNO_START    (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*4)
  |  |  |  |  ------------------
  |  |  |  |  |  |  535|     11|#define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  528|     11|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  521|     11|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  509|     11|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  515|     11|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  515|     11|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  515|     11|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define PJNATH_ERRNO_START    (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*4)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|     11|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1644|       |
 1645|       |    /* Copy hmac */
 1646|    748|    pj_memcpy(attr->hmac, buf+4, 20);
 1647|       |
 1648|       |    /* Done */
 1649|    748|    *p_attr = attr;
 1650|    748|    return PJ_SUCCESS;
 1651|    759|}
stun_msg.c:decode_errcode_attr:
 1750|    111|{
 1751|    111|    pj_stun_errcode_attr *attr;
 1752|    111|    pj_str_t value;
 1753|       |
 1754|    111|    PJ_UNUSED_ARG(msghdr);
  ------------------
  |  | 1537|    111|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
 1755|       |
 1756|       |    /* Create the attribute */
 1757|    111|    attr = PJ_POOL_ZALLOC_T(pool, pj_stun_errcode_attr);
  ------------------
  |  |  583|    111|            ((type*)pj_pool_zalloc(pool, sizeof(type)))
  ------------------
 1758|    111|    GETATTRHDR(buf, &attr->hdr);
 1759|       |
 1760|       |    /* Check that the attribute length is valid */
 1761|    111|    if (attr->hdr.length < 4)
  ------------------
  |  Branch (1761:9): [True: 8, False: 103]
  ------------------
 1762|      8|        return PJNATH_ESTUNINATTRLEN;
  ------------------
  |  |   83|      8|#define PJNATH_ESTUNINATTRLEN       (PJNATH_ERRNO_START+22) /* 370022 */
  |  |  ------------------
  |  |  |  |   40|      8|#define PJNATH_ERRNO_START    (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*4)
  |  |  |  |  ------------------
  |  |  |  |  |  |  535|      8|#define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  528|      8|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  521|      8|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  509|      8|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  515|      8|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  515|      8|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  515|      8|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define PJNATH_ERRNO_START    (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*4)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      8|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1763|       |
 1764|    103|    attr->err_code = buf[6] * 100 + buf[7];
 1765|       |
 1766|       |    /* Get pointer to the string in the message */
 1767|    103|    value.ptr = ((char*)buf + ATTR_HDR_LEN + 4);
  ------------------
  |  |  749|    103|#define ATTR_HDR_LEN        sizeof(pj_stun_attr_hdr)
  ------------------
 1768|    103|    value.slen = attr->hdr.length - 4;
 1769|       |
 1770|       |    /* Copy the string to the attribute */
 1771|    103|    pj_strdup(pool, &attr->reason, &value);
 1772|       |
 1773|       |    /* Done */
 1774|    103|    *p_attr = attr;
 1775|       |
 1776|    103|    return PJ_SUCCESS;
 1777|    111|}
stun_msg.c:encode_errcode_attr:
 1784|    960|{
 1785|    960|    const pj_stun_errcode_attr *ca = 
 1786|    960|        (const pj_stun_errcode_attr*)a;
 1787|       |
 1788|    960|    PJ_CHECK_STACK();
 1789|       |    
 1790|    960|    PJ_UNUSED_ARG(msghdr);
  ------------------
  |  | 1537|    960|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
 1791|       |
 1792|       |    /* Calculated total attr_len (add padding if necessary) */
 1793|    960|    *printed = (ATTR_HDR_LEN + 4 + (unsigned)ca->reason.slen + 3) & (~3);
  ------------------
  |  |  749|    960|#define ATTR_HDR_LEN        sizeof(pj_stun_attr_hdr)
  ------------------
 1794|    960|    if (len < *printed)
  ------------------
  |  Branch (1794:9): [True: 0, False: 960]
  ------------------
 1795|      0|        return PJ_ETOOSMALL;
  ------------------
  |  |  469|      0|#define PJ_ETOOSMALL        (PJ_ERRNO_START_STATUS + 19)/* 70019 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1796|       |
 1797|       |    /* Copy and convert attribute to network byte order */
 1798|    960|    PUTVAL16H(buf, 0, ca->hdr.type);
 1799|    960|    PUTVAL16H(buf, 2, (pj_uint16_t)(4 + ca->reason.slen));
 1800|    960|    PUTVAL16H(buf, 4, 0);
 1801|    960|    buf[6] = (pj_uint8_t)(ca->err_code / 100);
 1802|    960|    buf[7] = (pj_uint8_t)(ca->err_code % 100);
 1803|       |
 1804|       |    /* Copy error string */
 1805|    960|    pj_memcpy(buf + ATTR_HDR_LEN + 4, ca->reason.ptr, ca->reason.slen);
  ------------------
  |  |  749|    960|#define ATTR_HDR_LEN        sizeof(pj_stun_attr_hdr)
  ------------------
 1806|       |
 1807|       |    /* Zero-fill padding bytes if reason string is not 4-bytes aligned */
 1808|    960|    if (ca->reason.slen & 0x03) {
  ------------------
  |  Branch (1808:9): [True: 856, False: 104]
  ------------------
 1809|    856|        pj_uint8_t pad[3];
 1810|    856|        pj_memset(pad, padding_char, sizeof(pad));
 1811|    856|        pj_memcpy(buf + ATTR_HDR_LEN + 4 + ca->reason.slen, pad,
  ------------------
  |  |  749|    856|#define ATTR_HDR_LEN        sizeof(pj_stun_attr_hdr)
  ------------------
 1812|    856|                  4 - (ca->reason.slen & 0x03));
 1813|    856|    }
 1814|       |
 1815|       |    /* Done */
 1816|       |
 1817|    960|    return PJ_SUCCESS;
 1818|    960|}
stun_msg.c:decode_unknown_attr:
 1898|    736|{
 1899|    736|    pj_stun_unknown_attr *attr;
 1900|    736|    const pj_uint16_t *punk_attr;
 1901|    736|    unsigned i;
 1902|       |
 1903|    736|    PJ_UNUSED_ARG(msghdr);
  ------------------
  |  | 1537|    736|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
 1904|       |
 1905|    736|    attr = PJ_POOL_ZALLOC_T(pool, pj_stun_unknown_attr);
  ------------------
  |  |  583|    736|            ((type*)pj_pool_zalloc(pool, sizeof(type)))
  ------------------
 1906|    736|    GETATTRHDR(buf, &attr->hdr);
 1907|       | 
 1908|    736|    attr->attr_count = (attr->hdr.length >> 1);
 1909|    736|    if (attr->attr_count > PJ_STUN_MAX_ATTR)
  ------------------
  |  |   63|    736|#   define PJ_STUN_MAX_ATTR                         16
  ------------------
  |  Branch (1909:9): [True: 12, False: 724]
  ------------------
 1910|     12|        return PJ_ETOOMANY;
  ------------------
  |  |  423|     12|#define PJ_ETOOMANY         (PJ_ERRNO_START_STATUS + 10)/* 70010 */
  |  |  ------------------
  |  |  |  |  521|     12|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|     12|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|     12|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1911|       |
 1912|    724|    punk_attr = (const pj_uint16_t*)(buf + ATTR_HDR_LEN);
  ------------------
  |  |  749|    724|#define ATTR_HDR_LEN        sizeof(pj_stun_attr_hdr)
  ------------------
 1913|  1.71k|    for (i=0; i<attr->attr_count; ++i) {
  ------------------
  |  Branch (1913:15): [True: 991, False: 724]
  ------------------
 1914|    991|        attr->attrs[i] = pj_ntohs(punk_attr[i]);
 1915|    991|    }
 1916|       |
 1917|       |    /* Done */
 1918|    724|    *p_attr = attr;
 1919|       |
 1920|    724|    return PJ_SUCCESS;
 1921|    736|}
stun_msg.c:encode_unknown_attr:
 1928|    371|{
 1929|    371|    const pj_stun_unknown_attr *ca = (const pj_stun_unknown_attr*) a;
 1930|    371|    pj_uint16_t *dst_unk_attr;
 1931|    371|    unsigned i;
 1932|       |
 1933|    371|    PJ_CHECK_STACK();
 1934|       |    
 1935|    371|    PJ_UNUSED_ARG(msghdr);
  ------------------
  |  | 1537|    371|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
 1936|       |
 1937|       |    /* Calculated total attr_len (add padding if necessary) */
 1938|    371|    *printed = (ATTR_HDR_LEN + (ca->attr_count << 1) + 3) & (~3);
  ------------------
  |  |  749|    371|#define ATTR_HDR_LEN        sizeof(pj_stun_attr_hdr)
  ------------------
 1939|       |
 1940|       |    /* Check that buffer is enough */
 1941|    371|    if (len < *printed)
  ------------------
  |  Branch (1941:9): [True: 0, False: 371]
  ------------------
 1942|      0|        return PJ_ETOOSMALL;
  ------------------
  |  |  469|      0|#define PJ_ETOOSMALL        (PJ_ERRNO_START_STATUS + 19)/* 70019 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1943|       |
 1944|    371|    PUTVAL16H(buf, 0, ca->hdr.type);
 1945|    371|    PUTVAL16H(buf, 2, (pj_uint16_t)(ca->attr_count << 1));
 1946|       |
 1947|       |    /* Copy individual attribute */
 1948|    371|    dst_unk_attr = (pj_uint16_t*)(buf + ATTR_HDR_LEN);
  ------------------
  |  |  749|    371|#define ATTR_HDR_LEN        sizeof(pj_stun_attr_hdr)
  ------------------
 1949|  1.27k|    for (i=0; i < ca->attr_count; ++i, ++dst_unk_attr) {
  ------------------
  |  Branch (1949:15): [True: 908, False: 371]
  ------------------
 1950|    908|        *dst_unk_attr = pj_htons(ca->attrs[i]);
 1951|    908|    }
 1952|       |
 1953|       |    /* Zero-fill padding bytes if attribute list is not 4-bytes aligned */
 1954|    371|    if ((ca->attr_count << 1) & 0x03) {
  ------------------
  |  Branch (1954:9): [True: 162, False: 209]
  ------------------
 1955|    162|        pj_uint8_t pad[3];
 1956|    162|        pj_memset(pad, padding_char, sizeof(pad));
 1957|    162|        pj_memcpy(buf + ATTR_HDR_LEN + (ca->attr_count << 1), pad,
  ------------------
  |  |  749|    162|#define ATTR_HDR_LEN        sizeof(pj_stun_attr_hdr)
  ------------------
 1958|    162|                  4 - ((ca->attr_count << 1) & 0x03));
 1959|    162|    }
 1960|       |
 1961|       |    /* Done */
 1962|       |
 1963|    371|    return PJ_SUCCESS;
 1964|    371|}
stun_msg.c:decode_xored_sockaddr_attr:
  944|    795|{
  945|    795|    pj_stun_sockaddr_attr *attr;
  946|    795|    pj_status_t status;
  947|       |
  948|    795|    status = decode_sockaddr_attr(pool, buf, msghdr, p_attr);
  949|    795|    if (status != PJ_SUCCESS)
  ------------------
  |  Branch (949:9): [True: 32, False: 763]
  ------------------
  950|     32|        return status;
  951|       |
  952|    763|    attr = *(pj_stun_sockaddr_attr**)p_attr;
  953|       |
  954|    763|    attr->xor_ed = PJ_TRUE;
  955|       |
  956|    763|    if (attr->sockaddr.addr.sa_family == pj_AF_INET()) {
  ------------------
  |  |  113|    763|#   define pj_AF_INET()     PJ_AF_INET
  ------------------
  |  Branch (956:9): [True: 162, False: 601]
  ------------------
  957|    162|        attr->sockaddr.ipv4.sin_port ^= pj_htons(PJ_STUN_MAGIC >> 16);
  ------------------
  |  |   46|    162|#define PJ_STUN_MAGIC                       0x2112A442
  ------------------
  958|    162|        attr->sockaddr.ipv4.sin_addr.s_addr ^= pj_htonl(PJ_STUN_MAGIC);
  ------------------
  |  |   46|    162|#define PJ_STUN_MAGIC                       0x2112A442
  ------------------
  959|    601|    } else if (attr->sockaddr.addr.sa_family == pj_AF_INET6()) {
  ------------------
  |  |  115|    601|#   define pj_AF_INET6()    PJ_AF_INET6
  ------------------
  |  Branch (959:16): [True: 601, False: 0]
  ------------------
  960|    601|        unsigned i;
  961|    601|        pj_uint8_t *dst = (pj_uint8_t*) &attr->sockaddr.ipv6.sin6_addr;
  962|    601|        pj_uint32_t magic = pj_htonl(PJ_STUN_MAGIC);
  ------------------
  |  |   46|    601|#define PJ_STUN_MAGIC                       0x2112A442
  ------------------
  963|       |
  964|    601|        attr->sockaddr.ipv6.sin6_port ^= pj_htons(PJ_STUN_MAGIC >> 16);
  ------------------
  |  |   46|    601|#define PJ_STUN_MAGIC                       0x2112A442
  ------------------
  965|       |
  966|       |        /* If the IP address family is IPv6, X-Address is computed by
  967|       |         * taking the mapped IP address in host byte order, XOR'ing it
  968|       |         * with the concatenation of the magic cookie and the 96-bit 
  969|       |         * transaction ID, and converting the result to network byte 
  970|       |         * order.
  971|       |         */
  972|  3.00k|        for (i=0; i<4; ++i) {
  ------------------
  |  Branch (972:19): [True: 2.40k, False: 601]
  ------------------
  973|  2.40k|            dst[i] ^= ((const pj_uint8_t*)&magic)[i];
  974|  2.40k|        }
  975|    601|        pj_assert(sizeof(msghdr->tsx_id[0]) == 1);
  ------------------
  |  |   65|    601|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (975:9): [True: 0, Folded]
  |  Branch (975:9): [True: 601, Folded]
  ------------------
  976|  7.81k|        for (i=0; i<12; ++i) {
  ------------------
  |  Branch (976:19): [True: 7.21k, False: 601]
  ------------------
  977|  7.21k|            dst[i+4] ^= msghdr->tsx_id[i];
  978|  7.21k|        }
  979|       |
  980|    601|    } else {
  981|      0|        return PJNATH_EINVAF;
  ------------------
  |  |  121|      0|#define PJNATH_EINVAF               (PJNATH_ERRNO_START+42) /* 370042 */
  |  |  ------------------
  |  |  |  |   40|      0|#define PJNATH_ERRNO_START    (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*4)
  |  |  |  |  ------------------
  |  |  |  |  |  |  535|      0|#define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  528|      0|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define PJNATH_ERRNO_START    (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*4)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  982|      0|    }
  983|       |
  984|       |    /* Done */
  985|    763|    *p_attr = attr;
  986|       |
  987|    763|    return PJ_SUCCESS;
  988|    763|}
stun_msg.c:decode_binary_attr:
 2050|    126|{
 2051|    126|    pj_stun_binary_attr *attr;
 2052|       |
 2053|    126|    PJ_UNUSED_ARG(msghdr);
  ------------------
  |  | 1537|    126|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
 2054|       |
 2055|       |    /* Create the attribute */
 2056|    126|    attr = PJ_POOL_ZALLOC_T(pool, pj_stun_binary_attr);
  ------------------
  |  |  583|    126|            ((type*)pj_pool_zalloc(pool, sizeof(type)))
  ------------------
 2057|    126|    GETATTRHDR(buf, &attr->hdr);
 2058|       |
 2059|       |    /* Copy the data to the attribute */
 2060|    126|    attr->length = attr->hdr.length;
 2061|    126|    attr->data = (pj_uint8_t*) pj_pool_alloc(pool, attr->length);
 2062|    126|    pj_memcpy(attr->data, buf+ATTR_HDR_LEN, attr->length);
  ------------------
  |  |  749|    126|#define ATTR_HDR_LEN        sizeof(pj_stun_attr_hdr)
  ------------------
 2063|       |
 2064|       |    /* Done */
 2065|    126|    *p_attr = attr;
 2066|       |
 2067|    126|    return PJ_SUCCESS;
 2068|       |
 2069|    126|}
stun_msg.c:decode_uint64_attr:
 1535|     99|{
 1536|     99|    pj_stun_uint64_attr *attr;
 1537|       |
 1538|     99|    PJ_UNUSED_ARG(msghdr);
  ------------------
  |  | 1537|     99|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
 1539|       |
 1540|       |    /* Create the attribute */
 1541|     99|    attr = PJ_POOL_ZALLOC_T(pool, pj_stun_uint64_attr);
  ------------------
  |  |  583|     99|            ((type*)pj_pool_zalloc(pool, sizeof(type)))
  ------------------
 1542|     99|    GETATTRHDR(buf, &attr->hdr);
 1543|       |
 1544|     99|    if (attr->hdr.length != 8)
  ------------------
  |  Branch (1544:9): [True: 22, False: 77]
  ------------------
 1545|     22|        return PJNATH_ESTUNINATTRLEN;
  ------------------
  |  |   83|     22|#define PJNATH_ESTUNINATTRLEN       (PJNATH_ERRNO_START+22) /* 370022 */
  |  |  ------------------
  |  |  |  |   40|     22|#define PJNATH_ERRNO_START    (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*4)
  |  |  |  |  ------------------
  |  |  |  |  |  |  535|     22|#define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  528|     22|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  521|     22|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  509|     22|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  515|     22|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  515|     22|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  515|     22|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define PJNATH_ERRNO_START    (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*4)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|     22|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1546|       |
 1547|     77|    GETVAL64H(buf, 4, &attr->value);    
 1548|       |
 1549|       |    /* Done */
 1550|     77|    *p_attr = attr;
 1551|       |
 1552|     77|    return PJ_SUCCESS;
 1553|     99|}
stun_msg.c:GETVAL64H:
  790|     77|{
  791|     77|    ts->u32.hi = GETVAL32H(buf, pos);
  792|     77|    ts->u32.lo = GETVAL32H(buf, pos+4);
  793|     77|}
stun_msg.c:decode_empty_attr:
 1332|    246|{
 1333|    246|    pj_stun_empty_attr *attr;
 1334|       |
 1335|    246|    PJ_UNUSED_ARG(msghdr);
  ------------------
  |  | 1537|    246|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
 1336|       |
 1337|       |    /* Check that the struct address is valid */
 1338|    246|    pj_assert(sizeof(pj_stun_empty_attr) == ATTR_HDR_LEN);
  ------------------
  |  |   65|    246|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (1338:5): [True: 0, Folded]
  |  Branch (1338:5): [True: 246, Folded]
  ------------------
 1339|       |
 1340|       |    /* Create the attribute */
 1341|    246|    attr = PJ_POOL_ZALLOC_T(pool, pj_stun_empty_attr);
  ------------------
  |  |  583|    246|            ((type*)pj_pool_zalloc(pool, sizeof(type)))
  ------------------
 1342|    246|    GETATTRHDR(buf, &attr->hdr);
 1343|       |
 1344|       |    /* Check that the attribute length is valid */
 1345|    246|    if (attr->hdr.length != 0)
  ------------------
  |  Branch (1345:9): [True: 20, False: 226]
  ------------------
 1346|     20|        return PJNATH_ESTUNINATTRLEN;
  ------------------
  |  |   83|     20|#define PJNATH_ESTUNINATTRLEN       (PJNATH_ERRNO_START+22) /* 370022 */
  |  |  ------------------
  |  |  |  |   40|     20|#define PJNATH_ERRNO_START    (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*4)
  |  |  |  |  ------------------
  |  |  |  |  |  |  535|     20|#define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  528|     20|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  521|     20|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  509|     20|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  515|     20|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  515|     20|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  515|     20|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define PJNATH_ERRNO_START    (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*4)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|     20|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1347|       |
 1348|       |    /* Done */
 1349|    226|    *p_attr = attr;
 1350|       |
 1351|    226|    return PJ_SUCCESS;
 1352|    246|}
stun_msg.c:GETVAL16H:
  752|  27.4k|{
  753|  27.4k|    return (pj_uint16_t) (((pj_uint16_t)buf[pos + 0] << 8) | \
  754|  27.4k|                          ((pj_uint16_t)buf[pos + 1] << 0));
  755|  27.4k|}
stun_msg.c:GETVAL32H:
  769|  1.89k|{
  770|  1.89k|    return (pj_uint32_t) (((pj_uint32_t)buf[pos + 0] << 24UL) | \
  771|  1.89k|                          ((pj_uint32_t)buf[pos + 1] << 16UL) | \
  772|  1.89k|                          ((pj_uint32_t)buf[pos + 2] <<  8UL) | \
  773|  1.89k|                          ((pj_uint32_t)buf[pos + 3] <<  0UL));
  774|  1.89k|}
stun_msg.c:PUTVAL16H:
  763|  26.7k|{
  764|  26.7k|    buf[pos+0] = (pj_uint8_t) ((hval & 0xFF00) >> 8);
  765|  26.7k|    buf[pos+1] = (pj_uint8_t) ((hval & 0x00FF) >> 0);
  766|  26.7k|}
stun_msg.c:PUTVAL32H:
  782|  1.64k|{
  783|  1.64k|    buf[pos+0] = (pj_uint8_t) ((hval & 0xFF000000UL) >> 24);
  784|  1.64k|    buf[pos+1] = (pj_uint8_t) ((hval & 0x00FF0000UL) >> 16);
  785|  1.64k|    buf[pos+2] = (pj_uint8_t) ((hval & 0x0000FF00UL) >>  8);
  786|  1.64k|    buf[pos+3] = (pj_uint8_t) ((hval & 0x000000FFUL) >>  0);
  787|  1.64k|}
stun_msg.c:encode_msgint_attr:
 1658|  1.24k|{
 1659|  1.24k|    const pj_stun_msgint_attr *ca = (const pj_stun_msgint_attr*)a;
 1660|       |
 1661|  1.24k|    PJ_CHECK_STACK();
 1662|       |    
 1663|  1.24k|    PJ_UNUSED_ARG(msghdr);
  ------------------
  |  | 1537|  1.24k|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
 1664|       |
 1665|  1.24k|    if (len < 24) 
  ------------------
  |  Branch (1665:9): [True: 0, False: 1.24k]
  ------------------
 1666|      0|        return PJ_ETOOSMALL;
  ------------------
  |  |  469|      0|#define PJ_ETOOSMALL        (PJ_ERRNO_START_STATUS + 19)/* 70019 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1667|       |
 1668|       |    /* Copy and convert attribute to network byte order */
 1669|  1.24k|    PUTVAL16H(buf, 0, ca->hdr.type);
 1670|  1.24k|    PUTVAL16H(buf, 2, ca->hdr.length);
 1671|       |
 1672|  1.24k|    pj_memcpy(buf+4, ca->hmac, 20);
 1673|       |
 1674|       |    /* Done */
 1675|  1.24k|    *printed = 24;
 1676|       |
 1677|  1.24k|    return PJ_SUCCESS;
 1678|  1.24k|}

pj_stun_session_create:
  541|  1.57k|{
  542|  1.57k|    pj_pool_t   *pool;
  543|  1.57k|    pj_stun_session *sess;
  544|  1.57k|    pj_status_t status;
  545|       |
  546|  1.57k|    PJ_ASSERT_RETURN(cfg && cb && p_sess, PJ_EINVAL);
  ------------------
  |  |   97|  1.57k|            do { \
  |  |   98|  6.31k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 1.57k, False: 0]
  |  |  |  Branch (98:23): [True: 1.57k, False: 0]
  |  |  |  Branch (98:23): [True: 1.57k, False: 0]
  |  |  ------------------
  |  |   99|  1.57k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1.57k]
  |  |  ------------------
  ------------------
  |  Branch (546:5): [True: 0, False: 0]
  |  Branch (546:5): [True: 0, False: 0]
  |  Branch (546:5): [True: 0, False: 0]
  |  Branch (546:5): [True: 0, False: 0]
  |  Branch (546:5): [True: 0, False: 0]
  |  Branch (546:5): [True: 0, False: 0]
  ------------------
  547|       |
  548|  1.57k|    if (name==NULL)
  ------------------
  |  Branch (548:9): [True: 341, False: 1.23k]
  ------------------
  549|    341|        name = "stuse%p";
  550|       |
  551|  1.57k|    pool = pj_pool_create(cfg->pf, name, PJNATH_POOL_LEN_STUN_SESS, 
  ------------------
  |  |  558|  1.57k|#   define PJNATH_POOL_LEN_STUN_SESS                1000
  ------------------
  552|  1.57k|                          PJNATH_POOL_INC_STUN_SESS, NULL);
  ------------------
  |  |  563|  1.57k|#   define PJNATH_POOL_INC_STUN_SESS                1000
  ------------------
  553|  1.57k|    PJ_ASSERT_RETURN(pool, PJ_ENOMEM);
  ------------------
  |  |   97|  1.57k|            do { \
  |  |   98|  1.57k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 1.57k]
  |  |  ------------------
  |  |   99|  1.57k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1.57k]
  |  |  ------------------
  ------------------
  |  Branch (553:5): [True: 0, False: 0]
  |  Branch (553:5): [True: 0, False: 0]
  ------------------
  554|       |
  555|  1.57k|    sess = PJ_POOL_ZALLOC_T(pool, pj_stun_session);
  ------------------
  |  |  583|  1.57k|            ((type*)pj_pool_zalloc(pool, sizeof(type)))
  ------------------
  556|  1.57k|    sess->cfg = cfg;
  557|  1.57k|    sess->pool = pool;
  558|  1.57k|    pj_memcpy(&sess->cb, cb, sizeof(*cb));
  559|  1.57k|    sess->use_fingerprint = fingerprint;
  560|  1.57k|    sess->log_flag = 0xFFFF;
  561|       |
  562|  1.57k|    if (grp_lock) {
  ------------------
  |  Branch (562:9): [True: 1.57k, False: 0]
  ------------------
  563|  1.57k|        sess->grp_lock = grp_lock;
  564|  1.57k|    } else {
  565|      0|        status = pj_grp_lock_create(pool, NULL, &sess->grp_lock);
  566|      0|        if (status != PJ_SUCCESS) {
  ------------------
  |  Branch (566:13): [True: 0, False: 0]
  ------------------
  567|      0|            pj_pool_release(pool);
  568|      0|            return status;
  569|      0|        }
  570|      0|    }
  571|       |
  572|  1.57k|    pj_grp_lock_add_ref(sess->grp_lock);
  573|  1.57k|    pj_grp_lock_add_handler(sess->grp_lock, pool, sess,
  574|  1.57k|                            &stun_sess_on_destroy);
  575|       |
  576|  1.57k|    pj_stun_session_set_software_name(sess, &cfg->software_name);
  577|       |
  578|  1.57k|    sess->rx_pool = pj_pool_create(sess->cfg->pf, name,
  579|  1.57k|                                   PJNATH_POOL_LEN_STUN_TDATA,
  ------------------
  |  |  568|  1.57k|#   define PJNATH_POOL_LEN_STUN_TDATA               1000
  ------------------
  580|  1.57k|                                   PJNATH_POOL_INC_STUN_TDATA, NULL);
  ------------------
  |  |  573|  1.57k|#   define PJNATH_POOL_INC_STUN_TDATA               1000
  ------------------
  581|       |
  582|  1.57k|    pj_list_init(&sess->pending_request_list);
  583|  1.57k|    pj_list_init(&sess->cached_response_list);
  584|       |
  585|  1.57k|    *p_sess = sess;
  586|       |
  587|  1.57k|    return PJ_SUCCESS;
  588|  1.57k|}
pj_stun_session_destroy:
  606|    682|{
  607|    682|    pj_stun_tx_data *tdata;
  608|       |
  609|    682|    PJ_ASSERT_RETURN(sess, PJ_EINVAL);
  ------------------
  |  |   97|    682|            do { \
  |  |   98|    682|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 682]
  |  |  ------------------
  |  |   99|    682|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 682]
  |  |  ------------------
  ------------------
  |  Branch (609:5): [True: 0, False: 0]
  |  Branch (609:5): [True: 0, False: 0]
  ------------------
  610|       |
  611|    682|    TRACE_((SNAME(sess), "STUN session %p destroy request, ref_cnt=%d",
  ------------------
  |  |   57|    682|#   define TRACE_(expr)             PJ_LOG(5,expr)
  |  |  ------------------
  |  |  |  |  106|    682|#define PJ_LOG(level,arg)       do { \
  |  |  |  |  107|    682|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |  417|  1.36k|#  define PJ_LOG_MAX_LEVEL   5
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (107:41): [True: 682, Folded]
  |  |  |  |  |  Branch (107:70): [True: 0, False: 682]
  |  |  |  |  ------------------
  |  |  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  496|      0|    #define pj_log_wrapper_5(arg)       pj_log_5 arg
  |  |  |  |  ------------------
  |  |  |  |  109|      0|                                    } \
  |  |  |  |  110|    682|                                } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (110:42): [Folded, False: 682]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  612|    682|             sess, pj_grp_lock_get_ref(sess->grp_lock)));
  613|       |
  614|    682|    pj_grp_lock_acquire(sess->grp_lock);
  615|       |
  616|    682|    if (sess->is_destroying) {
  ------------------
  |  Branch (616:9): [True: 0, False: 682]
  ------------------
  617|       |        /* Prevent from decrementing the ref counter more than once */
  618|      0|        pj_grp_lock_release(sess->grp_lock);
  619|      0|        return PJ_EINVALIDOP;
  ------------------
  |  |  438|      0|#define PJ_EINVALIDOP       (PJ_ERRNO_START_STATUS + 13)/* 70013 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  620|      0|    }
  621|       |
  622|    682|    sess->is_destroying = PJ_TRUE;
  623|       |
  624|       |    /* We need to stop transactions because they are
  625|       |     * holding the group lock's reference counter while retransmitting.
  626|       |     */
  627|    682|    tdata = sess->pending_request_list.next;
  628|    682|    while (tdata != &sess->pending_request_list) {
  ------------------
  |  Branch (628:12): [True: 0, False: 682]
  ------------------
  629|      0|        if (tdata->client_tsx)
  ------------------
  |  Branch (629:13): [True: 0, False: 0]
  ------------------
  630|      0|            pj_stun_client_tsx_stop(tdata->client_tsx);
  631|      0|        tdata = tdata->next;
  632|      0|    }
  633|       |
  634|       |    /* Destroy cached response within session lock protection to avoid
  635|       |     * race scenario with on_cache_timeout().
  636|       |     */
  637|    682|    while (!pj_list_empty(&sess->cached_response_list)) {
  ------------------
  |  Branch (637:12): [True: 0, False: 682]
  ------------------
  638|      0|        pj_stun_tx_data *tmp_tdata = sess->cached_response_list.next;
  639|      0|        destroy_tdata(tmp_tdata, PJ_TRUE);
  640|      0|    }
  641|       |
  642|    682|    pj_grp_lock_dec_ref(sess->grp_lock);
  643|    682|    pj_grp_lock_release(sess->grp_lock);
  644|    682|    return PJ_SUCCESS;
  645|    682|}
pj_stun_session_set_user_data:
  650|  1.57k|{
  651|  1.57k|    PJ_ASSERT_RETURN(sess, PJ_EINVAL);
  ------------------
  |  |   97|  1.57k|            do { \
  |  |   98|  1.57k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 1.57k]
  |  |  ------------------
  |  |   99|  1.57k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1.57k]
  |  |  ------------------
  ------------------
  |  Branch (651:5): [True: 0, False: 0]
  |  Branch (651:5): [True: 0, False: 0]
  ------------------
  652|  1.57k|    pj_grp_lock_acquire(sess->grp_lock);
  653|  1.57k|    sess->user_data = user_data;
  654|  1.57k|    pj_grp_lock_release(sess->grp_lock);
  655|  1.57k|    return PJ_SUCCESS;
  656|  1.57k|}
pj_stun_session_get_user_data:
  659|    470|{
  660|    470|    PJ_ASSERT_RETURN(sess, NULL);
  ------------------
  |  |   97|    470|            do { \
  |  |   98|    470|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 470]
  |  |  ------------------
  |  |   99|    470|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 470]
  |  |  ------------------
  ------------------
  |  Branch (660:5): [True: 0, False: 0]
  |  Branch (660:5): [True: 0, False: 0]
  ------------------
  661|    470|    return sess->user_data;
  662|    470|}
pj_stun_session_set_software_name:
  672|  1.57k|{
  673|  1.57k|    PJ_ASSERT_RETURN(sess, PJ_EINVAL);
  ------------------
  |  |   97|  1.57k|            do { \
  |  |   98|  1.57k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 1.57k]
  |  |  ------------------
  |  |   99|  1.57k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1.57k]
  |  |  ------------------
  ------------------
  |  Branch (673:5): [True: 0, False: 0]
  |  Branch (673:5): [True: 0, False: 0]
  ------------------
  674|  1.57k|    pj_grp_lock_acquire(sess->grp_lock);
  675|  1.57k|    if (sw && sw->slen)
  ------------------
  |  Branch (675:9): [True: 1.57k, False: 0]
  |  Branch (675:15): [True: 1.57k, False: 0]
  ------------------
  676|  1.57k|        pj_strdup(sess->pool, &sess->srv_name, sw);
  677|      0|    else
  678|      0|        sess->srv_name.slen = 0;
  679|  1.57k|    pj_grp_lock_release(sess->grp_lock);
  680|  1.57k|    return PJ_SUCCESS;
  681|  1.57k|}
pj_stun_session_set_credential:
  686|  1.23k|{
  687|  1.23k|    PJ_ASSERT_RETURN(sess, PJ_EINVAL);
  ------------------
  |  |   97|  1.23k|            do { \
  |  |   98|  1.23k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 1.23k]
  |  |  ------------------
  |  |   99|  1.23k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1.23k]
  |  |  ------------------
  ------------------
  |  Branch (687:5): [True: 0, False: 0]
  |  Branch (687:5): [True: 0, False: 0]
  ------------------
  688|       |
  689|  1.23k|    pj_grp_lock_acquire(sess->grp_lock);
  690|  1.23k|    sess->auth_type = auth_type;
  691|  1.23k|    if (cred) {
  ------------------
  |  Branch (691:9): [True: 1.23k, False: 0]
  ------------------
  692|  1.23k|        pj_stun_auth_cred_dup(sess->pool, &sess->cred, cred);
  693|  1.23k|    } else {
  694|      0|        sess->auth_type = PJ_STUN_AUTH_NONE;
  695|      0|        pj_bzero(&sess->cred, sizeof(sess->cred));
  696|      0|    }
  697|  1.23k|    pj_grp_lock_release(sess->grp_lock);
  698|       |
  699|  1.23k|    return PJ_SUCCESS;
  700|  1.23k|}
pj_stun_session_on_rx_pkt:
 1477|    624|{
 1478|    624|    pj_stun_msg *msg, *response;
 1479|    624|    pj_status_t status;
 1480|       |
 1481|    624|    PJ_ASSERT_RETURN(sess && packet && pkt_size, PJ_EINVAL);
  ------------------
  |  |   97|    624|            do { \
  |  |   98|  2.49k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 624, False: 0]
  |  |  |  Branch (98:23): [True: 624, False: 0]
  |  |  |  Branch (98:23): [True: 624, False: 0]
  |  |  ------------------
  |  |   99|    624|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 624]
  |  |  ------------------
  ------------------
  |  Branch (1481:5): [True: 0, False: 0]
  |  Branch (1481:5): [True: 0, False: 0]
  |  Branch (1481:5): [True: 0, False: 0]
  |  Branch (1481:5): [True: 0, False: 0]
  |  Branch (1481:5): [True: 0, False: 0]
  |  Branch (1481:5): [True: 0, False: 0]
  ------------------
 1482|       |
 1483|       |    /* Lock the session and prevent user from destroying us in the callback */
 1484|    624|    pj_grp_lock_acquire(sess->grp_lock);
 1485|       |
 1486|    624|    if (sess->is_destroying) {
  ------------------
  |  Branch (1486:9): [True: 0, False: 624]
  ------------------
 1487|      0|        pj_grp_lock_release(sess->grp_lock);
 1488|      0|        return PJ_EINVALIDOP;
  ------------------
  |  |  438|      0|#define PJ_EINVALIDOP       (PJ_ERRNO_START_STATUS + 13)/* 70013 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1489|      0|    }
 1490|       |
 1491|    624|    pj_log_push_indent();
 1492|       |
 1493|       |    /* Reset pool */
 1494|    624|    pj_pool_reset(sess->rx_pool);
 1495|       |
 1496|       |    /* Try to parse the message */
 1497|    624|    status = pj_stun_msg_decode(sess->rx_pool, (const pj_uint8_t*)packet,
 1498|    624|                                pkt_size, options, 
 1499|    624|                                &msg, parsed_len, &response);
 1500|    624|    if (status != PJ_SUCCESS) {
  ------------------
  |  Branch (1500:9): [True: 230, False: 394]
  ------------------
 1501|    230|        LOG_ERR_(sess, "STUN msg_decode() error", status);
  ------------------
  |  |   62|    230|#define LOG_ERR_(sess,title,rc) PJ_PERROR(3,(sess->pool->obj_name,rc,title))
  |  |  ------------------
  |  |  |  |  189|    230|#define PJ_PERROR(level,arg)    do { \
  |  |  |  |  190|    230|                                    pj_perror_wrapper_##level(arg); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  595|    230|    #define pj_perror_wrapper_3(arg)    pj_perror_3 arg
  |  |  |  |  ------------------
  |  |  |  |  191|    230|                                } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (191:42): [Folded, False: 230]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1502|    230|        if (response) {
  ------------------
  |  Branch (1502:13): [True: 102, False: 128]
  ------------------
 1503|    102|            send_response(sess, token, sess->rx_pool, response, NULL,
 1504|    102|                          PJ_FALSE, src_addr, src_addr_len);
 1505|    102|        }
 1506|    230|        goto on_return;
 1507|    230|    }
 1508|       |
 1509|    394|    dump_rx_msg(sess, msg, (unsigned)pkt_size, src_addr);
 1510|       |
 1511|       |    /* For requests, check if we have cached response */
 1512|    394|    status = check_cached_response(sess, sess->rx_pool, msg, 
 1513|    394|                                   src_addr, src_addr_len);
 1514|    394|    if (status == PJ_SUCCESS) {
  ------------------
  |  Branch (1514:9): [True: 0, False: 394]
  ------------------
 1515|      0|        goto on_return;
 1516|      0|    }
 1517|       |
 1518|       |    /* Handle message */
 1519|    394|    if (PJ_STUN_IS_SUCCESS_RESPONSE(msg->hdr.type) ||
  ------------------
  |  |  159|    788|#define PJ_STUN_IS_SUCCESS_RESPONSE(msg_type) (((msg_type) & 0x0110) == 0x0100)
  |  |  ------------------
  |  |  |  Branch (159:47): [True: 23, False: 371]
  |  |  ------------------
  ------------------
 1520|    371|        PJ_STUN_IS_ERROR_RESPONSE(msg->hdr.type))
  ------------------
  |  |  170|    371|#define PJ_STUN_IS_ERROR_RESPONSE(msg_type) (((msg_type) & 0x0110) == 0x0110)
  |  |  ------------------
  |  |  |  Branch (170:45): [True: 3, False: 368]
  |  |  ------------------
  ------------------
 1521|     26|    {
 1522|     26|        status = on_incoming_response(sess, options, 
 1523|     26|                                      (const pj_uint8_t*) packet, 
 1524|     26|                                      (unsigned)pkt_size, msg, 
 1525|     26|                                      src_addr, src_addr_len);
 1526|       |
 1527|    368|    } else if (PJ_STUN_IS_REQUEST(msg->hdr.type)) {
  ------------------
  |  |  153|    368|#define PJ_STUN_IS_REQUEST(msg_type)    (((msg_type) & 0x0110) == 0x0000)
  |  |  ------------------
  |  |  |  Branch (153:41): [True: 299, False: 69]
  |  |  ------------------
  ------------------
 1528|       |
 1529|    299|        status = on_incoming_request(sess, options, token, sess->rx_pool, 
 1530|    299|                                     (const pj_uint8_t*) packet, 
 1531|    299|                                     (unsigned)pkt_size, 
 1532|    299|                                     msg, src_addr, src_addr_len);
 1533|       |
 1534|    299|    } else if (PJ_STUN_IS_INDICATION(msg->hdr.type)) {
  ------------------
  |  |  186|     69|#define PJ_STUN_IS_INDICATION(msg_type) (((msg_type) & 0x0110) == 0x0010)
  |  |  ------------------
  |  |  |  Branch (186:41): [True: 69, False: 0]
  |  |  ------------------
  ------------------
 1535|       |
 1536|     69|        status = on_incoming_indication(sess, token, sess->rx_pool, 
 1537|     69|                                        (const pj_uint8_t*) packet, 
 1538|     69|                                        (unsigned)pkt_size, msg, src_addr, 
 1539|     69|                                        src_addr_len);
 1540|       |
 1541|     69|    } else {
 1542|      0|        pj_assert(!"Unexpected!");
  ------------------
  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (1542:9): [Folded, False: 0]
  |  Branch (1542:9): [Folded, False: 0]
  ------------------
 1543|      0|        status = PJ_EBUG;
  ------------------
  |  |  413|      0|#define PJ_EBUG             (PJ_ERRNO_START_STATUS + 8) /* 70008 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1544|      0|    }
 1545|       |
 1546|    624|on_return:
 1547|    624|    pj_log_pop_indent();
 1548|       |
 1549|    624|    if (pj_grp_lock_release(sess->grp_lock))
  ------------------
  |  Branch (1549:9): [True: 0, False: 624]
  ------------------
 1550|      0|        return PJ_EGONE;
  ------------------
  |  |  489|      0|#define PJ_EGONE            (PJ_ERRNO_START_STATUS + 23)/* 70023 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1551|       |
 1552|    624|    return status;
 1553|    624|}
stun_session.c:stun_sess_on_destroy:
  591|    682|{
  592|    682|    pj_stun_session *sess = (pj_stun_session*)comp;
  593|       |
  594|    682|    while (!pj_list_empty(&sess->pending_request_list)) {
  ------------------
  |  Branch (594:12): [True: 0, False: 682]
  ------------------
  595|      0|        pj_stun_tx_data *tdata = sess->pending_request_list.next;
  596|      0|        destroy_tdata(tdata, PJ_TRUE);
  597|      0|    }
  598|       |
  599|    682|    pj_pool_safe_release(&sess->rx_pool);
  600|    682|    pj_pool_safe_release(&sess->pool);
  601|       |
  602|    682|    TRACE_((THIS_FILE, "STUN session %p destroyed", sess));
  ------------------
  |  |   57|    682|#   define TRACE_(expr)             PJ_LOG(5,expr)
  |  |  ------------------
  |  |  |  |  106|    682|#define PJ_LOG(level,arg)       do { \
  |  |  |  |  107|    682|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |  417|  1.36k|#  define PJ_LOG_MAX_LEVEL   5
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (107:41): [True: 682, Folded]
  |  |  |  |  |  Branch (107:70): [True: 0, False: 682]
  |  |  |  |  ------------------
  |  |  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  496|      0|    #define pj_log_wrapper_5(arg)       pj_log_5 arg
  |  |  |  |  ------------------
  |  |  |  |  109|      0|                                    } \
  |  |  |  |  110|    682|                                } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (110:42): [Folded, False: 682]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  603|    682|}
stun_session.c:apply_msg_options:
  266|    401|{
  267|    401|    pj_status_t status = 0;
  268|    401|    pj_str_t realm, username, nonce, auth_key;
  269|       |
  270|       |    /* If the agent is sending a request, it SHOULD add a SOFTWARE attribute
  271|       |     * to the request. The server SHOULD include a SOFTWARE attribute in all 
  272|       |     * responses.
  273|       |     *
  274|       |     * If magic value is not PJ_STUN_MAGIC, only apply the attribute for
  275|       |     * responses.
  276|       |     */
  277|    401|    if (sess->srv_name.slen && 
  ------------------
  |  Branch (277:9): [True: 401, False: 0]
  ------------------
  278|    401|        pj_stun_msg_find_attr(msg, PJ_STUN_ATTR_SOFTWARE, 0)==NULL &&
  ------------------
  |  Branch (278:9): [True: 401, False: 0]
  ------------------
  279|    401|        (PJ_STUN_IS_RESPONSE(msg->hdr.type) ||
  ------------------
  |  |  180|    802|#define PJ_STUN_IS_RESPONSE(msg_type) (((msg_type) & 0x0100) == 0x0100)
  |  |  ------------------
  |  |  |  Branch (180:39): [True: 401, False: 0]
  |  |  ------------------
  ------------------
  280|      0|         (PJ_STUN_IS_REQUEST(msg->hdr.type) && msg->hdr.magic==PJ_STUN_MAGIC))) 
  ------------------
  |  |  153|      0|#define PJ_STUN_IS_REQUEST(msg_type)    (((msg_type) & 0x0110) == 0x0000)
  |  |  ------------------
  |  |  |  Branch (153:41): [True: 0, False: 0]
  |  |  ------------------
  ------------------
                       (PJ_STUN_IS_REQUEST(msg->hdr.type) && msg->hdr.magic==PJ_STUN_MAGIC))) 
  ------------------
  |  |   46|      0|#define PJ_STUN_MAGIC                       0x2112A442
  ------------------
  |  Branch (280:48): [True: 0, False: 0]
  ------------------
  281|    401|    {
  282|    401|        pj_stun_msg_add_string_attr(pool, msg, PJ_STUN_ATTR_SOFTWARE,
  283|    401|                                    &sess->srv_name);
  284|    401|    }
  285|       |
  286|    401|    if (pj_stun_auth_valid_for_msg(msg) && auth_info) {
  ------------------
  |  Branch (286:9): [True: 5, False: 396]
  |  Branch (286:44): [True: 0, False: 5]
  ------------------
  287|      0|        realm = auth_info->realm;
  288|      0|        username = auth_info->username;
  289|      0|        nonce = auth_info->nonce;
  290|      0|        auth_key = auth_info->auth_key;
  291|    401|    } else {
  292|    401|        realm.slen = username.slen = nonce.slen = auth_key.slen = 0;
  293|    401|    }
  294|       |
  295|       |    /* Create and add USERNAME attribute if needed */
  296|    401|    if (username.slen && PJ_STUN_IS_REQUEST(msg->hdr.type)) {
  ------------------
  |  |  153|      0|#define PJ_STUN_IS_REQUEST(msg_type)    (((msg_type) & 0x0110) == 0x0000)
  |  |  ------------------
  |  |  |  Branch (153:41): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (296:9): [True: 0, False: 401]
  ------------------
  297|      0|        status = pj_stun_msg_add_string_attr(pool, msg,
  298|      0|                                             PJ_STUN_ATTR_USERNAME,
  299|      0|                                             &username);
  300|      0|        PJ_ASSERT_RETURN(status==PJ_SUCCESS, status);
  ------------------
  |  |   97|      0|            do { \
  |  |   98|      0|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 0]
  |  |  ------------------
  |  |   99|      0|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (300:9): [True: 0, False: 0]
  |  Branch (300:9): [True: 0, False: 0]
  ------------------
  301|      0|    }
  302|       |
  303|       |    /* Add REALM only when long term credential is used */
  304|    401|    if (realm.slen &&  PJ_STUN_IS_REQUEST(msg->hdr.type)) {
  ------------------
  |  |  153|      0|#define PJ_STUN_IS_REQUEST(msg_type)    (((msg_type) & 0x0110) == 0x0000)
  |  |  ------------------
  |  |  |  Branch (153:41): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (304:9): [True: 0, False: 401]
  ------------------
  305|      0|        status = pj_stun_msg_add_string_attr(pool, msg,
  306|      0|                                            PJ_STUN_ATTR_REALM,
  307|      0|                                            &realm);
  308|      0|        PJ_ASSERT_RETURN(status==PJ_SUCCESS, status);
  ------------------
  |  |   97|      0|            do { \
  |  |   98|      0|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 0]
  |  |  ------------------
  |  |   99|      0|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (308:9): [True: 0, False: 0]
  |  Branch (308:9): [True: 0, False: 0]
  ------------------
  309|      0|    }
  310|       |
  311|       |    /* Add NONCE when desired */
  312|    401|    if (nonce.slen && 
  ------------------
  |  Branch (312:9): [True: 0, False: 401]
  ------------------
  313|      0|        (PJ_STUN_IS_REQUEST(msg->hdr.type) ||
  ------------------
  |  |  153|      0|#define PJ_STUN_IS_REQUEST(msg_type)    (((msg_type) & 0x0110) == 0x0000)
  |  |  ------------------
  |  |  |  Branch (153:41): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  314|      0|         PJ_STUN_IS_ERROR_RESPONSE(msg->hdr.type))) 
  ------------------
  |  |  170|      0|#define PJ_STUN_IS_ERROR_RESPONSE(msg_type) (((msg_type) & 0x0110) == 0x0110)
  |  |  ------------------
  |  |  |  Branch (170:45): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  315|      0|    {
  316|      0|        status = pj_stun_msg_add_string_attr(pool, msg,
  317|      0|                                            PJ_STUN_ATTR_NONCE,
  318|      0|                                            &nonce);
  319|      0|        PJ_ASSERT_RETURN(status==PJ_SUCCESS, status);
  ------------------
  |  |   97|      0|            do { \
  |  |   98|      0|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 0]
  |  |  ------------------
  |  |   99|      0|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (319:9): [True: 0, False: 0]
  |  Branch (319:9): [True: 0, False: 0]
  ------------------
  320|      0|    }
  321|       |
  322|       |    /* Add MESSAGE-INTEGRITY attribute */
  323|    401|    if (username.slen && auth_key.slen) {
  ------------------
  |  Branch (323:9): [True: 0, False: 401]
  |  Branch (323:26): [True: 0, False: 0]
  ------------------
  324|      0|        status = pj_stun_msg_add_msgint_attr(pool, msg);
  325|      0|        PJ_ASSERT_RETURN(status==PJ_SUCCESS, status);
  ------------------
  |  |   97|      0|            do { \
  |  |   98|      0|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 0]
  |  |  ------------------
  |  |   99|      0|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (325:9): [True: 0, False: 0]
  |  Branch (325:9): [True: 0, False: 0]
  ------------------
  326|      0|    }
  327|       |
  328|       |
  329|       |    /* Add FINGERPRINT attribute if necessary */
  330|    401|    if (sess->use_fingerprint) {
  ------------------
  |  Branch (330:9): [True: 0, False: 401]
  ------------------
  331|      0|        status = pj_stun_msg_add_uint_attr(pool, msg, 
  332|      0|                                          PJ_STUN_ATTR_FINGERPRINT, 0);
  333|      0|        PJ_ASSERT_RETURN(status==PJ_SUCCESS, status);
  ------------------
  |  |   97|      0|            do { \
  |  |   98|      0|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 0]
  |  |  ------------------
  |  |   99|      0|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (333:9): [True: 0, False: 0]
  |  Branch (333:9): [True: 0, False: 0]
  ------------------
  334|      0|    }
  335|       |
  336|    401|    return PJ_SUCCESS;
  337|    401|}
stun_session.c:dump_tx_msg:
  926|    401|{
  927|    401|    char dst_name[PJ_INET6_ADDRSTRLEN+10];
  928|       |    
  929|    401|    if ((PJ_STUN_IS_REQUEST(msg->hdr.type) && 
  ------------------
  |  |  153|    802|#define PJ_STUN_IS_REQUEST(msg_type)    (((msg_type) & 0x0110) == 0x0000)
  |  |  ------------------
  |  |  |  Branch (153:41): [True: 0, False: 401]
  |  |  ------------------
  ------------------
  930|      0|         (sess->log_flag & PJ_STUN_SESS_LOG_TX_REQ)==0) ||
  ------------------
  |  Branch (930:10): [True: 0, False: 0]
  ------------------
  931|    401|        (PJ_STUN_IS_RESPONSE(msg->hdr.type) &&
  ------------------
  |  |  180|    802|#define PJ_STUN_IS_RESPONSE(msg_type) (((msg_type) & 0x0100) == 0x0100)
  |  |  ------------------
  |  |  |  Branch (180:39): [True: 401, False: 0]
  |  |  ------------------
  ------------------
  932|    401|         (sess->log_flag & PJ_STUN_SESS_LOG_TX_RES)==0) ||
  ------------------
  |  Branch (932:10): [True: 0, False: 401]
  ------------------
  933|    401|        (PJ_STUN_IS_INDICATION(msg->hdr.type) &&
  ------------------
  |  |  186|    802|#define PJ_STUN_IS_INDICATION(msg_type) (((msg_type) & 0x0110) == 0x0010)
  |  |  ------------------
  |  |  |  Branch (186:41): [True: 0, False: 401]
  |  |  ------------------
  ------------------
  934|      0|         (sess->log_flag & PJ_STUN_SESS_LOG_TX_IND)==0))
  ------------------
  |  Branch (934:10): [True: 0, False: 0]
  ------------------
  935|      0|    {
  936|      0|        return;
  937|      0|    }
  938|       |
  939|    401|    pj_sockaddr_print(addr, dst_name, sizeof(dst_name), 3);
  940|       |
  941|    401|    PJ_LOG(5,(SNAME(sess), 
  ------------------
  |  |  106|    401|#define PJ_LOG(level,arg)       do { \
  |  |  107|    401|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|    802|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 401, Folded]
  |  |  |  Branch (107:70): [True: 0, False: 401]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  496|      0|    #define pj_log_wrapper_5(arg)       pj_log_5 arg
  |  |  ------------------
  |  |  109|      0|                                    } \
  |  |  110|    401|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 401]
  |  |  ------------------
  ------------------
  942|    401|              "TX %d bytes STUN message to %s:\n"
  943|    401|              "--- begin STUN message ---\n"
  944|    401|              "%s"
  945|    401|              "--- end of STUN message ---\n",
  946|    401|              pkt_size, dst_name, 
  947|    401|              pj_stun_msg_dump(msg, sess->dump_buf, sizeof(sess->dump_buf), 
  948|    401|                               NULL)));
  949|       |
  950|    401|}
stun_session.c:send_response:
 1206|    401|{
 1207|    401|    pj_uint8_t *out_pkt;
 1208|    401|    pj_size_t out_max_len, out_len;
 1209|    401|    pj_status_t status;
 1210|       |
 1211|       |    /* Apply options */
 1212|    401|    if (!retransmission) {
  ------------------
  |  Branch (1212:9): [True: 401, False: 0]
  ------------------
 1213|    401|        status = apply_msg_options(sess, pool, auth_info, response);
 1214|    401|        if (status != PJ_SUCCESS)
  ------------------
  |  Branch (1214:13): [True: 0, False: 401]
  ------------------
 1215|      0|            return status;
 1216|    401|    }
 1217|       |
 1218|       |    /* Alloc packet buffer */
 1219|    401|    out_max_len = PJ_STUN_MAX_PKT_LEN;
  ------------------
  |  |  115|    401|#   define PJ_STUN_MAX_PKT_LEN                      800
  ------------------
 1220|    401|    out_pkt = (pj_uint8_t*) pj_pool_alloc(pool, out_max_len);
 1221|       |
 1222|       |    /* Encode */
 1223|    401|    status = pj_stun_msg_encode(response, out_pkt, out_max_len, 0,
 1224|    401|                                auth_info ? &auth_info->auth_key : NULL,
  ------------------
  |  Branch (1224:33): [True: 297, False: 104]
  ------------------
 1225|    401|                                &out_len);
 1226|    401|    if (status != PJ_SUCCESS) {
  ------------------
  |  Branch (1226:9): [True: 0, False: 401]
  ------------------
 1227|      0|        LOG_ERR_(sess, "Error encoding message", status);
  ------------------
  |  |   62|      0|#define LOG_ERR_(sess,title,rc) PJ_PERROR(3,(sess->pool->obj_name,rc,title))
  |  |  ------------------
  |  |  |  |  189|      0|#define PJ_PERROR(level,arg)    do { \
  |  |  |  |  190|      0|                                    pj_perror_wrapper_##level(arg); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  595|      0|    #define pj_perror_wrapper_3(arg)    pj_perror_3 arg
  |  |  |  |  ------------------
  |  |  |  |  191|      0|                                } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (191:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1228|      0|        return status;
 1229|      0|    }
 1230|       |
 1231|       |    /* Print log */
 1232|    401|    dump_tx_msg(sess, response, (unsigned)out_len, addr);
 1233|       |
 1234|       |    /* Send packet */
 1235|    401|    status = sess->cb.on_send_msg(sess, token, out_pkt, (unsigned)out_len, 
 1236|    401|                                  addr, addr_len);
 1237|       |
 1238|    401|    return status;
 1239|    401|}
stun_session.c:dump_rx_msg:
 1442|    394|{
 1443|    394|    char src_info[PJ_INET6_ADDRSTRLEN+10];
 1444|       |    
 1445|    394|    if ((PJ_STUN_IS_REQUEST(msg->hdr.type) && 
  ------------------
  |  |  153|    788|#define PJ_STUN_IS_REQUEST(msg_type)    (((msg_type) & 0x0110) == 0x0000)
  |  |  ------------------
  |  |  |  Branch (153:41): [True: 299, False: 95]
  |  |  ------------------
  ------------------
 1446|    299|         (sess->log_flag & PJ_STUN_SESS_LOG_RX_REQ)==0) ||
  ------------------
  |  Branch (1446:10): [True: 0, False: 299]
  ------------------
 1447|    394|        (PJ_STUN_IS_RESPONSE(msg->hdr.type) &&
  ------------------
  |  |  180|    788|#define PJ_STUN_IS_RESPONSE(msg_type) (((msg_type) & 0x0100) == 0x0100)
  |  |  ------------------
  |  |  |  Branch (180:39): [True: 26, False: 368]
  |  |  ------------------
  ------------------
 1448|     26|         (sess->log_flag & PJ_STUN_SESS_LOG_RX_RES)==0) ||
  ------------------
  |  Branch (1448:10): [True: 0, False: 26]
  ------------------
 1449|    394|        (PJ_STUN_IS_INDICATION(msg->hdr.type) &&
  ------------------
  |  |  186|    788|#define PJ_STUN_IS_INDICATION(msg_type) (((msg_type) & 0x0110) == 0x0010)
  |  |  ------------------
  |  |  |  Branch (186:41): [True: 69, False: 325]
  |  |  ------------------
  ------------------
 1450|     69|         (sess->log_flag & PJ_STUN_SESS_LOG_RX_IND)==0))
  ------------------
  |  Branch (1450:10): [True: 0, False: 69]
  ------------------
 1451|      0|    {
 1452|      0|        return;
 1453|      0|    }
 1454|       |
 1455|    394|    pj_sockaddr_print(addr, src_info, sizeof(src_info), 3);
 1456|       |
 1457|    394|    PJ_LOG(5,(SNAME(sess),
  ------------------
  |  |  106|    394|#define PJ_LOG(level,arg)       do { \
  |  |  107|    394|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|    788|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 394, Folded]
  |  |  |  Branch (107:70): [True: 0, False: 394]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  496|      0|    #define pj_log_wrapper_5(arg)       pj_log_5 arg
  |  |  ------------------
  |  |  109|      0|                                    } \
  |  |  110|    394|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 394]
  |  |  ------------------
  ------------------
 1458|    394|              "RX %d bytes STUN message from %s:\n"
 1459|    394|              "--- begin STUN message ---\n"
 1460|    394|              "%s"
 1461|    394|              "--- end of STUN message ---\n",
 1462|    394|              pkt_size, src_info,
 1463|    394|              pj_stun_msg_dump(msg, sess->dump_buf, sizeof(sess->dump_buf), 
 1464|    394|                               NULL)));
 1465|       |
 1466|    394|}
stun_session.c:check_cached_response:
 1332|    394|{
 1333|    394|    pj_stun_tx_data *t;
 1334|       |
 1335|       |    /* First lookup response in response cache */
 1336|    394|    t = sess->cached_response_list.next;
 1337|    394|    while (t != &sess->cached_response_list) {
  ------------------
  |  Branch (1337:12): [True: 0, False: 394]
  ------------------
 1338|      0|        if (t->msg_magic == msg->hdr.magic &&
  ------------------
  |  Branch (1338:13): [True: 0, False: 0]
  ------------------
 1339|      0|            t->msg->hdr.type == msg->hdr.type &&
  ------------------
  |  Branch (1339:13): [True: 0, False: 0]
  ------------------
 1340|      0|            pj_memcmp(t->msg_key, msg->hdr.tsx_id, 
  ------------------
  |  Branch (1340:13): [True: 0, False: 0]
  ------------------
 1341|      0|                      sizeof(msg->hdr.tsx_id))==0)
 1342|      0|        {
 1343|      0|            break;
 1344|      0|        }
 1345|      0|        t = t->next;
 1346|      0|    }
 1347|       |
 1348|    394|    if (t != &sess->cached_response_list) {
  ------------------
  |  Branch (1348:9): [True: 0, False: 394]
  ------------------
 1349|       |        /* Found response in the cache */
 1350|       |
 1351|      0|        PJ_LOG(5,(SNAME(sess), 
  ------------------
  |  |  106|      0|#define PJ_LOG(level,arg)       do { \
  |  |  107|      0|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|      0|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 0, Folded]
  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  496|      0|    #define pj_log_wrapper_5(arg)       pj_log_5 arg
  |  |  ------------------
  |  |  109|      0|                                    } \
  |  |  110|      0|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1352|      0|                 "Request retransmission, sending cached response"));
 1353|       |
 1354|      0|        send_response(sess, t->token, tmp_pool, t->msg, &t->auth_info, 
 1355|      0|                      PJ_TRUE, src_addr, src_addr_len);
 1356|      0|        return PJ_SUCCESS;
 1357|      0|    }
 1358|       |
 1359|    394|    return PJ_ENOTFOUND;
  ------------------
  |  |  403|    394|#define PJ_ENOTFOUND        (PJ_ERRNO_START_STATUS + 6) /* 70006 */
  |  |  ------------------
  |  |  |  |  521|    394|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|    394|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|    394|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1360|    394|}
stun_session.c:on_incoming_response:
 1281|     26|{
 1282|     26|    pj_stun_tx_data *tdata;
 1283|     26|    pj_status_t status;
 1284|       |
 1285|       |    /* Lookup pending client transaction */
 1286|     26|    tdata = tsx_lookup(sess, msg);
 1287|     26|    if (tdata == NULL) {
  ------------------
  |  Branch (1287:9): [True: 26, False: 0]
  ------------------
 1288|     26|        PJ_LOG(5,(SNAME(sess), 
  ------------------
  |  |  106|     26|#define PJ_LOG(level,arg)       do { \
  |  |  107|     26|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|     52|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 26, Folded]
  |  |  |  Branch (107:70): [True: 0, False: 26]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  496|      0|    #define pj_log_wrapper_5(arg)       pj_log_5 arg
  |  |  ------------------
  |  |  109|      0|                                    } \
  |  |  110|     26|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 26]
  |  |  ------------------
  ------------------
 1289|     26|                  "Transaction not found, response silently discarded"));
 1290|     26|        return PJ_SUCCESS;
 1291|     26|    }
 1292|       |
 1293|      0|    if (sess->auth_type == PJ_STUN_AUTH_NONE)
  ------------------
  |  Branch (1293:9): [True: 0, False: 0]
  ------------------
 1294|      0|        options |= PJ_STUN_NO_AUTHENTICATE;
 1295|       |
 1296|       |    /* Authenticate the message, unless PJ_STUN_NO_AUTHENTICATE
 1297|       |     * is specified in the option.
 1298|       |     */
 1299|      0|    if ((options & PJ_STUN_NO_AUTHENTICATE) == 0 && 
  ------------------
  |  Branch (1299:9): [True: 0, False: 0]
  ------------------
 1300|      0|        tdata->auth_info.auth_key.slen != 0 && 
  ------------------
  |  Branch (1300:9): [True: 0, False: 0]
  ------------------
 1301|      0|        pj_stun_auth_valid_for_msg(msg))
  ------------------
  |  Branch (1301:9): [True: 0, False: 0]
  ------------------
 1302|      0|    {
 1303|      0|        status = pj_stun_authenticate_response(pkt, pkt_len, msg, 
 1304|      0|                                               &tdata->auth_info.auth_key);
 1305|      0|        if (status != PJ_SUCCESS) {
  ------------------
  |  Branch (1305:13): [True: 0, False: 0]
  ------------------
 1306|      0|            PJ_PERROR(5,(SNAME(sess), status,
  ------------------
  |  |  189|      0|#define PJ_PERROR(level,arg)    do { \
  |  |  190|      0|                                    pj_perror_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  627|      0|    #define pj_perror_wrapper_5(arg)    pj_perror_5 arg
  |  |  ------------------
  |  |  191|      0|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (191:42): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1307|      0|                         "Response authentication failed"));
 1308|      0|            return status;
 1309|      0|        }
 1310|      0|    }
 1311|       |
 1312|       |    /* Pass the response to the transaction. 
 1313|       |     * If the message is accepted, transaction callback will be called,
 1314|       |     * and this will call the session callback too.
 1315|       |     */
 1316|      0|    status = pj_stun_client_tsx_on_rx_msg(tdata->client_tsx, msg, 
 1317|      0|                                          src_addr, src_addr_len);
 1318|      0|    if (status != PJ_SUCCESS) {
  ------------------
  |  Branch (1318:9): [True: 0, False: 0]
  ------------------
 1319|      0|        return status;
 1320|      0|    }
 1321|       |
 1322|      0|    return PJ_SUCCESS;
 1323|      0|}
stun_session.c:tsx_lookup:
  105|     26|{
  106|     26|    pj_stun_tx_data *tdata;
  107|       |
  108|     26|    tdata = sess->pending_request_list.next;
  109|     26|    while (tdata != &sess->pending_request_list) {
  ------------------
  |  Branch (109:12): [True: 0, False: 26]
  ------------------
  110|      0|        pj_assert(sizeof(tdata->msg_key)==sizeof(msg->hdr.tsx_id));
  ------------------
  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (110:9): [True: 0, Folded]
  |  Branch (110:9): [True: 0, Folded]
  ------------------
  111|      0|        if (tdata->msg_magic == msg->hdr.magic &&
  ------------------
  |  Branch (111:13): [True: 0, False: 0]
  ------------------
  112|      0|            pj_memcmp(tdata->msg_key, msg->hdr.tsx_id, 
  ------------------
  |  Branch (112:13): [True: 0, False: 0]
  ------------------
  113|      0|                      sizeof(msg->hdr.tsx_id))==0)
  114|      0|        {
  115|      0|            return tdata;
  116|      0|        }
  117|      0|        tdata = tdata->next;
  118|      0|    }
  119|       |
  120|     26|    return NULL;
  121|     26|}
stun_session.c:on_incoming_request:
 1372|    299|{
 1373|    299|    pj_stun_rx_data rdata;
 1374|    299|    pj_status_t status;
 1375|       |
 1376|       |    /* Init rdata */
 1377|    299|    rdata.msg = msg;
 1378|    299|    pj_bzero(&rdata.info, sizeof(rdata.info));
 1379|       |
 1380|    299|    if (sess->auth_type == PJ_STUN_AUTH_NONE)
  ------------------
  |  Branch (1380:9): [True: 0, False: 299]
  ------------------
 1381|      0|        options |= PJ_STUN_NO_AUTHENTICATE;
 1382|       |
 1383|       |    /* Authenticate the message, unless PJ_STUN_NO_AUTHENTICATE
 1384|       |     * is specified in the option.
 1385|       |     */
 1386|    299|    if ((options & PJ_STUN_NO_AUTHENTICATE) == 0) {
  ------------------
  |  Branch (1386:9): [True: 299, False: 0]
  ------------------
 1387|    299|        status = authenticate_req(sess, token, (const pj_uint8_t*) in_pkt, 
 1388|    299|                                  in_pkt_len,&rdata, tmp_pool, src_addr, 
 1389|    299|                                  src_addr_len);
 1390|    299|        if (status != PJ_SUCCESS) {
  ------------------
  |  Branch (1390:13): [True: 297, False: 2]
  ------------------
 1391|    297|            return status;
 1392|    297|        }
 1393|    299|    }
 1394|       |
 1395|       |    /* Distribute to handler, or respond with Bad Request */
 1396|      2|    if (sess->cb.on_rx_request) {
  ------------------
  |  Branch (1396:9): [True: 0, False: 2]
  ------------------
 1397|      0|        status = (*sess->cb.on_rx_request)(sess, in_pkt, in_pkt_len, &rdata,
 1398|      0|                                           token, src_addr, src_addr_len);
 1399|      2|    } else {
 1400|      2|        pj_str_t err_text;
 1401|      2|        pj_stun_msg *response;
 1402|       |
 1403|      2|        err_text = pj_str("Callback is not set to handle request");
 1404|      2|        status = pj_stun_msg_create_response(tmp_pool, msg, 
 1405|      2|                                             PJ_STUN_SC_BAD_REQUEST, 
 1406|      2|                                             &err_text, &response);
 1407|      2|        if (status == PJ_SUCCESS && response) {
  ------------------
  |  Branch (1407:13): [True: 2, False: 0]
  |  Branch (1407:37): [True: 2, False: 0]
  ------------------
 1408|      2|            status = send_response(sess, token, tmp_pool, response, 
 1409|      2|                                   NULL, PJ_FALSE, src_addr, src_addr_len);
 1410|      2|        }
 1411|      2|    }
 1412|       |
 1413|      2|    return status;
 1414|    299|}
stun_session.c:authenticate_req:
 1250|    299|{
 1251|    299|    pj_stun_msg *response;
 1252|    299|    pj_status_t status;
 1253|       |
 1254|    299|    if (PJ_STUN_IS_ERROR_RESPONSE(rdata->msg->hdr.type) || 
  ------------------
  |  |  170|    598|#define PJ_STUN_IS_ERROR_RESPONSE(msg_type) (((msg_type) & 0x0110) == 0x0110)
  |  |  ------------------
  |  |  |  Branch (170:45): [True: 0, False: 299]
  |  |  ------------------
  ------------------
 1255|    299|        sess->auth_type == PJ_STUN_AUTH_NONE)
  ------------------
  |  Branch (1255:9): [True: 0, False: 299]
  ------------------
 1256|      0|    {
 1257|      0|        return PJ_SUCCESS;
 1258|      0|    }
 1259|       |
 1260|    299|    status = pj_stun_authenticate_request(pkt, pkt_len, rdata->msg, 
 1261|    299|                                          &sess->cred, tmp_pool, &rdata->info,
 1262|    299|                                          &response);
 1263|    299|    if (status != PJ_SUCCESS && response != NULL) {
  ------------------
  |  Branch (1263:9): [True: 297, False: 2]
  |  Branch (1263:33): [True: 297, False: 0]
  ------------------
 1264|    297|        PJ_PERROR(5,(SNAME(sess), status, "Message authentication failed"));
  ------------------
  |  |  189|    297|#define PJ_PERROR(level,arg)    do { \
  |  |  190|    297|                                    pj_perror_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  627|    297|    #define pj_perror_wrapper_5(arg)    pj_perror_5 arg
  |  |  ------------------
  |  |  191|    297|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (191:42): [Folded, False: 297]
  |  |  ------------------
  ------------------
 1265|    297|        send_response(sess, token, tmp_pool, response, &rdata->info, 
 1266|    297|                      PJ_FALSE, src_addr, src_addr_len);
 1267|    297|    }
 1268|       |
 1269|    299|    return status;
 1270|    299|}
stun_session.c:on_incoming_indication:
 1426|     69|{
 1427|     69|    PJ_UNUSED_ARG(tmp_pool);
  ------------------
  |  | 1537|     69|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
 1428|       |
 1429|       |    /* Distribute to handler */
 1430|     69|    if (sess->cb.on_rx_indication) {
  ------------------
  |  Branch (1430:9): [True: 69, False: 0]
  ------------------
 1431|     69|        return (*sess->cb.on_rx_indication)(sess, in_pkt, in_pkt_len, msg,
 1432|     69|                                            token, src_addr, src_addr_len);
 1433|     69|    } else {
 1434|      0|        return PJ_SUCCESS;
 1435|      0|    }
 1436|     69|}

pj_stun_sock_cfg_default:
  146|    341|{
  147|    341|    pj_bzero(cfg, sizeof(*cfg));
  148|    341|    cfg->max_pkt_size = PJ_STUN_SOCK_PKT_LEN;
  ------------------
  |  |  153|    341|#   define PJ_STUN_SOCK_PKT_LEN                     2000
  ------------------
  149|    341|    cfg->async_cnt = 1;
  150|    341|    cfg->ka_interval = PJ_STUN_KEEP_ALIVE_SEC;
  ------------------
  |  |  161|    341|#   define PJ_STUN_KEEP_ALIVE_SEC                   15
  ------------------
  151|    341|    cfg->qos_type = PJ_QOS_TYPE_BEST_EFFORT;
  152|    341|    cfg->qos_ignore_error = PJ_TRUE;
  153|    341|}
pj_stun_sock_create:
  172|    341|{
  173|    341|    pj_pool_t *pool;
  174|    341|    pj_stun_sock *stun_sock;
  175|    341|    pj_stun_sock_cfg default_cfg;
  176|    341|    pj_sockaddr bound_addr;
  177|    341|    unsigned i;
  178|    341|    pj_uint16_t max_bind_retry;
  179|    341|    pj_status_t status;
  180|       |
  181|    341|    PJ_ASSERT_RETURN(stun_cfg && cb && p_stun_sock, PJ_EINVAL);
  ------------------
  |  |   97|    341|            do { \
  |  |   98|  1.36k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 341, False: 0]
  |  |  |  Branch (98:23): [True: 341, False: 0]
  |  |  |  Branch (98:23): [True: 341, False: 0]
  |  |  ------------------
  |  |   99|    341|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 341]
  |  |  ------------------
  ------------------
  |  Branch (181:5): [True: 0, False: 0]
  |  Branch (181:5): [True: 0, False: 0]
  |  Branch (181:5): [True: 0, False: 0]
  |  Branch (181:5): [True: 0, False: 0]
  |  Branch (181:5): [True: 0, False: 0]
  |  Branch (181:5): [True: 0, False: 0]
  ------------------
  182|    341|    PJ_ASSERT_RETURN(af==pj_AF_INET()||af==pj_AF_INET6(), PJ_EAFNOTSUP);
  ------------------
  |  |   97|    341|            do { \
  |  |   98|    341|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 341, False: 0]
  |  |  |  Branch (98:23): [True: 0, False: 0]
  |  |  ------------------
  |  |   99|    341|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 341]
  |  |  ------------------
  ------------------
  |  Branch (182:5): [True: 0, False: 0]
  |  Branch (182:5): [True: 0, False: 0]
  |  Branch (182:5): [True: 0, False: 0]
  |  Branch (182:5): [True: 0, False: 0]
  ------------------
  183|    341|    PJ_ASSERT_RETURN(!cfg || pj_stun_sock_cfg_is_valid(cfg), PJ_EINVAL);
  ------------------
  |  |   97|    341|            do { \
  |  |   98|    682|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 0, False: 341]
  |  |  |  Branch (98:23): [True: 341, False: 0]
  |  |  ------------------
  |  |   99|    341|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 341]
  |  |  ------------------
  ------------------
  |  Branch (183:5): [True: 0, False: 0]
  |  Branch (183:5): [True: 0, False: 0]
  |  Branch (183:5): [True: 0, False: 0]
  |  Branch (183:5): [True: 0, False: 0]
  ------------------
  184|    341|    PJ_ASSERT_RETURN(cb->on_status, PJ_EINVAL);
  ------------------
  |  |   97|    341|            do { \
  |  |   98|    341|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 341]
  |  |  ------------------
  |  |   99|    341|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 341]
  |  |  ------------------
  ------------------
  |  Branch (184:5): [True: 0, False: 0]
  |  Branch (184:5): [True: 0, False: 0]
  ------------------
  185|       |
  186|    341|    status = pj_stun_config_check_valid(stun_cfg);
  187|    341|    if (status != PJ_SUCCESS)
  ------------------
  |  Branch (187:9): [True: 0, False: 341]
  ------------------
  188|      0|        return status;
  189|       |
  190|    341|    if (name == NULL)
  ------------------
  |  Branch (190:9): [True: 341, False: 0]
  ------------------
  191|    341|        name = "stuntp%p";
  192|       |
  193|    341|    if (cfg == NULL) {
  ------------------
  |  Branch (193:9): [True: 0, False: 341]
  ------------------
  194|      0|        pj_stun_sock_cfg_default(&default_cfg);
  195|      0|        cfg = &default_cfg;
  196|      0|    }
  197|       |
  198|       |
  199|       |    /* Create structure */
  200|    341|    pool = pj_pool_create(stun_cfg->pf, name, 256, 512, NULL);
  201|    341|    stun_sock = PJ_POOL_ZALLOC_T(pool, pj_stun_sock);
  ------------------
  |  |  583|    341|            ((type*)pj_pool_zalloc(pool, sizeof(type)))
  ------------------
  202|    341|    stun_sock->pool = pool;
  203|    341|    stun_sock->obj_name = pool->obj_name;
  204|    341|    stun_sock->user_data = user_data;
  205|    341|    stun_sock->af = af;
  206|    341|    stun_sock->sock_fd = PJ_INVALID_SOCKET;
  ------------------
  |  |  492|    341|#define PJ_INVALID_SOCKET   (-1)
  ------------------
  207|    341|    pj_memcpy(&stun_sock->stun_cfg, stun_cfg, sizeof(*stun_cfg));
  208|    341|    pj_memcpy(&stun_sock->cb, cb, sizeof(*cb));
  209|       |
  210|    341|    stun_sock->ka_interval = cfg->ka_interval;
  211|    341|    if (stun_sock->ka_interval == 0)
  ------------------
  |  Branch (211:9): [True: 0, False: 341]
  ------------------
  212|      0|        stun_sock->ka_interval = PJ_STUN_KEEP_ALIVE_SEC;
  ------------------
  |  |  161|      0|#   define PJ_STUN_KEEP_ALIVE_SEC                   15
  ------------------
  213|       |
  214|    341|    if (cfg->grp_lock) {
  ------------------
  |  Branch (214:9): [True: 341, False: 0]
  ------------------
  215|    341|        stun_sock->grp_lock = cfg->grp_lock;
  216|    341|    } else {
  217|      0|        status = pj_grp_lock_create(pool, NULL, &stun_sock->grp_lock);
  218|      0|        if (status != PJ_SUCCESS) {
  ------------------
  |  Branch (218:13): [True: 0, False: 0]
  ------------------
  219|      0|            pj_pool_release(pool);
  220|      0|            return status;
  221|      0|        }
  222|      0|    }
  223|       |
  224|    341|    pj_grp_lock_add_ref(stun_sock->grp_lock);
  225|    341|    pj_grp_lock_add_handler(stun_sock->grp_lock, pool, stun_sock,
  226|    341|                            &stun_sock_destructor);
  227|       |
  228|       |    /* Create socket and bind socket */
  229|    341|    status = pj_sock_socket(af, pj_SOCK_DGRAM() | pj_SOCK_CLOEXEC(), 0, &stun_sock->sock_fd);
  ------------------
  |  |  167|    341|#   define pj_SOCK_DGRAM()  PJ_SOCK_DGRAM
  ------------------
                  status = pj_sock_socket(af, pj_SOCK_DGRAM() | pj_SOCK_CLOEXEC(), 0, &stun_sock->sock_fd);
  ------------------
  |  |  173|    341|#   define pj_SOCK_CLOEXEC() PJ_SOCK_CLOEXEC
  ------------------
  230|    341|    if (status != PJ_SUCCESS)
  ------------------
  |  Branch (230:9): [True: 0, False: 341]
  ------------------
  231|      0|        goto on_error;
  232|       |
  233|       |    /* Apply QoS, if specified */
  234|    341|    status = pj_sock_apply_qos2(stun_sock->sock_fd, cfg->qos_type,
  235|    341|                                &cfg->qos_params, 2, stun_sock->obj_name,
  236|    341|                                NULL);
  237|    341|    if (status != PJ_SUCCESS && !cfg->qos_ignore_error)
  ------------------
  |  Branch (237:9): [True: 0, False: 341]
  |  Branch (237:33): [True: 0, False: 0]
  ------------------
  238|      0|        goto on_error;
  239|       |
  240|       |    /* Apply socket buffer size */
  241|    341|    if (cfg->so_rcvbuf_size > 0) {
  ------------------
  |  Branch (241:9): [True: 0, False: 341]
  ------------------
  242|      0|        unsigned sobuf_size = cfg->so_rcvbuf_size;
  243|      0|        status = pj_sock_setsockopt_sobuf(stun_sock->sock_fd, pj_SO_RCVBUF(),
  ------------------
  |  |  384|      0|#   define pj_SO_RCVBUF()   PJ_SO_RCVBUF
  ------------------
  244|      0|                                          PJ_TRUE, &sobuf_size);
  245|      0|        if (status != PJ_SUCCESS) {
  ------------------
  |  Branch (245:13): [True: 0, False: 0]
  ------------------
  246|      0|            PJ_PERROR(3, (stun_sock->obj_name, status,
  ------------------
  |  |  189|      0|#define PJ_PERROR(level,arg)    do { \
  |  |  190|      0|                                    pj_perror_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  595|      0|    #define pj_perror_wrapper_3(arg)    pj_perror_3 arg
  |  |  ------------------
  |  |  191|      0|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (191:42): [Folded, False: 0]
  |  |  ------------------
  ------------------
  247|      0|                          "Failed setting SO_RCVBUF"));
  248|      0|        } else {
  249|      0|            if (sobuf_size < cfg->so_rcvbuf_size) {
  ------------------
  |  Branch (249:17): [True: 0, False: 0]
  ------------------
  250|      0|                PJ_LOG(4, (stun_sock->obj_name, 
  ------------------
  |  |  106|      0|#define PJ_LOG(level,arg)       do { \
  |  |  107|      0|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|      0|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 0, Folded]
  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  480|      0|    #define pj_log_wrapper_4(arg)       pj_log_4 arg
  |  |  ------------------
  |  |  109|      0|                                    } \
  |  |  110|      0|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 0]
  |  |  ------------------
  ------------------
  251|      0|                           "Warning! Cannot set SO_RCVBUF as configured, "
  252|      0|                           "now=%d, configured=%d",
  253|      0|                           sobuf_size, cfg->so_rcvbuf_size));
  254|      0|            } else {
  255|      0|                PJ_LOG(5, (stun_sock->obj_name, "SO_RCVBUF set to %d",
  ------------------
  |  |  106|      0|#define PJ_LOG(level,arg)       do { \
  |  |  107|      0|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|      0|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 0, Folded]
  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  496|      0|    #define pj_log_wrapper_5(arg)       pj_log_5 arg
  |  |  ------------------
  |  |  109|      0|                                    } \
  |  |  110|      0|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 0]
  |  |  ------------------
  ------------------
  256|      0|                           sobuf_size));
  257|      0|            }
  258|      0|        }
  259|      0|    }
  260|    341|    if (cfg->so_sndbuf_size > 0) {
  ------------------
  |  Branch (260:9): [True: 0, False: 341]
  ------------------
  261|      0|        unsigned sobuf_size = cfg->so_sndbuf_size;
  262|      0|        status = pj_sock_setsockopt_sobuf(stun_sock->sock_fd, pj_SO_SNDBUF(),
  ------------------
  |  |  387|      0|#   define pj_SO_SNDBUF()   PJ_SO_SNDBUF
  ------------------
  263|      0|                                          PJ_TRUE, &sobuf_size);
  264|      0|        if (status != PJ_SUCCESS) {
  ------------------
  |  Branch (264:13): [True: 0, False: 0]
  ------------------
  265|      0|            PJ_PERROR(3, (stun_sock->obj_name, status,
  ------------------
  |  |  189|      0|#define PJ_PERROR(level,arg)    do { \
  |  |  190|      0|                                    pj_perror_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  595|      0|    #define pj_perror_wrapper_3(arg)    pj_perror_3 arg
  |  |  ------------------
  |  |  191|      0|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (191:42): [Folded, False: 0]
  |  |  ------------------
  ------------------
  266|      0|                          "Failed setting SO_SNDBUF"));
  267|      0|        } else {
  268|      0|            if (sobuf_size < cfg->so_sndbuf_size) {
  ------------------
  |  Branch (268:17): [True: 0, False: 0]
  ------------------
  269|      0|                PJ_LOG(4, (stun_sock->obj_name, 
  ------------------
  |  |  106|      0|#define PJ_LOG(level,arg)       do { \
  |  |  107|      0|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|      0|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 0, Folded]
  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  480|      0|    #define pj_log_wrapper_4(arg)       pj_log_4 arg
  |  |  ------------------
  |  |  109|      0|                                    } \
  |  |  110|      0|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 0]
  |  |  ------------------
  ------------------
  270|      0|                           "Warning! Cannot set SO_SNDBUF as configured, "
  271|      0|                           "now=%d, configured=%d",
  272|      0|                           sobuf_size, cfg->so_sndbuf_size));
  273|      0|            } else {
  274|      0|                PJ_LOG(5, (stun_sock->obj_name, "SO_SNDBUF set to %d",
  ------------------
  |  |  106|      0|#define PJ_LOG(level,arg)       do { \
  |  |  107|      0|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|      0|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 0, Folded]
  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  496|      0|    #define pj_log_wrapper_5(arg)       pj_log_5 arg
  |  |  ------------------
  |  |  109|      0|                                    } \
  |  |  110|      0|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 0]
  |  |  ------------------
  ------------------
  275|      0|                           sobuf_size));
  276|      0|            }
  277|      0|        }
  278|      0|    }
  279|       |
  280|       |    /* Bind socket */
  281|    341|    max_bind_retry = MAX_BIND_RETRY;
  282|    341|    if (cfg->port_range && cfg->port_range < max_bind_retry)
  ------------------
  |  Branch (282:9): [True: 0, False: 341]
  |  Branch (282:28): [True: 0, False: 0]
  ------------------
  283|      0|        max_bind_retry = cfg->port_range;
  284|    341|    pj_sockaddr_init(af, &bound_addr, NULL, 0);
  285|    341|    if (pj_sockaddr_has_addr(&cfg->bound_addr.addr) || 
  ------------------
  |  Branch (285:9): [True: 0, False: 341]
  ------------------
  286|    341|        ((cfg->bound_addr.addr.sa_family == pj_AF_INET() ||
  ------------------
  |  |  113|    682|#   define pj_AF_INET()     PJ_AF_INET
  ------------------
  |  Branch (286:11): [True: 0, False: 341]
  ------------------
  287|    341|          cfg->bound_addr.addr.sa_family == pj_AF_INET6()) &&
  ------------------
  |  |  115|    341|#   define pj_AF_INET6()    PJ_AF_INET6
  ------------------
  |  Branch (287:11): [True: 0, False: 341]
  ------------------
  288|      0|            pj_sockaddr_get_port(&cfg->bound_addr) != 0))
  ------------------
  |  Branch (288:13): [True: 0, False: 0]
  ------------------
  289|      0|    {
  290|      0|        pj_sockaddr_cp(&bound_addr, &cfg->bound_addr);
  291|      0|    }
  292|    341|    status = pj_sock_bind_random(stun_sock->sock_fd, &bound_addr,
  293|    341|                                 cfg->port_range, max_bind_retry);
  294|    341|    if (status != PJ_SUCCESS)
  ------------------
  |  Branch (294:9): [True: 0, False: 341]
  ------------------
  295|      0|        goto on_error;
  296|       |
  297|       |    /* Create more useful information string about this transport */
  298|       |#if 0
  299|       |    {
  300|       |        pj_sockaddr bound_addr;
  301|       |        int addr_len = sizeof(bound_addr);
  302|       |
  303|       |        status = pj_sock_getsockname(stun_sock->sock_fd, &bound_addr, 
  304|       |                                     &addr_len);
  305|       |        if (status != PJ_SUCCESS)
  306|       |            goto on_error;
  307|       |
  308|       |        stun_sock->info = pj_pool_alloc(pool, PJ_INET6_ADDRSTRLEN+10);
  309|       |        pj_sockaddr_print(&bound_addr, stun_sock->info, 
  310|       |                          PJ_INET6_ADDRSTRLEN, 3);
  311|       |    }
  312|       |#endif
  313|       |
  314|       |    /* Init active socket configuration */
  315|    341|    {
  316|    341|        pj_activesock_cfg activesock_cfg;
  317|    341|        pj_activesock_cb activesock_cb;
  318|       |
  319|    341|        pj_activesock_cfg_default(&activesock_cfg);
  320|    341|        activesock_cfg.grp_lock = stun_sock->grp_lock;
  321|    341|        activesock_cfg.async_cnt = cfg->async_cnt;
  322|    341|        activesock_cfg.concurrency = 0;
  323|       |
  324|       |        /* Create the active socket */
  325|    341|        pj_bzero(&activesock_cb, sizeof(activesock_cb));
  326|    341|        activesock_cb.on_data_recvfrom = &on_data_recvfrom;
  327|    341|        activesock_cb.on_data_sent = &on_data_sent;
  328|    341|        status = pj_activesock_create(pool, stun_sock->sock_fd, 
  329|    341|                                      pj_SOCK_DGRAM(), 
  ------------------
  |  |  167|    341|#   define pj_SOCK_DGRAM()  PJ_SOCK_DGRAM
  ------------------
  330|    341|                                      &activesock_cfg, stun_cfg->ioqueue,
  331|    341|                                      &activesock_cb, stun_sock,
  332|    341|                                      &stun_sock->active_sock);
  333|    341|        if (status != PJ_SUCCESS)
  ------------------
  |  Branch (333:13): [True: 0, False: 341]
  ------------------
  334|      0|            goto on_error;
  335|       |
  336|       |        /* Start asynchronous read operations */
  337|    341|        status = pj_activesock_start_recvfrom(stun_sock->active_sock, pool,
  338|    341|                                              cfg->max_pkt_size, 0);
  339|    341|        if (status != PJ_SUCCESS)
  ------------------
  |  Branch (339:13): [True: 0, False: 341]
  ------------------
  340|      0|            goto on_error;
  341|       |
  342|       |        /* Init send keys */
  343|    341|        pj_ioqueue_op_key_init(&stun_sock->send_key, 
  344|    341|                               sizeof(stun_sock->send_key));
  345|    341|        pj_ioqueue_op_key_init(&stun_sock->int_send_key,
  346|    341|                               sizeof(stun_sock->int_send_key));
  347|    341|    }
  348|       |
  349|       |    /* Create STUN session */
  350|      0|    {
  351|    341|        pj_stun_session_cb sess_cb;
  352|       |
  353|    341|        pj_bzero(&sess_cb, sizeof(sess_cb));
  354|    341|        sess_cb.on_request_complete = &sess_on_request_complete;
  355|    341|        sess_cb.on_send_msg = &sess_on_send_msg;
  356|    341|        status = pj_stun_session_create(&stun_sock->stun_cfg, 
  357|    341|                                        stun_sock->obj_name,
  358|    341|                                        &sess_cb, PJ_FALSE, 
  359|    341|                                        stun_sock->grp_lock,
  360|    341|                                        &stun_sock->stun_sess);
  361|    341|        if (status != PJ_SUCCESS)
  ------------------
  |  Branch (361:13): [True: 0, False: 341]
  ------------------
  362|      0|            goto on_error;
  363|    341|    }
  364|       |
  365|       |    /* Associate us with the STUN session */
  366|    341|    pj_stun_session_set_user_data(stun_sock->stun_sess, stun_sock);
  367|       |
  368|       |    /* Initialize random numbers to be used as STUN transaction ID for
  369|       |     * outgoing Binding request. We use the 80bit number to distinguish
  370|       |     * STUN messages we sent with STUN messages that the application sends.
  371|       |     * The last 16bit value in the array is a counter.
  372|       |     */
  373|  2.38k|    for (i=0; i<PJ_ARRAY_SIZE(stun_sock->tsx_id); ++i) {
  ------------------
  |  |  315|  2.38k|#define PJ_ARRAY_SIZE(a)    (sizeof(a)/sizeof(a[0]))
  ------------------
  |  Branch (373:15): [True: 2.04k, False: 341]
  ------------------
  374|  2.04k|        stun_sock->tsx_id[i] = (pj_uint16_t) pj_rand();
  375|  2.04k|    }
  376|    341|    stun_sock->tsx_id[5] = 0;
  377|       |
  378|       |
  379|       |    /* Init timer entry */
  380|    341|    stun_sock->ka_timer.cb = &ka_timer_cb;
  381|    341|    stun_sock->ka_timer.user_data = stun_sock;
  382|       |
  383|       |    /* Done */
  384|    341|    *p_stun_sock = stun_sock;
  385|    341|    return PJ_SUCCESS;
  386|       |
  387|      0|on_error:
  388|      0|    pj_stun_sock_destroy(stun_sock);
  389|      0|    return status;
  390|    341|}
pj_stun_sock_destroy:
  507|    341|{
  508|    341|    TRACE_((stun_sock->obj_name, "STUN sock %p request, ref_cnt=%d",
  ------------------
  |  |   35|    341|#  define TRACE_(x)     PJ_LOG(5,x)
  |  |  ------------------
  |  |  |  |  106|    341|#define PJ_LOG(level,arg)       do { \
  |  |  |  |  107|    341|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |  417|    682|#  define PJ_LOG_MAX_LEVEL   5
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (107:41): [True: 341, Folded]
  |  |  |  |  |  Branch (107:70): [True: 0, False: 341]
  |  |  |  |  ------------------
  |  |  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  496|      0|    #define pj_log_wrapper_5(arg)       pj_log_5 arg
  |  |  |  |  ------------------
  |  |  |  |  109|      0|                                    } \
  |  |  |  |  110|    341|                                } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (110:42): [Folded, False: 341]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  509|    341|            stun_sock, pj_grp_lock_get_ref(stun_sock->grp_lock)));
  510|       |
  511|    341|    pj_grp_lock_acquire(stun_sock->grp_lock);
  512|    341|    if (stun_sock->is_destroying) {
  ------------------
  |  Branch (512:9): [True: 0, False: 341]
  ------------------
  513|       |        /* Destroy already called */
  514|      0|        pj_grp_lock_release(stun_sock->grp_lock);
  515|      0|        return PJ_EINVALIDOP;
  ------------------
  |  |  438|      0|#define PJ_EINVALIDOP       (PJ_ERRNO_START_STATUS + 13)/* 70013 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  516|      0|    }
  517|       |
  518|    341|    stun_sock->is_destroying = PJ_TRUE;
  519|    341|    pj_timer_heap_cancel_if_active(stun_sock->stun_cfg.timer_heap,
  520|    341|                                   &stun_sock->ka_timer, 0);
  521|       |
  522|    341|    if (stun_sock->active_sock != NULL) {
  ------------------
  |  Branch (522:9): [True: 341, False: 0]
  ------------------
  523|    341|        stun_sock->sock_fd = PJ_INVALID_SOCKET;
  ------------------
  |  |  492|    341|#define PJ_INVALID_SOCKET   (-1)
  ------------------
  524|    341|        pj_activesock_close(stun_sock->active_sock);
  525|    341|    } else if (stun_sock->sock_fd != PJ_INVALID_SOCKET) {
  ------------------
  |  |  492|      0|#define PJ_INVALID_SOCKET   (-1)
  ------------------
  |  Branch (525:16): [True: 0, False: 0]
  ------------------
  526|      0|        pj_sock_close(stun_sock->sock_fd);
  527|      0|        stun_sock->sock_fd = PJ_INVALID_SOCKET;
  ------------------
  |  |  492|      0|#define PJ_INVALID_SOCKET   (-1)
  ------------------
  528|      0|    }
  529|       |
  530|    341|    if (stun_sock->stun_sess) {
  ------------------
  |  Branch (530:9): [True: 341, False: 0]
  ------------------
  531|    341|        pj_stun_session_destroy(stun_sock->stun_sess);
  532|    341|    }
  533|    341|    pj_grp_lock_dec_ref(stun_sock->grp_lock);
  534|    341|    pj_grp_lock_release(stun_sock->grp_lock);
  535|    341|    return PJ_SUCCESS;
  536|    341|}
pj_stun_sock_get_info:
  654|    341|{
  655|    341|    int addr_len;
  656|    341|    pj_status_t status;
  657|       |
  658|    341|    PJ_ASSERT_RETURN(stun_sock && info, PJ_EINVAL);
  ------------------
  |  |   97|    341|            do { \
  |  |   98|    682|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 341, False: 0]
  |  |  |  Branch (98:23): [True: 341, False: 0]
  |  |  ------------------
  |  |   99|    341|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 341]
  |  |  ------------------
  ------------------
  |  Branch (658:5): [True: 0, False: 0]
  |  Branch (658:5): [True: 0, False: 0]
  |  Branch (658:5): [True: 0, False: 0]
  |  Branch (658:5): [True: 0, False: 0]
  ------------------
  659|       |
  660|    341|    pj_grp_lock_acquire(stun_sock->grp_lock);
  661|       |
  662|       |    /* Copy STUN server address and mapped address */
  663|    341|    pj_memcpy(&info->srv_addr, &stun_sock->srv_addr,
  664|    341|              sizeof(pj_sockaddr));
  665|    341|    pj_memcpy(&info->mapped_addr, &stun_sock->mapped_addr, 
  666|    341|              sizeof(pj_sockaddr));
  667|       |
  668|       |    /* Retrieve bound address */
  669|    341|    addr_len = sizeof(info->bound_addr);
  670|    341|    status = pj_sock_getsockname(stun_sock->sock_fd, &info->bound_addr,
  671|    341|                                 &addr_len);
  672|    341|    if (status != PJ_SUCCESS) {
  ------------------
  |  Branch (672:9): [True: 0, False: 341]
  ------------------
  673|      0|        pj_grp_lock_release(stun_sock->grp_lock);
  674|      0|        return status;
  675|      0|    }
  676|       |
  677|       |    /* If socket is bound to a specific interface, then only put that
  678|       |     * interface in the alias list. Otherwise query all the interfaces 
  679|       |     * in the host.
  680|       |     */
  681|    341|    if (pj_sockaddr_has_addr(&info->bound_addr)) {
  ------------------
  |  Branch (681:9): [True: 0, False: 341]
  ------------------
  682|      0|        info->alias_cnt = 1;
  683|      0|        pj_sockaddr_cp(&info->aliases[0], &info->bound_addr);
  684|    341|    } else {
  685|    341|        pj_sockaddr def_addr;
  686|    341|        pj_uint16_t port = pj_sockaddr_get_port(&info->bound_addr);
  687|    341|        pj_enum_ip_option enum_opt;
  688|    341|        unsigned i;
  689|       |
  690|       |        /* Get the default address */
  691|    341|        status = pj_gethostip(stun_sock->af, &def_addr);
  692|    341|        if (status != PJ_SUCCESS) {
  ------------------
  |  Branch (692:13): [True: 0, False: 341]
  ------------------
  693|      0|            PJ_PERROR(4,(stun_sock->obj_name, status,
  ------------------
  |  |  189|      0|#define PJ_PERROR(level,arg)    do { \
  |  |  190|      0|                                    pj_perror_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  611|      0|    #define pj_perror_wrapper_4(arg)    pj_perror_4 arg
  |  |  ------------------
  |  |  191|      0|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (191:42): [Folded, False: 0]
  |  |  ------------------
  ------------------
  694|      0|                         "Failed in getting default address for STUN info"));
  695|      0|            pj_grp_lock_release(stun_sock->grp_lock);
  696|      0|            return status;
  697|      0|        }
  698|       |        
  699|    341|        pj_sockaddr_set_port(&def_addr, port);
  700|       |        
  701|       |        /* Enum all IP interfaces in the host */
  702|    341|        pj_enum_ip_option_default(&enum_opt);
  703|    341|        enum_opt.af = stun_sock->af;
  704|    341|        enum_opt.omit_deprecated_ipv6 = PJ_TRUE;
  705|    341|        info->alias_cnt = PJ_ARRAY_SIZE(info->aliases);
  ------------------
  |  |  315|    341|#define PJ_ARRAY_SIZE(a)    (sizeof(a)/sizeof(a[0]))
  ------------------
  706|    341|        status = pj_enum_ip_interface2(&enum_opt, &info->alias_cnt, 
  707|    341|                                       info->aliases);
  708|    341|        if (status == PJ_ENOTSUP) {
  ------------------
  |  |  433|    341|#define PJ_ENOTSUP          (PJ_ERRNO_START_STATUS + 12)/* 70012 */
  |  |  ------------------
  |  |  |  |  521|    341|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|    341|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|    341|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (708:13): [True: 0, False: 341]
  ------------------
  709|       |            /* Try again without omitting deprecated IPv6 addresses */
  710|      0|            enum_opt.omit_deprecated_ipv6 = PJ_FALSE;
  711|      0|            status = pj_enum_ip_interface2(&enum_opt, &info->alias_cnt, 
  712|      0|                                           info->aliases);
  713|      0|        }
  714|       |
  715|    341|        if (status != PJ_SUCCESS) {
  ------------------
  |  Branch (715:13): [True: 0, False: 341]
  ------------------
  716|       |            /* If enumeration fails, just return the default address */
  717|      0|            PJ_PERROR(4,(stun_sock->obj_name, status,
  ------------------
  |  |  189|      0|#define PJ_PERROR(level,arg)    do { \
  |  |  190|      0|                                    pj_perror_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  611|      0|    #define pj_perror_wrapper_4(arg)    pj_perror_4 arg
  |  |  ------------------
  |  |  191|      0|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (191:42): [Folded, False: 0]
  |  |  ------------------
  ------------------
  718|      0|                         "Failed in enumerating interfaces for STUN info, "
  719|      0|                         "returning default address only"));
  720|      0|            info->alias_cnt = 1;
  721|      0|            pj_sockaddr_cp(&info->aliases[0], &def_addr);
  722|      0|        }
  723|       |
  724|       |        /* Set the port number for each address.
  725|       |         */
  726|    682|        for (i=0; i<info->alias_cnt; ++i) {
  ------------------
  |  Branch (726:19): [True: 341, False: 341]
  ------------------
  727|    341|            pj_sockaddr_set_port(&info->aliases[i], port);
  728|    341|        }
  729|       |
  730|       |        /* Put the default IP in the first slot */
  731|    341|        for (i=0; i<info->alias_cnt; ++i) {
  ------------------
  |  Branch (731:19): [True: 341, False: 0]
  ------------------
  732|    341|            if (pj_sockaddr_cmp(&info->aliases[i], &def_addr)==0) {
  ------------------
  |  Branch (732:17): [True: 341, False: 0]
  ------------------
  733|    341|                if (i!=0) {
  ------------------
  |  Branch (733:21): [True: 0, False: 341]
  ------------------
  734|      0|                    pj_sockaddr_cp(&info->aliases[i], &info->aliases[0]);
  735|      0|                    pj_sockaddr_cp(&info->aliases[0], &def_addr);
  736|      0|                }
  737|    341|                break;
  738|    341|            }
  739|    341|        }
  740|    341|    }
  741|       |
  742|    341|    pj_grp_lock_release(stun_sock->grp_lock);
  743|    341|    return PJ_SUCCESS;
  744|    341|}
stun_sock.c:pj_stun_sock_cfg_is_valid:
  158|    341|{
  159|    341|    return cfg->max_pkt_size > 1 && cfg->async_cnt >= 1;
  ------------------
  |  Branch (159:12): [True: 341, False: 0]
  |  Branch (159:37): [True: 341, False: 0]
  ------------------
  160|    341|}
stun_sock.c:stun_sock_destructor:
  484|    341|{
  485|    341|    pj_stun_sock *stun_sock = (pj_stun_sock*)obj;
  486|       |
  487|    341|    if (stun_sock->q) {
  ------------------
  |  Branch (487:9): [True: 0, False: 341]
  ------------------
  488|      0|        pj_dns_srv_cancel_query(stun_sock->q, PJ_FALSE);
  489|      0|        stun_sock->q = NULL;
  490|      0|    }
  491|       |
  492|       |    /*
  493|       |    if (stun_sock->stun_sess) {
  494|       |        pj_stun_session_destroy(stun_sock->stun_sess);
  495|       |        stun_sock->stun_sess = NULL;
  496|       |    }
  497|       |    */
  498|       |
  499|    341|    pj_pool_safe_release(&stun_sock->pool);
  500|       |
  501|    341|    TRACE_(("", "STUN sock %p destroyed", stun_sock));
  ------------------
  |  |   35|    341|#  define TRACE_(x)     PJ_LOG(5,x)
  |  |  ------------------
  |  |  |  |  106|    341|#define PJ_LOG(level,arg)       do { \
  |  |  |  |  107|    341|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |  417|    682|#  define PJ_LOG_MAX_LEVEL   5
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (107:41): [True: 341, Folded]
  |  |  |  |  |  Branch (107:70): [True: 0, False: 341]
  |  |  |  |  ------------------
  |  |  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  496|      0|    #define pj_log_wrapper_5(arg)       pj_log_5 arg
  |  |  |  |  ------------------
  |  |  |  |  109|      0|                                    } \
  |  |  |  |  110|    341|                                } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (110:42): [Folded, False: 341]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  502|       |
  503|    341|}

pj_turn_alloc_param_default:
  214|  1.23k|{
  215|  1.23k|    pj_bzero(prm, sizeof(*prm));
  216|  1.23k|    prm->peer_conn_type = PJ_TURN_TP_UDP;
  217|  1.23k|}
pj_turn_session_create:
  250|    896|{
  251|    896|    pj_pool_t *pool;
  252|    896|    pj_turn_session *sess;
  253|    896|    pj_stun_session_cb stun_cb;
  254|    896|    pj_status_t status;
  255|       |
  256|    896|    PJ_ASSERT_RETURN(cfg && cfg->pf && cb && p_sess, PJ_EINVAL);
  ------------------
  |  |   97|    896|            do { \
  |  |   98|  5.37k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 896, False: 0]
  |  |  |  Branch (98:23): [True: 896, False: 0]
  |  |  |  Branch (98:23): [True: 896, False: 0]
  |  |  |  Branch (98:23): [True: 896, False: 0]
  |  |  ------------------
  |  |   99|    896|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 896]
  |  |  ------------------
  ------------------
  |  Branch (256:5): [True: 0, False: 0]
  |  Branch (256:5): [True: 0, False: 0]
  |  Branch (256:5): [True: 0, False: 0]
  |  Branch (256:5): [True: 0, False: 0]
  |  Branch (256:5): [True: 0, False: 0]
  |  Branch (256:5): [True: 0, False: 0]
  |  Branch (256:5): [True: 0, False: 0]
  |  Branch (256:5): [True: 0, False: 0]
  ------------------
  257|    896|    PJ_ASSERT_RETURN(cb->on_send_pkt, PJ_EINVAL);
  ------------------
  |  |   97|    896|            do { \
  |  |   98|    896|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 896]
  |  |  ------------------
  |  |   99|    896|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 896]
  |  |  ------------------
  ------------------
  |  Branch (257:5): [True: 0, False: 0]
  |  Branch (257:5): [True: 0, False: 0]
  ------------------
  258|       |
  259|    896|    PJ_UNUSED_ARG(options);
  ------------------
  |  | 1537|    896|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
  260|       |
  261|    896|    if (name == NULL)
  ------------------
  |  Branch (261:9): [True: 0, False: 896]
  ------------------
  262|      0|        name = "turn%p";
  263|       |
  264|       |    /* Allocate and create TURN session */
  265|    896|    pool = pj_pool_create(cfg->pf, name, PJNATH_POOL_LEN_TURN_SESS,
  ------------------
  |  |  578|    896|#   define PJNATH_POOL_LEN_TURN_SESS                1000
  ------------------
  266|    896|                          PJNATH_POOL_INC_TURN_SESS, NULL);
  ------------------
  |  |  583|    896|#   define PJNATH_POOL_INC_TURN_SESS                1000
  ------------------
  267|    896|    sess = PJ_POOL_ZALLOC_T(pool, pj_turn_session);
  ------------------
  |  |  583|    896|            ((type*)pj_pool_zalloc(pool, sizeof(type)))
  ------------------
  268|    896|    sess->pool = pool;
  269|    896|    sess->obj_name = pool->obj_name;
  270|    896|    sess->timer_heap = cfg->timer_heap;
  271|    896|    sess->af = (pj_uint16_t)af;
  272|    896|    sess->conn_type = conn_type;
  273|    896|    sess->ka_interval = PJ_TURN_KEEP_ALIVE_SEC;
  ------------------
  |  |  219|    896|#   define PJ_TURN_KEEP_ALIVE_SEC                   15
  ------------------
  274|    896|    sess->user_data = user_data;
  275|    896|    sess->next_ch = PJ_TURN_CHANNEL_MIN;
  ------------------
  |  |   33|    896|#define PJ_TURN_CHANNEL_MIN         0x4000
  ------------------
  276|    896|    pj_turn_alloc_param_default(&sess->alloc_param);
  277|       |
  278|       |    /* Copy STUN session */
  279|    896|    pj_memcpy(&sess->stun_cfg, cfg, sizeof(pj_stun_config));
  280|       |
  281|       |    /* Copy callback */
  282|    896|    pj_memcpy(&sess->cb, cb, sizeof(*cb));
  283|       |
  284|       |    /* Peer hash table */
  285|    896|    sess->ch_table = pj_hash_create(pool, PJ_TURN_CHANNEL_HTABLE_SIZE);
  ------------------
  |  |   35|    896|#define PJ_TURN_CHANNEL_HTABLE_SIZE 8
  ------------------
  286|       |
  287|       |    /* Permission hash table */
  288|    896|    sess->perm_table = pj_hash_create(pool, PJ_TURN_PERM_HTABLE_SIZE);
  ------------------
  |  |   36|    896|#define PJ_TURN_PERM_HTABLE_SIZE    8
  ------------------
  289|       |
  290|       |    /* Session lock */
  291|    896|    if (grp_lock) {
  ------------------
  |  Branch (291:9): [True: 0, False: 896]
  ------------------
  292|      0|        sess->grp_lock = grp_lock;
  293|    896|    } else {
  294|    896|        status = pj_grp_lock_create(pool, NULL, &sess->grp_lock);
  295|    896|        if (status != PJ_SUCCESS) {
  ------------------
  |  Branch (295:13): [True: 0, False: 896]
  ------------------
  296|      0|            pj_pool_release(pool);
  297|      0|            return status;
  298|      0|        }
  299|    896|    }
  300|       |
  301|    896|    pj_grp_lock_add_ref(sess->grp_lock);
  302|    896|    pj_grp_lock_add_handler(sess->grp_lock, pool, sess,
  303|    896|                            &turn_sess_on_destroy);
  304|       |
  305|       |    /* Timer */
  306|    896|    pj_timer_entry_init(&sess->timer, TIMER_NONE, sess, &on_timer_event);
  307|       |
  308|       |    /* Create STUN session */
  309|    896|    pj_bzero(&stun_cb, sizeof(stun_cb));
  310|    896|    stun_cb.on_send_msg = &stun_on_send_msg;
  311|    896|    stun_cb.on_request_complete = &stun_on_request_complete;
  312|    896|    stun_cb.on_rx_indication = &stun_on_rx_indication;
  313|    896|    status = pj_stun_session_create(&sess->stun_cfg, sess->obj_name, &stun_cb,
  314|    896|                                    PJ_FALSE, sess->grp_lock, &sess->stun);
  315|    896|    if (status != PJ_SUCCESS) {
  ------------------
  |  Branch (315:9): [True: 0, False: 896]
  ------------------
  316|      0|        do_destroy(sess);
  317|      0|        return status;
  318|      0|    }
  319|       |
  320|       |    /* Attach ourself to STUN session */
  321|    896|    pj_stun_session_set_user_data(sess->stun, sess);
  322|       |
  323|       |    /* Done */
  324|       |
  325|    896|    PJ_LOG(4,(sess->obj_name, "TURN client session created"));
  ------------------
  |  |  106|    896|#define PJ_LOG(level,arg)       do { \
  |  |  107|    896|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|  1.79k|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 896, Folded]
  |  |  |  Branch (107:70): [True: 0, False: 896]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  480|      0|    #define pj_log_wrapper_4(arg)       pj_log_4 arg
  |  |  ------------------
  |  |  109|      0|                                    } \
  |  |  110|    896|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 896]
  |  |  ------------------
  ------------------
  326|       |
  327|    896|    *p_sess = sess;
  328|    896|    return PJ_SUCCESS;
  329|    896|}
pj_turn_session_destroy:
  479|    896|{
  480|    896|    PJ_ASSERT_RETURN(sess, PJ_EINVAL);
  ------------------
  |  |   97|    896|            do { \
  |  |   98|    896|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 896]
  |  |  ------------------
  |  |   99|    896|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 896]
  |  |  ------------------
  ------------------
  |  Branch (480:5): [True: 0, False: 0]
  |  Branch (480:5): [True: 0, False: 0]
  ------------------
  481|       |
  482|    896|    if (last_err != PJ_SUCCESS && sess->last_status == PJ_SUCCESS)
  ------------------
  |  Branch (482:9): [True: 0, False: 896]
  |  Branch (482:35): [True: 0, False: 0]
  ------------------
  483|      0|        sess->last_status = last_err;
  484|    896|    set_state(sess, PJ_TURN_STATE_DEALLOCATED);
  485|    896|    sess_shutdown(sess, PJ_SUCCESS);
  486|    896|    return PJ_SUCCESS;
  487|    896|}
pj_turn_session_set_server:
  585|    896|{
  586|    896|    pj_sockaddr tmp_addr;
  587|    896|    pj_bool_t is_ip_addr;
  588|    896|    pj_status_t status;
  589|       |
  590|    896|    PJ_ASSERT_RETURN(sess && domain, PJ_EINVAL);
  ------------------
  |  |   97|    896|            do { \
  |  |   98|  1.79k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 896, False: 0]
  |  |  |  Branch (98:23): [True: 896, False: 0]
  |  |  ------------------
  |  |   99|    896|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 896]
  |  |  ------------------
  ------------------
  |  Branch (590:5): [True: 0, False: 0]
  |  Branch (590:5): [True: 0, False: 0]
  |  Branch (590:5): [True: 0, False: 0]
  |  Branch (590:5): [True: 0, False: 0]
  ------------------
  591|    896|    PJ_ASSERT_RETURN(sess->state == PJ_TURN_STATE_NULL, PJ_EINVALIDOP);
  ------------------
  |  |   97|    896|            do { \
  |  |   98|    896|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 896]
  |  |  ------------------
  |  |   99|    896|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 896]
  |  |  ------------------
  ------------------
  |  Branch (591:5): [True: 0, False: 0]
  |  Branch (591:5): [True: 0, False: 0]
  ------------------
  592|       |
  593|    896|    pj_grp_lock_acquire(sess->grp_lock);
  594|       |
  595|       |    /* See if "domain" contains just IP address */
  596|    896|    tmp_addr.addr.sa_family = sess->af;
  597|    896|    status = pj_inet_pton(sess->af, domain, 
  598|    896|                          pj_sockaddr_get_addr(&tmp_addr));
  599|    896|    is_ip_addr = (status == PJ_SUCCESS);
  600|       |
  601|    896|    if (!is_ip_addr && resolver) {
  ------------------
  |  Branch (601:9): [True: 0, False: 896]
  |  Branch (601:24): [True: 0, False: 0]
  ------------------
  602|       |        /* Resolve with DNS SRV resolution, and fallback to DNS A resolution
  603|       |         * if default_port is specified.
  604|       |         */
  605|      0|        unsigned opt = 0;
  606|      0|        pj_str_t res_name;
  607|       |
  608|      0|        switch (sess->conn_type) {
  609|      0|        case PJ_TURN_TP_UDP:
  ------------------
  |  Branch (609:9): [True: 0, False: 0]
  ------------------
  610|      0|            res_name = pj_str("_turn._udp.");
  611|      0|            break;
  612|      0|        case PJ_TURN_TP_TCP:
  ------------------
  |  Branch (612:9): [True: 0, False: 0]
  ------------------
  613|      0|            res_name = pj_str("_turn._tcp.");
  614|      0|            break;
  615|      0|        case PJ_TURN_TP_TLS:
  ------------------
  |  Branch (615:9): [True: 0, False: 0]
  ------------------
  616|      0|            res_name = pj_str("_turns._tcp.");
  617|      0|            break;
  618|      0|        default:
  ------------------
  |  Branch (618:9): [True: 0, False: 0]
  ------------------
  619|      0|            status = PJNATH_ETURNINTP;
  ------------------
  |  |  217|      0|#define PJNATH_ETURNINTP            (PJNATH_ERRNO_START+120) /* 370120 */
  |  |  ------------------
  |  |  |  |   40|      0|#define PJNATH_ERRNO_START    (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*4)
  |  |  |  |  ------------------
  |  |  |  |  |  |  535|      0|#define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  528|      0|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define PJNATH_ERRNO_START    (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*4)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  620|      0|            goto on_return;
  621|      0|        }
  622|       |
  623|       |        /* Init DNS resolution option for IPv6 */
  624|      0|        if (sess->af == pj_AF_INET6())
  ------------------
  |  |  115|      0|#   define pj_AF_INET6()    PJ_AF_INET6
  ------------------
  |  Branch (624:13): [True: 0, False: 0]
  ------------------
  625|      0|            opt |= PJ_DNS_SRV_RESOLVE_AAAA_ONLY;
  626|       |
  627|       |        /* Fallback to DNS A only if default port is specified */
  628|      0|        if (default_port>0 && default_port<65536) {
  ------------------
  |  Branch (628:13): [True: 0, False: 0]
  |  Branch (628:31): [True: 0, False: 0]
  ------------------
  629|      0|            if (sess->af == pj_AF_INET6())
  ------------------
  |  |  115|      0|#   define pj_AF_INET6()    PJ_AF_INET6
  ------------------
  |  Branch (629:17): [True: 0, False: 0]
  ------------------
  630|      0|                opt |= PJ_DNS_SRV_FALLBACK_AAAA;
  631|      0|            else
  632|      0|                opt |= PJ_DNS_SRV_FALLBACK_A;
  633|      0|            sess->default_port = (pj_uint16_t)default_port;
  634|      0|        }
  635|       |
  636|      0|        PJ_LOG(5,(sess->obj_name, "Resolving %.*s%.*s with DNS SRV",
  ------------------
  |  |  106|      0|#define PJ_LOG(level,arg)       do { \
  |  |  107|      0|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|      0|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 0, Folded]
  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  496|      0|    #define pj_log_wrapper_5(arg)       pj_log_5 arg
  |  |  ------------------
  |  |  109|      0|                                    } \
  |  |  110|      0|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 0]
  |  |  ------------------
  ------------------
  637|      0|                  (int)res_name.slen, res_name.ptr,
  638|      0|                  (int)domain->slen, domain->ptr));
  639|      0|        set_state(sess, PJ_TURN_STATE_RESOLVING);
  640|       |
  641|       |        /* User may have destroyed us in the callback */
  642|      0|        if (sess->state != PJ_TURN_STATE_RESOLVING) {
  ------------------
  |  Branch (642:13): [True: 0, False: 0]
  ------------------
  643|      0|            status = PJ_ECANCELLED;
  ------------------
  |  |  443|      0|#define PJ_ECANCELLED       (PJ_ERRNO_START_STATUS + 14)/* 70014 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  644|      0|            goto on_return;
  645|      0|        }
  646|       |
  647|       |        /* Add reference before async DNS resolution */
  648|      0|        pj_grp_lock_add_ref(sess->grp_lock);
  649|       |
  650|      0|        status = pj_dns_srv_resolve(domain, &res_name, default_port, 
  651|      0|                                    sess->pool, resolver, opt, sess, 
  652|      0|                                    &dns_srv_resolver_cb, NULL);
  653|      0|        if (status != PJ_SUCCESS) {
  ------------------
  |  Branch (653:13): [True: 0, False: 0]
  ------------------
  654|      0|            set_state(sess, PJ_TURN_STATE_NULL);
  655|      0|            pj_grp_lock_dec_ref(sess->grp_lock);
  656|      0|            goto on_return;
  657|      0|        }
  658|       |
  659|    896|    } else {
  660|       |        /* Resolver is not specified, resolve with standard gethostbyname().
  661|       |         * The default_port MUST be specified in this case.
  662|       |         */
  663|    896|        pj_addrinfo *ai;
  664|    896|        unsigned i, cnt;
  665|       |
  666|       |        /* Default port must be specified */
  667|  1.79k|        PJ_ASSERT_ON_FAIL(default_port>0 && default_port<65536, 
  ------------------
  |  |  111|    896|            { \
  |  |  112|    896|                pj_assert(expr); \
  |  |  ------------------
  |  |  |  |   65|    896|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  113|  1.79k|                if (!(expr)) exec_on_fail; \
  |  |  ------------------
  |  |  |  Branch (113:23): [True: 896, False: 0]
  |  |  |  Branch (113:23): [True: 896, False: 0]
  |  |  ------------------
  |  |  114|    896|            }
  ------------------
  |  Branch (667:9): [True: 0, False: 896]
  |  Branch (667:9): [True: 0, False: 0]
  |  Branch (667:9): [True: 896, False: 0]
  |  Branch (667:9): [True: 896, False: 0]
  ------------------
  668|  1.79k|                            {status=PJ_EINVAL; goto on_return;});
  669|       |        
  670|  1.79k|        sess->default_port = (pj_uint16_t)default_port;
  671|       |
  672|  1.79k|        cnt = PJ_TURN_MAX_DNS_SRV_CNT;
  ------------------
  |  |  173|    896|#   define PJ_TURN_MAX_DNS_SRV_CNT                  4
  ------------------
  673|  1.79k|        ai = (pj_addrinfo*)
  674|  1.79k|             pj_pool_calloc(sess->pool, cnt, sizeof(pj_addrinfo));
  675|       |
  676|  1.79k|        PJ_LOG(5,(sess->obj_name, "Resolving %.*s with DNS A",
  ------------------
  |  |  106|    896|#define PJ_LOG(level,arg)       do { \
  |  |  107|    896|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|  1.79k|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 896, Folded]
  |  |  |  Branch (107:70): [True: 0, False: 896]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  496|      0|    #define pj_log_wrapper_5(arg)       pj_log_5 arg
  |  |  ------------------
  |  |  109|      0|                                    } \
  |  |  110|    896|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 896]
  |  |  ------------------
  ------------------
  677|  1.79k|                  (int)domain->slen, domain->ptr));
  678|  1.79k|        set_state(sess, PJ_TURN_STATE_RESOLVING);
  679|       |
  680|       |        /* User may have destroyed us in the callback */
  681|  1.79k|        if (sess->state != PJ_TURN_STATE_RESOLVING) {
  ------------------
  |  Branch (681:13): [True: 0, False: 896]
  ------------------
  682|      0|            status = PJ_ECANCELLED;
  ------------------
  |  |  443|      0|#define PJ_ECANCELLED       (PJ_ERRNO_START_STATUS + 14)/* 70014 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  683|      0|            goto on_return;
  684|      0|        }
  685|       |
  686|    896|        status = pj_getaddrinfo(sess->af, domain, &cnt, ai);
  687|    896|        if (status != PJ_SUCCESS)
  ------------------
  |  Branch (687:13): [True: 0, False: 896]
  ------------------
  688|      0|            goto on_return;
  689|       |
  690|    896|        sess->srv_addr_cnt = (pj_uint16_t)cnt;
  691|    896|        sess->srv_addr_list = (pj_sockaddr*)
  692|    896|                              pj_pool_calloc(sess->pool, cnt, 
  693|    896|                                             sizeof(pj_sockaddr));
  694|  1.79k|        for (i=0; i<cnt; ++i) {
  ------------------
  |  Branch (694:19): [True: 896, False: 896]
  ------------------
  695|    896|            pj_sockaddr *addr = &sess->srv_addr_list[i];
  696|    896|            pj_memcpy(addr, &ai[i].ai_addr, sizeof(pj_sockaddr));
  697|    896|            addr->addr.sa_family = sess->af;
  698|    896|            pj_sockaddr_set_port(addr, sess->default_port);
  699|    896|        }
  700|       |
  701|    896|        sess->srv_addr = &sess->srv_addr_list[0];
  702|    896|        set_state(sess, PJ_TURN_STATE_RESOLVED);
  703|    896|    }
  704|       |
  705|    896|on_return:
  706|    896|    pj_grp_lock_release(sess->grp_lock);
  707|    896|    return status;
  708|    896|}
pj_turn_session_set_credential:
  716|    896|{
  717|    896|    PJ_ASSERT_RETURN(sess && cred, PJ_EINVAL);
  ------------------
  |  |   97|    896|            do { \
  |  |   98|  1.79k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 896, False: 0]
  |  |  |  Branch (98:23): [True: 896, False: 0]
  |  |  ------------------
  |  |   99|    896|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 896]
  |  |  ------------------
  ------------------
  |  Branch (717:5): [True: 0, False: 0]
  |  Branch (717:5): [True: 0, False: 0]
  |  Branch (717:5): [True: 0, False: 0]
  |  Branch (717:5): [True: 0, False: 0]
  ------------------
  718|    896|    PJ_ASSERT_RETURN(sess->stun, PJ_EINVALIDOP);
  ------------------
  |  |   97|    896|            do { \
  |  |   98|    896|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 896]
  |  |  ------------------
  |  |   99|    896|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 896]
  |  |  ------------------
  ------------------
  |  Branch (718:5): [True: 0, False: 0]
  |  Branch (718:5): [True: 0, False: 0]
  ------------------
  719|       |
  720|    896|    pj_grp_lock_acquire(sess->grp_lock);
  721|       |
  722|    896|    pj_stun_session_set_credential(sess->stun, PJ_STUN_AUTH_LONG_TERM, cred);
  723|       |
  724|    896|    pj_grp_lock_release(sess->grp_lock);
  725|       |
  726|    896|    return PJ_SUCCESS;
  727|    896|}
pj_turn_session_sendto:
  993|    896|{
  994|    896|    struct ch_t *ch;
  995|    896|    struct perm_t *perm;
  996|    896|    pj_status_t status;
  997|       |
  998|    896|    PJ_ASSERT_RETURN(sess && pkt && pkt_len && addr && addr_len, 
  ------------------
  |  |   97|    896|            do { \
  |  |   98|  7.16k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 896, False: 0]
  |  |  |  Branch (98:23): [True: 896, False: 0]
  |  |  |  Branch (98:23): [True: 896, False: 0]
  |  |  |  Branch (98:23): [True: 896, False: 0]
  |  |  |  Branch (98:23): [True: 896, False: 0]
  |  |  ------------------
  |  |   99|    896|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 896]
  |  |  ------------------
  ------------------
  |  Branch (998:5): [True: 0, False: 0]
  |  Branch (998:5): [True: 0, False: 0]
  |  Branch (998:5): [True: 0, False: 0]
  |  Branch (998:5): [True: 0, False: 0]
  |  Branch (998:5): [True: 0, False: 0]
  |  Branch (998:5): [True: 0, False: 0]
  |  Branch (998:5): [True: 0, False: 0]
  |  Branch (998:5): [True: 0, False: 0]
  |  Branch (998:5): [True: 0, False: 0]
  |  Branch (998:5): [True: 0, False: 0]
  ------------------
  999|    896|                     PJ_EINVAL);
 1000|       |
 1001|       |    /* Return error if we're not ready */
 1002|    896|    if (sess->state != PJ_TURN_STATE_READY) {
  ------------------
  |  Branch (1002:9): [True: 896, False: 0]
  ------------------
 1003|    896|        return PJ_EIGNORED;
  ------------------
  |  |  474|    896|#define PJ_EIGNORED         (PJ_ERRNO_START_STATUS + 20)/* 70020 */
  |  |  ------------------
  |  |  |  |  521|    896|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|    896|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|    896|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1004|    896|    }
 1005|       |
 1006|       |    /* Lock session now */
 1007|      0|    pj_grp_lock_acquire(sess->grp_lock);
 1008|       |
 1009|       |    /* Lookup permission first */
 1010|      0|    perm = lookup_perm(sess, addr, pj_sockaddr_get_len(addr), PJ_FALSE);
 1011|      0|    if (perm == NULL) {
  ------------------
  |  Branch (1011:9): [True: 0, False: 0]
  ------------------
 1012|       |        /* Permission doesn't exist, install it first */
 1013|      0|        char ipstr[PJ_INET6_ADDRSTRLEN+2];
 1014|       |
 1015|      0|        PJ_LOG(4,(sess->obj_name, 
  ------------------
  |  |  106|      0|#define PJ_LOG(level,arg)       do { \
  |  |  107|      0|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|      0|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 0, Folded]
  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  480|      0|    #define pj_log_wrapper_4(arg)       pj_log_4 arg
  |  |  ------------------
  |  |  109|      0|                                    } \
  |  |  110|      0|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1016|      0|                  "sendto(): IP %s has no permission, requesting it first..",
 1017|      0|                  pj_sockaddr_print(addr, ipstr, sizeof(ipstr), 2)));
 1018|       |
 1019|      0|        status = pj_turn_session_set_perm(sess, 1, (const pj_sockaddr*)addr, 
 1020|      0|                                          0);
 1021|      0|        if (status != PJ_SUCCESS) {
  ------------------
  |  Branch (1021:13): [True: 0, False: 0]
  ------------------
 1022|      0|            pj_grp_lock_release(sess->grp_lock);
 1023|      0|            return status;
 1024|      0|        }
 1025|      0|    }
 1026|       |
 1027|       |    /* If peer connection is TCP (RFC 6062), send it directly */
 1028|      0|    if (sess->alloc_param.peer_conn_type == PJ_TURN_TP_TCP) {
  ------------------
  |  Branch (1028:9): [True: 0, False: 0]
  ------------------
 1029|      0|        status = sess->cb.on_send_pkt(sess, pkt, pkt_len, addr, addr_len);
 1030|      0|        goto on_return;
 1031|      0|    }
 1032|       |
 1033|       |    /* See if the peer is bound to a channel number */
 1034|      0|    ch = lookup_ch_by_addr(sess, addr, pj_sockaddr_get_len(addr), 
 1035|      0|                           PJ_FALSE, PJ_FALSE);
 1036|      0|    if (ch && ch->num != PJ_TURN_INVALID_CHANNEL && ch->bound) {
  ------------------
  |  |   41|      0|#define PJ_TURN_INVALID_CHANNEL     0xFFFF
  ------------------
  |  Branch (1036:9): [True: 0, False: 0]
  |  Branch (1036:15): [True: 0, False: 0]
  |  Branch (1036:53): [True: 0, False: 0]
  ------------------
 1037|      0|        unsigned total_len;
 1038|       |
 1039|       |        /* Peer is assigned a channel number, we can use ChannelData */
 1040|      0|        pj_turn_channel_data *cd = (pj_turn_channel_data*)sess->tx_pkt;
 1041|       |        
 1042|      0|        pj_assert(sizeof(*cd)==4);
  ------------------
  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (1042:9): [True: 0, Folded]
  |  Branch (1042:9): [True: 0, Folded]
  ------------------
 1043|       |
 1044|       |        /* Calculate total length, including paddings */
 1045|      0|        total_len = (pkt_len + sizeof(*cd) + 3) & (~3);
 1046|      0|        if (total_len > sizeof(sess->tx_pkt)) {
  ------------------
  |  Branch (1046:13): [True: 0, False: 0]
  ------------------
 1047|      0|            status = PJ_ETOOBIG;
  ------------------
  |  |  458|      0|#define PJ_ETOOBIG          (PJ_ERRNO_START_STATUS + 17)/* 70017 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1048|      0|            goto on_return;
 1049|      0|        }
 1050|       |
 1051|      0|        cd->ch_number = pj_htons((pj_uint16_t)ch->num);
 1052|      0|        cd->length = pj_htons((pj_uint16_t)pkt_len);
 1053|      0|        pj_memcpy(cd+1, pkt, pkt_len);
 1054|       |        /* Add zero padding, if data is not 4-bytes aligned. */
 1055|      0|        if (pkt_len & 0x03) {
  ------------------
  |  Branch (1055:13): [True: 0, False: 0]
  ------------------
 1056|      0|            pj_bzero(((pj_uint8_t *)(cd+1)) + pkt_len, 4 - (pkt_len & 0x03));
 1057|      0|        }
 1058|       |
 1059|      0|        pj_assert(sess->srv_addr != NULL);
  ------------------
  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (1059:9): [True: 0, False: 0]
  |  Branch (1059:9): [True: 0, False: 0]
  ------------------
 1060|       |
 1061|      0|        status = sess->cb.on_send_pkt(sess, sess->tx_pkt, total_len,
 1062|      0|                                      sess->srv_addr,
 1063|      0|                                      pj_sockaddr_get_len(sess->srv_addr));
 1064|       |
 1065|      0|    } else {
 1066|       |        /* Use Send Indication. */
 1067|      0|        pj_stun_sockaddr_attr peer_attr;
 1068|      0|        pj_stun_binary_attr data_attr;
 1069|      0|        pj_stun_msg send_ind;
 1070|      0|        pj_size_t send_ind_len;
 1071|       |
 1072|       |        /* Increment counter */
 1073|      0|        ++sess->send_ind_tsx_id[2];
 1074|       |
 1075|       |        /* Create blank SEND-INDICATION */
 1076|      0|        status = pj_stun_msg_init(&send_ind, PJ_STUN_SEND_INDICATION,
 1077|      0|                                  PJ_STUN_MAGIC, 
  ------------------
  |  |   46|      0|#define PJ_STUN_MAGIC                       0x2112A442
  ------------------
 1078|      0|                                  (const pj_uint8_t*)sess->send_ind_tsx_id);
 1079|      0|        if (status != PJ_SUCCESS)
  ------------------
  |  Branch (1079:13): [True: 0, False: 0]
  ------------------
 1080|      0|            goto on_return;
 1081|       |
 1082|       |        /* Add XOR-PEER-ADDRESS */
 1083|      0|        pj_stun_sockaddr_attr_init(&peer_attr, PJ_STUN_ATTR_XOR_PEER_ADDR,
 1084|      0|                                   PJ_TRUE, addr, addr_len);
 1085|      0|        pj_stun_msg_add_attr(&send_ind, (pj_stun_attr_hdr*)&peer_attr);
 1086|       |
 1087|       |        /* Add DATA attribute */
 1088|      0|        pj_stun_binary_attr_init(&data_attr, NULL, PJ_STUN_ATTR_DATA, NULL, 0);
 1089|      0|        data_attr.data = (pj_uint8_t*)pkt;
 1090|      0|        data_attr.length = pkt_len;
 1091|      0|        pj_stun_msg_add_attr(&send_ind, (pj_stun_attr_hdr*)&data_attr);
 1092|       |
 1093|       |        /* Encode the message */
 1094|      0|        status = pj_stun_msg_encode(&send_ind, sess->tx_pkt, 
 1095|      0|                                    sizeof(sess->tx_pkt), 0,
 1096|      0|                                    NULL, &send_ind_len);
 1097|      0|        if (status != PJ_SUCCESS)
  ------------------
  |  Branch (1097:13): [True: 0, False: 0]
  ------------------
 1098|      0|            goto on_return;
 1099|       |
 1100|       |        /* Send the Send Indication */
 1101|      0|        status = sess->cb.on_send_pkt(sess, sess->tx_pkt, 
 1102|      0|                                      (unsigned)send_ind_len,
 1103|      0|                                      sess->srv_addr,
 1104|      0|                                      pj_sockaddr_get_len(sess->srv_addr));
 1105|      0|    }
 1106|       |
 1107|      0|on_return:
 1108|      0|    pj_grp_lock_release(sess->grp_lock);
 1109|      0|    return status;
 1110|      0|}
pj_turn_session_on_rx_pkt2:
 1283|    663|{
 1284|    663|    pj_bool_t is_stun;
 1285|    663|    pj_status_t status;
 1286|    663|    pj_bool_t is_datagram;
 1287|       |
 1288|       |    /* Packet could be ChannelData or STUN message (response or
 1289|       |     * indication).
 1290|       |     */
 1291|       |
 1292|       |    /* Start locking the session */
 1293|    663|    pj_grp_lock_acquire(sess->grp_lock);
 1294|       |
 1295|    663|    is_datagram = (sess->conn_type==PJ_TURN_TP_UDP);
 1296|       |
 1297|       |    /* Quickly check if this is STUN message */
 1298|    663|    is_stun = ((((pj_uint8_t*)prm->pkt)[0] & 0xC0) == 0);
 1299|       |
 1300|    663|    if (is_stun) {
  ------------------
  |  Branch (1300:9): [True: 624, False: 39]
  ------------------
 1301|       |        /* This looks like STUN, give it to the STUN session */
 1302|    624|        unsigned options;
 1303|    624|        const pj_sockaddr_t *src_addr = prm->src_addr?
  ------------------
  |  Branch (1303:41): [True: 624, False: 0]
  ------------------
 1304|    624|                                        prm->src_addr:sess->srv_addr;
 1305|    624|        unsigned src_addr_len = prm->src_addr_len? prm->src_addr_len:
  ------------------
  |  Branch (1305:33): [True: 624, False: 0]
  ------------------
 1306|    624|                                pj_sockaddr_get_len(sess->srv_addr);
 1307|       |
 1308|    624|        options = PJ_STUN_CHECK_PACKET | PJ_STUN_NO_FINGERPRINT_CHECK;
 1309|    624|        if (is_datagram)
  ------------------
  |  Branch (1309:13): [True: 624, False: 0]
  ------------------
 1310|    624|            options |= PJ_STUN_IS_DATAGRAM;
 1311|    624|        status=pj_stun_session_on_rx_pkt(sess->stun, prm->pkt, prm->pkt_len,
 1312|    624|                                         options, NULL, &prm->parsed_len,
 1313|    624|                                         src_addr, src_addr_len);
 1314|       |
 1315|    624|    } else {
 1316|       |        /* This must be ChannelData. */
 1317|     39|        pj_turn_channel_data cd;
 1318|     39|        struct ch_t *ch;
 1319|       |
 1320|     39|        if (prm->pkt_len < 4) {
  ------------------
  |  Branch (1320:13): [True: 0, False: 39]
  ------------------
 1321|      0|            prm->parsed_len = 0;
 1322|      0|            status = PJ_ETOOSMALL;
  ------------------
  |  |  469|      0|#define PJ_ETOOSMALL        (PJ_ERRNO_START_STATUS + 19)/* 70019 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1323|      0|            goto on_return;
 1324|      0|        }
 1325|       |
 1326|       |        /* Decode ChannelData packet */
 1327|     39|        pj_memcpy(&cd, prm->pkt, sizeof(pj_turn_channel_data));
 1328|     39|        cd.ch_number = pj_ntohs(cd.ch_number);
 1329|     39|        cd.length = pj_ntohs(cd.length);
 1330|       |
 1331|       |        /* Check that size is sane */
 1332|     39|        if (prm->pkt_len < cd.length+sizeof(cd)) {
  ------------------
  |  Branch (1332:13): [True: 20, False: 19]
  ------------------
 1333|     20|            if (is_datagram) {
  ------------------
  |  Branch (1333:17): [True: 20, False: 0]
  ------------------
 1334|       |                /* Discard the datagram */
 1335|     20|                prm->parsed_len = prm->pkt_len;
 1336|     20|            } else {
 1337|       |                /* Insufficient fragment */
 1338|      0|                prm->parsed_len = 0;
 1339|      0|            }
 1340|     20|            status = PJ_ETOOSMALL;
  ------------------
  |  |  469|     20|#define PJ_ETOOSMALL        (PJ_ERRNO_START_STATUS + 19)/* 70019 */
  |  |  ------------------
  |  |  |  |  521|     20|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|     20|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|     20|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1341|     20|            goto on_return;
 1342|     20|        } else {
 1343|       |            /* Apply padding too */
 1344|     19|            prm->parsed_len = ((cd.length + 3) & (~3)) + sizeof(cd);
 1345|     19|        }
 1346|       |
 1347|       |        /* Lookup channel */
 1348|     19|        ch = lookup_ch_by_chnum(sess, cd.ch_number);
 1349|     19|        if (!ch || !ch->bound) {
  ------------------
  |  Branch (1349:13): [True: 19, False: 0]
  |  Branch (1349:20): [True: 0, False: 0]
  ------------------
 1350|     19|            status = PJ_ENOTFOUND;
  ------------------
  |  |  403|     19|#define PJ_ENOTFOUND        (PJ_ERRNO_START_STATUS + 6) /* 70006 */
  |  |  ------------------
  |  |  |  |  521|     19|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|     19|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|     19|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1351|     19|            goto on_return;
 1352|     19|        }
 1353|       |
 1354|       |        /* Notify application */
 1355|      0|        if (sess->cb.on_rx_data) {
  ------------------
  |  Branch (1355:13): [True: 0, False: 0]
  ------------------
 1356|      0|            (*sess->cb.on_rx_data)(sess, ((pj_uint8_t*)prm->pkt)+sizeof(cd), 
 1357|      0|                                   cd.length, &ch->addr,
 1358|      0|                                   pj_sockaddr_get_len(&ch->addr));
 1359|      0|        }
 1360|       |
 1361|      0|        status = PJ_SUCCESS;
 1362|      0|    }
 1363|       |
 1364|    663|on_return:
 1365|    663|    pj_grp_lock_release(sess->grp_lock);
 1366|    663|    return status;
 1367|    663|}
turn_session.c:sess_shutdown:
  386|    896|{
  387|    896|    pj_bool_t can_destroy = PJ_TRUE;
  388|       |
  389|    896|    PJ_LOG(4,(sess->obj_name, "Request to shutdown in state %s, cause:%d",
  ------------------
  |  |  106|    896|#define PJ_LOG(level,arg)       do { \
  |  |  107|    896|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|  1.79k|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 896, Folded]
  |  |  |  Branch (107:70): [True: 0, False: 896]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  480|      0|    #define pj_log_wrapper_4(arg)       pj_log_4 arg
  |  |  ------------------
  |  |  109|      0|                                    } \
  |  |  110|    896|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 896]
  |  |  ------------------
  ------------------
  390|    896|              state_names[sess->state], status));
  391|       |
  392|    896|    if (sess->last_status == PJ_SUCCESS && status != PJ_SUCCESS)
  ------------------
  |  Branch (392:9): [True: 896, False: 0]
  |  Branch (392:44): [True: 0, False: 896]
  ------------------
  393|      0|        sess->last_status = status;
  394|       |
  395|    896|    switch (sess->state) {
  ------------------
  |  Branch (395:13): [True: 896, False: 0]
  ------------------
  396|      0|    case PJ_TURN_STATE_NULL:
  ------------------
  |  Branch (396:5): [True: 0, False: 896]
  ------------------
  397|      0|        break;
  398|      0|    case PJ_TURN_STATE_RESOLVING:
  ------------------
  |  Branch (398:5): [True: 0, False: 896]
  ------------------
  399|       |        /* Wait for DNS callback invoked, it will call the this function
  400|       |         * again. If the callback happens to get pending_destroy==FALSE,
  401|       |         * the TURN allocation will call this function again.
  402|       |         */
  403|      0|        sess->pending_destroy = PJ_TRUE;
  404|      0|        can_destroy = PJ_FALSE;
  405|      0|        break;
  406|      0|    case PJ_TURN_STATE_RESOLVED:
  ------------------
  |  Branch (406:5): [True: 0, False: 896]
  ------------------
  407|      0|        break;
  408|      0|    case PJ_TURN_STATE_ALLOCATING:
  ------------------
  |  Branch (408:5): [True: 0, False: 896]
  ------------------
  409|       |        /* We need to wait until allocation complete */
  410|      0|        sess->pending_destroy = PJ_TRUE;
  411|      0|        can_destroy = PJ_FALSE;
  412|      0|        break;
  413|      0|    case PJ_TURN_STATE_READY:
  ------------------
  |  Branch (413:5): [True: 0, False: 896]
  ------------------
  414|       |        /* Send REFRESH with LIFETIME=0 */
  415|      0|        can_destroy = PJ_FALSE;
  416|      0|        send_refresh(sess, 0);
  417|      0|        break;
  418|      0|    case PJ_TURN_STATE_DEALLOCATING:
  ------------------
  |  Branch (418:5): [True: 0, False: 896]
  ------------------
  419|      0|        can_destroy = PJ_FALSE;
  420|       |        /* This may recursively call this function again with
  421|       |         * state==PJ_TURN_STATE_DEALLOCATED.
  422|       |         */
  423|       |        /* No need to deallocate as we're already deallocating!
  424|       |         * See https://github.com/pjsip/pjproject/issues/1551
  425|       |        send_refresh(sess, 0);
  426|       |        */
  427|      0|        break;
  428|    896|    case PJ_TURN_STATE_DEALLOCATED:
  ------------------
  |  Branch (428:5): [True: 896, False: 0]
  ------------------
  429|    896|    case PJ_TURN_STATE_DESTROYING:
  ------------------
  |  Branch (429:5): [True: 0, False: 896]
  ------------------
  430|    896|        break;
  431|    896|    }
  432|       |
  433|    896|    if (can_destroy) {
  ------------------
  |  Branch (433:9): [True: 896, False: 0]
  ------------------
  434|       |        /* Schedule destroy */
  435|    896|        pj_time_val delay = {0, 0};
  436|       |
  437|    896|        set_state(sess, PJ_TURN_STATE_DESTROYING);
  438|       |
  439|    896|        pj_timer_heap_cancel_if_active(sess->timer_heap, &sess->timer,
  440|    896|                                       TIMER_NONE);
  441|    896|        pj_timer_heap_schedule_w_grp_lock(sess->timer_heap, &sess->timer,
  ------------------
  |  |  280|    896|        pj_timer_heap_schedule_w_grp_lock_dbg(ht,e,d,id,g,__FILE__,__LINE__)
  ------------------
  442|    896|                                          &delay, TIMER_DESTROY,
  443|    896|                                          sess->grp_lock);
  444|    896|    }
  445|    896|}
turn_session.c:set_state:
  366|  3.58k|{
  367|  3.58k|    pj_turn_state_t old_state = sess->state;
  368|       |
  369|  3.58k|    if (state==sess->state)
  ------------------
  |  Branch (369:9): [True: 0, False: 3.58k]
  ------------------
  370|      0|        return;
  371|       |
  372|  3.58k|    PJ_LOG(4,(sess->obj_name, "State changed %s --> %s",
  ------------------
  |  |  106|  3.58k|#define PJ_LOG(level,arg)       do { \
  |  |  107|  3.58k|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|  7.16k|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 3.58k, Folded]
  |  |  |  Branch (107:70): [True: 0, False: 3.58k]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  480|      0|    #define pj_log_wrapper_4(arg)       pj_log_4 arg
  |  |  ------------------
  |  |  109|      0|                                    } \
  |  |  110|  3.58k|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 3.58k]
  |  |  ------------------
  ------------------
  373|  3.58k|              state_names[old_state], state_names[state]));
  374|  3.58k|    sess->state = state;
  375|       |
  376|  3.58k|    if (sess->cb.on_state) {
  ------------------
  |  Branch (376:9): [True: 3.58k, False: 0]
  ------------------
  377|  3.58k|        (*sess->cb.on_state)(sess, old_state, state);
  378|  3.58k|    }
  379|  3.58k|}
turn_session.c:stun_on_send_msg:
 1379|    401|{
 1380|    401|    pj_turn_session *sess;
 1381|       |
 1382|    401|    PJ_UNUSED_ARG(token);
  ------------------
  |  | 1537|    401|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
 1383|       |
 1384|    401|    sess = (pj_turn_session*) pj_stun_session_get_user_data(stun);
 1385|    401|    if (sess->cb.on_stun_send_pkt) {
  ------------------
  |  Branch (1385:9): [True: 0, False: 401]
  ------------------
 1386|      0|        return (*sess->cb.on_stun_send_pkt)(sess, (const pj_uint8_t*)pkt,
 1387|      0|                                            (unsigned)pkt_size,
 1388|      0|                                            dst_addr, addr_len);
 1389|    401|    } else {
 1390|    401|        return (*sess->cb.on_send_pkt)(sess, (const pj_uint8_t*)pkt,
 1391|    401|                                       (unsigned)pkt_size,
 1392|    401|                                       dst_addr, addr_len);
 1393|    401|    }
 1394|    401|}
turn_session.c:stun_on_rx_indication:
 1877|     69|{
 1878|     69|    pj_turn_session *sess;
 1879|     69|    pj_stun_xor_peer_addr_attr *peer_attr;
 1880|     69|    pj_stun_icmp_attr *icmp;
 1881|     69|    pj_stun_data_attr *data_attr;
 1882|       |
 1883|     69|    PJ_UNUSED_ARG(token);
  ------------------
  |  | 1537|     69|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
 1884|     69|    PJ_UNUSED_ARG(pkt);
  ------------------
  |  | 1537|     69|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
 1885|     69|    PJ_UNUSED_ARG(pkt_len);
  ------------------
  |  | 1537|     69|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
 1886|     69|    PJ_UNUSED_ARG(src_addr);
  ------------------
  |  | 1537|     69|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
 1887|     69|    PJ_UNUSED_ARG(src_addr_len);
  ------------------
  |  | 1537|     69|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
 1888|       |
 1889|     69|    sess = (pj_turn_session*)pj_stun_session_get_user_data(stun);
 1890|       |
 1891|       |    /* ConnectionAttempt Indication */
 1892|     69|    if (msg->hdr.type == PJ_STUN_CONNECTION_ATTEMPT_INDICATION) {
  ------------------
  |  Branch (1892:9): [True: 23, False: 46]
  ------------------
 1893|     23|        pj_stun_uint_attr *connection_id_attr;
 1894|       |
 1895|       |        /* Get CONNECTION-ID attribute */
 1896|     23|        connection_id_attr = (pj_stun_uint_attr*)
 1897|     23|            pj_stun_msg_find_attr(msg, PJ_STUN_ATTR_CONNECTION_ID, 0);
 1898|       |
 1899|       |        /* Get XOR-PEER-ADDRESS attribute */
 1900|     23|        peer_attr = (pj_stun_xor_peer_addr_attr*)
 1901|     23|            pj_stun_msg_find_attr(msg, PJ_STUN_ATTR_XOR_PEER_ADDR, 0);
 1902|       |
 1903|       |        /* Must have both XOR-PEER-ADDRESS and CONNECTION-ID attributes */
 1904|     23|        if (!peer_attr || !connection_id_attr) {
  ------------------
  |  Branch (1904:13): [True: 5, False: 18]
  |  Branch (1904:27): [True: 17, False: 1]
  ------------------
 1905|     22|            PJ_LOG(4,(sess->obj_name, 
  ------------------
  |  |  106|     22|#define PJ_LOG(level,arg)       do { \
  |  |  107|     22|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|     44|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 22, Folded]
  |  |  |  Branch (107:70): [True: 0, False: 22]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  480|      0|    #define pj_log_wrapper_4(arg)       pj_log_4 arg
  |  |  ------------------
  |  |  109|      0|                                    } \
  |  |  110|     22|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 22]
  |  |  ------------------
  ------------------
 1906|     22|                      "Received ConnectionAttempt indication with missing "
 1907|     22|                      "attributes"));
 1908|     22|            return PJ_EINVALIDOP;
  ------------------
  |  |  438|     22|#define PJ_EINVALIDOP       (PJ_ERRNO_START_STATUS + 13)/* 70013 */
  |  |  ------------------
  |  |  |  |  521|     22|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|     22|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|     22|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1909|     22|        }
 1910|       |
 1911|       |        /* Notify application */
 1912|      1|        if (sess->cb.on_connection_attempt) {
  ------------------
  |  Branch (1912:13): [True: 0, False: 1]
  ------------------
 1913|      0|            (*sess->cb.on_connection_attempt)
 1914|      0|                                (sess,
 1915|      0|                                connection_id_attr->value,
 1916|      0|                                &peer_attr->sockaddr,
 1917|      0|                                pj_sockaddr_get_len(&peer_attr->sockaddr));
 1918|      0|        }
 1919|      1|        return PJ_SUCCESS;
 1920|     23|    }
 1921|       |
 1922|       |    /* Next, expecting Data Indication only */
 1923|     46|    if (msg->hdr.type != PJ_STUN_DATA_INDICATION) {
  ------------------
  |  Branch (1923:9): [True: 30, False: 16]
  ------------------
 1924|     30|        PJ_LOG(4,(sess->obj_name, "Unexpected STUN %s indication",
  ------------------
  |  |  106|     30|#define PJ_LOG(level,arg)       do { \
  |  |  107|     30|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|     60|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 30, Folded]
  |  |  |  Branch (107:70): [True: 0, False: 30]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  480|      0|    #define pj_log_wrapper_4(arg)       pj_log_4 arg
  |  |  ------------------
  |  |  109|      0|                                    } \
  |  |  110|     30|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 30]
  |  |  ------------------
  ------------------
 1925|     30|                  pj_stun_get_method_name(msg->hdr.type)));
 1926|     30|        return PJ_EINVALIDOP;
  ------------------
  |  |  438|     30|#define PJ_EINVALIDOP       (PJ_ERRNO_START_STATUS + 13)/* 70013 */
  |  |  ------------------
  |  |  |  |  521|     30|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|     30|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|     30|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1927|     30|    }
 1928|       |
 1929|       |    /* Check if there is ICMP attribute in the message */
 1930|     16|    icmp = (pj_stun_icmp_attr*)
 1931|     16|           pj_stun_msg_find_attr(msg, PJ_STUN_ATTR_ICMP, 0);
 1932|     16|    if (icmp != NULL) {
  ------------------
  |  Branch (1932:9): [True: 2, False: 14]
  ------------------
 1933|       |        /* This is a forwarded ICMP packet. Ignore it for now */
 1934|      2|        return PJ_SUCCESS;
 1935|      2|    }
 1936|       |
 1937|       |    /* Get XOR-PEER-ADDRESS attribute */
 1938|     14|    peer_attr = (pj_stun_xor_peer_addr_attr*)
 1939|     14|                pj_stun_msg_find_attr(msg, PJ_STUN_ATTR_XOR_PEER_ADDR, 0);
 1940|       |
 1941|       |    /* Get DATA attribute */
 1942|     14|    data_attr = (pj_stun_data_attr*)
 1943|     14|                pj_stun_msg_find_attr(msg, PJ_STUN_ATTR_DATA, 0);
 1944|       |
 1945|       |    /* Must have both XOR-PEER-ADDRESS and DATA attributes */
 1946|     14|    if (!peer_attr || !data_attr) {
  ------------------
  |  Branch (1946:9): [True: 9, False: 5]
  |  Branch (1946:23): [True: 3, False: 2]
  ------------------
 1947|     12|        PJ_LOG(4,(sess->obj_name, 
  ------------------
  |  |  106|     12|#define PJ_LOG(level,arg)       do { \
  |  |  107|     12|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|     24|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 12, Folded]
  |  |  |  Branch (107:70): [True: 0, False: 12]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  480|      0|    #define pj_log_wrapper_4(arg)       pj_log_4 arg
  |  |  ------------------
  |  |  109|      0|                                    } \
  |  |  110|     12|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 12]
  |  |  ------------------
  ------------------
 1948|     12|                  "Received Data indication with missing attributes"));
 1949|     12|        return PJ_EINVALIDOP;
  ------------------
  |  |  438|     12|#define PJ_EINVALIDOP       (PJ_ERRNO_START_STATUS + 13)/* 70013 */
  |  |  ------------------
  |  |  |  |  521|     12|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|     12|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|     12|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1950|     12|    }
 1951|       |
 1952|       |    /* Notify application */
 1953|      2|    if (sess->cb.on_rx_data) {
  ------------------
  |  Branch (1953:9): [True: 2, False: 0]
  ------------------
 1954|      2|        (*sess->cb.on_rx_data)(sess, data_attr->data, data_attr->length, 
 1955|      2|                               &peer_attr->sockaddr,
 1956|      2|                               pj_sockaddr_get_len(&peer_attr->sockaddr));
 1957|      2|    }
 1958|       |
 1959|      2|    return PJ_SUCCESS;
 1960|     14|}
turn_session.c:lookup_ch_by_chnum:
 2095|     19|{
 2096|     19|    return (struct ch_t*) pj_hash_get(sess->ch_table, &chnum, 
 2097|       |                                      sizeof(chnum), NULL);
 2098|     19|}

pj_turn_sock_cfg_default:
  202|    341|{
  203|    341|    pj_bzero(cfg, sizeof(*cfg));
  204|    341|    cfg->max_pkt_size = PJ_TURN_MAX_PKT_LEN;
  ------------------
  |  |  181|    341|#   define PJ_TURN_MAX_PKT_LEN                      3000
  ------------------
  205|    341|    cfg->qos_type = PJ_QOS_TYPE_BEST_EFFORT;
  206|    341|    cfg->qos_ignore_error = PJ_TRUE;
  207|       |
  208|       |#if PJ_HAS_SSL_SOCK
  209|       |    pj_turn_sock_tls_cfg_default(&cfg->tls_cfg);
  210|       |#endif
  211|    341|}

stun_parse:
  105|  1.24k|{
  106|  1.24k|    pj_pool_t *pool;
  107|  1.24k|    pj_stun_msg *msg = NULL;
  108|  1.24k|    pj_stun_msg *response = NULL;
  109|  1.24k|    pj_stun_auth_cred cred;
  110|  1.24k|    pj_str_t username, password, realm, nonce;
  111|  1.24k|    unsigned char *encoded_buf;
  112|  1.24k|    pj_size_t encoded_len;
  113|       |
  114|       |    /* Extract all flags at the beginning */
  115|  1.24k|    uint8_t flag_cred_username = data[0] & 0x01;
  116|  1.24k|    uint8_t flag_cred_password = data[0] & 0x02;
  117|  1.24k|    uint8_t flag_msg_type = data[1];
  118|  1.24k|    uint8_t flag_error_code = data[2] & 0x01;
  119|  1.24k|    uint8_t flag_unknown_attrs = data[2] & 0x02;
  120|  1.24k|    uint8_t flag_turn_enabled = data[3] & 0x01;
  121|  1.24k|    uint8_t flag_ice_enabled = data[3] & 0x04;
  122|       |
  123|       |    /* Advance data pointer and adjust size */
  124|  1.24k|    data += 4;
  125|  1.24k|    Size -= 4;
  126|       |
  127|       |    /* Use fixed credentials based on extracted flags */
  128|  1.24k|    if (flag_cred_username) {
  ------------------
  |  Branch (128:9): [True: 518, False: 725]
  ------------------
  129|    518|        username = pj_str(ALT_USERNAME);
  ------------------
  |  |   37|    518|#define ALT_USERNAME "altuser"
  ------------------
  130|    725|    } else {
  131|    725|        username = pj_str(FIXED_USERNAME);
  ------------------
  |  |   31|    725|#define FIXED_USERNAME "testuser"
  ------------------
  132|    725|    }
  133|       |
  134|  1.24k|    if (flag_cred_password) {
  ------------------
  |  Branch (134:9): [True: 436, False: 807]
  ------------------
  135|    436|        password = pj_str(ALT_PASSWORD);
  ------------------
  |  |   38|    436|#define ALT_PASSWORD "altpass456"
  ------------------
  136|    807|    } else {
  137|    807|        password = pj_str(FIXED_PASSWORD);
  ------------------
  |  |   32|    807|#define FIXED_PASSWORD "testpass123"
  ------------------
  138|    807|    }
  139|       |
  140|  1.24k|    realm = pj_str(FIXED_REALM);
  ------------------
  |  |   33|  1.24k|#define FIXED_REALM "testrealm.org"
  ------------------
  141|  1.24k|    nonce = pj_str(FIXED_NONCE);
  ------------------
  |  |   34|  1.24k|#define FIXED_NONCE "1234567890abcdef"
  ------------------
  142|       |
  143|  1.24k|    pool = pj_pool_create(mem, "stun_fuzz", 4096, 4096, NULL);
  144|  1.24k|    encoded_buf = pj_pool_alloc(pool, kMaxInputLength);
  ------------------
  |  |   28|  1.24k|#define kMaxInputLength 5120
  ------------------
  145|       |
  146|       |    /* Path 1: Decode existing STUN message using full remaining data */
  147|  1.24k|    pj_stun_msg_decode(pool, data, Size,
  148|  1.24k|                       PJ_STUN_IS_DATAGRAM | PJ_STUN_CHECK_PACKET,
  149|  1.24k|                       &msg, NULL, NULL);
  150|       |
  151|       |    /* Path 2: Authenticate (execute regardless of decode result for coverage) */
  152|  1.24k|    pj_bzero(&cred, sizeof(cred));
  153|  1.24k|    cred.type = PJ_STUN_AUTH_CRED_STATIC;
  154|  1.24k|    cred.data.static_cred.username = username;
  155|  1.24k|    cred.data.static_cred.data_type = PJ_STUN_PASSWD_PLAIN;
  156|  1.24k|    cred.data.static_cred.data = password;
  157|  1.24k|    cred.data.static_cred.realm = realm;
  158|  1.24k|    cred.data.static_cred.nonce = nonce;
  159|       |
  160|  1.24k|    if (msg) {
  ------------------
  |  Branch (160:9): [True: 659, False: 584]
  ------------------
  161|    659|        pj_stun_authenticate_request(data, (unsigned)Size,
  162|    659|                                      msg, &cred, pool, NULL, NULL);
  163|    659|    }
  164|       |
  165|       |    /* Path 3: Create new STUN messages (different types based on flag) */
  166|  1.24k|    {
  167|  1.24k|        int msg_type;
  168|  1.24k|        int type_selector = flag_msg_type % 8;
  169|       |
  170|       |        /* Select proper STUN message type (method + class) */
  171|  1.24k|        if (type_selector < 2) {
  ------------------
  |  Branch (171:13): [True: 801, False: 442]
  ------------------
  172|    801|            msg_type = PJ_STUN_BINDING_REQUEST;
  173|    801|        } else if (type_selector < 4) {
  ------------------
  |  Branch (173:20): [True: 117, False: 325]
  ------------------
  174|    117|            msg_type = PJ_STUN_ALLOCATE_REQUEST;
  175|    325|        } else if (type_selector < 6) {
  ------------------
  |  Branch (175:20): [True: 205, False: 120]
  ------------------
  176|    205|            msg_type = PJ_STUN_REFRESH_REQUEST;
  177|    205|        } else {
  178|    120|            msg_type = PJ_STUN_BINDING_INDICATION;
  179|    120|        }
  180|       |
  181|  1.24k|        pj_stun_msg_create(pool, msg_type, PJ_STUN_MAGIC, NULL, &response);
  ------------------
  |  |   46|  1.24k|#define PJ_STUN_MAGIC                       0x2112A442
  ------------------
  182|  1.24k|    }
  183|       |
  184|       |    /* Path 4: Add various attributes to message using full remaining data */
  185|  1.24k|    if (response) {
  ------------------
  |  Branch (185:9): [True: 1.24k, False: 0]
  ------------------
  186|  1.24k|        pj_sockaddr_in addr;
  187|  1.24k|        pj_str_t software = pj_str("FuzzTest");
  188|       |
  189|       |        /* Add USERNAME attribute */
  190|  1.24k|        pj_stun_msg_add_string_attr(pool, response, PJ_STUN_ATTR_USERNAME, &username);
  191|       |
  192|       |        /* Add REALM attribute */
  193|  1.24k|        pj_stun_msg_add_string_attr(pool, response, PJ_STUN_ATTR_REALM, &realm);
  194|       |
  195|       |        /* Add NONCE attribute */
  196|  1.24k|        pj_stun_msg_add_string_attr(pool, response, PJ_STUN_ATTR_NONCE, &nonce);
  197|       |
  198|       |        /* Add SOFTWARE attribute */
  199|  1.24k|        pj_stun_msg_add_string_attr(pool, response, PJ_STUN_ATTR_SOFTWARE, &software);
  200|       |
  201|       |        /* Add MAPPED-ADDRESS attribute using data */
  202|  1.24k|        pj_bzero(&addr, sizeof(addr));
  203|  1.24k|        addr.sin_family = pj_AF_INET();
  ------------------
  |  |  113|  1.24k|#   define pj_AF_INET()     PJ_AF_INET
  ------------------
  204|  1.24k|        if (Size >= 6) {
  ------------------
  |  Branch (204:13): [True: 1.24k, False: 0]
  ------------------
  205|  1.24k|            pj_memcpy(&addr.sin_addr, data, 4);
  206|  1.24k|            pj_memcpy(&addr.sin_port, data + 4, 2);
  207|  1.24k|        }
  208|  1.24k|        pj_stun_msg_add_sockaddr_attr(pool, response, PJ_STUN_ATTR_MAPPED_ADDR,
  209|  1.24k|                                       PJ_FALSE, (pj_sockaddr_t*)&addr, sizeof(addr));
  210|       |
  211|       |        /* Add XOR-MAPPED-ADDRESS */
  212|  1.24k|        pj_stun_msg_add_sockaddr_attr(pool, response, PJ_STUN_ATTR_XOR_MAPPED_ADDR,
  213|  1.24k|                                       PJ_TRUE, (pj_sockaddr_t*)&addr, sizeof(addr));
  214|       |
  215|       |        /* Add ERROR-CODE attribute based on flag */
  216|  1.24k|        if (flag_error_code && Size >= 7) {
  ------------------
  |  Branch (216:13): [True: 559, False: 684]
  |  Branch (216:32): [True: 559, False: 0]
  ------------------
  217|    559|            int err_code = (data[6] % 200) + 400;
  218|    559|            pj_str_t err_reason = pj_str("Test Error");
  219|    559|            pj_stun_msg_add_errcode_attr(pool, response, err_code, &err_reason);
  220|    559|        }
  221|       |
  222|       |        /* Add UNKNOWN-ATTRIBUTES if decode found unknown attrs */
  223|  1.24k|        if (msg && flag_unknown_attrs && Size >= 8) {
  ------------------
  |  Branch (223:13): [True: 659, False: 584]
  |  Branch (223:20): [True: 363, False: 296]
  |  Branch (223:42): [True: 363, False: 0]
  ------------------
  224|    363|            pj_uint16_t unknown_attrs[4] = {0x8001, 0x8002, 0x8003, 0x8004};
  225|    363|            pj_stun_msg_add_unknown_attr(pool, response,
  226|    363|                                          (data[7] % 4) + 1, unknown_attrs);
  227|    363|        }
  228|       |
  229|       |        /* Path 5: Add MESSAGE-INTEGRITY and encode with proper key */
  230|  1.24k|        pj_stun_msg_add_msgint_attr(pool, response);
  231|       |
  232|       |        /* Create authentication key for MESSAGE-INTEGRITY calculation */
  233|  1.24k|        pj_str_t key;
  234|  1.24k|        pj_stun_create_key(pool, &key, &realm, &username,
  235|  1.24k|                          PJ_STUN_PASSWD_PLAIN, &password);
  236|       |
  237|       |        /* Encode message with MESSAGE-INTEGRITY */
  238|  1.24k|        pj_stun_msg_encode(response, encoded_buf, kMaxInputLength,
  ------------------
  |  |   28|  1.24k|#define kMaxInputLength 5120
  ------------------
  239|  1.24k|                           0, &key, &encoded_len);
  240|       |
  241|       |        /* Path 7: Attribute lookup and manipulation */
  242|  1.24k|        pj_stun_msg_find_attr(response, PJ_STUN_ATTR_USERNAME, 0);
  243|  1.24k|        pj_stun_msg_find_attr(response, PJ_STUN_ATTR_REALM, 0);
  244|  1.24k|        pj_stun_msg_find_attr(response, PJ_STUN_ATTR_MESSAGE_INTEGRITY, 0);
  245|  1.24k|    }
  246|       |
  247|       |    /* Path 8: Create error response (only if msg is a request) */
  248|  1.24k|    if (msg && PJ_STUN_IS_REQUEST(msg->hdr.type) && Size >= 9) {
  ------------------
  |  |  153|  1.90k|#define PJ_STUN_IS_REQUEST(msg_type)    (((msg_type) & 0x0110) == 0x0000)
  |  |  ------------------
  |  |  |  Branch (153:41): [True: 508, False: 151]
  |  |  ------------------
  ------------------
  |  Branch (248:9): [True: 659, False: 584]
  |  Branch (248:53): [True: 508, False: 0]
  ------------------
  249|    508|        pj_str_t err_msg = pj_str("Unauthorized");
  250|    508|        pj_stun_msg_create_response(pool, msg, (data[8] % 200) + 400,
  251|    508|                                     &err_msg, &response);
  252|    508|    }
  253|       |
  254|       |    /* Path 9: TURN session operations - sendto, packet reception, and allocate requests */
  255|  1.24k|    if (Size >= 20 && flag_turn_enabled) {
  ------------------
  |  Branch (255:9): [True: 1.24k, False: 0]
  |  Branch (255:23): [True: 896, False: 347]
  ------------------
  256|    896|        pj_turn_session *turn_sess = NULL;
  257|    896|        pj_turn_session_cb turn_cb;
  258|    896|        pj_stun_config stun_cfg;
  259|    896|        pj_ioqueue_t *ioqueue = NULL;
  260|    896|        pj_timer_heap_t *timer_heap = NULL;
  261|    896|        pj_status_t status;
  262|       |
  263|       |        /* Setup STUN config for TURN */
  264|    896|        pj_stun_config_init(&stun_cfg, mem, 0, ioqueue, timer_heap);
  265|    896|        status = pj_ioqueue_create(pool, 4, &ioqueue);
  266|    896|        if (status != PJ_SUCCESS) goto on_turn_cleanup;
  ------------------
  |  Branch (266:13): [True: 0, False: 896]
  ------------------
  267|    896|        status = pj_timer_heap_create(pool, 16, &timer_heap);
  268|    896|        if (status != PJ_SUCCESS) goto on_turn_cleanup;
  ------------------
  |  Branch (268:13): [True: 0, False: 896]
  ------------------
  269|    896|        stun_cfg.ioqueue = ioqueue;
  270|    896|        stun_cfg.timer_heap = timer_heap;
  271|       |
  272|       |        /* Create TURN session */
  273|    896|        pj_bzero(&turn_cb, sizeof(turn_cb));
  274|    896|        turn_cb.on_send_pkt = &turn_on_send_pkt;
  275|    896|        turn_cb.on_rx_data = &turn_on_rx_data;
  276|    896|        turn_cb.on_state = &turn_on_state;
  277|       |
  278|    896|        status = pj_turn_session_create(&stun_cfg, "turn_fuzz", pj_AF_INET(),
  ------------------
  |  |  113|    896|#   define pj_AF_INET()     PJ_AF_INET
  ------------------
  279|    896|                                       PJ_TURN_TP_UDP, NULL, &turn_cb, 0, NULL, &turn_sess);
  280|       |
  281|    896|        if (status == PJ_SUCCESS && turn_sess) {
  ------------------
  |  Branch (281:13): [True: 896, False: 0]
  |  Branch (281:37): [True: 896, False: 0]
  ------------------
  282|       |            /* Configure TURN server and credentials */
  283|    896|            pj_str_t srv_addr_str = pj_str("127.0.0.1");
  284|    896|            int default_port = 3478;
  285|    896|            pj_stun_auth_cred cred;
  286|       |
  287|    896|            pj_turn_session_set_server(turn_sess, &srv_addr_str, default_port, NULL);
  288|       |
  289|    896|            pj_bzero(&cred, sizeof(cred));
  290|    896|            cred.type = PJ_STUN_AUTH_CRED_STATIC;
  291|    896|            cred.data.static_cred.username = pj_str(FIXED_USERNAME);
  ------------------
  |  |   31|    896|#define FIXED_USERNAME "testuser"
  ------------------
  292|    896|            cred.data.static_cred.data_type = PJ_STUN_PASSWD_PLAIN;
  293|    896|            cred.data.static_cred.data = pj_str(FIXED_PASSWORD);
  ------------------
  |  |   32|    896|#define FIXED_PASSWORD "testpass123"
  ------------------
  294|    896|            pj_turn_session_set_credential(turn_sess, &cred);
  295|       |
  296|       |            /* Test TURN sendto API */
  297|    896|            if (Size >= 6) {
  ------------------
  |  Branch (297:17): [True: 896, False: 0]
  ------------------
  298|    896|                pj_sockaddr_in peer_addr;
  299|    896|                pj_bzero(&peer_addr, sizeof(peer_addr));
  300|    896|                peer_addr.sin_family = pj_AF_INET();
  ------------------
  |  |  113|    896|#   define pj_AF_INET()     PJ_AF_INET
  ------------------
  301|    896|                pj_memcpy(&peer_addr.sin_addr, data, 4);
  302|    896|                pj_memcpy(&peer_addr.sin_port, data + 4, 2);
  303|       |
  304|    896|                size_t payload_len = Size - 6;
  305|    896|                if (payload_len > 512) payload_len = 512;
  ------------------
  |  Branch (305:21): [True: 74, False: 822]
  ------------------
  306|       |
  307|    896|                if (payload_len > 0) {
  ------------------
  |  Branch (307:21): [True: 896, False: 0]
  ------------------
  308|    896|                    pj_turn_session_sendto(turn_sess, data + 6, payload_len,
  309|    896|                                          (pj_sockaddr_t*)&peer_addr, sizeof(peer_addr));
  310|    896|                }
  311|    896|            }
  312|       |
  313|       |            /* Test TURN packet reception API */
  314|    896|            if (Size >= 40) {
  ------------------
  |  Branch (314:17): [True: 663, False: 233]
  ------------------
  315|    663|                pj_turn_session_on_rx_pkt_param prm;
  316|    663|                pj_sockaddr_in src_addr;
  317|    663|                size_t pkt_len = Size;
  318|    663|                if (pkt_len > 1500) pkt_len = 1500;
  ------------------
  |  Branch (318:21): [True: 42, False: 621]
  ------------------
  319|       |
  320|    663|                pj_bzero(&src_addr, sizeof(src_addr));
  321|    663|                src_addr.sin_family = pj_AF_INET();
  ------------------
  |  |  113|    663|#   define pj_AF_INET()     PJ_AF_INET
  ------------------
  322|    663|                src_addr.sin_port = pj_htons(default_port);
  323|    663|                src_addr.sin_addr.s_addr = pj_htonl(0x7F000001);
  324|       |
  325|    663|                pj_bzero(&prm, sizeof(prm));
  326|    663|                prm.pkt = data;
  327|    663|                prm.pkt_len = pkt_len;
  328|    663|                prm.src_addr = (pj_sockaddr*)&src_addr;
  329|    663|                prm.src_addr_len = sizeof(src_addr);
  330|       |
  331|    663|                pj_turn_session_on_rx_pkt2(turn_sess, &prm);
  332|    663|            }
  333|       |
  334|    896|            pj_turn_session_destroy(turn_sess, PJ_SUCCESS);
  335|    896|        }
  336|       |
  337|    896|on_turn_cleanup:
  338|    896|        if (timer_heap) pj_timer_heap_destroy(timer_heap);
  ------------------
  |  Branch (338:13): [True: 896, False: 0]
  ------------------
  339|    896|        if (ioqueue) pj_ioqueue_destroy(ioqueue);
  ------------------
  |  Branch (339:13): [True: 896, False: 0]
  ------------------
  340|    896|    }
  341|       |
  342|       |    /* Path 10: ICE session operations - connectivity checks and packet handling */
  343|  1.24k|    if (Size >= 50 && flag_ice_enabled) {
  ------------------
  |  Branch (343:9): [True: 727, False: 516]
  |  Branch (343:23): [True: 341, False: 386]
  ------------------
  344|    341|        pj_ice_strans *ice_st = NULL;
  345|    341|        pj_ice_strans_cb ice_cb;
  346|    341|        pj_ice_strans_cfg ice_cfg;
  347|    341|        pj_stun_config stun_cfg;
  348|    341|        pj_ioqueue_t *ioqueue = NULL;
  349|    341|        pj_timer_heap_t *timer_heap = NULL;
  350|    341|        pj_status_t status;
  351|       |
  352|       |        /* Setup infrastructure */
  353|    341|        status = pj_ioqueue_create(pool, 8, &ioqueue);
  354|    341|        if (status != PJ_SUCCESS) goto on_ice_cleanup;
  ------------------
  |  Branch (354:13): [True: 0, False: 341]
  ------------------
  355|    341|        status = pj_timer_heap_create(pool, 32, &timer_heap);
  356|    341|        if (status != PJ_SUCCESS) goto on_ice_cleanup;
  ------------------
  |  Branch (356:13): [True: 0, False: 341]
  ------------------
  357|    341|        pj_stun_config_init(&stun_cfg, mem, 0, ioqueue, timer_heap);
  358|       |
  359|       |        /* Create ICE transport */
  360|    341|        pj_bzero(&ice_cb, sizeof(ice_cb));
  361|    341|        ice_cb.on_rx_data = &ice_on_rx_data;
  362|    341|        ice_cb.on_ice_complete = &ice_on_ice_complete;
  363|       |
  364|    341|        pj_ice_strans_cfg_default(&ice_cfg);
  365|    341|        ice_cfg.stun_cfg = stun_cfg;
  366|    341|        ice_cfg.af = pj_AF_INET();
  ------------------
  |  |  113|    341|#   define pj_AF_INET()     PJ_AF_INET
  ------------------
  367|       |
  368|    341|        status = pj_ice_strans_create("ice_fuzz", &ice_cfg, 1,
  369|    341|                                     NULL, &ice_cb, &ice_st);
  370|       |
  371|    341|        if (status == PJ_SUCCESS && ice_st) {
  ------------------
  |  Branch (371:13): [True: 341, False: 0]
  |  Branch (371:37): [True: 341, False: 0]
  ------------------
  372|    341|            pj_str_t local_ufrag = pj_str(FIXED_USERNAME);
  ------------------
  |  |   31|    341|#define FIXED_USERNAME "testuser"
  ------------------
  373|    341|            pj_str_t local_pwd = pj_str(FIXED_PASSWORD);
  ------------------
  |  |   32|    341|#define FIXED_PASSWORD "testpass123"
  ------------------
  374|       |
  375|       |            /* Initialize ICE with role based on flag */
  376|    341|            pj_ice_sess_role role = (data[0] & 0x04) ? 
  ------------------
  |  Branch (376:37): [True: 19, False: 322]
  ------------------
  377|     19|                                    PJ_ICE_SESS_ROLE_CONTROLLING :
  378|    341|                                    PJ_ICE_SESS_ROLE_CONTROLLED;
  379|       |
  380|    341|            status = pj_ice_strans_init_ice(ice_st, role, &local_ufrag, &local_pwd);
  381|       |
  382|    341|            if (status == PJ_SUCCESS) {
  ------------------
  |  Branch (382:17): [True: 341, False: 0]
  ------------------
  383|       |                /* Query ICE state - exercises state management code */
  384|    341|                pj_ice_strans_get_state(ice_st);
  385|    341|                pj_ice_strans_has_sess(ice_st);
  386|    341|                pj_ice_strans_sess_is_running(ice_st);
  387|    341|                pj_ice_strans_sess_is_complete(ice_st);
  388|       |
  389|       |                /* Test candidate enumeration if we have data */
  390|    341|                if (Size >= 20) {
  ------------------
  |  Branch (390:21): [True: 341, False: 0]
  ------------------
  391|    341|                    unsigned comp_id = 1;
  392|    341|                    unsigned cand_cnt = 8;
  393|    341|                    pj_ice_sess_cand cands[8];
  394|    341|                    pj_ice_sess_cand def_cand;
  395|       |
  396|    341|                    pj_ice_strans_enum_cands(ice_st, comp_id, &cand_cnt, cands);
  397|    341|                    pj_ice_strans_get_def_cand(ice_st, comp_id, &def_cand);
  398|    341|                }
  399|    341|            }
  400|       |
  401|    341|            pj_ice_strans_destroy(ice_st);
  402|    341|        }
  403|       |
  404|    341|on_ice_cleanup:
  405|    341|        if (timer_heap) pj_timer_heap_destroy(timer_heap);
  ------------------
  |  Branch (405:13): [True: 341, False: 0]
  ------------------
  406|    341|        if (ioqueue) pj_ioqueue_destroy(ioqueue);
  ------------------
  |  Branch (406:13): [True: 341, False: 0]
  ------------------
  407|    341|    }
  408|       |
  409|  1.24k|    pj_pool_release(pool);
  410|  1.24k|    return 0;
  411|  1.24k|}
LLVMFuzzerTestOneInput:
  416|  1.26k|{
  417|  1.26k|    int ret = 0;
  418|  1.26k|    uint8_t *data;
  419|  1.26k|    pj_caching_pool caching_pool;
  420|       |
  421|  1.26k|    if (Size < kMinInputLength || Size > kMaxInputLength) {
  ------------------
  |  |   27|  2.53k|#define kMinInputLength 24
  ------------------
                  if (Size < kMinInputLength || Size > kMaxInputLength) {
  ------------------
  |  |   28|  1.26k|#define kMaxInputLength 5120
  ------------------
  |  Branch (421:9): [True: 9, False: 1.26k]
  |  Branch (421:35): [True: 17, False: 1.24k]
  ------------------
  422|     26|        return 1;
  423|     26|    }
  424|       |
  425|       |    /* Add NULL byte */
  426|  1.24k|    data = (uint8_t *)calloc((Size+1), sizeof(uint8_t));
  427|  1.24k|    memcpy((void *)data, (void *)Data, Size);
  428|       |
  429|       |    /* init Calls */
  430|  1.24k|    pj_init();
  431|  1.24k|    pj_caching_pool_init(&caching_pool, &pj_pool_factory_default_policy, 0);
  432|  1.24k|    pj_log_set_level(0);
  433|       |
  434|  1.24k|    mem = &caching_pool.factory;
  435|       |
  436|       |    /* Call fuzzer */
  437|  1.24k|    ret = stun_parse(data, Size);
  438|       |
  439|  1.24k|    free(data);
  440|  1.24k|    pj_caching_pool_destroy(&caching_pool);
  441|       |
  442|  1.24k|    return ret;
  443|  1.26k|}
fuzz-stun.c:turn_on_send_pkt:
   48|    401|{
   49|    401|    PJ_UNUSED_ARG(sess);
  ------------------
  |  | 1537|    401|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
   50|    401|    PJ_UNUSED_ARG(pkt);
  ------------------
  |  | 1537|    401|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
   51|    401|    PJ_UNUSED_ARG(pkt_len);
  ------------------
  |  | 1537|    401|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
   52|    401|    PJ_UNUSED_ARG(dst_addr);
  ------------------
  |  | 1537|    401|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
   53|    401|    PJ_UNUSED_ARG(dst_addr_len);
  ------------------
  |  | 1537|    401|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
   54|    401|    return PJ_SUCCESS;
   55|    401|}
fuzz-stun.c:turn_on_rx_data:
   62|      2|{
   63|      2|    PJ_UNUSED_ARG(sess);
  ------------------
  |  | 1537|      2|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
   64|      2|    PJ_UNUSED_ARG(pkt);
  ------------------
  |  | 1537|      2|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
   65|      2|    PJ_UNUSED_ARG(pkt_len);
  ------------------
  |  | 1537|      2|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
   66|      2|    PJ_UNUSED_ARG(peer_addr);
  ------------------
  |  | 1537|      2|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
   67|      2|    PJ_UNUSED_ARG(addr_len);
  ------------------
  |  | 1537|      2|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
   68|      2|}
fuzz-stun.c:turn_on_state:
   73|  3.58k|{
   74|  3.58k|    PJ_UNUSED_ARG(sess);
  ------------------
  |  | 1537|  3.58k|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
   75|  3.58k|    PJ_UNUSED_ARG(old_state);
  ------------------
  |  | 1537|  3.58k|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
   76|  3.58k|    PJ_UNUSED_ARG(new_state);
  ------------------
  |  | 1537|  3.58k|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
   77|  3.58k|}
fuzz-stun.c:ice_on_ice_complete:
   98|    341|{
   99|    341|    PJ_UNUSED_ARG(ice_st);
  ------------------
  |  | 1537|    341|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
  100|    341|    PJ_UNUSED_ARG(op);
  ------------------
  |  | 1537|    341|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
  101|    341|    PJ_UNUSED_ARG(status);
  ------------------
  |  | 1537|    341|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
  102|    341|}

