mib.c:snmp_cstrcat:
  243|  3.01k|    {
  244|  3.01k|        return snmp_strcat(buf, buf_len, out_len, allow_realloc,
  245|  3.01k|                           (const u_char *)s);
  246|  3.01k|    }

asn_parse_nlength:
  327|  9.74k|{
  328|  9.74k|    int len_len;
  329|       |
  330|  9.74k|    if (pkt_len < 1)
  ------------------
  |  Branch (330:9): [True: 0, False: 9.74k]
  ------------------
  331|      0|        return NULL;               /* always too short */
  332|       |
  333|  9.74k|    if (NULL == pkt || NULL == data_len)
  ------------------
  |  Branch (333:9): [True: 0, False: 9.74k]
  |  Branch (333:24): [True: 0, False: 9.74k]
  ------------------
  334|      0|        return NULL;
  335|       |
  336|  9.74k|    *data_len = 0;
  337|       |
  338|  9.74k|    if (*pkt & 0x80) {
  ------------------
  |  Branch (338:9): [True: 991, False: 8.75k]
  ------------------
  339|       |        /*
  340|       |         * long length; first byte is length of length (after masking high bit)
  341|       |         */
  342|    991|        len_len = (int) ((*pkt & ~0x80) + 1);
  343|    991|        if (pkt_len < len_len)
  ------------------
  |  Branch (343:13): [True: 72, False: 919]
  ------------------
  344|     72|            return NULL;           /* still too short for length and data */
  345|       |
  346|       |        /* now we know we have enough data to parse length */
  347|    919|        if (NULL == asn_parse_length(pkt, data_len))
  ------------------
  |  Branch (347:13): [True: 129, False: 790]
  ------------------
  348|    129|            return NULL;           /* propagate error from asn_parse_length */
  349|  8.75k|    } else {
  350|       |        /*
  351|       |         * short length; first byte is the length
  352|       |         */
  353|  8.75k|        len_len = 1;
  354|  8.75k|        *data_len = *pkt;
  355|  8.75k|    }
  356|       |
  357|  9.54k|    if ((*data_len + len_len) > pkt_len)
  ------------------
  |  Branch (357:9): [True: 688, False: 8.85k]
  ------------------
  358|    688|        return NULL;
  359|       |
  360|  8.85k|    return (pkt + len_len);
  361|  9.54k|}
asn_parse_int:
  563|  2.90k|{
  564|       |    /*
  565|       |     * ASN.1 integer ::= 0x02 asnlength byte {byte}*
  566|       |     */
  567|  2.90k|    static const char *errpre = "parse int";
  568|  2.90k|    register u_char *bufp = data;
  569|  2.90k|    u_long          asn_length;
  570|  2.90k|    int             i;
  571|  2.90k|    union {
  572|  2.90k|        long          l;
  573|  2.90k|        unsigned char b[sizeof(long)];
  574|  2.90k|    } value;
  575|       |
  576|  2.90k|    if (NULL == data || NULL == datalength || NULL == type || NULL == intp) {
  ------------------
  |  Branch (576:9): [True: 0, False: 2.90k]
  |  Branch (576:25): [True: 0, False: 2.90k]
  |  Branch (576:47): [True: 0, False: 2.90k]
  |  Branch (576:63): [True: 0, False: 2.90k]
  ------------------
  577|      0|        ERROR_MSG("parse int: NULL pointer");
  ------------------
  |  |  190|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
  578|      0|        return NULL;
  579|      0|    }
  580|       |
  581|  2.90k|    if (intsize != sizeof(long)) {
  ------------------
  |  Branch (581:9): [True: 0, False: 2.90k]
  ------------------
  582|      0|        _asn_size_err(errpre, intsize, sizeof(long));
  583|      0|        return NULL;
  584|      0|    }
  585|       |
  586|       |    /** need at least 2 bytes to work with: type, length (which might be 0)  */
  587|  2.90k|    if (*datalength < 2) {
  ------------------
  |  Branch (587:9): [True: 14, False: 2.89k]
  ------------------
  588|     14|        _asn_short_err(errpre, *datalength, 2);
  589|     14|        return NULL;
  590|     14|    }
  591|       |
  592|  2.89k|    *type = *bufp++;
  593|  2.89k|    if (*type != ASN_INTEGER) {
  ------------------
  |  |   75|  2.89k|#define ASN_INTEGER	    0x02U
  ------------------
  |  Branch (593:9): [True: 23, False: 2.87k]
  ------------------
  594|     23|        _asn_type_err(errpre, *type);
  595|     23|        return NULL;
  596|     23|    }
  597|       |
  598|  2.87k|    bufp = asn_parse_nlength(bufp, *datalength - 1, &asn_length);
  599|  2.87k|    if (NULL == bufp) {
  ------------------
  |  Branch (599:9): [True: 132, False: 2.73k]
  ------------------
  600|    132|        _asn_short_err(errpre, *datalength - 1, asn_length);
  601|    132|        return NULL;
  602|    132|    }
  603|       |
  604|  2.73k|    if ((size_t) asn_length > intsize || (int) asn_length == 0) {
  ------------------
  |  Branch (604:9): [True: 12, False: 2.72k]
  |  Branch (604:42): [True: 8, False: 2.71k]
  ------------------
  605|     20|        _asn_length_err(errpre, (size_t) asn_length, intsize);
  606|     20|        return NULL;
  607|     20|    }
  608|       |
  609|  2.71k|    *datalength -= (int) asn_length + (bufp - data);
  610|       |
  611|  2.71k|    DEBUGDUMPSETUP("recv", data, bufp - data + asn_length);
  ------------------
  |  |   85|  2.71k|	do {if (_DBG_IF_) {__DBGDUMPSETUP(token,buf,len);} }while(0)
  |  |  ------------------
  |  |  |  |  146|  2.71k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 2.71k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPSETUP(token,buf,len);} }while(0)
  |  |  ------------------
  |  |  |  |  198|  2.71k|        debugmsg("dumpx" token, "dumpx_%s:%*s", token, __DBGINDENT(), ""); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  173|  2.71k|#define __DBGINDENT()      debug_indent_get()
  |  |  |  |  ------------------
  |  |  |  |  199|  2.71k|        __DBGMSGHEX(("dumpx_" token,buf,len)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  171|  2.71k|#define __DBGMSGHEX(x)     debugmsg_hex x
  |  |  |  |  ------------------
  |  |  |  |  200|  2.71k|        if (debug_is_token_registered("dumpv" token) == SNMPERR_SUCCESS || \
  |  |  |  |  ------------------
  |  |  |  |  |  |  217|  5.43k|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (200:13): [True: 2.71k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  201|  2.71k|            debug_is_token_registered("dumpv_" token) != SNMPERR_SUCCESS) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |  217|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (201:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  202|  2.71k|            debugmsg("dumpx_" token,"\n"); \
  |  |  |  |  203|  2.71k|        } else { \
  |  |  |  |  204|      0|            debugmsg("dumpx_" token,"  "); \
  |  |  |  |  205|      0|        } \
  |  |  |  |  206|  2.71k|        debugmsg("dumpv" token, "dumpv_%s:%*s", token, __DBGINDENT(), "");
  |  |  |  |  ------------------
  |  |  |  |  |  |  173|  2.71k|#define __DBGINDENT()      debug_indent_get()
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (85:60): [Folded - Ignored]
  |  |  ------------------
  ------------------
  612|       |
  613|  2.71k|    memset(&value.b, *bufp & 0x80 ? 0xff : 0, sizeof(value.b));
  ------------------
  |  Branch (613:22): [True: 771, False: 1.94k]
  ------------------
  614|  2.71k|    if (NETSNMP_BIGENDIAN) {
  ------------------
  |  | 2372|  2.71k|#  define NETSNMP_BIGENDIAN 0
  |  |  ------------------
  |  |  |  Branch (2372:29): [Folded - Ignored]
  |  |  ------------------
  ------------------
  615|      0|        for (i = sizeof(long) - asn_length; asn_length--; i++)
  ------------------
  |  Branch (615:45): [True: 0, False: 0]
  ------------------
  616|      0|            value.b[i] = *bufp++;
  617|  2.71k|    } else {
  618|  7.56k|        for (i = asn_length - 1; asn_length--; i--)
  ------------------
  |  Branch (618:34): [True: 4.84k, False: 2.71k]
  ------------------
  619|  4.84k|            value.b[i] = *bufp++;
  620|  2.71k|    }
  621|       |
  622|  2.71k|    CHECK_OVERFLOW_S(value.l, 1);
  ------------------
  |  |  214|  2.71k|#define CHECK_OVERFLOW_S(x,y) do {                                      \
  |  |  215|  2.71k|        if (x > INT32_MAX) {                                            \
  |  |  ------------------
  |  |  |  Branch (215:13): [True: 16, False: 2.70k]
  |  |  ------------------
  |  |  216|     16|            DEBUGMSG(("asn","truncating signed value %ld to 32 bits (%d)\n",(long)(x),y)); \
  |  |  ------------------
  |  |  |  |   63|     16|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  |  146|     16|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (146:29): [True: 16, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (63:67): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  217|     16|            x &= 0xffffffff;                                            \
  |  |  218|  2.70k|        } else if (x < INT32_MIN) {                                     \
  |  |  ------------------
  |  |  |  Branch (218:20): [True: 73, False: 2.62k]
  |  |  ------------------
  |  |  219|     73|            DEBUGMSG(("asn","truncating signed value %ld to 32 bits (%d)\n",(long)(x),y)); \
  |  |  ------------------
  |  |  |  |   63|     73|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  |  146|     73|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (146:29): [True: 73, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (63:67): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  220|     73|            x = 0 - (x & 0xffffffff);                                   \
  |  |  221|     73|        }                                                               \
  |  |  222|  2.71k|    } while(0)
  |  |  ------------------
  |  |  |  Branch (222:13): [Folded - Ignored]
  |  |  ------------------
  ------------------
  623|       |
  624|  2.71k|    DEBUGMSG(("dumpv_recv", "  Integer:\t%ld (0x%.2lX)\n", value.l, value.l));
  ------------------
  |  |   63|  2.71k|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  146|  2.71k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 2.71k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (63:67): [Folded - Ignored]
  |  |  ------------------
  ------------------
  625|       |
  626|  2.71k|    *intp = value.l;
  627|  2.71k|    return bufp;
  628|  2.73k|}
asn_parse_unsigned_int:
  656|    221|{
  657|       |    /*
  658|       |     * ASN.1 integer ::= 0x02 asnlength byte {byte}*
  659|       |     */
  660|    221|    static const char *errpre = "parse uint";
  661|    221|    register u_char *bufp = data;
  662|    221|    u_long          asn_length;
  663|    221|    register u_long value = 0;
  664|       |
  665|    221|    if (NULL == data || NULL == datalength || NULL == type || NULL == intp) {
  ------------------
  |  Branch (665:9): [True: 0, False: 221]
  |  Branch (665:25): [True: 0, False: 221]
  |  Branch (665:47): [True: 0, False: 221]
  |  Branch (665:63): [True: 0, False: 221]
  ------------------
  666|      0|        ERROR_MSG("parse uint: NULL pointer");
  ------------------
  |  |  190|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
  667|      0|        return NULL;
  668|      0|    }
  669|       |
  670|    221|    if (intsize != sizeof(long)) {
  ------------------
  |  Branch (670:9): [True: 0, False: 221]
  ------------------
  671|      0|        _asn_size_err(errpre, intsize, sizeof(long));
  672|      0|        return NULL;
  673|      0|    }
  674|       |
  675|       |    /** need at least 2 bytes to work with: type, length (which might be 0)  */
  676|    221|    if (*datalength < 2) {
  ------------------
  |  Branch (676:9): [True: 1, False: 220]
  ------------------
  677|      1|        _asn_short_err(errpre, *datalength, 2);
  678|      1|        return NULL;
  679|      1|    }
  680|       |
  681|    220|    *type = *bufp++;
  682|    220|    if (*type != ASN_COUNTER && *type != ASN_GAUGE && *type != ASN_TIMETICKS
  ------------------
  |  |   89|    440|#define ASN_COUNTER	(ASN_APPLICATION | 1)
  |  |  ------------------
  |  |  |  |   91|    220|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
                  if (*type != ASN_COUNTER && *type != ASN_GAUGE && *type != ASN_TIMETICKS
  ------------------
  |  |   90|    415|#define ASN_GAUGE	(ASN_APPLICATION | 2)
  |  |  ------------------
  |  |  |  |   91|    195|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
                  if (*type != ASN_COUNTER && *type != ASN_GAUGE && *type != ASN_TIMETICKS
  ------------------
  |  |   92|    353|#define ASN_TIMETICKS   (ASN_APPLICATION | 3)
  |  |  ------------------
  |  |  |  |   91|    133|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (682:9): [True: 195, False: 25]
  |  Branch (682:33): [True: 133, False: 62]
  |  Branch (682:55): [True: 56, False: 77]
  ------------------
  683|    220|            && *type != ASN_UINTEGER) {
  ------------------
  |  |  100|     56|#define ASN_UINTEGER    (ASN_APPLICATION | 7)   /* historic - don't use */
  |  |  ------------------
  |  |  |  |   91|     56|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (683:16): [True: 16, False: 40]
  ------------------
  684|     16|        _asn_type_err(errpre, *type);
  685|     16|        return NULL;
  686|     16|    }
  687|       |
  688|    204|    bufp = asn_parse_nlength(bufp, *datalength - 1, &asn_length);
  689|    204|    if (NULL == bufp) {
  ------------------
  |  Branch (689:9): [True: 98, False: 106]
  ------------------
  690|     98|        _asn_short_err(errpre, *datalength - 1, asn_length);
  691|     98|        return NULL;
  692|     98|    }
  693|       |
  694|    106|    if ((asn_length > (intsize + 1)) || ((int) asn_length == 0) ||
  ------------------
  |  Branch (694:9): [True: 2, False: 104]
  |  Branch (694:41): [True: 4, False: 100]
  ------------------
  695|    106|        ((asn_length == intsize + 1) && *bufp != 0x00)) {
  ------------------
  |  Branch (695:10): [True: 23, False: 77]
  |  Branch (695:41): [True: 4, False: 19]
  ------------------
  696|     10|        _asn_length_err(errpre, (size_t) asn_length, intsize);
  697|     10|        return NULL;
  698|     10|    }
  699|     96|    *datalength -= (int) asn_length + (bufp - data);
  700|       |
  701|     96|    DEBUGDUMPSETUP("recv", data, bufp - data + asn_length);
  ------------------
  |  |   85|     96|	do {if (_DBG_IF_) {__DBGDUMPSETUP(token,buf,len);} }while(0)
  |  |  ------------------
  |  |  |  |  146|     96|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 96, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPSETUP(token,buf,len);} }while(0)
  |  |  ------------------
  |  |  |  |  198|     96|        debugmsg("dumpx" token, "dumpx_%s:%*s", token, __DBGINDENT(), ""); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  173|     96|#define __DBGINDENT()      debug_indent_get()
  |  |  |  |  ------------------
  |  |  |  |  199|     96|        __DBGMSGHEX(("dumpx_" token,buf,len)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  171|     96|#define __DBGMSGHEX(x)     debugmsg_hex x
  |  |  |  |  ------------------
  |  |  |  |  200|     96|        if (debug_is_token_registered("dumpv" token) == SNMPERR_SUCCESS || \
  |  |  |  |  ------------------
  |  |  |  |  |  |  217|    192|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (200:13): [True: 96, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  201|     96|            debug_is_token_registered("dumpv_" token) != SNMPERR_SUCCESS) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |  217|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (201:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  202|     96|            debugmsg("dumpx_" token,"\n"); \
  |  |  |  |  203|     96|        } else { \
  |  |  |  |  204|      0|            debugmsg("dumpx_" token,"  "); \
  |  |  |  |  205|      0|        } \
  |  |  |  |  206|     96|        debugmsg("dumpv" token, "dumpv_%s:%*s", token, __DBGINDENT(), "");
  |  |  |  |  ------------------
  |  |  |  |  |  |  173|     96|#define __DBGINDENT()      debug_indent_get()
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (85:60): [Folded - Ignored]
  |  |  ------------------
  ------------------
  702|       |
  703|    649|    while (asn_length--)
  ------------------
  |  Branch (703:12): [True: 553, False: 96]
  ------------------
  704|    553|        value = (value << 8) | *bufp++;
  705|       |
  706|     96|    CHECK_OVERFLOW_U(value,2);
  ------------------
  |  |  224|     96|#define CHECK_OVERFLOW_U(x,y) do {                                      \
  |  |  225|     96|        if (x > UINT32_MAX) {                                           \
  |  |  ------------------
  |  |  |  Branch (225:13): [True: 45, False: 51]
  |  |  ------------------
  |  |  226|     45|            x &= 0xffffffff;                                            \
  |  |  227|     45|            DEBUGMSG(("asn","truncating unsigned value to 32 bits (%d)\n",y)); \
  |  |  ------------------
  |  |  |  |   63|     45|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  |  146|     45|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (146:29): [True: 45, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (63:67): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  228|     45|        }                                                               \
  |  |  229|     96|    } while(0)
  |  |  ------------------
  |  |  |  Branch (229:13): [Folded - Ignored]
  |  |  ------------------
  ------------------
  707|       |
  708|     96|    DEBUGMSG(("dumpv_recv", "  UInteger:\t%ld (0x%.2lX)\n", value, value));
  ------------------
  |  |   63|     96|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  146|     96|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 96, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (63:67): [Folded - Ignored]
  |  |  ------------------
  ------------------
  709|       |
  710|     96|    *intp = value;
  711|     96|    return bufp;
  712|    106|}
asn_parse_string:
  916|  1.51k|{
  917|  1.51k|    static const char *errpre = "parse string";
  918|  1.51k|    u_char         *bufp = data;
  919|  1.51k|    u_long          asn_length;
  920|       |
  921|  1.51k|    if (NULL == data || NULL == datalength || NULL == type || NULL == str ||
  ------------------
  |  Branch (921:9): [True: 0, False: 1.51k]
  |  Branch (921:25): [True: 0, False: 1.51k]
  |  Branch (921:47): [True: 0, False: 1.51k]
  |  Branch (921:63): [True: 0, False: 1.51k]
  ------------------
  922|  1.51k|        NULL == strlength) {
  ------------------
  |  Branch (922:9): [True: 0, False: 1.51k]
  ------------------
  923|      0|        ERROR_MSG("parse string: NULL pointer");
  ------------------
  |  |  190|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
  924|      0|        return NULL;
  925|      0|    }
  926|       |
  927|       |    /** need at least 2 bytes to work with: type, length (which might be 0)  */
  928|  1.51k|    if (*datalength < 2) {
  ------------------
  |  Branch (928:9): [True: 212, False: 1.30k]
  ------------------
  929|    212|        _asn_short_err(errpre, *datalength, 2);
  930|    212|        return NULL;
  931|    212|    }
  932|       |
  933|  1.30k|    *type = *bufp++;
  934|  1.30k|    if (*type != ASN_OCTET_STR && *type != ASN_IPADDRESS && *type != ASN_OPAQUE
  ------------------
  |  |   78|  2.60k|#define ASN_OCTET_STR	    0x04U
  ------------------
                  if (*type != ASN_OCTET_STR && *type != ASN_IPADDRESS && *type != ASN_OPAQUE
  ------------------
  |  |   88|  2.14k|#define ASN_IPADDRESS   (ASN_APPLICATION | 0)
  |  |  ------------------
  |  |  |  |   91|    847|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
                  if (*type != ASN_OCTET_STR && *type != ASN_IPADDRESS && *type != ASN_OPAQUE
  ------------------
  |  |   93|  1.84k|#define ASN_OPAQUE	(ASN_APPLICATION | 4)   /* changed so no conflict with other includes */
  |  |  ------------------
  |  |  |  |   91|    539|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (934:9): [True: 847, False: 454]
  |  Branch (934:35): [True: 539, False: 308]
  |  Branch (934:61): [True: 439, False: 100]
  ------------------
  935|  1.30k|            && *type != ASN_NSAP) {
  ------------------
  |  |   98|    439|#define ASN_NSAP	(ASN_APPLICATION | 5)   /* historic - don't use */
  |  |  ------------------
  |  |  |  |   91|    439|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (935:16): [True: 27, False: 412]
  ------------------
  936|     27|        _asn_type_err(errpre, *type);
  937|     27|        return NULL;
  938|     27|    }
  939|       |
  940|  1.27k|    bufp = asn_parse_nlength(bufp, *datalength - 1, &asn_length);
  941|  1.27k|    if (NULL == bufp) {
  ------------------
  |  Branch (941:9): [True: 141, False: 1.13k]
  ------------------
  942|    141|        _asn_short_err(errpre, *datalength - 1, asn_length);
  943|    141|        return NULL;
  944|    141|    }
  945|       |
  946|  1.13k|    if (asn_length > *strlength) {
  ------------------
  |  Branch (946:9): [True: 18, False: 1.11k]
  ------------------
  947|     18|        _asn_length_err(errpre, (size_t) asn_length, *strlength);
  948|     18|        return NULL;
  949|     18|    }
  950|       |
  951|  1.11k|    DEBUGDUMPSETUP("recv", data, bufp - data + asn_length);
  ------------------
  |  |   85|  1.11k|	do {if (_DBG_IF_) {__DBGDUMPSETUP(token,buf,len);} }while(0)
  |  |  ------------------
  |  |  |  |  146|  1.11k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 1.11k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPSETUP(token,buf,len);} }while(0)
  |  |  ------------------
  |  |  |  |  198|  1.11k|        debugmsg("dumpx" token, "dumpx_%s:%*s", token, __DBGINDENT(), ""); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  173|  1.11k|#define __DBGINDENT()      debug_indent_get()
  |  |  |  |  ------------------
  |  |  |  |  199|  1.11k|        __DBGMSGHEX(("dumpx_" token,buf,len)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  171|  1.11k|#define __DBGMSGHEX(x)     debugmsg_hex x
  |  |  |  |  ------------------
  |  |  |  |  200|  1.11k|        if (debug_is_token_registered("dumpv" token) == SNMPERR_SUCCESS || \
  |  |  |  |  ------------------
  |  |  |  |  |  |  217|  2.23k|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (200:13): [True: 1.11k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  201|  1.11k|            debug_is_token_registered("dumpv_" token) != SNMPERR_SUCCESS) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |  217|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (201:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  202|  1.11k|            debugmsg("dumpx_" token,"\n"); \
  |  |  |  |  203|  1.11k|        } else { \
  |  |  |  |  204|      0|            debugmsg("dumpx_" token,"  "); \
  |  |  |  |  205|      0|        } \
  |  |  |  |  206|  1.11k|        debugmsg("dumpv" token, "dumpv_%s:%*s", token, __DBGINDENT(), "");
  |  |  |  |  ------------------
  |  |  |  |  |  |  173|  1.11k|#define __DBGINDENT()      debug_indent_get()
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (85:60): [Folded - Ignored]
  |  |  ------------------
  ------------------
  952|       |
  953|  1.11k|    memmove(str, bufp, asn_length);
  954|  1.11k|    if (*strlength > asn_length)
  ------------------
  |  Branch (954:9): [True: 995, False: 120]
  ------------------
  955|    995|        str[asn_length] = 0;
  956|  1.11k|    *strlength = asn_length;
  957|  1.11k|    *datalength -= asn_length + (bufp - data);
  958|       |
  959|  1.11k|    DEBUGIF("dumpv_recv") {
  ------------------
  |  |  147|  1.11k|#define DEBUGIF(x)         if (_DBG_IF_ && debug_is_token_registered(x) == SNMPERR_SUCCESS)
  |  |  ------------------
  |  |  |  |  146|  2.23k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 1.11k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGIF(x)         if (_DBG_IF_ && debug_is_token_registered(x) == SNMPERR_SUCCESS)
  |  |  ------------------
  |  |  |  |  217|  1.11k|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  ------------------
  |  |  |  Branch (147:44): [True: 1.11k, False: 0]
  |  |  ------------------
  ------------------
  960|  1.11k|        u_char         *buf = (u_char *) malloc(1 + asn_length);
  961|  1.11k|        size_t          l = (buf != NULL) ? (1 + asn_length) : 0, ol = 0;
  ------------------
  |  Branch (961:29): [True: 1.11k, False: 0]
  ------------------
  962|       |
  963|  1.11k|        if (sprint_realloc_asciistring
  ------------------
  |  Branch (963:13): [True: 1.11k, False: 0]
  ------------------
  964|  1.11k|            (&buf, &l, &ol, 1, str, asn_length)) {
  965|  1.11k|            DEBUGMSG(("dumpv_recv", "  String:\t%s\n", buf));
  ------------------
  |  |   63|  1.11k|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  146|  1.11k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 1.11k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (63:67): [Folded - Ignored]
  |  |  ------------------
  ------------------
  966|  1.11k|        } else {
  967|      0|            if (buf == NULL) {
  ------------------
  |  Branch (967:17): [True: 0, False: 0]
  ------------------
  968|      0|                DEBUGMSG(("dumpv_recv", "  String:\t[TRUNCATED]\n"));
  ------------------
  |  |   63|      0|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (63:67): [Folded - Ignored]
  |  |  ------------------
  ------------------
  969|      0|            } else {
  970|      0|                DEBUGMSG(("dumpv_recv", "  String:\t%s [TRUNCATED]\n",
  ------------------
  |  |   63|      0|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (63:67): [Folded - Ignored]
  |  |  ------------------
  ------------------
  971|      0|                          buf));
  972|      0|            }
  973|      0|        }
  974|  1.11k|        if (buf != NULL) {
  ------------------
  |  Branch (974:13): [True: 1.11k, False: 0]
  ------------------
  975|  1.11k|            free(buf);
  976|  1.11k|        }
  977|  1.11k|    }
  978|       |
  979|  1.11k|    return bufp + asn_length;
  980|  1.13k|}
asn_parse_header:
 1077|  4.14k|{
 1078|  4.14k|    register u_char *bufp;
 1079|  4.14k|    u_long          asn_length = 0;
 1080|  4.14k|    const char      *errpre = "parse header";
 1081|       |
 1082|  4.14k|    if (!data || !datalength || !type) {
  ------------------
  |  Branch (1082:9): [True: 0, False: 4.14k]
  |  Branch (1082:18): [True: 0, False: 4.14k]
  |  Branch (1082:33): [True: 0, False: 4.14k]
  ------------------
 1083|      0|        ERROR_MSG("parse header: NULL pointer");
  ------------------
  |  |  190|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 1084|      0|        return NULL;
 1085|      0|    }
 1086|       |
 1087|       |    /** need at least 2 bytes to work with: type, length (which might be 0) */
 1088|  4.14k|    if (*datalength < 2) {
  ------------------
  |  Branch (1088:9): [True: 32, False: 4.11k]
  ------------------
 1089|     32|        _asn_short_err(errpre, *datalength, 2);
 1090|     32|        return NULL;
 1091|     32|    }
 1092|       |
 1093|  4.11k|    bufp = data;
 1094|       |    /*
 1095|       |     * this only works on data types < 30, i.e. no extension octets 
 1096|       |     */
 1097|  4.11k|    if (IS_EXTENSION_ID(*bufp)) {
  ------------------
  |  |  103|  4.11k|#define IS_EXTENSION_ID(byte)	(((byte) & ASN_EXTENSION_ID) == ASN_EXTENSION_ID)
  |  |  ------------------
  |  |  |  |   99|  4.11k|#define ASN_EXTENSION_ID    0x1FU
  |  |  ------------------
  |  |               #define IS_EXTENSION_ID(byte)	(((byte) & ASN_EXTENSION_ID) == ASN_EXTENSION_ID)
  |  |  ------------------
  |  |  |  |   99|  4.11k|#define ASN_EXTENSION_ID    0x1FU
  |  |  ------------------
  |  |  |  Branch (103:31): [True: 42, False: 4.07k]
  |  |  ------------------
  ------------------
 1098|     42|        ERROR_MSG("can't process ID >= 30");
  ------------------
  |  |  190|     42|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 1099|     42|        return NULL;
 1100|     42|    }
 1101|  4.07k|    *type = *bufp++;
 1102|       |
 1103|  4.07k|    bufp = asn_parse_nlength(bufp, *datalength - 1, &asn_length);
 1104|  4.07k|    if (NULL == bufp) {
  ------------------
  |  Branch (1104:9): [True: 396, False: 3.67k]
  ------------------
 1105|    396|        _asn_short_err(errpre, *datalength - 1, asn_length);
 1106|    396|        return NULL;
 1107|    396|    }
 1108|       |
 1109|       |#ifdef DUMP_PRINT_HEADERS
 1110|       |    DEBUGDUMPSETUP("recv", data, (bufp - data));
 1111|       |    DEBUGMSG(("dumpv_recv", "  Header: 0x%.2X, len = %d (0x%X)\n", *data,
 1112|       |              asn_length, asn_length));
 1113|       |#else
 1114|       |    /*
 1115|       |     * DEBUGMSGHEXTLI(("recv",data,(bufp-data)));
 1116|       |     * DEBUGMSG(("dumpH_recv","\n"));
 1117|       |     */
 1118|  3.67k|#endif
 1119|       |
 1120|  3.67k|#ifdef NETSNMP_WITH_OPAQUE_SPECIAL_TYPES
 1121|       |
 1122|  3.67k|    if ((asn_length > 2) && (*type == ASN_OPAQUE) && (*bufp == ASN_OPAQUE_TAG1)) {
  ------------------
  |  |   93|  3.36k|#define ASN_OPAQUE	(ASN_APPLICATION | 4)   /* changed so no conflict with other includes */
  |  |  ------------------
  |  |  |  |   91|  3.36k|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
                  if ((asn_length > 2) && (*type == ASN_OPAQUE) && (*bufp == ASN_OPAQUE_TAG1)) {
  ------------------
  |  |  131|    157|#define ASN_OPAQUE_TAG1 (ASN_CONTEXT | ASN_EXTENSION_ID)
  |  |  ------------------
  |  |  |  |   92|    157|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define ASN_OPAQUE_TAG1 (ASN_CONTEXT | ASN_EXTENSION_ID)
  |  |  ------------------
  |  |  |  |   99|    157|#define ASN_EXTENSION_ID    0x1FU
  |  |  ------------------
  ------------------
  |  Branch (1122:9): [True: 3.36k, False: 314]
  |  Branch (1122:29): [True: 157, False: 3.20k]
  |  Branch (1122:54): [True: 143, False: 14]
  ------------------
 1123|       |
 1124|       |        /*
 1125|       |         * check if 64-but counter 
 1126|       |         */
 1127|    143|        switch (*(bufp + 1)) {
 1128|      7|        case ASN_OPAQUE_COUNTER64:
  ------------------
  |  |  156|      7|#define ASN_OPAQUE_COUNTER64 (ASN_OPAQUE_TAG2 + ASN_APP_COUNTER64)
  |  |  ------------------
  |  |  |  |  136|      7|#define ASN_OPAQUE_TAG2 0x30U
  |  |  ------------------
  |  |               #define ASN_OPAQUE_COUNTER64 (ASN_OPAQUE_TAG2 + ASN_APP_COUNTER64)
  |  |  ------------------
  |  |  |  |  146|      7|#define ASN_APP_COUNTER64 (ASN_APPLICATION | 6)
  |  |  |  |  ------------------
  |  |  |  |  |  |   91|      7|#define ASN_APPLICATION     0x40U
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (1128:9): [True: 7, False: 136]
  ------------------
 1129|     20|        case ASN_OPAQUE_U64:
  ------------------
  |  |  192|     20|#define ASN_OPAQUE_U64 (ASN_OPAQUE_TAG2 + ASN_APP_U64)
  |  |  ------------------
  |  |  |  |  136|     20|#define ASN_OPAQUE_TAG2 0x30U
  |  |  ------------------
  |  |               #define ASN_OPAQUE_U64 (ASN_OPAQUE_TAG2 + ASN_APP_U64)
  |  |  ------------------
  |  |  |  |  150|     20|#define ASN_APP_U64 (ASN_APPLICATION | 11)
  |  |  |  |  ------------------
  |  |  |  |  |  |   91|     20|#define ASN_APPLICATION     0x40U
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (1129:9): [True: 13, False: 130]
  ------------------
 1130|     27|        case ASN_OPAQUE_FLOAT:
  ------------------
  |  |  165|     27|#define ASN_OPAQUE_FLOAT (ASN_OPAQUE_TAG2 + ASN_APP_FLOAT)
  |  |  ------------------
  |  |  |  |  136|     27|#define ASN_OPAQUE_TAG2 0x30U
  |  |  ------------------
  |  |               #define ASN_OPAQUE_FLOAT (ASN_OPAQUE_TAG2 + ASN_APP_FLOAT)
  |  |  ------------------
  |  |  |  |  147|     27|#define ASN_APP_FLOAT (ASN_APPLICATION | 8)
  |  |  |  |  ------------------
  |  |  |  |  |  |   91|     27|#define ASN_APPLICATION     0x40U
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (1130:9): [True: 7, False: 136]
  ------------------
 1131|     34|        case ASN_OPAQUE_DOUBLE:
  ------------------
  |  |  174|     34|#define ASN_OPAQUE_DOUBLE (ASN_OPAQUE_TAG2 + ASN_APP_DOUBLE)
  |  |  ------------------
  |  |  |  |  136|     34|#define ASN_OPAQUE_TAG2 0x30U
  |  |  ------------------
  |  |               #define ASN_OPAQUE_DOUBLE (ASN_OPAQUE_TAG2 + ASN_APP_DOUBLE)
  |  |  ------------------
  |  |  |  |  148|     34|#define ASN_APP_DOUBLE (ASN_APPLICATION | 9)
  |  |  |  |  ------------------
  |  |  |  |  |  |   91|     34|#define ASN_APPLICATION     0x40U
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (1131:9): [True: 7, False: 136]
  ------------------
 1132|    140|        case ASN_OPAQUE_I64:
  ------------------
  |  |  183|    140|#define ASN_OPAQUE_I64 (ASN_OPAQUE_TAG2 + ASN_APP_I64)
  |  |  ------------------
  |  |  |  |  136|    140|#define ASN_OPAQUE_TAG2 0x30U
  |  |  ------------------
  |  |               #define ASN_OPAQUE_I64 (ASN_OPAQUE_TAG2 + ASN_APP_I64)
  |  |  ------------------
  |  |  |  |  149|    140|#define ASN_APP_I64 (ASN_APPLICATION | 10)
  |  |  |  |  ------------------
  |  |  |  |  |  |   91|    140|#define ASN_APPLICATION     0x40U
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (1132:9): [True: 106, False: 37]
  ------------------
 1133|    140|            *type = *(bufp + 1);
 1134|    140|            break;
 1135|       |
 1136|      3|        default:
  ------------------
  |  Branch (1136:9): [True: 3, False: 140]
  ------------------
 1137|       |            /*
 1138|       |             * just an Opaque 
 1139|       |             */
 1140|      3|            *datalength = (int) asn_length;
 1141|      3|            return bufp;
 1142|    143|        }
 1143|       |        /*
 1144|       |         * value is encoded as special format 
 1145|       |         */
 1146|    140|        *datalength = (int) asn_length;
 1147|    140|        bufp = asn_parse_nlength(bufp+2, *datalength - 2, &asn_length);
 1148|    140|        if (NULL == bufp) {
  ------------------
  |  Branch (1148:13): [True: 7, False: 133]
  ------------------
 1149|      7|            _asn_short_err("parse opaque header", *datalength - 2, asn_length);
 1150|      7|            return NULL;
 1151|      7|        }
 1152|    140|    }
 1153|  3.66k|#endif                          /* NETSNMP_WITH_OPAQUE_SPECIAL_TYPES */
 1154|       |
 1155|  3.66k|    *datalength = (int) asn_length;
 1156|       |
 1157|  3.66k|    return bufp;
 1158|  3.67k|}
asn_parse_sequence:
 1177|  2.91k|{                               /* error message prefix */
 1178|  2.91k|    data = asn_parse_header(data, datalength, type);
 1179|  2.91k|    if (data && (*type != expected_type)) {
  ------------------
  |  Branch (1179:9): [True: 2.45k, False: 461]
  |  Branch (1179:17): [True: 168, False: 2.28k]
  ------------------
 1180|    168|        char            ebuf[128];
 1181|    168|        snprintf(ebuf, sizeof(ebuf),
 1182|    168|                 "%s header type %02X: s/b %02X", estr,
 1183|    168|                (u_char) * type, (u_char) expected_type);
 1184|    168|        ebuf[ sizeof(ebuf)-1 ] = 0;
 1185|    168|        ERROR_MSG(ebuf);
  ------------------
  |  |  190|    168|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 1186|    168|        return NULL;
 1187|    168|    }
 1188|  2.74k|    return data;
 1189|  2.91k|}
asn_parse_length:
 1302|    919|{
 1303|    919|    static const char *errpre = "parse length";
 1304|    919|    char            ebuf[128];
 1305|    919|    register u_char lengthbyte;
 1306|       |
 1307|    919|    if (!data || !length) {
  ------------------
  |  Branch (1307:9): [True: 0, False: 919]
  |  Branch (1307:18): [True: 0, False: 919]
  ------------------
 1308|      0|        ERROR_MSG("parse length: NULL pointer");
  ------------------
  |  |  190|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 1309|      0|        return NULL;
 1310|      0|    }
 1311|    919|    lengthbyte = *data;
 1312|       |
 1313|    919|    if (lengthbyte & ASN_LONG_LEN) {
  ------------------
  |  |   98|    919|#define ASN_LONG_LEN	    0x80U
  ------------------
  |  Branch (1313:9): [True: 919, False: 0]
  ------------------
 1314|    919|        lengthbyte &= ~ASN_LONG_LEN;    /* turn MSb off */
  ------------------
  |  |   98|    919|#define ASN_LONG_LEN	    0x80U
  ------------------
 1315|    919|        if (lengthbyte == 0) {
  ------------------
  |  Branch (1315:13): [True: 29, False: 890]
  ------------------
 1316|     29|            snprintf(ebuf, sizeof(ebuf),
 1317|     29|                     "%s: indefinite length not supported", errpre);
 1318|     29|            ebuf[ sizeof(ebuf)-1 ] = 0;
 1319|     29|            ERROR_MSG(ebuf);
  ------------------
  |  |  190|     29|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 1320|     29|            return NULL;
 1321|     29|        }
 1322|    890|        if (lengthbyte > sizeof(long)) {
  ------------------
  |  Branch (1322:13): [True: 37, False: 853]
  ------------------
 1323|     37|            snprintf(ebuf, sizeof(ebuf),
 1324|     37|                    "%s: data length %d > %lu not supported", errpre,
 1325|     37|                    lengthbyte, (unsigned long)sizeof(long));
 1326|     37|            ebuf[ sizeof(ebuf)-1 ] = 0;
 1327|     37|            ERROR_MSG(ebuf);
  ------------------
  |  |  190|     37|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 1328|     37|            return NULL;
 1329|     37|        }
 1330|    853|        data++;
 1331|    853|        *length = 0;            /* protect against short lengths */
 1332|  4.64k|        while (lengthbyte--) {
  ------------------
  |  Branch (1332:16): [True: 3.79k, False: 853]
  ------------------
 1333|  3.79k|            *length <<= 8;
 1334|  3.79k|            *length |= *data++;
 1335|  3.79k|        }
 1336|    853|        if ((long) *length < 0) {
  ------------------
  |  Branch (1336:13): [True: 63, False: 790]
  ------------------
 1337|     63|            snprintf(ebuf, sizeof(ebuf),
 1338|     63|                     "%s: negative data length %ld\n", errpre,
 1339|     63|                     (long) *length);
 1340|     63|            ebuf[ sizeof(ebuf)-1 ] = 0;
 1341|     63|            ERROR_MSG(ebuf);
  ------------------
  |  |  190|     63|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 1342|     63|            return NULL;
 1343|     63|        }
 1344|    790|        return data;
 1345|    853|    } else {                    /* short asnlength */
 1346|      0|        *length = (long) lengthbyte;
 1347|      0|        return data + 1;
 1348|      0|    }
 1349|    919|}
asn_parse_objid:
 1450|    832|{
 1451|    832|    static const char *errpre = "parse objid";
 1452|       |    /*
 1453|       |     * ASN.1 objid ::= 0x06 asnlength subidentifier {subidentifier}*
 1454|       |     * subidentifier ::= {leadingbyte}* lastbyte
 1455|       |     * leadingbyte ::= 1 7bitvalue
 1456|       |     * lastbyte ::= 0 7bitvalue
 1457|       |     */
 1458|    832|    register u_char *bufp = data;
 1459|    832|    register oid   *oidp = objid + 1;
 1460|    832|    register u_long subidentifier;
 1461|    832|    register long   length;
 1462|    832|    u_long          asn_length;
 1463|    832|    size_t          original_length = *objidlength;
 1464|       |
 1465|    832|    if (NULL == data || NULL == datalength || NULL == type || NULL == objid) {
  ------------------
  |  Branch (1465:9): [True: 0, False: 832]
  |  Branch (1465:25): [True: 0, False: 832]
  |  Branch (1465:47): [True: 0, False: 832]
  |  Branch (1465:63): [True: 0, False: 832]
  ------------------
 1466|      0|        ERROR_MSG("parse objid: NULL pointer");
  ------------------
  |  |  190|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 1467|      0|        return NULL;
 1468|      0|    }
 1469|       |
 1470|       |    /** need at least 2 bytes to work with: type, length (which might be 0)  */
 1471|    832|    if (*datalength < 2) {
  ------------------
  |  Branch (1471:9): [True: 8, False: 824]
  ------------------
 1472|      8|        _asn_short_err(errpre, *datalength, 2);
 1473|      8|        return NULL;
 1474|      8|    }
 1475|       |
 1476|    824|    *type = *bufp++;
 1477|    824|    if (*type != ASN_OBJECT_ID) {
  ------------------
  |  |   81|    824|#define ASN_OBJECT_ID	    0x06U
  ------------------
  |  Branch (1477:9): [True: 10, False: 814]
  ------------------
 1478|     10|        _asn_type_err(errpre, *type);
 1479|     10|        return NULL;
 1480|     10|    }
 1481|    814|    bufp = asn_parse_nlength(bufp, *datalength - 1, &asn_length);
 1482|    814|    if (NULL == bufp) {
  ------------------
  |  Branch (1482:9): [True: 115, False: 699]
  ------------------
 1483|    115|        _asn_short_err(errpre, *datalength - 1, asn_length);
 1484|    115|        return NULL;
 1485|    115|    }
 1486|       |
 1487|    699|    *datalength -= (int) asn_length + (bufp - data);
 1488|       |
 1489|    699|    DEBUGDUMPSETUP("recv", data, bufp - data + asn_length);
  ------------------
  |  |   85|    699|	do {if (_DBG_IF_) {__DBGDUMPSETUP(token,buf,len);} }while(0)
  |  |  ------------------
  |  |  |  |  146|    699|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 699, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPSETUP(token,buf,len);} }while(0)
  |  |  ------------------
  |  |  |  |  198|    699|        debugmsg("dumpx" token, "dumpx_%s:%*s", token, __DBGINDENT(), ""); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  173|    699|#define __DBGINDENT()      debug_indent_get()
  |  |  |  |  ------------------
  |  |  |  |  199|    699|        __DBGMSGHEX(("dumpx_" token,buf,len)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  171|    699|#define __DBGMSGHEX(x)     debugmsg_hex x
  |  |  |  |  ------------------
  |  |  |  |  200|    699|        if (debug_is_token_registered("dumpv" token) == SNMPERR_SUCCESS || \
  |  |  |  |  ------------------
  |  |  |  |  |  |  217|  1.39k|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (200:13): [True: 699, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  201|    699|            debug_is_token_registered("dumpv_" token) != SNMPERR_SUCCESS) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |  217|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (201:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  202|    699|            debugmsg("dumpx_" token,"\n"); \
  |  |  |  |  203|    699|        } else { \
  |  |  |  |  204|      0|            debugmsg("dumpx_" token,"  "); \
  |  |  |  |  205|      0|        } \
  |  |  |  |  206|    699|        debugmsg("dumpv" token, "dumpv_%s:%*s", token, __DBGINDENT(), "");
  |  |  |  |  ------------------
  |  |  |  |  |  |  173|    699|#define __DBGINDENT()      debug_indent_get()
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (85:60): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1490|       |
 1491|       |    /*
 1492|       |     * Handle invalid object identifier encodings of the form 06 00 robustly 
 1493|       |     */
 1494|    699|    if (asn_length == 0)
  ------------------
  |  Branch (1494:9): [True: 344, False: 355]
  ------------------
 1495|    344|        objid[0] = objid[1] = 0;
 1496|       |
 1497|    699|    length = asn_length;
 1498|    699|    (*objidlength)--;           /* account for expansion of first byte */
 1499|       |
 1500|  2.79k|    while (length > 0 && (*objidlength)-- > 0) {
  ------------------
  |  Branch (1500:12): [True: 2.11k, False: 682]
  |  Branch (1500:26): [True: 2.11k, False: 0]
  ------------------
 1501|  2.11k|        subidentifier = 0;
 1502|  2.61k|        do {                    /* shift and add in low order 7 bits */
 1503|  2.61k|            subidentifier =
 1504|  2.61k|                (subidentifier << 7) + (*(u_char *) bufp & ~ASN_BIT8);
  ------------------
  |  |  100|  2.61k|#define ASN_BIT8	    0x80U
  ------------------
 1505|  2.61k|            length--;
 1506|  2.61k|        } while ((*(u_char *) bufp++ & ASN_BIT8) && (length > 0));        /* last byte has high bit clear */
  ------------------
  |  |  100|  2.61k|#define ASN_BIT8	    0x80U
  ------------------
  |  Branch (1506:18): [True: 518, False: 2.09k]
  |  Branch (1506:53): [True: 506, False: 12]
  ------------------
 1507|       |
 1508|  2.11k|	if (length == 0) {
  ------------------
  |  Branch (1508:6): [True: 351, False: 1.76k]
  ------------------
 1509|    351|            u_char *last_byte = bufp - 1;
 1510|    351|            if (*last_byte & ASN_BIT8) {
  ------------------
  |  |  100|    351|#define ASN_BIT8	    0x80U
  ------------------
  |  Branch (1510:17): [True: 12, False: 339]
  ------------------
 1511|       |                /* last byte has high bit set -> wrong BER encoded OID */
 1512|     12|                ERROR_MSG("subidentifier syntax error");
  ------------------
  |  |  190|     12|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 1513|     12|                return NULL;
 1514|     12|            }
 1515|    351|        }
 1516|  2.09k|        if (subidentifier > MAX_SUBID) {
  ------------------
  |  |   18|  2.09k|#define MAX_SUBID   0xFFFFFFFFUL
  ------------------
  |  Branch (1516:13): [True: 5, False: 2.09k]
  ------------------
 1517|      5|            ERROR_MSG("subidentifier too large");
  ------------------
  |  |  190|      5|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 1518|      5|            return NULL;
 1519|      5|        }
 1520|  2.09k|        *oidp++ = (oid) subidentifier;
 1521|  2.09k|    }
 1522|       |
 1523|    682|    if (length || oidp < objid + 1) {
  ------------------
  |  Branch (1523:9): [True: 0, False: 682]
  |  Branch (1523:19): [True: 0, False: 682]
  ------------------
 1524|      0|        ERROR_MSG("OID length exceeds buffer size");
  ------------------
  |  |  190|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 1525|      0|        *objidlength = original_length;
 1526|      0|        return NULL;
 1527|      0|    }
 1528|       |
 1529|       |    /*
 1530|       |     * The first two subidentifiers are encoded into the first component
 1531|       |     * with the value (X * 40) + Y, where:
 1532|       |     *  X is the value of the first subidentifier.
 1533|       |     *  Y is the value of the second subidentifier.
 1534|       |     */
 1535|    682|    subidentifier = oidp - objid >= 2 ? objid[1] : 0;
  ------------------
  |  Branch (1535:21): [True: 338, False: 344]
  ------------------
 1536|    682|    if (subidentifier == 0x2B) {
  ------------------
  |  Branch (1536:9): [True: 21, False: 661]
  ------------------
 1537|     21|        objid[0] = 1;
 1538|     21|        objid[1] = 3;
 1539|    661|    } else {
 1540|    661|        if (subidentifier < 40) {
  ------------------
  |  Branch (1540:13): [True: 445, False: 216]
  ------------------
 1541|    445|            objid[0] = 0;
 1542|    445|            objid[1] = subidentifier;
 1543|    445|        } else if (subidentifier < 80) {
  ------------------
  |  Branch (1543:20): [True: 79, False: 137]
  ------------------
 1544|     79|            objid[0] = 1;
 1545|     79|            objid[1] = subidentifier - 40;
 1546|    137|        } else {
 1547|    137|            objid[0] = 2;
 1548|    137|            objid[1] = subidentifier - 80;
 1549|    137|        }
 1550|    661|    }
 1551|       |
 1552|    682|    *objidlength = (int) (oidp - objid);
 1553|       |
 1554|    682|    DEBUGMSG(("dumpv_recv", "  ObjID: "));
  ------------------
  |  |   63|    682|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  146|    682|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 682, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (63:67): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1555|    682|    DEBUGMSGOID(("dumpv_recv", objid, *objidlength));
  ------------------
  |  |   69|    682|#define DEBUGMSGOID(x)     do {if (_DBG_IF_) {__DBGMSGOID(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|    682|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 682, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGOID(x)     do {if (_DBG_IF_) {__DBGMSGOID(x);} }while(0)
  |  |  ------------------
  |  |  |  |  167|    682|#define __DBGMSGOID(x)     debugmsg_oid x
  |  |  ------------------
  |  |  |  Branch (69:71): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1556|    682|    DEBUGMSG(("dumpv_recv", "\n"));
  ------------------
  |  |   63|    682|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  146|    682|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 682, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (63:67): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1557|    682|    return bufp;
 1558|    682|}
asn_parse_bitstring:
 1827|     11|{
 1828|       |    /*
 1829|       |     * bitstring ::= 0x03 asnlength unused {byte}*
 1830|       |     */
 1831|     11|    static const char *errpre = "parse bitstring";
 1832|     11|    register u_char *bufp = data;
 1833|     11|    u_long          asn_length;
 1834|       |
 1835|     11|    if (NULL == data || NULL == datalength || NULL == type ||
  ------------------
  |  Branch (1835:9): [True: 0, False: 11]
  |  Branch (1835:25): [True: 0, False: 11]
  |  Branch (1835:47): [True: 0, False: 11]
  ------------------
 1836|     11|        NULL == str || NULL == strlength) {
  ------------------
  |  Branch (1836:9): [True: 0, False: 11]
  |  Branch (1836:24): [True: 0, False: 11]
  ------------------
 1837|      0|        ERROR_MSG("parse bitstring: NULL pointer");
  ------------------
  |  |  190|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 1838|      0|        return NULL;
 1839|      0|    }
 1840|       |
 1841|       |    /** need at least 2 bytes to work with: type, length (which might be 0)  */
 1842|     11|    if (*datalength < 2) {
  ------------------
  |  Branch (1842:9): [True: 0, False: 11]
  ------------------
 1843|      0|        _asn_short_err(errpre, *datalength, 2);
 1844|      0|        return NULL;
 1845|      0|    }
 1846|       |
 1847|     11|    *type = *bufp++;
 1848|     11|    if (*type != ASN_BIT_STR) {
  ------------------
  |  |   77|     11|#define ASN_BIT_STR	    0x03U
  ------------------
  |  Branch (1848:9): [True: 0, False: 11]
  ------------------
 1849|      0|        _asn_type_err(errpre, *type);
 1850|      0|        return NULL;
 1851|      0|    }
 1852|       |
 1853|     11|    bufp = asn_parse_nlength(bufp, *datalength - 1, &asn_length);
 1854|     11|    if (NULL == bufp) {
  ------------------
  |  Branch (1854:9): [True: 0, False: 11]
  ------------------
 1855|      0|        _asn_short_err(errpre, *datalength - 1, asn_length);
 1856|      0|        return NULL;
 1857|      0|    }
 1858|       |
 1859|     11|    if ((size_t) asn_length > *strlength) {
  ------------------
  |  Branch (1859:9): [True: 0, False: 11]
  ------------------
 1860|      0|        _asn_length_err(errpre, (size_t) asn_length, *strlength);
 1861|      0|        return NULL;
 1862|      0|    }
 1863|     11|    if (_asn_bitstring_check(errpre, asn_length, *bufp))
  ------------------
  |  Branch (1863:9): [True: 4, False: 7]
  ------------------
 1864|      4|        return NULL;
 1865|       |
 1866|      7|    DEBUGDUMPSETUP("recv", data, bufp - data);
  ------------------
  |  |   85|      7|	do {if (_DBG_IF_) {__DBGDUMPSETUP(token,buf,len);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      7|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 7, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPSETUP(token,buf,len);} }while(0)
  |  |  ------------------
  |  |  |  |  198|      7|        debugmsg("dumpx" token, "dumpx_%s:%*s", token, __DBGINDENT(), ""); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  173|      7|#define __DBGINDENT()      debug_indent_get()
  |  |  |  |  ------------------
  |  |  |  |  199|      7|        __DBGMSGHEX(("dumpx_" token,buf,len)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  171|      7|#define __DBGMSGHEX(x)     debugmsg_hex x
  |  |  |  |  ------------------
  |  |  |  |  200|      7|        if (debug_is_token_registered("dumpv" token) == SNMPERR_SUCCESS || \
  |  |  |  |  ------------------
  |  |  |  |  |  |  217|     14|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (200:13): [True: 7, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  201|      7|            debug_is_token_registered("dumpv_" token) != SNMPERR_SUCCESS) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |  217|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (201:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  202|      7|            debugmsg("dumpx_" token,"\n"); \
  |  |  |  |  203|      7|        } else { \
  |  |  |  |  204|      0|            debugmsg("dumpx_" token,"  "); \
  |  |  |  |  205|      0|        } \
  |  |  |  |  206|      7|        debugmsg("dumpv" token, "dumpv_%s:%*s", token, __DBGINDENT(), "");
  |  |  |  |  ------------------
  |  |  |  |  |  |  173|      7|#define __DBGINDENT()      debug_indent_get()
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (85:60): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1867|      7|    DEBUGMSG(("dumpv_recv", "  Bitstring: "));
  ------------------
  |  |   63|      7|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  146|      7|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 7, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (63:67): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1868|      7|    DEBUGMSGHEX(("dumpv_recv", data, asn_length));
  ------------------
  |  |   73|      7|#define DEBUGMSGHEX(x)     do {if (_DBG_IF_) {__DBGMSGHEX(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      7|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 7, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGHEX(x)     do {if (_DBG_IF_) {__DBGMSGHEX(x);} }while(0)
  |  |  ------------------
  |  |  |  |  171|      7|#define __DBGMSGHEX(x)     debugmsg_hex x
  |  |  ------------------
  |  |  |  Branch (73:71): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1869|      7|    DEBUGMSG(("dumpv_recv", "\n"));
  ------------------
  |  |   63|      7|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  146|      7|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 7, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (63:67): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1870|       |
 1871|      7|    memmove(str, bufp, asn_length);
 1872|      7|    *strlength = (int) asn_length;
 1873|      7|    *datalength -= (int) asn_length + (bufp - data);
 1874|      7|    return bufp + asn_length;
 1875|     11|}
asn_parse_unsigned_int64:
 1959|    110|{
 1960|       |    /*
 1961|       |     * ASN.1 integer ::= 0x02 asnlength byte {byte}*
 1962|       |     */
 1963|    110|    static const char *errpre = "parse uint64";
 1964|    110|    const int       uint64sizelimit = (4 * 2) + 1;
 1965|    110|    register u_char *bufp = data;
 1966|    110|    u_long          asn_length;
 1967|    110|    register u_long low = 0, high = 0;
 1968|       |
 1969|    110|    if (countersize != sizeof(struct counter64)) {
  ------------------
  |  Branch (1969:9): [True: 0, False: 110]
  ------------------
 1970|      0|        _asn_size_err(errpre, countersize, sizeof(struct counter64));
 1971|      0|        return NULL;
 1972|      0|    }
 1973|       |
 1974|    110|    if (NULL == data || NULL == datalength || NULL == type || NULL == cp) {
  ------------------
  |  Branch (1974:9): [True: 0, False: 110]
  |  Branch (1974:25): [True: 0, False: 110]
  |  Branch (1974:47): [True: 0, False: 110]
  |  Branch (1974:63): [True: 0, False: 110]
  ------------------
 1975|      0|        ERROR_MSG("parse uint64: NULL pointer");
  ------------------
  |  |  190|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 1976|      0|        return NULL;
 1977|      0|    }
 1978|       |
 1979|       |    /** need at least 2 bytes to work with: type, length (which might be 0)  */
 1980|    110|    if (*datalength < 2) {
  ------------------
  |  Branch (1980:9): [True: 0, False: 110]
  ------------------
 1981|      0|        _asn_short_err(errpre, *datalength, 2);
 1982|      0|        return NULL;
 1983|      0|    }
 1984|       |
 1985|    110|    *type = *bufp++;
 1986|    110|    if (*type != ASN_COUNTER64
  ------------------
  |  |   99|    220|#define ASN_COUNTER64   (ASN_APPLICATION | 6)
  |  |  ------------------
  |  |  |  |   91|    110|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (1986:9): [True: 20, False: 90]
  ------------------
 1987|    110|#ifdef NETSNMP_WITH_OPAQUE_SPECIAL_TYPES
 1988|    110|            && *type != ASN_OPAQUE
  ------------------
  |  |   93|     20|#define ASN_OPAQUE	(ASN_APPLICATION | 4)   /* changed so no conflict with other includes */
  |  |  ------------------
  |  |  |  |   91|     20|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (1988:16): [True: 2, False: 18]
  ------------------
 1989|    110|#endif
 1990|    110|            ) {
 1991|      2|        _asn_type_err(errpre, *type);
 1992|      2|        return NULL;
 1993|      2|    }
 1994|    108|    bufp = asn_parse_nlength(bufp, *datalength - 1, &asn_length);
 1995|    108|    if (NULL == bufp) {
  ------------------
  |  Branch (1995:9): [True: 0, False: 108]
  ------------------
 1996|      0|        _asn_short_err(errpre, *datalength - 1, asn_length);
 1997|      0|        return NULL;
 1998|      0|    }
 1999|       |
 2000|    108|    DEBUGDUMPSETUP("recv", data, bufp - data + asn_length);
  ------------------
  |  |   85|    108|	do {if (_DBG_IF_) {__DBGDUMPSETUP(token,buf,len);} }while(0)
  |  |  ------------------
  |  |  |  |  146|    108|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 108, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPSETUP(token,buf,len);} }while(0)
  |  |  ------------------
  |  |  |  |  198|    108|        debugmsg("dumpx" token, "dumpx_%s:%*s", token, __DBGINDENT(), ""); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  173|    108|#define __DBGINDENT()      debug_indent_get()
  |  |  |  |  ------------------
  |  |  |  |  199|    108|        __DBGMSGHEX(("dumpx_" token,buf,len)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  171|    108|#define __DBGMSGHEX(x)     debugmsg_hex x
  |  |  |  |  ------------------
  |  |  |  |  200|    108|        if (debug_is_token_registered("dumpv" token) == SNMPERR_SUCCESS || \
  |  |  |  |  ------------------
  |  |  |  |  |  |  217|    216|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (200:13): [True: 108, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  201|    108|            debug_is_token_registered("dumpv_" token) != SNMPERR_SUCCESS) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |  217|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (201:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  202|    108|            debugmsg("dumpx_" token,"\n"); \
  |  |  |  |  203|    108|        } else { \
  |  |  |  |  204|      0|            debugmsg("dumpx_" token,"  "); \
  |  |  |  |  205|      0|        } \
  |  |  |  |  206|    108|        debugmsg("dumpv" token, "dumpv_%s:%*s", token, __DBGINDENT(), "");
  |  |  |  |  ------------------
  |  |  |  |  |  |  173|    108|#define __DBGINDENT()      debug_indent_get()
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (85:60): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2001|    108|#ifdef NETSNMP_WITH_OPAQUE_SPECIAL_TYPES
 2002|       |    /** need at least 2 bytes: ASN_OPAQUE_TAG1 and ASN_OPAQUE_<type> */
 2003|    108|    if ((*type == ASN_OPAQUE) && (asn_length < 2)) {
  ------------------
  |  |   93|    108|#define ASN_OPAQUE	(ASN_APPLICATION | 4)   /* changed so no conflict with other includes */
  |  |  ------------------
  |  |  |  |   91|    108|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (2003:9): [True: 18, False: 90]
  |  Branch (2003:34): [True: 0, False: 18]
  ------------------
 2004|      0|        _asn_short_err(errpre, asn_length, 2);
 2005|      0|        return NULL;
 2006|      0|    }
 2007|       |
 2008|       |    /*
 2009|       |     * 64 bit counters as opaque 
 2010|       |     */
 2011|    108|    if ((*type == ASN_OPAQUE) &&
  ------------------
  |  |   93|    108|#define ASN_OPAQUE	(ASN_APPLICATION | 4)   /* changed so no conflict with other includes */
  |  |  ------------------
  |  |  |  |   91|    108|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (2011:9): [True: 18, False: 90]
  ------------------
 2012|    108|        (asn_length <= ASN_OPAQUE_COUNTER64_MX_BER_LEN) &&
  ------------------
  |  |  160|     18|#define ASN_OPAQUE_COUNTER64_MX_BER_LEN 12
  ------------------
  |  Branch (2012:9): [True: 17, False: 1]
  ------------------
 2013|    108|        (*bufp == ASN_OPAQUE_TAG1) &&
  ------------------
  |  |  131|     17|#define ASN_OPAQUE_TAG1 (ASN_CONTEXT | ASN_EXTENSION_ID)
  |  |  ------------------
  |  |  |  |   92|     17|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define ASN_OPAQUE_TAG1 (ASN_CONTEXT | ASN_EXTENSION_ID)
  |  |  ------------------
  |  |  |  |   99|     17|#define ASN_EXTENSION_ID    0x1FU
  |  |  ------------------
  ------------------
  |  Branch (2013:9): [True: 17, False: 0]
  ------------------
 2014|    108|        ((*(bufp + 1) == ASN_OPAQUE_COUNTER64) ||
  ------------------
  |  |  156|     17|#define ASN_OPAQUE_COUNTER64 (ASN_OPAQUE_TAG2 + ASN_APP_COUNTER64)
  |  |  ------------------
  |  |  |  |  136|     17|#define ASN_OPAQUE_TAG2 0x30U
  |  |  ------------------
  |  |               #define ASN_OPAQUE_COUNTER64 (ASN_OPAQUE_TAG2 + ASN_APP_COUNTER64)
  |  |  ------------------
  |  |  |  |  146|     17|#define ASN_APP_COUNTER64 (ASN_APPLICATION | 6)
  |  |  |  |  ------------------
  |  |  |  |  |  |   91|     17|#define ASN_APPLICATION     0x40U
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (2014:10): [True: 5, False: 12]
  ------------------
 2015|     17|         (*(bufp + 1) == ASN_OPAQUE_U64))) {
  ------------------
  |  |  192|     12|#define ASN_OPAQUE_U64 (ASN_OPAQUE_TAG2 + ASN_APP_U64)
  |  |  ------------------
  |  |  |  |  136|     12|#define ASN_OPAQUE_TAG2 0x30U
  |  |  ------------------
  |  |               #define ASN_OPAQUE_U64 (ASN_OPAQUE_TAG2 + ASN_APP_U64)
  |  |  ------------------
  |  |  |  |  150|     12|#define ASN_APP_U64 (ASN_APPLICATION | 11)
  |  |  |  |  ------------------
  |  |  |  |  |  |   91|     12|#define ASN_APPLICATION     0x40U
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (2015:10): [True: 12, False: 0]
  ------------------
 2016|       |        /*
 2017|       |         * change type to Counter64 or U64 
 2018|       |         */
 2019|     17|        *type = *(bufp + 1);
 2020|       |        /*
 2021|       |         * value is encoded as special format 
 2022|       |         */
 2023|     17|        *datalength = asn_length;
 2024|     17|        bufp = asn_parse_nlength(bufp+2, *datalength - 2, &asn_length);
 2025|     17|        if (NULL == bufp) {
  ------------------
  |  Branch (2025:13): [True: 0, False: 17]
  ------------------
 2026|      0|            _asn_short_err("parse opaque uint64", *datalength - 2, asn_length);
 2027|      0|            return NULL;
 2028|      0|        }
 2029|     17|    }
 2030|    108|#endif                          /* NETSNMP_WITH_OPAQUE_SPECIAL_TYPES */
 2031|    108|    if (((int) asn_length > uint64sizelimit) ||
  ------------------
  |  Branch (2031:9): [True: 2, False: 106]
  ------------------
 2032|    108|        (((int) asn_length == uint64sizelimit) && *bufp != 0x00)) {
  ------------------
  |  Branch (2032:10): [True: 21, False: 85]
  |  Branch (2032:51): [True: 2, False: 19]
  ------------------
 2033|      4|        _asn_length_err(errpre, (size_t) asn_length, uint64sizelimit);
 2034|      4|        return NULL;
 2035|      4|    }
 2036|    104|    *datalength -= (int) asn_length + (bufp - data);
 2037|    806|    while (asn_length--) {
  ------------------
  |  Branch (2037:12): [True: 702, False: 104]
  ------------------
 2038|    702|        high = ((0x00FFFFFF & high) << 8) | ((low & 0xFF000000U) >> 24);
 2039|    702|        low = ((low & 0x00FFFFFF) << 8) | *bufp++;
 2040|    702|    }
 2041|       |
 2042|    104|    CHECK_OVERFLOW_U(high,6);
  ------------------
  |  |  224|    104|#define CHECK_OVERFLOW_U(x,y) do {                                      \
  |  |  225|    104|        if (x > UINT32_MAX) {                                           \
  |  |  ------------------
  |  |  |  Branch (225:13): [True: 0, False: 104]
  |  |  ------------------
  |  |  226|      0|            x &= 0xffffffff;                                            \
  |  |  227|      0|            DEBUGMSG(("asn","truncating unsigned value to 32 bits (%d)\n",y)); \
  |  |  ------------------
  |  |  |  |   63|      0|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (63:67): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  228|      0|        }                                                               \
  |  |  229|    104|    } while(0)
  |  |  ------------------
  |  |  |  Branch (229:13): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2043|    104|    CHECK_OVERFLOW_U(low,6);
  ------------------
  |  |  224|    104|#define CHECK_OVERFLOW_U(x,y) do {                                      \
  |  |  225|    104|        if (x > UINT32_MAX) {                                           \
  |  |  ------------------
  |  |  |  Branch (225:13): [True: 0, False: 104]
  |  |  ------------------
  |  |  226|      0|            x &= 0xffffffff;                                            \
  |  |  227|      0|            DEBUGMSG(("asn","truncating unsigned value to 32 bits (%d)\n",y)); \
  |  |  ------------------
  |  |  |  |   63|      0|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (63:67): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  228|      0|        }                                                               \
  |  |  229|    104|    } while(0)
  |  |  ------------------
  |  |  |  Branch (229:13): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2044|       |
 2045|    104|    cp->low = low;
 2046|    104|    cp->high = high;
 2047|       |
 2048|    104|    DEBUGIF("dumpv_recv") {
  ------------------
  |  |  147|    104|#define DEBUGIF(x)         if (_DBG_IF_ && debug_is_token_registered(x) == SNMPERR_SUCCESS)
  |  |  ------------------
  |  |  |  |  146|    208|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 104, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGIF(x)         if (_DBG_IF_ && debug_is_token_registered(x) == SNMPERR_SUCCESS)
  |  |  ------------------
  |  |  |  |  217|    104|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  ------------------
  |  |  |  Branch (147:44): [True: 104, False: 0]
  |  |  ------------------
  ------------------
 2049|    104|        char            i64buf[I64CHARSZ + 1];
 2050|    104|        printU64(i64buf, cp);
 2051|    104|        DEBUGMSG(("dumpv_recv", "Counter64: %s\n", i64buf));
  ------------------
  |  |   63|    104|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  146|    104|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 104, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (63:67): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2052|    104|    }
 2053|       |
 2054|    104|    return bufp;
 2055|    108|}
asn_parse_signed_int64:
 2232|    108|{
 2233|    108|    static const char *errpre = "parse int64";
 2234|    108|    const int       int64sizelimit = (4 * 2) + 1;
 2235|    108|    char            ebuf[128];
 2236|    108|    register u_char *bufp = data;
 2237|    108|    u_long          asn_length;
 2238|    108|    register u_int  low = 0, high = 0;
 2239|       |
 2240|    108|    if (countersize != sizeof(struct counter64)) {
  ------------------
  |  Branch (2240:9): [True: 0, False: 108]
  ------------------
 2241|      0|        _asn_size_err(errpre, countersize, sizeof(struct counter64));
 2242|      0|        return NULL;
 2243|      0|    }
 2244|       |
 2245|    108|    if (NULL == data || NULL == datalength || NULL == type || NULL == cp) {
  ------------------
  |  Branch (2245:9): [True: 0, False: 108]
  |  Branch (2245:25): [True: 0, False: 108]
  |  Branch (2245:47): [True: 0, False: 108]
  |  Branch (2245:63): [True: 0, False: 108]
  ------------------
 2246|      0|        ERROR_MSG("parse int64: NULL pointer");
  ------------------
  |  |  190|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 2247|      0|        return NULL;
 2248|      0|    }
 2249|       |
 2250|       |    /** need at least 2 bytes to work with: type, length (which might be 0) */
 2251|    108|    if (*datalength < 2) {
  ------------------
  |  Branch (2251:9): [True: 0, False: 108]
  ------------------
 2252|      0|        _asn_short_err(errpre, *datalength, 2);
 2253|      0|        return NULL;
 2254|      0|    }
 2255|       |
 2256|    108|    *type = *bufp++;
 2257|    108|    bufp = asn_parse_nlength(bufp, *datalength - 1, &asn_length);
 2258|    108|    if (NULL == bufp) {
  ------------------
  |  Branch (2258:9): [True: 0, False: 108]
  ------------------
 2259|      0|        _asn_short_err(errpre, *datalength - 1, asn_length);
 2260|      0|        return NULL;
 2261|      0|    }
 2262|       |
 2263|       |    /** need at least 2 bytes: ASN_OPAQUE_TAG1 and ASN_OPAQUE_I64 */
 2264|    108|    if (asn_length < 2) {
  ------------------
  |  Branch (2264:9): [True: 3, False: 105]
  ------------------
 2265|      3|        _asn_short_err(errpre, asn_length, 2);
 2266|      3|        return NULL;
 2267|      3|    }
 2268|       |
 2269|    105|    DEBUGDUMPSETUP("recv", data, bufp - data + asn_length);
  ------------------
  |  |   85|    105|	do {if (_DBG_IF_) {__DBGDUMPSETUP(token,buf,len);} }while(0)
  |  |  ------------------
  |  |  |  |  146|    105|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 105, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPSETUP(token,buf,len);} }while(0)
  |  |  ------------------
  |  |  |  |  198|    105|        debugmsg("dumpx" token, "dumpx_%s:%*s", token, __DBGINDENT(), ""); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  173|    105|#define __DBGINDENT()      debug_indent_get()
  |  |  |  |  ------------------
  |  |  |  |  199|    105|        __DBGMSGHEX(("dumpx_" token,buf,len)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  171|    105|#define __DBGMSGHEX(x)     debugmsg_hex x
  |  |  |  |  ------------------
  |  |  |  |  200|    105|        if (debug_is_token_registered("dumpv" token) == SNMPERR_SUCCESS || \
  |  |  |  |  ------------------
  |  |  |  |  |  |  217|    210|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (200:13): [True: 105, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  201|    105|            debug_is_token_registered("dumpv_" token) != SNMPERR_SUCCESS) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |  217|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (201:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  202|    105|            debugmsg("dumpx_" token,"\n"); \
  |  |  |  |  203|    105|        } else { \
  |  |  |  |  204|      0|            debugmsg("dumpx_" token,"  "); \
  |  |  |  |  205|      0|        } \
  |  |  |  |  206|    105|        debugmsg("dumpv" token, "dumpv_%s:%*s", token, __DBGINDENT(), "");
  |  |  |  |  ------------------
  |  |  |  |  |  |  173|    105|#define __DBGINDENT()      debug_indent_get()
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (85:60): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2270|    105|    if ((*type == ASN_OPAQUE) &&
  ------------------
  |  |   93|    105|#define ASN_OPAQUE	(ASN_APPLICATION | 4)   /* changed so no conflict with other includes */
  |  |  ------------------
  |  |  |  |   91|    105|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (2270:9): [True: 102, False: 3]
  ------------------
 2271|    105|        (asn_length <= ASN_OPAQUE_COUNTER64_MX_BER_LEN) &&
  ------------------
  |  |  160|    102|#define ASN_OPAQUE_COUNTER64_MX_BER_LEN 12
  ------------------
  |  Branch (2271:9): [True: 100, False: 2]
  ------------------
 2272|    105|        (*bufp == ASN_OPAQUE_TAG1) && (*(bufp + 1) == ASN_OPAQUE_I64)) {
  ------------------
  |  |  131|    100|#define ASN_OPAQUE_TAG1 (ASN_CONTEXT | ASN_EXTENSION_ID)
  |  |  ------------------
  |  |  |  |   92|    100|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define ASN_OPAQUE_TAG1 (ASN_CONTEXT | ASN_EXTENSION_ID)
  |  |  ------------------
  |  |  |  |   99|    100|#define ASN_EXTENSION_ID    0x1FU
  |  |  ------------------
  ------------------
                      (*bufp == ASN_OPAQUE_TAG1) && (*(bufp + 1) == ASN_OPAQUE_I64)) {
  ------------------
  |  |  183|    100|#define ASN_OPAQUE_I64 (ASN_OPAQUE_TAG2 + ASN_APP_I64)
  |  |  ------------------
  |  |  |  |  136|    100|#define ASN_OPAQUE_TAG2 0x30U
  |  |  ------------------
  |  |               #define ASN_OPAQUE_I64 (ASN_OPAQUE_TAG2 + ASN_APP_I64)
  |  |  ------------------
  |  |  |  |  149|    100|#define ASN_APP_I64 (ASN_APPLICATION | 10)
  |  |  |  |  ------------------
  |  |  |  |  |  |   91|    100|#define ASN_APPLICATION     0x40U
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (2272:9): [True: 100, False: 0]
  |  Branch (2272:39): [True: 100, False: 0]
  ------------------
 2273|       |        /*
 2274|       |         * change type to Int64 
 2275|       |         */
 2276|    100|        *type = *(bufp + 1);
 2277|       |        /*
 2278|       |         * value is encoded as special format 
 2279|       |         */
 2280|    100|        *datalength = asn_length;
 2281|    100|        bufp = asn_parse_nlength(bufp+2, *datalength - 2, &asn_length);
 2282|    100|        if (NULL == bufp) {
  ------------------
  |  Branch (2282:13): [True: 0, False: 100]
  ------------------
 2283|      0|            _asn_short_err("parse opaque int64", *datalength - 2, asn_length);
 2284|      0|            return NULL;
 2285|      0|        }
 2286|    100|    }
 2287|       |    /*
 2288|       |     * this should always have been true until snmp gets int64 PDU types 
 2289|       |     */
 2290|      5|    else {
 2291|      5|        snprintf(ebuf, sizeof(ebuf),
 2292|      5|                "%s: wrong type: %d, len %d, buf bytes (%02X,%02X)",
 2293|      5|                errpre, *type, (int) asn_length, *bufp, *(bufp + 1));
 2294|      5|        ebuf[ sizeof(ebuf)-1 ] = 0;
 2295|      5|        ERROR_MSG(ebuf);
  ------------------
  |  |  190|      5|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 2296|      5|        return NULL;
 2297|      5|    }
 2298|    100|    if (((int) asn_length > int64sizelimit) ||
  ------------------
  |  Branch (2298:9): [True: 0, False: 100]
  ------------------
 2299|    100|        (((int) asn_length == int64sizelimit) && *bufp != 0x00)) {
  ------------------
  |  Branch (2299:10): [True: 10, False: 90]
  |  Branch (2299:50): [True: 6, False: 4]
  ------------------
 2300|      6|        _asn_length_err(errpre, (size_t) asn_length, int64sizelimit);
 2301|      6|        return NULL;
 2302|      6|    }
 2303|     94|    *datalength -= (int) asn_length + (bufp - data);
 2304|     94|    if ((asn_length > 0) && (*bufp & 0x80)) {
  ------------------
  |  Branch (2304:9): [True: 92, False: 2]
  |  Branch (2304:29): [True: 58, False: 34]
  ------------------
 2305|     58|        low = 0xFFFFFFFFU;   /* first byte bit 1 means start the data with 1s */
 2306|     58|        high = 0xFFFFFF;
 2307|     58|    }
 2308|       |
 2309|    742|    while (asn_length--) {
  ------------------
  |  Branch (2309:12): [True: 648, False: 94]
  ------------------
 2310|    648|        high = ((0x00FFFFFF & high) << 8) | ((low & 0xFF000000U) >> 24);
 2311|    648|        low = ((low & 0x00FFFFFF) << 8) | *bufp++;
 2312|    648|    }
 2313|       |
 2314|     94|    CHECK_OVERFLOW_U(high,8);
  ------------------
  |  |  224|     94|#define CHECK_OVERFLOW_U(x,y) do {                                      \
  |  |  225|     94|        if (x > UINT32_MAX) {                                           \
  |  |  ------------------
  |  |  |  Branch (225:13): [True: 0, False: 94]
  |  |  ------------------
  |  |  226|      0|            x &= 0xffffffff;                                            \
  |  |  227|      0|            DEBUGMSG(("asn","truncating unsigned value to 32 bits (%d)\n",y)); \
  |  |  ------------------
  |  |  |  |   63|      0|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (63:67): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  228|      0|        }                                                               \
  |  |  229|     94|    } while(0)
  |  |  ------------------
  |  |  |  Branch (229:13): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2315|     94|    CHECK_OVERFLOW_U(low,8);
  ------------------
  |  |  224|     94|#define CHECK_OVERFLOW_U(x,y) do {                                      \
  |  |  225|     94|        if (x > UINT32_MAX) {                                           \
  |  |  ------------------
  |  |  |  Branch (225:13): [True: 0, False: 94]
  |  |  ------------------
  |  |  226|      0|            x &= 0xffffffff;                                            \
  |  |  227|      0|            DEBUGMSG(("asn","truncating unsigned value to 32 bits (%d)\n",y)); \
  |  |  ------------------
  |  |  |  |   63|      0|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (63:67): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  228|      0|        }                                                               \
  |  |  229|     94|    } while(0)
  |  |  ------------------
  |  |  |  Branch (229:13): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2316|       |
 2317|     94|    cp->low = low;
 2318|     94|    cp->high = high;
 2319|       |
 2320|     94|    DEBUGIF("dumpv_recv") {
  ------------------
  |  |  147|     94|#define DEBUGIF(x)         if (_DBG_IF_ && debug_is_token_registered(x) == SNMPERR_SUCCESS)
  |  |  ------------------
  |  |  |  |  146|    188|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 94, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGIF(x)         if (_DBG_IF_ && debug_is_token_registered(x) == SNMPERR_SUCCESS)
  |  |  ------------------
  |  |  |  |  217|     94|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  ------------------
  |  |  |  Branch (147:44): [True: 94, False: 0]
  |  |  ------------------
  ------------------
 2321|     94|        char            i64buf[I64CHARSZ + 1];
 2322|     94|        printI64(i64buf, cp);
 2323|     94|        DEBUGMSG(("dumpv_recv", "Integer64: %s\n", i64buf));
  ------------------
  |  |   63|     94|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  146|     94|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 94, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (63:67): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2324|     94|    }
 2325|       |
 2326|     94|    return bufp;
 2327|    100|}
asn_parse_float:
 2450|     15|{
 2451|     15|    static const char *errpre = "parse float";
 2452|     15|    register u_char *bufp = data;
 2453|     15|    u_long          asn_length;
 2454|     15|    union {
 2455|     15|        float           floatVal;
 2456|     15|        long            longVal;
 2457|     15|        u_char          c[sizeof(float)];
 2458|     15|    } fu;
 2459|       |
 2460|     15|    if (floatsize != sizeof(float)) {
  ------------------
  |  Branch (2460:9): [True: 0, False: 15]
  ------------------
 2461|      0|        _asn_size_err("parse float", floatsize, sizeof(float));
 2462|      0|        return NULL;
 2463|      0|    }
 2464|       |
 2465|     15|    if (NULL == data || NULL == datalength || NULL == type || NULL == floatp) {
  ------------------
  |  Branch (2465:9): [True: 0, False: 15]
  |  Branch (2465:25): [True: 0, False: 15]
  |  Branch (2465:47): [True: 0, False: 15]
  |  Branch (2465:63): [True: 0, False: 15]
  ------------------
 2466|      0|        ERROR_MSG("parse float: NULL pointer");
  ------------------
  |  |  190|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 2467|      0|        return NULL;
 2468|      0|    }
 2469|       |
 2470|       |    /** need at least 2 bytes to work with: type, length (which might be 0)  */
 2471|     15|    if (*datalength < 2) {
  ------------------
  |  Branch (2471:9): [True: 0, False: 15]
  ------------------
 2472|      0|        _asn_short_err(errpre, *datalength, 2);
 2473|      0|        return NULL;
 2474|      0|    }
 2475|       |
 2476|     15|    *type = *bufp++;
 2477|     15|    bufp = asn_parse_nlength(bufp, *datalength - 1, &asn_length);
 2478|     15|    if (NULL == bufp) {
  ------------------
  |  Branch (2478:9): [True: 0, False: 15]
  ------------------
 2479|      0|        _asn_short_err(errpre, *datalength - 1, asn_length);
 2480|      0|        return NULL;
 2481|      0|    }
 2482|       |
 2483|     15|    DEBUGDUMPSETUP("recv", data, bufp - data + asn_length);
  ------------------
  |  |   85|     15|	do {if (_DBG_IF_) {__DBGDUMPSETUP(token,buf,len);} }while(0)
  |  |  ------------------
  |  |  |  |  146|     15|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 15, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPSETUP(token,buf,len);} }while(0)
  |  |  ------------------
  |  |  |  |  198|     15|        debugmsg("dumpx" token, "dumpx_%s:%*s", token, __DBGINDENT(), ""); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  173|     15|#define __DBGINDENT()      debug_indent_get()
  |  |  |  |  ------------------
  |  |  |  |  199|     15|        __DBGMSGHEX(("dumpx_" token,buf,len)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  171|     15|#define __DBGMSGHEX(x)     debugmsg_hex x
  |  |  |  |  ------------------
  |  |  |  |  200|     15|        if (debug_is_token_registered("dumpv" token) == SNMPERR_SUCCESS || \
  |  |  |  |  ------------------
  |  |  |  |  |  |  217|     30|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (200:13): [True: 15, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  201|     15|            debug_is_token_registered("dumpv_" token) != SNMPERR_SUCCESS) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |  217|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (201:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  202|     15|            debugmsg("dumpx_" token,"\n"); \
  |  |  |  |  203|     15|        } else { \
  |  |  |  |  204|      0|            debugmsg("dumpx_" token,"  "); \
  |  |  |  |  205|      0|        } \
  |  |  |  |  206|     15|        debugmsg("dumpv" token, "dumpv_%s:%*s", token, __DBGINDENT(), "");
  |  |  |  |  ------------------
  |  |  |  |  |  |  173|     15|#define __DBGINDENT()      debug_indent_get()
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (85:60): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2484|       |    /*
 2485|       |     * the float is encoded as an opaque 
 2486|       |     */
 2487|     15|    if ((*type == ASN_OPAQUE) &&
  ------------------
  |  |   93|     15|#define ASN_OPAQUE	(ASN_APPLICATION | 4)   /* changed so no conflict with other includes */
  |  |  ------------------
  |  |  |  |   91|     15|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (2487:9): [True: 6, False: 9]
  ------------------
 2488|     15|        (asn_length == ASN_OPAQUE_FLOAT_BER_LEN) &&
  ------------------
  |  |  169|      6|#define ASN_OPAQUE_FLOAT_BER_LEN 7
  ------------------
  |  Branch (2488:9): [True: 1, False: 5]
  ------------------
 2489|     15|        (*bufp == ASN_OPAQUE_TAG1) && (*(bufp + 1) == ASN_OPAQUE_FLOAT)) {
  ------------------
  |  |  131|      1|#define ASN_OPAQUE_TAG1 (ASN_CONTEXT | ASN_EXTENSION_ID)
  |  |  ------------------
  |  |  |  |   92|      1|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define ASN_OPAQUE_TAG1 (ASN_CONTEXT | ASN_EXTENSION_ID)
  |  |  ------------------
  |  |  |  |   99|      1|#define ASN_EXTENSION_ID    0x1FU
  |  |  ------------------
  ------------------
                      (*bufp == ASN_OPAQUE_TAG1) && (*(bufp + 1) == ASN_OPAQUE_FLOAT)) {
  ------------------
  |  |  165|      1|#define ASN_OPAQUE_FLOAT (ASN_OPAQUE_TAG2 + ASN_APP_FLOAT)
  |  |  ------------------
  |  |  |  |  136|      1|#define ASN_OPAQUE_TAG2 0x30U
  |  |  ------------------
  |  |               #define ASN_OPAQUE_FLOAT (ASN_OPAQUE_TAG2 + ASN_APP_FLOAT)
  |  |  ------------------
  |  |  |  |  147|      1|#define ASN_APP_FLOAT (ASN_APPLICATION | 8)
  |  |  |  |  ------------------
  |  |  |  |  |  |   91|      1|#define ASN_APPLICATION     0x40U
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (2489:9): [True: 1, False: 0]
  |  Branch (2489:39): [True: 1, False: 0]
  ------------------
 2490|       |
 2491|       |        /*
 2492|       |         * value is encoded as special format 
 2493|       |         */
 2494|      1|        *datalength = asn_length;
 2495|      1|        bufp = asn_parse_nlength(bufp+2, *datalength - 2, &asn_length);
 2496|      1|        if (NULL == bufp) {
  ------------------
  |  Branch (2496:13): [True: 0, False: 1]
  ------------------
 2497|      0|            _asn_short_err("parse opaque float", *datalength - 2, asn_length);
 2498|      0|            return NULL;
 2499|      0|        }
 2500|       |        /*
 2501|       |         * change type to Float 
 2502|       |         */
 2503|      1|        *type = ASN_OPAQUE_FLOAT;
  ------------------
  |  |  165|      1|#define ASN_OPAQUE_FLOAT (ASN_OPAQUE_TAG2 + ASN_APP_FLOAT)
  |  |  ------------------
  |  |  |  |  136|      1|#define ASN_OPAQUE_TAG2 0x30U
  |  |  ------------------
  |  |               #define ASN_OPAQUE_FLOAT (ASN_OPAQUE_TAG2 + ASN_APP_FLOAT)
  |  |  ------------------
  |  |  |  |  147|      1|#define ASN_APP_FLOAT (ASN_APPLICATION | 8)
  |  |  |  |  ------------------
  |  |  |  |  |  |   91|      1|#define ASN_APPLICATION     0x40U
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2504|      1|    }
 2505|       |
 2506|     15|    if (*type != ASN_OPAQUE_FLOAT) {
  ------------------
  |  |  165|     15|#define ASN_OPAQUE_FLOAT (ASN_OPAQUE_TAG2 + ASN_APP_FLOAT)
  |  |  ------------------
  |  |  |  |  136|     15|#define ASN_OPAQUE_TAG2 0x30U
  |  |  ------------------
  |  |               #define ASN_OPAQUE_FLOAT (ASN_OPAQUE_TAG2 + ASN_APP_FLOAT)
  |  |  ------------------
  |  |  |  |  147|     15|#define ASN_APP_FLOAT (ASN_APPLICATION | 8)
  |  |  |  |  ------------------
  |  |  |  |  |  |   91|     15|#define ASN_APPLICATION     0x40U
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (2506:9): [True: 5, False: 10]
  ------------------
 2507|      5|        _asn_type_err(errpre, *type);
 2508|      5|        return NULL;
 2509|      5|    }
 2510|       |
 2511|     10|    if (asn_length != sizeof(float)) {
  ------------------
  |  Branch (2511:9): [True: 6, False: 4]
  ------------------
 2512|      6|        _asn_size_err("parse seq float", asn_length, sizeof(float));
 2513|      6|        return NULL;
 2514|      6|    }
 2515|       |
 2516|      4|    *datalength -= (int) asn_length + (bufp - data);
 2517|      4|    memcpy(&fu.c[0], bufp, asn_length);
 2518|       |
 2519|       |    /*
 2520|       |     * correct for endian differences 
 2521|       |     */
 2522|      4|    fu.longVal = ntohl(fu.longVal);
 2523|       |
 2524|      4|    *floatp = fu.floatVal;
 2525|       |
 2526|      4|    DEBUGMSG(("dumpv_recv", "Opaque float: %f\n", *floatp));
  ------------------
  |  |   63|      4|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  146|      4|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 4, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (63:67): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2527|      4|    return bufp;
 2528|     10|}
asn_parse_double:
 2633|     10|{
 2634|     10|    static const char *errpre = "parse double";
 2635|     10|    register u_char *bufp = data;
 2636|     10|    u_long          asn_length;
 2637|     10|    long            tmp;
 2638|     10|    union {
 2639|     10|        double          doubleVal;
 2640|     10|        int             intVal[2];
 2641|     10|        u_char          c[sizeof(double)];
 2642|     10|    } fu;
 2643|       |
 2644|       |
 2645|     10|    if (doublesize != sizeof(double)) {
  ------------------
  |  Branch (2645:9): [True: 0, False: 10]
  ------------------
 2646|      0|        _asn_size_err("parse double", doublesize, sizeof(double));
 2647|      0|        return NULL;
 2648|      0|    }
 2649|       |
 2650|     10|    if (NULL == data || NULL == datalength || NULL == type || NULL == doublep) {
  ------------------
  |  Branch (2650:9): [True: 0, False: 10]
  |  Branch (2650:25): [True: 0, False: 10]
  |  Branch (2650:47): [True: 0, False: 10]
  |  Branch (2650:63): [True: 0, False: 10]
  ------------------
 2651|      0|        ERROR_MSG("parse double: NULL pointer");
  ------------------
  |  |  190|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 2652|      0|        return NULL;
 2653|      0|    }
 2654|       |
 2655|       |    /** need at least 2 bytes to work with: type, length (which might be 0)  */
 2656|     10|    if (*datalength < 2) {
  ------------------
  |  Branch (2656:9): [True: 0, False: 10]
  ------------------
 2657|      0|        _asn_short_err(errpre, *datalength, 2);
 2658|      0|        return NULL;
 2659|      0|    }
 2660|       |
 2661|     10|    *type = *bufp++;
 2662|     10|    bufp = asn_parse_nlength(bufp, *datalength - 1, &asn_length);
 2663|     10|    if (NULL == bufp) {
  ------------------
  |  Branch (2663:9): [True: 0, False: 10]
  ------------------
 2664|      0|        _asn_short_err(errpre, *datalength - 1, asn_length);
 2665|      0|        return NULL;
 2666|      0|    }
 2667|       |
 2668|     10|    DEBUGDUMPSETUP("recv", data, bufp - data + asn_length);
  ------------------
  |  |   85|     10|	do {if (_DBG_IF_) {__DBGDUMPSETUP(token,buf,len);} }while(0)
  |  |  ------------------
  |  |  |  |  146|     10|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 10, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPSETUP(token,buf,len);} }while(0)
  |  |  ------------------
  |  |  |  |  198|     10|        debugmsg("dumpx" token, "dumpx_%s:%*s", token, __DBGINDENT(), ""); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  173|     10|#define __DBGINDENT()      debug_indent_get()
  |  |  |  |  ------------------
  |  |  |  |  199|     10|        __DBGMSGHEX(("dumpx_" token,buf,len)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  171|     10|#define __DBGMSGHEX(x)     debugmsg_hex x
  |  |  |  |  ------------------
  |  |  |  |  200|     10|        if (debug_is_token_registered("dumpv" token) == SNMPERR_SUCCESS || \
  |  |  |  |  ------------------
  |  |  |  |  |  |  217|     20|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (200:13): [True: 10, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  201|     10|            debug_is_token_registered("dumpv_" token) != SNMPERR_SUCCESS) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |  217|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (201:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  202|     10|            debugmsg("dumpx_" token,"\n"); \
  |  |  |  |  203|     10|        } else { \
  |  |  |  |  204|      0|            debugmsg("dumpx_" token,"  "); \
  |  |  |  |  205|      0|        } \
  |  |  |  |  206|     10|        debugmsg("dumpv" token, "dumpv_%s:%*s", token, __DBGINDENT(), "");
  |  |  |  |  ------------------
  |  |  |  |  |  |  173|     10|#define __DBGINDENT()      debug_indent_get()
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (85:60): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2669|       |    /*
 2670|       |     * the double is encoded as an opaque 
 2671|       |     */
 2672|       |    /** need at least 2 bytes: ASN_OPAQUE_TAG1 and ASN_OPAQUE_DOUBLE */
 2673|     10|    if ((*type == ASN_OPAQUE) && (asn_length < 2)) {
  ------------------
  |  |   93|     10|#define ASN_OPAQUE	(ASN_APPLICATION | 4)   /* changed so no conflict with other includes */
  |  |  ------------------
  |  |  |  |   91|     10|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (2673:9): [True: 6, False: 4]
  |  Branch (2673:34): [True: 0, False: 6]
  ------------------
 2674|      0|        _asn_short_err(errpre, asn_length, 2);
 2675|      0|        return NULL;
 2676|      0|    }
 2677|     10|    if ((*type == ASN_OPAQUE) &&
  ------------------
  |  |   93|     10|#define ASN_OPAQUE	(ASN_APPLICATION | 4)   /* changed so no conflict with other includes */
  |  |  ------------------
  |  |  |  |   91|     10|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (2677:9): [True: 6, False: 4]
  ------------------
 2678|     10|        (asn_length == ASN_OPAQUE_DOUBLE_BER_LEN) &&
  ------------------
  |  |  178|      6|#define ASN_OPAQUE_DOUBLE_BER_LEN 11
  ------------------
  |  Branch (2678:9): [True: 1, False: 5]
  ------------------
 2679|     10|        (*bufp == ASN_OPAQUE_TAG1) && (*(bufp + 1) == ASN_OPAQUE_DOUBLE)) {
  ------------------
  |  |  131|      1|#define ASN_OPAQUE_TAG1 (ASN_CONTEXT | ASN_EXTENSION_ID)
  |  |  ------------------
  |  |  |  |   92|      1|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define ASN_OPAQUE_TAG1 (ASN_CONTEXT | ASN_EXTENSION_ID)
  |  |  ------------------
  |  |  |  |   99|      1|#define ASN_EXTENSION_ID    0x1FU
  |  |  ------------------
  ------------------
                      (*bufp == ASN_OPAQUE_TAG1) && (*(bufp + 1) == ASN_OPAQUE_DOUBLE)) {
  ------------------
  |  |  174|      1|#define ASN_OPAQUE_DOUBLE (ASN_OPAQUE_TAG2 + ASN_APP_DOUBLE)
  |  |  ------------------
  |  |  |  |  136|      1|#define ASN_OPAQUE_TAG2 0x30U
  |  |  ------------------
  |  |               #define ASN_OPAQUE_DOUBLE (ASN_OPAQUE_TAG2 + ASN_APP_DOUBLE)
  |  |  ------------------
  |  |  |  |  148|      1|#define ASN_APP_DOUBLE (ASN_APPLICATION | 9)
  |  |  |  |  ------------------
  |  |  |  |  |  |   91|      1|#define ASN_APPLICATION     0x40U
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (2679:9): [True: 1, False: 0]
  |  Branch (2679:39): [True: 1, False: 0]
  ------------------
 2680|       |
 2681|       |        /*
 2682|       |         * value is encoded as special format 
 2683|       |         */
 2684|      1|        *datalength = asn_length;
 2685|      1|        bufp = asn_parse_nlength(bufp+2, *datalength - 2, &asn_length);
 2686|      1|        if (NULL == bufp) {
  ------------------
  |  Branch (2686:13): [True: 0, False: 1]
  ------------------
 2687|      0|            _asn_short_err("parse opaque double", *datalength - 2, asn_length);
 2688|      0|            return NULL;
 2689|      0|        }
 2690|       |
 2691|       |        /*
 2692|       |         * change type to Double 
 2693|       |         */
 2694|      1|        *type = ASN_OPAQUE_DOUBLE;
  ------------------
  |  |  174|      1|#define ASN_OPAQUE_DOUBLE (ASN_OPAQUE_TAG2 + ASN_APP_DOUBLE)
  |  |  ------------------
  |  |  |  |  136|      1|#define ASN_OPAQUE_TAG2 0x30U
  |  |  ------------------
  |  |               #define ASN_OPAQUE_DOUBLE (ASN_OPAQUE_TAG2 + ASN_APP_DOUBLE)
  |  |  ------------------
  |  |  |  |  148|      1|#define ASN_APP_DOUBLE (ASN_APPLICATION | 9)
  |  |  |  |  ------------------
  |  |  |  |  |  |   91|      1|#define ASN_APPLICATION     0x40U
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2695|      1|    }
 2696|       |
 2697|     10|    if (*type != ASN_OPAQUE_DOUBLE) {
  ------------------
  |  |  174|     10|#define ASN_OPAQUE_DOUBLE (ASN_OPAQUE_TAG2 + ASN_APP_DOUBLE)
  |  |  ------------------
  |  |  |  |  136|     10|#define ASN_OPAQUE_TAG2 0x30U
  |  |  ------------------
  |  |               #define ASN_OPAQUE_DOUBLE (ASN_OPAQUE_TAG2 + ASN_APP_DOUBLE)
  |  |  ------------------
  |  |  |  |  148|     10|#define ASN_APP_DOUBLE (ASN_APPLICATION | 9)
  |  |  |  |  ------------------
  |  |  |  |  |  |   91|     10|#define ASN_APPLICATION     0x40U
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (2697:9): [True: 5, False: 5]
  ------------------
 2698|      5|        _asn_type_err(errpre, *type);
 2699|      5|        return NULL;
 2700|      5|    }
 2701|       |
 2702|      5|    if (asn_length != sizeof(double)) {
  ------------------
  |  Branch (2702:9): [True: 4, False: 1]
  ------------------
 2703|      4|        _asn_size_err("parse seq double", asn_length, sizeof(double));
 2704|      4|        return NULL;
 2705|      4|    }
 2706|      1|    *datalength -= (int) asn_length + (bufp - data);
 2707|      1|    memcpy(&fu.c[0], bufp, asn_length);
 2708|       |
 2709|       |    /*
 2710|       |     * correct for endian differences 
 2711|       |     */
 2712|       |
 2713|      1|    tmp = ntohl(fu.intVal[0]);
 2714|      1|    fu.intVal[0] = ntohl(fu.intVal[1]);
 2715|      1|    fu.intVal[1] = tmp;
 2716|       |
 2717|      1|    *doublep = fu.doubleVal;
 2718|      1|    DEBUGMSG(("dumpv_recv", "  Opaque Double:\t%f\n", *doublep));
  ------------------
  |  |   63|      1|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  146|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (63:67): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2719|       |
 2720|      1|    return bufp;
 2721|      5|}
asn1.c:_asn_size_err:
  242|     10|{
  243|     10|    char            ebuf[128];
  244|       |
  245|     10|    snprintf(ebuf, sizeof(ebuf),
  246|     10|            "%s size %lu: s/b %lu", str,
  247|     10|	    (unsigned long)wrongsize, (unsigned long)rightsize);
  248|     10|    ebuf[ sizeof(ebuf)-1 ] = 0;
  249|     10|    ERROR_MSG(ebuf);
  ------------------
  |  |  190|     10|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
  250|     10|}
asn1.c:_asn_short_err:
  301|  1.15k|{
  302|  1.15k|    char            ebuf[128];
  303|       |
  304|  1.15k|    snprintf(ebuf, sizeof(ebuf), "%s length %lu too short: need %lu", str,
  305|  1.15k|	    (unsigned long)wrongsize, (unsigned long)rightsize);
  306|  1.15k|    ERROR_MSG(ebuf);
  ------------------
  |  |  190|  1.15k|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
  307|  1.15k|}
asn1.c:_asn_type_err:
  262|     88|{
  263|     88|    char            ebuf[128];
  264|       |
  265|     88|    snprintf(ebuf, sizeof(ebuf), "%s type %d", str, wrongtype);
  266|     88|    ebuf[ sizeof(ebuf)-1 ] = 0;
  267|     88|    ERROR_MSG(ebuf);
  ------------------
  |  |  190|     88|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
  268|     88|}
asn1.c:_asn_length_err:
  281|     58|{
  282|     58|    char            ebuf[128];
  283|       |
  284|     58|    snprintf(ebuf, sizeof(ebuf),
  285|     58|            "%s length %lu too large: exceeds %lu", str,
  286|     58|	    (unsigned long)wrongsize, (unsigned long)rightsize);
  287|     58|    ebuf[ sizeof(ebuf)-1 ] = 0;
  288|     58|    ERROR_MSG(ebuf);
  ------------------
  |  |  190|     58|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
  289|     58|}
asn1.c:_asn_bitstring_check:
  518|     11|{
  519|     11|    char            ebuf[128];
  520|       |
  521|     11|    if (asn_length < 1) {
  ------------------
  |  Branch (521:9): [True: 4, False: 7]
  ------------------
  522|      4|        snprintf(ebuf, sizeof(ebuf),
  523|      4|                "%s: length %d too small", str, (int) asn_length);
  524|      4|        ebuf[ sizeof(ebuf)-1 ] = 0;
  525|      4|        ERROR_MSG(ebuf);
  ------------------
  |  |  190|      4|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
  526|      4|        return 1;
  527|      4|    }
  528|       |    /*
  529|       |     * if (datum > 7){
  530|       |     * sprintf(ebuf,"%s: datum %d >7: too large", str, (int)(datum));
  531|       |     * ERROR_MSG(ebuf);
  532|       |     * return 1;
  533|       |     * }
  534|       |     */
  535|      7|    return 0;
  536|     11|}

init_callbacks:
  177|      2|{
  178|       |    /*
  179|       |     * (poses a problem if you put init_callbacks() inside of
  180|       |     * init_snmp() and then want the app to register a callback before
  181|       |     * init_snmp() is called in the first place.  -- Wes 
  182|       |     */
  183|      2|    if (0 == _callback_need_init)
  ------------------
  |  Branch (183:9): [True: 1, False: 1]
  ------------------
  184|      1|        return;
  185|       |    
  186|      1|    _callback_need_init = 0;
  187|       |    
  188|      1|    memset(thecallbacks, 0, sizeof(thecallbacks)); 
  189|      1|#ifdef LOCK_PER_CALLBACK_SUBID
  190|      1|    memset(_locks, 0, sizeof(_locks));
  191|       |#else
  192|       |    _lock = 0;
  193|       |#endif
  194|       |    
  195|      1|    DEBUGMSGTL(("callback", "initialized\n"));
  ------------------
  |  |   68|      1|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
  196|      1|}
snmp_register_callback:
  237|     11|{
  238|     11|    return netsnmp_register_callback( major, minor, new_callback, arg,
  239|     11|                                      NETSNMP_CALLBACK_DEFAULT_PRIORITY);
  ------------------
  |  |   39|     11|#define NETSNMP_CALLBACK_DEFAULT_PRIORITY       0
  ------------------
  240|     11|}
netsnmp_register_callback:
  259|     11|{
  260|     11|    if (major >= MAX_CALLBACK_IDS || minor >= MAX_CALLBACK_SUBIDS) {
  ------------------
  |  |   12|     22|#define MAX_CALLBACK_IDS    2
  ------------------
                  if (major >= MAX_CALLBACK_IDS || minor >= MAX_CALLBACK_SUBIDS) {
  ------------------
  |  |   13|     11|#define MAX_CALLBACK_SUBIDS 18
  ------------------
  |  Branch (260:9): [True: 0, False: 11]
  |  Branch (260:38): [True: 0, False: 11]
  ------------------
  261|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  218|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  262|      0|    }
  263|       |
  264|     11|    struct snmp_gen_callback *newscp = NULL, *scp = NULL;
  265|     11|    struct snmp_gen_callback **prevNext = &(thecallbacks[major][minor]);
  266|       |
  267|     11|    if (_callback_need_init)
  ------------------
  |  Branch (267:9): [True: 1, False: 10]
  ------------------
  268|      1|        init_callbacks();
  269|       |
  270|     11|    _callback_lock(major,minor, "netsnmp_register_callback", 1);
  271|       |    
  272|     11|    if ((newscp = SNMP_MALLOC_STRUCT(snmp_gen_callback)) == NULL) {
  ------------------
  |  |   69|     11|#define SNMP_MALLOC_STRUCT(s)   (struct s *) calloc(1, sizeof(struct s))
  ------------------
  |  Branch (272:9): [True: 0, False: 11]
  ------------------
  273|      0|        _callback_unlock(major,minor);
  274|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  218|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  275|     11|    } else {
  276|     11|        newscp->priority = priority;
  277|     11|        newscp->sc_client_arg = arg;
  278|     11|        newscp->sc_callback = new_callback;
  279|     11|        newscp->next = NULL;
  280|       |
  281|     20|        for (scp = thecallbacks[major][minor]; scp != NULL;
  ------------------
  |  Branch (281:48): [True: 9, False: 11]
  ------------------
  282|     11|             scp = scp->next) {
  283|      9|            if (newscp->priority < scp->priority) {
  ------------------
  |  Branch (283:17): [True: 0, False: 9]
  ------------------
  284|      0|                newscp->next = scp;
  285|      0|                break;
  286|      0|            }
  287|      9|            prevNext = &(scp->next);
  288|      9|        }
  289|       |
  290|     11|        *prevNext = newscp;
  291|       |
  292|     11|        DEBUGMSGTL(("callback", "registered (%d,%d) at %p with priority %d\n",
  ------------------
  |  |   68|     11|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|     11|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 10, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|     10|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|     10|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|     10|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|     10|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
  293|     11|                    major, minor, newscp, priority));
  294|     11|        _callback_unlock(major,minor);
  295|     11|        return SNMPERR_SUCCESS;
  ------------------
  |  |  217|     11|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  296|     11|    }
  297|     11|}
snmp_call_callbacks:
  318|  1.75k|{
  319|  1.75k|    struct snmp_gen_callback *scp;
  320|  1.75k|    unsigned int    count = 0;
  321|       |    
  322|  1.75k|    if (major >= MAX_CALLBACK_IDS || minor >= MAX_CALLBACK_SUBIDS) {
  ------------------
  |  |   12|  3.50k|#define MAX_CALLBACK_IDS    2
  ------------------
                  if (major >= MAX_CALLBACK_IDS || minor >= MAX_CALLBACK_SUBIDS) {
  ------------------
  |  |   13|  1.75k|#define MAX_CALLBACK_SUBIDS 18
  ------------------
  |  Branch (322:9): [True: 0, False: 1.75k]
  |  Branch (322:38): [True: 0, False: 1.75k]
  ------------------
  323|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  218|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  324|      0|    }
  325|       |    
  326|  1.75k|    if (_callback_need_init)
  ------------------
  |  Branch (326:9): [True: 0, False: 1.75k]
  ------------------
  327|      0|        init_callbacks();
  328|       |
  329|  1.75k|#ifdef LOCK_PER_CALLBACK_SUBID
  330|  1.75k|    _callback_lock(major,minor,"snmp_call_callbacks", 1);
  331|       |#else
  332|       |    /*
  333|       |     * Notes:
  334|       |     * - this gets hit the first time a trap is sent after a new trap
  335|       |     *   destination has been added (session init cb during send trap cb)
  336|       |     */
  337|       |    _callback_lock(major,minor, NULL, 0);
  338|       |#endif
  339|       |
  340|  1.75k|    DEBUGMSGTL(("callback", "START calling callbacks for maj=%d min=%d\n",
  ------------------
  |  |   68|  1.75k|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|  1.75k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 1.75k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|  1.75k|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|  1.75k|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|  1.75k|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|  1.75k|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
  341|  1.75k|                major, minor));
  342|       |
  343|       |    /*
  344|       |     * for each registered callback of type major and minor 
  345|       |     */
  346|  3.50k|    for (scp = thecallbacks[major][minor]; scp != NULL; scp = scp->next) {
  ------------------
  |  Branch (346:44): [True: 1.75k, False: 1.75k]
  ------------------
  347|       |
  348|       |        /*
  349|       |         * skip unregistered callbacks
  350|       |         */
  351|  1.75k|        if(NULL == scp->sc_callback)
  ------------------
  |  Branch (351:12): [True: 0, False: 1.75k]
  ------------------
  352|      0|            continue;
  353|       |
  354|  1.75k|        DEBUGMSGTL(("callback", "calling a callback for maj=%d min=%d\n",
  ------------------
  |  |   68|  1.75k|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|  1.75k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 1.75k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|  1.75k|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|  1.75k|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|  1.75k|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|  1.75k|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
  355|  1.75k|                    major, minor));
  356|       |
  357|       |        /*
  358|       |         * call them 
  359|       |         */
  360|  1.75k|        (*(scp->sc_callback)) (major, minor, caller_arg,
  361|  1.75k|                               scp->sc_client_arg);
  362|  1.75k|        count++;
  363|  1.75k|    }
  364|       |
  365|  1.75k|    DEBUGMSGTL(("callback",
  ------------------
  |  |   68|  1.75k|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|  1.75k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 1.75k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|  1.75k|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|  1.75k|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|  1.75k|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|  1.75k|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
  366|  1.75k|                "END calling callbacks for maj=%d min=%d (%d called)\n",
  367|  1.75k|                major, minor, count));
  368|       |
  369|  1.75k|    _callback_unlock(major,minor);
  370|  1.75k|    return SNMPERR_SUCCESS;
  ------------------
  |  |  217|  1.75k|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  371|  1.75k|}
callback.c:_callback_lock:
  119|  1.76k|{
  120|  1.76k|    int lock_holded=0;
  121|  1.76k|    NETSNMP_SELECT_TIMEVAL lock_time = { 0, 1000 };
  ------------------
  |  | 1731|  1.76k|#define NETSNMP_SELECT_TIMEVAL struct timeval
  ------------------
  122|       |
  123|       |#ifdef NETSNMP_PARANOID_LEVEL_HIGH
  124|       |    if (major >= MAX_CALLBACK_IDS || minor >= MAX_CALLBACK_SUBIDS) {
  125|       |        netsnmp_assert("bad callback id");
  126|       |        return 1;
  127|       |    }
  128|       |#endif
  129|       |    
  130|  1.76k|#ifdef CALLBACK_NAME_LOGGING
  131|  1.76k|    DEBUGMSGTL(("9:callback:lock", "locked (%s,%s)\n",
  ------------------
  |  |   68|  1.76k|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|  1.76k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 1.76k, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|  7.04k|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|  1.76k|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|  1.76k|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|  1.76k|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (166:52): [True: 1.75k, False: 2]
  |  |  |  |  |  Branch (166:52): [True: 1.76k, False: 0]
  |  |  |  |  |  Branch (166:64): [True: 1.75k, False: 2]
  |  |  |  |  |  Branch (166:64): [True: 1.76k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
  132|  1.76k|                types[major], (SNMP_CALLBACK_LIBRARY == major) ?
  133|  1.76k|                SNMP_STRORNULL(lib[minor]) : "null"));
  134|  1.76k|#endif
  135|  1.76k|    while (CALLBACK_LOCK_COUNT(major,minor) >= 1 && ++lock_holded < 100)
  ------------------
  |  |  109|  1.76k|#define CALLBACK_LOCK_COUNT(maj,min) _locks[maj][min]
  ------------------
  |  Branch (135:12): [True: 0, False: 1.76k]
  |  Branch (135:53): [True: 0, False: 0]
  ------------------
  136|      0|	select(0, NULL, NULL, NULL, &lock_time);
  137|       |
  138|  1.76k|    if(lock_holded >= 100) {
  ------------------
  |  Branch (138:8): [True: 0, False: 1.76k]
  ------------------
  139|      0|        if (NULL != warn)
  ------------------
  |  Branch (139:13): [True: 0, False: 0]
  ------------------
  140|      0|            snmp_log(LOG_WARNING,
  141|      0|                     "lock in _callback_lock sleeps more than 100 milliseconds in %s\n", warn);
  142|      0|        if (do_assert)
  ------------------
  |  Branch (142:13): [True: 0, False: 0]
  ------------------
  143|      0|            netsnmp_assert(lock_holded < 100);
  ------------------
  |  |   47|      0|#      define netsnmp_assert(x)  do { \
  |  |   48|      0|              if ( x ) \
  |  |  ------------------
  |  |  |  Branch (48:20): [True: 0, False: 0]
  |  |  ------------------
  |  |   49|      0|                 ; \
  |  |   50|      0|              else \
  |  |   51|      0|                 snmp_log(LOG_ERR, \
  |  |   52|      0|                          "netsnmp_assert %s failed %s:%d" NETSNMP_FUNC_FMT, \
  |  |  ------------------
  |  |  |  |   40|      0|#          define NETSNMP_FUNC_FMT " %s()\n"
  |  |  ------------------
  |  |   53|      0|                          __STRING(x),__FILE__,__LINE__, \
  |  |   54|      0|                          NETSNMP_FUNC_PARAM); \
  |  |  ------------------
  |  |  |  |   41|      0|#          define NETSNMP_FUNC_PARAM NETSNMP_FUNCTION
  |  |  |  |  ------------------
  |  |  |  |  |  | 1681|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|      0|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded - Ignored]
  |  |  ------------------
  ------------------
  144|       |        
  145|      0|        return 1;
  146|      0|    }
  147|       |
  148|  1.76k|    CALLBACK_LOCK(major,minor);
  ------------------
  |  |  107|  1.76k|#define CALLBACK_LOCK(maj,min) ++_locks[maj][min]
  ------------------
  149|  1.76k|    return 0;
  150|  1.76k|}
callback.c:_callback_unlock:
  154|  1.76k|{
  155|       |#ifdef NETSNMP_PARANOID_LEVEL_HIGH
  156|       |    if (major >= MAX_CALLBACK_IDS || minor >= MAX_CALLBACK_SUBIDS) {
  157|       |        netsnmp_assert("bad callback id");
  158|       |        return;
  159|       |    }
  160|       |#endif
  161|       |    
  162|  1.76k|    CALLBACK_UNLOCK(major,minor);
  ------------------
  |  |  108|  1.76k|#define CALLBACK_UNLOCK(maj,min) --_locks[maj][min]
  ------------------
  163|       |
  164|  1.76k|#ifdef CALLBACK_NAME_LOGGING
  165|  1.76k|    DEBUGMSGTL(("9:callback:lock", "unlocked (%s,%s)\n",
  ------------------
  |  |   68|  1.76k|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|  1.76k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 1.76k, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|  7.04k|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|  1.76k|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|  1.76k|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|  1.76k|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (166:52): [True: 1.75k, False: 2]
  |  |  |  |  |  Branch (166:52): [True: 1.76k, False: 0]
  |  |  |  |  |  Branch (166:64): [True: 1.75k, False: 2]
  |  |  |  |  |  Branch (166:64): [True: 1.76k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
  166|  1.76k|                types[major], (SNMP_CALLBACK_LIBRARY == major) ?
  167|  1.76k|                SNMP_STRORNULL(lib[minor]) : "null"));
  168|  1.76k|#endif
  169|  1.76k|}

_netsnmp_release_trustcerts:
  177|      1|{
  178|      1|    if (NULL != _trusted_certs) {
  ------------------
  |  Branch (178:9): [True: 1, False: 0]
  ------------------
  179|      1|        CONTAINER_FREE_ALL(_trusted_certs, NULL);
  180|      1|        CONTAINER_FREE(_trusted_certs);
  181|      1|        _trusted_certs = NULL;
  182|      1|    }
  183|      1|}
_setup_trusted_certs:
  187|      1|{
  188|      1|    _trusted_certs = netsnmp_container_find("trusted_certs:fifo");
  189|      1|    if (NULL == _trusted_certs) {
  ------------------
  |  Branch (189:9): [True: 0, False: 1]
  ------------------
  190|      0|        snmp_log(LOG_ERR, "could not create container for trusted certs\n");
  191|      0|        netsnmp_certs_shutdown();
  192|      0|        return;
  193|      0|    }
  194|      1|    _trusted_certs->container_name = strdup("trusted certificates");
  195|      1|    _trusted_certs->compare = (netsnmp_container_compare*) strcmp;
  196|      1|}
netsnmp_certs_init:
  211|      1|{
  212|      1|    const char *trustCert_help = TRUSTCERT_CONFIG_TOKEN
  ------------------
  |  |  142|      1|#define TRUSTCERT_CONFIG_TOKEN "trustCert"
  ------------------
  213|      1|        " FINGERPRINT|FILENAME";
  214|       |
  215|      1|    register_config_handler("snmp", TRUSTCERT_CONFIG_TOKEN,
  ------------------
  |  |  142|      1|#define TRUSTCERT_CONFIG_TOKEN "trustCert"
  ------------------
  216|      1|                            _parse_trustcert, _netsnmp_release_trustcerts,
  217|      1|                            trustCert_help);
  218|      1|    _setup_containers();
  219|       |
  220|       |    /** add certificate type mapping */
  221|      1|    se_add_pair_to_slist("cert_types", strdup("pem"), NS_CERT_TYPE_PEM);
  222|      1|    se_add_pair_to_slist("cert_types", strdup("crt"), NS_CERT_TYPE_DER);
  223|      1|    se_add_pair_to_slist("cert_types", strdup("cer"), NS_CERT_TYPE_DER);
  224|      1|    se_add_pair_to_slist("cert_types", strdup("cert"), NS_CERT_TYPE_DER);
  225|      1|    se_add_pair_to_slist("cert_types", strdup("der"), NS_CERT_TYPE_DER);
  226|      1|    se_add_pair_to_slist("cert_types", strdup("key"), NS_CERT_TYPE_KEY);
  227|      1|    se_add_pair_to_slist("cert_types", strdup("private"), NS_CERT_TYPE_KEY);
  228|       |
  229|       |    /** hash algs */
  230|      1|    se_add_pair_to_slist("cert_hash_alg", strdup("sha1"), NS_HASH_SHA1);
  ------------------
  |  |   82|      1|#define NS_HASH_SHA1        2
  ------------------
  231|      1|    se_add_pair_to_slist("cert_hash_alg", strdup("md5"), NS_HASH_MD5);
  ------------------
  |  |   81|      1|#define NS_HASH_MD5         1
  ------------------
  232|      1|    se_add_pair_to_slist("cert_hash_alg", strdup("sha224"), NS_HASH_SHA224);
  ------------------
  |  |   83|      1|#define NS_HASH_SHA224      3
  ------------------
  233|      1|    se_add_pair_to_slist("cert_hash_alg", strdup("sha256"), NS_HASH_SHA256);
  ------------------
  |  |   84|      1|#define NS_HASH_SHA256      4
  ------------------
  234|      1|    se_add_pair_to_slist("cert_hash_alg", strdup("sha384"), NS_HASH_SHA384);
  ------------------
  |  |   85|      1|#define NS_HASH_SHA384      5
  ------------------
  235|      1|    se_add_pair_to_slist("cert_hash_alg", strdup("sha512"), NS_HASH_SHA512);
  ------------------
  |  |   86|      1|#define NS_HASH_SHA512      6
  ------------------
  236|       |
  237|       |    /** map types */
  238|      1|    se_add_pair_to_slist("cert_map_type", strdup("cn"),
  239|      1|                         TSNM_tlstmCertCommonName);
  ------------------
  |  |  126|      1|#define TSNM_tlstmCertCommonName                6
  ------------------
  240|      1|    se_add_pair_to_slist("cert_map_type", strdup("ip"),
  241|      1|                         TSNM_tlstmCertSANIpAddress);
  ------------------
  |  |  124|      1|#define TSNM_tlstmCertSANIpAddress              4
  ------------------
  242|      1|    se_add_pair_to_slist("cert_map_type", strdup("rfc822"),
  243|      1|                         TSNM_tlstmCertSANRFC822Name);
  ------------------
  |  |  122|      1|#define TSNM_tlstmCertSANRFC822Name             2
  ------------------
  244|      1|    se_add_pair_to_slist("cert_map_type", strdup("dns"),
  245|      1|                         TSNM_tlstmCertSANDNSName);
  ------------------
  |  |  123|      1|#define TSNM_tlstmCertSANDNSName                3
  ------------------
  246|      1|    se_add_pair_to_slist("cert_map_type", strdup("any"), TSNM_tlstmCertSANAny);
  ------------------
  |  |  125|      1|#define TSNM_tlstmCertSANAny                    5
  ------------------
  247|      1|    se_add_pair_to_slist("cert_map_type", strdup("sn"),
  248|      1|                         TSNM_tlstmCertSpecified);
  ------------------
  |  |  121|      1|#define TSNM_tlstmCertSpecified                 1
  ------------------
  249|       |
  250|      1|}
netsnmp_certs_load:
  272|      1|{
  273|      1|    netsnmp_iterator  *itr;
  274|      1|    netsnmp_key        *key;
  275|      1|    netsnmp_cert       *cert;
  276|       |
  277|      1|    DEBUGMSGT(("cert:util:init","init\n"));
  ------------------
  |  |   64|      1|#define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  149|      1|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  ------------------
  |  |  |  Branch (64:69): [Folded - Ignored]
  |  |  ------------------
  ------------------
  278|       |
  279|      1|    if (NULL == _certs) {
  ------------------
  |  Branch (279:9): [True: 0, False: 1]
  ------------------
  280|      0|        snmp_log(LOG_ERR, "cant load certs without container\n");
  281|      0|        return;
  282|      0|    }
  283|       |
  284|      1|    if (CONTAINER_SIZE(_certs) != 0) {
  ------------------
  |  |  400|      1|#define CONTAINER_SIZE(x)           (x)->get_size(x)
  ------------------
  |  Branch (284:9): [True: 0, False: 1]
  ------------------
  285|      0|        DEBUGMSGT(("cert:util:init", "ignoring duplicate init\n"));
  ------------------
  |  |   64|      0|#define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  ------------------
  |  |  |  Branch (64:69): [Folded - Ignored]
  |  |  ------------------
  ------------------
  286|      0|        return;
  287|      0|    }
  288|       |
  289|      1|    netsnmp_init_openssl();
  290|       |
  291|       |    /** scan config dirs for certs */
  292|      1|    _cert_indexes_load();
  293|       |
  294|       |    /** match up keys w/certs */
  295|      1|    itr = CONTAINER_ITERATOR(_keys);
  ------------------
  |  |  401|      1|#define CONTAINER_ITERATOR(x)       (x)->get_iterator(x)
  ------------------
  296|      1|    if (NULL == itr) {
  ------------------
  |  Branch (296:9): [True: 0, False: 1]
  ------------------
  297|      0|        snmp_log(LOG_ERR, "could not get iterator for keys\n");
  298|      0|        netsnmp_certs_shutdown();
  299|      0|        return;
  300|      0|    }
  301|      1|    key = ITERATOR_FIRST(itr);
  ------------------
  |  |  543|      1|#define ITERATOR_FIRST(x)  x->first(x)
  ------------------
  302|      1|    for( ; key; key = ITERATOR_NEXT(itr))
  ------------------
  |  |  544|      0|#define ITERATOR_NEXT(x)   x->next(x)
  ------------------
  |  Branch (302:12): [True: 0, False: 1]
  ------------------
  303|      0|        _find_partner(NULL, key);
  304|      1|    ITERATOR_RELEASE(itr);
  ------------------
  |  |  547|      1|#define ITERATOR_RELEASE(x) do { x->release(x); x = NULL; } while(0)
  |  |  ------------------
  |  |  |  Branch (547:67): [Folded - Ignored]
  |  |  ------------------
  ------------------
  305|       |
  306|      1|    DEBUGIF("cert:dump") {
  ------------------
  |  |  147|      1|#define DEBUGIF(x)         if (_DBG_IF_ && debug_is_token_registered(x) == SNMPERR_SUCCESS)
  |  |  ------------------
  |  |  |  |  146|      2|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGIF(x)         if (_DBG_IF_ && debug_is_token_registered(x) == SNMPERR_SUCCESS)
  |  |  ------------------
  |  |  |  |  217|      1|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  ------------------
  |  |  |  Branch (147:44): [True: 1, False: 0]
  |  |  ------------------
  ------------------
  307|      1|        itr = CONTAINER_ITERATOR(_certs);
  ------------------
  |  |  401|      1|#define CONTAINER_ITERATOR(x)       (x)->get_iterator(x)
  ------------------
  308|      1|        if (NULL == itr) {
  ------------------
  |  Branch (308:13): [True: 0, False: 1]
  ------------------
  309|      0|            snmp_log(LOG_ERR, "could not get iterator for certs\n");
  310|      0|            netsnmp_certs_shutdown();
  311|      0|            return;
  312|      0|        }
  313|      1|        cert = ITERATOR_FIRST(itr);
  ------------------
  |  |  543|      1|#define ITERATOR_FIRST(x)  x->first(x)
  ------------------
  314|      1|        for( ; cert; cert = ITERATOR_NEXT(itr)) {
  ------------------
  |  |  544|      0|#define ITERATOR_NEXT(x)   x->next(x)
  ------------------
  |  Branch (314:16): [True: 0, False: 1]
  ------------------
  315|      0|            netsnmp_cert_load_x509(cert);
  316|      0|        }
  317|      1|        ITERATOR_RELEASE(itr);
  ------------------
  |  |  547|      1|#define ITERATOR_RELEASE(x) do { x->release(x); x = NULL; } while(0)
  |  |  ------------------
  |  |  |  Branch (547:67): [Folded - Ignored]
  |  |  ------------------
  ------------------
  318|      1|        DEBUGMSGT(("cert:dump",
  ------------------
  |  |   64|      1|#define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  149|      1|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  ------------------
  |  |  |  Branch (64:69): [Folded - Ignored]
  |  |  ------------------
  ------------------
  319|      1|                   "-------------------- Certificates -----------------\n"));
  320|      1|        netsnmp_cert_dump_all();
  321|      1|        DEBUGMSGT(("cert:dump",
  ------------------
  |  |   64|      1|#define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  149|      1|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  ------------------
  |  |  |  Branch (64:69): [Folded - Ignored]
  |  |  ------------------
  ------------------
  322|      1|                   "------------------------ End ----------------------\n"));
  323|      1|    }
  324|      1|}
netsnmp_cert_dump_all:
 1802|      1|{
 1803|      1|    CONTAINER_FOR_EACH(_certs, (netsnmp_container_obj_func*)_cert_print, NULL);
  ------------------
  |  |  403|      1|#define CONTAINER_FOR_EACH(x,f,c)   (x)->for_each(x,f,c)
  ------------------
 1804|      1|    CONTAINER_FOR_EACH(_keys, (netsnmp_container_obj_func*)_key_print, NULL);
  ------------------
  |  |  403|      1|#define CONTAINER_FOR_EACH(x,f,c)   (x)->for_each(x,f,c)
  ------------------
 1805|      1|}
cert_util.c:_setup_containers:
  354|      1|{
  355|      1|    netsnmp_container *additional_keys;
  356|       |
  357|      1|    int rc;
  358|       |
  359|      1|    _certs = _get_cert_container("netsnmp certificates");
  360|      1|    if (NULL == _certs)
  ------------------
  |  Branch (360:9): [True: 0, False: 1]
  ------------------
  361|      0|        return;
  362|       |
  363|       |    /** additional keys: common name */
  364|      1|    additional_keys = netsnmp_container_find("certs_cn:binary_array");
  365|      1|    if (NULL == additional_keys) {
  ------------------
  |  Branch (365:9): [True: 0, False: 1]
  ------------------
  366|      0|        snmp_log(LOG_ERR, "could not create CN container for certificates\n");
  367|      0|        netsnmp_certs_shutdown();
  368|      0|        return;
  369|      0|    }
  370|      1|    additional_keys->container_name = strdup("certs_cn");
  371|      1|    additional_keys->free_item = NULL;
  372|      1|    additional_keys->compare = (netsnmp_container_compare*)_cert_cn_compare;
  373|      1|    CONTAINER_SET_OPTIONS(additional_keys, CONTAINER_KEY_ALLOW_DUPLICATES, rc);
  ------------------
  |  |  372|      1|#define CONTAINER_SET_OPTIONS(x,o,rc)  do {                             \
  |  |  373|      1|        if (NULL==(x)->options)                                         \
  |  |  ------------------
  |  |  |  Branch (373:13): [True: 0, False: 1]
  |  |  ------------------
  |  |  374|      1|            rc = -1;                                                    \
  |  |  375|      1|        else {                                                          \
  |  |  376|      1|            rc = (x)->options(x, 1, o);                                 \
  |  |  377|      1|            if (rc != -1 )                                              \
  |  |  ------------------
  |  |  |  Branch (377:17): [True: 1, False: 0]
  |  |  ------------------
  |  |  378|      1|                (x)->flags |= o;                                        \
  |  |  379|      1|        }                                                               \
  |  |  380|      1|    } while(0)
  |  |  ------------------
  |  |  |  Branch (380:13): [Folded - Ignored]
  |  |  ------------------
  ------------------
  374|      1|    netsnmp_container_add_index(_certs, additional_keys);
  375|       |
  376|       |    /** additional keys: subject name */
  377|      1|    additional_keys = netsnmp_container_find("certs_sn:binary_array");
  378|      1|    if (NULL == additional_keys) {
  ------------------
  |  Branch (378:9): [True: 0, False: 1]
  ------------------
  379|      0|        snmp_log(LOG_ERR, "could not create SN container for certificates\n");
  380|      0|        netsnmp_certs_shutdown();
  381|      0|        return;
  382|      0|    }
  383|      1|    additional_keys->container_name = strdup("certs_sn");
  384|      1|    additional_keys->free_item = NULL;
  385|      1|    additional_keys->compare = (netsnmp_container_compare*)_cert_sn_compare;
  386|      1|    additional_keys->ncompare = (netsnmp_container_compare*)_cert_sn_ncompare;
  387|      1|    CONTAINER_SET_OPTIONS(additional_keys, CONTAINER_KEY_ALLOW_DUPLICATES, rc);
  ------------------
  |  |  372|      1|#define CONTAINER_SET_OPTIONS(x,o,rc)  do {                             \
  |  |  373|      1|        if (NULL==(x)->options)                                         \
  |  |  ------------------
  |  |  |  Branch (373:13): [True: 0, False: 1]
  |  |  ------------------
  |  |  374|      1|            rc = -1;                                                    \
  |  |  375|      1|        else {                                                          \
  |  |  376|      1|            rc = (x)->options(x, 1, o);                                 \
  |  |  377|      1|            if (rc != -1 )                                              \
  |  |  ------------------
  |  |  |  Branch (377:17): [True: 1, False: 0]
  |  |  ------------------
  |  |  378|      1|                (x)->flags |= o;                                        \
  |  |  379|      1|        }                                                               \
  |  |  380|      1|    } while(0)
  |  |  ------------------
  |  |  |  Branch (380:13): [Folded - Ignored]
  |  |  ------------------
  ------------------
  388|      1|    netsnmp_container_add_index(_certs, additional_keys);
  389|       |
  390|       |    /** additional keys: file name */
  391|      1|    additional_keys = netsnmp_container_find("certs_fn:binary_array");
  392|      1|    if (NULL == additional_keys) {
  ------------------
  |  Branch (392:9): [True: 0, False: 1]
  ------------------
  393|      0|        snmp_log(LOG_ERR, "could not create FN container for certificates\n");
  394|      0|        netsnmp_certs_shutdown();
  395|      0|        return;
  396|      0|    }
  397|      1|    additional_keys->container_name = strdup("certs_fn");
  398|      1|    additional_keys->free_item = NULL;
  399|      1|    additional_keys->compare = (netsnmp_container_compare*)_cert_fn_compare;
  400|      1|    additional_keys->ncompare = (netsnmp_container_compare*)_cert_fn_ncompare;
  401|      1|    CONTAINER_SET_OPTIONS(additional_keys, CONTAINER_KEY_ALLOW_DUPLICATES, rc);
  ------------------
  |  |  372|      1|#define CONTAINER_SET_OPTIONS(x,o,rc)  do {                             \
  |  |  373|      1|        if (NULL==(x)->options)                                         \
  |  |  ------------------
  |  |  |  Branch (373:13): [True: 0, False: 1]
  |  |  ------------------
  |  |  374|      1|            rc = -1;                                                    \
  |  |  375|      1|        else {                                                          \
  |  |  376|      1|            rc = (x)->options(x, 1, o);                                 \
  |  |  377|      1|            if (rc != -1 )                                              \
  |  |  ------------------
  |  |  |  Branch (377:17): [True: 1, False: 0]
  |  |  ------------------
  |  |  378|      1|                (x)->flags |= o;                                        \
  |  |  379|      1|        }                                                               \
  |  |  380|      1|    } while(0)
  |  |  ------------------
  |  |  |  Branch (380:13): [Folded - Ignored]
  |  |  ------------------
  ------------------
  402|      1|    netsnmp_container_add_index(_certs, additional_keys);
  403|       |
  404|      1|    _keys = netsnmp_container_find("cert_keys:binary_array");
  405|      1|    if (NULL == _keys) {
  ------------------
  |  Branch (405:9): [True: 0, False: 1]
  ------------------
  406|      0|        snmp_log(LOG_ERR, "could not create container for certificate keys\n");
  407|      0|        netsnmp_certs_shutdown();
  408|      0|        return;
  409|      0|    }
  410|      1|    _keys->container_name = strdup("netsnmp certificate keys");
  411|      1|    _keys->free_item = (netsnmp_container_obj_func*)_key_free;
  412|      1|    _keys->compare = (netsnmp_container_compare*)_cert_fn_compare;
  413|       |
  414|      1|    _setup_trusted_certs();
  415|      1|}
cert_util.c:_get_cert_container:
  333|      1|{
  334|      1|    netsnmp_container *c;
  335|       |
  336|      1|    int rc;
  337|       |
  338|      1|    c = netsnmp_container_find("certs:binary_array");
  339|      1|    if (NULL == c) {
  ------------------
  |  Branch (339:9): [True: 0, False: 1]
  ------------------
  340|      0|        snmp_log(LOG_ERR, "could not create container for %s\n", use);
  341|      0|        return NULL;
  342|      0|    }
  343|      1|    c->container_name = strdup(use);
  344|      1|    c->free_item = (netsnmp_container_obj_func*)_cert_free;
  345|      1|    c->compare = (netsnmp_container_compare*)_cert_compare;
  346|       |
  347|      1|    CONTAINER_SET_OPTIONS(c, CONTAINER_KEY_ALLOW_DUPLICATES, rc);
  ------------------
  |  |  372|      1|#define CONTAINER_SET_OPTIONS(x,o,rc)  do {                             \
  |  |  373|      1|        if (NULL==(x)->options)                                         \
  |  |  ------------------
  |  |  |  Branch (373:13): [True: 0, False: 1]
  |  |  ------------------
  |  |  374|      1|            rc = -1;                                                    \
  |  |  375|      1|        else {                                                          \
  |  |  376|      1|            rc = (x)->options(x, 1, o);                                 \
  |  |  377|      1|            if (rc != -1 )                                              \
  |  |  ------------------
  |  |  |  Branch (377:17): [True: 1, False: 0]
  |  |  ------------------
  |  |  378|      1|                (x)->flags |= o;                                        \
  |  |  379|      1|        }                                                               \
  |  |  380|      1|    } while(0)
  |  |  ------------------
  |  |  |  Branch (380:13): [Folded - Ignored]
  |  |  ------------------
  ------------------
  348|       |
  349|      1|    return c;
  350|      1|}
cert_util.c:_cert_indexes_load:
 1718|      1|{
 1719|      1|    const char     *confpath;
 1720|      1|    char           *confpath_copy, *dir, *st = NULL;
 1721|      1|    char            certdir[SNMP_MAXPATH];
 1722|      1|    const char     *subdirs[] = { NULL, "ca-certs", "certs", "private", NULL };
 1723|      1|    int             i = 0;
 1724|       |
 1725|       |    /*
 1726|       |     * load indexes from persistent dir
 1727|       |     */
 1728|      1|    _certindexes_load();
 1729|       |
 1730|       |    /*
 1731|       |     * duplicate path building from read_config_files_of_type() in
 1732|       |     * read_config.c. That is, use SNMPCONFPATH environment variable if
 1733|       |     * it is defined, otherwise use configuration directory.
 1734|       |     */
 1735|      1|    confpath = netsnmp_getenv("SNMPCONFPATH");
 1736|      1|    if (NULL == confpath)
  ------------------
  |  Branch (1736:9): [True: 1, False: 0]
  ------------------
 1737|      1|        confpath = get_configuration_directory();
 1738|       |
 1739|      1|    subdirs[0] = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1740|      1|                                       NETSNMP_DS_LIB_CERT_EXTRA_SUBDIR);
  ------------------
  |  |  177|      1|#define NETSNMP_DS_LIB_CERT_EXTRA_SUBDIR 26
  ------------------
 1741|      1|    confpath_copy = strdup(confpath);
 1742|      1|    if (!confpath_copy)
  ------------------
  |  Branch (1742:9): [True: 0, False: 1]
  ------------------
 1743|      0|        return;
 1744|      1|    for ( dir = strtok_r(confpath_copy, ENV_SEPARATOR, &st);
  ------------------
  |  |   67|      1|#define ENV_SEPARATOR ":"
  ------------------
 1745|      5|          dir; dir = strtok_r(NULL, ENV_SEPARATOR, &st)) {
  ------------------
  |  |   67|      4|#define ENV_SEPARATOR ":"
  ------------------
  |  Branch (1745:11): [True: 4, False: 1]
  ------------------
 1746|       |
 1747|      4|        i = (NULL == subdirs[0]) ? 1 : 0;
  ------------------
  |  Branch (1747:13): [True: 4, False: 0]
  ------------------
 1748|     16|        for ( ; subdirs[i] ; ++i ) {
  ------------------
  |  Branch (1748:17): [True: 12, False: 4]
  ------------------
 1749|       |            /** check tls subdir */
 1750|     12|            snprintf(certdir, sizeof(certdir), "%s/tls/%s", dir, subdirs[i]);
 1751|     12|            _add_certdir(certdir);
 1752|     12|        } /* for subdirs */
 1753|      4|    } /* for conf path dirs */
 1754|      1|    SNMP_FREE(confpath_copy);
  ------------------
  |  |   62|      1|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 1, False: 0]
  |  |  |  Branch (62:66): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1755|      1|}
cert_util.c:_certindexes_load:
  772|      1|{
  773|      1|    DIR *dir;
  774|      1|    struct dirent *file;
  775|      1|    FILE *fp;
  776|      1|    char filename[SNMP_MAXPATH], line[300];
  777|      1|    int  i;
  778|      1|    char *cp, *pos;
  779|       |
  780|       |    /*
  781|       |     * Open the CERT index directory, or create it (empty)
  782|       |     */
  783|      1|    snprintf( filename, sizeof(filename), "%s/cert_indexes",
  784|      1|              get_persistent_directory());
  785|      1|    filename[sizeof(filename)-1] = 0;
  786|      1|    dir = opendir( filename );
  787|      1|    if ( dir == NULL ) {
  ------------------
  |  Branch (787:10): [True: 0, False: 1]
  ------------------
  788|      0|        DEBUGMSGT(("cert:index:load",
  ------------------
  |  |   64|      0|#define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  ------------------
  |  |  |  Branch (64:69): [Folded - Ignored]
  |  |  ------------------
  ------------------
  789|      0|                   "creating new cert_indexes directory\n"));
  790|      0|        mkdirhier( filename, NETSNMP_AGENT_DIRECTORY_MODE, 0);
  ------------------
  |  | 1984|      0|#define NETSNMP_AGENT_DIRECTORY_MODE 0700
  ------------------
  791|      0|        return;
  792|      0|    }
  793|       |
  794|       |    /*
  795|       |     * Create a list of which directory each file refers to
  796|       |     */
  797|      3|    while ((file = readdir( dir ))) {
  ------------------
  |  Branch (797:12): [True: 2, False: 1]
  ------------------
  798|      2|        if ( !isdigit(0xFF & file->d_name[0]))
  ------------------
  |  Branch (798:14): [True: 2, False: 0]
  ------------------
  799|      2|            continue;
  800|      0|        i = atoi( file->d_name );
  801|       |
  802|      0|        snprintf( filename, sizeof(filename), "%s/cert_indexes/%d",
  803|      0|              get_persistent_directory(), i );
  804|      0|        filename[sizeof(filename)-1] = 0;
  805|      0|        fp = fopen( filename, "r" );
  806|      0|        if ( !fp ) {
  ------------------
  |  Branch (806:14): [True: 0, False: 0]
  ------------------
  807|      0|            DEBUGMSGT(("cert:index:load", "error opening index (%d)\n", i));
  ------------------
  |  |   64|      0|#define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  ------------------
  |  |  |  Branch (64:69): [Folded - Ignored]
  |  |  ------------------
  ------------------
  808|      0|            continue;
  809|      0|        }
  810|      0|        cp = fgets( line, sizeof(line), fp );
  811|      0|        if ( cp ) {
  ------------------
  |  Branch (811:14): [True: 0, False: 0]
  ------------------
  812|      0|            line[strlen(line)-1] = 0;
  813|      0|            pos = strrchr(line, ' ');
  814|      0|            if (pos)
  ------------------
  |  Branch (814:17): [True: 0, False: 0]
  ------------------
  815|      0|                *pos = '\0';
  816|      0|            DEBUGMSGT(("9:cert:index:load","adding (%d) %s\n", i, line));
  ------------------
  |  |   64|      0|#define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  ------------------
  |  |  |  Branch (64:69): [Folded - Ignored]
  |  |  ------------------
  ------------------
  817|      0|            (void)_certindex_add( line+4, i );  /* Skip 'DIR ' */
  818|      0|        } else {
  819|      0|            DEBUGMSGT(("cert:index:load", "Empty index (%d)\n", i));
  ------------------
  |  |   64|      0|#define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  ------------------
  |  |  |  Branch (64:69): [Folded - Ignored]
  |  |  ------------------
  ------------------
  820|      0|        }
  821|      0|        fclose( fp );
  822|      0|    }
  823|      1|    closedir( dir );
  824|      1|}
cert_util.c:_add_certdir:
 1627|     12|{
 1628|     12|    FILE           *index;
 1629|     12|    char           *file;
 1630|     12|    int             count = 0;
 1631|     12|    netsnmp_container *cert_container;
 1632|     12|    netsnmp_iterator  *it;
 1633|     12|    struct stat     statbuf;
 1634|       |
 1635|     12|    netsnmp_assert(NULL != dirname);
  ------------------
  |  |   47|     12|#      define netsnmp_assert(x)  do { \
  |  |   48|     12|              if ( x ) \
  |  |  ------------------
  |  |  |  Branch (48:20): [True: 12, False: 0]
  |  |  ------------------
  |  |   49|     12|                 ; \
  |  |   50|     12|              else \
  |  |   51|     12|                 snmp_log(LOG_ERR, \
  |  |   52|      0|                          "netsnmp_assert %s failed %s:%d" NETSNMP_FUNC_FMT, \
  |  |  ------------------
  |  |  |  |   40|      0|#          define NETSNMP_FUNC_FMT " %s()\n"
  |  |  ------------------
  |  |   53|      0|                          __STRING(x),__FILE__,__LINE__, \
  |  |   54|      0|                          NETSNMP_FUNC_PARAM); \
  |  |  ------------------
  |  |  |  |   41|      0|#          define NETSNMP_FUNC_PARAM NETSNMP_FUNCTION
  |  |  |  |  ------------------
  |  |  |  |  |  | 1681|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|     12|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1636|       |
 1637|     12|    DEBUGMSGT(("9:cert:dir:add", " config dir: %s\n", dirname ));
  ------------------
  |  |   64|     12|#define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|     12|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 12, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  149|     12|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  ------------------
  |  |  |  Branch (64:69): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1638|       |
 1639|     12|    if (stat(dirname, &statbuf) != 0) {
  ------------------
  |  Branch (1639:9): [True: 12, False: 0]
  ------------------
 1640|     12|        DEBUGMSGT(("9:cert:dir:add", " dir not present: %s\n",
  ------------------
  |  |   64|     12|#define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|     12|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 12, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  149|     12|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  ------------------
  |  |  |  Branch (64:69): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1641|     12|                   dirname ));
 1642|     12|        return -1;
 1643|     12|    }
 1644|      0|#ifdef S_ISDIR
 1645|      0|    if (!S_ISDIR(statbuf.st_mode)) {
  ------------------
  |  Branch (1645:9): [True: 0, False: 0]
  ------------------
 1646|      0|        DEBUGMSGT(("9:cert:dir:add", " not a dir: %s\n", dirname ));
  ------------------
  |  |   64|      0|#define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  ------------------
  |  |  |  Branch (64:69): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1647|      0|        return -1;
 1648|      0|    }
 1649|      0|#endif
 1650|       |
 1651|      0|    DEBUGMSGT(("cert:index:dir", "Scanning directory %s\n", dirname));
  ------------------
  |  |   64|      0|#define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  ------------------
  |  |  |  Branch (64:69): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1652|       |
 1653|       |    /*
 1654|       |     * look for existing index
 1655|       |     */
 1656|      0|    count = _cert_read_index(dirname, &statbuf);
 1657|      0|    if (count >= 0)
  ------------------
  |  Branch (1657:9): [True: 0, False: 0]
  ------------------
 1658|      0|        return count;
 1659|       |
 1660|      0|    index = _certindex_new( dirname );
 1661|      0|    if (NULL == index) {
  ------------------
  |  Branch (1661:9): [True: 0, False: 0]
  ------------------
 1662|      0|        DEBUGMSGT(("9:cert:index:dir",
  ------------------
  |  |   64|      0|#define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  ------------------
  |  |  |  Branch (64:69): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1663|      0|                    "error opening index for cert directory\n"));
 1664|      0|        DEBUGMSGTL(("cert:index", "could not open certificate index file\n"));
  ------------------
  |  |   68|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1665|      0|    }
 1666|       |
 1667|       |    /*
 1668|       |     * index was missing, out of date or bad. rescan directory.
 1669|       |     */
 1670|      0|    cert_container =
 1671|      0|        netsnmp_directory_container_read_some(NULL, dirname,
 1672|      0|                                              _cert_cert_filter, NULL,
 1673|      0|                                              NETSNMP_DIR_RELATIVE_PATH |
  ------------------
  |  |   48|      0|#define NETSNMP_DIR_RELATIVE_PATH                     0x0002
  ------------------
 1674|      0|                                              NETSNMP_DIR_EMPTY_OK |
  ------------------
  |  |   51|      0|#define NETSNMP_DIR_EMPTY_OK                          0x0008
  ------------------
 1675|      0|                                              NETSNMP_DIR_ALLOW_DUPLICATES);
  ------------------
  |  |   57|      0|#define NETSNMP_DIR_ALLOW_DUPLICATES                  0x0040
  ------------------
 1676|      0|    if (NULL == cert_container) {
  ------------------
  |  Branch (1676:9): [True: 0, False: 0]
  ------------------
 1677|      0|        DEBUGMSGT(("cert:index:dir",
  ------------------
  |  |   64|      0|#define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  ------------------
  |  |  |  Branch (64:69): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1678|      0|                    "error creating container for cert files\n"));
 1679|      0|        goto err_index;
 1680|      0|    }
 1681|       |
 1682|       |    /*
 1683|       |     * iterate through the found files and add them to index
 1684|       |     */
 1685|      0|    it = CONTAINER_ITERATOR(cert_container);
  ------------------
  |  |  401|      0|#define CONTAINER_ITERATOR(x)       (x)->get_iterator(x)
  ------------------
 1686|      0|    if (NULL == it) {
  ------------------
  |  Branch (1686:9): [True: 0, False: 0]
  ------------------
 1687|      0|        DEBUGMSGT(("cert:index:dir",
  ------------------
  |  |   64|      0|#define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  ------------------
  |  |  |  Branch (64:69): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1688|      0|                    "error creating iterator for cert files\n"));
 1689|      0|        goto err_container;
 1690|      0|    }
 1691|       |
 1692|      0|    for (file = ITERATOR_FIRST(it); file; file = ITERATOR_NEXT(it)) {
  ------------------
  |  |  543|      0|#define ITERATOR_FIRST(x)  x->first(x)
  ------------------
                  for (file = ITERATOR_FIRST(it); file; file = ITERATOR_NEXT(it)) {
  ------------------
  |  |  544|      0|#define ITERATOR_NEXT(x)   x->next(x)
  ------------------
  |  Branch (1692:37): [True: 0, False: 0]
  ------------------
 1693|      0|        DEBUGMSGT(("cert:index:dir", "adding %s to index\n", file));
  ------------------
  |  |   64|      0|#define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  ------------------
  |  |  |  Branch (64:69): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1694|      0|        if ( 0 == _add_certfile( dirname, file, index ))
  ------------------
  |  Branch (1694:14): [True: 0, False: 0]
  ------------------
 1695|      0|            count++;
 1696|      0|        else
 1697|      0|            DEBUGMSGT(("cert:index:dir", "error adding %s to index\n",
  ------------------
  |  |   64|      0|#define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  ------------------
  |  |  |  Branch (64:69): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1698|      0|                        file));
 1699|      0|    }
 1700|       |
 1701|       |    /*
 1702|       |     * clean up and return
 1703|       |     */
 1704|      0|    ITERATOR_RELEASE(it);
  ------------------
  |  |  547|      0|#define ITERATOR_RELEASE(x) do { x->release(x); x = NULL; } while(0)
  |  |  ------------------
  |  |  |  Branch (547:67): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1705|       |
 1706|      0|  err_container:
 1707|      0|    netsnmp_directory_container_free(cert_container);
 1708|       |
 1709|      0|  err_index:
 1710|      0|    if (index)
  ------------------
  |  Branch (1710:9): [True: 0, False: 0]
  ------------------
 1711|      0|        fclose(index);
 1712|       |
 1713|      0|    return count;
 1714|      0|}

netsnmp_container_init_list:
   82|      1|{
   83|      1|    if (NULL != containers)
  ------------------
  |  Branch (83:9): [True: 0, False: 1]
  ------------------
   84|      0|        return;
   85|       |
   86|       |    /*
   87|       |     * create a binary arry container to hold container
   88|       |     * factories
   89|       |     */
   90|      1|    containers = netsnmp_container_get_binary_array();
   91|      1|    containers->compare = netsnmp_compare_cstring;
   92|      1|    containers->container_name = strdup("container list");
   93|       |
   94|       |    /*
   95|       |     * register containers
   96|       |     */
   97|      1|    netsnmp_container_binary_array_init();
   98|      1|#ifndef NETSNMP_FEATURE_REMOVE_CONTAINER_LINKED_LIST
   99|      1|    netsnmp_container_ssll_init();
  100|      1|#endif /* NETSNMP_FEATURE_REMOVE_CONTAINER_LINKED_LIST */
  101|      1|#ifndef NETSNMP_FEATURE_REMOVE_CONTAINER_NULL
  102|      1|    netsnmp_container_null_init();
  103|      1|#endif /* NETSNMP_FEATURE_REMOVE_CONTAINER_NULL */
  104|       |
  105|       |    /*
  106|       |     * default aliases for some containers
  107|       |     */
  108|      1|    netsnmp_container_register("table_container",
  109|      1|                               netsnmp_container_get_factory("binary_array"));
  110|       |
  111|      1|#ifndef NETSNMP_FEATURE_REMOVE_CONTAINER_LINKED_LIST
  112|      1|    netsnmp_container_register("linked_list",
  113|      1|                               netsnmp_container_get_factory("sorted_singly_linked_list"));
  114|      1|    netsnmp_container_register("ssll_container",
  115|      1|                               netsnmp_container_get_factory("sorted_singly_linked_list"));
  116|      1|#endif /* NETSNMP_FEATURE_REMOVE_CONTAINER_LINKED_LIST */
  117|       |
  118|      1|    netsnmp_container_register_with_compare
  119|      1|        ("cstring", netsnmp_container_get_factory("binary_array"),
  120|      1|         netsnmp_compare_direct_cstring);
  121|       |
  122|      1|    netsnmp_container_register_with_compare
  123|      1|        ("string", netsnmp_container_get_factory("binary_array"),
  124|      1|         netsnmp_compare_cstring);
  125|      1|    netsnmp_container_register_with_compare
  126|      1|        ("string_binary_array", netsnmp_container_get_factory("binary_array"),
  127|      1|         netsnmp_compare_cstring);
  128|       |
  129|      1|}
netsnmp_container_register_with_compare:
  153|     12|{
  154|     12|    container_type *ct, tmp;
  155|       |
  156|     12|    if (NULL==containers)
  ------------------
  |  Branch (156:9): [True: 0, False: 12]
  ------------------
  157|      0|        return -1;
  158|       |
  159|     12|    tmp.name = NETSNMP_REMOVE_CONST(char *, name);
  ------------------
  |  |   91|     12|    (__extension__ ({ const t tmp = (e); (t)(size_t)tmp; }))
  ------------------
  160|     12|    ct = (container_type *)CONTAINER_FIND(containers, &tmp);
  ------------------
  |  |  391|     12|#define CONTAINER_FIND(x,k)         (x)->find(x,k)
  ------------------
  161|     12|    if (NULL!=ct) {
  ------------------
  |  Branch (161:9): [True: 0, False: 12]
  ------------------
  162|      0|        DEBUGMSGT(("container_registry",
  ------------------
  |  |   64|      0|#define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  ------------------
  |  |  |  Branch (64:69): [Folded - Ignored]
  |  |  ------------------
  ------------------
  163|      0|                   "replacing previous container factory\n"));
  164|      0|        ct->factory = f;
  165|      0|    }
  166|     12|    else {
  167|     12|        ct = SNMP_MALLOC_TYPEDEF(container_type);
  ------------------
  |  |   73|     12|#define SNMP_MALLOC_TYPEDEF(td)  (td *) calloc(1, sizeof(td))
  ------------------
  168|     12|        if (NULL == ct)
  ------------------
  |  Branch (168:13): [True: 0, False: 12]
  ------------------
  169|      0|            return -1;
  170|     12|        ct->name = strdup(name);
  171|     12|        ct->factory = f;
  172|     12|        ct->compare = c;
  173|     12|        CONTAINER_INSERT(containers, ct);
  174|     12|    }
  175|     12|    DEBUGMSGT(("container_registry", "registered container factory %s (%s)\n",
  ------------------
  |  |   64|     12|#define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|     12|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 12, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  149|     12|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  ------------------
  |  |  |  Branch (64:69): [Folded - Ignored]
  |  |  ------------------
  ------------------
  176|     12|               ct->name, f->product));
  177|       |
  178|     12|    return 0;
  179|     12|}
netsnmp_container_register:
  183|      9|{
  184|      9|    return netsnmp_container_register_with_compare(name, f, NULL);
  185|      9|}
netsnmp_container_get_factory:
  191|      6|{
  192|      6|    container_type ct, *found;
  193|       |    
  194|      6|    if (NULL==containers)
  ------------------
  |  Branch (194:9): [True: 0, False: 6]
  ------------------
  195|      0|        return NULL;
  196|       |
  197|      6|    ct.name = type;
  198|      6|    found = (container_type *)CONTAINER_FIND(containers, &ct);
  ------------------
  |  |  391|      6|#define CONTAINER_FIND(x,k)         (x)->find(x,k)
  ------------------
  199|       |
  200|      6|    return found ? found->factory : NULL;
  ------------------
  |  Branch (200:12): [True: 6, False: 0]
  ------------------
  201|      6|}
netsnmp_container_find:
  300|      6|{
  301|      6|    container_type *ct = netsnmp_container_find_ct(type);
  302|      6|    netsnmp_container *c = ct ? (netsnmp_container *)(ct->factory->produce()) : NULL;
  ------------------
  |  Branch (302:28): [True: 6, False: 0]
  ------------------
  303|       |
  304|       |    /*
  305|       |     * provide default compare and ncompare
  306|       |     */
  307|      6|    if (c) {
  ------------------
  |  Branch (307:9): [True: 6, False: 0]
  ------------------
  308|      6|        if (ct->compare)
  ------------------
  |  Branch (308:13): [True: 0, False: 6]
  ------------------
  309|      0|            c->compare = ct->compare;
  310|      6|        else if (NULL == c->compare)
  ------------------
  |  Branch (310:18): [True: 6, False: 0]
  ------------------
  311|      6|            c->compare = netsnmp_compare_netsnmp_index;
  312|       |
  313|      6|        if (NULL == c->ncompare)
  ------------------
  |  Branch (313:13): [True: 6, False: 0]
  ------------------
  314|      6|            c->ncompare = netsnmp_ncompare_netsnmp_index;
  315|      6|    }
  316|       |
  317|      6|    return c;
  318|      6|}
netsnmp_container_add_index:
  325|      3|{
  326|      3|    netsnmp_container *curr = primary;
  327|       |
  328|      3|    if((NULL == new_index) || (NULL == primary)) {
  ------------------
  |  Branch (328:8): [True: 0, False: 3]
  |  Branch (328:31): [True: 0, False: 3]
  ------------------
  329|      0|        snmp_log(LOG_ERR, "add index called with null pointer\n");
  330|      0|        return;
  331|      0|    }
  332|       |
  333|      6|    while(curr->next)
  ------------------
  |  Branch (333:11): [True: 3, False: 3]
  ------------------
  334|      3|        curr = curr->next;
  335|       |
  336|      3|    curr->next = new_index;
  337|      3|    new_index->prev = curr;
  338|      3|}
CONTAINER_INSERT_HELPER:
  341|     24|{
  342|     24|    while(x && x->insert_filter && x->insert_filter(x,k) == 1)
  ------------------
  |  Branch (342:11): [True: 12, False: 12]
  |  Branch (342:16): [True: 0, False: 12]
  |  Branch (342:36): [True: 0, False: 0]
  ------------------
  343|      0|        x = x->next;
  344|     24|    if(x) {
  ------------------
  |  Branch (344:8): [True: 12, False: 12]
  ------------------
  345|     12|        int rc = x->insert(x,k);
  346|     12|        if(rc)
  ------------------
  |  Branch (346:12): [True: 0, False: 12]
  ------------------
  347|      0|            snmp_log(LOG_DEBUG,"error on subcontainer '%s' insert (%d)\n",
  348|      0|                     x->container_name ? x->container_name : "", rc);
  ------------------
  |  Branch (348:22): [True: 0, False: 0]
  ------------------
  349|     12|        else {
  350|     12|            rc = CONTAINER_INSERT_HELPER(x->next, k);
  351|     12|            if(rc)
  ------------------
  |  Branch (351:16): [True: 0, False: 12]
  ------------------
  352|      0|                x->remove(x,k);
  353|     12|        }
  354|     12|        return rc;
  355|     12|    }
  356|     12|    return 0;
  357|     24|}
CONTAINER_INSERT:
  360|     12|{
  361|       |    /** start at first container */
  362|     12|    while(x->prev)
  ------------------
  |  Branch (362:11): [True: 0, False: 12]
  ------------------
  363|      0|        x = x->prev;
  364|     12|    return CONTAINER_INSERT_HELPER(x, k);
  365|     12|}
CONTAINER_FREE:
  469|      1|{
  470|      1|    int  rc2, rc = 0;
  471|       |
  472|      1|    if (!x)
  ------------------
  |  Branch (472:9): [True: 0, False: 1]
  ------------------
  473|      0|        return rc;
  474|       |
  475|       |    /** start at last container */
  476|      1|    while(x->next)
  ------------------
  |  Branch (476:11): [True: 0, False: 1]
  ------------------
  477|      0|        x = x->next;
  478|      2|    while(x) {
  ------------------
  |  Branch (478:11): [True: 1, False: 1]
  ------------------
  479|      1|        netsnmp_container *tmp;
  480|      1|        char *name;
  481|      1|        tmp = x->prev;
  482|      1|        name = x->container_name;
  483|      1|        x->container_name = NULL;
  484|      1|        rc2 = x->cfree(x);
  485|      1|        if (rc2) {
  ------------------
  |  Branch (485:13): [True: 0, False: 1]
  ------------------
  486|      0|            snmp_log(LOG_ERR,"error on subcontainer '%s' cfree (%d)\n",
  487|      0|                     name ? name : "", rc2);
  ------------------
  |  Branch (487:22): [True: 0, False: 0]
  ------------------
  488|      0|            rc = rc2;
  489|      0|        }
  490|      1|        SNMP_FREE(name);
  ------------------
  |  |   62|      1|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 1, False: 0]
  |  |  |  Branch (62:66): [Folded - Ignored]
  |  |  ------------------
  ------------------
  491|      1|        x = tmp;
  492|      1|    }
  493|      1|    return rc;
  494|      1|}
CONTAINER_CLEAR:
  503|      1|{
  504|       |    /** start at last container */
  505|      1|    while(x->next)
  ------------------
  |  Branch (505:11): [True: 0, False: 1]
  ------------------
  506|      0|        x = x->next;
  507|      1|    while(x->prev) {
  ------------------
  |  Branch (507:11): [True: 0, False: 1]
  ------------------
  508|      0|        x->clear(x, NULL, c);
  509|      0|        x = x->prev;
  510|      0|    }
  511|      1|    x->clear(x, f, c);
  512|      1|}
CONTAINER_FREE_ALL:
  521|      1|{
  522|      1|    CONTAINER_CLEAR(x, x->free_item, c);
  523|      1|}
netsnmp_init_container:
  560|      7|{
  561|      7|    if (c == NULL)
  ------------------
  |  Branch (561:9): [True: 0, False: 7]
  ------------------
  562|      0|        return;
  563|       |
  564|      7|    c->init = init;
  565|      7|    c->cfree = cfree;
  566|      7|    c->get_size = size;
  567|      7|    c->compare = cmp;
  568|      7|    c->insert = ins;
  569|      7|    c->remove = rem;
  570|      7|    c->find = fnd;
  571|      7|    c->free_item = netsnmp_container_simple_free;
  572|      7|}
netsnmp_compare_cstring:
  640|    149|{
  641|    149|    const container_type *lhs = lhs_arg;
  642|    149|    const container_type *rhs = rhs_arg;
  643|       |
  644|    149|    return strcmp(lhs->name, rhs->name);
  645|    149|}
container.c:netsnmp_container_get_ct:
  234|     12|{
  235|     12|    container_type ct;
  236|       |
  237|     12|    if (NULL == containers)
  ------------------
  |  Branch (237:9): [True: 0, False: 12]
  ------------------
  238|      0|        return NULL;
  239|       |    
  240|     12|    ct.name = type;
  241|     12|    return (container_type *)CONTAINER_FIND(containers, &ct);
  ------------------
  |  |  391|     12|#define CONTAINER_FIND(x,k)         (x)->find(x,k)
  ------------------
  242|     12|}
container.c:netsnmp_container_find_ct:
  246|      6|{
  247|      6|    container_type    *ct = NULL;
  248|      6|    char              *list, *entry;
  249|      6|    char              *st = NULL;
  250|       |
  251|      6|    if (NULL==type_list)
  ------------------
  |  Branch (251:9): [True: 0, False: 6]
  ------------------
  252|      0|        return NULL;
  253|       |
  254|      6|    list = strdup(type_list);
  255|      6|    if (!list)
  ------------------
  |  Branch (255:9): [True: 0, False: 6]
  ------------------
  256|      0|        return NULL;
  257|      6|    entry = strtok_r(list, ":", &st);
  258|     12|    while (entry) {
  ------------------
  |  Branch (258:12): [True: 12, False: 0]
  ------------------
  259|     12|        ct = netsnmp_container_get_ct(entry);
  260|     12|        if (NULL != ct)
  ------------------
  |  Branch (260:13): [True: 6, False: 6]
  ------------------
  261|      6|            break;
  262|      6|        entry = strtok_r(NULL, ":", &st);
  263|      6|    }
  264|       |
  265|      6|    free(list);
  266|      6|    return ct;
  267|      6|}

netsnmp_binary_array_options_set:
  216|      4|{
  217|      4|#define BA_FLAGS (CONTAINER_KEY_ALLOW_DUPLICATES|CONTAINER_KEY_UNSORTED)
  218|       |
  219|      4|    if (set) {
  ------------------
  |  Branch (219:9): [True: 4, False: 0]
  ------------------
  220|      4|        if ((flags & BA_FLAGS) == flags) {
  ------------------
  |  |  217|      4|#define BA_FLAGS (CONTAINER_KEY_ALLOW_DUPLICATES|CONTAINER_KEY_UNSORTED)
  |  |  ------------------
  |  |  |  |  367|      4|#define CONTAINER_KEY_ALLOW_DUPLICATES             0x00000001
  |  |  ------------------
  |  |               #define BA_FLAGS (CONTAINER_KEY_ALLOW_DUPLICATES|CONTAINER_KEY_UNSORTED)
  |  |  ------------------
  |  |  |  |  368|      4|#define CONTAINER_KEY_UNSORTED                     0x00000002
  |  |  ------------------
  ------------------
  |  Branch (220:13): [True: 4, False: 0]
  ------------------
  221|       |            /** if turning off unsorted, do sort */
  222|      4|            int sort = ((c->flags & CONTAINER_KEY_UNSORTED) &&
  ------------------
  |  |  368|      4|#define CONTAINER_KEY_UNSORTED                     0x00000002
  ------------------
  |  Branch (222:25): [True: 0, False: 4]
  ------------------
  223|      4|                        ! (flags & CONTAINER_KEY_UNSORTED));
  ------------------
  |  |  368|      0|#define CONTAINER_KEY_UNSORTED                     0x00000002
  ------------------
  |  Branch (223:25): [True: 0, False: 0]
  ------------------
  224|      4|            c->flags = flags;
  225|      4|            if (sort) {
  ------------------
  |  Branch (225:17): [True: 0, False: 4]
  ------------------
  226|      0|                binary_array_table *t = (binary_array_table*)c->container_data;
  227|      0|                t->dirty = 1; /* force sort */
  228|      0|                Sort_Array(c);
  229|      0|            }
  230|      4|            return flags;
  231|      4|        } else {
  232|      0|            return -1; /* unsupported flag */
  233|      0|        }
  234|      4|    } else {
  235|      0|        return ((c->flags & flags) == flags);
  236|      0|    }
  237|      4|}
netsnmp_container_get_binary_array:
  793|      6|{
  794|       |    /*
  795|       |     * allocate memory
  796|       |     */
  797|      6|    netsnmp_container *c = SNMP_MALLOC_TYPEDEF(netsnmp_container);
  ------------------
  |  |   73|      6|#define SNMP_MALLOC_TYPEDEF(td)  (td *) calloc(1, sizeof(td))
  ------------------
  798|      6|    if (NULL==c) {
  ------------------
  |  Branch (798:9): [True: 0, False: 6]
  ------------------
  799|      0|        snmp_log(LOG_ERR, "couldn't allocate memory\n");
  800|      0|        return NULL;
  801|      0|    }
  802|       |
  803|      6|    c->container_data = netsnmp_binary_array_initialize();
  804|      6|    if (NULL == c->container_data) {
  ------------------
  |  Branch (804:9): [True: 0, False: 6]
  ------------------
  805|      0|        free(c);
  806|      0|        snmp_log(LOG_ERR, "couldn't allocate memory for container_data\n");
  807|      0|        return NULL;
  808|      0|    }
  809|       |
  810|       |    /*
  811|       |     * NOTE: CHANGES HERE MUST BE DUPLICATED IN duplicate AS WELL!!
  812|       |     */
  813|      6|    netsnmp_init_container(c, NULL, _ba_free, _ba_size, NULL, _ba_insert,
  814|      6|                           _ba_remove, _ba_find);
  815|      6|    c->find_next = _ba_find_next;
  816|      6|    c->get_subset = _ba_get_subset;
  817|      6|    c->get_iterator = _ba_iterator_get;
  818|      6|    c->for_each = _ba_for_each;
  819|      6|    c->clear = _ba_clear;
  820|      6|    c->options = _ba_options;
  821|      6|    c->duplicate = _ba_duplicate;
  822|      6|    c->get_at = netsnmp_binary_array_get_at;
  823|      6|    c->remove_at = netsnmp_binary_array_remove_at;
  824|      6|    c->insert_before = _ba_insert_before;
  825|       |
  826|      6|    return c;
  827|      6|}
netsnmp_container_get_binary_array_factory:
  831|      1|{
  832|      1|    static netsnmp_factory f = { "binary_array",
  833|      1|                                 netsnmp_container_get_binary_array };
  834|       |    
  835|      1|    return &f;
  836|      1|}
netsnmp_container_binary_array_init:
  840|      1|{
  841|      1|    netsnmp_container_register("binary_array",
  842|      1|                               netsnmp_container_get_binary_array_factory());
  843|      1|}
container_binary_array.c:_ba_is_sorted:
  320|     12|{
  321|       |    /*
  322|       |     * The code below has been commented out because it negatively affects
  323|       |     * performance.
  324|       |     */
  325|       |#if 0
  326|       |    const binary_array_table *t = c->container_data;
  327|       |    int i;
  328|       |
  329|       |    for (i = 0; i + 1 < t->count; ++i)
  330|       |        if (c->compare(t->data[i], t->data[i + 1]) > 0)
  331|       |            return 0;
  332|       |#endif
  333|       |
  334|     12|    return 1;
  335|     12|}
container_binary_array.c:binary_search:
  110|     40|{
  111|     40|    binary_array_table *t = (binary_array_table*)c->container_data;
  112|     40|    size_t             len = t->count;
  113|     40|    size_t             half;
  114|     40|    size_t             first = 0;
  115|     40|    size_t             middle = 0; /* init not needed; keeps compiler happy */
  116|     40|    int                result = 0; /* init not needed; keeps compiler happy */
  117|       |
  118|     40|    if (!len) {
  ------------------
  |  Branch (118:9): [True: 0, False: 40]
  ------------------
  119|      0|        if (NULL != next)
  ------------------
  |  Branch (119:13): [True: 0, False: 0]
  ------------------
  120|      0|            *next = 0;
  121|      0|        return -1;
  122|      0|    }
  123|       |
  124|     40|    if (c->flags & CONTAINER_KEY_UNSORTED) {
  ------------------
  |  |  368|     40|#define CONTAINER_KEY_UNSORTED                     0x00000002
  ------------------
  |  Branch (124:9): [True: 0, False: 40]
  ------------------
  125|      0|        if (!exact) {
  ------------------
  |  Branch (125:13): [True: 0, False: 0]
  ------------------
  126|      0|            snmp_log(LOG_ERR, "non-exact search on unsorted container %s?!?\n",
  127|      0|                     c->container_name);
  128|      0|            return -1;
  129|      0|        }
  130|      0|        return linear_search(val, c);
  131|      0|    }
  132|       |
  133|     40|    if (t->dirty)
  ------------------
  |  Branch (133:9): [True: 0, False: 40]
  ------------------
  134|      0|        Sort_Array(c);
  135|       |
  136|    157|    while (len > 0) {
  ------------------
  |  Branch (136:12): [True: 129, False: 28]
  ------------------
  137|    129|        half = len >> 1;
  138|    129|        middle = first + half;
  139|    129|        if ((result = c->compare(t->data[middle], val)) < 0) {
  ------------------
  |  Branch (139:13): [True: 43, False: 86]
  ------------------
  140|     43|            first = middle + 1;
  141|     43|            len = len - half - 1;
  142|     86|        } else if (result == 0) {
  ------------------
  |  Branch (142:20): [True: 12, False: 74]
  ------------------
  143|     12|            first = middle;
  144|     12|            break;
  145|     74|        } else {
  146|     74|            len = half;
  147|     74|        }
  148|    129|    }
  149|       |
  150|     40|    if (first >= t->count) {
  ------------------
  |  Branch (150:9): [True: 4, False: 36]
  ------------------
  151|      4|        if (exact && NULL != next)
  ------------------
  |  Branch (151:13): [True: 4, False: 0]
  |  Branch (151:22): [True: 2, False: 2]
  ------------------
  152|      2|            *next = t->count;
  153|      4|        return -1;
  154|      4|    }
  155|       |
  156|     36|    if (first != middle) {
  ------------------
  |  Branch (156:9): [True: 20, False: 16]
  ------------------
  157|       |        /* last compare wasn't against first, so get actual result */
  158|     20|        result = c->compare(t->data[first], val);
  159|     20|    }
  160|       |
  161|     36|    if(result == 0) {
  ------------------
  |  Branch (161:8): [True: 12, False: 24]
  ------------------
  162|     12|        if (exact && NULL != next)
  ------------------
  |  Branch (162:13): [True: 12, False: 0]
  |  Branch (162:22): [True: 0, False: 12]
  ------------------
  163|      0|            *next = first+1;
  164|     12|        else if (!exact && ++first == t->count) {
  ------------------
  |  Branch (164:18): [True: 0, False: 12]
  |  Branch (164:28): [True: 0, False: 0]
  ------------------
  165|      0|            if (NULL != next)
  ------------------
  |  Branch (165:17): [True: 0, False: 0]
  ------------------
  166|      0|                *next = first;
  167|      0|            first = -1;
  168|      0|        }
  169|     24|    } else if(exact) {
  ------------------
  |  Branch (169:15): [True: 24, False: 0]
  ------------------
  170|     24|        if (NULL != next) {
  ------------------
  |  Branch (170:13): [True: 9, False: 15]
  ------------------
  171|      9|            if (result > 0)
  ------------------
  |  Branch (171:17): [True: 9, False: 0]
  ------------------
  172|      9|                *next = first;
  173|      0|            else
  174|      0|                *next = t->count;
  175|      9|        }
  176|     24|        first = -1;
  177|     24|    }
  178|       |
  179|     36|    return first;
  180|     40|}
container_binary_array.c:netsnmp_binary_array_initialize:
  184|      6|{
  185|      6|    binary_array_table *t;
  186|       |
  187|      6|    t = SNMP_MALLOC_TYPEDEF(binary_array_table);
  ------------------
  |  |   73|      6|#define SNMP_MALLOC_TYPEDEF(td)  (td *) calloc(1, sizeof(td))
  ------------------
  188|      6|    if (t == NULL)
  ------------------
  |  Branch (188:9): [True: 0, False: 6]
  ------------------
  189|      0|        return NULL;
  190|       |
  191|      6|    t->max_size = 0;
  192|      6|    t->count = 0;
  193|      6|    t->dirty = 0;
  194|      6|    t->data = NULL;
  195|       |
  196|      6|    return t;
  197|      6|}
container_binary_array.c:_ba_size:
  696|      1|{
  697|      1|    return netsnmp_binary_array_count(container);
  698|      1|}
container_binary_array.c:netsnmp_binary_array_count:
  241|      1|{
  242|      1|    binary_array_table *t = (binary_array_table*)c->container_data;
  243|       |    /*
  244|       |     * return count
  245|       |     */
  246|      1|    return t ? t->count : 0;
  ------------------
  |  Branch (246:12): [True: 1, False: 0]
  ------------------
  247|      1|}
container_binary_array.c:_ba_insert:
  670|     12|{
  671|     12|    return netsnmp_binary_array_insert(container, data);
  672|     12|}
container_binary_array.c:netsnmp_binary_array_insert:
  516|     12|{
  517|     12|    binary_array_table *t = (binary_array_table*)c->container_data;
  518|     12|    const int duplicates_allowed = c->flags & CONTAINER_KEY_ALLOW_DUPLICATES;
  ------------------
  |  |  367|     12|#define CONTAINER_KEY_ALLOW_DUPLICATES             0x00000001
  ------------------
  519|     12|    const int sorted = !(c->flags & CONTAINER_KEY_UNSORTED);
  ------------------
  |  |  368|     12|#define CONTAINER_KEY_UNSORTED                     0x00000002
  ------------------
  520|     12|    int             i = -2;
  521|     12|    size_t          next, pos;
  522|     12|    void           *entry = NETSNMP_REMOVE_CONST(void *, const_entry);
  ------------------
  |  |   91|     12|    (__extension__ ({ const t tmp = (e); (t)(size_t)tmp; }))
  ------------------
  523|       |
  524|     12|    if (NULL == entry)
  ------------------
  |  Branch (524:9): [True: 0, False: 12]
  ------------------
  525|      0|        return -1;
  526|       |
  527|       |    /*
  528|       |     * check key if we have at least 1 item and duplicates aren't allowed
  529|       |     */
  530|     12|    if (!duplicates_allowed && t->count) {
  ------------------
  |  Branch (530:9): [True: 12, False: 0]
  |  Branch (530:32): [True: 11, False: 1]
  ------------------
  531|     11|        i = binary_search(entry, c, 1, &next);
  532|     11|        if (i >= 0) {
  ------------------
  |  Branch (532:13): [True: 0, False: 11]
  ------------------
  533|      0|            DEBUGMSGTL(("container","not inserting duplicate key\n"));
  ------------------
  |  |   68|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
  534|      0|            return -1;
  535|      0|        }
  536|     11|    }
  537|       | 
  538|       |    /*
  539|       |     * if unsorted, just add at the end
  540|       |     */
  541|     12|    if (!sorted) {
  ------------------
  |  Branch (541:9): [True: 0, False: 12]
  ------------------
  542|      0|        pos = t->count;
  543|     12|    } else {
  544|       |        /** if we haven't searched for key yet, do it now */
  545|     12|        if (-2 == i) {
  ------------------
  |  Branch (545:13): [True: 1, False: 11]
  ------------------
  546|      1|            if (0 == t->count) {
  ------------------
  |  Branch (546:17): [True: 1, False: 0]
  ------------------
  547|      1|                next = 0;
  548|      1|                i = -1;
  549|      1|            } else {
  550|      0|                i = binary_search(entry, c, 1, &next);
  551|      0|            }
  552|      1|        }
  553|       |
  554|     12|        pos = next;
  555|       |        /* if key found, advance past any duplicates */
  556|     12|        if (duplicates_allowed && i >= 0)
  ------------------
  |  Branch (556:13): [True: 0, False: 12]
  |  Branch (556:35): [True: 0, False: 0]
  ------------------
  557|      0|            while (pos < t->count && c->compare(t->data[pos], entry) == 0)
  ------------------
  |  Branch (557:20): [True: 0, False: 0]
  |  Branch (557:38): [True: 0, False: 0]
  ------------------
  558|      0|                ++pos;
  559|     12|    }
  560|       |
  561|     12|    return netsnmp_binary_array_insert_before(c, pos, entry, !sorted);
  562|     12|}
container_binary_array.c:netsnmp_binary_array_insert_before:
  471|     12|{
  472|     12|    binary_array_table *t = (binary_array_table*)c->container_data;
  473|       |
  474|     12|    if (NULL == entry)
  ------------------
  |  Branch (474:9): [True: 0, False: 12]
  ------------------
  475|      0|        return -1;
  476|       |
  477|     12|    if (index > t->count) {
  ------------------
  |  Branch (477:9): [True: 0, False: 12]
  ------------------
  478|      0|        DEBUGMSGTL(("container:insert:before", "index out of range\n"));
  ------------------
  |  |   68|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
  479|      0|        return -1;
  480|      0|    }
  481|       |
  482|       |     /*
  483|       |      * check if we need to resize the array
  484|       |      */
  485|     12|    _ba_resize_check(t);
  486|       |
  487|     12|    netsnmp_assert(t->count < t->max_size);
  ------------------
  |  |   47|     12|#      define netsnmp_assert(x)  do { \
  |  |   48|     12|              if ( x ) \
  |  |  ------------------
  |  |  |  Branch (48:20): [True: 12, False: 0]
  |  |  ------------------
  |  |   49|     12|                 ; \
  |  |   50|     12|              else \
  |  |   51|     12|                 snmp_log(LOG_ERR, \
  |  |   52|      0|                          "netsnmp_assert %s failed %s:%d" NETSNMP_FUNC_FMT, \
  |  |  ------------------
  |  |  |  |   40|      0|#          define NETSNMP_FUNC_FMT " %s()\n"
  |  |  ------------------
  |  |   53|      0|                          __STRING(x),__FILE__,__LINE__, \
  |  |   54|      0|                          NETSNMP_FUNC_PARAM); \
  |  |  ------------------
  |  |  |  |   41|      0|#          define NETSNMP_FUNC_PARAM NETSNMP_FUNCTION
  |  |  |  |  ------------------
  |  |  |  |  |  | 1681|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|     12|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded - Ignored]
  |  |  ------------------
  ------------------
  488|       |
  489|       |    /*
  490|       |     * shift array
  491|       |     */
  492|     12|    memmove(&t->data[index+1], &t->data[index],
  493|     12|            sizeof(void*) * (t->count - index));
  494|       |
  495|       |    /*
  496|       |     * Insert the new entry into the data array
  497|       |     */
  498|     12|    t->data[index] = NETSNMP_REMOVE_CONST(void *, entry);
  ------------------
  |  |   91|     12|    (__extension__ ({ const t tmp = (e); (t)(size_t)tmp; }))
  ------------------
  499|     12|    ++t->count;
  500|       |
  501|     12|    netsnmp_assert(index < t->count);
  ------------------
  |  |   47|     12|#      define netsnmp_assert(x)  do { \
  |  |   48|     12|              if ( x ) \
  |  |  ------------------
  |  |  |  Branch (48:20): [True: 12, False: 0]
  |  |  ------------------
  |  |   49|     12|                 ; \
  |  |   50|     12|              else \
  |  |   51|     12|                 snmp_log(LOG_ERR, \
  |  |   52|      0|                          "netsnmp_assert %s failed %s:%d" NETSNMP_FUNC_FMT, \
  |  |  ------------------
  |  |  |  |   40|      0|#          define NETSNMP_FUNC_FMT " %s()\n"
  |  |  ------------------
  |  |   53|      0|                          __STRING(x),__FILE__,__LINE__, \
  |  |   54|      0|                          NETSNMP_FUNC_PARAM); \
  |  |  ------------------
  |  |  |  |   41|      0|#          define NETSNMP_FUNC_PARAM NETSNMP_FUNCTION
  |  |  |  |  ------------------
  |  |  |  |  |  | 1681|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|     12|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded - Ignored]
  |  |  ------------------
  ------------------
  502|     12|    netsnmp_assert(t->count <= t->max_size);
  ------------------
  |  |   47|     12|#      define netsnmp_assert(x)  do { \
  |  |   48|     12|              if ( x ) \
  |  |  ------------------
  |  |  |  Branch (48:20): [True: 12, False: 0]
  |  |  ------------------
  |  |   49|     12|                 ; \
  |  |   50|     12|              else \
  |  |   51|     12|                 snmp_log(LOG_ERR, \
  |  |   52|      0|                          "netsnmp_assert %s failed %s:%d" NETSNMP_FUNC_FMT, \
  |  |  ------------------
  |  |  |  |   40|      0|#          define NETSNMP_FUNC_FMT " %s()\n"
  |  |  ------------------
  |  |   53|      0|                          __STRING(x),__FILE__,__LINE__, \
  |  |   54|      0|                          NETSNMP_FUNC_PARAM); \
  |  |  ------------------
  |  |  |  |   41|      0|#          define NETSNMP_FUNC_PARAM NETSNMP_FUNCTION
  |  |  |  |  ------------------
  |  |  |  |  |  | 1681|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|     12|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded - Ignored]
  |  |  ------------------
  ------------------
  503|       |
  504|     12|    if (dirty)
  ------------------
  |  Branch (504:9): [True: 0, False: 12]
  ------------------
  505|      0|        t->dirty = 1;
  506|       |
  507|     12|    netsnmp_assert(t->dirty || _ba_is_sorted(c));
  ------------------
  |  |   47|     12|#      define netsnmp_assert(x)  do { \
  |  |   48|     36|              if ( x ) \
  |  |  ------------------
  |  |  |  Branch (48:20): [True: 0, False: 12]
  |  |  |  Branch (48:20): [True: 12, False: 0]
  |  |  ------------------
  |  |   49|     12|                 ; \
  |  |   50|     12|              else \
  |  |   51|     12|                 snmp_log(LOG_ERR, \
  |  |   52|      0|                          "netsnmp_assert %s failed %s:%d" NETSNMP_FUNC_FMT, \
  |  |  ------------------
  |  |  |  |   40|      0|#          define NETSNMP_FUNC_FMT " %s()\n"
  |  |  ------------------
  |  |   53|      0|                          __STRING(x),__FILE__,__LINE__, \
  |  |   54|      0|                          NETSNMP_FUNC_PARAM); \
  |  |  ------------------
  |  |  |  |   41|      0|#          define NETSNMP_FUNC_PARAM NETSNMP_FUNCTION
  |  |  |  |  ------------------
  |  |  |  |  |  | 1681|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|     12|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded - Ignored]
  |  |  ------------------
  ------------------
  508|       |
  509|     12|    ++c->sync;
  510|       |
  511|     12|    return 0;
  512|     12|}
container_binary_array.c:_ba_resize_check:
  442|     12|{
  443|     12|    size_t new_max;
  444|     12|    void ** new_data;
  445|     12|    if (t->max_size > t->count)
  ------------------
  |  Branch (445:9): [True: 10, False: 2]
  ------------------
  446|     10|        return 0; /* resize not needed */
  447|       |
  448|       |    /*
  449|       |     * Table is full, so extend it to double the size, or use 10 elements
  450|       |     * if it is empty.
  451|       |     */
  452|      2|    new_max = t->max_size > 0 ? 2 * t->max_size : 10;
  ------------------
  |  Branch (452:15): [True: 1, False: 1]
  ------------------
  453|      2|    new_data = (void**) realloc(t->data, new_max * sizeof(void*));
  454|      2|    if (new_data == NULL) {
  ------------------
  |  Branch (454:9): [True: 0, False: 2]
  ------------------
  455|      0|        snmp_log(LOG_ERR, "malloc failed in _ba_resize_check\n");
  456|      0|        return -1; /* error */
  457|      0|    }
  458|       |
  459|      2|    memset(new_data + t->max_size, 0x0,
  460|      2|           (new_max - t->max_size) * sizeof(void*));
  461|       |
  462|      2|    t->data = new_data;
  463|      2|    t->max_size = new_max;
  464|       |
  465|      2|    return 1; /* resized */
  466|      2|}
container_binary_array.c:_ba_find:
  658|     30|{
  659|     30|    return netsnmp_binary_array_get(container, data, 1);
  660|     30|}
container_binary_array.c:netsnmp_binary_array_get:
  251|     30|{
  252|     30|    binary_array_table *t = (binary_array_table*)c->container_data;
  253|     30|    int             index = 0;
  254|       |
  255|       |    /*
  256|       |     * if there is no data, return NULL;
  257|       |     */
  258|     30|    if (!t->count)
  ------------------
  |  Branch (258:9): [True: 1, False: 29]
  ------------------
  259|      1|        return NULL;
  260|       |
  261|       |    /*
  262|       |     * if the table is dirty, sort it.
  263|       |     */
  264|     29|    if (t->dirty)
  ------------------
  |  Branch (264:9): [True: 0, False: 29]
  ------------------
  265|      0|        Sort_Array(c);
  266|       |
  267|       |    /*
  268|       |     * if there is a key, search. Otherwise default is 0;
  269|       |     */
  270|     29|    if (key) {
  ------------------
  |  Branch (270:9): [True: 29, False: 0]
  ------------------
  271|     29|        if ((index = binary_search(key, c, exact, NULL)) == -1)
  ------------------
  |  Branch (271:13): [True: 17, False: 12]
  ------------------
  272|     17|            return NULL;
  273|     12|        if (!exact &&
  ------------------
  |  Branch (273:13): [True: 0, False: 12]
  ------------------
  274|     12|            c->flags & CONTAINER_KEY_ALLOW_DUPLICATES) {
  ------------------
  |  |  367|      0|#define CONTAINER_KEY_ALLOW_DUPLICATES             0x00000001
  ------------------
  |  Branch (274:13): [True: 0, False: 0]
  ------------------
  275|      0|            int result;
  276|       |
  277|       |            /*
  278|       |             * If duplicates are allowed, we have to be extra
  279|       |             * sure that we didn't just increment to a duplicate,
  280|       |             * thus causing a getnext loop.
  281|       |             */
  282|      0|            result = c->compare(t->data[index], key);
  283|      0|            while (result == 0) {
  ------------------
  |  Branch (283:20): [True: 0, False: 0]
  ------------------
  284|      0|		DEBUGMSGTL(("container","skipping duplicate key in %s\n",
  ------------------
  |  |   68|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
  285|      0|					    c->container_name));
  286|      0|                if (++index == t->count)
  ------------------
  |  Branch (286:21): [True: 0, False: 0]
  ------------------
  287|      0|                   return NULL;
  288|      0|                result = c->compare(t->data[index], key);
  289|      0|            }
  290|      0|        }
  291|     12|    }
  292|       |
  293|     12|    return t->data[index];
  294|     29|}
container_binary_array.c:_ba_for_each:
  703|      2|{
  704|      2|    netsnmp_binary_array_for_each(container, f, context, 1);
  705|      2|}
container_binary_array.c:netsnmp_binary_array_for_each:
  410|      2|{
  411|      2|    binary_array_table *t = (binary_array_table*)c->container_data;
  412|      2|    size_t             i;
  413|       |
  414|      2|    if (sort && t->dirty)
  ------------------
  |  Branch (414:9): [True: 2, False: 0]
  |  Branch (414:17): [True: 0, False: 2]
  ------------------
  415|      0|        Sort_Array(c);
  416|       |
  417|      2|    for (i = 0; i < t->count; ++i)
  ------------------
  |  Branch (417:17): [True: 0, False: 2]
  ------------------
  418|      0|        (*fe) (t->data[i], context);
  419|      2|}
container_binary_array.c:_ba_options:
  738|      4|{
  739|      4|    return netsnmp_binary_array_options_set(c, set, flags);
  740|      4|}
container_binary_array.c:_ba_iterator_get:
  987|      2|{
  988|      2|    binary_array_iterator* it;
  989|       |
  990|      2|    if(NULL == c)
  ------------------
  |  Branch (990:8): [True: 0, False: 2]
  ------------------
  991|      0|        return NULL;
  992|       |
  993|      2|    it = SNMP_MALLOC_TYPEDEF(binary_array_iterator);
  ------------------
  |  |   73|      2|#define SNMP_MALLOC_TYPEDEF(td)  (td *) calloc(1, sizeof(td))
  ------------------
  994|      2|    if(NULL == it)
  ------------------
  |  Branch (994:8): [True: 0, False: 2]
  ------------------
  995|      0|        return NULL;
  996|       |
  997|      2|    it->base.container = c;
  998|       |    
  999|      2|    it->base.first = (netsnmp_iterator_rtn*)_ba_iterator_first;
 1000|      2|    it->base.next = (netsnmp_iterator_rtn*)_ba_iterator_next;
 1001|      2|    it->base.curr = (netsnmp_iterator_rtn*)_ba_iterator_curr;
 1002|      2|    it->base.last = (netsnmp_iterator_rtn*)_ba_iterator_last;
 1003|      2|    it->base.remove = (netsnmp_iterator_rc*)_ba_iterator_remove;
 1004|      2|    it->base.reset = (netsnmp_iterator_rc*)_ba_iterator_reset;
 1005|      2|    it->base.release = (netsnmp_iterator_rc*)_ba_iterator_release;
 1006|       |
 1007|      2|    (void)_ba_iterator_reset(it);
 1008|       |
 1009|      2|    return (netsnmp_iterator *)it;
 1010|      2|}
container_binary_array.c:_ba_iterator_first:
  906|      2|{
  907|      2|    return _ba_iterator_position(it, 0);
  908|      2|}
container_binary_array.c:_ba_iterator_position:
  871|      2|{
  872|      2|    binary_array_table *t = _ba_it2cont(it);
  873|      2|    if (NULL == t)
  ------------------
  |  Branch (873:9): [True: 0, False: 2]
  ------------------
  874|      0|        return t; /* msg already logged */
  875|       |
  876|      2|    if(it->base.container->sync != it->base.sync) {
  ------------------
  |  Branch (876:8): [True: 0, False: 2]
  ------------------
  877|      0|        DEBUGMSGTL(("container:iterator", "out of sync\n"));
  ------------------
  |  |   68|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
  878|      0|        return NULL;
  879|      0|    }
  880|       |    
  881|      2|    if(0 == t->count) {
  ------------------
  |  Branch (881:8): [True: 2, False: 0]
  ------------------
  882|      2|        DEBUGMSGTL(("container:iterator", "empty\n"));
  ------------------
  |  |   68|      2|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      2|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 2, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      2|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      2|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      2|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      2|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
  883|      2|        return NULL;
  884|      2|    }
  885|      0|    else if(pos >= t->count) {
  ------------------
  |  Branch (885:13): [True: 0, False: 0]
  ------------------
  886|      0|        DEBUGMSGTL(("container:iterator", "end of container\n"));
  ------------------
  |  |   68|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
  887|      0|        return NULL;
  888|      0|    }
  889|       |
  890|      0|    return t->data[ pos ];
  891|      2|}
container_binary_array.c:_ba_it2cont:
  852|      4|{
  853|      4|    if(NULL == it) {
  ------------------
  |  Branch (853:8): [True: 0, False: 4]
  ------------------
  854|      0|        netsnmp_assert(NULL != it);
  ------------------
  |  |   47|      0|#      define netsnmp_assert(x)  do { \
  |  |   48|      0|              if ( x ) \
  |  |  ------------------
  |  |  |  Branch (48:20): [True: 0, False: 0]
  |  |  ------------------
  |  |   49|      0|                 ; \
  |  |   50|      0|              else \
  |  |   51|      0|                 snmp_log(LOG_ERR, \
  |  |   52|      0|                          "netsnmp_assert %s failed %s:%d" NETSNMP_FUNC_FMT, \
  |  |  ------------------
  |  |  |  |   40|      0|#          define NETSNMP_FUNC_FMT " %s()\n"
  |  |  ------------------
  |  |   53|      0|                          __STRING(x),__FILE__,__LINE__, \
  |  |   54|      0|                          NETSNMP_FUNC_PARAM); \
  |  |  ------------------
  |  |  |  |   41|      0|#          define NETSNMP_FUNC_PARAM NETSNMP_FUNCTION
  |  |  |  |  ------------------
  |  |  |  |  |  | 1681|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|      0|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded - Ignored]
  |  |  ------------------
  ------------------
  855|      0|        return NULL;
  856|      0|    }
  857|      4|    if(NULL == it->base.container) {
  ------------------
  |  Branch (857:8): [True: 0, False: 4]
  ------------------
  858|      0|        netsnmp_assert(NULL != it->base.container);
  ------------------
  |  |   47|      0|#      define netsnmp_assert(x)  do { \
  |  |   48|      0|              if ( x ) \
  |  |  ------------------
  |  |  |  Branch (48:20): [True: 0, False: 0]
  |  |  ------------------
  |  |   49|      0|                 ; \
  |  |   50|      0|              else \
  |  |   51|      0|                 snmp_log(LOG_ERR, \
  |  |   52|      0|                          "netsnmp_assert %s failed %s:%d" NETSNMP_FUNC_FMT, \
  |  |  ------------------
  |  |  |  |   40|      0|#          define NETSNMP_FUNC_FMT " %s()\n"
  |  |  ------------------
  |  |   53|      0|                          __STRING(x),__FILE__,__LINE__, \
  |  |   54|      0|                          NETSNMP_FUNC_PARAM); \
  |  |  ------------------
  |  |  |  |   41|      0|#          define NETSNMP_FUNC_PARAM NETSNMP_FUNCTION
  |  |  |  |  ------------------
  |  |  |  |  |  | 1681|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|      0|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded - Ignored]
  |  |  ------------------
  ------------------
  859|      0|        return NULL;
  860|      0|    }
  861|      4|    if(NULL == it->base.container->container_data) {
  ------------------
  |  Branch (861:8): [True: 0, False: 4]
  ------------------
  862|      0|        netsnmp_assert(NULL != it->base.container->container_data);
  ------------------
  |  |   47|      0|#      define netsnmp_assert(x)  do { \
  |  |   48|      0|              if ( x ) \
  |  |  ------------------
  |  |  |  Branch (48:20): [True: 0, False: 0]
  |  |  ------------------
  |  |   49|      0|                 ; \
  |  |   50|      0|              else \
  |  |   51|      0|                 snmp_log(LOG_ERR, \
  |  |   52|      0|                          "netsnmp_assert %s failed %s:%d" NETSNMP_FUNC_FMT, \
  |  |  ------------------
  |  |  |  |   40|      0|#          define NETSNMP_FUNC_FMT " %s()\n"
  |  |  ------------------
  |  |   53|      0|                          __STRING(x),__FILE__,__LINE__, \
  |  |   54|      0|                          NETSNMP_FUNC_PARAM); \
  |  |  ------------------
  |  |  |  |   41|      0|#          define NETSNMP_FUNC_PARAM NETSNMP_FUNCTION
  |  |  |  |  ------------------
  |  |  |  |  |  | 1681|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|      0|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded - Ignored]
  |  |  ------------------
  ------------------
  863|      0|        return NULL;
  864|      0|    }
  865|       |
  866|      4|    return (binary_array_table*)(it->base.container->container_data);
  867|      4|}
container_binary_array.c:_ba_iterator_reset:
  956|      2|{
  957|      2|    binary_array_table* t = _ba_it2cont(it);
  958|      2|    if(NULL == t) {
  ------------------
  |  Branch (958:8): [True: 0, False: 2]
  ------------------
  959|      0|        netsnmp_assert(NULL != t);
  ------------------
  |  |   47|      0|#      define netsnmp_assert(x)  do { \
  |  |   48|      0|              if ( x ) \
  |  |  ------------------
  |  |  |  Branch (48:20): [True: 0, False: 0]
  |  |  ------------------
  |  |   49|      0|                 ; \
  |  |   50|      0|              else \
  |  |   51|      0|                 snmp_log(LOG_ERR, \
  |  |   52|      0|                          "netsnmp_assert %s failed %s:%d" NETSNMP_FUNC_FMT, \
  |  |  ------------------
  |  |  |  |   40|      0|#          define NETSNMP_FUNC_FMT " %s()\n"
  |  |  ------------------
  |  |   53|      0|                          __STRING(x),__FILE__,__LINE__, \
  |  |   54|      0|                          NETSNMP_FUNC_PARAM); \
  |  |  ------------------
  |  |  |  |   41|      0|#          define NETSNMP_FUNC_PARAM NETSNMP_FUNCTION
  |  |  |  |  ------------------
  |  |  |  |  |  | 1681|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|      0|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded - Ignored]
  |  |  ------------------
  ------------------
  960|      0|        return -1;
  961|      0|    }
  962|       |
  963|      2|    if (t->dirty)
  ------------------
  |  Branch (963:9): [True: 0, False: 2]
  ------------------
  964|      0|        Sort_Array(it->base.container);
  965|       |
  966|       |    /*
  967|       |     * save sync count, to make sure container doesn't change while
  968|       |     * iterator is in use.
  969|       |     */
  970|      2|    it->base.sync = it->base.container->sync;
  971|       |
  972|      2|    it->pos = 0;
  973|       |
  974|      2|    return 0;
  975|      2|}
container_binary_array.c:_ba_iterator_release:
  979|      2|{
  980|      2|    free(it);
  981|       |
  982|      2|    return 0;
  983|      2|}

netsnmp_container_get_ssll:
  320|      1|{
  321|       |    /*
  322|       |     * allocate memory
  323|       |     */
  324|      1|    sl_container *sl = SNMP_MALLOC_TYPEDEF(sl_container);
  ------------------
  |  |   73|      1|#define SNMP_MALLOC_TYPEDEF(td)  (td *) calloc(1, sizeof(td))
  ------------------
  325|      1|    if (NULL==sl) {
  ------------------
  |  Branch (325:9): [True: 0, False: 1]
  ------------------
  326|      0|        snmp_log(LOG_ERR, "couldn't allocate memory\n");
  327|      0|        return NULL;
  328|      0|    }
  329|       |
  330|      1|    netsnmp_init_container((netsnmp_container *)sl, NULL, _ssll_free,
  331|      1|                           _ssll_size, NULL, _ssll_insert, _ssll_remove,
  332|      1|                           _ssll_find);
  333|      1|    sl->c.find_next = _ssll_find_next;
  334|      1|    sl->c.get_subset = NULL;
  335|      1|    sl->c.get_iterator =_ssll_iterator_get;
  336|      1|    sl->c.for_each = _ssll_for_each;
  337|      1|    sl->c.clear = _ssll_clear;
  338|       |
  339|      1|    return &sl->c;
  340|      1|}
netsnmp_container_get_usll:
  344|      1|{
  345|       |    /*
  346|       |     * allocate memory
  347|       |     */
  348|      1|    sl_container *sl = (sl_container *)netsnmp_container_get_ssll();
  349|      1|    if (NULL==sl)
  ------------------
  |  Branch (349:9): [True: 0, False: 1]
  ------------------
  350|      0|        return NULL; /* msg already logged */
  351|       |
  352|      1|    sl->unsorted = 1;
  353|       |
  354|      1|    return (netsnmp_container*)sl;
  355|      1|}
netsnmp_container_get_singly_linked_list:
  359|      1|{
  360|      1|    sl_container *sl = (sl_container *)netsnmp_container_get_usll();
  361|      1|    if (NULL == sl)
  ------------------
  |  Branch (361:9): [True: 0, False: 1]
  ------------------
  362|      0|        return NULL; /* error already logged */
  363|       |
  364|      1|    sl->fifo = fifo;
  365|       |
  366|      1|    return (netsnmp_container *)sl;
  367|      1|}
netsnmp_container_get_fifo:
  371|      1|{
  372|      1|    return netsnmp_container_get_singly_linked_list(1);
  373|      1|}
netsnmp_container_ssll_init:
  377|      1|{
  378|      1|    static netsnmp_factory ssll = {
  379|      1|        "sorted_singly_linked_list",
  380|      1|        netsnmp_container_get_ssll
  381|      1|    };
  382|      1|    static netsnmp_factory usll = {
  383|      1|        "unsorted_singly_linked_list-lifo",
  384|      1|        netsnmp_container_get_usll
  385|      1|    };
  386|      1|    static netsnmp_factory fifo = {
  387|      1|        "unsorted_singly_linked_list-fifo",
  388|      1|        netsnmp_container_get_fifo
  389|      1|    };
  390|       |
  391|      1|    netsnmp_container_register("sorted_singly_linked_list", &ssll);
  392|      1|    netsnmp_container_register("unsorted_singly_linked_list", &usll);
  393|      1|    netsnmp_container_register("lifo", &usll);
  394|      1|    netsnmp_container_register("fifo", &fifo);
  395|      1|}
container_list_ssll.c:_ssll_free:
  110|      1|{
  111|      1|    if(c) {
  ------------------
  |  Branch (111:8): [True: 1, False: 0]
  ------------------
  112|      1|        free(c);
  113|      1|    }
  114|      1|    return 0;
  115|      1|}
container_list_ssll.c:_ssll_clear:
  287|      1|{
  288|      1|    sl_container *sl = (sl_container*)c;
  289|      1|    sl_node  *curr, *next;
  290|       |    
  291|      1|    if(NULL == c)
  ------------------
  |  Branch (291:8): [True: 0, False: 1]
  ------------------
  292|      0|        return;
  293|       |    
  294|      1|    for(curr = sl->head; curr; curr = next) {
  ------------------
  |  Branch (294:26): [True: 0, False: 1]
  ------------------
  295|       |
  296|      0|        next = curr->next;
  297|       |
  298|      0|        if( NULL != f ) {
  ------------------
  |  Branch (298:13): [True: 0, False: 0]
  ------------------
  299|      0|            curr->next = NULL;
  300|      0|            (*f) ((void *)curr->data, context);
  301|      0|        }
  302|       |
  303|       |        /*
  304|       |         * free our node structure, but not the data
  305|       |         */
  306|      0|        free(curr);
  307|      0|    }
  308|      1|    sl->head = NULL;
  309|      1|    sl->count = 0;
  310|      1|    ++c->sync;
  311|      1|}

netsnmp_container_get_null_factory:
  173|      1|{
  174|      1|    static netsnmp_factory f = { "null",
  175|      1|                                 netsnmp_container_get_null};
  176|       |    
  177|      1|    DEBUGMSGTL(("container:null:get_null_factory","in\n"));
  ------------------
  |  |   68|      1|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      1|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      1|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      1|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      1|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
  178|      1|    return &f;
  179|      1|}
netsnmp_container_null_init:
  183|      1|{
  184|      1|    netsnmp_container_register("null",
  185|      1|                               netsnmp_container_get_null_factory());
  186|      1|}

netsnmp_free_all_list_data:
   49|      1|{
   50|      1|    netsnmp_data_list *tmpptr;
   51|      1|    for (; head;) {
  ------------------
  |  Branch (51:12): [True: 0, False: 1]
  ------------------
   52|      0|        netsnmp_free_list_data(head);
   53|      0|        tmpptr = head;
   54|      0|        head = head->next;
   55|      0|        SNMP_FREE(tmpptr);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded - Ignored]
  |  |  ------------------
  ------------------
   56|      0|    }
   57|      1|}

netsnmp_ds_set_boolean:
  201|      4|{
  202|      4|    if (storeid < 0 || storeid >= NETSNMP_DS_MAX_IDS || 
  ------------------
  |  |   38|      8|#define NETSNMP_DS_MAX_IDS 3
  ------------------
  |  Branch (202:9): [True: 0, False: 4]
  |  Branch (202:24): [True: 0, False: 4]
  ------------------
  203|      4|	which   < 0 || which   >= NETSNMP_DS_MAX_SUBIDS) {
  ------------------
  |  |   39|      4|#define NETSNMP_DS_MAX_SUBIDS 64        /* needs to be a multiple of 8 */
  ------------------
  |  Branch (203:2): [True: 0, False: 4]
  |  Branch (203:17): [True: 0, False: 4]
  ------------------
  204|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  218|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  205|      0|    }
  206|       |
  207|      4|    DEBUGMSGTL(("netsnmp_ds_set_boolean", "Setting %s:%d = %d/%s\n",
  ------------------
  |  |   68|      4|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      4|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 2, False: 2]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      4|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      2|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      2|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      2|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (166:52): [True: 2, False: 0]
  |  |  |  |  |  Branch (166:64): [True: 2, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
  208|      4|                stores[storeid], which, value, ((value) ? "True" : "False")));
  209|       |
  210|      4|    if (value > 0) {
  ------------------
  |  Branch (210:9): [True: 4, False: 0]
  ------------------
  211|      4|        netsnmp_ds_booleans[storeid][which/8] |= (1 << (which % 8));
  212|      4|    } else {
  213|      0|        netsnmp_ds_booleans[storeid][which/8] &= (0xff7f >> (7 - (which % 8)));
  214|      0|    }
  215|       |
  216|      4|    return SNMPERR_SUCCESS;
  ------------------
  |  |  217|      4|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  217|      4|}
netsnmp_ds_get_boolean:
  242|  6.31M|{
  243|  6.31M|    if (storeid < 0 || storeid >= NETSNMP_DS_MAX_IDS || 
  ------------------
  |  |   38|  12.6M|#define NETSNMP_DS_MAX_IDS 3
  ------------------
  |  Branch (243:9): [True: 0, False: 6.31M]
  |  Branch (243:24): [True: 0, False: 6.31M]
  ------------------
  244|  6.31M|	which   < 0 || which   >= NETSNMP_DS_MAX_SUBIDS) {
  ------------------
  |  |   39|  6.31M|#define NETSNMP_DS_MAX_SUBIDS 64        /* needs to be a multiple of 8 */
  ------------------
  |  Branch (244:2): [True: 0, False: 6.31M]
  |  Branch (244:17): [True: 0, False: 6.31M]
  ------------------
  245|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  218|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  246|      0|    }
  247|       |
  248|  6.31M|    return (netsnmp_ds_booleans[storeid][which/8] & (1 << (which % 8))) ? 1:0;
  ------------------
  |  Branch (248:12): [True: 48, False: 6.31M]
  ------------------
  249|  6.31M|}
netsnmp_ds_set_int:
  253|      2|{
  254|      2|    if (storeid < 0 || storeid >= NETSNMP_DS_MAX_IDS || 
  ------------------
  |  |   38|      4|#define NETSNMP_DS_MAX_IDS 3
  ------------------
  |  Branch (254:9): [True: 0, False: 2]
  |  Branch (254:24): [True: 0, False: 2]
  ------------------
  255|      2|	which   < 0 || which   >= NETSNMP_DS_MAX_SUBIDS) {
  ------------------
  |  |   39|      2|#define NETSNMP_DS_MAX_SUBIDS 64        /* needs to be a multiple of 8 */
  ------------------
  |  Branch (255:2): [True: 0, False: 2]
  |  Branch (255:17): [True: 0, False: 2]
  ------------------
  256|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  218|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  257|      0|    }
  258|       |
  259|      2|    DEBUGMSGTL(("netsnmp_ds_set_int", "Setting %s:%d = %d\n",
  ------------------
  |  |   68|      2|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      2|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 2]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
  260|      2|                stores[storeid], which, value));
  261|       |
  262|      2|    netsnmp_ds_integers[storeid][which] = value;
  263|      2|    return SNMPERR_SUCCESS;
  ------------------
  |  |  217|      2|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  264|      2|}
netsnmp_ds_get_int:
  268|  18.8k|{
  269|  18.8k|    if (storeid < 0 || storeid >= NETSNMP_DS_MAX_IDS || 
  ------------------
  |  |   38|  37.6k|#define NETSNMP_DS_MAX_IDS 3
  ------------------
  |  Branch (269:9): [True: 0, False: 18.8k]
  |  Branch (269:24): [True: 0, False: 18.8k]
  ------------------
  270|  18.8k|	which   < 0 || which   >= NETSNMP_DS_MAX_SUBIDS) {
  ------------------
  |  |   39|  18.8k|#define NETSNMP_DS_MAX_SUBIDS 64        /* needs to be a multiple of 8 */
  ------------------
  |  Branch (270:2): [True: 0, False: 18.8k]
  |  Branch (270:17): [True: 0, False: 18.8k]
  ------------------
  271|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  218|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  272|      0|    }
  273|       |
  274|  18.8k|    return netsnmp_ds_integers[storeid][which];
  275|  18.8k|}
netsnmp_ds_set_string:
  279|      5|{
  280|      5|    if (storeid < 0 || storeid >= NETSNMP_DS_MAX_IDS || 
  ------------------
  |  |   38|     10|#define NETSNMP_DS_MAX_IDS 3
  ------------------
  |  Branch (280:9): [True: 0, False: 5]
  |  Branch (280:24): [True: 0, False: 5]
  ------------------
  281|      5|	which   < 0 || which   >= NETSNMP_DS_MAX_SUBIDS) {
  ------------------
  |  |   39|      5|#define NETSNMP_DS_MAX_SUBIDS 64        /* needs to be a multiple of 8 */
  ------------------
  |  Branch (281:2): [True: 0, False: 5]
  |  Branch (281:17): [True: 0, False: 5]
  ------------------
  282|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  218|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  283|      0|    }
  284|       |
  285|      5|    DEBUGMSGTL(("netsnmp_ds_set_string", "Setting %s:%d = \"%s\"\n",
  ------------------
  |  |   68|      5|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      5|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 5, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|     10|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      5|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      5|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      5|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (166:52): [True: 5, False: 0]
  |  |  |  |  |  Branch (166:64): [True: 5, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
  286|      5|                stores[storeid], which, (value ? value : "(null)")));
  287|       |
  288|       |    /*
  289|       |     * is some silly person is calling us with our own pointer?
  290|       |     */
  291|      5|    if (netsnmp_ds_strings[storeid][which] == value)
  ------------------
  |  Branch (291:9): [True: 0, False: 5]
  ------------------
  292|      0|        return SNMPERR_SUCCESS;
  ------------------
  |  |  217|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  293|       |
  294|      5|    snmp_res_lock(MT_LIBRARY_ID, MT_LIB_SESSION);
  ------------------
  |  |   79|      5|#define snmp_res_lock(x,y) do {} while (0)
  |  |  ------------------
  |  |  |  Branch (79:41): [Folded - Ignored]
  |  |  ------------------
  ------------------
  295|      5|    if (netsnmp_ds_strings[storeid][which] != NULL) {
  ------------------
  |  Branch (295:9): [True: 1, False: 4]
  ------------------
  296|      1|        free(netsnmp_ds_strings[storeid][which]);
  297|      1|	netsnmp_ds_strings[storeid][which] = NULL;
  298|      1|    }
  299|      5|    snmp_res_unlock(MT_LIBRARY_ID, MT_LIB_SESSION);
  ------------------
  |  |   80|      5|#define snmp_res_unlock(x,y) do {} while (0)
  |  |  ------------------
  |  |  |  Branch (80:43): [Folded - Ignored]
  |  |  ------------------
  ------------------
  300|       |
  301|      5|    if (value) {
  ------------------
  |  Branch (301:9): [True: 5, False: 0]
  ------------------
  302|      5|        netsnmp_ds_strings[storeid][which] = strdup(value);
  303|      5|    } else {
  304|      0|        netsnmp_ds_strings[storeid][which] = NULL;
  305|      0|    }
  306|       |
  307|      5|    return SNMPERR_SUCCESS;
  ------------------
  |  |  217|      5|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  308|      5|}
netsnmp_ds_get_string:
  312|  19.2k|{
  313|  19.2k|    if (storeid < 0 || storeid >= NETSNMP_DS_MAX_IDS || 
  ------------------
  |  |   38|  38.5k|#define NETSNMP_DS_MAX_IDS 3
  ------------------
  |  Branch (313:9): [True: 0, False: 19.2k]
  |  Branch (313:24): [True: 0, False: 19.2k]
  ------------------
  314|  19.2k|	which   < 0 || which   >= NETSNMP_DS_MAX_SUBIDS) {
  ------------------
  |  |   39|  19.2k|#define NETSNMP_DS_MAX_SUBIDS 64        /* needs to be a multiple of 8 */
  ------------------
  |  Branch (314:2): [True: 0, False: 19.2k]
  |  Branch (314:17): [True: 0, False: 19.2k]
  ------------------
  315|      0|        return NULL;
  316|      0|    }
  317|       |
  318|  19.2k|    return netsnmp_ds_strings[storeid][which];
  319|  19.2k|}
netsnmp_ds_register_config:
  439|     43|{
  440|     43|    netsnmp_ds_read_config *drsp;
  441|       |
  442|     43|    if (storeid < 0 || storeid >= NETSNMP_DS_MAX_IDS    || 
  ------------------
  |  |   38|     86|#define NETSNMP_DS_MAX_IDS 3
  ------------------
  |  Branch (442:9): [True: 0, False: 43]
  |  Branch (442:24): [True: 0, False: 43]
  ------------------
  443|     43|	which   < 0 || which   >= NETSNMP_DS_MAX_SUBIDS || token == NULL) {
  ------------------
  |  |   39|     86|#define NETSNMP_DS_MAX_SUBIDS 64        /* needs to be a multiple of 8 */
  ------------------
  |  Branch (443:2): [True: 0, False: 43]
  |  Branch (443:17): [True: 0, False: 43]
  |  Branch (443:53): [True: 0, False: 43]
  ------------------
  444|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  218|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  445|      0|    }
  446|       |
  447|     43|    if (netsnmp_ds_configs == NULL) {
  ------------------
  |  Branch (447:9): [True: 1, False: 42]
  ------------------
  448|      1|        netsnmp_ds_configs = SNMP_MALLOC_TYPEDEF(netsnmp_ds_read_config);
  ------------------
  |  |   73|      1|#define SNMP_MALLOC_TYPEDEF(td)  (td *) calloc(1, sizeof(td))
  ------------------
  449|      1|        if (netsnmp_ds_configs == NULL)
  ------------------
  |  Branch (449:13): [True: 0, False: 1]
  ------------------
  450|      0|            return SNMPERR_GENERR;
  ------------------
  |  |  218|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  451|      1|        drsp = netsnmp_ds_configs;
  452|     42|    } else {
  453|  1.69k|        for (drsp = netsnmp_ds_configs; drsp->next != NULL; drsp = drsp->next);
  ------------------
  |  Branch (453:41): [True: 1.65k, False: 42]
  ------------------
  454|     42|        drsp->next = SNMP_MALLOC_TYPEDEF(netsnmp_ds_read_config);
  ------------------
  |  |   73|     42|#define SNMP_MALLOC_TYPEDEF(td)  (td *) calloc(1, sizeof(td))
  ------------------
  455|     42|        if (drsp->next == NULL)
  ------------------
  |  Branch (455:13): [True: 0, False: 42]
  ------------------
  456|      0|            return SNMPERR_GENERR;
  ------------------
  |  |  218|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  457|     42|        drsp = drsp->next;
  458|     42|    }
  459|       |
  460|     43|    drsp->type    = type;
  461|     43|    drsp->ftype   = strdup(ftype);
  462|     43|    drsp->token   = strdup(token);
  463|     43|    drsp->storeid = storeid;
  464|     43|    drsp->which   = which;
  465|       |
  466|     43|    switch (type) {
  ------------------
  |  Branch (466:13): [True: 0, False: 43]
  ------------------
  467|     13|    case ASN_BOOLEAN:
  ------------------
  |  |   72|     13|#define ASN_BOOLEAN	    0x01U
  ------------------
  |  Branch (467:5): [True: 13, False: 30]
  ------------------
  468|     13|        register_config_handler(ftype, token, netsnmp_ds_handle_config, NULL,
  469|     13|                                "(1|yes|true|0|no|false)");
  470|     13|        break;
  471|       |
  472|      8|    case ASN_INTEGER:
  ------------------
  |  |   75|      8|#define ASN_INTEGER	    0x02U
  ------------------
  |  Branch (472:5): [True: 8, False: 35]
  ------------------
  473|      8|        register_config_handler(ftype, token, netsnmp_ds_handle_config, NULL,
  474|      8|                                "integerValue");
  475|      8|        break;
  476|       |
  477|     22|    case ASN_OCTET_STR:
  ------------------
  |  |   78|     22|#define ASN_OCTET_STR	    0x04U
  ------------------
  |  Branch (477:5): [True: 22, False: 21]
  ------------------
  478|     22|        register_config_handler(ftype, token, netsnmp_ds_handle_config, NULL,
  479|     22|                                "string");
  480|     22|        break;
  481|       |
  482|     43|    }
  483|     43|    return SNMPERR_SUCCESS;
  ------------------
  |  |  217|     43|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  484|     43|}
netsnmp_ds_register_premib:
  489|     23|{
  490|     23|    netsnmp_ds_read_config *drsp;
  491|       |
  492|     23|    if (storeid < 0 || storeid >= NETSNMP_DS_MAX_IDS    || 
  ------------------
  |  |   38|     46|#define NETSNMP_DS_MAX_IDS 3
  ------------------
  |  Branch (492:9): [True: 0, False: 23]
  |  Branch (492:24): [True: 0, False: 23]
  ------------------
  493|     23|	which   < 0 || which   >= NETSNMP_DS_MAX_SUBIDS || token == NULL) {
  ------------------
  |  |   39|     46|#define NETSNMP_DS_MAX_SUBIDS 64        /* needs to be a multiple of 8 */
  ------------------
  |  Branch (493:2): [True: 0, False: 23]
  |  Branch (493:17): [True: 0, False: 23]
  |  Branch (493:53): [True: 0, False: 23]
  ------------------
  494|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  218|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  495|      0|    }
  496|       |
  497|     23|    if (netsnmp_ds_configs == NULL) {
  ------------------
  |  Branch (497:9): [True: 0, False: 23]
  ------------------
  498|      0|        netsnmp_ds_configs = SNMP_MALLOC_TYPEDEF(netsnmp_ds_read_config);
  ------------------
  |  |   73|      0|#define SNMP_MALLOC_TYPEDEF(td)  (td *) calloc(1, sizeof(td))
  ------------------
  499|      0|        if (netsnmp_ds_configs == NULL)
  ------------------
  |  Branch (499:13): [True: 0, False: 0]
  ------------------
  500|      0|            return SNMPERR_GENERR;
  ------------------
  |  |  218|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  501|      0|        drsp = netsnmp_ds_configs;
  502|     23|    } else {
  503|    451|        for (drsp = netsnmp_ds_configs; drsp->next != NULL; drsp = drsp->next);
  ------------------
  |  Branch (503:41): [True: 428, False: 23]
  ------------------
  504|     23|        drsp->next = SNMP_MALLOC_TYPEDEF(netsnmp_ds_read_config);
  ------------------
  |  |   73|     23|#define SNMP_MALLOC_TYPEDEF(td)  (td *) calloc(1, sizeof(td))
  ------------------
  505|     23|        if (drsp->next == NULL)
  ------------------
  |  Branch (505:13): [True: 0, False: 23]
  ------------------
  506|      0|            return SNMPERR_GENERR;
  ------------------
  |  |  218|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  507|     23|        drsp = drsp->next;
  508|     23|    }
  509|       |
  510|     23|    drsp->type    = type;
  511|     23|    drsp->ftype   = strdup(ftype);
  512|     23|    drsp->token   = strdup(token);
  513|     23|    drsp->storeid = storeid;
  514|     23|    drsp->which   = which;
  515|       |
  516|     23|    switch (type) {
  ------------------
  |  Branch (516:13): [True: 0, False: 23]
  ------------------
  517|     17|    case ASN_BOOLEAN:
  ------------------
  |  |   72|     17|#define ASN_BOOLEAN	    0x01U
  ------------------
  |  Branch (517:5): [True: 17, False: 6]
  ------------------
  518|     17|        register_prenetsnmp_mib_handler(ftype, token, netsnmp_ds_handle_config,
  519|     17|                                        NULL, "(1|yes|true|0|no|false)");
  520|     17|        break;
  521|       |
  522|      4|    case ASN_INTEGER:
  ------------------
  |  |   75|      4|#define ASN_INTEGER	    0x02U
  ------------------
  |  Branch (522:5): [True: 4, False: 19]
  ------------------
  523|      4|        register_prenetsnmp_mib_handler(ftype, token, netsnmp_ds_handle_config,
  524|      4|                                        NULL, "integerValue");
  525|      4|        break;
  526|       |
  527|      2|    case ASN_OCTET_STR:
  ------------------
  |  |   78|      2|#define ASN_OCTET_STR	    0x04U
  ------------------
  |  Branch (527:5): [True: 2, False: 21]
  ------------------
  528|      2|        register_prenetsnmp_mib_handler(ftype, token, netsnmp_ds_handle_config,
  529|      2|                                        NULL, "string");
  530|      2|        break;
  531|       |
  532|     23|    }
  533|     23|    return SNMPERR_SUCCESS;
  ------------------
  |  |  217|     23|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  534|     23|}

divBy10:
   40|  3.06k|{
   41|  3.06k|    unsigned long   ulT;
   42|  3.06k|    unsigned long   ulQ;
   43|  3.06k|    unsigned long   ulR;
   44|       |
   45|       |    /*
   46|       |     * top 16 bits 
   47|       |     */
   48|  3.06k|    ulT = (u64.high >> 16) & 0x0ffff;
   49|  3.06k|    ulQ = ulT / 10;
   50|  3.06k|    ulR = ulT % 10;
   51|  3.06k|    pu64Q->high = ulQ << 16;
   52|       |
   53|       |    /*
   54|       |     * next 16 
   55|       |     */
   56|  3.06k|    ulT = (u64.high & 0x0ffff);
   57|  3.06k|    ulT += (ulR << 16);
   58|  3.06k|    ulQ = ulT / 10;
   59|  3.06k|    ulR = ulT % 10;
   60|  3.06k|    pu64Q->high = pu64Q->high | ulQ;
   61|       |
   62|       |    /*
   63|       |     * next 16 
   64|       |     */
   65|  3.06k|    ulT = ((u64.low >> 16) & 0x0ffff) + (ulR << 16);
   66|  3.06k|    ulQ = ulT / 10;
   67|  3.06k|    ulR = ulT % 10;
   68|  3.06k|    pu64Q->low = ulQ << 16;
   69|       |
   70|       |    /*
   71|       |     * final 16 
   72|       |     */
   73|  3.06k|    ulT = (u64.low & 0x0ffff);
   74|  3.06k|    ulT += (ulR << 16);
   75|  3.06k|    ulQ = ulT / 10;
   76|  3.06k|    ulR = ulT % 10;
   77|  3.06k|    pu64Q->low = pu64Q->low | ulQ;
   78|       |
   79|  3.06k|    *puR = (unsigned int) (ulR);
   80|  3.06k|}
incrByU32:
  150|     59|{
  151|     59|    uint32_t tmp;
  152|       |
  153|     59|    tmp = pu64->low;
  154|     59|    pu64->low = (uint32_t)(tmp + u32);
  155|     59|    if (pu64->low < tmp)
  ------------------
  |  Branch (155:9): [True: 19, False: 40]
  ------------------
  156|     19|        pu64->high = (uint32_t)(pu64->high + 1);
  157|     59|}
isZeroU64:
  241|  3.06k|{
  242|  3.06k|    return pu64->low == 0 && pu64->high == 0;
  ------------------
  |  Branch (242:12): [True: 289, False: 2.77k]
  |  Branch (242:30): [True: 198, False: 91]
  ------------------
  243|  3.06k|}
printU64:
  402|    198|{
  403|    198|    struct counter64 u64a;
  404|    198|    struct counter64 u64b;
  405|       |
  406|    198|    char            aRes[I64CHARSZ + 1];
  407|    198|    unsigned int    u;
  408|    198|    int             j;
  409|       |
  410|    198|    u64a = *pu64;
  411|    198|    aRes[I64CHARSZ] = 0;
  ------------------
  |  |   16|    198|#define I64CHARSZ 21
  ------------------
  412|  3.06k|    for (j = 0; j < I64CHARSZ; j++) {
  ------------------
  |  |   16|  3.06k|#define I64CHARSZ 21
  ------------------
  |  Branch (412:17): [True: 3.06k, False: 0]
  ------------------
  413|  3.06k|        divBy10(u64a, &u64b, &u);
  414|  3.06k|        aRes[(I64CHARSZ - 1) - j] = (char) ('0' + u);
  ------------------
  |  |   16|  3.06k|#define I64CHARSZ 21
  ------------------
  415|  3.06k|        u64a = u64b;
  416|  3.06k|        if (isZeroU64(&u64a))
  ------------------
  |  Branch (416:13): [True: 198, False: 2.86k]
  ------------------
  417|    198|            break;
  418|  3.06k|    }
  419|    198|    strcpy(buf, &aRes[(I64CHARSZ - 1) - j]);
  ------------------
  |  |   16|    198|#define I64CHARSZ 21
  ------------------
  420|    198|}
printI64:
  426|     94|{
  427|     94|    struct counter64 u64a;
  428|       |
  429|     94|    if (pu64->high & 0x80000000) {
  ------------------
  |  Branch (429:9): [True: 59, False: 35]
  ------------------
  430|     59|        u64a.high = (uint32_t) ~pu64->high;
  431|     59|        u64a.low = (uint32_t) ~pu64->low;
  432|     59|        incrByU32(&u64a, 1);    /* bit invert and incr by 1 to print 2s complement */
  433|     59|        buf[0] = '-';
  434|     59|        printU64(buf + 1, &u64a);
  435|     59|    } else {
  436|     35|        printU64(buf, pu64);
  437|     35|    }
  438|     94|}

netsnmp_large_fd_setfd:
  120|  1.74k|{
  121|  1.74k|    netsnmp_assert(fd >= 0);
  ------------------
  |  |   47|  1.74k|#      define netsnmp_assert(x)  do { \
  |  |   48|  1.74k|              if ( x ) \
  |  |  ------------------
  |  |  |  Branch (48:20): [True: 1.74k, False: 0]
  |  |  ------------------
  |  |   49|  1.74k|                 ; \
  |  |   50|  1.74k|              else \
  |  |   51|  1.74k|                 snmp_log(LOG_ERR, \
  |  |   52|      0|                          "netsnmp_assert %s failed %s:%d" NETSNMP_FUNC_FMT, \
  |  |  ------------------
  |  |  |  |   40|      0|#          define NETSNMP_FUNC_FMT " %s()\n"
  |  |  ------------------
  |  |   53|      0|                          __STRING(x),__FILE__,__LINE__, \
  |  |   54|      0|                          NETSNMP_FUNC_PARAM); \
  |  |  ------------------
  |  |  |  |   41|      0|#          define NETSNMP_FUNC_PARAM NETSNMP_FUNCTION
  |  |  |  |  ------------------
  |  |  |  |  |  | 1681|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|  1.74k|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded - Ignored]
  |  |  ------------------
  ------------------
  122|       |
  123|  1.74k|    while (fd >= (int)fdset->lfs_setsize)
  ------------------
  |  Branch (123:12): [True: 0, False: 1.74k]
  ------------------
  124|      0|        netsnmp_large_fd_set_resize(fdset, 2 * (fdset->lfs_setsize + 1));
  125|       |
  126|  1.74k|    LFD_SET(fd, fdset->lfs_setptr);
  127|  1.74k|}
netsnmp_large_fd_clr:
  131|  1.74k|{
  132|  1.74k|    netsnmp_assert(fd >= 0);
  ------------------
  |  |   47|  1.74k|#      define netsnmp_assert(x)  do { \
  |  |   48|  1.74k|              if ( x ) \
  |  |  ------------------
  |  |  |  Branch (48:20): [True: 1.74k, False: 0]
  |  |  ------------------
  |  |   49|  1.74k|                 ; \
  |  |   50|  1.74k|              else \
  |  |   51|  1.74k|                 snmp_log(LOG_ERR, \
  |  |   52|      0|                          "netsnmp_assert %s failed %s:%d" NETSNMP_FUNC_FMT, \
  |  |  ------------------
  |  |  |  |   40|      0|#          define NETSNMP_FUNC_FMT " %s()\n"
  |  |  ------------------
  |  |   53|      0|                          __STRING(x),__FILE__,__LINE__, \
  |  |   54|      0|                          NETSNMP_FUNC_PARAM); \
  |  |  ------------------
  |  |  |  |   41|      0|#          define NETSNMP_FUNC_PARAM NETSNMP_FUNCTION
  |  |  |  |  ------------------
  |  |  |  |  |  | 1681|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|  1.74k|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded - Ignored]
  |  |  ------------------
  ------------------
  133|       |
  134|  1.74k|    if ((unsigned)fd < fdset->lfs_setsize)
  ------------------
  |  Branch (134:9): [True: 1.74k, False: 0]
  ------------------
  135|  1.74k|        LFD_CLR(fd, fdset->lfs_setptr);
  136|  1.74k|}
netsnmp_large_fd_is_set:
  140|  4.55M|{
  141|  4.55M|    netsnmp_assert(fd >= 0);
  ------------------
  |  |   47|  4.55M|#      define netsnmp_assert(x)  do { \
  |  |   48|  4.55M|              if ( x ) \
  |  |  ------------------
  |  |  |  Branch (48:20): [True: 4.55M, False: 0]
  |  |  ------------------
  |  |   49|  4.55M|                 ; \
  |  |   50|  4.55M|              else \
  |  |   51|  4.55M|                 snmp_log(LOG_ERR, \
  |  |   52|      0|                          "netsnmp_assert %s failed %s:%d" NETSNMP_FUNC_FMT, \
  |  |  ------------------
  |  |  |  |   40|      0|#          define NETSNMP_FUNC_FMT " %s()\n"
  |  |  ------------------
  |  |   53|      0|                          __STRING(x),__FILE__,__LINE__, \
  |  |   54|      0|                          NETSNMP_FUNC_PARAM); \
  |  |  ------------------
  |  |  |  |   41|      0|#          define NETSNMP_FUNC_PARAM NETSNMP_FUNCTION
  |  |  |  |  ------------------
  |  |  |  |  |  | 1681|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|  4.55M|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded - Ignored]
  |  |  ------------------
  ------------------
  142|       |
  143|  4.55M|    return ((unsigned)fd < fdset->lfs_setsize &&
  ------------------
  |  Branch (143:13): [True: 4.55M, False: 0]
  ------------------
  144|  4.55M|            LFD_ISSET(fd, fdset->lfs_setptr));
  ------------------
  |  Branch (144:13): [True: 10.4k, False: 4.54M]
  ------------------
  145|  4.55M|}
netsnmp_large_fd_set_init:
  151|  1.74k|{
  152|  1.74k|    fdset->lfs_setsize = 0;
  153|  1.74k|    fdset->lfs_setptr  = NULL;
  154|       |#if !defined(cygwin) && defined(HAVE_WINSOCK_H)
  155|       |    fdset->lfs_set.fd_count = 0;
  156|       |#endif
  157|  1.74k|    netsnmp_large_fd_set_resize(fdset, setsize);
  158|  1.74k|}
netsnmp_large_fd_set_resize:
  192|  3.49k|{
  193|  3.49k|    int             fd_set_bytes;
  194|       |
  195|  3.49k|    if (fdset->lfs_setsize == setsize)
  ------------------
  |  Branch (195:9): [True: 0, False: 3.49k]
  ------------------
  196|      0|        goto success;
  197|       |
  198|  3.49k|    if (setsize > FD_SETSIZE) {
  ------------------
  |  Branch (198:9): [True: 0, False: 3.49k]
  ------------------
  199|      0|        fd_set_bytes = NETSNMP_FD_SET_BYTES(setsize);
  ------------------
  |  |   99|      0|    (sizeof(fd_set) + ((setsize) > FD_SETSIZE ?                          \
  |  |  ------------------
  |  |  |  Branch (99:24): [True: 0, False: 0]
  |  |  ------------------
  |  |  100|      0|                       NETSNMP_FD_SET_ELEM_COUNT((setsize) - FD_SETSIZE) \
  |  |  ------------------
  |  |  |  |   92|      0|    (setsize + NETSNMP_BITS_PER_FD_MASK - 1) / NETSNMP_BITS_PER_FD_MASK
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|      0|#define NETSNMP_BITS_PER_FD_MASK (8 * NETSNMP_FD_MASK_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   85|      0|#define NETSNMP_FD_MASK_SIZE sizeof(((fd_set*)0)->fds_bits[0])
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |                   (setsize + NETSNMP_BITS_PER_FD_MASK - 1) / NETSNMP_BITS_PER_FD_MASK
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|      0|#define NETSNMP_BITS_PER_FD_MASK (8 * NETSNMP_FD_MASK_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   85|      0|#define NETSNMP_FD_MASK_SIZE sizeof(((fd_set*)0)->fds_bits[0])
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  101|      0|                       * NETSNMP_FD_MASK_SIZE : 0))
  |  |  ------------------
  |  |  |  |   85|      0|#define NETSNMP_FD_MASK_SIZE sizeof(((fd_set*)0)->fds_bits[0])
  |  |  ------------------
  ------------------
  200|      0|        if (fdset->lfs_setsize > FD_SETSIZE) {
  ------------------
  |  Branch (200:13): [True: 0, False: 0]
  ------------------
  201|      0|            fdset->lfs_setptr = realloc(fdset->lfs_setptr, fd_set_bytes);
  202|      0|            if (!fdset->lfs_setptr)
  ------------------
  |  Branch (202:17): [True: 0, False: 0]
  ------------------
  203|      0|                goto out_of_mem;
  204|      0|        } else {
  205|      0|            fdset->lfs_setptr = malloc(fd_set_bytes);
  206|      0|            if (!fdset->lfs_setptr)
  ------------------
  |  Branch (206:17): [True: 0, False: 0]
  ------------------
  207|      0|                goto out_of_mem;
  208|      0|            *fdset->lfs_setptr = fdset->lfs_set;
  209|      0|        }
  210|  3.49k|    } else {
  211|  3.49k|        if (fdset->lfs_setsize > FD_SETSIZE) {
  ------------------
  |  Branch (211:13): [True: 0, False: 3.49k]
  ------------------
  212|      0|            fdset->lfs_set = *fdset->lfs_setptr;
  213|      0|            free(fdset->lfs_setptr);
  214|      0|        }
  215|  3.49k|        fdset->lfs_setptr = &fdset->lfs_set;
  216|  3.49k|    }
  217|       |
  218|  3.49k|#if defined(cygwin) || !defined(HAVE_WINSOCK_H)
  219|       |    /*
  220|       |     * Unix: when enlarging, clear the file descriptors defined in the
  221|       |     * resized *fdset but that were not defined in the original *fdset.
  222|       |     */
  223|  3.49k|    if ( fdset->lfs_setsize == 0 && setsize == FD_SETSIZE ) {
  ------------------
  |  Branch (223:10): [True: 1.74k, False: 1.74k]
  |  Branch (223:37): [True: 1.74k, False: 0]
  ------------------
  224|       |        /* In this case we can use the OS's FD_ZERO */
  225|  1.74k|        FD_ZERO(fdset->lfs_setptr);
  226|  1.74k|    } else {
  227|  1.74k|        int             i;
  228|       |
  229|  1.74k|        for (i = fdset->lfs_setsize; i < setsize; i++)
  ------------------
  |  Branch (229:38): [True: 0, False: 1.74k]
  ------------------
  230|      0|            LFD_CLR(i, fdset->lfs_setptr);
  231|  1.74k|    }
  232|  3.49k|#endif
  233|       |
  234|  3.49k|    fdset->lfs_setsize = setsize;
  235|       |#if !defined(cygwin) && defined(HAVE_WINSOCK_H)
  236|       |    if (setsize < fdset->lfs_setptr->fd_count)
  237|       |        fdset->lfs_setptr->fd_count = setsize;
  238|       |#endif
  239|  3.49k|success:
  240|  3.49k|    return 1;
  241|       |
  242|      0|out_of_mem:
  243|      0|    fdset->lfs_setsize = 0;
  244|       |#if !defined(cygwin) && defined(HAVE_WINSOCK_H)
  245|       |    fdset->lfs_setptr->fd_count = 0;
  246|       |#endif
  247|      0|    return 0;
  248|  3.49k|}
netsnmp_large_fd_set_cleanup:
  252|  1.74k|{
  253|  1.74k|    netsnmp_large_fd_set_resize(fdset, 0);
  254|  1.74k|    fdset->lfs_setsize = 0;
  255|  1.74k|    fdset->lfs_setptr  = NULL;
  256|  1.74k|}
large_fd_set.c:LFD_SET:
   95|  1.74k|{
   96|  1.74k|    enum { nfdbits = 8 * sizeof(p->fds_bits[0]) };
   97|  1.74k|    NETSNMP_FD_MASK_TYPE *fds_array = p->fds_bits;
  ------------------
  |  | 1675|  1.74k|#define NETSNMP_FD_MASK_TYPE __fd_mask
  ------------------
   98|       |
   99|  1.74k|    fds_array[n / nfdbits] |= (1ULL << (n % nfdbits));
  100|  1.74k|}
large_fd_set.c:LFD_CLR:
  103|  1.74k|{
  104|  1.74k|    enum { nfdbits = 8 * sizeof(p->fds_bits[0]) };
  105|  1.74k|    NETSNMP_FD_MASK_TYPE *fds_array = p->fds_bits;
  ------------------
  |  | 1675|  1.74k|#define NETSNMP_FD_MASK_TYPE __fd_mask
  ------------------
  106|       |
  107|  1.74k|    fds_array[n / nfdbits] &= ~(1ULL << (n % nfdbits));
  108|  1.74k|}
large_fd_set.c:LFD_ISSET:
  111|  4.55M|{
  112|  4.55M|    enum { nfdbits = 8 * sizeof(p->fds_bits[0]) };
  113|  4.55M|    const NETSNMP_FD_MASK_TYPE *fds_array = p->fds_bits;
  114|       |
  115|  4.55M|    return (fds_array[n / nfdbits] & (1ULL << (n % nfdbits))) != 0;
  116|  4.55M|}

set_enginetime:
  344|      1|{
  345|      1|    int             rval = SNMPERR_SUCCESS, iindex;
  ------------------
  |  |  217|      1|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  346|      1|    Enginetime      e = NULL;
  347|       |
  348|       |
  349|       |
  350|       |    /*
  351|       |     * Sanity check.
  352|       |     */
  353|      1|    if (!engineID || (engineID_len <= 0)) {
  ------------------
  |  Branch (353:9): [True: 0, False: 1]
  |  Branch (353:22): [True: 0, False: 1]
  ------------------
  354|      0|        return rval;
  355|      0|    }
  356|       |
  357|       |
  358|       |    /*
  359|       |     * Store the given <engine_time, engineboot> tuple in the record
  360|       |     * for engineID.  Create a new record if necessary.
  361|       |     */
  362|      1|    if (!(e = search_enginetime_list(engineID, engineID_len))) {
  ------------------
  |  Branch (362:9): [True: 1, False: 0]
  ------------------
  363|      1|        if ((iindex = hash_engineID(engineID, engineID_len)) < 0) {
  ------------------
  |  Branch (363:13): [True: 0, False: 1]
  ------------------
  364|      0|            QUITFUN(SNMPERR_GENERR, set_enginetime_quit);
  ------------------
  |  |  143|      0|	if ( (e) != SNMPERR_SUCCESS) {	\
  |  |  ------------------
  |  |  |  |  217|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  ------------------
  |  |  |  Branch (143:7): [Folded - Ignored]
  |  |  ------------------
  |  |  144|      0|		rval = SNMPERR_GENERR;	\
  |  |  ------------------
  |  |  |  |  218|      0|#define SNMPERR_GENERR			(-1)
  |  |  ------------------
  |  |  145|      0|		goto l ;		\
  |  |  146|      0|	}
  ------------------
  365|      0|        }
  366|       |
  367|      1|        e = calloc(1, sizeof(*e));
  368|       |
  369|      1|        e->next = etimelist[iindex];
  370|      1|        etimelist[iindex] = e;
  371|       |
  372|      1|        e->engineID = calloc(1, engineID_len);
  373|      1|        memcpy(e->engineID, engineID, engineID_len);
  374|       |
  375|      1|        e->engineID_len = engineID_len;
  376|      1|    }
  377|      1|#ifdef LCD_TIME_SYNC_OPT
  378|      1|    if (authenticated || !e->authenticatedFlag) {
  ------------------
  |  Branch (378:9): [True: 1, False: 0]
  |  Branch (378:26): [True: 0, False: 0]
  ------------------
  379|      1|        e->authenticatedFlag = authenticated;
  380|       |#else
  381|       |    if (authenticated) {
  382|       |#endif
  383|      1|        e->engineTime = engine_time;
  384|      1|        e->engineBoot = engineboot;
  385|      1|        e->lastReceivedEngineTime = snmpv3_local_snmpEngineTime();
  386|      1|    }
  387|       |
  388|      1|    e = NULL;                   /* Indicates a successful update. */
  389|       |
  390|      1|    DEBUGMSGTL(("lcd_set_enginetime", "engineID "));
  ------------------
  |  |   68|      1|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      1|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      1|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      1|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      1|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
  391|      1|    DEBUGMSGHEX(("lcd_set_enginetime", engineID, engineID_len));
  ------------------
  |  |   73|      1|#define DEBUGMSGHEX(x)     do {if (_DBG_IF_) {__DBGMSGHEX(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGHEX(x)     do {if (_DBG_IF_) {__DBGMSGHEX(x);} }while(0)
  |  |  ------------------
  |  |  |  |  171|      1|#define __DBGMSGHEX(x)     debugmsg_hex x
  |  |  ------------------
  |  |  |  Branch (73:71): [Folded - Ignored]
  |  |  ------------------
  ------------------
  392|      1|    DEBUGMSG(("lcd_set_enginetime", ": boots=%d, time=%d\n", engineboot,
  ------------------
  |  |   63|      1|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  146|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (63:67): [Folded - Ignored]
  |  |  ------------------
  ------------------
  393|      1|              engine_time));
  394|       |
  395|      1|  set_enginetime_quit:
  396|      1|    SNMP_FREE(e);
  ------------------
  |  |   62|      1|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 1]
  |  |  |  Branch (62:66): [Folded - Ignored]
  |  |  ------------------
  ------------------
  397|       |
  398|      1|    return rval;
  399|       |
  400|      1|}                               /* end set_enginetime() */
search_enginetime_list:
  423|      1|{
  424|      1|    int             rval = SNMPERR_SUCCESS;
  ------------------
  |  |  217|      1|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  425|      1|    Enginetime      e = NULL;
  426|       |
  427|       |
  428|       |    /*
  429|       |     * Sanity check.
  430|       |     */
  431|      1|    if (!engineID || (engineID_len <= 0)) {
  ------------------
  |  Branch (431:9): [True: 0, False: 1]
  |  Branch (431:22): [True: 0, False: 1]
  ------------------
  432|      0|        QUITFUN(SNMPERR_GENERR, search_enginetime_list_quit);
  ------------------
  |  |  143|      0|	if ( (e) != SNMPERR_SUCCESS) {	\
  |  |  ------------------
  |  |  |  |  217|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  ------------------
  |  |  |  Branch (143:7): [Folded - Ignored]
  |  |  ------------------
  |  |  144|      0|		rval = SNMPERR_GENERR;	\
  |  |  ------------------
  |  |  |  |  218|      0|#define SNMPERR_GENERR			(-1)
  |  |  ------------------
  |  |  145|      0|		goto l ;		\
  |  |  146|      0|	}
  ------------------
  433|      0|    }
  434|       |
  435|       |
  436|       |    /*
  437|       |     * Find the entry for engineID if there be one.
  438|       |     */
  439|      1|    rval = hash_engineID(engineID, engineID_len);
  440|      1|    if (rval < 0) {
  ------------------
  |  Branch (440:9): [True: 0, False: 1]
  ------------------
  441|      0|        QUITFUN(SNMPERR_GENERR, search_enginetime_list_quit);
  ------------------
  |  |  143|      0|	if ( (e) != SNMPERR_SUCCESS) {	\
  |  |  ------------------
  |  |  |  |  217|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  ------------------
  |  |  |  Branch (143:7): [Folded - Ignored]
  |  |  ------------------
  |  |  144|      0|		rval = SNMPERR_GENERR;	\
  |  |  ------------------
  |  |  |  |  218|      0|#define SNMPERR_GENERR			(-1)
  |  |  ------------------
  |  |  145|      0|		goto l ;		\
  |  |  146|      0|	}
  ------------------
  442|      0|    }
  443|      1|    e = etimelist[rval];
  444|       |
  445|      1|    for ( /*EMPTY*/; e; e = e->next) {
  ------------------
  |  Branch (445:22): [True: 0, False: 1]
  ------------------
  446|      0|        if ((engineID_len == e->engineID_len)
  ------------------
  |  Branch (446:13): [True: 0, False: 0]
  ------------------
  447|      0|            && !memcmp(e->engineID, engineID, engineID_len)) {
  ------------------
  |  Branch (447:16): [True: 0, False: 0]
  ------------------
  448|      0|            break;
  449|      0|        }
  450|      0|    }
  451|       |
  452|       |
  453|      1|  search_enginetime_list_quit:
  454|      1|    return e;
  455|       |
  456|      1|}                               /* end search_enginetime_list() */
hash_engineID:
  481|      2|{
  482|      2|    int             rval = SNMPERR_GENERR;
  ------------------
  |  |  218|      2|#define SNMPERR_GENERR			(-1)
  ------------------
  483|      2|    size_t          buf_len = SNMP_MAXBUF;
  ------------------
  |  |   43|      2|#define SNMP_MAXBUF		(1024 * 4)
  ------------------
  484|      2|    u_int           additive = 0;
  485|      2|    u_char         *bufp, buf[SNMP_MAXBUF];
  486|      2|    void           *context = NULL;
  487|       |
  488|       |
  489|       |
  490|       |    /*
  491|       |     * Sanity check.
  492|       |     */
  493|      2|    if (!engineID || (engineID_len <= 0)) {
  ------------------
  |  Branch (493:9): [True: 0, False: 2]
  |  Branch (493:22): [True: 0, False: 2]
  ------------------
  494|      0|        QUITFUN(SNMPERR_GENERR, hash_engineID_quit);
  ------------------
  |  |  143|      0|	if ( (e) != SNMPERR_SUCCESS) {	\
  |  |  ------------------
  |  |  |  |  217|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  ------------------
  |  |  |  Branch (143:7): [Folded - Ignored]
  |  |  ------------------
  |  |  144|      0|		rval = SNMPERR_GENERR;	\
  |  |  ------------------
  |  |  |  |  218|      0|#define SNMPERR_GENERR			(-1)
  |  |  ------------------
  |  |  145|      0|		goto l ;		\
  |  |  146|      0|	}
  ------------------
  495|      0|    }
  496|       |
  497|       |
  498|       |    /*
  499|       |     * Hash engineID into a list index.
  500|       |     */
  501|      2|#ifndef NETSNMP_DISABLE_MD5
  502|      2|    rval = sc_hash(usmHMACMD5AuthProtocol,
  503|      2|                   OID_LENGTH(usmHMACMD5AuthProtocol),
  ------------------
  |  |   64|      2|    (sizeof(x) / sizeof((x)[0]) +                                       \
  |  |   65|      2|     sizeof(int[-__builtin_types_compatible_p(typeof(x), typeof(&(x)[0]))]))
  ------------------
  504|      2|                   engineID, engineID_len, buf, &buf_len);
  505|      2|    if (rval == SNMPERR_SC_NOT_CONFIGURED) {
  ------------------
  |  |  256|      2|#define SNMPERR_SC_NOT_CONFIGURED	(-39)
  ------------------
  |  Branch (505:9): [True: 0, False: 2]
  ------------------
  506|       |        /* fall back to sha1 */
  507|      0|        rval = sc_hash(usmHMACSHA1AuthProtocol,
  508|      0|                   OID_LENGTH(usmHMACSHA1AuthProtocol),
  ------------------
  |  |   64|      0|    (sizeof(x) / sizeof((x)[0]) +                                       \
  |  |   65|      0|     sizeof(int[-__builtin_types_compatible_p(typeof(x), typeof(&(x)[0]))]))
  ------------------
  509|      0|                   engineID, engineID_len, buf, &buf_len);
  510|      0|    }
  511|       |#else
  512|       |    rval = sc_hash(usmHMACSHA1AuthProtocol,
  513|       |                   OID_LENGTH(usmHMACSHA1AuthProtocol),
  514|       |                   engineID, engineID_len, buf, &buf_len);
  515|       |#endif
  516|      2|    QUITFUN(rval, hash_engineID_quit);
  ------------------
  |  |  143|      2|	if ( (e) != SNMPERR_SUCCESS) {	\
  |  |  ------------------
  |  |  |  |  217|      2|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  ------------------
  |  |  |  Branch (143:7): [True: 0, False: 2]
  |  |  ------------------
  |  |  144|      0|		rval = SNMPERR_GENERR;	\
  |  |  ------------------
  |  |  |  |  218|      0|#define SNMPERR_GENERR			(-1)
  |  |  ------------------
  |  |  145|      0|		goto l ;		\
  |  |  146|      0|	}
  ------------------
  517|       |
  518|     10|    for (bufp = buf; (bufp - buf) < (int) buf_len; bufp += 4) {
  ------------------
  |  Branch (518:22): [True: 8, False: 2]
  ------------------
  519|      8|        additive += (u_int) * bufp;
  520|      8|    }
  521|       |
  522|      2|  hash_engineID_quit:
  523|      2|    SNMP_FREE(context);
  ------------------
  |  |   62|      2|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 2]
  |  |  |  Branch (62:66): [Folded - Ignored]
  |  |  ------------------
  ------------------
  524|      2|    memset(buf, 0, SNMP_MAXBUF);
  ------------------
  |  |   43|      2|#define SNMP_MAXBUF		(1024 * 4)
  ------------------
  525|       |
  526|      2|    return (rval < 0) ? rval : (int)(additive % ETIMELIST_SIZE);
  ------------------
  |  |   21|      2|#define ETIMELIST_SIZE	23
  ------------------
  |  Branch (526:12): [True: 0, False: 2]
  ------------------
  527|       |
  528|      2|}                               /* end hash_engineID() */

_sprint_hexstring_line:
  296|  5.43k|{
  297|  5.43k|    const u_char   *tp;
  298|  5.43k|    const u_char   *cp2 = cp;
  299|  5.43k|    size_t          lenleft = line_len;
  300|       |
  301|       |    /*
  302|       |     * Make sure there's enough room for the hex output....
  303|       |     */
  304|  10.3k|    while ((*out_len + line_len*3+1) >= *buf_len) {
  ------------------
  |  Branch (304:12): [True: 4.92k, False: 5.43k]
  ------------------
  305|  4.92k|        if (!(allow_realloc && snmp_realloc(buf, buf_len))) {
  ------------------
  |  Branch (305:15): [True: 4.92k, False: 0]
  |  Branch (305:32): [True: 4.92k, False: 0]
  ------------------
  306|      0|            return 0;
  307|      0|        }
  308|  4.92k|    }
  309|       |
  310|       |    /*
  311|       |     * .... and display the hex values themselves....
  312|       |     */
  313|  7.02k|    for (; lenleft >= 8; lenleft-=8) {
  ------------------
  |  Branch (313:12): [True: 1.59k, False: 5.43k]
  ------------------
  314|  1.59k|        sprintf((char *) (*buf + *out_len),
  315|  1.59k|                "%02X %02X %02X %02X %02X %02X %02X %02X ", cp[0], cp[1],
  316|  1.59k|                cp[2], cp[3], cp[4], cp[5], cp[6], cp[7]);
  317|  1.59k|        *out_len += strlen((char *) (*buf + *out_len));
  318|  1.59k|        cp       += 8;
  319|  1.59k|    }
  320|  22.6k|    for (; lenleft > 0; lenleft--) {
  ------------------
  |  Branch (320:12): [True: 17.2k, False: 5.43k]
  ------------------
  321|  17.2k|        sprintf((char *) (*buf + *out_len), "%02X ", *cp++);
  322|  17.2k|        *out_len += strlen((char *) (*buf + *out_len));
  323|  17.2k|    }
  324|       |
  325|       |    /*
  326|       |     * .... plus (optionally) do the same for the ASCII equivalent.
  327|       |     */
  328|  5.43k|    if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_PRINT_HEX_TEXT)) {
  ------------------
  |  |   48|  5.43k|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                  if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_PRINT_HEX_TEXT)) {
  ------------------
  |  |   83|  5.43k|#define NETSNMP_DS_LIB_PRINT_HEX_TEXT      23   /* print ASCII text along with hex strings */
  ------------------
  |  Branch (328:9): [True: 0, False: 5.43k]
  ------------------
  329|      0|        while ((*out_len + line_len+5) >= *buf_len) {
  ------------------
  |  Branch (329:16): [True: 0, False: 0]
  ------------------
  330|      0|            if (!(allow_realloc && snmp_realloc(buf, buf_len))) {
  ------------------
  |  Branch (330:19): [True: 0, False: 0]
  |  Branch (330:36): [True: 0, False: 0]
  ------------------
  331|      0|                return 0;
  332|      0|            }
  333|      0|        }
  334|      0|        sprintf((char *) (*buf + *out_len), "  [");
  335|      0|        *out_len += strlen((char *) (*buf + *out_len));
  336|      0|        for (tp = cp2; tp < cp; tp++) {
  ------------------
  |  Branch (336:24): [True: 0, False: 0]
  ------------------
  337|      0|            sprint_char((char *) (*buf + *out_len), *tp);
  338|      0|            (*out_len)++;
  339|      0|        }
  340|      0|        sprintf((char *) (*buf + *out_len), "]");
  341|      0|        *out_len += strlen((char *) (*buf + *out_len));
  342|      0|    }
  343|  5.43k|    return 1;
  344|  5.43k|}
sprint_realloc_hexstring:
  349|  4.88k|{
  350|  4.88k|    int line_len = netsnmp_ds_get_int(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|  4.88k|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  351|  4.88k|                                      NETSNMP_DS_LIB_HEX_OUTPUT_LENGTH);
  ------------------
  |  |  121|  4.88k|#define NETSNMP_DS_LIB_HEX_OUTPUT_LENGTH    6
  ------------------
  352|  4.88k|    if (line_len <= 0)
  ------------------
  |  Branch (352:9): [True: 0, False: 4.88k]
  ------------------
  353|      0|        line_len = len;
  354|       |
  355|  5.43k|    for (; (int)len > line_len; len -= line_len) {
  ------------------
  |  Branch (355:12): [True: 552, False: 4.88k]
  ------------------
  356|    552|        if(!_sprint_hexstring_line(buf, buf_len, out_len, allow_realloc, cp, line_len))
  ------------------
  |  Branch (356:12): [True: 0, False: 552]
  ------------------
  357|      0|            return 0;
  358|    552|        *(*buf + (*out_len)++) = '\n';
  359|    552|        *(*buf + *out_len) = 0;
  360|    552|        cp += line_len;
  361|    552|    }
  362|  4.88k|    if(!_sprint_hexstring_line(buf, buf_len, out_len, allow_realloc, cp, len))
  ------------------
  |  Branch (362:8): [True: 0, False: 4.88k]
  ------------------
  363|      0|        return 0;
  364|  4.88k|    *(*buf + *out_len) = 0;
  365|  4.88k|    return 1;
  366|  4.88k|}
sprint_realloc_asciistring:
  393|  1.11k|{
  394|  1.11k|    int             i;
  395|       |
  396|  10.9k|    for (i = 0; i < (int) len; i++) {
  ------------------
  |  Branch (396:17): [True: 9.85k, False: 1.11k]
  ------------------
  397|  9.85k|        if (isprint(*cp) || isspace(*cp)) {
  398|  5.24k|            if (*cp == '\\' || *cp == '"') {
  ------------------
  |  Branch (398:17): [True: 470, False: 4.77k]
  |  Branch (398:32): [True: 1.31k, False: 3.46k]
  ------------------
  399|  1.78k|                if ((*out_len >= *buf_len) &&
  ------------------
  |  Branch (399:21): [True: 19, False: 1.76k]
  ------------------
  400|  1.78k|                    !(allow_realloc && snmp_realloc(buf, buf_len))) {
  ------------------
  |  Branch (400:23): [True: 19, False: 0]
  |  Branch (400:40): [True: 19, False: 0]
  ------------------
  401|      0|                    return 0;
  402|      0|                }
  403|  1.78k|                *(*buf + (*out_len)++) = '\\';
  404|  1.78k|            }
  405|  5.24k|            if ((*out_len >= *buf_len) &&
  ------------------
  |  Branch (405:17): [True: 31, False: 5.21k]
  ------------------
  406|  5.24k|                !(allow_realloc && snmp_realloc(buf, buf_len))) {
  ------------------
  |  Branch (406:19): [True: 31, False: 0]
  |  Branch (406:36): [True: 31, False: 0]
  ------------------
  407|      0|                return 0;
  408|      0|            }
  409|  5.24k|            *(*buf + (*out_len)++) = *cp++;
  410|  5.24k|        } else {
  411|  4.60k|            if ((*out_len >= *buf_len) &&
  ------------------
  |  Branch (411:17): [True: 21, False: 4.58k]
  ------------------
  412|  4.60k|                !(allow_realloc && snmp_realloc(buf, buf_len))) {
  ------------------
  |  Branch (412:19): [True: 21, False: 0]
  |  Branch (412:36): [True: 21, False: 0]
  ------------------
  413|      0|                return 0;
  414|      0|            }
  415|  4.60k|            *(*buf + (*out_len)++) = '.';
  416|  4.60k|            cp++;
  417|  4.60k|        }
  418|  9.85k|    }
  419|  1.11k|    if ((*out_len >= *buf_len) &&
  ------------------
  |  Branch (419:9): [True: 43, False: 1.07k]
  ------------------
  420|  1.11k|        !(allow_realloc && snmp_realloc(buf, buf_len))) {
  ------------------
  |  Branch (420:11): [True: 43, False: 0]
  |  Branch (420:28): [True: 43, False: 0]
  ------------------
  421|      0|        return 0;
  422|      0|    }
  423|  1.11k|    *(*buf + *out_len) = '\0';
  424|  1.11k|    return 1;
  425|  1.11k|}
register_mib_handlers:
 2452|      1|{
 2453|      1|#ifndef NETSNMP_DISABLE_MIB_LOADING
 2454|      1|    register_prenetsnmp_mib_handler("snmp", "mibdirs",
 2455|      1|                                    handle_mibdirs_conf, NULL,
 2456|      1|                                    "[mib-dirs|+mib-dirs|-mib-dirs]");
 2457|      1|    register_prenetsnmp_mib_handler("snmp", "mibs",
 2458|      1|                                    handle_mibs_conf, NULL,
 2459|      1|                                    "[mib-tokens|+mib-tokens|-mib-tokens]");
 2460|      1|    register_config_handler("snmp", "mibfile",
 2461|      1|                            handle_mibfile_conf, NULL, "mibfile-to-read");
 2462|       |    /*
 2463|       |     * register the snmp.conf configuration handlers for default
 2464|       |     * parsing behaviour 
 2465|       |     */
 2466|       |
 2467|      1|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "showMibErrors",
  ------------------
  |  |   72|      1|#define ASN_BOOLEAN	    0x01U
  ------------------
 2468|      1|                       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_MIB_ERRORS);
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                     NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_MIB_ERRORS);
  ------------------
  |  |   59|      1|#define NETSNMP_DS_LIB_MIB_ERRORS          0
  ------------------
 2469|      1|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "commentToEOL",     /* Describes actual behaviour */
  ------------------
  |  |   72|      1|#define ASN_BOOLEAN	    0x01U
  ------------------
 2470|      1|                       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_MIB_COMMENT_TERM);
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                     NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_MIB_COMMENT_TERM);
  ------------------
  |  |   61|      1|#define NETSNMP_DS_LIB_MIB_COMMENT_TERM    2
  ------------------
 2471|      1|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "strictCommentTerm",    /* Backward compatibility */
  ------------------
  |  |   72|      1|#define ASN_BOOLEAN	    0x01U
  ------------------
 2472|      1|                       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_MIB_COMMENT_TERM);
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                     NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_MIB_COMMENT_TERM);
  ------------------
  |  |   61|      1|#define NETSNMP_DS_LIB_MIB_COMMENT_TERM    2
  ------------------
 2473|      1|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "mibAllowUnderline",
  ------------------
  |  |   72|      1|#define ASN_BOOLEAN	    0x01U
  ------------------
 2474|      1|                       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_MIB_PARSE_LABEL);
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                     NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_MIB_PARSE_LABEL);
  ------------------
  |  |   62|      1|#define NETSNMP_DS_LIB_MIB_PARSE_LABEL     3
  ------------------
 2475|      1|    netsnmp_ds_register_premib(ASN_INTEGER, "snmp", "mibWarningLevel",
  ------------------
  |  |   75|      1|#define ASN_INTEGER	    0x02U
  ------------------
 2476|      1|                       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_MIB_WARNINGS);
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                     NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_MIB_WARNINGS);
  ------------------
  |  |  114|      1|#define NETSNMP_DS_LIB_MIB_WARNINGS         0
  ------------------
 2477|      1|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "mibReplaceWithLatest",
  ------------------
  |  |   72|      1|#define ASN_BOOLEAN	    0x01U
  ------------------
 2478|      1|                       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_MIB_REPLACE);
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                     NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_MIB_REPLACE);
  ------------------
  |  |   67|      1|#define NETSNMP_DS_LIB_MIB_REPLACE         7    /* replace objects from latest module */
  ------------------
 2479|      1|#endif
 2480|       |
 2481|      1|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "printNumericEnums",
  ------------------
  |  |   72|      1|#define ASN_BOOLEAN	    0x01U
  ------------------
 2482|      1|                       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_PRINT_NUMERIC_ENUM);
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                     NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_PRINT_NUMERIC_ENUM);
  ------------------
  |  |   68|      1|#define NETSNMP_DS_LIB_PRINT_NUMERIC_ENUM  8    /* print only numeric enum values */
  ------------------
 2483|      1|    register_prenetsnmp_mib_handler("snmp", "printNumericOids",
 2484|      1|                       handle_print_numeric, NULL, "(1|yes|true|0|no|false)");
 2485|      1|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "escapeQuotes",
  ------------------
  |  |   72|      1|#define ASN_BOOLEAN	    0x01U
  ------------------
 2486|      1|                       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_ESCAPE_QUOTES);
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                     NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_ESCAPE_QUOTES);
  ------------------
  |  |   79|      1|#define NETSNMP_DS_LIB_ESCAPE_QUOTES       19   /* shell escape quote marks in oids */
  ------------------
 2487|      1|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "dontBreakdownOids",
  ------------------
  |  |   72|      1|#define ASN_BOOLEAN	    0x01U
  ------------------
 2488|      1|                       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DONT_BREAKDOWN_OIDS);
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                     NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DONT_BREAKDOWN_OIDS);
  ------------------
  |  |   70|      1|#define NETSNMP_DS_LIB_DONT_BREAKDOWN_OIDS 10   /* dont print oid indexes specially */
  ------------------
 2489|      1|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "quickPrinting",
  ------------------
  |  |   72|      1|#define ASN_BOOLEAN	    0x01U
  ------------------
 2490|      1|                       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICK_PRINT);
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                     NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICK_PRINT);
  ------------------
  |  |   73|      1|#define NETSNMP_DS_LIB_QUICK_PRINT         13   /* print very brief output for parsing */
  ------------------
 2491|      1|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "numericTimeticks",
  ------------------
  |  |   72|      1|#define ASN_BOOLEAN	    0x01U
  ------------------
 2492|      1|                       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_NUMERIC_TIMETICKS);
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                     NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_NUMERIC_TIMETICKS);
  ------------------
  |  |   78|      1|#define NETSNMP_DS_LIB_NUMERIC_TIMETICKS   18   /* print timeticks as a number */
  ------------------
 2493|      1|    netsnmp_ds_register_premib(ASN_INTEGER, "snmp", "oidOutputFormat",
  ------------------
  |  |   75|      1|#define ASN_INTEGER	    0x02U
  ------------------
 2494|      1|                       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_OID_OUTPUT_FORMAT);
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                     NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_OID_OUTPUT_FORMAT);
  ------------------
  |  |  118|      1|#define NETSNMP_DS_LIB_OID_OUTPUT_FORMAT    4
  ------------------
 2495|      1|    netsnmp_ds_register_premib(ASN_INTEGER, "snmp", "suffixPrinting",
  ------------------
  |  |   75|      1|#define ASN_INTEGER	    0x02U
  ------------------
 2496|      1|                       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_OID_OUTPUT_FORMAT);
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                     NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_OID_OUTPUT_FORMAT);
  ------------------
  |  |  118|      1|#define NETSNMP_DS_LIB_OID_OUTPUT_FORMAT    4
  ------------------
 2497|      1|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "extendedIndex",
  ------------------
  |  |   72|      1|#define ASN_BOOLEAN	    0x01U
  ------------------
 2498|      1|                       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_EXTENDED_INDEX);
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                     NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_EXTENDED_INDEX);
  ------------------
  |  |   82|      1|#define NETSNMP_DS_LIB_EXTENDED_INDEX	   22   /* print extended index format [x1][x2] */
  ------------------
 2499|      1|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "printHexText",
  ------------------
  |  |   72|      1|#define ASN_BOOLEAN	    0x01U
  ------------------
 2500|      1|                       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_PRINT_HEX_TEXT);
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                     NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_PRINT_HEX_TEXT);
  ------------------
  |  |   83|      1|#define NETSNMP_DS_LIB_PRINT_HEX_TEXT      23   /* print ASCII text along with hex strings */
  ------------------
 2501|      1|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "printValueOnly",
  ------------------
  |  |   72|      1|#define ASN_BOOLEAN	    0x01U
  ------------------
 2502|      1|                       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_PRINT_BARE_VALUE);
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                     NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_PRINT_BARE_VALUE);
  ------------------
  |  |   81|      1|#define NETSNMP_DS_LIB_PRINT_BARE_VALUE	   21   /* just print value (not OID = value) */
  ------------------
 2503|      1|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "dontPrintUnits",
  ------------------
  |  |   72|      1|#define ASN_BOOLEAN	    0x01U
  ------------------
 2504|      1|                       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DONT_PRINT_UNITS);
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                     NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DONT_PRINT_UNITS);
  ------------------
  |  |   89|      1|#define NETSNMP_DS_LIB_DONT_PRINT_UNITS    29 /* don't print UNITS suffix */
  ------------------
 2505|      1|    netsnmp_ds_register_premib(ASN_INTEGER, "snmp", "hexOutputLength",
  ------------------
  |  |   75|      1|#define ASN_INTEGER	    0x02U
  ------------------
 2506|      1|                       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_HEX_OUTPUT_LENGTH);
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                     NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_HEX_OUTPUT_LENGTH);
  ------------------
  |  |  121|      1|#define NETSNMP_DS_LIB_HEX_OUTPUT_LENGTH    6
  ------------------
 2507|      1|}
netsnmp_set_mib_directory:
 2522|      2|{
 2523|      2|    const char *newdir;
 2524|      2|    char *olddir, *tmpdir = NULL;
 2525|       |
 2526|      2|    DEBUGTRACE;
  ------------------
  |  |   65|      2|#define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
  |  |  ------------------
  |  |  |  |  146|      2|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 2, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
  |  |  ------------------
  |  |  |  |  156|      2|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  ------------------
  |  |  |  |  |  |  149|      2|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  157|      2|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  ------------------
  |  |  |  Branch (65:67): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2527|      2|    if (NULL == dir) {
  ------------------
  |  Branch (2527:9): [True: 0, False: 2]
  ------------------
 2528|      0|        return;
 2529|      0|    }
 2530|       |    
 2531|      2|    olddir = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 2532|      2|				   NETSNMP_DS_LIB_MIBDIRS);
  ------------------
  |  |  162|      2|#define NETSNMP_DS_LIB_MIBDIRS           11
  ------------------
 2533|      2|    if (olddir) {
  ------------------
  |  Branch (2533:9): [True: 1, False: 1]
  ------------------
 2534|      1|        if ((*dir == '+') || (*dir == '-')) {
  ------------------
  |  Branch (2534:13): [True: 0, False: 1]
  |  Branch (2534:30): [True: 0, False: 1]
  ------------------
 2535|       |            /** New dir starts with '+', thus we add it. */
 2536|      0|            tmpdir = (char *)malloc(strlen(dir) + strlen(olddir) + 2);
 2537|      0|            if (!tmpdir) {
  ------------------
  |  Branch (2537:17): [True: 0, False: 0]
  ------------------
 2538|      0|                DEBUGMSGTL(("read_config:initmib", "set mibdir malloc failed"));
  ------------------
  |  |   68|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2539|      0|                return;
 2540|      0|            }
 2541|      0|            if (*dir++ == '+')
  ------------------
  |  Branch (2541:17): [True: 0, False: 0]
  ------------------
 2542|      0|                sprintf(tmpdir, "%s%c%s", olddir, ENV_SEPARATOR_CHAR, dir);
  ------------------
  |  |   70|      0|#define ENV_SEPARATOR_CHAR ':'
  ------------------
 2543|      0|            else
 2544|      0|                sprintf(tmpdir, "%s%c%s", dir, ENV_SEPARATOR_CHAR, olddir);
  ------------------
  |  |   70|      0|#define ENV_SEPARATOR_CHAR ':'
  ------------------
 2545|      0|            newdir = tmpdir;
 2546|      1|        } else {
 2547|      1|            newdir = dir;
 2548|      1|        }
 2549|      1|    } else {
 2550|       |        /** If dir starts with '+' skip '+' it. */
 2551|      1|        newdir = ((*dir == '+') ? ++dir : dir);
  ------------------
  |  Branch (2551:19): [True: 0, False: 1]
  ------------------
 2552|      1|    }
 2553|      2|    netsnmp_ds_set_string(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_MIBDIRS,
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                  netsnmp_ds_set_string(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_MIBDIRS,
  ------------------
  |  |  162|      2|#define NETSNMP_DS_LIB_MIBDIRS           11
  ------------------
 2554|      2|                          newdir);
 2555|       |
 2556|       |    /** set_string calls strdup, so if we allocated memory, free it */
 2557|      2|    if (tmpdir == newdir) {
  ------------------
  |  Branch (2557:9): [True: 0, False: 2]
  ------------------
 2558|      0|        SNMP_FREE(tmpdir);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2559|      0|    }
 2560|      2|}
netsnmp_get_mib_directory:
 2577|      3|{
 2578|      3|    char *dir;
 2579|       |
 2580|      3|    DEBUGTRACE;
  ------------------
  |  |   65|      3|#define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
  |  |  ------------------
  |  |  |  |  146|      3|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 3, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
  |  |  ------------------
  |  |  |  |  156|      3|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  ------------------
  |  |  |  |  |  |  149|      3|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  157|      3|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  ------------------
  |  |  |  Branch (65:67): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2581|      3|    dir = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_MIBDIRS);
  ------------------
  |  |   48|      3|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                  dir = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_MIBDIRS);
  ------------------
  |  |  162|      3|#define NETSNMP_DS_LIB_MIBDIRS           11
  ------------------
 2582|      3|    if (dir == NULL) {
  ------------------
  |  Branch (2582:9): [True: 1, False: 2]
  ------------------
 2583|      1|        DEBUGMSGTL(("get_mib_directory", "no mib directories set\n"));
  ------------------
  |  |   68|      1|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      1|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      1|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      1|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      1|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2584|       |
 2585|       |        /** Check if the environment variable is set */
 2586|      1|        dir = netsnmp_getenv("MIBDIRS");
 2587|      1|        if (dir == NULL) {
  ------------------
  |  Branch (2587:13): [True: 1, False: 0]
  ------------------
 2588|      1|            DEBUGMSGTL(("get_mib_directory", "no mib directories set by environment\n"));
  ------------------
  |  |   68|      1|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      1|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      1|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      1|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      1|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2589|       |            /** Not set use hard coded path */
 2590|      1|            if (confmibdir == NULL) {
  ------------------
  |  Branch (2590:17): [True: 1, False: 0]
  ------------------
 2591|      1|                DEBUGMSGTL(("get_mib_directory", "no mib directories set by config\n"));
  ------------------
  |  |   68|      1|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      1|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      1|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      1|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      1|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2592|      1|                netsnmp_set_mib_directory(NETSNMP_DEFAULT_MIBDIRS);
  ------------------
  |  | 1623|      1|#define NETSNMP_DEFAULT_MIBDIRS "$HOME/.snmp/mibs:/usr/local/net-snmp-master/share/snmp/mibs"
  ------------------
 2593|      1|            }
 2594|      0|            else if ((*confmibdir == '+') || (*confmibdir == '-')) {
  ------------------
  |  Branch (2594:22): [True: 0, False: 0]
  |  Branch (2594:46): [True: 0, False: 0]
  ------------------
 2595|      0|                DEBUGMSGTL(("get_mib_directory", "mib directories set by config (but added)\n"));
  ------------------
  |  |   68|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2596|      0|                netsnmp_set_mib_directory(NETSNMP_DEFAULT_MIBDIRS);
  ------------------
  |  | 1623|      0|#define NETSNMP_DEFAULT_MIBDIRS "$HOME/.snmp/mibs:/usr/local/net-snmp-master/share/snmp/mibs"
  ------------------
 2597|      0|                netsnmp_set_mib_directory(confmibdir);
 2598|      0|            }
 2599|      0|            else {
 2600|      0|                DEBUGMSGTL(("get_mib_directory", "mib directories set by config\n"));
  ------------------
  |  |   68|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2601|      0|                netsnmp_set_mib_directory(confmibdir);
 2602|      0|            }
 2603|      1|        } else if ((*dir == '+') || (*dir == '-')) {
  ------------------
  |  Branch (2603:20): [True: 0, False: 0]
  |  Branch (2603:37): [True: 0, False: 0]
  ------------------
 2604|      0|            DEBUGMSGTL(("get_mib_directory", "mib directories set by environment (but added)\n"));
  ------------------
  |  |   68|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2605|      0|            netsnmp_set_mib_directory(NETSNMP_DEFAULT_MIBDIRS);
  ------------------
  |  | 1623|      0|#define NETSNMP_DEFAULT_MIBDIRS "$HOME/.snmp/mibs:/usr/local/net-snmp-master/share/snmp/mibs"
  ------------------
 2606|      0|            netsnmp_set_mib_directory(dir);
 2607|      0|        } else {
 2608|      0|            DEBUGMSGTL(("get_mib_directory", "mib directories set by environment\n"));
  ------------------
  |  |   68|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2609|      0|            netsnmp_set_mib_directory(dir);
 2610|      0|        }
 2611|      1|        dir = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_MIBDIRS);
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                      dir = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_MIBDIRS);
  ------------------
  |  |  162|      1|#define NETSNMP_DS_LIB_MIBDIRS           11
  ------------------
 2612|      1|    }
 2613|      3|    DEBUGMSGTL(("get_mib_directory", "mib directories set '%s'\n", dir));
  ------------------
  |  |   68|      3|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      3|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 3, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      3|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      3|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      3|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      3|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2614|      3|    return(dir);
 2615|      3|}
netsnmp_fixup_mib_directory:
 2624|      1|{
 2625|      1|    char *homepath = netsnmp_getenv("HOME");
 2626|      1|    char *mibpath = netsnmp_get_mib_directory();
 2627|      1|    char *oldmibpath = NULL;
 2628|      1|    char *ptr_home;
 2629|      1|    char *new_mibpath;
 2630|       |
 2631|      1|    DEBUGTRACE;
  ------------------
  |  |   65|      1|#define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
  |  |  ------------------
  |  |  |  |  146|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
  |  |  ------------------
  |  |  |  |  156|      1|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  ------------------
  |  |  |  |  |  |  149|      1|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  157|      1|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  ------------------
  |  |  |  Branch (65:67): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2632|      1|    if (homepath && mibpath) {
  ------------------
  |  Branch (2632:9): [True: 1, False: 0]
  |  Branch (2632:21): [True: 1, False: 0]
  ------------------
 2633|      1|        DEBUGMSGTL(("fixup_mib_directory", "mib directories '%s'\n", mibpath));
  ------------------
  |  |   68|      1|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      1|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      1|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      1|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      1|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2634|      2|        while ((ptr_home = strstr(mibpath, "$HOME"))) {
  ------------------
  |  Branch (2634:16): [True: 1, False: 1]
  ------------------
 2635|      1|            new_mibpath = (char *)malloc(strlen(mibpath) - strlen("$HOME") +
 2636|      1|					 strlen(homepath)+1);
 2637|      1|            if (new_mibpath) {
  ------------------
  |  Branch (2637:17): [True: 1, False: 0]
  ------------------
 2638|      1|                *ptr_home = 0; /* null out the spot where we stop copying */
 2639|      1|                sprintf(new_mibpath, "%s%s%s", mibpath, homepath,
 2640|      1|			ptr_home + strlen("$HOME"));
 2641|       |                /** swap in the new value and repeat */
 2642|      1|                mibpath = new_mibpath;
 2643|      1|		if (oldmibpath != NULL) {
  ------------------
  |  Branch (2643:7): [True: 0, False: 1]
  ------------------
 2644|      0|		    SNMP_FREE(oldmibpath);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2645|      0|		}
 2646|      1|		oldmibpath = new_mibpath;
 2647|      1|            } else {
 2648|      0|                break;
 2649|      0|            }
 2650|      1|        }
 2651|       |
 2652|      1|        netsnmp_set_mib_directory(mibpath);
 2653|       |	
 2654|       |	/*  The above copies the mibpath for us, so...  */
 2655|       |
 2656|      1|	if (oldmibpath != NULL) {
  ------------------
  |  Branch (2656:6): [True: 1, False: 0]
  ------------------
 2657|      1|	    SNMP_FREE(oldmibpath);
  ------------------
  |  |   62|      1|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 1, False: 0]
  |  |  |  Branch (62:66): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2658|      1|	}
 2659|       |
 2660|      1|    }
 2661|       |
 2662|      1|}
netsnmp_init_mib:
 2671|      1|{
 2672|      1|    const char     *prefix;
 2673|      1|    char           *env_var, *entry;
 2674|      1|    PrefixListPtr   pp = &mib_prefixes[0];
 2675|      1|    char           *st = NULL;
 2676|       |
 2677|      1|    if (Mib)
  ------------------
  |  Branch (2677:9): [True: 0, False: 1]
  ------------------
 2678|      0|        return;
 2679|      1|    netsnmp_init_mib_internals();
 2680|       |
 2681|       |    /*
 2682|       |     * Initialise the MIB directory/ies 
 2683|       |     */
 2684|      1|    netsnmp_fixup_mib_directory();
 2685|      1|    env_var = strdup(netsnmp_get_mib_directory());
 2686|      1|    if (!env_var)
  ------------------
  |  Branch (2686:9): [True: 0, False: 1]
  ------------------
 2687|      0|        return;
 2688|       |
 2689|      1|    DEBUGMSGTL(("init_mib",
  ------------------
  |  |   68|      1|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      1|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      1|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      1|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      1|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2690|      1|                "Seen MIBDIRS: Looking in '%s' for mib dirs ...\n",
 2691|      1|                env_var));
 2692|       |
 2693|      1|    entry = strtok_r(env_var, ENV_SEPARATOR, &st);
  ------------------
  |  |   67|      1|#define ENV_SEPARATOR ":"
  ------------------
 2694|      3|    while (entry) {
  ------------------
  |  Branch (2694:12): [True: 2, False: 1]
  ------------------
 2695|      2|        add_mibdir(entry);
 2696|      2|        entry = strtok_r(NULL, ENV_SEPARATOR, &st);
  ------------------
  |  |   67|      2|#define ENV_SEPARATOR ":"
  ------------------
 2697|      2|    }
 2698|      1|    SNMP_FREE(env_var);
  ------------------
  |  |   62|      1|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 1, False: 0]
  |  |  |  Branch (62:66): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2699|       |
 2700|      1|    env_var = netsnmp_getenv("MIBFILES");
 2701|      1|    if (env_var != NULL) {
  ------------------
  |  Branch (2701:9): [True: 0, False: 1]
  ------------------
 2702|      0|        if (*env_var == '+')
  ------------------
  |  Branch (2702:13): [True: 0, False: 0]
  ------------------
 2703|      0|            entry = strtok_r(env_var+1, ENV_SEPARATOR, &st);
  ------------------
  |  |   67|      0|#define ENV_SEPARATOR ":"
  ------------------
 2704|      0|        else
 2705|      0|            entry = strtok_r(env_var, ENV_SEPARATOR, &st);
  ------------------
  |  |   67|      0|#define ENV_SEPARATOR ":"
  ------------------
 2706|      0|        while (entry) {
  ------------------
  |  Branch (2706:16): [True: 0, False: 0]
  ------------------
 2707|      0|            add_mibfile(entry, NULL);
 2708|      0|            entry = strtok_r(NULL, ENV_SEPARATOR, &st);
  ------------------
  |  |   67|      0|#define ENV_SEPARATOR ":"
  ------------------
 2709|      0|        }
 2710|      0|    }
 2711|       |
 2712|      1|    netsnmp_init_mib_internals();
 2713|       |
 2714|       |    /*
 2715|       |     * Read in any modules or mibs requested 
 2716|       |     */
 2717|       |
 2718|      1|    env_var = netsnmp_getenv("MIBS");
 2719|      1|    if (env_var == NULL) {
  ------------------
  |  Branch (2719:9): [True: 1, False: 0]
  ------------------
 2720|      1|        if (confmibs != NULL)
  ------------------
  |  Branch (2720:13): [True: 0, False: 1]
  ------------------
 2721|      0|            env_var = strdup(confmibs);
 2722|      1|        else
 2723|      1|            env_var = strdup(NETSNMP_DEFAULT_MIBS);
  ------------------
  |  | 1964|      1|#define NETSNMP_DEFAULT_MIBS ":NET-SNMP-EXTEND-MIB:SNMPv2-MIB:IF-MIB:IP-MIB:TCP-MIB:UDP-MIB:HOST-RESOURCES-MIB:NOTIFICATION-LOG-MIB:DISMAN-EVENT-MIB:DISMAN-SCHEDULE-MIB:NET-SNMP-PERIODIC-NOTIFY-MIB:DISMAN-NSLOOKUP-MIB:DISMAN-PING-MIB:DISMAN-TRACEROUTE-MIB:EtherLike-MIB:NET-SNMP-EXAMPLES-MIB:HOST-RESOURCES-TYPES:IP-FORWARD-MIB:MTA-MIB:NETWORK-SERVICES-MIB:UCD-IPFWACC-MIB:RMON-MIB:SCTP-MIB:SNMP-USM-DH-OBJECTS-MIB:SNMP-TLS-TM-MIB:SNMP-TSM-MIB:TUNNEL-MIB:IPV6-FLOW-LABEL-MIB:UCD-DISKIO-MIB:LM-SENSORS-MIB:UCD-SNMP-MIB:UCD-DEMO-MIB:SNMP-TARGET-MIB:NET-SNMP-AGENT-MIB:SNMP-NOTIFICATION-MIB:NET-SNMP-PASS-MIB:SNMP-FRAMEWORK-MIB:SNMP-MPD-MIB:SNMP-USER-BASED-SM-MIB:SNMP-VIEW-BASED-ACM-MIB:SNMP-COMMUNITY-MIB:IPV6-ICMP-MIB:IPV6-MIB:IPV6-TCP-MIB:IPV6-UDP-MIB:UCD-DLMOD-MIB:SNMPv2-TM:NET-SNMP-VACM-MIB"
  ------------------
 2724|      1|    } else {
 2725|      0|        env_var = strdup(env_var);
 2726|      0|    }
 2727|      1|    if (env_var && ((*env_var == '+') || (*env_var == '-'))) {
  ------------------
  |  Branch (2727:9): [True: 1, False: 0]
  |  Branch (2727:21): [True: 0, False: 1]
  |  Branch (2727:42): [True: 0, False: 1]
  ------------------
 2728|      0|        entry =
 2729|      0|            (char *) malloc(strlen(NETSNMP_DEFAULT_MIBS) + strlen(env_var) + 2);
  ------------------
  |  | 1964|      0|#define NETSNMP_DEFAULT_MIBS ":NET-SNMP-EXTEND-MIB:SNMPv2-MIB:IF-MIB:IP-MIB:TCP-MIB:UDP-MIB:HOST-RESOURCES-MIB:NOTIFICATION-LOG-MIB:DISMAN-EVENT-MIB:DISMAN-SCHEDULE-MIB:NET-SNMP-PERIODIC-NOTIFY-MIB:DISMAN-NSLOOKUP-MIB:DISMAN-PING-MIB:DISMAN-TRACEROUTE-MIB:EtherLike-MIB:NET-SNMP-EXAMPLES-MIB:HOST-RESOURCES-TYPES:IP-FORWARD-MIB:MTA-MIB:NETWORK-SERVICES-MIB:UCD-IPFWACC-MIB:RMON-MIB:SCTP-MIB:SNMP-USM-DH-OBJECTS-MIB:SNMP-TLS-TM-MIB:SNMP-TSM-MIB:TUNNEL-MIB:IPV6-FLOW-LABEL-MIB:UCD-DISKIO-MIB:LM-SENSORS-MIB:UCD-SNMP-MIB:UCD-DEMO-MIB:SNMP-TARGET-MIB:NET-SNMP-AGENT-MIB:SNMP-NOTIFICATION-MIB:NET-SNMP-PASS-MIB:SNMP-FRAMEWORK-MIB:SNMP-MPD-MIB:SNMP-USER-BASED-SM-MIB:SNMP-VIEW-BASED-ACM-MIB:SNMP-COMMUNITY-MIB:IPV6-ICMP-MIB:IPV6-MIB:IPV6-TCP-MIB:IPV6-UDP-MIB:UCD-DLMOD-MIB:SNMPv2-TM:NET-SNMP-VACM-MIB"
  ------------------
 2730|      0|        if (!entry) {
  ------------------
  |  Branch (2730:13): [True: 0, False: 0]
  ------------------
 2731|      0|            DEBUGMSGTL(("init_mib", "env mibs malloc failed"));
  ------------------
  |  |   68|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2732|      0|            SNMP_FREE(env_var);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2733|      0|            return;
 2734|      0|        } else {
 2735|      0|            if (*env_var == '+')
  ------------------
  |  Branch (2735:17): [True: 0, False: 0]
  ------------------
 2736|      0|                sprintf(entry, "%s%c%s", NETSNMP_DEFAULT_MIBS, ENV_SEPARATOR_CHAR,
  ------------------
  |  | 1964|      0|#define NETSNMP_DEFAULT_MIBS ":NET-SNMP-EXTEND-MIB:SNMPv2-MIB:IF-MIB:IP-MIB:TCP-MIB:UDP-MIB:HOST-RESOURCES-MIB:NOTIFICATION-LOG-MIB:DISMAN-EVENT-MIB:DISMAN-SCHEDULE-MIB:NET-SNMP-PERIODIC-NOTIFY-MIB:DISMAN-NSLOOKUP-MIB:DISMAN-PING-MIB:DISMAN-TRACEROUTE-MIB:EtherLike-MIB:NET-SNMP-EXAMPLES-MIB:HOST-RESOURCES-TYPES:IP-FORWARD-MIB:MTA-MIB:NETWORK-SERVICES-MIB:UCD-IPFWACC-MIB:RMON-MIB:SCTP-MIB:SNMP-USM-DH-OBJECTS-MIB:SNMP-TLS-TM-MIB:SNMP-TSM-MIB:TUNNEL-MIB:IPV6-FLOW-LABEL-MIB:UCD-DISKIO-MIB:LM-SENSORS-MIB:UCD-SNMP-MIB:UCD-DEMO-MIB:SNMP-TARGET-MIB:NET-SNMP-AGENT-MIB:SNMP-NOTIFICATION-MIB:NET-SNMP-PASS-MIB:SNMP-FRAMEWORK-MIB:SNMP-MPD-MIB:SNMP-USER-BASED-SM-MIB:SNMP-VIEW-BASED-ACM-MIB:SNMP-COMMUNITY-MIB:IPV6-ICMP-MIB:IPV6-MIB:IPV6-TCP-MIB:IPV6-UDP-MIB:UCD-DLMOD-MIB:SNMPv2-TM:NET-SNMP-VACM-MIB"
  ------------------
                              sprintf(entry, "%s%c%s", NETSNMP_DEFAULT_MIBS, ENV_SEPARATOR_CHAR,
  ------------------
  |  |   70|      0|#define ENV_SEPARATOR_CHAR ':'
  ------------------
 2737|      0|                        env_var+1);
 2738|      0|            else
 2739|      0|                sprintf(entry, "%s%c%s", env_var+1, ENV_SEPARATOR_CHAR,
  ------------------
  |  |   70|      0|#define ENV_SEPARATOR_CHAR ':'
  ------------------
 2740|      0|                        NETSNMP_DEFAULT_MIBS );
  ------------------
  |  | 1964|      0|#define NETSNMP_DEFAULT_MIBS ":NET-SNMP-EXTEND-MIB:SNMPv2-MIB:IF-MIB:IP-MIB:TCP-MIB:UDP-MIB:HOST-RESOURCES-MIB:NOTIFICATION-LOG-MIB:DISMAN-EVENT-MIB:DISMAN-SCHEDULE-MIB:NET-SNMP-PERIODIC-NOTIFY-MIB:DISMAN-NSLOOKUP-MIB:DISMAN-PING-MIB:DISMAN-TRACEROUTE-MIB:EtherLike-MIB:NET-SNMP-EXAMPLES-MIB:HOST-RESOURCES-TYPES:IP-FORWARD-MIB:MTA-MIB:NETWORK-SERVICES-MIB:UCD-IPFWACC-MIB:RMON-MIB:SCTP-MIB:SNMP-USM-DH-OBJECTS-MIB:SNMP-TLS-TM-MIB:SNMP-TSM-MIB:TUNNEL-MIB:IPV6-FLOW-LABEL-MIB:UCD-DISKIO-MIB:LM-SENSORS-MIB:UCD-SNMP-MIB:UCD-DEMO-MIB:SNMP-TARGET-MIB:NET-SNMP-AGENT-MIB:SNMP-NOTIFICATION-MIB:NET-SNMP-PASS-MIB:SNMP-FRAMEWORK-MIB:SNMP-MPD-MIB:SNMP-USER-BASED-SM-MIB:SNMP-VIEW-BASED-ACM-MIB:SNMP-COMMUNITY-MIB:IPV6-ICMP-MIB:IPV6-MIB:IPV6-TCP-MIB:IPV6-UDP-MIB:UCD-DLMOD-MIB:SNMPv2-TM:NET-SNMP-VACM-MIB"
  ------------------
 2741|      0|        }
 2742|      0|        SNMP_FREE(env_var);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2743|      0|        env_var = entry;
 2744|      0|    }
 2745|       |
 2746|      1|    DEBUGMSGTL(("init_mib",
  ------------------
  |  |   68|      1|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      1|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      1|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      1|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      1|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2747|      1|                "Seen MIBS: Looking in '%s' for mib files ...\n",
 2748|      1|                env_var));
 2749|      1|    entry = strtok_r(env_var, ENV_SEPARATOR, &st);
  ------------------
  |  |   67|      1|#define ENV_SEPARATOR ":"
  ------------------
 2750|     49|    while (entry) {
  ------------------
  |  Branch (2750:12): [True: 48, False: 1]
  ------------------
 2751|     48|        if (strcasecmp(entry, DEBUG_ALWAYS_TOKEN) == 0) {
  ------------------
  |  |  229|     48|#define DEBUG_ALWAYS_TOKEN "all"
  ------------------
  |  Branch (2751:13): [True: 0, False: 48]
  ------------------
 2752|      0|            read_all_mibs();
 2753|     48|        } else if (strstr(entry, "/") != NULL) {
  ------------------
  |  Branch (2753:20): [True: 0, False: 48]
  ------------------
 2754|      0|            read_mib(entry);
 2755|     48|        } else {
 2756|     48|            netsnmp_read_module(entry);
 2757|     48|        }
 2758|     48|        entry = strtok_r(NULL, ENV_SEPARATOR, &st);
  ------------------
  |  |   67|     48|#define ENV_SEPARATOR ":"
  ------------------
 2759|     48|    }
 2760|      1|    adopt_orphans();
 2761|      1|    SNMP_FREE(env_var);
  ------------------
  |  |   62|      1|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 1, False: 0]
  |  |  |  Branch (62:66): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2762|       |
 2763|      1|    env_var = netsnmp_getenv("MIBFILES");
 2764|      1|    if (env_var != NULL) {
  ------------------
  |  Branch (2764:9): [True: 0, False: 1]
  ------------------
 2765|      0|        if ((*env_var == '+') || (*env_var == '-')) {
  ------------------
  |  Branch (2765:13): [True: 0, False: 0]
  |  Branch (2765:34): [True: 0, False: 0]
  ------------------
 2766|       |#ifdef NETSNMP_DEFAULT_MIBFILES
 2767|       |            entry =
 2768|       |                (char *) malloc(strlen(NETSNMP_DEFAULT_MIBFILES) +
 2769|       |                                strlen(env_var) + 2);
 2770|       |            if (!entry) {
 2771|       |                DEBUGMSGTL(("init_mib", "env mibfiles malloc failed"));
 2772|       |            } else {
 2773|       |                if (*env_var++ == '+')
 2774|       |                    sprintf(entry, "%s%c%s", NETSNMP_DEFAULT_MIBFILES, ENV_SEPARATOR_CHAR,
 2775|       |                            env_var );
 2776|       |                else
 2777|       |                    sprintf(entry, "%s%c%s", env_var, ENV_SEPARATOR_CHAR,
 2778|       |                            NETSNMP_DEFAULT_MIBFILES );
 2779|       |            }
 2780|       |            SNMP_FREE(env_var);
 2781|       |            env_var = entry;
 2782|       |#else
 2783|      0|            env_var = strdup(env_var + 1);
 2784|      0|#endif
 2785|      0|        } else {
 2786|      0|            env_var = strdup(env_var);
 2787|      0|        }
 2788|      1|    } else {
 2789|       |#ifdef NETSNMP_DEFAULT_MIBFILES
 2790|       |        env_var = strdup(NETSNMP_DEFAULT_MIBFILES);
 2791|       |#endif
 2792|      1|    }
 2793|       |
 2794|      1|    if (env_var != NULL) {
  ------------------
  |  Branch (2794:9): [True: 0, False: 1]
  ------------------
 2795|      0|        DEBUGMSGTL(("init_mib",
  ------------------
  |  |   68|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2796|      0|                    "Seen MIBFILES: Looking in '%s' for mib files ...\n",
 2797|      0|                    env_var));
 2798|      0|        entry = strtok_r(env_var, ENV_SEPARATOR, &st);
  ------------------
  |  |   67|      0|#define ENV_SEPARATOR ":"
  ------------------
 2799|      0|        while (entry) {
  ------------------
  |  Branch (2799:16): [True: 0, False: 0]
  ------------------
 2800|      0|            read_mib(entry);
 2801|      0|            entry = strtok_r(NULL, ENV_SEPARATOR, &st);
  ------------------
  |  |   67|      0|#define ENV_SEPARATOR ":"
  ------------------
 2802|      0|        }
 2803|      0|        SNMP_FREE(env_var);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2804|      0|    }
 2805|       |
 2806|      1|    prefix = netsnmp_getenv("PREFIX");
 2807|       |
 2808|      1|    if (!prefix)
  ------------------
  |  Branch (2808:9): [True: 1, False: 0]
  ------------------
 2809|      1|        prefix = Standard_Prefix;
 2810|       |
 2811|      1|    Prefix = (char *) malloc(strlen(prefix) + 2);
 2812|      1|    if (!Prefix)
  ------------------
  |  Branch (2812:9): [True: 0, False: 1]
  ------------------
 2813|      0|        DEBUGMSGTL(("init_mib", "Prefix malloc failed"));
  ------------------
  |  |   68|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2814|      1|    else
 2815|      1|        strcpy(Prefix, prefix);
 2816|       |
 2817|      1|    DEBUGMSGTL(("init_mib",
  ------------------
  |  |   68|      1|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      1|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      1|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      1|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      1|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2818|      1|                "Seen PREFIX: Looking in '%s' for prefix ...\n", Prefix));
 2819|       |
 2820|       |    /*
 2821|       |     * remove trailing dot 
 2822|       |     */
 2823|      1|    if (Prefix) {
  ------------------
  |  Branch (2823:9): [True: 1, False: 0]
  ------------------
 2824|      1|        env_var = &Prefix[strlen(Prefix) - 1];
 2825|      1|        if (*env_var == '.')
  ------------------
  |  Branch (2825:13): [True: 0, False: 1]
  ------------------
 2826|      0|            *env_var = '\0';
 2827|      1|    }
 2828|       |
 2829|      1|    pp->str = Prefix;           /* fixup first mib_prefix entry */
 2830|       |    /*
 2831|       |     * now that the list of prefixes is built, save each string length. 
 2832|       |     */
 2833|      7|    while (pp->str) {
  ------------------
  |  Branch (2833:12): [True: 6, False: 1]
  ------------------
 2834|      6|        pp->len = strlen(pp->str);
 2835|      6|        pp++;
 2836|      6|    }
 2837|       |
 2838|      1|    Mib = tree_head;            /* Backwards compatibility */
 2839|      1|    tree_top = calloc(1, sizeof(struct tree));
 2840|       |    /*
 2841|       |     * XX error check ? 
 2842|       |     */
 2843|      1|    if (tree_top) {
  ------------------
  |  Branch (2843:9): [True: 1, False: 0]
  ------------------
 2844|      1|        tree_top->label = strdup("(top)");
 2845|      1|        tree_top->child_list = tree_head;
 2846|      1|    }
 2847|      1|}
set_function:
 2910|      3|{
 2911|      3|    subtree->printer = NULL;
 2912|      3|    switch (subtree->type) {
 2913|      0|    case TYPE_OBJID:
  ------------------
  |  |  154|      0|#define TYPE_OBJID          1
  ------------------
  |  Branch (2913:5): [True: 0, False: 3]
  ------------------
 2914|      0|        subtree->printomat = sprint_realloc_object_identifier;
 2915|      0|        break;
 2916|      0|    case TYPE_OCTETSTR:
  ------------------
  |  |  155|      0|#define TYPE_OCTETSTR       2
  ------------------
  |  Branch (2916:5): [True: 0, False: 3]
  ------------------
 2917|      0|        subtree->printomat = sprint_realloc_octet_string;
 2918|      0|        break;
 2919|      0|    case TYPE_INTEGER:
  ------------------
  |  |  156|      0|#define TYPE_INTEGER        3
  ------------------
  |  Branch (2919:5): [True: 0, False: 3]
  ------------------
 2920|      0|        subtree->printomat = sprint_realloc_integer;
 2921|      0|        break;
 2922|      0|    case TYPE_INTEGER32:
  ------------------
  |  |  169|      0|#define TYPE_INTEGER32      16
  ------------------
  |  Branch (2922:5): [True: 0, False: 3]
  ------------------
 2923|      0|        subtree->printomat = sprint_realloc_integer;
 2924|      0|        break;
 2925|      0|    case TYPE_NETADDR:
  ------------------
  |  |  157|      0|#define TYPE_NETADDR        4
  ------------------
  |  Branch (2925:5): [True: 0, False: 3]
  ------------------
 2926|      0|        subtree->printomat = sprint_realloc_networkaddress;
 2927|      0|        break;
 2928|      0|    case TYPE_IPADDR:
  ------------------
  |  |  158|      0|#define TYPE_IPADDR         5
  ------------------
  |  Branch (2928:5): [True: 0, False: 3]
  ------------------
 2929|      0|        subtree->printomat = sprint_realloc_ipaddress;
 2930|      0|        break;
 2931|      0|    case TYPE_COUNTER:
  ------------------
  |  |  159|      0|#define TYPE_COUNTER        6
  ------------------
  |  Branch (2931:5): [True: 0, False: 3]
  ------------------
 2932|      0|        subtree->printomat = sprint_realloc_counter;
 2933|      0|        break;
 2934|      0|    case TYPE_GAUGE:
  ------------------
  |  |  160|      0|#define TYPE_GAUGE          7
  ------------------
  |  Branch (2934:5): [True: 0, False: 3]
  ------------------
 2935|      0|        subtree->printomat = sprint_realloc_gauge;
 2936|      0|        break;
 2937|      0|    case TYPE_TIMETICKS:
  ------------------
  |  |  161|      0|#define TYPE_TIMETICKS      8
  ------------------
  |  Branch (2937:5): [True: 0, False: 3]
  ------------------
 2938|      0|        subtree->printomat = sprint_realloc_timeticks;
 2939|      0|        break;
 2940|      0|    case TYPE_OPAQUE:
  ------------------
  |  |  162|      0|#define TYPE_OPAQUE         9
  ------------------
  |  Branch (2940:5): [True: 0, False: 3]
  ------------------
 2941|      0|        subtree->printomat = sprint_realloc_opaque;
 2942|      0|        break;
 2943|      0|    case TYPE_NULL:
  ------------------
  |  |  163|      0|#define TYPE_NULL           10
  ------------------
  |  Branch (2943:5): [True: 0, False: 3]
  ------------------
 2944|      0|        subtree->printomat = sprint_realloc_null;
 2945|      0|        break;
 2946|      0|    case TYPE_BITSTRING:
  ------------------
  |  |  165|      0|#define TYPE_BITSTRING      12
  ------------------
  |  Branch (2946:5): [True: 0, False: 3]
  ------------------
 2947|      0|        subtree->printomat = sprint_realloc_bitstring;
 2948|      0|        break;
 2949|      0|    case TYPE_NSAPADDRESS:
  ------------------
  |  |  166|      0|#define TYPE_NSAPADDRESS    13
  ------------------
  |  Branch (2949:5): [True: 0, False: 3]
  ------------------
 2950|      0|        subtree->printomat = sprint_realloc_nsapaddress;
 2951|      0|        break;
 2952|      0|    case TYPE_COUNTER64:
  ------------------
  |  |  164|      0|#define TYPE_COUNTER64      11
  ------------------
  |  Branch (2952:5): [True: 0, False: 3]
  ------------------
 2953|      0|        subtree->printomat = sprint_realloc_counter64;
 2954|      0|        break;
 2955|      0|    case TYPE_UINTEGER:
  ------------------
  |  |  167|      0|#define TYPE_UINTEGER       14
  ------------------
  |  Branch (2955:5): [True: 0, False: 3]
  ------------------
 2956|      0|        subtree->printomat = sprint_realloc_uinteger;
 2957|      0|        break;
 2958|      0|    case TYPE_UNSIGNED32:
  ------------------
  |  |  168|      0|#define TYPE_UNSIGNED32     15
  ------------------
  |  Branch (2958:5): [True: 0, False: 3]
  ------------------
 2959|      0|        subtree->printomat = sprint_realloc_gauge;
 2960|      0|        break;
 2961|      3|    case TYPE_OTHER:
  ------------------
  |  |  153|      3|#define TYPE_OTHER          0
  ------------------
  |  Branch (2961:5): [True: 3, False: 0]
  ------------------
 2962|      3|    default:
  ------------------
  |  Branch (2962:5): [True: 0, False: 3]
  ------------------
 2963|      3|        subtree->printomat = sprint_realloc_by_type;
 2964|      3|        break;
 2965|      3|    }
 2966|      3|}
netsnmp_sprint_realloc_objid_tree:
 3140|    682|{
 3141|    682|    u_char         *tbuf = NULL, *cp = NULL;
 3142|    682|    size_t          tbuf_len = 512, tout_len = 0;
 3143|    682|    struct tree    *subtree = tree_head;
 3144|    682|    size_t          midpoint_offset = 0;
 3145|    682|    int             tbuf_overflow = 0;
 3146|    682|    int             output_format;
 3147|       |
 3148|    682|    if ((tbuf = calloc(tbuf_len, 1)) == NULL) {
  ------------------
  |  Branch (3148:9): [True: 0, False: 682]
  ------------------
 3149|      0|        tbuf_overflow = 1;
 3150|    682|    } else {
 3151|    682|        *tbuf = '.';
 3152|    682|        tout_len = 1;
 3153|    682|    }
 3154|       |
 3155|    682|    subtree = _get_realloc_symbol(objid, objidlen, subtree,
 3156|    682|                                  &tbuf, &tbuf_len, &tout_len,
 3157|    682|                                  allow_realloc, &tbuf_overflow, NULL,
 3158|    682|                                  &midpoint_offset);
 3159|       |
 3160|    682|    if (tbuf_overflow) {
  ------------------
  |  Branch (3160:9): [True: 0, False: 682]
  ------------------
 3161|      0|        if (!*buf_overflow) {
  ------------------
  |  Branch (3161:13): [True: 0, False: 0]
  ------------------
 3162|      0|            snmp_strcat(buf, buf_len, out_len, allow_realloc, tbuf);
 3163|      0|            *buf_overflow = 1;
 3164|      0|        }
 3165|      0|        SNMP_FREE(tbuf);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded - Ignored]
  |  |  ------------------
  ------------------
 3166|      0|        return subtree;
 3167|      0|    }
 3168|       |
 3169|    682|    output_format = netsnmp_ds_get_int(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_OID_OUTPUT_FORMAT);
  ------------------
  |  |   48|    682|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                  output_format = netsnmp_ds_get_int(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_OID_OUTPUT_FORMAT);
  ------------------
  |  |  118|    682|#define NETSNMP_DS_LIB_OID_OUTPUT_FORMAT    4
  ------------------
 3170|    682|    if (0 == output_format) {
  ------------------
  |  Branch (3170:9): [True: 682, False: 0]
  ------------------
 3171|    682|        output_format = NETSNMP_OID_OUTPUT_MODULE;
  ------------------
  |  |  512|    682|#define NETSNMP_OID_OUTPUT_MODULE  2
  ------------------
 3172|    682|    }
 3173|    682|    switch (output_format) {
 3174|      0|    case NETSNMP_OID_OUTPUT_FULL:
  ------------------
  |  |  513|      0|#define NETSNMP_OID_OUTPUT_FULL    3
  ------------------
  |  Branch (3174:5): [True: 0, False: 682]
  ------------------
 3175|      0|    case NETSNMP_OID_OUTPUT_FULL_AND_NUMERIC:
  ------------------
  |  |  517|      0|#define NETSNMP_OID_OUTPUT_FULL_AND_NUMERIC 7
  ------------------
  |  Branch (3175:5): [True: 0, False: 682]
  ------------------
 3176|      0|    case NETSNMP_OID_OUTPUT_NUMERIC:
  ------------------
  |  |  514|      0|#define NETSNMP_OID_OUTPUT_NUMERIC 4
  ------------------
  |  Branch (3176:5): [True: 0, False: 682]
  ------------------
 3177|      0|        cp = tbuf;
 3178|      0|        break;
 3179|       |
 3180|      0|    case NETSNMP_OID_OUTPUT_SUFFIX:
  ------------------
  |  |  511|      0|#define NETSNMP_OID_OUTPUT_SUFFIX  1
  ------------------
  |  Branch (3180:5): [True: 0, False: 682]
  ------------------
 3181|    682|    case NETSNMP_OID_OUTPUT_MODULE:
  ------------------
  |  |  512|    682|#define NETSNMP_OID_OUTPUT_MODULE  2
  ------------------
  |  Branch (3181:5): [True: 682, False: 0]
  ------------------
 3182|  12.5k|        for (cp = tbuf; *cp; cp++);
  ------------------
  |  Branch (3182:25): [True: 11.9k, False: 682]
  ------------------
 3183|       |
 3184|    682|        if (midpoint_offset != 0) {
  ------------------
  |  Branch (3184:13): [True: 338, False: 344]
  ------------------
 3185|    338|            cp = tbuf + midpoint_offset - 2;    /*  beyond the '.'  */
 3186|    344|        } else {
 3187|    688|            while (cp >= tbuf) {
  ------------------
  |  Branch (3187:20): [True: 688, False: 0]
  ------------------
 3188|    688|                if (isalpha(*cp)) {
 3189|    344|                    break;
 3190|    344|                }
 3191|    344|                cp--;
 3192|    344|            }
 3193|    344|        }
 3194|       |
 3195|  5.26k|        while (cp >= tbuf) {
  ------------------
  |  Branch (3195:16): [True: 5.26k, False: 0]
  ------------------
 3196|  5.26k|            if (*cp == '.') {
  ------------------
  |  Branch (3196:17): [True: 682, False: 4.58k]
  ------------------
 3197|    682|                break;
 3198|    682|            }
 3199|  4.58k|            cp--;
 3200|  4.58k|        }
 3201|       |
 3202|    682|        cp++;
 3203|       |
 3204|    682|        if ((NETSNMP_OID_OUTPUT_MODULE == output_format)
  ------------------
  |  |  512|    682|#define NETSNMP_OID_OUTPUT_MODULE  2
  ------------------
  |  Branch (3204:13): [True: 682, False: 0]
  ------------------
 3205|    682|            && cp > tbuf) {
  ------------------
  |  Branch (3205:16): [True: 682, False: 0]
  ------------------
 3206|    682|            char            modbuf[256] = { 0 }, *mod =
 3207|    682|                module_name(subtree->modid, modbuf);
 3208|       |
 3209|       |            /*
 3210|       |             * Don't add the module ID if it's just numeric (i.e. we couldn't look
 3211|       |             * it up properly.  
 3212|       |             */
 3213|       |
 3214|    682|            if (!*buf_overflow && modbuf[0] != '#') {
  ------------------
  |  Branch (3214:17): [True: 682, False: 0]
  |  Branch (3214:35): [True: 0, False: 682]
  ------------------
 3215|      0|                if (!snmp_cstrcat(buf, buf_len, out_len, allow_realloc, mod) ||
  ------------------
  |  Branch (3215:21): [True: 0, False: 0]
  ------------------
 3216|      0|                    !snmp_cstrcat(buf, buf_len, out_len, allow_realloc, "::")) {
  ------------------
  |  Branch (3216:21): [True: 0, False: 0]
  ------------------
 3217|      0|                    *buf_overflow = 1;
 3218|      0|                }
 3219|      0|            }
 3220|    682|        }
 3221|    682|        break;
 3222|       |
 3223|      0|    case NETSNMP_OID_OUTPUT_UCD:
  ------------------
  |  |  515|      0|#define NETSNMP_OID_OUTPUT_UCD     5
  ------------------
  |  Branch (3223:5): [True: 0, False: 682]
  ------------------
 3224|      0|    {
 3225|      0|        PrefixListPtr   pp = &mib_prefixes[0];
 3226|      0|        size_t          ilen, tlen;
 3227|      0|        const char     *testcp;
 3228|       |
 3229|      0|        cp = tbuf;
 3230|      0|        tlen = strlen((char *) tbuf);
 3231|       |
 3232|      0|        while (pp->str) {
  ------------------
  |  Branch (3232:16): [True: 0, False: 0]
  ------------------
 3233|      0|            ilen = pp->len;
 3234|      0|            testcp = pp->str;
 3235|       |
 3236|      0|            if ((tlen > ilen) && memcmp(tbuf, testcp, ilen) == 0) {
  ------------------
  |  Branch (3236:17): [True: 0, False: 0]
  |  Branch (3236:34): [True: 0, False: 0]
  ------------------
 3237|      0|                cp += (ilen + 1);
 3238|      0|                break;
 3239|      0|            }
 3240|      0|            pp++;
 3241|      0|        }
 3242|      0|        break;
 3243|      0|    }
 3244|       |
 3245|      0|    case NETSNMP_OID_OUTPUT_NONE:
  ------------------
  |  |  516|      0|#define NETSNMP_OID_OUTPUT_NONE    6
  ------------------
  |  Branch (3245:5): [True: 0, False: 682]
  ------------------
 3246|      0|    default:
  ------------------
  |  Branch (3246:5): [True: 0, False: 682]
  ------------------
 3247|      0|        cp = NULL;
 3248|    682|    }
 3249|       |
 3250|    682|    if (!*buf_overflow &&
  ------------------
  |  Branch (3250:9): [True: 682, False: 0]
  ------------------
 3251|    682|        !snmp_strcat(buf, buf_len, out_len, allow_realloc, cp)) {
  ------------------
  |  Branch (3251:9): [True: 0, False: 682]
  ------------------
 3252|      0|        *buf_overflow = 1;
 3253|      0|    }
 3254|    682|    SNMP_FREE(tbuf);
  ------------------
  |  |   62|    682|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 682, False: 0]
  |  |  |  Branch (62:66): [Folded - Ignored]
  |  |  ------------------
  ------------------
 3255|    682|    return subtree;
 3256|    682|}
sprint_realloc_objid:
 3263|    682|{
 3264|    682|    int             buf_overflow = 0;
 3265|       |
 3266|    682|    netsnmp_sprint_realloc_objid_tree(buf, buf_len, out_len, allow_realloc,
 3267|    682|                                      &buf_overflow, objid, objidlen);
 3268|    682|    return !buf_overflow;
 3269|    682|}
mib.c:_oid_finish_printing:
 4136|    338|                     int allow_realloc, int *buf_overflow) {
 4137|    338|    char            intbuf[64];
 4138|    338|    if (*buf != NULL && *(*buf + *out_len - 1) != '.') {
  ------------------
  |  Branch (4138:9): [True: 338, False: 0]
  |  Branch (4138:25): [True: 0, False: 338]
  ------------------
 4139|      0|        if (!*buf_overflow && !snmp_cstrcat(buf, buf_len, out_len,
  ------------------
  |  Branch (4139:13): [True: 0, False: 0]
  |  Branch (4139:31): [True: 0, False: 0]
  ------------------
 4140|      0|                                            allow_realloc, ".")) {
 4141|      0|            *buf_overflow = 1;
 4142|      0|        }
 4143|      0|    }
 4144|       |
 4145|  2.33k|    while (objidlen-- > 0) {    /* output rest of name, uninterpreted */
  ------------------
  |  Branch (4145:12): [True: 1.99k, False: 338]
  ------------------
 4146|  1.99k|        sprintf(intbuf, "%" NETSNMP_PRIo "u.", *objid++);
 4147|  1.99k|        if (!*buf_overflow && !snmp_cstrcat(buf, buf_len, out_len,
  ------------------
  |  Branch (4147:13): [True: 1.99k, False: 0]
  |  Branch (4147:31): [True: 0, False: 1.99k]
  ------------------
 4148|  1.99k|                                            allow_realloc, intbuf)) {
 4149|      0|            *buf_overflow = 1;
 4150|      0|        }
 4151|  1.99k|    }
 4152|       |
 4153|    338|    if (*buf != NULL) {
  ------------------
  |  Branch (4153:9): [True: 338, False: 0]
  ------------------
 4154|    338|        *(*buf + *out_len - 1) = '\0';  /* remove trailing dot */
 4155|    338|        *out_len = *out_len - 1;
 4156|    338|    }
 4157|    338|}
mib.c:_get_realloc_symbol:
 4191|  1.02k|{
 4192|  1.02k|    struct tree    *return_tree = NULL;
 4193|  1.02k|    int             extended_index =
 4194|  1.02k|        netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_EXTENDED_INDEX);
  ------------------
  |  |   48|  1.02k|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                      netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_EXTENDED_INDEX);
  ------------------
  |  |   82|  1.02k|#define NETSNMP_DS_LIB_EXTENDED_INDEX	   22   /* print extended index format [x1][x2] */
  ------------------
 4195|  1.02k|    int             output_format =
 4196|  1.02k|        netsnmp_ds_get_int(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_OID_OUTPUT_FORMAT);
  ------------------
  |  |   48|  1.02k|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                      netsnmp_ds_get_int(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_OID_OUTPUT_FORMAT);
  ------------------
  |  |  118|  1.02k|#define NETSNMP_DS_LIB_OID_OUTPUT_FORMAT    4
  ------------------
 4197|  1.02k|    char            intbuf[64];
 4198|  1.02k|    struct tree    *orgtree = subtree;
 4199|       |
 4200|  1.02k|    if (!objid || !buf) {
  ------------------
  |  Branch (4200:9): [True: 0, False: 1.02k]
  |  Branch (4200:19): [True: 0, False: 1.02k]
  ------------------
 4201|      0|        return NULL;
 4202|      0|    }
 4203|       |
 4204|  1.73k|    for (; subtree; subtree = subtree->next_peer) {
  ------------------
  |  Branch (4204:12): [True: 1.40k, False: 338]
  ------------------
 4205|  1.40k|        if (*objid == subtree->subid) {
  ------------------
  |  Branch (4205:13): [True: 682, False: 719]
  ------------------
 4206|    682|	    while (subtree->next_peer && subtree->next_peer->subid == *objid)
  ------------------
  |  Branch (4206:13): [True: 545, False: 137]
  |  Branch (4206:35): [True: 0, False: 545]
  ------------------
 4207|      0|		subtree = subtree->next_peer;
 4208|    682|            if (subtree->indexes) {
  ------------------
  |  Branch (4208:17): [True: 0, False: 682]
  ------------------
 4209|      0|                in_dices = subtree->indexes;
 4210|    682|            } else if (subtree->augments) {
  ------------------
  |  Branch (4210:24): [True: 0, False: 682]
  ------------------
 4211|      0|                struct tree    *tp2 =
 4212|      0|                    find_tree_node(subtree->augments, -1);
 4213|      0|                if (tp2) {
  ------------------
  |  Branch (4213:21): [True: 0, False: 0]
  ------------------
 4214|      0|                    in_dices = tp2->indexes;
 4215|      0|                }
 4216|      0|            }
 4217|       |
 4218|    682|            if (!strncmp(subtree->label, ANON, ANON_LEN) ||
  ------------------
  |  |  195|    682|#define	ANON	"anonymous#"
  ------------------
                          if (!strncmp(subtree->label, ANON, ANON_LEN) ||
  ------------------
  |  |  196|    682|#define	ANON_LEN  strlen(ANON)
  |  |  ------------------
  |  |  |  |  195|    682|#define	ANON	"anonymous#"
  |  |  ------------------
  ------------------
  |  Branch (4218:17): [True: 0, False: 682]
  ------------------
 4219|    682|                (NETSNMP_OID_OUTPUT_NUMERIC == output_format)) {
  ------------------
  |  |  514|    682|#define NETSNMP_OID_OUTPUT_NUMERIC 4
  ------------------
  |  Branch (4219:17): [True: 0, False: 682]
  ------------------
 4220|      0|                sprintf(intbuf, "%lu", subtree->subid);
 4221|      0|                if (!*buf_overflow && !snmp_cstrcat(buf, buf_len, out_len,
  ------------------
  |  Branch (4221:21): [True: 0, False: 0]
  |  Branch (4221:39): [True: 0, False: 0]
  ------------------
 4222|      0|                                                    allow_realloc, intbuf)) {
 4223|      0|                    *buf_overflow = 1;
 4224|      0|                }
 4225|    682|            } else {
 4226|    682|                if (!*buf_overflow &&
  ------------------
  |  Branch (4226:21): [True: 682, False: 0]
  ------------------
 4227|    682|                    !snmp_cstrcat(buf, buf_len, out_len, allow_realloc,
  ------------------
  |  Branch (4227:21): [True: 0, False: 682]
  ------------------
 4228|    682|                                  subtree->label)) {
 4229|      0|                    *buf_overflow = 1;
 4230|      0|                }
 4231|    682|                if (output_format == NETSNMP_OID_OUTPUT_FULL_AND_NUMERIC) {
  ------------------
  |  |  517|    682|#define NETSNMP_OID_OUTPUT_FULL_AND_NUMERIC 7
  ------------------
  |  Branch (4231:21): [True: 0, False: 682]
  ------------------
 4232|      0|                    snprintf(intbuf, sizeof intbuf, "(%lu)", subtree->subid);
 4233|      0|                    if (!*buf_overflow &&
  ------------------
  |  Branch (4233:25): [True: 0, False: 0]
  ------------------
 4234|      0|                        !snmp_cstrcat(buf, buf_len, out_len, allow_realloc,
  ------------------
  |  Branch (4234:25): [True: 0, False: 0]
  ------------------
 4235|      0|                                      intbuf)) {
 4236|      0|                        *buf_overflow = 1;
 4237|      0|                    }
 4238|      0|                }
 4239|    682|            }
 4240|       |
 4241|    682|            if (objidlen > 1) {
  ------------------
  |  Branch (4241:17): [True: 338, False: 344]
  ------------------
 4242|    338|                if (!*buf_overflow &&
  ------------------
  |  Branch (4242:21): [True: 338, False: 0]
  ------------------
 4243|    338|                    !snmp_cstrcat(buf, buf_len, out_len, allow_realloc, ".")) {
  ------------------
  |  Branch (4243:21): [True: 0, False: 338]
  ------------------
 4244|      0|                    *buf_overflow = 1;
 4245|      0|                }
 4246|       |
 4247|    338|                return_tree = _get_realloc_symbol(objid + 1, objidlen - 1,
 4248|    338|                                                  subtree->child_list,
 4249|    338|                                                  buf, buf_len, out_len,
 4250|    338|                                                  allow_realloc,
 4251|    338|                                                  buf_overflow, in_dices,
 4252|    338|                                                  end_of_known);
 4253|    338|            }
 4254|       |
 4255|    682|            if (return_tree != NULL) {
  ------------------
  |  Branch (4255:17): [True: 0, False: 682]
  ------------------
 4256|      0|                return return_tree;
 4257|    682|            } else {
 4258|    682|                return subtree;
 4259|    682|            }
 4260|    682|        }
 4261|  1.40k|    }
 4262|       |
 4263|    338|    if (end_of_known) {
  ------------------
  |  Branch (4263:9): [True: 338, False: 0]
  ------------------
 4264|    338|        *end_of_known = *out_len;
 4265|    338|    }
 4266|       |
 4267|       |    /*
 4268|       |     * Subtree not found.  
 4269|       |     */
 4270|       |
 4271|    338|    if (orgtree && in_dices && objidlen > 0) {
  ------------------
  |  Branch (4271:9): [True: 0, False: 338]
  |  Branch (4271:20): [True: 0, False: 0]
  |  Branch (4271:32): [True: 0, False: 0]
  ------------------
 4272|      0|	sprintf(intbuf, "%" NETSNMP_PRIo "u.", *objid);
 4273|      0|	if (!*buf_overflow
  ------------------
  |  Branch (4273:6): [True: 0, False: 0]
  ------------------
 4274|      0|	    && !snmp_cstrcat(buf, buf_len, out_len, allow_realloc, intbuf)) {
  ------------------
  |  Branch (4274:9): [True: 0, False: 0]
  ------------------
 4275|      0|	    *buf_overflow = 1;
 4276|      0|	}
 4277|      0|	objid++;
 4278|      0|	objidlen--;
 4279|      0|    }
 4280|       |
 4281|    338|    while (in_dices && (objidlen > 0) &&
  ------------------
  |  Branch (4281:12): [True: 0, False: 338]
  |  Branch (4281:24): [True: 0, False: 0]
  ------------------
 4282|    338|           (NETSNMP_OID_OUTPUT_NUMERIC != output_format) &&
  ------------------
  |  |  514|      0|#define NETSNMP_OID_OUTPUT_NUMERIC 4
  ------------------
  |  Branch (4282:12): [True: 0, False: 0]
  ------------------
 4283|    338|           !netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DONT_BREAKDOWN_OIDS)) {
  ------------------
  |  |   48|      0|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                         !netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DONT_BREAKDOWN_OIDS)) {
  ------------------
  |  |   70|      0|#define NETSNMP_DS_LIB_DONT_BREAKDOWN_OIDS 10   /* dont print oid indexes specially */
  ------------------
  |  Branch (4283:12): [True: 0, False: 0]
  ------------------
 4284|      0|        size_t          numids;
 4285|      0|        struct tree    *tp;
 4286|       |
 4287|      0|        tp = find_tree_node(in_dices->ilabel, -1);
 4288|       |
 4289|      0|        if (!tp) {
  ------------------
  |  Branch (4289:13): [True: 0, False: 0]
  ------------------
 4290|       |            /*
 4291|       |             * Can't find an index in the mib tree.  Bail.  
 4292|       |             */
 4293|      0|            goto finish_it;
 4294|      0|        }
 4295|       |
 4296|      0|        if (extended_index) {
  ------------------
  |  Branch (4296:13): [True: 0, False: 0]
  ------------------
 4297|      0|            if (*buf != NULL && *(*buf + *out_len - 1) == '.') {
  ------------------
  |  Branch (4297:17): [True: 0, False: 0]
  |  Branch (4297:33): [True: 0, False: 0]
  ------------------
 4298|      0|                (*out_len)--;
 4299|      0|            }
 4300|      0|            if (!*buf_overflow &&
  ------------------
  |  Branch (4300:17): [True: 0, False: 0]
  ------------------
 4301|      0|                !snmp_cstrcat(buf, buf_len, out_len, allow_realloc, "[")) {
  ------------------
  |  Branch (4301:17): [True: 0, False: 0]
  ------------------
 4302|      0|                *buf_overflow = 1;
 4303|      0|            }
 4304|      0|        }
 4305|       |
 4306|      0|        switch (tp->type) {
 4307|      0|        case TYPE_OCTETSTR:
  ------------------
  |  |  155|      0|#define TYPE_OCTETSTR       2
  ------------------
  |  Branch (4307:9): [True: 0, False: 0]
  ------------------
 4308|      0|            if (extended_index && tp->hint) {
  ------------------
  |  Branch (4308:17): [True: 0, False: 0]
  |  Branch (4308:35): [True: 0, False: 0]
  ------------------
 4309|      0|                if (in_dices->isimplied) {
  ------------------
  |  Branch (4309:21): [True: 0, False: 0]
  ------------------
 4310|      0|                    numids = objidlen;
 4311|      0|                    if (numids > objidlen)
  ------------------
  |  Branch (4311:25): [True: 0, False: 0]
  ------------------
 4312|      0|                        goto finish_it;
 4313|      0|                } else if (tp->ranges && !tp->ranges->next
  ------------------
  |  Branch (4313:28): [True: 0, False: 0]
  |  Branch (4313:42): [True: 0, False: 0]
  ------------------
 4314|      0|                           && tp->ranges->low == tp->ranges->high) {
  ------------------
  |  Branch (4314:31): [True: 0, False: 0]
  ------------------
 4315|      0|                    numids = tp->ranges->low;
 4316|      0|                    if (numids > objidlen)
  ------------------
  |  Branch (4316:25): [True: 0, False: 0]
  ------------------
 4317|      0|                        goto finish_it;
 4318|      0|                } else {
 4319|      0|                    numids = *objid;
 4320|      0|                    if (numids >= objidlen)
  ------------------
  |  Branch (4320:25): [True: 0, False: 0]
  ------------------
 4321|      0|                        goto finish_it;
 4322|      0|                    objid++;
 4323|      0|                    objidlen--;
 4324|      0|                }
 4325|      0|                if (numids > objidlen)
  ------------------
  |  Branch (4325:21): [True: 0, False: 0]
  ------------------
 4326|      0|                    goto finish_it;
 4327|      0|		_get_realloc_symbol_octet_string(numids, objid, buf, buf_len,
 4328|      0|						 out_len, allow_realloc,
 4329|      0|						 buf_overflow, tp);
 4330|      0|            } else if (in_dices->isimplied) {
  ------------------
  |  Branch (4330:24): [True: 0, False: 0]
  ------------------
 4331|      0|                numids = objidlen;
 4332|      0|                if (numids > objidlen)
  ------------------
  |  Branch (4332:21): [True: 0, False: 0]
  ------------------
 4333|      0|                    goto finish_it;
 4334|       |
 4335|      0|                if (!*buf_overflow) {
  ------------------
  |  Branch (4335:21): [True: 0, False: 0]
  ------------------
 4336|      0|                    if (!dump_realloc_oid_to_string
  ------------------
  |  Branch (4336:25): [True: 0, False: 0]
  ------------------
 4337|      0|                        (objid, numids, buf, buf_len, out_len,
 4338|      0|                         allow_realloc, '\'')) {
 4339|      0|                        *buf_overflow = 1;
 4340|      0|                    }
 4341|      0|                }
 4342|      0|            } else if (tp->ranges && !tp->ranges->next
  ------------------
  |  Branch (4342:24): [True: 0, False: 0]
  |  Branch (4342:38): [True: 0, False: 0]
  ------------------
 4343|      0|                       && tp->ranges->low == tp->ranges->high) {
  ------------------
  |  Branch (4343:27): [True: 0, False: 0]
  ------------------
 4344|       |                /*
 4345|       |                 * a fixed-length octet string 
 4346|       |                 */
 4347|      0|                numids = tp->ranges->low;
 4348|      0|                if (numids > objidlen)
  ------------------
  |  Branch (4348:21): [True: 0, False: 0]
  ------------------
 4349|      0|                    goto finish_it;
 4350|       |
 4351|      0|                if (!*buf_overflow) {
  ------------------
  |  Branch (4351:21): [True: 0, False: 0]
  ------------------
 4352|      0|                    if (!dump_realloc_oid_to_string
  ------------------
  |  Branch (4352:25): [True: 0, False: 0]
  ------------------
 4353|      0|                        (objid, numids, buf, buf_len, out_len,
 4354|      0|                         allow_realloc, '\'')) {
 4355|      0|                        *buf_overflow = 1;
 4356|      0|                    }
 4357|      0|                }
 4358|      0|            } else {
 4359|      0|                numids = (size_t) * objid + 1;
 4360|      0|                if (numids > objidlen)
  ------------------
  |  Branch (4360:21): [True: 0, False: 0]
  ------------------
 4361|      0|                    goto finish_it;
 4362|      0|                if (numids == 1) {
  ------------------
  |  Branch (4362:21): [True: 0, False: 0]
  ------------------
 4363|      0|                    if (netsnmp_ds_get_boolean
  ------------------
  |  Branch (4363:25): [True: 0, False: 0]
  ------------------
 4364|      0|                        (NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_ESCAPE_QUOTES)) {
  ------------------
  |  |   48|      0|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                      (NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_ESCAPE_QUOTES)) {
  ------------------
  |  |   79|      0|#define NETSNMP_DS_LIB_ESCAPE_QUOTES       19   /* shell escape quote marks in oids */
  ------------------
 4365|      0|                        if (!*buf_overflow &&
  ------------------
  |  Branch (4365:29): [True: 0, False: 0]
  ------------------
 4366|      0|                            !snmp_cstrcat(buf, buf_len, out_len, allow_realloc,
  ------------------
  |  Branch (4366:29): [True: 0, False: 0]
  ------------------
 4367|      0|                                          "\\")) {
 4368|      0|                            *buf_overflow = 1;
 4369|      0|                        }
 4370|      0|                    }
 4371|      0|                    if (!*buf_overflow &&
  ------------------
  |  Branch (4371:25): [True: 0, False: 0]
  ------------------
 4372|      0|                        !snmp_cstrcat(buf, buf_len, out_len, allow_realloc,
  ------------------
  |  Branch (4372:25): [True: 0, False: 0]
  ------------------
 4373|      0|                                      "\"")) {
 4374|      0|                        *buf_overflow = 1;
 4375|      0|                    }
 4376|      0|                    if (netsnmp_ds_get_boolean
  ------------------
  |  Branch (4376:25): [True: 0, False: 0]
  ------------------
 4377|      0|                        (NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_ESCAPE_QUOTES)) {
  ------------------
  |  |   48|      0|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                      (NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_ESCAPE_QUOTES)) {
  ------------------
  |  |   79|      0|#define NETSNMP_DS_LIB_ESCAPE_QUOTES       19   /* shell escape quote marks in oids */
  ------------------
 4378|      0|                        if (!*buf_overflow &&
  ------------------
  |  Branch (4378:29): [True: 0, False: 0]
  ------------------
 4379|      0|                            !snmp_cstrcat(buf, buf_len, out_len, allow_realloc,
  ------------------
  |  Branch (4379:29): [True: 0, False: 0]
  ------------------
 4380|      0|                                          "\\")) {
 4381|      0|                            *buf_overflow = 1;
 4382|      0|                        }
 4383|      0|                    }
 4384|      0|                    if (!*buf_overflow &&
  ------------------
  |  Branch (4384:25): [True: 0, False: 0]
  ------------------
 4385|      0|                        !snmp_cstrcat(buf, buf_len, out_len, allow_realloc,
  ------------------
  |  Branch (4385:25): [True: 0, False: 0]
  ------------------
 4386|      0|                                      "\"")) {
 4387|      0|                        *buf_overflow = 1;
 4388|      0|                    }
 4389|      0|                } else {
 4390|      0|                    if (!*buf_overflow) {
  ------------------
  |  Branch (4390:25): [True: 0, False: 0]
  ------------------
 4391|      0|                        struct tree * next_peer;
 4392|      0|                        int normal_handling = 1;
 4393|       |
 4394|      0|                        if (tp->next_peer) {
  ------------------
  |  Branch (4394:29): [True: 0, False: 0]
  ------------------
 4395|      0|                            next_peer = tp->next_peer;
 4396|      0|                        }
 4397|       |
 4398|       |                        /* Try handling the InetAddress in the OID, in case of failure,
 4399|       |                         * use the normal_handling. 
 4400|       |                         */
 4401|      0|                        if (tp->next_peer &&
  ------------------
  |  Branch (4401:29): [True: 0, False: 0]
  ------------------
 4402|      0|                            tp->tc_index != -1 &&
  ------------------
  |  Branch (4402:29): [True: 0, False: 0]
  ------------------
 4403|      0|                            next_peer->tc_index != -1 &&
  ------------------
  |  Branch (4403:29): [True: 0, False: 0]
  ------------------
 4404|      0|                            strcmp(get_tc_descriptor(tp->tc_index), "InetAddress") == 0 &&
  ------------------
  |  Branch (4404:29): [True: 0, False: 0]
  ------------------
 4405|      0|                            strcmp(get_tc_descriptor(next_peer->tc_index), 
  ------------------
  |  Branch (4405:29): [True: 0, False: 0]
  ------------------
 4406|      0|                                    "InetAddressType") == 0 ) {
 4407|       |
 4408|      0|                            int ret;
 4409|      0|                            int addr_type = *(objid - 1);
 4410|       |
 4411|      0|                            ret = dump_realloc_oid_to_inetaddress(addr_type, 
 4412|      0|                                        objid + 1, numids - 1, buf, buf_len, out_len,
 4413|      0|                                        allow_realloc, '"');
 4414|      0|                            if (ret != 2) {
  ------------------
  |  Branch (4414:33): [True: 0, False: 0]
  ------------------
 4415|      0|                                normal_handling = 0;
 4416|      0|                                if (ret == 0) {
  ------------------
  |  Branch (4416:37): [True: 0, False: 0]
  ------------------
 4417|      0|                                    *buf_overflow = 1;
 4418|      0|                                }
 4419|       |
 4420|      0|                            }
 4421|      0|                        } 
 4422|      0|                        if (normal_handling && !dump_realloc_oid_to_string
  ------------------
  |  Branch (4422:29): [True: 0, False: 0]
  |  Branch (4422:48): [True: 0, False: 0]
  ------------------
 4423|      0|                            (objid + 1, numids - 1, buf, buf_len, out_len,
 4424|      0|                             allow_realloc, '"')) {
 4425|      0|                            *buf_overflow = 1;
 4426|      0|                        }
 4427|      0|                    }
 4428|      0|                }
 4429|      0|            }
 4430|      0|            objid += numids;
 4431|      0|            objidlen -= numids;
 4432|      0|            break;
 4433|       |
 4434|      0|        case TYPE_INTEGER32:
  ------------------
  |  |  169|      0|#define TYPE_INTEGER32      16
  ------------------
  |  Branch (4434:9): [True: 0, False: 0]
  ------------------
 4435|      0|        case TYPE_UINTEGER:
  ------------------
  |  |  167|      0|#define TYPE_UINTEGER       14
  ------------------
  |  Branch (4435:9): [True: 0, False: 0]
  ------------------
 4436|      0|        case TYPE_UNSIGNED32:
  ------------------
  |  |  168|      0|#define TYPE_UNSIGNED32     15
  ------------------
  |  Branch (4436:9): [True: 0, False: 0]
  ------------------
 4437|      0|        case TYPE_GAUGE:
  ------------------
  |  |  160|      0|#define TYPE_GAUGE          7
  ------------------
  |  Branch (4437:9): [True: 0, False: 0]
  ------------------
 4438|      0|        case TYPE_INTEGER:
  ------------------
  |  |  156|      0|#define TYPE_INTEGER        3
  ------------------
  |  Branch (4438:9): [True: 0, False: 0]
  ------------------
 4439|      0|            if (tp->enums) {
  ------------------
  |  Branch (4439:17): [True: 0, False: 0]
  ------------------
 4440|      0|                struct enum_list *ep = tp->enums;
 4441|      0|                while (ep && ep->value != (int) (*objid)) {
  ------------------
  |  Branch (4441:24): [True: 0, False: 0]
  |  Branch (4441:30): [True: 0, False: 0]
  ------------------
 4442|      0|                    ep = ep->next;
 4443|      0|                }
 4444|      0|                if (ep) {
  ------------------
  |  Branch (4444:21): [True: 0, False: 0]
  ------------------
 4445|      0|                    if (!*buf_overflow &&
  ------------------
  |  Branch (4445:25): [True: 0, False: 0]
  ------------------
 4446|      0|                        !snmp_cstrcat(buf, buf_len, out_len, allow_realloc,
  ------------------
  |  Branch (4446:25): [True: 0, False: 0]
  ------------------
 4447|      0|                                      ep->label)) {
 4448|      0|                        *buf_overflow = 1;
 4449|      0|                    }
 4450|      0|                } else {
 4451|      0|                    sprintf(intbuf, "%" NETSNMP_PRIo "u", *objid);
 4452|      0|                    if (!*buf_overflow &&
  ------------------
  |  Branch (4452:25): [True: 0, False: 0]
  ------------------
 4453|      0|                        !snmp_cstrcat(buf, buf_len, out_len, allow_realloc,
  ------------------
  |  Branch (4453:25): [True: 0, False: 0]
  ------------------
 4454|      0|                                      intbuf)) {
 4455|      0|                        *buf_overflow = 1;
 4456|      0|                    }
 4457|      0|                }
 4458|      0|            } else {
 4459|      0|                sprintf(intbuf, "%" NETSNMP_PRIo "u", *objid);
 4460|      0|                if (!*buf_overflow &&
  ------------------
  |  Branch (4460:21): [True: 0, False: 0]
  ------------------
 4461|      0|                    !snmp_cstrcat(buf, buf_len, out_len, allow_realloc,
  ------------------
  |  Branch (4461:21): [True: 0, False: 0]
  ------------------
 4462|      0|                                  intbuf)) {
 4463|      0|                    *buf_overflow = 1;
 4464|      0|                }
 4465|      0|            }
 4466|      0|            objid++;
 4467|      0|            objidlen--;
 4468|      0|            break;
 4469|       |
 4470|      0|        case TYPE_TIMETICKS:
  ------------------
  |  |  161|      0|#define TYPE_TIMETICKS      8
  ------------------
  |  Branch (4470:9): [True: 0, False: 0]
  ------------------
 4471|       |            /* In an index, this is probably a timefilter */
 4472|      0|            if (extended_index) {
  ------------------
  |  Branch (4472:17): [True: 0, False: 0]
  ------------------
 4473|      0|                uptimeString( *objid, intbuf, sizeof( intbuf ) );
 4474|      0|            } else {
 4475|      0|                sprintf(intbuf, "%" NETSNMP_PRIo "u", *objid);
 4476|      0|            }   
 4477|      0|            if (!*buf_overflow &&
  ------------------
  |  Branch (4477:17): [True: 0, False: 0]
  ------------------
 4478|      0|                !snmp_cstrcat(buf, buf_len, out_len, allow_realloc, intbuf)) {
  ------------------
  |  Branch (4478:17): [True: 0, False: 0]
  ------------------
 4479|      0|                *buf_overflow = 1;
 4480|      0|            }
 4481|      0|            objid++;
 4482|      0|            objidlen--;
 4483|      0|            break;
 4484|       |
 4485|      0|        case TYPE_OBJID:
  ------------------
  |  |  154|      0|#define TYPE_OBJID          1
  ------------------
  |  Branch (4485:9): [True: 0, False: 0]
  ------------------
 4486|      0|            if (in_dices->isimplied) {
  ------------------
  |  Branch (4486:17): [True: 0, False: 0]
  ------------------
 4487|      0|                numids = objidlen;
 4488|      0|            } else {
 4489|      0|                numids = (size_t) * objid + 1;
 4490|      0|            }
 4491|      0|            if (numids > objidlen)
  ------------------
  |  Branch (4491:17): [True: 0, False: 0]
  ------------------
 4492|      0|                goto finish_it;
 4493|      0|            if (extended_index) {
  ------------------
  |  Branch (4493:17): [True: 0, False: 0]
  ------------------
 4494|      0|                if (in_dices->isimplied) {
  ------------------
  |  Branch (4494:21): [True: 0, False: 0]
  ------------------
 4495|      0|                    if (!*buf_overflow
  ------------------
  |  Branch (4495:25): [True: 0, False: 0]
  ------------------
 4496|      0|                        && !netsnmp_sprint_realloc_objid_tree(buf, buf_len,
  ------------------
  |  Branch (4496:28): [True: 0, False: 0]
  ------------------
 4497|      0|                                                              out_len,
 4498|      0|                                                              allow_realloc,
 4499|      0|                                                              buf_overflow,
 4500|      0|                                                              objid,
 4501|      0|                                                              numids)) {
 4502|      0|                        *buf_overflow = 1;
 4503|      0|                    }
 4504|      0|                } else {
 4505|      0|                    if (!*buf_overflow
  ------------------
  |  Branch (4505:25): [True: 0, False: 0]
  ------------------
 4506|      0|                        && !netsnmp_sprint_realloc_objid_tree(buf, buf_len,
  ------------------
  |  Branch (4506:28): [True: 0, False: 0]
  ------------------
 4507|      0|                                                              out_len,
 4508|      0|                                                              allow_realloc,
 4509|      0|                                                              buf_overflow,
 4510|      0|                                                              objid + 1,
 4511|      0|                                                              numids -
 4512|      0|                                                              1)) {
 4513|      0|                        *buf_overflow = 1;
 4514|      0|                    }
 4515|      0|                }
 4516|      0|            } else {
 4517|      0|                _get_realloc_symbol(objid, numids, NULL, buf, buf_len,
 4518|      0|                                    out_len, allow_realloc, buf_overflow,
 4519|      0|                                    NULL, NULL);
 4520|      0|            }
 4521|      0|            objid += (numids);
 4522|      0|            objidlen -= (numids);
 4523|      0|            break;
 4524|       |
 4525|      0|        case TYPE_IPADDR:
  ------------------
  |  |  158|      0|#define TYPE_IPADDR         5
  ------------------
  |  Branch (4525:9): [True: 0, False: 0]
  ------------------
 4526|      0|            if (objidlen < 4)
  ------------------
  |  Branch (4526:17): [True: 0, False: 0]
  ------------------
 4527|      0|                goto finish_it;
 4528|      0|            sprintf(intbuf, "%" NETSNMP_PRIo "u.%" NETSNMP_PRIo "u."
 4529|      0|                    "%" NETSNMP_PRIo "u.%" NETSNMP_PRIo "u",
 4530|      0|                    objid[0], objid[1], objid[2], objid[3]);
 4531|      0|            objid += 4;
 4532|      0|            objidlen -= 4;
 4533|      0|            if (!*buf_overflow &&
  ------------------
  |  Branch (4533:17): [True: 0, False: 0]
  ------------------
 4534|      0|                !snmp_cstrcat(buf, buf_len, out_len, allow_realloc, intbuf)) {
  ------------------
  |  Branch (4534:17): [True: 0, False: 0]
  ------------------
 4535|      0|                *buf_overflow = 1;
 4536|      0|            }
 4537|      0|            break;
 4538|       |
 4539|      0|        case TYPE_NETADDR:{
  ------------------
  |  |  157|      0|#define TYPE_NETADDR        4
  ------------------
  |  Branch (4539:9): [True: 0, False: 0]
  ------------------
 4540|      0|                oid             ntype = *objid++;
 4541|       |
 4542|      0|                objidlen--;
 4543|      0|                sprintf(intbuf, "%" NETSNMP_PRIo "u.", ntype);
 4544|      0|                if (!*buf_overflow &&
  ------------------
  |  Branch (4544:21): [True: 0, False: 0]
  ------------------
 4545|      0|                    !snmp_cstrcat(buf, buf_len, out_len, allow_realloc,
  ------------------
  |  Branch (4545:21): [True: 0, False: 0]
  ------------------
 4546|      0|                                  intbuf)) {
 4547|      0|                    *buf_overflow = 1;
 4548|      0|                }
 4549|       |
 4550|      0|                if (ntype == 1 && objidlen >= 4) {
  ------------------
  |  Branch (4550:21): [True: 0, False: 0]
  |  Branch (4550:35): [True: 0, False: 0]
  ------------------
 4551|      0|                    sprintf(intbuf, "%" NETSNMP_PRIo "u.%" NETSNMP_PRIo "u."
 4552|      0|                            "%" NETSNMP_PRIo "u.%" NETSNMP_PRIo "u",
 4553|      0|                            objid[0], objid[1], objid[2], objid[3]);
 4554|      0|                    if (!*buf_overflow &&
  ------------------
  |  Branch (4554:25): [True: 0, False: 0]
  ------------------
 4555|      0|                        !snmp_cstrcat(buf, buf_len, out_len, allow_realloc,
  ------------------
  |  Branch (4555:25): [True: 0, False: 0]
  ------------------
 4556|      0|                                      intbuf)) {
 4557|      0|                        *buf_overflow = 1;
 4558|      0|                    }
 4559|      0|                    objid += 4;
 4560|      0|                    objidlen -= 4;
 4561|      0|                } else {
 4562|      0|                    goto finish_it;
 4563|      0|                }
 4564|      0|            }
 4565|      0|            break;
 4566|       |
 4567|      0|        case TYPE_NSAPADDRESS:
  ------------------
  |  |  166|      0|#define TYPE_NSAPADDRESS    13
  ------------------
  |  Branch (4567:9): [True: 0, False: 0]
  ------------------
 4568|      0|        default:
  ------------------
  |  Branch (4568:9): [True: 0, False: 0]
  ------------------
 4569|      0|            goto finish_it;
 4570|      0|            break;
 4571|      0|        }
 4572|       |
 4573|      0|        if (extended_index) {
  ------------------
  |  Branch (4573:13): [True: 0, False: 0]
  ------------------
 4574|      0|            if (!*buf_overflow &&
  ------------------
  |  Branch (4574:17): [True: 0, False: 0]
  ------------------
 4575|      0|                !snmp_cstrcat(buf, buf_len, out_len, allow_realloc, "]")) {
  ------------------
  |  Branch (4575:17): [True: 0, False: 0]
  ------------------
 4576|      0|                *buf_overflow = 1;
 4577|      0|            }
 4578|      0|        } else {
 4579|      0|            if (!*buf_overflow &&
  ------------------
  |  Branch (4579:17): [True: 0, False: 0]
  ------------------
 4580|      0|                !snmp_cstrcat(buf, buf_len, out_len, allow_realloc, ".")) {
  ------------------
  |  Branch (4580:17): [True: 0, False: 0]
  ------------------
 4581|      0|                *buf_overflow = 1;
 4582|      0|            }
 4583|      0|        }
 4584|      0|        in_dices = in_dices->next;
 4585|      0|    }
 4586|       |
 4587|    338|  finish_it:
 4588|    338|    _oid_finish_printing(objid, objidlen,
 4589|    338|                         buf, buf_len, out_len,
 4590|    338|                         allow_realloc, buf_overflow);
 4591|    338|    return NULL;
 4592|    338|}

netsnmp_init_mib_internals:
  699|     51|{
  700|     51|    register struct tok *tp;
  701|     51|    register int    b, i;
  702|     51|    int             max_modc;
  703|       |
  704|     51|    if (tree_head)
  ------------------
  |  Branch (704:9): [True: 50, False: 1]
  ------------------
  705|     50|        return;
  706|       |
  707|       |    /*
  708|       |     * Set up hash list of pre-defined tokens
  709|       |     */
  710|      1|    memset(buckets, 0, sizeof(buckets));
  711|     93|    for (tp = tokens; tp->name; tp++) {
  ------------------
  |  Branch (711:23): [True: 92, False: 1]
  ------------------
  712|     92|        tp->hash = name_hash(tp->name);
  713|     92|        b = BUCKET(tp->hash);
  ------------------
  |  |  526|     92|#define BUCKET(x)       (x & (HASHSIZE-1))
  |  |  ------------------
  |  |  |  |  525|     92|#define HASHSIZE        32
  |  |  ------------------
  ------------------
  714|     92|        if (buckets[b])
  ------------------
  |  Branch (714:13): [True: 60, False: 32]
  ------------------
  715|     60|            tp->next = buckets[b];      /* BUG ??? */
  716|     92|        buckets[b] = tp;
  717|     92|    }
  718|       |
  719|       |    /*
  720|       |     * Initialise other internal structures
  721|       |     */
  722|       |
  723|      1|    max_modc = sizeof(module_map) / sizeof(module_map[0]) - 1;
  724|     22|    for (i = 0; i < max_modc; ++i)
  ------------------
  |  Branch (724:17): [True: 21, False: 1]
  ------------------
  725|     21|        module_map[i].next = &(module_map[i + 1]);
  726|      1|    module_map[max_modc].next = NULL;
  727|      1|    module_map_head = module_map;
  728|       |
  729|      1|    memset(nbuckets, 0, sizeof(nbuckets));
  730|      1|    memset(tbuckets, 0, sizeof(tbuckets));
  731|      1|    tc_alloc = TC_INCR;
  ------------------
  |  |  134|      1|#define TC_INCR 100
  ------------------
  732|      1|    tclist = calloc(tc_alloc, sizeof(struct tc));
  733|      1|    build_translation_table();
  734|      1|    init_tree_roots();          /* Set up initial roots */
  735|       |    /*
  736|       |     * Relies on 'add_mibdir' having set up the modules 
  737|       |     */
  738|      1|}
which_module:
 3776|      3|{
 3777|      3|    struct module  *mp;
 3778|       |
 3779|      3|    for (mp = module_head; mp; mp = mp->next)
  ------------------
  |  Branch (3779:28): [True: 0, False: 3]
  ------------------
 3780|      0|        if (!label_compare(mp->name, name))
  ------------------
  |  | 1234|      0|#define	label_compare	strcmp
  ------------------
  |  Branch (3780:13): [True: 0, False: 0]
  ------------------
 3781|      0|            return (mp->modid);
 3782|       |
 3783|      3|    DEBUGMSGTL(("parse-mibs", "Module %s not found\n", name));
  ------------------
  |  |   68|      3|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      3|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 3]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
 3784|      3|    return (-1);
 3785|      3|}
module_name:
 3792|    682|{
 3793|    682|    struct module  *mp;
 3794|       |
 3795|    682|    for (mp = module_head; mp; mp = mp->next)
  ------------------
  |  Branch (3795:28): [True: 0, False: 682]
  ------------------
 3796|      0|        if (mp->modid == modid) {
  ------------------
  |  Branch (3796:13): [True: 0, False: 0]
  ------------------
 3797|      0|            strcpy(cp, mp->name);
 3798|      0|            return (cp);
 3799|      0|        }
 3800|       |
 3801|    682|    if (modid != -1) DEBUGMSGTL(("parse-mibs", "Module %d not found\n", modid));
  ------------------
  |  |   68|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
  |  Branch (3801:9): [True: 0, False: 682]
  ------------------
 3802|    682|    sprintf(cp, "#%d", modid);
 3803|    682|    return (cp);
 3804|    682|}
adopt_orphans:
 3970|      1|{
 3971|      1|    struct node    *np, *onp;
 3972|      1|    struct tree    *tp;
 3973|      1|    int             i, adopted = 1;
 3974|       |
 3975|      1|    if (!orphan_nodes)
  ------------------
  |  Branch (3975:9): [True: 1, False: 0]
  ------------------
 3976|      1|        return;
 3977|      0|    init_node_hash(orphan_nodes);
 3978|      0|    orphan_nodes = NULL;
 3979|       |
 3980|      0|    while (adopted) {
  ------------------
  |  Branch (3980:12): [True: 0, False: 0]
  ------------------
 3981|      0|        adopted = 0;
 3982|      0|        for (i = 0; i < NHASHSIZE; i++)
  ------------------
  |  |  528|      0|#define NHASHSIZE    128
  ------------------
  |  Branch (3982:21): [True: 0, False: 0]
  ------------------
 3983|      0|            if (nbuckets[i]) {
  ------------------
  |  Branch (3983:17): [True: 0, False: 0]
  ------------------
 3984|      0|                for (np = nbuckets[i]; np != NULL; np = np->next) {
  ------------------
  |  Branch (3984:40): [True: 0, False: 0]
  ------------------
 3985|      0|                    tp = find_tree_node(np->parent, -1);
 3986|      0|		    if (tp) {
  ------------------
  |  Branch (3986:11): [True: 0, False: 0]
  ------------------
 3987|      0|			do_subtree(tp, &np);
 3988|      0|			adopted = 1;
 3989|       |                        /*
 3990|       |                         * if do_subtree adopted the entire bucket, stop
 3991|       |                         */
 3992|      0|                        if(NULL == nbuckets[i])
  ------------------
  |  Branch (3992:28): [True: 0, False: 0]
  ------------------
 3993|      0|                            break;
 3994|       |
 3995|       |                        /*
 3996|       |                         * do_subtree may modify nbuckets, and if np
 3997|       |                         * was adopted, np->next probably isn't an orphan
 3998|       |                         * anymore. if np is still in the bucket (do_subtree
 3999|       |                         * didn't adopt it) keep on plugging. otherwise
 4000|       |                         * start over, at the top of the bucket.
 4001|       |                         */
 4002|      0|                        for(onp = nbuckets[i]; onp; onp = onp->next)
  ------------------
  |  Branch (4002:48): [True: 0, False: 0]
  ------------------
 4003|      0|                            if(onp == np)
  ------------------
  |  Branch (4003:32): [True: 0, False: 0]
  ------------------
 4004|      0|                                break;
 4005|      0|                        if(NULL == onp) { /* not in the list */
  ------------------
  |  Branch (4005:28): [True: 0, False: 0]
  ------------------
 4006|      0|                            np = nbuckets[i]; /* start over */
 4007|      0|                        }
 4008|      0|		    }
 4009|      0|		}
 4010|      0|            }
 4011|      0|    }
 4012|       |
 4013|       |    /*
 4014|       |     * Report on outstanding orphans
 4015|       |     *    and link them back into the orphan list
 4016|       |     */
 4017|      0|    for (i = 0; i < NHASHSIZE; i++)
  ------------------
  |  |  528|      0|#define NHASHSIZE    128
  ------------------
  |  Branch (4017:17): [True: 0, False: 0]
  ------------------
 4018|      0|        if (nbuckets[i]) {
  ------------------
  |  Branch (4018:13): [True: 0, False: 0]
  ------------------
 4019|      0|            if (orphan_nodes)
  ------------------
  |  Branch (4019:17): [True: 0, False: 0]
  ------------------
 4020|      0|                onp = np->next = nbuckets[i];
 4021|      0|            else
 4022|      0|                onp = orphan_nodes = nbuckets[i];
 4023|      0|            nbuckets[i] = NULL;
 4024|      0|            while (onp) {
  ------------------
  |  Branch (4024:20): [True: 0, False: 0]
  ------------------
 4025|      0|                char            modbuf[256];
 4026|      0|                snmp_log(LOG_WARNING,
 4027|      0|                         "Cannot adopt OID in %s: %s ::= { %s %ld }\n",
 4028|      0|                         module_name(onp->modid, modbuf),
 4029|      0|                         (onp->label ? onp->label : "<no label>"),
  ------------------
  |  Branch (4029:27): [True: 0, False: 0]
  ------------------
 4030|      0|                         (onp->parent ? onp->parent : "<no parent>"),
  ------------------
  |  Branch (4030:27): [True: 0, False: 0]
  ------------------
 4031|      0|                         onp->subid);
 4032|       |
 4033|      0|                np = onp;
 4034|      0|                onp = onp->next;
 4035|      0|            }
 4036|      0|        }
 4037|      0|}
netsnmp_read_module:
 4049|     48|{
 4050|     48|    int status = 0;
 4051|     48|    status = read_module_internal(name);
 4052|       |
 4053|     48|    if (status == MODULE_NOT_FOUND) {
  ------------------
  |  |  512|     48|#define MODULE_NOT_FOUND	0
  ------------------
  |  Branch (4053:9): [True: 48, False: 0]
  ------------------
 4054|     48|        if (!read_module_replacements(name))
  ------------------
  |  Branch (4054:13): [True: 48, False: 0]
  ------------------
 4055|     48|            print_module_not_found(name);
 4056|     48|    } else if (status == MODULE_SYNTAX_ERROR) {
  ------------------
  |  |  519|      0|#define MODULE_SYNTAX_ERROR     4
  ------------------
  |  Branch (4056:16): [True: 0, False: 0]
  ------------------
 4057|      0|        gMibError = 0;
 4058|      0|        gLoop = 1;
 4059|       |
 4060|      0|        strncat(gMibNames, " ", sizeof(gMibNames) - strlen(gMibNames) - 1);
 4061|      0|        strncat(gMibNames, name, sizeof(gMibNames) - strlen(gMibNames) - 1);
 4062|      0|    }
 4063|       |
 4064|     48|    return tree_head;
 4065|     48|}
add_mibdir:
 5024|      2|{
 5025|      2|    const char     *oldFile = File;
 5026|      2|    char          **filenames;
 5027|      2|    int             count = 0;
 5028|      2|    int             filename_count, i;
 5029|       |
 5030|      2|    DEBUGMSGTL(("parse-mibs", "Scanning directory %s\n", dirname));
  ------------------
  |  |   68|      2|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      2|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 2, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      2|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      2|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      2|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      2|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
 5031|       |
 5032|      2|    filename_count = scan_directory(&filenames, dirname);
 5033|       |
 5034|      2|    if (filename_count >= 0) {
  ------------------
  |  Branch (5034:9): [True: 0, False: 2]
  ------------------
 5035|      0|        for (i = 0; i < filename_count; i++) {
  ------------------
  |  Branch (5035:21): [True: 0, False: 0]
  ------------------
 5036|      0|            if (add_mibfile(filenames[i], strrchr(filenames[i], '/')) == 0)
  ------------------
  |  Branch (5036:17): [True: 0, False: 0]
  ------------------
 5037|      0|                count++;
 5038|      0|	    free(filenames[i]);
 5039|      0|        }
 5040|      0|        File = oldFile;
 5041|      0|        free(filenames);
 5042|      0|        return (count);
 5043|      0|    }
 5044|      2|    else
 5045|      2|        DEBUGMSGTL(("parse-mibs","cannot open MIB directory %s\n", dirname));
  ------------------
  |  |   68|      2|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      2|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 2, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      2|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      2|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      2|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      2|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
 5046|       |
 5047|      2|    return (-1);
 5048|      2|}
parse.c:name_hash:
  686|     95|{
  687|     95|    int             hash = 0;
  688|     95|    const char     *cp;
  689|       |
  690|     95|    if (!name)
  ------------------
  |  Branch (690:9): [True: 0, False: 95]
  ------------------
  691|      0|        return 0;
  692|  1.00k|    for (cp = name; *cp; cp++)
  ------------------
  |  Branch (692:21): [True: 907, False: 95]
  ------------------
  693|    907|        hash += tolower((unsigned char)(*cp));
  694|     95|    return (hash);
  695|     95|}
parse.c:build_translation_table:
 1069|      1|{
 1070|      1|    int             count;
 1071|       |
 1072|    257|    for (count = 0; count < 256; count++) {
  ------------------
  |  Branch (1072:21): [True: 256, False: 1]
  ------------------
 1073|    256|        switch (count) {
 1074|      1|        case OBJID:
  ------------------
  |  |  166|      1|#define OBJID       (4 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  156|      1|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1074:9): [True: 1, False: 255]
  ------------------
 1075|      1|            translation_table[count] = TYPE_OBJID;
  ------------------
  |  |  154|      1|#define TYPE_OBJID          1
  ------------------
 1076|      1|            break;
 1077|      1|        case OCTETSTR:
  ------------------
  |  |  167|      1|#define OCTETSTR    (5 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  156|      1|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1077:9): [True: 1, False: 255]
  ------------------
 1078|      1|            translation_table[count] = TYPE_OCTETSTR;
  ------------------
  |  |  155|      1|#define TYPE_OCTETSTR       2
  ------------------
 1079|      1|            break;
 1080|      1|        case INTEGER:
  ------------------
  |  |  168|      1|#define INTEGER     (6 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  156|      1|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1080:9): [True: 1, False: 255]
  ------------------
 1081|      1|            translation_table[count] = TYPE_INTEGER;
  ------------------
  |  |  156|      1|#define TYPE_INTEGER        3
  ------------------
 1082|      1|            break;
 1083|      1|        case NETADDR:
  ------------------
  |  |  169|      1|#define NETADDR     (7 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  156|      1|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1083:9): [True: 1, False: 255]
  ------------------
 1084|      1|            translation_table[count] = TYPE_NETADDR;
  ------------------
  |  |  157|      1|#define TYPE_NETADDR        4
  ------------------
 1085|      1|            break;
 1086|      1|        case IPADDR:
  ------------------
  |  |  170|      1|#define IPADDR      (8 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  156|      1|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1086:9): [True: 1, False: 255]
  ------------------
 1087|      1|            translation_table[count] = TYPE_IPADDR;
  ------------------
  |  |  158|      1|#define TYPE_IPADDR         5
  ------------------
 1088|      1|            break;
 1089|      1|        case COUNTER:
  ------------------
  |  |  171|      1|#define COUNTER     (9 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  156|      1|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1089:9): [True: 1, False: 255]
  ------------------
 1090|      1|            translation_table[count] = TYPE_COUNTER;
  ------------------
  |  |  159|      1|#define TYPE_COUNTER        6
  ------------------
 1091|      1|            break;
 1092|      1|        case GAUGE:
  ------------------
  |  |  172|      1|#define GAUGE       (10 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  156|      1|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1092:9): [True: 1, False: 255]
  ------------------
 1093|      1|            translation_table[count] = TYPE_GAUGE;
  ------------------
  |  |  160|      1|#define TYPE_GAUGE          7
  ------------------
 1094|      1|            break;
 1095|      1|        case TIMETICKS:
  ------------------
  |  |  173|      1|#define TIMETICKS   (11 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  156|      1|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1095:9): [True: 1, False: 255]
  ------------------
 1096|      1|            translation_table[count] = TYPE_TIMETICKS;
  ------------------
  |  |  161|      1|#define TYPE_TIMETICKS      8
  ------------------
 1097|      1|            break;
 1098|      1|        case KW_OPAQUE:
  ------------------
  |  |  174|      1|#define KW_OPAQUE   (12 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  156|      1|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1098:9): [True: 1, False: 255]
  ------------------
 1099|      1|            translation_table[count] = TYPE_OPAQUE;
  ------------------
  |  |  162|      1|#define TYPE_OPAQUE         9
  ------------------
 1100|      1|            break;
 1101|      1|        case NUL:
  ------------------
  |  |  175|      1|#define NUL         (13 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  156|      1|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1101:9): [True: 1, False: 255]
  ------------------
 1102|      1|            translation_table[count] = TYPE_NULL;
  ------------------
  |  |  163|      1|#define TYPE_NULL           10
  ------------------
 1103|      1|            break;
 1104|      1|        case COUNTER64:
  ------------------
  |  |  210|      1|#define COUNTER64   (43 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  156|      1|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1104:9): [True: 1, False: 255]
  ------------------
 1105|      1|            translation_table[count] = TYPE_COUNTER64;
  ------------------
  |  |  164|      1|#define TYPE_COUNTER64      11
  ------------------
 1106|      1|            break;
 1107|      1|        case BITSTRING:
  ------------------
  |  |  208|      1|#define BITSTRING   (41 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  156|      1|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1107:9): [True: 1, False: 255]
  ------------------
 1108|      1|            translation_table[count] = TYPE_BITSTRING;
  ------------------
  |  |  165|      1|#define TYPE_BITSTRING      12
  ------------------
 1109|      1|            break;
 1110|      1|        case NSAPADDRESS:
  ------------------
  |  |  209|      1|#define NSAPADDRESS (42 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  156|      1|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1110:9): [True: 1, False: 255]
  ------------------
 1111|      1|            translation_table[count] = TYPE_NSAPADDRESS;
  ------------------
  |  |  166|      1|#define TYPE_NSAPADDRESS    13
  ------------------
 1112|      1|            break;
 1113|      1|        case INTEGER32:
  ------------------
  |  |  273|      1|#define INTEGER32	(105 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  156|      1|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1113:9): [True: 1, False: 255]
  ------------------
 1114|      1|            translation_table[count] = TYPE_INTEGER32;
  ------------------
  |  |  169|      1|#define TYPE_INTEGER32      16
  ------------------
 1115|      1|            break;
 1116|      1|        case UINTEGER32:
  ------------------
  |  |  223|      1|#define UINTEGER32 (56 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  156|      1|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1116:9): [True: 1, False: 255]
  ------------------
 1117|      1|            translation_table[count] = TYPE_UINTEGER;
  ------------------
  |  |  167|      1|#define TYPE_UINTEGER       14
  ------------------
 1118|      1|            break;
 1119|      1|        case UNSIGNED32:
  ------------------
  |  |  272|      1|#define UNSIGNED32	(104 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  156|      1|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1119:9): [True: 1, False: 255]
  ------------------
 1120|      1|            translation_table[count] = TYPE_UNSIGNED32;
  ------------------
  |  |  168|      1|#define TYPE_UNSIGNED32     15
  ------------------
 1121|      1|            break;
 1122|      1|        case TRAPTYPE:
  ------------------
  |  |  228|      1|#define TRAPTYPE    61
  ------------------
  |  Branch (1122:9): [True: 1, False: 255]
  ------------------
 1123|      1|            translation_table[count] = TYPE_TRAPTYPE;
  ------------------
  |  |  173|      1|#define TYPE_TRAPTYPE	    20
  ------------------
 1124|      1|            break;
 1125|      1|        case NOTIFTYPE:
  ------------------
  |  |  212|      1|#define NOTIFTYPE   45
  ------------------
  |  Branch (1125:9): [True: 1, False: 255]
  ------------------
 1126|      1|            translation_table[count] = TYPE_NOTIFTYPE;
  ------------------
  |  |  174|      1|#define TYPE_NOTIFTYPE      21
  ------------------
 1127|      1|            break;
 1128|      1|        case NOTIFGROUP:
  ------------------
  |  |  257|      1|#define NOTIFGROUP  88
  ------------------
  |  Branch (1128:9): [True: 1, False: 255]
  ------------------
 1129|      1|            translation_table[count] = TYPE_NOTIFGROUP;
  ------------------
  |  |  176|      1|#define TYPE_NOTIFGROUP	    23
  ------------------
 1130|      1|            break;
 1131|      1|        case OBJGROUP:
  ------------------
  |  |  211|      1|#define OBJGROUP    44
  ------------------
  |  Branch (1131:9): [True: 1, False: 255]
  ------------------
 1132|      1|            translation_table[count] = TYPE_OBJGROUP;
  ------------------
  |  |  175|      1|#define TYPE_OBJGROUP	    22
  ------------------
 1133|      1|            break;
 1134|      1|        case MODULEIDENTITY:
  ------------------
  |  |  219|      1|#define MODULEIDENTITY 52
  ------------------
  |  Branch (1134:9): [True: 1, False: 255]
  ------------------
 1135|      1|            translation_table[count] = TYPE_MODID;
  ------------------
  |  |  177|      1|#define TYPE_MODID	    24
  ------------------
 1136|      1|            break;
 1137|      1|        case OBJIDENTITY:
  ------------------
  |  |  274|      1|#define OBJIDENTITY	106
  ------------------
  |  Branch (1137:9): [True: 1, False: 255]
  ------------------
 1138|      1|            translation_table[count] = TYPE_OBJIDENTITY;
  ------------------
  |  |  180|      1|#define TYPE_OBJIDENTITY    27
  ------------------
 1139|      1|            break;
 1140|      1|        case AGENTCAP:
  ------------------
  |  |  242|      1|#define AGENTCAP    73
  ------------------
  |  Branch (1140:9): [True: 1, False: 255]
  ------------------
 1141|      1|            translation_table[count] = TYPE_AGENTCAP;
  ------------------
  |  |  178|      1|#define TYPE_AGENTCAP       25
  ------------------
 1142|      1|            break;
 1143|      1|        case COMPLIANCE:
  ------------------
  |  |  214|      1|#define COMPLIANCE  47
  ------------------
  |  Branch (1143:9): [True: 1, False: 255]
  ------------------
 1144|      1|            translation_table[count] = TYPE_MODCOMP;
  ------------------
  |  |  179|      1|#define TYPE_MODCOMP        26
  ------------------
 1145|      1|            break;
 1146|    232|        default:
  ------------------
  |  Branch (1146:9): [True: 232, False: 24]
  ------------------
 1147|    232|            translation_table[count] = TYPE_OTHER;
  ------------------
  |  |  153|    232|#define TYPE_OTHER          0
  ------------------
 1148|    232|            break;
 1149|    256|        }
 1150|    256|    }
 1151|      1|}
parse.c:init_tree_roots:
 1155|      1|{
 1156|      1|    struct tree    *tp, *lasttp;
 1157|      1|    int             base_modid;
 1158|      1|    int             hash;
 1159|       |
 1160|      1|    base_modid = which_module("SNMPv2-SMI");
 1161|      1|    if (base_modid == -1)
  ------------------
  |  Branch (1161:9): [True: 1, False: 0]
  ------------------
 1162|      1|        base_modid = which_module("RFC1155-SMI");
 1163|      1|    if (base_modid == -1)
  ------------------
  |  Branch (1163:9): [True: 1, False: 0]
  ------------------
 1164|      1|        base_modid = which_module("RFC1213-MIB");
 1165|       |
 1166|       |    /*
 1167|       |     * build root node 
 1168|       |     */
 1169|      1|    tp = calloc(1, sizeof(struct tree));
 1170|      1|    if (tp == NULL)
  ------------------
  |  Branch (1170:9): [True: 0, False: 1]
  ------------------
 1171|      0|        return;
 1172|      1|    tp->label = strdup("joint-iso-ccitt");
 1173|      1|    tp->modid = base_modid;
 1174|      1|    tp->number_modules = 1;
 1175|      1|    tp->module_list = &(tp->modid);
 1176|      1|    tp->subid = 2;
 1177|      1|    tp->tc_index = -1;
 1178|      1|    set_function(tp);           /* from mib.c */
 1179|      1|    hash = NBUCKET(name_hash(tp->label));
  ------------------
  |  |  529|      1|#define NBUCKET(x)   (x & (NHASHSIZE-1))
  |  |  ------------------
  |  |  |  |  528|      1|#define NHASHSIZE    128
  |  |  ------------------
  ------------------
 1180|      1|    tp->next = tbuckets[hash];
 1181|      1|    tbuckets[hash] = tp;
 1182|      1|    lasttp = tp;
 1183|      1|    root_imports[0].label = strdup(tp->label);
 1184|      1|    root_imports[0].modid = base_modid;
 1185|       |
 1186|       |    /*
 1187|       |     * build root node 
 1188|       |     */
 1189|      1|    tp = calloc(1, sizeof(struct tree));
 1190|      1|    if (tp == NULL)
  ------------------
  |  Branch (1190:9): [True: 0, False: 1]
  ------------------
 1191|      0|        return;
 1192|      1|    tp->next_peer = lasttp;
 1193|      1|    tp->label = strdup("ccitt");
 1194|      1|    tp->modid = base_modid;
 1195|      1|    tp->number_modules = 1;
 1196|      1|    tp->module_list = &(tp->modid);
 1197|      1|    tp->subid = 0;
 1198|      1|    tp->tc_index = -1;
 1199|      1|    set_function(tp);           /* from mib.c */
 1200|      1|    hash = NBUCKET(name_hash(tp->label));
  ------------------
  |  |  529|      1|#define NBUCKET(x)   (x & (NHASHSIZE-1))
  |  |  ------------------
  |  |  |  |  528|      1|#define NHASHSIZE    128
  |  |  ------------------
  ------------------
 1201|      1|    tp->next = tbuckets[hash];
 1202|      1|    tbuckets[hash] = tp;
 1203|      1|    lasttp = tp;
 1204|      1|    root_imports[1].label = strdup(tp->label);
 1205|      1|    root_imports[1].modid = base_modid;
 1206|       |
 1207|       |    /*
 1208|       |     * build root node 
 1209|       |     */
 1210|      1|    tp = calloc(1, sizeof(struct tree));
 1211|      1|    if (tp == NULL)
  ------------------
  |  Branch (1211:9): [True: 0, False: 1]
  ------------------
 1212|      0|        return;
 1213|      1|    tp->next_peer = lasttp;
 1214|      1|    tp->label = strdup("iso");
 1215|      1|    tp->modid = base_modid;
 1216|      1|    tp->number_modules = 1;
 1217|      1|    tp->module_list = &(tp->modid);
 1218|      1|    tp->subid = 1;
 1219|      1|    tp->tc_index = -1;
 1220|      1|    set_function(tp);           /* from mib.c */
 1221|      1|    hash = NBUCKET(name_hash(tp->label));
  ------------------
  |  |  529|      1|#define NBUCKET(x)   (x & (NHASHSIZE-1))
  |  |  ------------------
  |  |  |  |  528|      1|#define NHASHSIZE    128
  |  |  ------------------
  ------------------
 1222|      1|    tp->next = tbuckets[hash];
 1223|      1|    tbuckets[hash] = tp;
 1224|      1|    lasttp = tp;
 1225|      1|    root_imports[2].label = strdup(tp->label);
 1226|      1|    root_imports[2].modid = base_modid;
 1227|       |
 1228|      1|    tree_head = tp;
 1229|      1|}
parse.c:read_module_internal:
 3909|     48|{
 3910|     48|    struct module  *mp;
 3911|     48|    FILE           *fp;
 3912|     48|    struct node    *np;
 3913|     48|    int             res;
 3914|       |
 3915|     48|    netsnmp_init_mib_internals();
 3916|       |
 3917|     48|    for (mp = module_head; mp; mp = mp->next)
  ------------------
  |  Branch (3917:28): [True: 0, False: 48]
  ------------------
 3918|      0|        if (!label_compare(mp->name, name)) {
  ------------------
  |  | 1234|      0|#define	label_compare	strcmp
  ------------------
  |  Branch (3918:13): [True: 0, False: 0]
  ------------------
 3919|      0|            const char     *oldFile = File;
 3920|      0|            int             oldLine = mibLine;
 3921|      0|            int             oldModule = current_module;
 3922|       |
 3923|      0|            if (mp->no_imports != -1) {
  ------------------
  |  Branch (3923:17): [True: 0, False: 0]
  ------------------
 3924|      0|                DEBUGMSGTL(("parse-mibs", "Module %s already loaded\n",
  ------------------
  |  |   68|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
 3925|      0|                            name));
 3926|      0|                return MODULE_ALREADY_LOADED;
  ------------------
  |  |  514|      0|#define MODULE_ALREADY_LOADED	2
  ------------------
 3927|      0|            }
 3928|      0|            if ((fp = fopen(mp->file, "r")) == NULL) {
  ------------------
  |  Branch (3928:17): [True: 0, False: 0]
  ------------------
 3929|      0|                int rval;
 3930|      0|                if (errno == ENOTDIR || errno == ENOENT)
  ------------------
  |  Branch (3930:21): [True: 0, False: 0]
  |  Branch (3930:41): [True: 0, False: 0]
  ------------------
 3931|      0|                    rval = MODULE_NOT_FOUND;
  ------------------
  |  |  512|      0|#define MODULE_NOT_FOUND	0
  ------------------
 3932|      0|                else
 3933|      0|                    rval = MODULE_LOAD_FAILED;
  ------------------
  |  |  518|      0|#define MODULE_LOAD_FAILED	MODULE_NOT_FOUND
  |  |  ------------------
  |  |  |  |  512|      0|#define MODULE_NOT_FOUND	0
  |  |  ------------------
  ------------------
 3934|      0|                snmp_log_perror(mp->file);
 3935|      0|                return rval;
 3936|      0|            }
 3937|      0|#ifdef HAVE_FLOCKFILE
 3938|      0|            flockfile(fp);
 3939|      0|#endif
 3940|      0|            mp->no_imports = 0; /* Note that we've read the file */
 3941|      0|            File = mp->file;
 3942|      0|            mibLine = 1;
 3943|      0|            current_module = mp->modid;
 3944|       |            /*
 3945|       |             * Parse the file
 3946|       |             */
 3947|      0|            np = parse(fp);
 3948|      0|#ifdef HAVE_FUNLOCKFILE
 3949|      0|            funlockfile(fp);
 3950|      0|#endif
 3951|      0|            fclose(fp);
 3952|      0|            File = oldFile;
 3953|      0|            mibLine = oldLine;
 3954|      0|            current_module = oldModule;
 3955|      0|            res = !np && gMibError == MODULE_SYNTAX_ERROR ?
  ------------------
  |  |  519|      0|#define MODULE_SYNTAX_ERROR     4
  ------------------
  |  Branch (3955:19): [True: 0, False: 0]
  |  Branch (3955:26): [True: 0, False: 0]
  ------------------
 3956|      0|                MODULE_SYNTAX_ERROR : MODULE_LOADED_OK;
  ------------------
  |  |  519|      0|#define MODULE_SYNTAX_ERROR     4
  ------------------
                              MODULE_SYNTAX_ERROR : MODULE_LOADED_OK;
  ------------------
  |  |  513|      0|#define MODULE_LOADED_OK	1
  ------------------
 3957|      0|            while (np) {
  ------------------
  |  Branch (3957:20): [True: 0, False: 0]
  ------------------
 3958|      0|                struct node *nnp = np->next;
 3959|      0|                free_node(np);
 3960|      0|                np = nnp;
 3961|      0|            }
 3962|      0|            return res;
 3963|      0|        }
 3964|       |
 3965|     48|    return MODULE_NOT_FOUND;
  ------------------
  |  |  512|     48|#define MODULE_NOT_FOUND	0
  ------------------
 3966|     48|}
parse.c:print_error:
  778|     48|{
  779|     48|    erroneousMibs++;
  780|     48|    if (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|     48|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (780:9): [True: 0, False: 48]
  ------------------
  781|     48|                                NETSNMP_DS_LIB_MIB_ERRORS))
  ------------------
  |  |   59|     48|#define NETSNMP_DS_LIB_MIB_ERRORS          0
  ------------------
  782|      0|	return;
  783|     48|    DEBUGMSGTL(("parse-mibs", "\n"));
  ------------------
  |  |   68|     48|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|     48|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 48, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|     48|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|     48|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|     48|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|     48|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
  784|     48|    if (type == ENDOFFILE)
  ------------------
  |  |  162|     48|#define ENDOFFILE   0
  ------------------
  |  Branch (784:9): [True: 0, False: 48]
  ------------------
  785|      0|        snmp_log(LOG_ERR, "%s (EOF): At line %d in %s\n", str, mibLine,
  786|      0|                 File);
  787|     48|    else if (token && *token)
  ------------------
  |  Branch (787:14): [True: 48, False: 0]
  |  Branch (787:23): [True: 48, False: 0]
  ------------------
  788|     48|        snmp_log(LOG_ERR, "%s (%s): At line %d in %s\n", str, token,
  789|     48|                 mibLine, File);
  790|      0|    else
  791|      0|        snmp_log(LOG_ERR, "%s: At line %d in %s\n", str, mibLine, File);
  792|     48|}
parse.c:read_module_replacements:
 3840|     48|{
 3841|     48|    struct module_compatability *mcp;
 3842|       |
 3843|  1.10k|    for (mcp = module_map_head; mcp; mcp = mcp->next) {
  ------------------
  |  Branch (3843:33): [True: 1.05k, False: 48]
  ------------------
 3844|  1.05k|        if (!label_compare(mcp->old_module, name)) {
  ------------------
  |  | 1234|  1.05k|#define	label_compare	strcmp
  ------------------
  |  Branch (3844:13): [True: 0, False: 1.05k]
  ------------------
 3845|      0|            if (netsnmp_ds_get_int(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|      0|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (3845:17): [True: 0, False: 0]
  ------------------
 3846|      0|				   NETSNMP_DS_LIB_MIB_WARNINGS)) {
  ------------------
  |  |  114|      0|#define NETSNMP_DS_LIB_MIB_WARNINGS         0
  ------------------
 3847|      0|                snmp_log(LOG_WARNING,
 3848|      0|                         "Loading replacement module %s for %s (%s)\n",
 3849|      0|                         mcp->new_module, name, File);
 3850|      0|	    }
 3851|      0|            (void) netsnmp_read_module(mcp->new_module);
 3852|      0|            return 1;
 3853|      0|        }
 3854|  1.05k|    }
 3855|     48|    return 0;
 3856|     48|}
parse.c:print_module_not_found:
  796|     48|{
  797|     48|    if (first_err_module) {
  ------------------
  |  Branch (797:9): [True: 1, False: 47]
  ------------------
  798|      1|        snmp_log(LOG_ERR, "MIB search path: %s\n",
  799|      1|                           netsnmp_get_mib_directory());
  800|      1|        first_err_module = 0;
  801|      1|    }
  802|     48|    if (!last_err_module || strcmp(cp, last_err_module))
  ------------------
  |  Branch (802:9): [True: 1, False: 47]
  |  Branch (802:29): [True: 47, False: 0]
  ------------------
  803|     48|        print_error("Cannot find module", cp, CONTINUE);
  ------------------
  |  |  161|     48|#define CONTINUE    -1
  ------------------
  804|     48|    if (last_err_module)
  ------------------
  |  Branch (804:9): [True: 47, False: 1]
  ------------------
  805|     47|        free(last_err_module);
  806|     48|    last_err_module = strdup(cp);
  807|     48|}
parse.c:scan_directory:
 4954|      2|{
 4955|      2|    DIR            *dir, *dir2;
 4956|      2|    struct dirent  *file;
 4957|      2|    char          **filenames = NULL;
 4958|      2|    int             fname_len, i, filename_count = 0, array_size = 0;
 4959|      2|    char           *tmpstr;
 4960|       |
 4961|      2|    *result = NULL;
 4962|       |
 4963|      2|    dir = opendir(dirname);
 4964|      2|    if (!dir)
  ------------------
  |  Branch (4964:9): [True: 2, False: 0]
  ------------------
 4965|      2|        return -1;
 4966|       |
 4967|      0|    while ((file = readdir(dir))) {
  ------------------
  |  Branch (4967:12): [True: 0, False: 0]
  ------------------
 4968|       |        /*
 4969|       |         * Only parse file names that don't begin with a '.'
 4970|       |         * Also skip files ending in '~', or starting/ending
 4971|       |         * with '#' which are typically editor backup files.
 4972|       |         */
 4973|      0|        fname_len = strlen(file->d_name);
 4974|      0|        if (fname_len > 0 && file->d_name[0] != '.'
  ------------------
  |  Branch (4974:13): [True: 0, False: 0]
  |  Branch (4974:30): [True: 0, False: 0]
  ------------------
 4975|      0|            && file->d_name[0] != '#'
  ------------------
  |  Branch (4975:16): [True: 0, False: 0]
  ------------------
 4976|      0|            && file->d_name[fname_len-1] != '#'
  ------------------
  |  Branch (4976:16): [True: 0, False: 0]
  ------------------
 4977|      0|            && file->d_name[fname_len-1] != '~') {
  ------------------
  |  Branch (4977:16): [True: 0, False: 0]
  ------------------
 4978|      0|            if (asprintf(&tmpstr, "%s/%s", dirname, file->d_name) < 0)
  ------------------
  |  Branch (4978:17): [True: 0, False: 0]
  ------------------
 4979|      0|                continue;
 4980|      0|            dir2 = opendir(tmpstr);
 4981|      0|            if (dir2) {
  ------------------
  |  Branch (4981:17): [True: 0, False: 0]
  ------------------
 4982|       |                /* file is a directory, don't read it */
 4983|      0|                closedir(dir2);
 4984|      0|            } else {
 4985|      0|                if (filename_count >= array_size) {
  ------------------
  |  Branch (4985:21): [True: 0, False: 0]
  ------------------
 4986|      0|                    char **new_filenames;
 4987|       |
 4988|      0|                    array_size = (array_size + 16) * 2;
 4989|      0|                    new_filenames = realloc(filenames,
 4990|      0|                                        array_size * sizeof(filenames[0]));
 4991|      0|                    if (!new_filenames) {
  ------------------
  |  Branch (4991:25): [True: 0, False: 0]
  ------------------
 4992|      0|                        free(tmpstr);
 4993|      0|                        for (i = 0; i < filename_count; i++)
  ------------------
  |  Branch (4993:37): [True: 0, False: 0]
  ------------------
 4994|      0|                            free(filenames[i]);
 4995|      0|                        free(filenames);
 4996|      0|                        closedir(dir);
 4997|      0|                        return -1;
 4998|      0|                    }
 4999|      0|                    filenames = new_filenames;
 5000|      0|                }
 5001|      0|                filenames[filename_count++] = tmpstr;
 5002|      0|                tmpstr = NULL;
 5003|      0|            }
 5004|      0|            free(tmpstr);
 5005|      0|        }
 5006|      0|    }
 5007|      0|    closedir(dir);
 5008|       |
 5009|      0|    if (filenames)
  ------------------
  |  Branch (5009:9): [True: 0, False: 0]
  ------------------
 5010|      0|        qsort(filenames, filename_count, sizeof(filenames[0]), elemcmp);
 5011|      0|    *result = filenames;
 5012|       |
 5013|      0|    return filename_count;
 5014|      0|}

register_prenetsnmp_mib_handler:
  253|     35|{
  254|     35|    return internal_register_config_handler(type, token, parser, releaser,
  255|     35|					    help, PREMIB_CONFIG);
  ------------------
  |  |   15|     35|#define PREMIB_CONFIG 1
  ------------------
  256|     35|}
register_config_handler:
  308|     63|{
  309|     63|    return internal_register_config_handler(type, token, parser, releaser,
  310|     63|					    help, NORMAL_CONFIG);
  ------------------
  |  |   14|     63|#define NORMAL_CONFIG 0
  ------------------
  311|     63|}
register_const_config_handler:
  318|      1|{
  319|      1|    return internal_register_config_handler(type, token,
  320|      1|                                            (void(*)(const char *, char *))
  321|      1|                                            parser, releaser,
  322|      1|					    help, NORMAL_CONFIG);
  ------------------
  |  |   14|      1|#define NORMAL_CONFIG 0
  ------------------
  323|      1|}
register_app_config_handler:
  329|      2|{
  330|      2|    return (register_config_handler(NULL, token, parser, releaser, help));
  331|      2|}
netsnmp_config_remember_free_list:
  673|      1|{
  674|      1|    struct read_config_memory *tmpmem;
  675|      1|    while (*mem) {
  ------------------
  |  Branch (675:12): [True: 0, False: 1]
  ------------------
  676|      0|        SNMP_FREE((*mem)->line);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded - Ignored]
  |  |  ------------------
  ------------------
  677|      0|        tmpmem = (*mem)->next;
  678|      0|        SNMP_FREE(*mem);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded - Ignored]
  |  |  ------------------
  ------------------
  679|      0|        *mem = tmpmem;
  680|      0|    }
  681|      1|}
netsnmp_config_process_memory_list:
  686|      2|{
  687|       |
  688|      2|    struct read_config_memory *mem;
  689|       |
  690|      2|    if (!memp)
  ------------------
  |  Branch (690:9): [True: 0, False: 2]
  ------------------
  691|      0|        return;
  692|       |
  693|      2|    mem = *memp;
  694|       |
  695|      2|    while (mem) {
  ------------------
  |  Branch (695:12): [True: 0, False: 2]
  ------------------
  696|      0|        DEBUGMSGTL(("read_config:mem", "processing memory: %s\n", mem->line));
  ------------------
  |  |   68|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
  697|      0|        snmp_config_when(mem->line, when);
  698|      0|        mem = mem->next;
  699|      0|    }
  700|       |
  701|      2|    if (clear)
  ------------------
  |  Branch (701:9): [True: 1, False: 1]
  ------------------
  702|      1|        netsnmp_config_remember_free_list(memp);
  703|      2|}
netsnmp_config_process_memories_when:
  724|      2|{
  725|      2|    netsnmp_config_process_memory_list(&memorylist, when, clear);
  726|      2|}
read_config:
  755|      8|{
  756|      8|    static int      depth = 0;
  757|      8|    static int      files = 0;
  758|       |
  759|      8|    const char * const prev_filename = curfilename;
  760|      8|    const unsigned int prev_linecount = linecount;
  761|       |
  762|      8|    FILE           *ifile;
  763|      8|    char           *line = NULL;  /* current line buffer */
  764|      8|    size_t          linesize = 0; /* allocated size of line */
  765|       |
  766|      8|    netsnmp_assert(line_handler);
  ------------------
  |  |   47|      8|#      define netsnmp_assert(x)  do { \
  |  |   48|      8|              if ( x ) \
  |  |  ------------------
  |  |  |  Branch (48:20): [True: 8, False: 0]
  |  |  ------------------
  |  |   49|      8|                 ; \
  |  |   50|      8|              else \
  |  |   51|      8|                 snmp_log(LOG_ERR, \
  |  |   52|      0|                          "netsnmp_assert %s failed %s:%d" NETSNMP_FUNC_FMT, \
  |  |  ------------------
  |  |  |  |   40|      0|#          define NETSNMP_FUNC_FMT " %s()\n"
  |  |  ------------------
  |  |   53|      0|                          __STRING(x),__FILE__,__LINE__, \
  |  |   54|      0|                          NETSNMP_FUNC_PARAM); \
  |  |  ------------------
  |  |  |  |   41|      0|#          define NETSNMP_FUNC_PARAM NETSNMP_FUNCTION
  |  |  |  |  ------------------
  |  |  |  |  |  | 1681|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|      8|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded - Ignored]
  |  |  ------------------
  ------------------
  767|      8|    netsnmp_assert(line_handler->config_token);
  ------------------
  |  |   47|      8|#      define netsnmp_assert(x)  do { \
  |  |   48|      8|              if ( x ) \
  |  |  ------------------
  |  |  |  Branch (48:20): [True: 8, False: 0]
  |  |  ------------------
  |  |   49|      8|                 ; \
  |  |   50|      8|              else \
  |  |   51|      8|                 snmp_log(LOG_ERR, \
  |  |   52|      0|                          "netsnmp_assert %s failed %s:%d" NETSNMP_FUNC_FMT, \
  |  |  ------------------
  |  |  |  |   40|      0|#          define NETSNMP_FUNC_FMT " %s()\n"
  |  |  ------------------
  |  |   53|      0|                          __STRING(x),__FILE__,__LINE__, \
  |  |   54|      0|                          NETSNMP_FUNC_PARAM); \
  |  |  ------------------
  |  |  |  |   41|      0|#          define NETSNMP_FUNC_PARAM NETSNMP_FUNCTION
  |  |  |  |  ------------------
  |  |  |  |  |  | 1681|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|      8|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded - Ignored]
  |  |  ------------------
  ------------------
  768|       |
  769|       |    /* reset file counter when recursion depth is 0 */
  770|      8|    if (depth == 0)
  ------------------
  |  Branch (770:9): [True: 8, False: 0]
  ------------------
  771|      8|        files = 0;
  772|       |
  773|      8|    if ((ifile = fopen(filename, "r")) == NULL) {
  ------------------
  |  Branch (773:9): [True: 8, False: 0]
  ------------------
  774|      8|#ifdef ENOENT
  775|      8|        if (errno == ENOENT) {
  ------------------
  |  Branch (775:13): [True: 8, False: 0]
  ------------------
  776|      8|            DEBUGMSGTL(("read_config", "%s: %s\n", filename,
  ------------------
  |  |   68|      8|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      8|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 8, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      8|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      8|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      8|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      8|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
  777|      8|                        strerror(errno)));
  778|      8|        } else
  779|      0|#endif                          /* ENOENT */
  780|      0|#ifdef EACCES
  781|      0|        if (errno == EACCES) {
  ------------------
  |  Branch (781:13): [True: 0, False: 0]
  ------------------
  782|      0|            DEBUGMSGTL(("read_config", "%s: %s\n", filename,
  ------------------
  |  |   68|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
  783|      0|                        strerror(errno)));
  784|      0|        } else
  785|      0|#endif                          /* EACCES */
  786|      0|        {
  787|      0|            snmp_log_perror(filename);
  788|      0|        }
  789|      8|        return SNMPERR_GENERR;
  ------------------
  |  |  218|      8|#define SNMPERR_GENERR			(-1)
  ------------------
  790|      8|    }
  791|       |
  792|      0|#define CONFIG_MAX_FILES 4096
  793|      0|    if (files > CONFIG_MAX_FILES) {
  ------------------
  |  |  792|      0|#define CONFIG_MAX_FILES 4096
  ------------------
  |  Branch (793:9): [True: 0, False: 0]
  ------------------
  794|      0|        netsnmp_config_error("maximum conf file count (%d) exceeded\n",
  795|      0|                             CONFIG_MAX_FILES);
  ------------------
  |  |  792|      0|#define CONFIG_MAX_FILES 4096
  ------------------
  796|      0|	fclose(ifile);
  797|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  218|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  798|      0|    }
  799|      0|#define CONFIG_MAX_RECURSE_DEPTH 16
  800|      0|    if (depth > CONFIG_MAX_RECURSE_DEPTH) {
  ------------------
  |  |  799|      0|#define CONFIG_MAX_RECURSE_DEPTH 16
  ------------------
  |  Branch (800:9): [True: 0, False: 0]
  ------------------
  801|      0|        netsnmp_config_error("nested include depth > %d\n",
  802|      0|                             CONFIG_MAX_RECURSE_DEPTH);
  ------------------
  |  |  799|      0|#define CONFIG_MAX_RECURSE_DEPTH 16
  ------------------
  803|      0|	fclose(ifile);
  804|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  218|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  805|      0|    }
  806|       |
  807|      0|    linecount = 0;
  808|      0|    curfilename = filename;
  809|       |
  810|      0|    ++files;
  811|      0|    ++depth;
  812|       |
  813|      0|    DEBUGMSGTL(("read_config:file", "Reading configuration %s (%d)\n",
  ------------------
  |  |   68|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
  814|      0|                filename, when));
  815|       |
  816|      0|    while (ifile) {
  ------------------
  |  Branch (816:12): [True: 0, False: 0]
  ------------------
  817|      0|        size_t              linelen = 0; /* strlen of the current line */
  818|      0|        char               *cptr;
  819|      0|        struct config_line *lptr = line_handler;
  820|       |
  821|      0|        for (;;) {
  822|      0|            if (linesize <= linelen + 1) {
  ------------------
  |  Branch (822:17): [True: 0, False: 0]
  ------------------
  823|      0|                char *tmp = realloc(line, linesize + 256);
  824|      0|                if (tmp) {
  ------------------
  |  Branch (824:21): [True: 0, False: 0]
  ------------------
  825|      0|                    line = tmp;
  826|      0|                    linesize += 256;
  827|      0|                } else {
  828|      0|                    netsnmp_config_error("Failed to allocate memory\n");
  829|      0|                    free(line);
  830|      0|                    fclose(ifile);
  831|      0|                    return SNMPERR_GENERR;
  ------------------
  |  |  218|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  832|      0|                }
  833|      0|            }
  834|      0|            if (fgets(line + linelen, linesize - linelen, ifile) == NULL) {
  ------------------
  |  Branch (834:17): [True: 0, False: 0]
  ------------------
  835|      0|                line[linelen] = '\0';
  836|      0|                fclose (ifile);
  837|      0|                ifile = NULL;
  838|      0|                break;
  839|      0|            }
  840|       |
  841|      0|            linelen += strlen(line + linelen);
  842|       |
  843|      0|            if (linelen && line[linelen - 1] == '\n') {
  ------------------
  |  Branch (843:17): [True: 0, False: 0]
  |  Branch (843:28): [True: 0, False: 0]
  ------------------
  844|      0|              line[linelen - 1] = '\0';
  845|      0|              break;
  846|      0|            }
  847|      0|        }
  848|       |
  849|      0|        ++linecount;
  850|      0|        DEBUGMSGTL(("9:read_config:line", "%s:%d examining: %s\n",
  ------------------
  |  |   68|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
  851|      0|                    filename, linecount, line));
  852|       |        /*
  853|       |         * check blank line or # comment 
  854|       |         */
  855|      0|        if ((cptr = skip_white(line))) {
  ------------------
  |  Branch (855:13): [True: 0, False: 0]
  ------------------
  856|      0|            char token[STRINGMAX];
  857|       |
  858|      0|            cptr = copy_nword(cptr, token, sizeof(token));
  859|      0|            if (token[0] == '[') {
  ------------------
  |  Branch (859:17): [True: 0, False: 0]
  ------------------
  860|      0|                if (token[strlen(token) - 1] != ']') {
  ------------------
  |  Branch (860:21): [True: 0, False: 0]
  ------------------
  861|      0|		    netsnmp_config_error("no matching ']' for type %s.",
  862|      0|					 &token[1]);
  863|      0|                    continue;
  864|      0|                }
  865|      0|                token[strlen(token) - 1] = '\0';
  866|      0|                lptr = read_config_get_handlers(&token[1]);
  867|      0|                if (lptr == NULL) {
  ------------------
  |  Branch (867:21): [True: 0, False: 0]
  ------------------
  868|      0|		    netsnmp_config_error("No handlers regestered for type %s.",
  869|      0|					 &token[1]);
  870|      0|                    continue;
  871|      0|                }
  872|      0|                DEBUGMSGTL(("read_config:context",
  ------------------
  |  |   68|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (166:52): [True: 0, False: 0]
  |  |  |  |  |  Branch (166:64): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
  873|      0|                            "Switching to new context: %s%s\n",
  874|      0|                            ((cptr) ? "(this line only) " : ""),
  875|      0|                            &token[1]));
  876|      0|                if (cptr == NULL) {
  ------------------
  |  Branch (876:21): [True: 0, False: 0]
  ------------------
  877|       |                    /*
  878|       |                     * change context permanently 
  879|       |                     */
  880|      0|                    line_handler = lptr;
  881|      0|                    continue;
  882|      0|                } else {
  883|       |                    /*
  884|       |                     * the rest of this line only applies. 
  885|       |                     */
  886|      0|                    cptr = copy_nword(cptr, token, sizeof(token));
  887|      0|                }
  888|      0|            } else if ((token[0] == 'i') && (strncasecmp(token,"include", 7 )==0)) {
  ------------------
  |  Branch (888:24): [True: 0, False: 0]
  |  Branch (888:45): [True: 0, False: 0]
  ------------------
  889|      0|                if ( strcasecmp( token, "include" )==0) {
  ------------------
  |  Branch (889:22): [True: 0, False: 0]
  ------------------
  890|      0|                    if (when != PREMIB_CONFIG && 
  ------------------
  |  |   15|      0|#define PREMIB_CONFIG 1
  ------------------
  |  Branch (890:25): [True: 0, False: 0]
  ------------------
  891|      0|	                !netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|      0|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (891:18): [True: 0, False: 0]
  ------------------
  892|      0|				                NETSNMP_DS_LIB_NO_TOKEN_WARNINGS)) {
  ------------------
  |  |   77|      0|#define NETSNMP_DS_LIB_NO_TOKEN_WARNINGS   17   /* no warn about unknown config tokens */
  ------------------
  893|      0|	                netsnmp_config_warn("Ambiguous token '%s' - use 'includeSearch' (or 'includeFile') instead.", token);
  894|      0|                    }
  895|      0|                    continue;
  896|      0|                } else if ( strcasecmp( token, "includedir" )==0) {
  ------------------
  |  Branch (896:29): [True: 0, False: 0]
  ------------------
  897|      0|                    DIR *d;
  898|      0|                    struct dirent *entry;
  899|      0|                    char  fname[SNMP_MAXPATH];
  900|      0|                    int   len;
  901|       |
  902|      0|                    if (cptr == NULL) {
  ------------------
  |  Branch (902:25): [True: 0, False: 0]
  ------------------
  903|      0|                        if (when != PREMIB_CONFIG)
  ------------------
  |  |   15|      0|#define PREMIB_CONFIG 1
  ------------------
  |  Branch (903:29): [True: 0, False: 0]
  ------------------
  904|      0|		            netsnmp_config_error("Blank line following %s token.", token);
  905|      0|                        continue;
  906|      0|                    }
  907|      0|                    if ((d=opendir(cptr)) == NULL ) {
  ------------------
  |  Branch (907:25): [True: 0, False: 0]
  ------------------
  908|      0|                        if (when != PREMIB_CONFIG)
  ------------------
  |  |   15|      0|#define PREMIB_CONFIG 1
  ------------------
  |  Branch (908:29): [True: 0, False: 0]
  ------------------
  909|      0|                            netsnmp_config_error("Can't open include dir '%s'.", cptr);
  910|      0|                        continue;
  911|      0|                    }
  912|      0|                    while ((entry = readdir( d )) != NULL ) {
  ------------------
  |  Branch (912:28): [True: 0, False: 0]
  ------------------
  913|      0|                        if ( entry->d_name[0] != '.') {
  ------------------
  |  Branch (913:30): [True: 0, False: 0]
  ------------------
  914|      0|                            len = strlen(entry->d_name);
  915|      0|                            if ((len > 5) && (strcmp(&(entry->d_name[len-5]),".conf") == 0)) {
  ------------------
  |  Branch (915:33): [True: 0, False: 0]
  |  Branch (915:46): [True: 0, False: 0]
  ------------------
  916|      0|                                snprintf(fname, SNMP_MAXPATH, "%s/%s",
  ------------------
  |  |   33|      0|#    define SNMP_MAXPATH PATH_MAX
  ------------------
  917|      0|                                         cptr, entry->d_name);
  918|      0|                                (void)read_config(fname, line_handler, when);
  919|      0|                            }
  920|      0|                        }
  921|      0|                    }
  922|      0|                    closedir(d);
  923|      0|                    continue;
  924|      0|                } else if ( strcasecmp( token, "includefile" )==0) {
  ------------------
  |  Branch (924:29): [True: 0, False: 0]
  ------------------
  925|      0|                    char  fname[SNMP_MAXPATH], *cp;
  926|       |
  927|      0|                    if (cptr == NULL) {
  ------------------
  |  Branch (927:25): [True: 0, False: 0]
  ------------------
  928|      0|                        if (when != PREMIB_CONFIG)
  ------------------
  |  |   15|      0|#define PREMIB_CONFIG 1
  ------------------
  |  Branch (928:29): [True: 0, False: 0]
  ------------------
  929|      0|		            netsnmp_config_error("Blank line following %s token.", token);
  930|      0|                        continue;
  931|      0|                    }
  932|      0|                    if ( cptr[0] == '/' ) {
  ------------------
  |  Branch (932:26): [True: 0, False: 0]
  ------------------
  933|      0|                        strlcpy(fname, cptr, SNMP_MAXPATH);
  ------------------
  |  |   33|      0|#    define SNMP_MAXPATH PATH_MAX
  ------------------
  934|      0|                    } else {
  935|      0|                        strlcpy(fname, filename, SNMP_MAXPATH);
  ------------------
  |  |   33|      0|#    define SNMP_MAXPATH PATH_MAX
  ------------------
  936|      0|                        cp = strrchr(fname, '/');
  937|      0|                        if (!cp)
  ------------------
  |  Branch (937:29): [True: 0, False: 0]
  ------------------
  938|      0|                            fname[0] = '\0';
  939|      0|                        else
  940|      0|                            *(++cp) = '\0';
  941|      0|                        strlcat(fname, cptr, SNMP_MAXPATH);
  ------------------
  |  |   33|      0|#    define SNMP_MAXPATH PATH_MAX
  ------------------
  942|      0|                    }
  943|      0|                    if (read_config(fname, line_handler, when) !=
  ------------------
  |  Branch (943:25): [True: 0, False: 0]
  ------------------
  944|      0|                        SNMPERR_SUCCESS && when != PREMIB_CONFIG)
  ------------------
  |  |  217|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
                                      SNMPERR_SUCCESS && when != PREMIB_CONFIG)
  ------------------
  |  |   15|      0|#define PREMIB_CONFIG 1
  ------------------
  |  Branch (944:44): [True: 0, False: 0]
  ------------------
  945|      0|                        netsnmp_config_error("Included file '%s' not found.",
  946|      0|                                             fname);
  947|      0|                    continue;
  948|      0|                } else if ( strcasecmp( token, "includesearch" )==0) {
  ------------------
  |  Branch (948:29): [True: 0, False: 0]
  ------------------
  949|      0|                    struct config_files ctmp;
  950|      0|                    int len, ret;
  951|       |
  952|      0|                    if (cptr == NULL) {
  ------------------
  |  Branch (952:25): [True: 0, False: 0]
  ------------------
  953|      0|                        if (when != PREMIB_CONFIG)
  ------------------
  |  |   15|      0|#define PREMIB_CONFIG 1
  ------------------
  |  Branch (953:29): [True: 0, False: 0]
  ------------------
  954|      0|		            netsnmp_config_error("Blank line following %s token.", token);
  955|      0|                        continue;
  956|      0|                    }
  957|      0|                    len = strlen(cptr);
  958|      0|                    ctmp.fileHeader = cptr;
  959|      0|                    ctmp.start = line_handler;
  960|      0|                    ctmp.next = NULL;
  961|      0|                    if ((len > 5) && (strcmp(&cptr[len-5],".conf") == 0))
  ------------------
  |  Branch (961:25): [True: 0, False: 0]
  |  Branch (961:38): [True: 0, False: 0]
  ------------------
  962|      0|                       cptr[len-5] = 0; /* chop off .conf */
  963|      0|                    ret = read_config_files_of_type(when,&ctmp);
  964|      0|                    if ((len > 5) && (cptr[len-5] == 0))
  ------------------
  |  Branch (964:25): [True: 0, False: 0]
  |  Branch (964:38): [True: 0, False: 0]
  ------------------
  965|      0|                       cptr[len-5] = '.'; /* restore .conf */
  966|      0|                    if (( ret != SNMPERR_SUCCESS ) && (when != PREMIB_CONFIG))
  ------------------
  |  |  217|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
                                  if (( ret != SNMPERR_SUCCESS ) && (when != PREMIB_CONFIG))
  ------------------
  |  |   15|      0|#define PREMIB_CONFIG 1
  ------------------
  |  Branch (966:25): [True: 0, False: 0]
  |  Branch (966:55): [True: 0, False: 0]
  ------------------
  967|      0|		        netsnmp_config_error("Included config '%s' not found.", cptr);
  968|      0|                    continue;
  969|      0|                } else {
  970|      0|                    lptr = line_handler;
  971|      0|                }
  972|      0|            } else {
  973|      0|                lptr = line_handler;
  974|      0|            }
  975|      0|            if (cptr == NULL) {
  ------------------
  |  Branch (975:17): [True: 0, False: 0]
  ------------------
  976|      0|		netsnmp_config_error("Blank line following %s token.", token);
  977|      0|            } else {
  978|      0|                DEBUGMSGTL(("read_config:line", "%s:%d examining: %s\n",
  ------------------
  |  |   68|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
  979|      0|                            filename, linecount, line));
  980|      0|                run_config_handler(lptr, token, cptr, when);
  981|      0|            }
  982|      0|        }
  983|      0|    }
  984|      0|    free(line);
  985|      0|    linecount = prev_linecount;
  986|      0|    curfilename = prev_filename;
  987|      0|    --depth;
  988|      0|    return SNMPERR_SUCCESS;
  ------------------
  |  |  217|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  989|       |
  990|      0|}                               /* end read_config() */
free_config:
  996|      1|{
  997|      1|    struct config_files *ctmp = config_files;
  998|      1|    struct config_line *ltmp;
  999|       |
 1000|      3|    for (; ctmp != NULL; ctmp = ctmp->next)
  ------------------
  |  Branch (1000:12): [True: 2, False: 1]
  ------------------
 1001|    103|        for (ltmp = ctmp->start; ltmp != NULL; ltmp = ltmp->next)
  ------------------
  |  Branch (1001:34): [True: 101, False: 2]
  ------------------
 1002|    101|            if (ltmp->free_func)
  ------------------
  |  Branch (1002:17): [True: 7, False: 94]
  ------------------
 1003|      7|                (*(ltmp->free_func)) ();
 1004|      1|}
read_configs:
 1049|      1|{
 1050|      1|    char *optional_config = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1051|      1|					       NETSNMP_DS_LIB_OPTIONALCONFIG);
  ------------------
  |  |  156|      1|#define NETSNMP_DS_LIB_OPTIONALCONFIG    5
  ------------------
 1052|       |
 1053|      1|    snmp_call_callbacks(SNMP_CALLBACK_LIBRARY,
  ------------------
  |  |   18|      1|#define SNMP_CALLBACK_LIBRARY     0
  ------------------
 1054|      1|                        SNMP_CALLBACK_PRE_READ_CONFIG, NULL);
  ------------------
  |  |   30|      1|#define SNMP_CALLBACK_PRE_READ_CONFIG	        7
  ------------------
 1055|       |
 1056|      1|    DEBUGMSGTL(("read_config", "reading normal configuration tokens\n"));
  ------------------
  |  |   68|      1|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      1|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      1|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      1|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      1|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1057|       |
 1058|      1|    if ((NULL != optional_config) && (*optional_config == '-')) {
  ------------------
  |  Branch (1058:9): [True: 0, False: 1]
  |  Branch (1058:38): [True: 0, False: 0]
  ------------------
 1059|      0|        (void)read_configs_optional(++optional_config, NORMAL_CONFIG);
  ------------------
  |  |   14|      0|#define NORMAL_CONFIG 0
  ------------------
 1060|      0|        optional_config = NULL; /* clear, so we don't read them twice */
 1061|      0|    }
 1062|       |
 1063|      1|    (void)read_config_files(NORMAL_CONFIG);
  ------------------
  |  |   14|      1|#define NORMAL_CONFIG 0
  ------------------
 1064|       |
 1065|       |    /*
 1066|       |     * do this even when the normal above wasn't done 
 1067|       |     */
 1068|      1|    if (NULL != optional_config)
  ------------------
  |  Branch (1068:9): [True: 0, False: 1]
  ------------------
 1069|      0|        (void)read_configs_optional(optional_config, NORMAL_CONFIG);
  ------------------
  |  |   14|      0|#define NORMAL_CONFIG 0
  ------------------
 1070|       |
 1071|      1|    netsnmp_config_process_memories_when(NORMAL_CONFIG, 1);
  ------------------
  |  |   14|      1|#define NORMAL_CONFIG 0
  ------------------
 1072|       |
 1073|      1|    netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1074|      1|			   NETSNMP_DS_LIB_HAVE_READ_CONFIG, 1);
  ------------------
  |  |   87|      1|#define NETSNMP_DS_LIB_HAVE_READ_CONFIG    27   /* have the config tokens been processed */
  ------------------
 1075|      1|    snmp_call_callbacks(SNMP_CALLBACK_LIBRARY,
  ------------------
  |  |   18|      1|#define SNMP_CALLBACK_LIBRARY     0
  ------------------
 1076|      1|                        SNMP_CALLBACK_POST_READ_CONFIG, NULL);
  ------------------
  |  |   24|      1|#define SNMP_CALLBACK_POST_READ_CONFIG	        0
  ------------------
 1077|      1|}
read_premib_configs:
 1081|      1|{
 1082|      1|    char *optional_config = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1083|      1|					       NETSNMP_DS_LIB_OPTIONALCONFIG);
  ------------------
  |  |  156|      1|#define NETSNMP_DS_LIB_OPTIONALCONFIG    5
  ------------------
 1084|       |
 1085|      1|    snmp_call_callbacks(SNMP_CALLBACK_LIBRARY,
  ------------------
  |  |   18|      1|#define SNMP_CALLBACK_LIBRARY     0
  ------------------
 1086|      1|                        SNMP_CALLBACK_PRE_PREMIB_READ_CONFIG, NULL);
  ------------------
  |  |   31|      1|#define SNMP_CALLBACK_PRE_PREMIB_READ_CONFIG	8
  ------------------
 1087|       |
 1088|      1|    DEBUGMSGTL(("read_config", "reading premib configuration tokens\n"));
  ------------------
  |  |   68|      1|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      1|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      1|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      1|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      1|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1089|       |
 1090|      1|    if ((NULL != optional_config) && (*optional_config == '-')) {
  ------------------
  |  Branch (1090:9): [True: 0, False: 1]
  |  Branch (1090:38): [True: 0, False: 0]
  ------------------
 1091|      0|        (void)read_configs_optional(++optional_config, PREMIB_CONFIG);
  ------------------
  |  |   15|      0|#define PREMIB_CONFIG 1
  ------------------
 1092|      0|        optional_config = NULL; /* clear, so we don't read them twice */
 1093|      0|    }
 1094|       |
 1095|      1|    (void)read_config_files(PREMIB_CONFIG);
  ------------------
  |  |   15|      1|#define PREMIB_CONFIG 1
  ------------------
 1096|       |
 1097|      1|    if (NULL != optional_config)
  ------------------
  |  Branch (1097:9): [True: 0, False: 1]
  ------------------
 1098|      0|        (void)read_configs_optional(optional_config, PREMIB_CONFIG);
  ------------------
  |  |   15|      0|#define PREMIB_CONFIG 1
  ------------------
 1099|       |
 1100|      1|    netsnmp_config_process_memories_when(PREMIB_CONFIG, 0);
  ------------------
  |  |   15|      1|#define PREMIB_CONFIG 1
  ------------------
 1101|       |
 1102|      1|    netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1103|      1|			   NETSNMP_DS_LIB_HAVE_READ_PREMIB_CONFIG, 1);
  ------------------
  |  |   86|      1|#define NETSNMP_DS_LIB_HAVE_READ_PREMIB_CONFIG 26       /* have the pre-mib parsing config tokens been processed */
  ------------------
 1104|      1|    snmp_call_callbacks(SNMP_CALLBACK_LIBRARY,
  ------------------
  |  |   18|      1|#define SNMP_CALLBACK_LIBRARY     0
  ------------------
 1105|      1|                        SNMP_CALLBACK_POST_PREMIB_READ_CONFIG, NULL);
  ------------------
  |  |   27|      1|#define SNMP_CALLBACK_POST_PREMIB_READ_CONFIG	3
  ------------------
 1106|      1|}
set_configuration_directory:
 1118|      1|{
 1119|      1|    netsnmp_ds_set_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1120|      1|			  NETSNMP_DS_LIB_CONFIGURATION_DIR, dir);
  ------------------
  |  |  160|      1|#define NETSNMP_DS_LIB_CONFIGURATION_DIR 9
  ------------------
 1121|      1|}
get_configuration_directory:
 1137|      5|{
 1138|      5|    char            defaultPath[SPRINT_MAX_LEN];
 1139|      5|    char           *homepath;
 1140|       |
 1141|      5|    if (NULL == netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|      5|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (1141:9): [True: 1, False: 4]
  ------------------
 1142|      5|				      NETSNMP_DS_LIB_CONFIGURATION_DIR)) {
  ------------------
  |  |  160|      5|#define NETSNMP_DS_LIB_CONFIGURATION_DIR 9
  ------------------
 1143|      1|        homepath = netsnmp_getenv("HOME");
 1144|      1|        snprintf(defaultPath, sizeof(defaultPath), "%s%c%s%c%s%s%s%s",
 1145|      1|                SNMPCONFPATH, ENV_SEPARATOR_CHAR,
  ------------------
  |  | 2009|      1|#define SNMPCONFPATH "/usr/local/net-snmp-master/etc/snmp"
  ------------------
                              SNMPCONFPATH, ENV_SEPARATOR_CHAR,
  ------------------
  |  |   70|      1|#define ENV_SEPARATOR_CHAR ':'
  ------------------
 1146|      1|                SNMPSHAREPATH, ENV_SEPARATOR_CHAR, SNMPLIBPATH,
  ------------------
  |  | 2008|      1|#define SNMPSHAREPATH "/usr/local/net-snmp-master/share/snmp"
  ------------------
                              SNMPSHAREPATH, ENV_SEPARATOR_CHAR, SNMPLIBPATH,
  ------------------
  |  |   70|      1|#define ENV_SEPARATOR_CHAR ':'
  ------------------
                              SNMPSHAREPATH, ENV_SEPARATOR_CHAR, SNMPLIBPATH,
  ------------------
  |  | 2007|      1|#define SNMPLIBPATH "/usr/local/net-snmp-master/lib/snmp"
  ------------------
 1147|      1|                ((homepath == NULL) ? "" : ENV_SEPARATOR),
  ------------------
  |  |   67|      1|#define ENV_SEPARATOR ":"
  ------------------
  |  Branch (1147:18): [True: 0, False: 1]
  ------------------
 1148|      1|                ((homepath == NULL) ? "" : homepath),
  ------------------
  |  Branch (1148:18): [True: 0, False: 1]
  ------------------
 1149|      1|                ((homepath == NULL) ? "" : "/.snmp"));
  ------------------
  |  Branch (1149:18): [True: 0, False: 1]
  ------------------
 1150|      1|        defaultPath[ sizeof(defaultPath)-1 ] = 0;
 1151|      1|        set_configuration_directory(defaultPath);
 1152|      1|    }
 1153|      5|    return (netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|      5|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1154|      5|				  NETSNMP_DS_LIB_CONFIGURATION_DIR));
  ------------------
  |  |  160|      5|#define NETSNMP_DS_LIB_CONFIGURATION_DIR 9
  ------------------
 1155|      5|}
set_persistent_directory:
 1168|      1|{
 1169|      1|    netsnmp_ds_set_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1170|      1|			  NETSNMP_DS_LIB_PERSISTENT_DIR, dir);
  ------------------
  |  |  159|      1|#define NETSNMP_DS_LIB_PERSISTENT_DIR    8
  ------------------
 1171|      1|}
get_persistent_directory:
 1185|      9|{
 1186|      9|    if (NULL == netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|      9|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (1186:9): [True: 1, False: 8]
  ------------------
 1187|      9|				      NETSNMP_DS_LIB_PERSISTENT_DIR)) {
  ------------------
  |  |  159|      9|#define NETSNMP_DS_LIB_PERSISTENT_DIR    8
  ------------------
 1188|      1|        const char *persdir = netsnmp_getenv("SNMP_PERSISTENT_DIR");
 1189|      1|        if (NULL == persdir)
  ------------------
  |  Branch (1189:13): [True: 1, False: 0]
  ------------------
 1190|      1|            persdir = NETSNMP_PERSISTENT_DIRECTORY;
  ------------------
  |  | 1979|      1|#define NETSNMP_PERSISTENT_DIRECTORY "/var/net-snmp"
  ------------------
 1191|      1|        set_persistent_directory(persdir);
 1192|      1|    }
 1193|      9|    return (netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|      9|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1194|      9|				  NETSNMP_DS_LIB_PERSISTENT_DIR));
  ------------------
  |  |  159|      9|#define NETSNMP_DS_LIB_PERSISTENT_DIR    8
  ------------------
 1195|      9|}
read_config_files_of_type:
 1382|      4|{
 1383|      4|    const char     *confpath, *persfile, *envconfpath;
 1384|      4|    char           *perspath;
 1385|      4|    int             ret = SNMPERR_GENERR;
  ------------------
  |  |  218|      4|#define SNMPERR_GENERR			(-1)
  ------------------
 1386|       |
 1387|      4|    if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      4|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (1387:9): [True: 0, False: 4]
  ------------------
 1388|      4|                               NETSNMP_DS_LIB_DONT_PERSIST_STATE)
  ------------------
  |  |   92|      4|#define NETSNMP_DS_LIB_DONT_PERSIST_STATE  32	/* don't load config and don't load/save persistent file */
  ------------------
 1389|      4|        || netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      4|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (1389:12): [True: 0, False: 4]
  ------------------
 1390|      4|                                  NETSNMP_DS_LIB_DISABLE_CONFIG_LOAD)
  ------------------
  |  |   66|      4|#define NETSNMP_DS_LIB_DISABLE_CONFIG_LOAD      NETSNMP_DS_LIB_DONT_READ_CONFIGS
  |  |  ------------------
  |  |  |  |   65|      4|#define NETSNMP_DS_LIB_DONT_READ_CONFIGS   6    /* don't read normal config files */
  |  |  ------------------
  ------------------
 1391|      4|        || (NULL == ctmp)) return ret;
  ------------------
  |  Branch (1391:12): [True: 0, False: 4]
  ------------------
 1392|       |
 1393|       |    /*
 1394|       |     * these shouldn't change
 1395|       |     */
 1396|      4|    confpath = get_configuration_directory();
 1397|      4|    persfile = netsnmp_getenv("SNMP_PERSISTENT_FILE");
 1398|      4|    envconfpath = netsnmp_getenv("SNMPCONFPATH");
 1399|       |
 1400|       |
 1401|       |        /*
 1402|       |         * read the config files. strdup() the result of
 1403|       |         * get_persistent_directory() to avoid that parsing the "persistentDir"
 1404|       |         * keyword transforms the perspath pointer into a dangling pointer.
 1405|       |         */
 1406|      4|        perspath = strdup(get_persistent_directory());
 1407|      4|        if (perspath == NULL) {
  ------------------
  |  Branch (1407:13): [True: 0, False: 4]
  ------------------
 1408|      0|            return SNMPERR_GENERR;
  ------------------
  |  |  218|      0|#define SNMPERR_GENERR			(-1)
  ------------------
 1409|      0|        }
 1410|      4|        if (envconfpath == NULL) {
  ------------------
  |  Branch (1410:13): [True: 4, False: 0]
  ------------------
 1411|       |            /*
 1412|       |             * read just the config files (no persistent stuff), since
 1413|       |             * persistent path can change via conf file. Then get the
 1414|       |             * current persistent directory, and read files there.
 1415|       |             */
 1416|      4|            if ( read_config_files_in_path(confpath, ctmp, when, perspath,
  ------------------
  |  Branch (1416:18): [True: 0, False: 4]
  ------------------
 1417|      4|                                      persfile) == SNMPERR_SUCCESS )
  ------------------
  |  |  217|      4|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 1418|      0|                ret = SNMPERR_SUCCESS;
  ------------------
  |  |  217|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 1419|      4|            free(perspath);
 1420|      4|            perspath = strdup(get_persistent_directory());
 1421|      4|            if (perspath == NULL) {
  ------------------
  |  Branch (1421:17): [True: 0, False: 4]
  ------------------
 1422|      0|                return SNMPERR_GENERR;
  ------------------
  |  |  218|      0|#define SNMPERR_GENERR			(-1)
  ------------------
 1423|      0|            }
 1424|      4|            if ( read_config_files_in_path(perspath, ctmp, when, perspath,
  ------------------
  |  Branch (1424:18): [True: 0, False: 4]
  ------------------
 1425|      4|                                      persfile) == SNMPERR_SUCCESS )
  ------------------
  |  |  217|      4|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 1426|      0|                ret = SNMPERR_SUCCESS;
  ------------------
  |  |  217|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 1427|      4|        }
 1428|      0|        else {
 1429|       |            /*
 1430|       |             * only read path specified by user
 1431|       |             */
 1432|      0|            if ( read_config_files_in_path(envconfpath, ctmp, when, perspath,
  ------------------
  |  Branch (1432:18): [True: 0, False: 0]
  ------------------
 1433|      0|                                      persfile) == SNMPERR_SUCCESS )
  ------------------
  |  |  217|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 1434|      0|                ret = SNMPERR_SUCCESS;
  ------------------
  |  |  217|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 1435|      0|        }
 1436|      4|        free(perspath);
 1437|      4|        return ret;
 1438|      4|}
read_config_files:
 1446|      2|read_config_files(int when) {
 1447|       |
 1448|      2|    struct config_files *ctmp = config_files;
 1449|      2|    int                  ret  = SNMPERR_GENERR;
  ------------------
  |  |  218|      2|#define SNMPERR_GENERR			(-1)
  ------------------
 1450|       |
 1451|      2|    config_errors = 0;
 1452|       |
 1453|      2|    if (when == PREMIB_CONFIG)
  ------------------
  |  |   15|      2|#define PREMIB_CONFIG 1
  ------------------
  |  Branch (1453:9): [True: 1, False: 1]
  ------------------
 1454|      1|        free_config();
 1455|       |
 1456|       |    /*
 1457|       |     * read all config file types 
 1458|       |     */
 1459|      6|    for (; ctmp != NULL; ctmp = ctmp->next) {
  ------------------
  |  Branch (1459:12): [True: 4, False: 2]
  ------------------
 1460|      4|        if ( read_config_files_of_type(when, ctmp) == SNMPERR_SUCCESS )
  ------------------
  |  |  217|      4|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  |  Branch (1460:14): [True: 0, False: 4]
  ------------------
 1461|      0|            ret = SNMPERR_SUCCESS;
  ------------------
  |  |  217|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 1462|      4|    }
 1463|       |
 1464|      2|    if (config_errors) {
  ------------------
  |  Branch (1464:9): [True: 0, False: 2]
  ------------------
 1465|      0|        snmp_log(LOG_ERR, "net-snmp: %d error(s) in config file(s)\n",
 1466|      0|                 config_errors);
 1467|      0|    }
 1468|      2|    return ret;
 1469|      2|}
skip_white_const:
 1786|      4|{
 1787|      4|    if (ptr == NULL)
  ------------------
  |  Branch (1787:9): [True: 0, False: 4]
  ------------------
 1788|      0|        return (NULL);
 1789|      6|    while (*ptr != 0 && isspace((unsigned char)*ptr))
  ------------------
  |  Branch (1789:12): [True: 4, False: 2]
  ------------------
 1790|      2|        ptr++;
 1791|      4|    if (*ptr == 0 || *ptr == '#')
  ------------------
  |  Branch (1791:9): [True: 2, False: 2]
  |  Branch (1791:22): [True: 0, False: 2]
  ------------------
 1792|      2|        return (NULL);
 1793|      2|    return (ptr);
 1794|      4|}
copy_nword_const:
 1851|      4|{
 1852|      4|    char            quote;
 1853|      4|    if (!from || !to)
  ------------------
  |  Branch (1853:9): [True: 0, False: 4]
  |  Branch (1853:18): [True: 0, False: 4]
  ------------------
 1854|      0|        return NULL;
 1855|      4|    if ((*from == '\"') || (*from == '\'')) {
  ------------------
  |  Branch (1855:9): [True: 0, False: 4]
  |  Branch (1855:28): [True: 0, False: 4]
  ------------------
 1856|      0|        quote = *(from++);
 1857|      0|        while ((*from != quote) && (*from != 0)) {
  ------------------
  |  Branch (1857:16): [True: 0, False: 0]
  |  Branch (1857:36): [True: 0, False: 0]
  ------------------
 1858|      0|            if ((*from == '\\') && (*(from + 1) != 0)) {
  ------------------
  |  Branch (1858:17): [True: 0, False: 0]
  |  Branch (1858:36): [True: 0, False: 0]
  ------------------
 1859|      0|                if (len > 0) {  /* don't copy beyond len bytes */
  ------------------
  |  Branch (1859:21): [True: 0, False: 0]
  ------------------
 1860|      0|                    *to++ = *(from + 1);
 1861|      0|                    if (--len == 0)
  ------------------
  |  Branch (1861:25): [True: 0, False: 0]
  ------------------
 1862|      0|                        *(to - 1) = '\0';       /* null protect the last spot */
 1863|      0|                }
 1864|      0|                from = from + 2;
 1865|      0|            } else {
 1866|      0|                if (len > 0) {  /* don't copy beyond len bytes */
  ------------------
  |  Branch (1866:21): [True: 0, False: 0]
  ------------------
 1867|      0|                    *to++ = *from++;
 1868|      0|                    if (--len == 0)
  ------------------
  |  Branch (1868:25): [True: 0, False: 0]
  ------------------
 1869|      0|                        *(to - 1) = '\0';       /* null protect the last spot */
 1870|      0|                } else
 1871|      0|                    from++;
 1872|      0|            }
 1873|      0|        }
 1874|      0|        if (*from == 0) {
  ------------------
  |  Branch (1874:13): [True: 0, False: 0]
  ------------------
 1875|      0|            DEBUGMSGTL(("read_config_copy_word",
  ------------------
  |  |   68|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1876|      0|                        "no end quote found in config string\n"));
 1877|      0|        } else
 1878|      0|            from++;
 1879|      4|    } else {
 1880|     18|        while (*from != 0 && !isspace((unsigned char)(*from))) {
  ------------------
  |  Branch (1880:16): [True: 16, False: 2]
  |  Branch (1880:30): [True: 14, False: 2]
  ------------------
 1881|     14|            if ((*from == '\\') && (*(from + 1) != 0)) {
  ------------------
  |  Branch (1881:17): [True: 0, False: 14]
  |  Branch (1881:36): [True: 0, False: 0]
  ------------------
 1882|      0|                if (len > 0) {  /* don't copy beyond len bytes */
  ------------------
  |  Branch (1882:21): [True: 0, False: 0]
  ------------------
 1883|      0|                    *to++ = *(from + 1);
 1884|      0|                    if (--len == 0)
  ------------------
  |  Branch (1884:25): [True: 0, False: 0]
  ------------------
 1885|      0|                        *(to - 1) = '\0';       /* null protect the last spot */
 1886|      0|                }
 1887|      0|                from = from + 2;
 1888|     14|            } else {
 1889|     14|                if (len > 0) {  /* don't copy beyond len bytes */
  ------------------
  |  Branch (1889:21): [True: 14, False: 0]
  ------------------
 1890|     14|                    *to++ = *from++;
 1891|     14|                    if (--len == 0)
  ------------------
  |  Branch (1891:25): [True: 0, False: 14]
  ------------------
 1892|      0|                        *(to - 1) = '\0';       /* null protect the last spot */
 1893|     14|                } else
 1894|      0|                    from++;
 1895|     14|            }
 1896|     14|        }
 1897|      4|    }
 1898|      4|    if (len > 0)
  ------------------
  |  Branch (1898:9): [True: 4, False: 0]
  ------------------
 1899|      4|        *to = 0;
 1900|      4|    from = skip_white_const(from);
 1901|      4|    return (from);
 1902|      4|}                               /* copy_nword */
read_config.c:internal_register_config_handler:
  151|    103|{
  152|    103|    struct config_files **ctmp = &config_files;
  153|    103|    struct config_line  **ltmp;
  154|    103|    const char           *type = type_param;
  155|       |
  156|    103|    if (type == NULL || *type == '\0') {
  ------------------
  |  Branch (156:9): [True: 2, False: 101]
  |  Branch (156:25): [True: 2, False: 99]
  ------------------
  157|      4|        type = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|      4|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  158|      4|				     NETSNMP_DS_LIB_APPTYPE);
  ------------------
  |  |  157|      4|#define NETSNMP_DS_LIB_APPTYPE           6
  ------------------
  159|      4|    }
  160|       |
  161|       |    /*
  162|       |     * Handle multiple types (recursively)
  163|       |     */
  164|    103|    if (strchr(type, ':')) {
  ------------------
  |  Branch (164:9): [True: 2, False: 101]
  ------------------
  165|      2|        struct config_line *ltmp2 = NULL;
  166|      2|        char                buf[STRINGMAX];
  167|      2|        char               *cptr = buf;
  168|       |
  169|      2|        strlcpy(buf, type, STRINGMAX);
  ------------------
  |  |   12|      2|#define STRINGMAX 1024
  ------------------
  170|      6|        while (cptr) {
  ------------------
  |  Branch (170:16): [True: 4, False: 2]
  ------------------
  171|      4|            char* c = cptr;
  172|      4|            cptr = strchr(cptr, ':');
  173|      4|            if(cptr) {
  ------------------
  |  Branch (173:16): [True: 2, False: 2]
  ------------------
  174|      2|                *cptr = '\0';
  175|      2|                ++cptr;
  176|      2|            }
  177|      4|            ltmp2 = internal_register_config_handler(c, token, parser,
  178|      4|                                                     releaser, help, when);
  179|      4|        }
  180|      2|        return ltmp2;
  181|      2|    }
  182|       |    
  183|       |    /*
  184|       |     * Find type in current list  -OR-  create a new file type.
  185|       |     */
  186|    118|    while (*ctmp != NULL && strcmp((*ctmp)->fileHeader, type)) {
  ------------------
  |  Branch (186:12): [True: 116, False: 2]
  |  Branch (186:29): [True: 17, False: 99]
  ------------------
  187|     17|        ctmp = &((*ctmp)->next);
  188|     17|    }
  189|       |
  190|    101|    if (*ctmp == NULL) {
  ------------------
  |  Branch (190:9): [True: 2, False: 99]
  ------------------
  191|      2|        *ctmp = (struct config_files *)
  192|      2|            calloc(1, sizeof(struct config_files));
  193|      2|        if (!*ctmp) {
  ------------------
  |  Branch (193:13): [True: 0, False: 2]
  ------------------
  194|      0|            return NULL;
  195|      0|        }
  196|       |
  197|      2|        (*ctmp)->fileHeader = strdup(type);
  198|      2|        if (!(*ctmp)->fileHeader) {
  ------------------
  |  Branch (198:13): [True: 0, False: 2]
  ------------------
  199|      0|            free(*ctmp);
  200|      0|            *ctmp = NULL;
  201|      0|            return NULL;
  202|      0|        }
  203|      2|        DEBUGMSGTL(("9:read_config:type", "new type %s\n", type));
  ------------------
  |  |   68|      2|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      2|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 1, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      1|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      1|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      1|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      1|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
  204|      2|    }
  205|       |
  206|    101|    DEBUGMSGTL(("9:read_config:register_handler", "registering %s %s\n",
  ------------------
  |  |   68|    101|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|    101|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 91, False: 10]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|     91|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|     91|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|     91|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|     91|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
  207|    101|                type, token));
  208|       |    /*
  209|       |     * Find parser type in current list  -OR-  create a new
  210|       |     * line parser entry.
  211|       |     */
  212|    101|    ltmp = &((*ctmp)->start);
  213|       |
  214|  3.72k|    while (*ltmp != NULL && strcmp((*ltmp)->config_token, token)) {
  ------------------
  |  Branch (214:12): [True: 3.62k, False: 101]
  |  Branch (214:29): [True: 3.62k, False: 0]
  ------------------
  215|  3.62k|        ltmp = &((*ltmp)->next);
  216|  3.62k|    }
  217|       |
  218|    101|    if (*ltmp == NULL) {
  ------------------
  |  Branch (218:9): [True: 101, False: 0]
  ------------------
  219|    101|        *ltmp = (struct config_line *)
  220|    101|            calloc(1, sizeof(struct config_line));
  221|    101|        if (!*ltmp) {
  ------------------
  |  Branch (221:13): [True: 0, False: 101]
  ------------------
  222|      0|            return NULL;
  223|      0|        }
  224|       |
  225|    101|        (*ltmp)->config_time = when;
  226|    101|        (*ltmp)->config_token = strdup(token);
  227|    101|        if (!(*ltmp)->config_token) {
  ------------------
  |  Branch (227:13): [True: 0, False: 101]
  ------------------
  228|      0|            free(*ltmp);
  229|      0|            *ltmp = NULL;
  230|      0|            return NULL;
  231|      0|        }
  232|       |
  233|    101|        if (help != NULL)
  ------------------
  |  Branch (233:13): [True: 89, False: 12]
  ------------------
  234|     89|            (*ltmp)->help = strdup(help);
  235|    101|    }
  236|       |
  237|       |    /*
  238|       |     * Add/Replace the parse/free functions for the given line type
  239|       |     * in the given file type.
  240|       |     */
  241|    101|    (*ltmp)->parse_line = parser;
  242|    101|    (*ltmp)->free_func = releaser;
  243|       |
  244|    101|    return (*ltmp);
  245|       |
  246|    101|}                               /* end register_config_handler() */
read_config.c:read_config_files_in_path:
 1244|      8|{
 1245|      8|    int             done, j;
 1246|      8|    char            configfile[300];
 1247|      8|    char           *cptr1, *cptr2, *envconfpath;
 1248|      8|    struct stat     statbuf;
 1249|      8|    int             ret = SNMPERR_GENERR;
  ------------------
  |  |  218|      8|#define SNMPERR_GENERR			(-1)
  ------------------
 1250|       |
 1251|      8|    if ((NULL == path) || (NULL == ctmp))
  ------------------
  |  Branch (1251:9): [True: 0, False: 8]
  |  Branch (1251:27): [True: 0, False: 8]
  ------------------
 1252|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  218|      0|#define SNMPERR_GENERR			(-1)
  ------------------
 1253|       |
 1254|      8|    envconfpath = strdup(path);
 1255|      8|    if (NULL == envconfpath) {
  ------------------
  |  Branch (1255:9): [True: 0, False: 8]
  ------------------
 1256|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  218|      0|#define SNMPERR_GENERR			(-1)
  ------------------
 1257|      0|    }
 1258|       |
 1259|      8|    DEBUGMSGTL(("read_config:path", " config path used for %s:%s (persistent path:%s)\n",
  ------------------
  |  |   68|      8|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      8|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 8, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      8|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      8|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      8|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      8|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1260|      8|                ctmp->fileHeader, envconfpath, perspath));
 1261|      8|    cptr1 = cptr2 = envconfpath;
 1262|      8|    done = 0;
 1263|     24|    while ((!done) && (*cptr2 != 0)) {
  ------------------
  |  Branch (1263:12): [True: 20, False: 4]
  |  Branch (1263:23): [True: 20, False: 0]
  ------------------
 1264|    544|        while (*cptr1 != 0 && *cptr1 != ENV_SEPARATOR_CHAR)
  ------------------
  |  |   70|    536|#define ENV_SEPARATOR_CHAR ':'
  ------------------
  |  Branch (1264:16): [True: 536, False: 8]
  |  Branch (1264:31): [True: 524, False: 12]
  ------------------
 1265|    524|            cptr1++;
 1266|     20|        if (*cptr1 == 0)
  ------------------
  |  Branch (1266:13): [True: 8, False: 12]
  ------------------
 1267|      8|            done = 1;
 1268|     12|        else
 1269|     12|            *cptr1 = 0;
 1270|       |
 1271|     20|        DEBUGMSGTL(("read_config:dir", " config dir: %s\n", cptr2 ));
  ------------------
  |  |   68|     20|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|     20|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 20, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|     20|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|     20|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|     20|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|     20|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1272|     20|        if (stat(cptr2, &statbuf) != 0) {
  ------------------
  |  Branch (1272:13): [True: 16, False: 4]
  ------------------
 1273|       |            /*
 1274|       |             * Directory not there, continue 
 1275|       |             */
 1276|     16|            DEBUGMSGTL(("read_config:dir", " Directory not present: %s\n", cptr2 ));
  ------------------
  |  |   68|     16|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|     16|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 16, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|     16|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|     16|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|     16|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|     16|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1277|     16|            cptr2 = ++cptr1;
 1278|     16|            continue;
 1279|     16|        }
 1280|      4|#ifdef S_ISDIR
 1281|      4|        if (!S_ISDIR(statbuf.st_mode)) {
  ------------------
  |  Branch (1281:13): [True: 0, False: 4]
  ------------------
 1282|       |            /*
 1283|       |             * Not a directory, continue 
 1284|       |             */
 1285|      0|            DEBUGMSGTL(("read_config:dir", " Not a directory: %s\n", cptr2 ));
  ------------------
  |  |   68|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1286|      0|            cptr2 = ++cptr1;
 1287|      0|            continue;
 1288|      0|        }
 1289|      4|#endif
 1290|       |
 1291|       |        /*
 1292|       |         * for proper persistent storage retrieval, we need to read old backup
 1293|       |         * copies of the previous storage files.  If the application in
 1294|       |         * question has died without the proper call to snmp_clean_persistent,
 1295|       |         * then we read all the configuration files we can, starting with
 1296|       |         * the oldest first.
 1297|       |         */
 1298|      4|        if (strncmp(cptr2, perspath, strlen(perspath)) == 0 ||
  ------------------
  |  Branch (1298:13): [True: 4, False: 0]
  ------------------
 1299|      4|            (persfile != NULL &&
  ------------------
  |  Branch (1299:14): [True: 0, False: 0]
  ------------------
 1300|      4|             strncmp(cptr2, persfile, strlen(persfile)) == 0)) {
  ------------------
  |  Branch (1300:14): [True: 0, False: 0]
  ------------------
 1301|      4|            DEBUGMSGTL(("read_config:persist", " persist dir: %s\n", cptr2 ));
  ------------------
  |  |   68|      4|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      4|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 4, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      4|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      4|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      4|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      4|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1302|       |            /*
 1303|       |             * limit this to the known storage directory only 
 1304|       |             */
 1305|      4|            for (j = 0; j <= NETSNMP_MAX_PERSISTENT_BACKUPS; j++) {
  ------------------
  |  | 1991|      4|#define NETSNMP_MAX_PERSISTENT_BACKUPS 10
  ------------------
  |  Branch (1305:25): [True: 4, False: 0]
  ------------------
 1306|      4|                snprintf(configfile, sizeof(configfile),
 1307|      4|                         "%s/%s.%d.conf", cptr2,
 1308|      4|                         ctmp->fileHeader, j);
 1309|      4|                configfile[ sizeof(configfile)-1 ] = 0;
 1310|      4|                if (stat(configfile, &statbuf) != 0) {
  ------------------
  |  Branch (1310:21): [True: 4, False: 0]
  ------------------
 1311|       |                    /*
 1312|       |                     * file not there, continue 
 1313|       |                     */
 1314|      4|                    break;
 1315|      4|                } else {
 1316|       |                    /*
 1317|       |                     * backup exists, read it 
 1318|       |                     */
 1319|      0|                    DEBUGMSGTL(("read_config_files",
  ------------------
  |  |   68|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1320|      0|                                "old config file found: %s, parsing\n",
 1321|      0|                                configfile));
 1322|      0|                    if (read_config(configfile, ctmp->start, when) == SNMPERR_SUCCESS)
  ------------------
  |  |  217|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  |  Branch (1322:25): [True: 0, False: 0]
  ------------------
 1323|      0|                        ret = SNMPERR_SUCCESS;
  ------------------
  |  |  217|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 1324|      0|                }
 1325|      4|            }
 1326|      4|        }
 1327|      4|        snprintf(configfile, sizeof(configfile),
 1328|      4|                 "%s/%s.conf", cptr2, ctmp->fileHeader);
 1329|      4|        configfile[ sizeof(configfile)-1 ] = 0;
 1330|      4|        if (read_config(configfile, ctmp->start, when) == SNMPERR_SUCCESS)
  ------------------
  |  |  217|      4|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  |  Branch (1330:13): [True: 0, False: 4]
  ------------------
 1331|      0|            ret = SNMPERR_SUCCESS;
  ------------------
  |  |  217|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 1332|      4|        snprintf(configfile, sizeof(configfile),
 1333|      4|                 "%s/%s.local.conf", cptr2, ctmp->fileHeader);
 1334|      4|        configfile[ sizeof(configfile)-1 ] = 0;
 1335|      4|        if (read_config(configfile, ctmp->start, when) == SNMPERR_SUCCESS)
  ------------------
  |  |  217|      4|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  |  Branch (1335:13): [True: 0, False: 4]
  ------------------
 1336|      0|            ret = SNMPERR_SUCCESS;
  ------------------
  |  |  217|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 1337|       |
 1338|      4|        if(done)
  ------------------
  |  Branch (1338:12): [True: 4, False: 0]
  ------------------
 1339|      4|            break;
 1340|       |
 1341|      0|        cptr2 = ++cptr1;
 1342|      0|    }
 1343|      8|    SNMP_FREE(envconfpath);
  ------------------
  |  |   62|      8|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 8, False: 0]
  |  |  |  Branch (62:66): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1344|      8|    return ret;
 1345|      8|}

sc_find_auth_alg_byoid:
  266|      2|{
  267|      2|    int i = 0;
  268|       |
  269|      2|    DEBUGTRACE;
  ------------------
  |  |   65|      2|#define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
  |  |  ------------------
  |  |  |  |  146|      2|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 2, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
  |  |  ------------------
  |  |  |  |  156|      2|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  ------------------
  |  |  |  |  |  |  149|      2|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  157|      2|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  ------------------
  |  |  |  Branch (65:67): [Folded - Ignored]
  |  |  ------------------
  ------------------
  270|       |
  271|      2|    if ((NULL == authoid) || (0 == len))
  ------------------
  |  Branch (271:9): [True: 0, False: 2]
  |  Branch (271:30): [True: 0, False: 2]
  ------------------
  272|      0|        return NULL;
  273|       |
  274|      6|    for( ; _auth_alg_info[i].type != -1; ++i) {
  ------------------
  |  Branch (274:12): [True: 6, False: 0]
  ------------------
  275|      6|        if (len != _auth_alg_info[i].oid_len)
  ------------------
  |  Branch (275:13): [True: 0, False: 6]
  ------------------
  276|      0|            continue;
  277|      6|        if (snmp_oid_compare(_auth_alg_info[i].alg_oid,
  ------------------
  |  Branch (277:13): [True: 2, False: 4]
  ------------------
  278|      6|                             _auth_alg_info[i].oid_len,
  279|      6|                             authoid, len) == 0 )
  280|      2|            return(&_auth_alg_info[i]);
  281|      6|    }
  282|       |
  283|       |/*    DEBUGMSGTL(("scapi", "No auth alg found for"));
  284|       |      DEBUGMSGOID(("scapi", authoid, len ));*/
  285|       |
  286|      0|    return NULL;
  287|      2|}
sc_find_auth_alg_bytype:
  313|      2|{
  314|      2|    int i = 0;
  315|       |
  316|      2|    DEBUGTRACE;
  ------------------
  |  |   65|      2|#define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
  |  |  ------------------
  |  |  |  |  146|      2|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 2, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
  |  |  ------------------
  |  |  |  |  156|      2|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  ------------------
  |  |  |  |  |  |  149|      2|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  157|      2|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  ------------------
  |  |  |  Branch (65:67): [Folded - Ignored]
  |  |  ------------------
  ------------------
  317|       |
  318|      6|    for( ; _auth_alg_info[i].type != -1; ++i) {
  ------------------
  |  Branch (318:12): [True: 6, False: 0]
  ------------------
  319|      6|        if (type != _auth_alg_info[i].type)
  ------------------
  |  Branch (319:13): [True: 4, False: 2]
  ------------------
  320|      4|            continue;
  321|      2|        return(&_auth_alg_info[i]);
  322|      6|    }
  323|       |
  324|      0|    return NULL;
  325|      2|}
sc_get_authtype:
  338|      2|{
  339|      2|    const netsnmp_auth_alg_info *aai;
  340|       |
  341|      2|    DEBUGTRACE;
  ------------------
  |  |   65|      2|#define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
  |  |  ------------------
  |  |  |  |  146|      2|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 2, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
  |  |  ------------------
  |  |  |  |  156|      2|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  ------------------
  |  |  |  |  |  |  149|      2|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  157|      2|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  ------------------
  |  |  |  Branch (65:67): [Folded - Ignored]
  |  |  ------------------
  ------------------
  342|       |
  343|      2|    aai = sc_find_auth_alg_byoid(hashtype, hashtype_len);
  344|      2|    if (NULL == aai)
  ------------------
  |  Branch (344:9): [True: 0, False: 2]
  ------------------
  345|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  218|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  346|       |
  347|      2|    return aai->type;
  348|      2|}
sc_get_proper_auth_length_bytype:
  395|      2|{
  396|      2|    const netsnmp_auth_alg_info *aai;
  397|       |
  398|      2|    DEBUGTRACE;
  ------------------
  |  |   65|      2|#define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
  |  |  ------------------
  |  |  |  |  146|      2|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 2, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
  |  |  ------------------
  |  |  |  |  156|      2|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  ------------------
  |  |  |  |  |  |  149|      2|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  157|      2|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  ------------------
  |  |  |  Branch (65:67): [Folded - Ignored]
  |  |  ------------------
  ------------------
  399|       |
  400|      2|    aai = sc_find_auth_alg_bytype(hashtype);
  401|      2|    if (NULL == aai)
  ------------------
  |  Branch (401:9): [True: 0, False: 2]
  ------------------
  402|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  218|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  403|       |
  404|      2|    return aai->proper_length;
  405|      2|}
sc_init:
  546|      1|{
  547|      1|    int             rval = SNMPERR_SUCCESS;
  ------------------
  |  |  217|      1|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  548|       |
  549|       |#if !defined(NETSNMP_USE_OPENSSL)
  550|       |#if defined(NETSNMP_USE_INTERNAL_MD5) || defined(NETSNMP_USE_INTERNAL_CRYPTO)
  551|       |    struct timeval  tv;
  552|       |
  553|       |    DEBUGTRACE;
  554|       |
  555|       |    gettimeofday(&tv, (struct timezone *) 0);
  556|       |
  557|       |    netsnmp_srandom((unsigned)(tv.tv_sec ^ tv.tv_usec));
  558|       |#elif defined(NETSNMP_USE_PKCS11)
  559|       |    DEBUGTRACE;
  560|       |    rval = pkcs_init();
  561|       |#else
  562|       |    rval = SNMPERR_SC_NOT_CONFIGURED;
  563|       |#endif                           /* NETSNMP_USE_INTERNAL_MD5 */
  564|       |    /*
  565|       |     * XXX ogud: The only reason to do anything here with openssl is to 
  566|       |     * * XXX ogud: seed random number generator 
  567|       |     */
  568|       |#endif                          /* ifndef NETSNMP_USE_OPENSSL */
  569|       |
  570|      1|    return rval;
  571|      1|}                               /* end sc_init() */
sc_random:
  586|      3|{
  587|      3|    int             rval = SNMPERR_SUCCESS;
  ------------------
  |  |  217|      3|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  588|       |#if !defined(NETSNMP_USE_OPENSSL) && !defined(NETSNMP_USE_PKCS11)
  589|       |    int             i;
  590|       |    int             rndval;
  591|       |    u_char         *ucp = buf;
  592|       |#endif
  593|       |
  594|      3|    DEBUGTRACE;
  ------------------
  |  |   65|      3|#define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
  |  |  ------------------
  |  |  |  |  146|      3|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 3, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
  |  |  ------------------
  |  |  |  |  156|      3|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  ------------------
  |  |  |  |  |  |  149|      3|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  157|      3|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  ------------------
  |  |  |  Branch (65:67): [Folded - Ignored]
  |  |  ------------------
  ------------------
  595|       |
  596|      3|#ifdef NETSNMP_USE_OPENSSL
  597|      3|    RAND_bytes(buf, *buflen);   /* will never fail */
  598|      3|    MAKE_MEM_DEFINED(buf, *buflen);
  ------------------
  |  |    8|      3|#define MAKE_MEM_DEFINED(ptr, len) do { } while (0)
  |  |  ------------------
  |  |  |  Branch (8:50): [Folded - Ignored]
  |  |  ------------------
  ------------------
  599|       |#elif defined(NETSNMP_USE_PKCS11)  /* NETSNMP_USE_PKCS11 */
  600|       |    pkcs_random(buf, *buflen);
  601|       |#else                           /* NETSNMP_USE_INTERNAL_MD5 */
  602|       |    /*
  603|       |     * fill the buffer with random integers.  Note that random()
  604|       |     * is defined in config.h and may not be truly the random()
  605|       |     * system call if something better existed 
  606|       |     */
  607|       |    rval = *buflen - *buflen % sizeof(rndval);
  608|       |    for (i = 0; i < rval; i += sizeof(rndval)) {
  609|       |        rndval = netsnmp_random();
  610|       |        memcpy(ucp, &rndval, sizeof(rndval));
  611|       |        ucp += sizeof(rndval);
  612|       |    }
  613|       |
  614|       |    rndval = netsnmp_random();
  615|       |    memcpy(ucp, &rndval, *buflen % sizeof(rndval));
  616|       |
  617|       |    rval = SNMPERR_SUCCESS;
  618|       |#endif                          /* NETSNMP_USE_OPENSSL */
  619|      3|    return rval;
  620|       |
  621|      3|}                               /* end sc_random() */
sc_get_openssl_hashfn:
  631|      2|{
  632|      2|    const EVP_MD   *hashfn = NULL;
  633|       |
  634|      2|    DEBUGTRACE;
  ------------------
  |  |   65|      2|#define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
  |  |  ------------------
  |  |  |  |  146|      2|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 2, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
  |  |  ------------------
  |  |  |  |  156|      2|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  ------------------
  |  |  |  |  |  |  149|      2|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  157|      2|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  ------------------
  |  |  |  Branch (65:67): [Folded - Ignored]
  |  |  ------------------
  ------------------
  635|       |
  636|      2|    switch (auth_type) {
  ------------------
  |  Branch (636:13): [True: 0, False: 2]
  ------------------
  637|      0|#ifndef NETSNMP_DISABLE_MD5
  638|      2|        case NETSNMP_USMAUTH_HMACMD5:
  ------------------
  |  |   21|      2|#define NETSNMP_USMAUTH_HMACMD5           2
  ------------------
  |  Branch (638:9): [True: 2, False: 0]
  ------------------
  639|      2|            hashfn = (const EVP_MD *) EVP_md5();
  640|      2|            break;
  641|      0|#endif
  642|      0|        case NETSNMP_USMAUTH_HMACSHA1:
  ------------------
  |  |   22|      0|#define NETSNMP_USMAUTH_HMACSHA1          3
  ------------------
  |  Branch (642:9): [True: 0, False: 2]
  ------------------
  643|      0|            hashfn = (const EVP_MD *) EVP_sha1();
  644|      0|            break;
  645|       |
  646|      0|#ifdef HAVE_EVP_SHA224
  647|      0|        case NETSNMP_USMAUTH_HMAC128SHA224:
  ------------------
  |  |   24|      0|#define NETSNMP_USMAUTH_HMAC128SHA224     4 /* RFC 7860; OPTIONAL */
  ------------------
  |  Branch (647:9): [True: 0, False: 2]
  ------------------
  648|      0|            hashfn = (const EVP_MD *) EVP_sha224();
  649|      0|            break;
  650|       |
  651|      0|        case NETSNMP_USMAUTH_HMAC192SHA256:
  ------------------
  |  |   25|      0|#define NETSNMP_USMAUTH_HMAC192SHA256     5 /* RFC 7860; MUST */
  ------------------
  |  Branch (651:9): [True: 0, False: 2]
  ------------------
  652|      0|            hashfn = (const EVP_MD *) EVP_sha256();
  653|      0|            break;
  654|      0|#endif /* HAVE_EVP_SHA224 */
  655|       |
  656|      0|#ifdef HAVE_EVP_SHA384
  657|      0|        case NETSNMP_USMAUTH_HMAC256SHA384:
  ------------------
  |  |   26|      0|#define NETSNMP_USMAUTH_HMAC256SHA384     6 /* RFC 7860; OPTIONAL */
  ------------------
  |  Branch (657:9): [True: 0, False: 2]
  ------------------
  658|      0|            hashfn = (const EVP_MD *) EVP_sha384();
  659|      0|            break;
  660|       |
  661|      0|        case NETSNMP_USMAUTH_HMAC384SHA512:
  ------------------
  |  |   27|      0|#define NETSNMP_USMAUTH_HMAC384SHA512     7 /* RFC 7860; SHOULD */
  ------------------
  |  Branch (661:9): [True: 0, False: 2]
  ------------------
  662|      0|            hashfn = (const EVP_MD *) EVP_sha512();
  663|      0|            break;
  664|      2|#endif /* HAVE_EVP_SHA384 */
  665|      2|    }
  666|       |
  667|      2|    return hashfn;
  668|      2|}
sc_hash:
  886|      2|{
  887|      2|    int auth_type;
  888|       |
  889|      2|    DEBUGTRACE;
  ------------------
  |  |   65|      2|#define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
  |  |  ------------------
  |  |  |  |  146|      2|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 2, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
  |  |  ------------------
  |  |  |  |  156|      2|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  ------------------
  |  |  |  |  |  |  149|      2|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  157|      2|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  ------------------
  |  |  |  Branch (65:67): [Folded - Ignored]
  |  |  ------------------
  ------------------
  890|       |
  891|      2|    if (hashtype == NULL)
  ------------------
  |  Branch (891:9): [True: 0, False: 2]
  ------------------
  892|      0|        return (SNMPERR_GENERR);
  ------------------
  |  |  218|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  893|       |
  894|      2|    auth_type = sc_get_authtype(hashtype, hashtypelen);
  895|      2|    if (auth_type < 0 )
  ------------------
  |  Branch (895:9): [True: 0, False: 2]
  ------------------
  896|      0|        return (SNMPERR_GENERR);
  ------------------
  |  |  218|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  897|       |
  898|      2|    return sc_hash_type(auth_type, buf, buf_len, MAC, MAC_len);
  899|      2|}
sc_hash_type:
  925|      2|{
  926|      2|#if defined(NETSNMP_USE_OPENSSL) || defined(NETSNMP_USE_PKCS11) || defined(NETSNMP_USE_INTERNAL_CRYPTO)
  927|      2|    int            rval = SNMPERR_SUCCESS;
  ------------------
  |  |  217|      2|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  928|      2|#endif
  929|      2|#if defined(NETSNMP_USE_OPENSSL) || defined(NETSNMP_USE_PKCS11)
  930|      2|    unsigned int   tmp_len;
  931|      2|#endif
  932|      2|    int            ret;
  933|       |
  934|      2|#ifdef NETSNMP_USE_OPENSSL
  935|      2|    const EVP_MD   *hashfn;
  936|      2|    EVP_MD_CTX     *cptr;
  937|      2|#endif
  938|       |#ifdef NETSNMP_USE_INTERNAL_CRYPTO
  939|       |    MD5_CTX        cmd5;
  940|       |    SHA_CTX        csha1;
  941|       |#endif
  942|      2|    DEBUGTRACE;
  ------------------
  |  |   65|      2|#define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
  |  |  ------------------
  |  |  |  |  146|      2|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 2, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
  |  |  ------------------
  |  |  |  |  156|      2|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  ------------------
  |  |  |  |  |  |  149|      2|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  157|      2|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  ------------------
  |  |  |  Branch (65:67): [Folded - Ignored]
  |  |  ------------------
  ------------------
  943|       |
  944|      2|    if (buf == NULL || buf_len <= 0 || MAC == NULL || MAC_len == NULL )
  ------------------
  |  Branch (944:9): [True: 0, False: 2]
  |  Branch (944:24): [True: 0, False: 2]
  |  Branch (944:40): [True: 0, False: 2]
  |  Branch (944:55): [True: 0, False: 2]
  ------------------
  945|      0|        return (SNMPERR_GENERR);
  ------------------
  |  |  218|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  946|       |
  947|      2|    ret = sc_get_proper_auth_length_bytype(auth_type);
  948|      2|    if (( ret < 0 ) || (*MAC_len < (size_t)ret ))
  ------------------
  |  Branch (948:9): [True: 0, False: 2]
  |  Branch (948:24): [True: 0, False: 2]
  ------------------
  949|      0|        return (SNMPERR_GENERR);
  ------------------
  |  |  218|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  950|       |
  951|      2|#ifdef NETSNMP_USE_OPENSSL
  952|       |    /*
  953|       |     * Determine transform type.
  954|       |     */
  955|      2|    hashfn = sc_get_openssl_hashfn(auth_type);
  956|      2|    if (NULL == hashfn)
  ------------------
  |  Branch (956:9): [True: 0, False: 2]
  ------------------
  957|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  218|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  958|       |
  959|       |/** initialize the pointer */
  960|      2|#if defined(HAVE_EVP_MD_CTX_NEW)
  961|      2|    cptr = EVP_MD_CTX_new();
  962|       |#elif defined(HAVE_EVP_MD_CTX_CREATE)
  963|       |    cptr = EVP_MD_CTX_create();
  964|       |#else
  965|       |    cptr = malloc(sizeof(*cptr));
  966|       |#if defined(OLD_DES)
  967|       |    memset(cptr, 0, sizeof(*cptr));
  968|       |#else
  969|       |    EVP_MD_CTX_init(cptr);
  970|       |#endif
  971|       |#endif
  972|      2|    if (!EVP_DigestInit(cptr, hashfn)) {
  ------------------
  |  Branch (972:9): [True: 0, False: 2]
  ------------------
  973|       |        /* requested hash function is not available */
  974|      0|        rval = SNMPERR_SC_NOT_CONFIGURED;
  ------------------
  |  |  256|      0|#define SNMPERR_SC_NOT_CONFIGURED	(-39)
  ------------------
  975|      0|        goto sc_hash_type_quit;
  976|      0|    }
  977|       |
  978|       |/** pass the data */
  979|      2|    EVP_DigestUpdate(cptr, buf, buf_len);
  980|       |
  981|       |/** do the final pass */
  982|      2|    EVP_DigestFinal(cptr, MAC, &tmp_len);
  983|      2|    *MAC_len = tmp_len;
  984|       |
  985|      2|sc_hash_type_quit:
  986|      2|#if defined(HAVE_EVP_MD_CTX_FREE)
  987|      2|    EVP_MD_CTX_free(cptr);
  988|       |#elif defined(HAVE_EVP_MD_CTX_DESTROY)
  989|       |    EVP_MD_CTX_destroy(cptr);
  990|       |#else
  991|       |#if !defined(OLD_DES)
  992|       |    EVP_MD_CTX_cleanup(cptr);
  993|       |#endif
  994|       |    free(cptr);
  995|       |#endif
  996|      2|    return (rval);
  997|       |
  998|       |#elif defined(NETSNMP_USE_INTERNAL_CRYPTO)
  999|       |#ifndef NETSNMP_DISABLE_MD5
 1000|       |    if (NETSNMP_USMAUTH_HMACMD5 == auth_type) {
 1001|       |        if (*MAC_len < MD5_DIGEST_LENGTH)
 1002|       |            return (SNMPERR_GENERR);      /* the buffer isn't big enough */
 1003|       |        MD5_Init(&cmd5);
 1004|       |        MD5_Update(&cmd5, buf, buf_len);
 1005|       |        MD5_Final(MAC, &cmd5);
 1006|       |        *MAC_len = MD5_DIGEST_LENGTH;
 1007|       |    } else 
 1008|       |#endif
 1009|       |    if (NETSNMP_USMAUTH_HMACSHA1 == auth_type) {
 1010|       |        if (*MAC_len < SHA_DIGEST_LENGTH)
 1011|       |            return (SNMPERR_GENERR);      /* the buffer isn't big enough */
 1012|       |        SHA1_Init(&csha1);
 1013|       |        SHA1_Update(&csha1, buf, buf_len);
 1014|       |        SHA1_Final(MAC, &csha1);
 1015|       |        *MAC_len = SHA_DIGEST_LENGTH;
 1016|       |            
 1017|       |    } else {
 1018|       |        return (SNMPERR_GENERR);
 1019|       |    }
 1020|       |    return (rval);
 1021|       |#elif defined(NETSNMP_USE_PKCS11)        /* NETSNMP_USE_PKCS11 */
 1022|       |
 1023|       |#ifndef NETSNMP_DISABLE_MD5
 1024|       |    if (NETSNMP_USMAUTH_HMACMD5 == auth_type) {
 1025|       |        rval = pkcs_digest(CKM_MD5, buf, buf_len, MAC, &tmp_len);
 1026|       |        *MAC_len = tmp_len;
 1027|       |    } else
 1028|       |#endif
 1029|       |    if (NETSNMP_USMAUTH_HMACSHA1 == auth_type) {
 1030|       |       rval = pkcs_digest(CKM_SHA_1, buf, buf_len, MAC, &tmp_len);
 1031|       |        *MAC_len = tmp_len;
 1032|       |    } else {
 1033|       |        return (SNMPERR_GENERR);
 1034|       |    }
 1035|       |
 1036|       |     return (rval);
 1037|       |
 1038|       |#else                           /* NETSNMP_USE_INTERNAL_MD5 */
 1039|       |
 1040|       |    if (MDchecksum(buf, buf_len, MAC, *MAC_len)) {
 1041|       |        return SNMPERR_GENERR;
 1042|       |    }
 1043|       |    if (*MAC_len > 16)
 1044|       |        *MAC_len = 16;
 1045|       |    return SNMPERR_SUCCESS;
 1046|       |
 1047|       |#endif                          /* NETSNMP_USE_OPENSSL */
 1048|      2|}

snmp_parse_var_op:
  153|    771|{
  154|    771|    u_char          var_op_type;
  155|    771|    size_t          var_op_len = *listlength;
  156|    771|    u_char         *var_op_start = data;
  157|       |
  158|    771|    data = asn_parse_sequence(data, &var_op_len, &var_op_type,
  159|    771|                              (ASN_SEQUENCE | ASN_CONSTRUCTOR), "var_op");
  ------------------
  |  |   84|    771|#define ASN_SEQUENCE	    0x10U
  ------------------
                                            (ASN_SEQUENCE | ASN_CONSTRUCTOR), "var_op");
  ------------------
  |  |   96|    771|#define ASN_CONSTRUCTOR	    0x20U
  ------------------
  160|    771|    if (data == NULL) {
  ------------------
  |  Branch (160:9): [True: 314, False: 457]
  ------------------
  161|       |        /*
  162|       |         * msg detail is set 
  163|       |         */
  164|    314|        return NULL;
  165|    314|    }
  166|    457|    DEBUGDUMPHEADER("recv", "Name");
  ------------------
  |  |   81|    457|	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|    457|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 457, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  180|    457|        __DBGPRINTINDENT("dumph_" token); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  177|    457|#define __DBGPRINTINDENT(token) __DBGMSGTL((token, "%*s", __DBGINDENT(), ""))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  166|    457|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  156|    457|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  149|    457|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  157|    457|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  181|    457|        debugmsg("dumph_" token,x); \
  |  |  |  |  182|    457|        if (debug_is_token_registered("dumpx" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  217|    914|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (182:13): [True: 457, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  183|    457|            debug_is_token_registered("dumpv" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  217|    457|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  184|    457|            (debug_is_token_registered("dumpx_" token) != SNMPERR_SUCCESS &&  \
  |  |  |  |  ------------------
  |  |  |  |  |  |  217|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (184:14): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  185|    457|             debug_is_token_registered("dumpv_" token) != SNMPERR_SUCCESS)) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |  217|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (185:14): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  186|    457|            debugmsg("dumph_" token,"\n"); \
  |  |  |  |  187|    457|        } else { \
  |  |  |  |  188|      0|            debugmsg("dumph_" token,"  "); \
  |  |  |  |  189|      0|        } \
  |  |  |  |  190|    457|        __DBGINDENTMORE()
  |  |  |  |  ------------------
  |  |  |  |  |  |  175|    457|#define __DBGINDENTMORE()  debug_indent_add(2)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (81:55): [Folded - Ignored]
  |  |  ------------------
  ------------------
  167|    457|    data =
  168|    457|        asn_parse_objid(data, &var_op_len, &var_op_type, var_name,
  169|    457|                        var_name_len);
  170|    457|    DEBUGINDENTLESS();
  ------------------
  |  |   77|    457|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  146|    457|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 457, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  176|    457|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (77:74): [Folded - Ignored]
  |  |  ------------------
  ------------------
  171|    457|    if (data == NULL) {
  ------------------
  |  Branch (171:9): [True: 7, False: 450]
  ------------------
  172|      7|        ERROR_MSG("No OID for variable");
  ------------------
  |  |  190|      7|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
  173|      7|        return NULL;
  174|      7|    }
  175|    450|    if (var_op_type !=
  ------------------
  |  Branch (175:9): [True: 0, False: 450]
  ------------------
  176|    450|        (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_OBJECT_ID))
  ------------------
  |  |   90|    450|#define ASN_UNIVERSAL	    0x00U
  ------------------
                      (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_OBJECT_ID))
  ------------------
  |  |   95|    450|#define ASN_PRIMITIVE	    0x00U
  ------------------
                      (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_OBJECT_ID))
  ------------------
  |  |   81|    450|#define ASN_OBJECT_ID	    0x06U
  ------------------
  177|      0|        return NULL;
  178|    450|    *var_val = data;            /* save pointer to this object */
  179|       |    /*
  180|       |     * find out what type of object this is 
  181|       |     */
  182|    450|    data = asn_parse_header(data, &var_op_len, var_val_type);
  183|    450|    if (data == NULL) {
  ------------------
  |  Branch (183:9): [True: 2, False: 448]
  ------------------
  184|      2|        ERROR_MSG("No header for value");
  ------------------
  |  |  190|      2|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
  185|      2|        return NULL;
  186|      2|    }
  187|       |    /*
  188|       |     * XXX no check for type! 
  189|       |     */
  190|    448|    *var_val_len = var_op_len;
  191|    448|    data += var_op_len;
  192|    448|    *listlength -= (int) (data - var_op_start);
  193|    448|    return data;
  194|    450|}

init_alarm_post_config:
   63|      1|{
   64|      1|    start_alarms = 1;
   65|      1|    set_an_alarm();
   66|      1|    return SNMPERR_SUCCESS;
  ------------------
  |  |  217|      1|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
   67|      1|}
init_snmp_alarm:
   71|      1|{
   72|      1|    start_alarms = 0;
   73|      1|    snmp_register_callback(SNMP_CALLBACK_LIBRARY,
  ------------------
  |  |   18|      1|#define SNMP_CALLBACK_LIBRARY     0
  ------------------
   74|      1|                           SNMP_CALLBACK_POST_READ_CONFIG,
  ------------------
  |  |   24|      1|#define SNMP_CALLBACK_POST_READ_CONFIG	        0
  ------------------
   75|      1|                           init_alarm_post_config, NULL);
   76|      1|}
sa_find_next:
  169|      1|{
  170|      1|    struct snmp_alarm *a, *lowest = NULL;
  171|       |
  172|      1|    for (a = thealarms; a != NULL; a = a->next)
  ------------------
  |  Branch (172:25): [True: 0, False: 1]
  ------------------
  173|      0|        if (!(a->flags & SA_FIRED)
  ------------------
  |  |   29|      0|#define SA_FIRED 0x10          /* Being processed in run_alarms */
  ------------------
  |  Branch (173:13): [True: 0, False: 0]
  ------------------
  174|      0|            && (lowest == NULL || timercmp(&a->t_nextM, &lowest->t_nextM, <)))
  ------------------
  |  Branch (174:17): [True: 0, False: 0]
  ------------------
  175|      0|            lowest = a;
  176|       |
  177|      1|    return lowest;
  178|      1|}
netsnmp_get_next_alarm_time:
  253|      1|{
  254|      1|    struct snmp_alarm *sa_ptr;
  255|       |
  256|      1|    sa_ptr = sa_find_next();
  257|       |
  258|      1|    if (sa_ptr) {
  ------------------
  |  Branch (258:9): [True: 0, False: 1]
  ------------------
  259|      0|        netsnmp_assert(alarm_tm);
  ------------------
  |  |   47|      0|#      define netsnmp_assert(x)  do { \
  |  |   48|      0|              if ( x ) \
  |  |  ------------------
  |  |  |  Branch (48:20): [True: 0, False: 0]
  |  |  ------------------
  |  |   49|      0|                 ; \
  |  |   50|      0|              else \
  |  |   51|      0|                 snmp_log(LOG_ERR, \
  |  |   52|      0|                          "netsnmp_assert %s failed %s:%d" NETSNMP_FUNC_FMT, \
  |  |  ------------------
  |  |  |  |   40|      0|#          define NETSNMP_FUNC_FMT " %s()\n"
  |  |  ------------------
  |  |   53|      0|                          __STRING(x),__FILE__,__LINE__, \
  |  |   54|      0|                          NETSNMP_FUNC_PARAM); \
  |  |  ------------------
  |  |  |  |   41|      0|#          define NETSNMP_FUNC_PARAM NETSNMP_FUNCTION
  |  |  |  |  ------------------
  |  |  |  |  |  | 1681|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|      0|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded - Ignored]
  |  |  ------------------
  ------------------
  260|      0|        netsnmp_assert(timerisset(&sa_ptr->t_nextM));
  ------------------
  |  |   47|      0|#      define netsnmp_assert(x)  do { \
  |  |   48|      0|              if ( x ) \
  |  |  ------------------
  |  |  |  Branch (48:20): [True: 0, False: 0]
  |  |  |  Branch (48:20): [True: 0, False: 0]
  |  |  ------------------
  |  |   49|      0|                 ; \
  |  |   50|      0|              else \
  |  |   51|      0|                 snmp_log(LOG_ERR, \
  |  |   52|      0|                          "netsnmp_assert %s failed %s:%d" NETSNMP_FUNC_FMT, \
  |  |  ------------------
  |  |  |  |   40|      0|#          define NETSNMP_FUNC_FMT " %s()\n"
  |  |  ------------------
  |  |   53|      0|                          __STRING(x),__FILE__,__LINE__, \
  |  |   54|      0|                          NETSNMP_FUNC_PARAM); \
  |  |  ------------------
  |  |  |  |   41|      0|#          define NETSNMP_FUNC_PARAM NETSNMP_FUNCTION
  |  |  |  |  ------------------
  |  |  |  |  |  | 1681|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|      0|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded - Ignored]
  |  |  ------------------
  ------------------
  261|      0|        if (timercmp(&sa_ptr->t_nextM, now, >))
  262|      0|            *alarm_tm = sa_ptr->t_nextM;
  263|      0|        else
  264|      0|            *alarm_tm = *now;
  265|      0|        return sa_ptr->clientreg;
  266|      1|    } else {
  267|      1|        return 0;
  268|      1|    }
  269|      1|}
get_next_alarm_delay_time:
  282|      1|{
  283|      1|    struct timeval t_now, alarm_tm;
  284|      1|    int res;
  285|       |
  286|      1|    netsnmp_get_monotonic_clock(&t_now);
  287|      1|    res = netsnmp_get_next_alarm_time(&alarm_tm, &t_now);
  288|      1|    if (res)
  ------------------
  |  Branch (288:9): [True: 0, False: 1]
  ------------------
  289|      0|        NETSNMP_TIMERSUB(&alarm_tm, &t_now, delta);
  ------------------
  |  |  173|      0|#define NETSNMP_TIMERSUB(a, b, res) do {                        \
  |  |  174|      0|    (res)->tv_sec  = (a)->tv_sec  - (b)->tv_sec - 1;            \
  |  |  175|      0|    (res)->tv_usec = (a)->tv_usec - (b)->tv_usec + 1000000L;    \
  |  |  176|      0|    if ((res)->tv_usec >= 1000000L) {                           \
  |  |  ------------------
  |  |  |  Branch (176:9): [True: 0, False: 0]
  |  |  ------------------
  |  |  177|      0|        (res)->tv_usec -= 1000000L;                             \
  |  |  178|      0|        (res)->tv_sec++;                                        \
  |  |  179|      0|    }                                                           \
  |  |  180|      0|} while (0)
  |  |  ------------------
  |  |  |  Branch (180:10): [Folded - Ignored]
  |  |  ------------------
  ------------------
  290|      1|    return res;
  291|      1|}
set_an_alarm:
  296|      1|{
  297|      1|    struct timeval  delta;
  298|      1|    int             nextalarm = get_next_alarm_delay_time(&delta);
  299|       |
  300|       |    /*
  301|       |     * We don't use signals if they asked us nicely not to.  It's expected
  302|       |     * they'll check the next alarm time and do their own calling of
  303|       |     * run_alarms().  
  304|       |     */
  305|       |
  306|      1|    if (nextalarm && !netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      0|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (306:9): [True: 0, False: 1]
  |  Branch (306:22): [True: 0, False: 0]
  ------------------
  307|      0|					NETSNMP_DS_LIB_ALARM_DONT_USE_SIG)) {
  ------------------
  |  |   71|      0|#define NETSNMP_DS_LIB_ALARM_DONT_USE_SIG  11   /* don't use the alarm() signal */
  ------------------
  308|      0|#if defined(HAVE_SETITIMER)
  309|      0|        struct itimerval it;
  310|       |
  311|      0|        it.it_value = delta;
  312|      0|        timerclear(&it.it_interval);
  313|       |
  314|      0|        signal(SIGALRM, alarm_handler);
  315|      0|        setitimer(ITIMER_REAL, &it, NULL);
  316|      0|        DEBUGMSGTL(("snmp_alarm", "schedule alarm %d in %ld.%03ld seconds\n",
  ------------------
  |  |   68|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
  317|      0|                    nextalarm, (long) delta.tv_sec, (long)(delta.tv_usec / 1000)));
  318|       |#elif defined(SIGALRM)
  319|       |        signal(SIGALRM, alarm_handler);
  320|       |        alarm(delta.tv_sec);
  321|       |        DEBUGMSGTL(("snmp_alarm",
  322|       |                    "schedule alarm %d in roughly %ld seconds\n", nextalarm,
  323|       |                    delta.tv_sec));
  324|       |#endif
  325|      1|    } else {
  326|      1|        DEBUGMSGTL(("snmp_alarm", "no alarms found to schedule\n"));
  ------------------
  |  |   68|      1|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      1|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      1|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      1|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      1|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
  327|      1|    }
  328|      1|}

netsnmp_max_send_msg_size:
  360|  3.49k|{
  361|  3.49k|    u_int max = netsnmp_ds_get_int(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|  3.49k|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  362|  3.49k|                                   NETSNMP_DS_LIB_MSG_SEND_MAX);
  ------------------
  |  |  132|  3.49k|#define NETSNMP_DS_LIB_MSG_SEND_MAX        16 /* global max response size */
  ------------------
  363|  3.49k|    if (0 == max)
  ------------------
  |  Branch (363:9): [True: 3.49k, False: 0]
  ------------------
  364|  3.49k|        max = SNMP_MAX_PACKET_LEN;
  ------------------
  |  |   49|  3.49k|#define SNMP_MAX_PACKET_LEN (0x7fffffff)
  ------------------
  365|      0|    else if (max < SNMP_MIN_MAX_LEN)
  ------------------
  |  |   48|      0|#define SNMP_MIN_MAX_LEN    484 /* minimum maximum message size */
  ------------------
  |  Branch (365:14): [True: 0, False: 0]
  ------------------
  366|      0|        max = SNMP_MIN_MAX_LEN; /* minimum max size per SNMP specs */
  ------------------
  |  |   48|      0|#define SNMP_MIN_MAX_LEN    484 /* minimum maximum message size */
  ------------------
  367|      0|    else if (max > SNMP_MAX_PACKET_LEN)
  ------------------
  |  |   49|      0|#define SNMP_MAX_PACKET_LEN (0x7fffffff)
  ------------------
  |  Branch (367:14): [True: 0, False: 0]
  ------------------
  368|      0|        max = SNMP_MAX_PACKET_LEN;
  ------------------
  |  |   49|      0|#define SNMP_MAX_PACKET_LEN (0x7fffffff)
  ------------------
  369|       |
  370|  3.49k|    return max;
  371|  3.49k|}
snmp_pdu_type:
  388|  1.53k|{
  389|  1.53k|    static char unknown[20];
  390|  1.53k|    switch(type) {
  391|     36|    case SNMP_MSG_GET:
  ------------------
  |  |  125|     36|#define SNMP_MSG_GET        (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x0) /* a0=160 */
  |  |  ------------------
  |  |  |  |   92|     36|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_MSG_GET        (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x0) /* a0=160 */
  |  |  ------------------
  |  |  |  |   96|     36|#define ASN_CONSTRUCTOR	    0x20U
  |  |  ------------------
  ------------------
  |  Branch (391:5): [True: 36, False: 1.50k]
  ------------------
  392|     36|        return "GET";
  393|     76|    case SNMP_MSG_GETNEXT:
  ------------------
  |  |  126|     76|#define SNMP_MSG_GETNEXT    (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x1) /* a1=161 */
  |  |  ------------------
  |  |  |  |   92|     76|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_MSG_GETNEXT    (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x1) /* a1=161 */
  |  |  ------------------
  |  |  |  |   96|     76|#define ASN_CONSTRUCTOR	    0x20U
  |  |  ------------------
  ------------------
  |  Branch (393:5): [True: 76, False: 1.46k]
  ------------------
  394|     76|        return "GETNEXT";
  395|     32|    case SNMP_MSG_GETBULK:
  ------------------
  |  |  140|     32|#define SNMP_MSG_GETBULK    (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x5) /* a5=165 */
  |  |  ------------------
  |  |  |  |   92|     32|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_MSG_GETBULK    (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x5) /* a5=165 */
  |  |  ------------------
  |  |  |  |   96|     32|#define ASN_CONSTRUCTOR	    0x20U
  |  |  ------------------
  ------------------
  |  Branch (395:5): [True: 32, False: 1.50k]
  ------------------
  396|     32|        return "GETBULK";
  397|      0|#ifndef NETSNMP_NO_WRITE_SUPPORT
  398|    424|    case SNMP_MSG_SET:
  ------------------
  |  |  129|    424|#define SNMP_MSG_SET        (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x3) /* a3=163 */
  |  |  ------------------
  |  |  |  |   92|    424|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_MSG_SET        (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x3) /* a3=163 */
  |  |  ------------------
  |  |  |  |   96|    424|#define ASN_CONSTRUCTOR	    0x20U
  |  |  ------------------
  ------------------
  |  Branch (398:5): [True: 424, False: 1.11k]
  ------------------
  399|    424|        return "SET";
  400|      0|#endif /* !NETSNMP_NO_WRITE_SUPPORT */
  401|    114|    case SNMP_MSG_RESPONSE:
  ------------------
  |  |  127|    114|#define SNMP_MSG_RESPONSE   (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x2) /* a2=162 */
  |  |  ------------------
  |  |  |  |   92|    114|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_MSG_RESPONSE   (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x2) /* a2=162 */
  |  |  ------------------
  |  |  |  |   96|    114|#define ASN_CONSTRUCTOR	    0x20U
  |  |  ------------------
  ------------------
  |  Branch (401:5): [True: 114, False: 1.42k]
  ------------------
  402|    114|        return "RESPONSE";
  403|    698|    case SNMP_MSG_TRAP:
  ------------------
  |  |  135|    698|#define SNMP_MSG_TRAP       (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x4) /* a4=164 */
  |  |  ------------------
  |  |  |  |   92|    698|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_MSG_TRAP       (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x4) /* a4=164 */
  |  |  ------------------
  |  |  |  |   96|    698|#define ASN_CONSTRUCTOR	    0x20U
  |  |  ------------------
  ------------------
  |  Branch (403:5): [True: 698, False: 840]
  ------------------
  404|    698|        return "TRAP";
  405|     46|    case SNMP_MSG_INFORM:
  ------------------
  |  |  141|     46|#define SNMP_MSG_INFORM     (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x6) /* a6=166 */
  |  |  ------------------
  |  |  |  |   92|     46|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_MSG_INFORM     (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x6) /* a6=166 */
  |  |  ------------------
  |  |  |  |   96|     46|#define ASN_CONSTRUCTOR	    0x20U
  |  |  ------------------
  ------------------
  |  Branch (405:5): [True: 46, False: 1.49k]
  ------------------
  406|     46|        return "INFORM";
  407|     58|    case SNMP_MSG_TRAP2:
  ------------------
  |  |  142|     58|#define SNMP_MSG_TRAP2      (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x7) /* a7=167 */
  |  |  ------------------
  |  |  |  |   92|     58|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_MSG_TRAP2      (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x7) /* a7=167 */
  |  |  ------------------
  |  |  |  |   96|     58|#define ASN_CONSTRUCTOR	    0x20U
  |  |  ------------------
  ------------------
  |  Branch (407:5): [True: 58, False: 1.48k]
  ------------------
  408|     58|        return "TRAP2";
  409|     40|    case SNMP_MSG_REPORT:
  ------------------
  |  |  147|     40|#define SNMP_MSG_REPORT     (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x8) /* a8=168 */
  |  |  ------------------
  |  |  |  |   92|     40|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_MSG_REPORT     (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x8) /* a8=168 */
  |  |  ------------------
  |  |  |  |   96|     40|#define ASN_CONSTRUCTOR	    0x20U
  |  |  ------------------
  ------------------
  |  Branch (409:5): [True: 40, False: 1.49k]
  ------------------
  410|     40|        return "REPORT";
  411|     14|    default:
  ------------------
  |  Branch (411:5): [True: 14, False: 1.52k]
  ------------------
  412|     14|        snprintf(unknown, sizeof(unknown), "?0x%2X?", type);
  413|     14|	return unknown;
  414|  1.53k|    }
  415|  1.53k|}
snmp_get_next_sessid:
  464|  1.74k|{
  465|  1.74k|    long            retVal;
  466|  1.74k|    snmp_res_lock(MT_LIBRARY_ID, MT_LIB_SESSIONID);
  ------------------
  |  |   79|  1.74k|#define snmp_res_lock(x,y) do {} while (0)
  |  |  ------------------
  |  |  |  Branch (79:41): [Folded - Ignored]
  |  |  ------------------
  ------------------
  467|  1.74k|    retVal = 1 + Sessid;        /*MTCRITICAL_RESOURCE */
  468|  1.74k|    if (!retVal)
  ------------------
  |  Branch (468:9): [True: 0, False: 1.74k]
  ------------------
  469|      0|        retVal = 2;
  470|  1.74k|    Sessid = retVal;
  471|  1.74k|    if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_16BIT_IDS))
  ------------------
  |  |   48|  1.74k|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                  if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_16BIT_IDS))
  ------------------
  |  |   91|  1.74k|#define NETSNMP_DS_LIB_16BIT_IDS           31   /* restrict requestIDs, etc to 16-bit values */
  ------------------
  |  Branch (471:9): [True: 0, False: 1.74k]
  ------------------
  472|      0|        retVal &= 0x7fff;	/* mask to 15 bits */
  473|  1.74k|    else
  474|  1.74k|        retVal &= 0x7fffffff;	/* mask to 31 bits */
  475|       |
  476|  1.74k|    if (!retVal) {
  ------------------
  |  Branch (476:9): [True: 0, False: 1.74k]
  ------------------
  477|      0|        Sessid = retVal = 2;
  478|      0|    }
  479|  1.74k|    snmp_res_unlock(MT_LIBRARY_ID, MT_LIB_SESSIONID);
  ------------------
  |  |   80|  1.74k|#define snmp_res_unlock(x,y) do {} while (0)
  |  |  ------------------
  |  |  |  Branch (80:43): [Folded - Ignored]
  |  |  ------------------
  ------------------
  480|  1.74k|    return retVal;
  481|  1.74k|}
snmp_get_next_transid:
  485|  1.74k|{
  486|  1.74k|    long            retVal;
  487|  1.74k|    snmp_res_lock(MT_LIBRARY_ID, MT_LIB_TRANSID);
  ------------------
  |  |   79|  1.74k|#define snmp_res_lock(x,y) do {} while (0)
  |  |  ------------------
  |  |  |  Branch (79:41): [Folded - Ignored]
  |  |  ------------------
  ------------------
  488|  1.74k|    retVal = 1 + Transid;       /*MTCRITICAL_RESOURCE */
  489|  1.74k|    if (!retVal)
  ------------------
  |  Branch (489:9): [True: 0, False: 1.74k]
  ------------------
  490|      0|        retVal = 2;
  491|  1.74k|    Transid = retVal;
  492|  1.74k|    if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_16BIT_IDS))
  ------------------
  |  |   48|  1.74k|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                  if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_16BIT_IDS))
  ------------------
  |  |   91|  1.74k|#define NETSNMP_DS_LIB_16BIT_IDS           31   /* restrict requestIDs, etc to 16-bit values */
  ------------------
  |  Branch (492:9): [True: 0, False: 1.74k]
  ------------------
  493|      0|        retVal &= 0x7fff;	/* mask to 15 bits */
  494|  1.74k|    else
  495|  1.74k|        retVal &= 0x7fffffff;	/* mask to 31 bits */
  496|       |
  497|  1.74k|    if (!retVal) {
  ------------------
  |  Branch (497:9): [True: 0, False: 1.74k]
  ------------------
  498|      0|        Transid = retVal = 2;
  499|      0|    }
  500|  1.74k|    snmp_res_unlock(MT_LIBRARY_ID, MT_LIB_TRANSID);
  ------------------
  |  |   80|  1.74k|#define snmp_res_unlock(x,y) do {} while (0)
  |  |  ------------------
  |  |  |  Branch (80:43): [Folded - Ignored]
  |  |  ------------------
  ------------------
  501|  1.74k|    return retVal;
  502|  1.74k|}
snmp_set_detail:
  516|  10.8k|{
  517|  10.8k|    if (detail_string != NULL) {
  ------------------
  |  Branch (517:9): [True: 10.8k, False: 0]
  ------------------
  518|  10.8k|        strlcpy(snmp_detail, detail_string, sizeof(snmp_detail));
  519|  10.8k|        snmp_detail_f = 1;
  520|  10.8k|    }
  521|  10.8k|}
snmp_api_errstring:
  531|    391|{
  532|    391|    const char     *msg = "";
  533|    391|    static char     msg_buf[SPRINT_MAX_LEN];
  534|       |
  535|    391|    if (snmp_errnumber >= SNMPERR_MAX && snmp_errnumber <= SNMPERR_GENERR) {
  ------------------
  |  |  288|    782|#define SNMPERR_MAX			(-69)
  ------------------
                  if (snmp_errnumber >= SNMPERR_MAX && snmp_errnumber <= SNMPERR_GENERR) {
  ------------------
  |  |  218|    391|#define SNMPERR_GENERR			(-1)
  ------------------
  |  Branch (535:9): [True: 391, False: 0]
  |  Branch (535:42): [True: 0, False: 391]
  ------------------
  536|      0|        msg = api_errors[-snmp_errnumber];
  537|    391|    } else if (snmp_errnumber != SNMPERR_SUCCESS) {
  ------------------
  |  |  217|    391|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  |  Branch (537:16): [True: 0, False: 391]
  ------------------
  538|      0|        msg = NULL;
  539|      0|    }
  540|    391|    if (!msg) {
  ------------------
  |  Branch (540:9): [True: 0, False: 391]
  ------------------
  541|      0|	snprintf(msg_buf, sizeof(msg_buf), "Unknown error: %d", snmp_errnumber);
  542|      0|        msg_buf[sizeof(msg_buf)-1] = '\0';
  543|    391|    } else if (snmp_detail_f) {
  ------------------
  |  Branch (543:16): [True: 387, False: 4]
  ------------------
  544|    387|        snprintf(msg_buf, sizeof(msg_buf), "%s (%s)", msg, snmp_detail);
  545|    387|        msg_buf[sizeof(msg_buf)-1] = '\0';
  546|    387|        snmp_detail_f = 0;
  547|    387|    } else {
  548|      4|        strlcpy(msg_buf, msg, sizeof(msg_buf));
  549|      4|    }
  550|       |
  551|    391|    return (msg_buf);
  552|    391|}
netsnmp_random:
  639|      3|{
  640|      3|#if defined(HAVE_RANDOM)
  641|       |    /*
  642|       |     * The function random() is a more sophisticated random number generator
  643|       |     * which uses nonlinear feedback and an internal table that is 124 bytes
  644|       |     * (992 bits) long. The function returns random values that are 32 bits in
  645|       |     * length. All of the bits generated by random() are usable. The random()
  646|       |     * function is adequate for simulations and games, but should not be used
  647|       |     * for security related applications such as picking cryptographic keys or
  648|       |     * simulating one-time pads.
  649|       |     */
  650|      3|    return random();
  651|       |#elif defined(HAVE_LRAND48)
  652|       |    /*
  653|       |     * As with random(), lrand48() provides excellent random numbers for
  654|       |     * simulations and games, but should not be used for security-related
  655|       |     * applications such as picking cryptographic keys or simulating one-time
  656|       |     * pads; linear congruential algorithms are too easy to break.
  657|       |     */
  658|       |    return lrand48();
  659|       |#elif defined(HAVE_RAND)
  660|       |    /*
  661|       |     * The original UNIX random number generator, rand(), is not a very good
  662|       |     * random number generator. It uses a 32-bit seed and maintains a 32-bit
  663|       |     * internal state.
  664|       |     */
  665|       |    return rand();
  666|       |#else
  667|       |#error "Neither random(), nor lrand48() nor rand() are available"
  668|       |#endif
  669|      3|}
netsnmp_srandom:
  672|      1|{
  673|      1|#if defined(HAVE_SRANDOM)
  674|      1|    srandom(seed);
  675|       |#elif defined(HAVE_SRAND48)
  676|       |    srand48(seed);
  677|       |#elif defined(HAVE_SRAND)
  678|       |    srand(seed);
  679|       |#else
  680|       |#error "Neither srandom(), nor srand48() nor srand() are available"
  681|       |#endif
  682|      1|}
snmp_sess_init:
  775|  1.74k|{
  776|  1.74k|    _init_snmp();
  777|       |
  778|       |    /*
  779|       |     * initialize session to default values 
  780|       |     */
  781|       |
  782|  1.74k|    memset(session, 0, sizeof(netsnmp_session));
  783|  1.74k|    session->timeout = SNMP_DEFAULT_TIMEOUT;
  ------------------
  |  |  113|  1.74k|#define SNMP_DEFAULT_TIMEOUT	    -1
  ------------------
  784|  1.74k|    session->retries = SNMP_DEFAULT_RETRIES;
  ------------------
  |  |  112|  1.74k|#define SNMP_DEFAULT_RETRIES	    -1
  ------------------
  785|  1.74k|    session->version = SNMP_DEFAULT_VERSION;
  ------------------
  |  |  123|  1.74k|#define SNMP_DEFAULT_VERSION	    -1
  ------------------
  786|  1.74k|    session->securityModel = SNMP_DEFAULT_SECMODEL;
  ------------------
  |  |  124|  1.74k|#define SNMP_DEFAULT_SECMODEL	    -1
  ------------------
  787|  1.74k|    session->rcvMsgMaxSize = netsnmp_max_send_msg_size();
  788|  1.74k|    session->sndMsgMaxSize = netsnmp_max_send_msg_size();
  789|  1.74k|    session->flags |= SNMP_FLAGS_DONT_PROBE;
  ------------------
  |  |  188|  1.74k|#define SNMP_FLAGS_DONT_PROBE      0x100      /* don't probe for an engineID */
  ------------------
  790|  1.74k|}
init_snmp:
  879|  1.74k|{
  880|  1.74k|    if (init_snmp_init_done) {
  ------------------
  |  Branch (880:9): [True: 1.74k, False: 1]
  ------------------
  881|  1.74k|        return;
  882|  1.74k|    }
  883|       |
  884|      1|    init_snmp_init_done = 1;
  885|       |
  886|       |    /*
  887|       |     * make the type available everywhere else 
  888|       |     */
  889|      1|    if (type && !netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (889:9): [True: 1, False: 0]
  |  Branch (889:17): [True: 1, False: 0]
  ------------------
  890|      1|				       NETSNMP_DS_LIB_APPTYPE)) {
  ------------------
  |  |  157|      1|#define NETSNMP_DS_LIB_APPTYPE           6
  ------------------
  891|      1|        netsnmp_ds_set_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  892|      1|			      NETSNMP_DS_LIB_APPTYPE, type);
  ------------------
  |  |  157|      1|#define NETSNMP_DS_LIB_APPTYPE           6
  ------------------
  893|      1|    }
  894|       |
  895|      1|    _init_snmp();
  896|       |
  897|       |    /*
  898|       |     * set our current locale properly to initialize isprint() type functions 
  899|       |     */
  900|      1|#ifdef HAVE_SETLOCALE
  901|      1|    setlocale(LC_CTYPE, "");
  902|      1|#endif
  903|       |
  904|      1|    snmp_debug_init();    /* should be done first, to turn on debugging ASAP */
  905|      1|    netsnmp_container_init_list();
  906|      1|    init_callbacks();
  907|      1|    init_snmp_logging();
  908|      1|    snmp_init_statistics();
  909|      1|    register_mib_handlers();
  910|      1|    register_default_handlers();
  911|      1|    init_snmp_transport();
  912|      1|    init_snmpv3(type);
  913|      1|    init_snmp_alarm();
  914|      1|    init_snmp_enum(type);
  915|      1|    init_vacm();
  916|      1|#if defined(NETSNMP_USE_OPENSSL) && defined(HAVE_LIBSSL) && NETSNMP_TRANSPORT_TLSBASE_DOMAIN
  917|      1|    netsnmp_certs_init();
  918|      1|#endif
  919|       |#ifdef DNSSEC_LOCAL_VALIDATION
  920|       |    netsnmp_ds_register_config(ASN_BOOLEAN, "snmp", "dnssecWarnOnly",
  921|       |                               NETSNMP_DS_LIBRARY_ID,
  922|       |                               NETSNMP_DS_LIB_DNSSEC_WARN_ONLY);
  923|       |#endif
  924|       |
  925|      1|    read_premib_configs();
  926|      1|#ifndef NETSNMP_DISABLE_MIB_LOADING
  927|      1|    netsnmp_init_mib();
  928|      1|#endif /* NETSNMP_DISABLE_MIB_LOADING */
  929|       |
  930|      1|    read_configs();
  931|       |
  932|      1|}                               /* end init_snmp() */
snmp_session_insert:
 1013|  1.74k|{
 1014|  1.74k|    if (NULL == slp)
  ------------------
  |  Branch (1014:9): [True: 0, False: 1.74k]
  ------------------
 1015|      0|        return;
 1016|       |
 1017|  1.74k|    snmp_res_lock(MT_LIBRARY_ID, MT_LIB_SESSION);
  ------------------
  |  |   79|  1.74k|#define snmp_res_lock(x,y) do {} while (0)
  |  |  ------------------
  |  |  |  Branch (79:41): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1018|  1.74k|    slp->next = Sessions;
 1019|  1.74k|    Sessions = slp;
 1020|  1.74k|    snmp_res_unlock(MT_LIBRARY_ID, MT_LIB_SESSION);
  ------------------
  |  |   80|  1.74k|#define snmp_res_unlock(x,y) do {} while (0)
  |  |  ------------------
  |  |  |  Branch (80:43): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1021|  1.74k|}
netsnmp_sess_config_transport:
 1550|  1.74k|{
 1551|       |    /* Optional supplimental transport configuration information and
 1552|       |       final call to actually open the transport */
 1553|  1.74k|    if (transport_configuration) {
  ------------------
  |  Branch (1553:9): [True: 0, False: 1.74k]
  ------------------
 1554|      0|        DEBUGMSGTL(("snmp_sess", "configuring transport\n"));
  ------------------
  |  |   68|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1555|      0|        if (transport->f_config) {
  ------------------
  |  Branch (1555:13): [True: 0, False: 0]
  ------------------
 1556|      0|            netsnmp_iterator *iter;
 1557|      0|            netsnmp_transport_config *config_data;
 1558|      0|            int ret = 0;
 1559|       |
 1560|      0|            iter = CONTAINER_ITERATOR(transport_configuration);
  ------------------
  |  |  401|      0|#define CONTAINER_ITERATOR(x)       (x)->get_iterator(x)
  ------------------
 1561|      0|            if (NULL == iter) {
  ------------------
  |  Branch (1561:17): [True: 0, False: 0]
  ------------------
 1562|      0|                return SNMPERR_GENERR;
  ------------------
  |  |  218|      0|#define SNMPERR_GENERR			(-1)
  ------------------
 1563|      0|            }
 1564|       |
 1565|      0|            for(config_data = (netsnmp_transport_config*)ITERATOR_FIRST(iter); config_data;
  ------------------
  |  |  543|      0|#define ITERATOR_FIRST(x)  x->first(x)
  ------------------
  |  Branch (1565:80): [True: 0, False: 0]
  ------------------
 1566|      0|                config_data = (netsnmp_transport_config*)ITERATOR_NEXT(iter)) {
  ------------------
  |  |  544|      0|#define ITERATOR_NEXT(x)   x->next(x)
  ------------------
 1567|      0|                ret = transport->f_config(transport, config_data->key,
 1568|      0|                                          config_data->value);
 1569|      0|                if (ret)
  ------------------
  |  Branch (1569:21): [True: 0, False: 0]
  ------------------
 1570|      0|                    break;
 1571|      0|            }
 1572|      0|            ITERATOR_RELEASE(iter);
  ------------------
  |  |  547|      0|#define ITERATOR_RELEASE(x) do { x->release(x); x = NULL; } while(0)
  |  |  ------------------
  |  |  |  Branch (547:67): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1573|      0|            if (ret)
  ------------------
  |  Branch (1573:17): [True: 0, False: 0]
  ------------------
 1574|      0|                return SNMPERR_TRANSPORT_CONFIG_ERROR;
  ------------------
  |  |  285|      0|#define SNMPERR_TRANSPORT_CONFIG_ERROR  (-68)
  ------------------
 1575|      0|        } else {
 1576|      0|            return SNMPERR_TRANSPORT_NO_CONFIG;
  ------------------
  |  |  284|      0|#define SNMPERR_TRANSPORT_NO_CONFIG     (-67)
  ------------------
 1577|      0|        }
 1578|      0|    }
 1579|  1.74k|    return SNMPERR_SUCCESS;
  ------------------
  |  |  217|  1.74k|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 1580|  1.74k|}
netsnmp_sess_config_and_open_transport:
 1612|  1.74k|{
 1613|  1.74k|    int rc;
 1614|       |    
 1615|  1.74k|    DEBUGMSGTL(("snmp_sess", "opening transport: %x\n", transport->flags & NETSNMP_TRANSPORT_FLAG_OPENED));
  ------------------
  |  |   68|  1.74k|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|  1.74k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 1.74k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|  1.74k|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|  1.74k|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|  1.74k|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|  1.74k|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1616|       |
 1617|       |    /* don't double open */
 1618|  1.74k|    if (transport->flags & NETSNMP_TRANSPORT_FLAG_OPENED)
  ------------------
  |  |   57|  1.74k|#define		NETSNMP_TRANSPORT_FLAG_OPENED	 0x20  /* f_open called */
  ------------------
  |  Branch (1618:9): [True: 0, False: 1.74k]
  ------------------
 1619|      0|        return SNMPERR_SUCCESS;
  ------------------
  |  |  217|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 1620|       |
 1621|  1.74k|    if ((rc = netsnmp_sess_config_transport(in_session->transport_configuration,
  ------------------
  |  Branch (1621:9): [True: 0, False: 1.74k]
  ------------------
 1622|  1.74k|                                            transport)) != SNMPERR_SUCCESS) {
  ------------------
  |  |  217|  1.74k|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 1623|      0|        in_session->s_snmp_errno = rc;
 1624|      0|        in_session->s_errno = 0;
 1625|      0|        return rc;
 1626|      0|    }
 1627|       |        
 1628|  1.74k|    if (transport->f_open)
  ------------------
  |  Branch (1628:9): [True: 0, False: 1.74k]
  ------------------
 1629|      0|        transport = transport->f_open(transport);
 1630|       |
 1631|  1.74k|    if (transport == NULL) {
  ------------------
  |  Branch (1631:9): [True: 0, False: 1.74k]
  ------------------
 1632|      0|        DEBUGMSGTL(("snmp_sess", "couldn't open transport connection\n"));
  ------------------
  |  |   68|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1633|      0|        in_session->s_snmp_errno = SNMPERR_BAD_ADDRESS;
  ------------------
  |  |  220|      0|#define SNMPERR_BAD_ADDRESS		(-3)
  ------------------
 1634|      0|        in_session->s_errno = errno;
 1635|      0|        snmp_set_detail(in_session->peername);
 1636|      0|        return SNMPERR_BAD_ADDRESS;
  ------------------
  |  |  220|      0|#define SNMPERR_BAD_ADDRESS		(-3)
  ------------------
 1637|      0|    }
 1638|       |
 1639|       |    /** if transport has a max size, make sure session is the same (or less) */
 1640|  1.74k|    if (in_session->rcvMsgMaxSize > transport->msgMaxSize) {
  ------------------
  |  Branch (1640:9): [True: 1.74k, False: 0]
  ------------------
 1641|  1.74k|        DEBUGMSGTL(("snmp_sess",
  ------------------
  |  |   68|  1.74k|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|  1.74k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 1.74k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|  1.74k|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|  1.74k|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|  1.74k|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|  1.74k|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1642|  1.74k|                    "limiting session rcv size (%" NETSNMP_PRIz "d) to transport max (%" NETSNMP_PRIz "d)\n",
 1643|  1.74k|                    in_session->rcvMsgMaxSize, transport->msgMaxSize));
 1644|  1.74k|        in_session->rcvMsgMaxSize = transport->msgMaxSize;
 1645|  1.74k|    }
 1646|       |
 1647|  1.74k|    if (in_session->sndMsgMaxSize > transport->msgMaxSize) {
  ------------------
  |  Branch (1647:9): [True: 1.74k, False: 0]
  ------------------
 1648|  1.74k|        DEBUGMSGTL(("snmp_sess",
  ------------------
  |  |   68|  1.74k|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|  1.74k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 1.74k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|  1.74k|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|  1.74k|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|  1.74k|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|  1.74k|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1649|  1.74k|                    "limiting session snd size (%" NETSNMP_PRIz "d) to transport max (%" NETSNMP_PRIz "d)\n",
 1650|  1.74k|                    in_session->sndMsgMaxSize, transport->msgMaxSize));
 1651|  1.74k|        in_session->sndMsgMaxSize = transport->msgMaxSize;
 1652|  1.74k|    }
 1653|       |
 1654|  1.74k|    transport->flags |= NETSNMP_TRANSPORT_FLAG_OPENED;
  ------------------
  |  |   57|  1.74k|#define		NETSNMP_TRANSPORT_FLAG_OPENED	 0x20  /* f_open called */
  ------------------
 1655|  1.74k|    DEBUGMSGTL(("snmp_sess", "done opening transport: %x\n", transport->flags & NETSNMP_TRANSPORT_FLAG_OPENED));
  ------------------
  |  |   68|  1.74k|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|  1.74k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 1.74k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|  1.74k|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|  1.74k|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|  1.74k|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|  1.74k|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1656|  1.74k|    return SNMPERR_SUCCESS;
  ------------------
  |  |  217|  1.74k|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 1657|  1.74k|}
snmp_add:
 1770|  1.74k|{
 1771|  1.74k|    struct session_list *slp;
 1772|       |
 1773|  1.74k|    slp = snmp_sess_add_ex(in_session, transport, fpre_parse, NULL,
 1774|  1.74k|                           fpost_parse, NULL, NULL, NULL, NULL);
 1775|  1.74k|    if (slp == NULL) {
  ------------------
  |  Branch (1775:9): [True: 0, False: 1.74k]
  ------------------
 1776|      0|        return NULL;
 1777|      0|    }
 1778|       |
 1779|  1.74k|    snmp_session_insert(slp);
 1780|       |
 1781|  1.74k|    return (slp->session);
 1782|  1.74k|}
snmp_sess_add_ex:
 1831|  1.74k|{
 1832|  1.74k|    struct session_list *slp;
 1833|  1.74k|    int rc;
 1834|       |    
 1835|  1.74k|    _init_snmp();
 1836|       |
 1837|  1.74k|    if (transport == NULL)
  ------------------
  |  Branch (1837:9): [True: 0, False: 1.74k]
  ------------------
 1838|      0|        return NULL;
 1839|       |
 1840|  1.74k|    if (NULL != in_session && (in_session->rcvMsgMaxSize < SNMP_MIN_MAX_LEN ||
  ------------------
  |  |   48|  3.49k|#define SNMP_MIN_MAX_LEN    484 /* minimum maximum message size */
  ------------------
  |  Branch (1840:9): [True: 1.74k, False: 0]
  |  Branch (1840:32): [True: 0, False: 1.74k]
  ------------------
 1841|  1.74k|                               in_session->sndMsgMaxSize < SNMP_MIN_MAX_LEN)) {
  ------------------
  |  |   48|  1.74k|#define SNMP_MIN_MAX_LEN    484 /* minimum maximum message size */
  ------------------
  |  Branch (1841:32): [True: 0, False: 1.74k]
  ------------------
 1842|      0|        DEBUGMSGTL(("snmp_sess_add",
  ------------------
  |  |   68|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1843|      0|                    "invalid session (msg sizes). need snmp_sess_init"));
 1844|      0|        in_session = NULL; /* force transport cleanup below */
 1845|      0|    }
 1846|       |
 1847|  1.74k|    if (in_session == NULL) {
  ------------------
  |  Branch (1847:9): [True: 0, False: 1.74k]
  ------------------
 1848|      0|        transport->f_close(transport);
 1849|      0|        netsnmp_transport_free(transport);
 1850|      0|        return NULL;
 1851|      0|    }
 1852|       |
 1853|       |    /* if the transport hasn't been fully opened yet, open it now */
 1854|  1.74k|    if ((rc = netsnmp_sess_config_and_open_transport(in_session, transport))
  ------------------
  |  Branch (1854:9): [True: 0, False: 1.74k]
  ------------------
 1855|  1.74k|        != SNMPERR_SUCCESS) {
  ------------------
  |  |  217|  1.74k|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 1856|      0|        return NULL;
 1857|      0|    }
 1858|       |
 1859|  1.74k|    if (transport->f_setup_session) {
  ------------------
  |  Branch (1859:9): [True: 0, False: 1.74k]
  ------------------
 1860|      0|        if (SNMPERR_SUCCESS !=
  ------------------
  |  |  217|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  |  Branch (1860:13): [True: 0, False: 0]
  ------------------
 1861|      0|            transport->f_setup_session(transport, in_session)) {
 1862|      0|            netsnmp_transport_free(transport);
 1863|      0|            return NULL;
 1864|      0|        }
 1865|      0|    }
 1866|       |        
 1867|       |            
 1868|  1.74k|    DEBUGMSGTL(("snmp_sess_add", "fd %d\n", transport->sock));
  ------------------
  |  |   68|  1.74k|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|  1.74k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 1.74k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|  1.74k|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|  1.74k|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|  1.74k|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|  1.74k|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1869|       |
 1870|       |
 1871|  1.74k|    if ((slp = snmp_sess_copy(in_session)) == NULL) {
  ------------------
  |  Branch (1871:9): [True: 0, False: 1.74k]
  ------------------
 1872|      0|        transport->f_close(transport);
 1873|      0|        netsnmp_transport_free(transport);
 1874|      0|        return (NULL);
 1875|      0|    }
 1876|       |
 1877|  1.74k|    slp->transport = transport;
 1878|  1.74k|    slp->internal->hook_pre = fpre_parse;
 1879|  1.74k|    slp->internal->hook_parse = fparse;
 1880|  1.74k|    slp->internal->hook_post = fpost_parse;
 1881|  1.74k|    slp->internal->hook_build = fbuild;
 1882|  1.74k|    slp->internal->hook_realloc_build = frbuild;
 1883|  1.74k|    slp->internal->check_packet = fcheck;
 1884|  1.74k|    slp->internal->hook_create_pdu = fcreate_pdu;
 1885|       |
 1886|       |    /** don't let session max exceed transport max */
 1887|  1.74k|    if (slp->session->rcvMsgMaxSize > transport->msgMaxSize) {
  ------------------
  |  Branch (1887:9): [True: 0, False: 1.74k]
  ------------------
 1888|      0|        DEBUGMSGTL(("snmp_sess_add",
  ------------------
  |  |   68|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1889|      0|                    "limiting session rcv size (%" NETSNMP_PRIz "d) to transport max (%" NETSNMP_PRIz "d)\n",
 1890|      0|                    slp->session->rcvMsgMaxSize, transport->msgMaxSize));
 1891|      0|        slp->session->rcvMsgMaxSize = transport->msgMaxSize;
 1892|      0|    }
 1893|  1.74k|    if (slp->session->sndMsgMaxSize > transport->msgMaxSize) {
  ------------------
  |  Branch (1893:9): [True: 0, False: 1.74k]
  ------------------
 1894|      0|        DEBUGMSGTL(("snmp_sess_add",
  ------------------
  |  |   68|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1895|      0|                    "limiting session snd size (%" NETSNMP_PRIz "d) to transport max (%" NETSNMP_PRIz "d)\n",
 1896|      0|                    slp->session->sndMsgMaxSize, transport->msgMaxSize));
 1897|      0|        slp->session->sndMsgMaxSize = transport->msgMaxSize;
 1898|      0|    }
 1899|       |
 1900|  1.74k|    if (slp->session->version == SNMP_VERSION_3) {
  ------------------
  |  |  113|  1.74k|#define SNMP_VERSION_3     3
  ------------------
  |  Branch (1900:9): [True: 0, False: 1.74k]
  ------------------
 1901|      0|        DEBUGMSGTL(("snmp_sess_add",
  ------------------
  |  |   68|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1902|      0|                    "adding v3 session -- maybe engineID probe now\n"));
 1903|      0|        if (!snmpv3_engineID_probe(slp, slp->session)) {
  ------------------
  |  Branch (1903:13): [True: 0, False: 0]
  ------------------
 1904|      0|            DEBUGMSGTL(("snmp_sess_add", "engine ID probe failed\n"));
  ------------------
  |  |   68|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1905|      0|            snmp_sess_close(slp);
 1906|      0|            return NULL;
 1907|      0|        }
 1908|      0|    }
 1909|       |
 1910|  1.74k|    slp->session->flags &= ~SNMP_FLAGS_DONT_PROBE;
  ------------------
  |  |  188|  1.74k|#define SNMP_FLAGS_DONT_PROBE      0x100      /* don't probe for an engineID */
  ------------------
 1911|       |
 1912|  1.74k|    return slp;
 1913|  1.74k|}                               /*  end snmp_sess_add_ex()  */
create_user_from_session:
 1943|  1.74k|create_user_from_session(netsnmp_session * session) {
 1944|  1.74k|#ifdef NETSNMP_SECMOD_USM
 1945|  1.74k|    return usm_create_user_from_session(session);
 1946|       |#else
 1947|       |    snmp_log(LOG_ERR, "create_user_from_session called when USM wasn't compiled in");
 1948|       |    netsnmp_assert(0 == 1);
 1949|       |    return SNMP_ERR_GENERR;
 1950|       |#endif
 1951|  1.74k|}
netsnmp_cleanup_session:
 1955|  1.74k|{
 1956|  1.74k|    SNMP_FREE(s->localname);
  ------------------
  |  |   62|  1.74k|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 1.74k]
  |  |  |  Branch (62:66): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1957|  1.74k|    SNMP_FREE(s->peername);
  ------------------
  |  |   62|  1.74k|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 1.74k, False: 0]
  |  |  |  Branch (62:66): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1958|  1.74k|    SNMP_FREE(s->community);
  ------------------
  |  |   62|  1.74k|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 1.74k]
  |  |  |  Branch (62:66): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1959|  1.74k|    SNMP_FREE(s->contextEngineID);
  ------------------
  |  |   62|  1.74k|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 1.74k]
  |  |  |  Branch (62:66): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1960|  1.74k|    SNMP_FREE(s->contextName);
  ------------------
  |  |   62|  1.74k|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 1.74k]
  |  |  |  Branch (62:66): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1961|  1.74k|    SNMP_FREE(s->securityEngineID);
  ------------------
  |  |   62|  1.74k|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 1.74k]
  |  |  |  Branch (62:66): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1962|  1.74k|    SNMP_FREE(s->securityName);
  ------------------
  |  |   62|  1.74k|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 1.74k]
  |  |  |  Branch (62:66): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1963|  1.74k|    SNMP_FREE(s->securityAuthProto);
  ------------------
  |  |   62|  1.74k|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 1.74k]
  |  |  |  Branch (62:66): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1964|  1.74k|    SNMP_FREE(s->securityAuthLocalKey);
  ------------------
  |  |   62|  1.74k|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 1.74k]
  |  |  |  Branch (62:66): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1965|  1.74k|    SNMP_FREE(s->securityPrivProto);
  ------------------
  |  |   62|  1.74k|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 1.74k]
  |  |  |  Branch (62:66): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1966|  1.74k|    SNMP_FREE(s->securityPrivLocalKey);
  ------------------
  |  |   62|  1.74k|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 1.74k]
  |  |  |  Branch (62:66): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1967|  1.74k|    SNMP_FREE(s->paramName);
  ------------------
  |  |   62|  1.74k|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 1.74k]
  |  |  |  Branch (62:66): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1968|  1.74k|#ifndef NETSNMP_NO_TRAP_STATS
 1969|  1.74k|    SNMP_FREE(s->trap_stats);
  ------------------
  |  |   62|  1.74k|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 1.74k]
  |  |  |  Branch (62:66): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1970|  1.74k|#endif /* NETSNMP_NO_TRAP_STATS */
 1971|  1.74k|    usm_free_user(s->sessUser);
 1972|  1.74k|}
snmp_close:
 2082|  1.74k|{
 2083|  1.74k|    struct session_list *slp = NULL, *oslp = NULL;
 2084|       |
 2085|  1.74k|    {                           /*MTCRITICAL_RESOURCE */
 2086|  1.74k|        snmp_res_lock(MT_LIBRARY_ID, MT_LIB_SESSION);
  ------------------
  |  |   79|  1.74k|#define snmp_res_lock(x,y) do {} while (0)
  |  |  ------------------
  |  |  |  Branch (79:41): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2087|  1.74k|        if (Sessions && Sessions->session == session) { /* If first entry */
  ------------------
  |  Branch (2087:13): [True: 1.74k, False: 0]
  |  Branch (2087:25): [True: 0, False: 1.74k]
  ------------------
 2088|      0|            slp = Sessions;
 2089|      0|            Sessions = slp->next;
 2090|  1.74k|        } else {
 2091|  1.52M|            for (slp = Sessions; slp; slp = slp->next) {
  ------------------
  |  Branch (2091:34): [True: 1.52M, False: 1.74k]
  ------------------
 2092|  1.52M|                if (slp->session == session) {
  ------------------
  |  Branch (2092:21): [True: 0, False: 1.52M]
  ------------------
 2093|      0|                    if (oslp)   /* if we found entry that points here */
  ------------------
  |  Branch (2093:25): [True: 0, False: 0]
  ------------------
 2094|      0|                        oslp->next = slp->next; /* link around this entry */
 2095|      0|                    break;
 2096|      0|                }
 2097|  1.52M|                oslp = slp;
 2098|  1.52M|            }
 2099|  1.74k|        }
 2100|  1.74k|        snmp_res_unlock(MT_LIBRARY_ID, MT_LIB_SESSION);
  ------------------
  |  |   80|  1.74k|#define snmp_res_unlock(x,y) do {} while (0)
  |  |  ------------------
  |  |  |  Branch (80:43): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2101|  1.74k|    }                           /*END MTCRITICAL_RESOURCE */
 2102|  1.74k|    if (slp == NULL) {
  ------------------
  |  Branch (2102:9): [True: 1.74k, False: 0]
  ------------------
 2103|  1.74k|        return 0;
 2104|  1.74k|    }
 2105|      0|    return snmp_sess_close(slp);
 2106|  1.74k|}
snmp_parse:
 4611|  1.74k|{
 4612|  1.74k|    int             rc;
 4613|       |
 4614|  1.74k|    rc = _snmp_parse(slp, pss, pdu, data, length);
 4615|  1.74k|    if (rc) {
  ------------------
  |  Branch (4615:9): [True: 1.73k, False: 10]
  ------------------
 4616|  1.73k|        if (!pss->s_snmp_errno) {
  ------------------
  |  Branch (4616:13): [True: 1.56k, False: 168]
  ------------------
 4617|  1.56k|            pss->s_snmp_errno = SNMPERR_BAD_PARSE;
  ------------------
  |  |  230|  1.56k|#define SNMPERR_BAD_PARSE		(-13)
  ------------------
 4618|  1.56k|        }
 4619|  1.73k|        SET_SNMP_ERROR(pss->s_snmp_errno);
  ------------------
  |  |   56|  1.73k|#define SET_SNMP_ERROR(x) snmp_errno=(x)
  ------------------
 4620|  1.73k|    }
 4621|       |
 4622|  1.74k|    return rc;
 4623|  1.74k|}
snmp_pdu_parse:
 4627|    783|{
 4628|    783|    u_char          type;
 4629|    783|    u_char          msg_type;
 4630|    783|    u_char         *var_val;
 4631|    783|    size_t          len;
 4632|    783|    size_t          four;
 4633|    783|    netsnmp_variable_list *vp = NULL, *vplast = NULL;
 4634|    783|    oid             objid[MAX_OID_LEN];
 4635|    783|    u_char         *p;
 4636|       |
 4637|       |    /*
 4638|       |     * Get the PDU type 
 4639|       |     */
 4640|    783|    data = asn_parse_header(data, length, &msg_type);
 4641|    783|    if (data == NULL)
  ------------------
  |  Branch (4641:9): [True: 14, False: 769]
  ------------------
 4642|     14|        return -1;
 4643|    769|    DEBUGMSGTL(("dumpv_recv","    Command %s\n", snmp_pdu_type(msg_type)));
  ------------------
  |  |   68|    769|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|    769|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 769, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|    769|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|    769|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|    769|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|    769|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
 4644|    769|    pdu->command = msg_type;
 4645|    769|    pdu->flags &= (~UCD_MSG_FLAG_RESPONSE_PDU);
  ------------------
  |  |  311|    769|#define UCD_MSG_FLAG_RESPONSE_PDU            0x100
  ------------------
 4646|       |
 4647|       |    /*
 4648|       |     * get the fields in the PDU preceding the variable-bindings sequence
 4649|       |     */
 4650|    769|    switch (pdu->command) {
 4651|    349|    case SNMP_MSG_TRAP:
  ------------------
  |  |  135|    349|#define SNMP_MSG_TRAP       (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x4) /* a4=164 */
  |  |  ------------------
  |  |  |  |   92|    349|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_MSG_TRAP       (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x4) /* a4=164 */
  |  |  ------------------
  |  |  |  |   96|    349|#define ASN_CONSTRUCTOR	    0x20U
  |  |  ------------------
  ------------------
  |  Branch (4651:5): [True: 349, False: 420]
  ------------------
 4652|       |        /*
 4653|       |         * enterprise 
 4654|       |         */
 4655|    349|        pdu->enterprise_length = MAX_OID_LEN;
  ------------------
  |  |  103|    349|#define MAX_OID_LEN	    128 /* max subid's in an oid */
  ------------------
 4656|    349|        data = asn_parse_objid(data, length, &type, objid,
 4657|    349|                               &pdu->enterprise_length);
 4658|    349|        if (data == NULL)
  ------------------
  |  Branch (4658:13): [True: 142, False: 207]
  ------------------
 4659|    142|            return -1;
 4660|    207|        pdu->enterprise = netsnmp_memdup(objid,
 4661|    207|                                         pdu->enterprise_length * sizeof(oid));
 4662|    207|        if (pdu->enterprise == NULL) {
  ------------------
  |  Branch (4662:13): [True: 0, False: 207]
  ------------------
 4663|      0|            return -1;
 4664|      0|        }
 4665|       |
 4666|       |        /*
 4667|       |         * agent-addr 
 4668|       |         */
 4669|    207|        four = 4;
 4670|    207|        data = asn_parse_string(data, length, &type,
 4671|    207|                                (u_char *) pdu->agent_addr, &four);
 4672|    207|        if (data == NULL)
  ------------------
  |  Branch (4672:13): [True: 80, False: 127]
  ------------------
 4673|     80|            return -1;
 4674|       |
 4675|       |        /*
 4676|       |         * generic trap 
 4677|       |         */
 4678|    127|        data = asn_parse_int(data, length, &type, (long *) &pdu->trap_type,
 4679|    127|                             sizeof(pdu->trap_type));
 4680|    127|        if (data == NULL)
  ------------------
  |  Branch (4680:13): [True: 8, False: 119]
  ------------------
 4681|      8|            return -1;
 4682|       |        /*
 4683|       |         * specific trap 
 4684|       |         */
 4685|    119|        data =
 4686|    119|            asn_parse_int(data, length, &type,
 4687|    119|                          (long *) &pdu->specific_type,
 4688|    119|                          sizeof(pdu->specific_type));
 4689|    119|        if (data == NULL)
  ------------------
  |  Branch (4689:13): [True: 2, False: 117]
  ------------------
 4690|      2|            return -1;
 4691|       |
 4692|       |        /*
 4693|       |         * timestamp  
 4694|       |         */
 4695|    117|        data = asn_parse_unsigned_int(data, length, &type, &pdu->time,
 4696|    117|                                      sizeof(pdu->time));
 4697|    117|        if (data == NULL)
  ------------------
  |  Branch (4697:13): [True: 115, False: 2]
  ------------------
 4698|    115|            return -1;
 4699|       |
 4700|      2|        break;
 4701|       |
 4702|     57|    case SNMP_MSG_RESPONSE:
  ------------------
  |  |  127|     57|#define SNMP_MSG_RESPONSE   (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x2) /* a2=162 */
  |  |  ------------------
  |  |  |  |   92|     57|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_MSG_RESPONSE   (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x2) /* a2=162 */
  |  |  ------------------
  |  |  |  |   96|     57|#define ASN_CONSTRUCTOR	    0x20U
  |  |  ------------------
  ------------------
  |  Branch (4702:5): [True: 57, False: 712]
  ------------------
 4703|     77|    case SNMP_MSG_REPORT:
  ------------------
  |  |  147|     77|#define SNMP_MSG_REPORT     (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x8) /* a8=168 */
  |  |  ------------------
  |  |  |  |   92|     77|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_MSG_REPORT     (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x8) /* a8=168 */
  |  |  ------------------
  |  |  |  |   96|     77|#define ASN_CONSTRUCTOR	    0x20U
  |  |  ------------------
  ------------------
  |  Branch (4703:5): [True: 20, False: 749]
  ------------------
 4704|     77|        pdu->flags |= UCD_MSG_FLAG_RESPONSE_PDU;
  ------------------
  |  |  311|     77|#define UCD_MSG_FLAG_RESPONSE_PDU            0x100
  ------------------
 4705|     77|        NETSNMP_FALLTHROUGH;
  ------------------
  |  | 2390|     77|#    define NETSNMP_FALLTHROUGH __attribute__((__fallthrough__))
  ------------------
 4706|       |
 4707|    106|    case SNMP_MSG_TRAP2:
  ------------------
  |  |  142|    106|#define SNMP_MSG_TRAP2      (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x7) /* a7=167 */
  |  |  ------------------
  |  |  |  |   92|    106|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_MSG_TRAP2      (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x7) /* a7=167 */
  |  |  ------------------
  |  |  |  |   96|    106|#define ASN_CONSTRUCTOR	    0x20U
  |  |  ------------------
  ------------------
  |  Branch (4707:5): [True: 29, False: 740]
  ------------------
 4708|    129|    case SNMP_MSG_INFORM:
  ------------------
  |  |  141|    129|#define SNMP_MSG_INFORM     (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x6) /* a6=166 */
  |  |  ------------------
  |  |  |  |   92|    129|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_MSG_INFORM     (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x6) /* a6=166 */
  |  |  ------------------
  |  |  |  |   96|    129|#define ASN_CONSTRUCTOR	    0x20U
  |  |  ------------------
  ------------------
  |  Branch (4708:5): [True: 23, False: 746]
  ------------------
 4709|    129|#ifndef NETSNMP_NOTIFY_ONLY
 4710|    147|    case SNMP_MSG_GET:
  ------------------
  |  |  125|    147|#define SNMP_MSG_GET        (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x0) /* a0=160 */
  |  |  ------------------
  |  |  |  |   92|    147|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_MSG_GET        (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x0) /* a0=160 */
  |  |  ------------------
  |  |  |  |   96|    147|#define ASN_CONSTRUCTOR	    0x20U
  |  |  ------------------
  ------------------
  |  Branch (4710:5): [True: 18, False: 751]
  ------------------
 4711|    185|    case SNMP_MSG_GETNEXT:
  ------------------
  |  |  126|    185|#define SNMP_MSG_GETNEXT    (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x1) /* a1=161 */
  |  |  ------------------
  |  |  |  |   92|    185|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_MSG_GETNEXT    (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x1) /* a1=161 */
  |  |  ------------------
  |  |  |  |   96|    185|#define ASN_CONSTRUCTOR	    0x20U
  |  |  ------------------
  ------------------
  |  Branch (4711:5): [True: 38, False: 731]
  ------------------
 4712|    201|    case SNMP_MSG_GETBULK:
  ------------------
  |  |  140|    201|#define SNMP_MSG_GETBULK    (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x5) /* a5=165 */
  |  |  ------------------
  |  |  |  |   92|    201|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_MSG_GETBULK    (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x5) /* a5=165 */
  |  |  ------------------
  |  |  |  |   96|    201|#define ASN_CONSTRUCTOR	    0x20U
  |  |  ------------------
  ------------------
  |  Branch (4712:5): [True: 16, False: 753]
  ------------------
 4713|    201|#endif /* ! NETSNMP_NOTIFY_ONLY */
 4714|    201|#ifndef NETSNMP_NO_WRITE_SUPPORT
 4715|    413|    case SNMP_MSG_SET:
  ------------------
  |  |  129|    413|#define SNMP_MSG_SET        (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x3) /* a3=163 */
  |  |  ------------------
  |  |  |  |   92|    413|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_MSG_SET        (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x3) /* a3=163 */
  |  |  ------------------
  |  |  |  |   96|    413|#define ASN_CONSTRUCTOR	    0x20U
  |  |  ------------------
  ------------------
  |  Branch (4715:5): [True: 212, False: 557]
  ------------------
 4716|    413|#endif /* !NETSNMP_NO_WRITE_SUPPORT */
 4717|       |        /*
 4718|       |         * PDU is not an SNMPv1 TRAP 
 4719|       |         */
 4720|       |
 4721|       |        /*
 4722|       |         * request id 
 4723|       |         */
 4724|    413|        DEBUGDUMPHEADER("recv", "request_id");
  ------------------
  |  |   81|    413|	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|    413|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 413, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  180|    413|        __DBGPRINTINDENT("dumph_" token); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  177|    413|#define __DBGPRINTINDENT(token) __DBGMSGTL((token, "%*s", __DBGINDENT(), ""))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  166|    413|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  156|    413|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  149|    413|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  157|    413|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  181|    413|        debugmsg("dumph_" token,x); \
  |  |  |  |  182|    413|        if (debug_is_token_registered("dumpx" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  217|    826|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (182:13): [True: 413, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  183|    413|            debug_is_token_registered("dumpv" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  217|    413|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  184|    413|            (debug_is_token_registered("dumpx_" token) != SNMPERR_SUCCESS &&  \
  |  |  |  |  ------------------
  |  |  |  |  |  |  217|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (184:14): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  185|    413|             debug_is_token_registered("dumpv_" token) != SNMPERR_SUCCESS)) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |  217|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (185:14): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  186|    413|            debugmsg("dumph_" token,"\n"); \
  |  |  |  |  187|    413|        } else { \
  |  |  |  |  188|      0|            debugmsg("dumph_" token,"  "); \
  |  |  |  |  189|      0|        } \
  |  |  |  |  190|    413|        __DBGINDENTMORE()
  |  |  |  |  ------------------
  |  |  |  |  |  |  175|    413|#define __DBGINDENTMORE()  debug_indent_add(2)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (81:55): [Folded - Ignored]
  |  |  ------------------
  ------------------
 4725|    413|        data = asn_parse_int(data, length, &type, &pdu->reqid,
 4726|    413|                             sizeof(pdu->reqid));
 4727|    413|        DEBUGINDENTLESS();
  ------------------
  |  |   77|    413|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  146|    413|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 413, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  176|    413|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (77:74): [Folded - Ignored]
  |  |  ------------------
  ------------------
 4728|    413|        if (data == NULL) {
  ------------------
  |  Branch (4728:13): [True: 9, False: 404]
  ------------------
 4729|      9|            return -1;
 4730|      9|        }
 4731|       |
 4732|       |        /*
 4733|       |         * error status (getbulk non-repeaters) 
 4734|       |         */
 4735|    404|        DEBUGDUMPHEADER("recv", "error status");
  ------------------
  |  |   81|    404|	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|    404|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 404, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  180|    404|        __DBGPRINTINDENT("dumph_" token); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  177|    404|#define __DBGPRINTINDENT(token) __DBGMSGTL((token, "%*s", __DBGINDENT(), ""))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  166|    404|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  156|    404|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  149|    404|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  157|    404|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  181|    404|        debugmsg("dumph_" token,x); \
  |  |  |  |  182|    404|        if (debug_is_token_registered("dumpx" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  217|    808|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (182:13): [True: 404, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  183|    404|            debug_is_token_registered("dumpv" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  217|    404|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  184|    404|            (debug_is_token_registered("dumpx_" token) != SNMPERR_SUCCESS &&  \
  |  |  |  |  ------------------
  |  |  |  |  |  |  217|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (184:14): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  185|    404|             debug_is_token_registered("dumpv_" token) != SNMPERR_SUCCESS)) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |  217|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (185:14): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  186|    404|            debugmsg("dumph_" token,"\n"); \
  |  |  |  |  187|    404|        } else { \
  |  |  |  |  188|      0|            debugmsg("dumph_" token,"  "); \
  |  |  |  |  189|      0|        } \
  |  |  |  |  190|    404|        __DBGINDENTMORE()
  |  |  |  |  ------------------
  |  |  |  |  |  |  175|    404|#define __DBGINDENTMORE()  debug_indent_add(2)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (81:55): [Folded - Ignored]
  |  |  ------------------
  ------------------
 4736|    404|        data = asn_parse_int(data, length, &type, &pdu->errstat,
 4737|    404|                             sizeof(pdu->errstat));
 4738|    404|        DEBUGINDENTLESS();
  ------------------
  |  |   77|    404|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  146|    404|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 404, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  176|    404|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (77:74): [Folded - Ignored]
  |  |  ------------------
  ------------------
 4739|    404|        if (data == NULL) {
  ------------------
  |  Branch (4739:13): [True: 1, False: 403]
  ------------------
 4740|      1|            return -1;
 4741|      1|        }
 4742|       |
 4743|       |        /*
 4744|       |         * error index (getbulk max-repetitions) 
 4745|       |         */
 4746|    403|        DEBUGDUMPHEADER("recv", "error index");
  ------------------
  |  |   81|    403|	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|    403|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 403, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  180|    403|        __DBGPRINTINDENT("dumph_" token); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  177|    403|#define __DBGPRINTINDENT(token) __DBGMSGTL((token, "%*s", __DBGINDENT(), ""))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  166|    403|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  156|    403|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  149|    403|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  157|    403|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  181|    403|        debugmsg("dumph_" token,x); \
  |  |  |  |  182|    403|        if (debug_is_token_registered("dumpx" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  217|    806|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (182:13): [True: 403, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  183|    403|            debug_is_token_registered("dumpv" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  217|    403|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  184|    403|            (debug_is_token_registered("dumpx_" token) != SNMPERR_SUCCESS &&  \
  |  |  |  |  ------------------
  |  |  |  |  |  |  217|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (184:14): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  185|    403|             debug_is_token_registered("dumpv_" token) != SNMPERR_SUCCESS)) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |  217|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (185:14): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  186|    403|            debugmsg("dumph_" token,"\n"); \
  |  |  |  |  187|    403|        } else { \
  |  |  |  |  188|      0|            debugmsg("dumph_" token,"  "); \
  |  |  |  |  189|      0|        } \
  |  |  |  |  190|    403|        __DBGINDENTMORE()
  |  |  |  |  ------------------
  |  |  |  |  |  |  175|    403|#define __DBGINDENTMORE()  debug_indent_add(2)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (81:55): [Folded - Ignored]
  |  |  ------------------
  ------------------
 4747|    403|        data = asn_parse_int(data, length, &type, &pdu->errindex,
 4748|    403|                             sizeof(pdu->errindex));
 4749|    403|        DEBUGINDENTLESS();
  ------------------
  |  |   77|    403|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  146|    403|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 403, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  176|    403|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (77:74): [Folded - Ignored]
  |  |  ------------------
  ------------------
 4750|    403|        if (data == NULL) {
  ------------------
  |  Branch (4750:13): [True: 4, False: 399]
  ------------------
 4751|      4|            return -1;
 4752|      4|        }
 4753|    399|	break;
 4754|       |
 4755|    399|    default:
  ------------------
  |  Branch (4755:5): [True: 7, False: 762]
  ------------------
 4756|      7|        snmp_log(LOG_ERR, "Bad PDU type received: 0x%.2x\n", pdu->command);
 4757|      7|        snmp_increment_statistic(STAT_SNMPINASNPARSEERRS);
  ------------------
  |  |  681|      7|#define  STAT_SNMPINASNPARSEERRS             14
  ------------------
 4758|      7|        return -1;
 4759|    769|    }
 4760|       |
 4761|       |    /*
 4762|       |     * get header for variable-bindings sequence 
 4763|       |     */
 4764|    401|    DEBUGDUMPSECTION("recv", "VarBindList");
  ------------------
  |  |   83|    401|	do {if (_DBG_IF_) {__DBGDUMPSECTION(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|    401|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 401, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPSECTION(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  193|    401|        __DBGPRINTINDENT("dumph_" token); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  177|    401|#define __DBGPRINTINDENT(token) __DBGMSGTL((token, "%*s", __DBGINDENT(), ""))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  166|    401|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  156|    401|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  149|    401|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  157|    401|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  194|    401|        debugmsg("dumph_" token,"%s\n",x);\
  |  |  |  |  195|    401|        __DBGINDENTMORE()
  |  |  |  |  ------------------
  |  |  |  |  |  |  175|    401|#define __DBGINDENTMORE()  debug_indent_add(2)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (83:56): [Folded - Ignored]
  |  |  ------------------
  ------------------
 4765|    401|    data = asn_parse_sequence(data, length, &type,
 4766|    401|                              (ASN_SEQUENCE | ASN_CONSTRUCTOR),
  ------------------
  |  |   84|    401|#define ASN_SEQUENCE	    0x10U
  ------------------
                                            (ASN_SEQUENCE | ASN_CONSTRUCTOR),
  ------------------
  |  |   96|    401|#define ASN_CONSTRUCTOR	    0x20U
  ------------------
 4767|    401|                              "varbinds");
 4768|    401|    if (data == NULL)
  ------------------
  |  Branch (4768:9): [True: 5, False: 396]
  ------------------
 4769|      5|        goto fail;
 4770|       |
 4771|       |    /*
 4772|       |     * get each varBind sequence 
 4773|       |     */
 4774|    781|    while ((int) *length > 0) {
  ------------------
  |  Branch (4774:12): [True: 771, False: 10]
  ------------------
 4775|    771|        vp = SNMP_MALLOC_TYPEDEF(netsnmp_variable_list);
  ------------------
  |  |   73|    771|#define SNMP_MALLOC_TYPEDEF(td)  (td *) calloc(1, sizeof(td))
  ------------------
 4776|    771|        if (NULL == vp)
  ------------------
  |  Branch (4776:13): [True: 0, False: 771]
  ------------------
 4777|      0|            goto fail;
 4778|       |
 4779|    771|        vp->name_length = MAX_OID_LEN;
  ------------------
  |  |  103|    771|#define MAX_OID_LEN	    128 /* max subid's in an oid */
  ------------------
 4780|    771|        DEBUGDUMPSECTION("recv", "VarBind");
  ------------------
  |  |   83|    771|	do {if (_DBG_IF_) {__DBGDUMPSECTION(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|    771|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 771, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPSECTION(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  193|    771|        __DBGPRINTINDENT("dumph_" token); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  177|    771|#define __DBGPRINTINDENT(token) __DBGMSGTL((token, "%*s", __DBGINDENT(), ""))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  166|    771|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  156|    771|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  149|    771|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  157|    771|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  194|    771|        debugmsg("dumph_" token,"%s\n",x);\
  |  |  |  |  195|    771|        __DBGINDENTMORE()
  |  |  |  |  ------------------
  |  |  |  |  |  |  175|    771|#define __DBGINDENTMORE()  debug_indent_add(2)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (83:56): [Folded - Ignored]
  |  |  ------------------
  ------------------
 4781|    771|        data = snmp_parse_var_op(data, objid, &vp->name_length, &vp->type,
 4782|    771|                                 &vp->val_len, &var_val, length);
 4783|    771|        if (data == NULL)
  ------------------
  |  Branch (4783:13): [True: 323, False: 448]
  ------------------
 4784|    323|            goto fail;
 4785|    448|        if (snmp_set_var_objid(vp, objid, vp->name_length))
  ------------------
  |  Branch (4785:13): [True: 0, False: 448]
  ------------------
 4786|      0|            goto fail;
 4787|       |
 4788|    448|        len = SNMP_MAX_PACKET_LEN;
  ------------------
  |  |   49|    448|#define SNMP_MAX_PACKET_LEN (0x7fffffff)
  ------------------
 4789|    448|        DEBUGDUMPHEADER("recv", "Value");
  ------------------
  |  |   81|    448|	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|    448|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 448, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  180|    448|        __DBGPRINTINDENT("dumph_" token); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  177|    448|#define __DBGPRINTINDENT(token) __DBGMSGTL((token, "%*s", __DBGINDENT(), ""))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  166|    448|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  156|    448|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  149|    448|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  157|    448|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  181|    448|        debugmsg("dumph_" token,x); \
  |  |  |  |  182|    448|        if (debug_is_token_registered("dumpx" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  217|    896|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (182:13): [True: 448, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  183|    448|            debug_is_token_registered("dumpv" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  217|    448|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  184|    448|            (debug_is_token_registered("dumpx_" token) != SNMPERR_SUCCESS &&  \
  |  |  |  |  ------------------
  |  |  |  |  |  |  217|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (184:14): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  185|    448|             debug_is_token_registered("dumpv_" token) != SNMPERR_SUCCESS)) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |  217|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (185:14): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  186|    448|            debugmsg("dumph_" token,"\n"); \
  |  |  |  |  187|    448|        } else { \
  |  |  |  |  188|      0|            debugmsg("dumph_" token,"  "); \
  |  |  |  |  189|      0|        } \
  |  |  |  |  190|    448|        __DBGINDENTMORE()
  |  |  |  |  ------------------
  |  |  |  |  |  |  175|    448|#define __DBGINDENTMORE()  debug_indent_add(2)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (81:55): [Folded - Ignored]
  |  |  ------------------
  ------------------
 4790|    448|        switch ((short) vp->type) {
 4791|      9|        case ASN_INTEGER:
  ------------------
  |  |   75|      9|#define ASN_INTEGER	    0x02U
  ------------------
  |  Branch (4791:9): [True: 9, False: 439]
  ------------------
 4792|      9|            vp->val.integer = (long *) vp->buf;
 4793|      9|            vp->val_len = sizeof(long);
 4794|      9|            p = asn_parse_int(var_val, &len, &vp->type,
 4795|      9|                          (long *) vp->val.integer,
 4796|      9|                          sizeof(*vp->val.integer));
 4797|      9|            if (!p)
  ------------------
  |  Branch (4797:17): [True: 2, False: 7]
  ------------------
 4798|      2|                goto fail;
 4799|      7|            break;
 4800|     16|        case ASN_COUNTER:
  ------------------
  |  |   89|     16|#define ASN_COUNTER	(ASN_APPLICATION | 1)
  |  |  ------------------
  |  |  |  |   91|     16|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (4800:9): [True: 16, False: 432]
  ------------------
 4801|     58|        case ASN_GAUGE:
  ------------------
  |  |   90|     58|#define ASN_GAUGE	(ASN_APPLICATION | 2)
  |  |  ------------------
  |  |  |  |   91|     58|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (4801:9): [True: 42, False: 406]
  ------------------
 4802|     72|        case ASN_TIMETICKS:
  ------------------
  |  |   92|     72|#define ASN_TIMETICKS   (ASN_APPLICATION | 3)
  |  |  ------------------
  |  |  |  |   91|     72|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (4802:9): [True: 14, False: 434]
  ------------------
 4803|    104|        case ASN_UINTEGER:
  ------------------
  |  |  100|    104|#define ASN_UINTEGER    (ASN_APPLICATION | 7)   /* historic - don't use */
  |  |  ------------------
  |  |  |  |   91|    104|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (4803:9): [True: 32, False: 416]
  ------------------
 4804|    104|            vp->val.integer = (long *) vp->buf;
 4805|    104|            vp->val_len = sizeof(u_long);
 4806|    104|            p = asn_parse_unsigned_int(var_val, &len, &vp->type,
 4807|    104|                                   (u_long *) vp->val.integer,
 4808|    104|                                   vp->val_len);
 4809|    104|            if (!p)
  ------------------
  |  Branch (4809:17): [True: 10, False: 94]
  ------------------
 4810|     10|                goto fail;
 4811|     94|            break;
 4812|     94|#ifdef NETSNMP_WITH_OPAQUE_SPECIAL_TYPES
 4813|     94|        case ASN_OPAQUE_COUNTER64:
  ------------------
  |  |  156|      7|#define ASN_OPAQUE_COUNTER64 (ASN_OPAQUE_TAG2 + ASN_APP_COUNTER64)
  |  |  ------------------
  |  |  |  |  136|      7|#define ASN_OPAQUE_TAG2 0x30U
  |  |  ------------------
  |  |               #define ASN_OPAQUE_COUNTER64 (ASN_OPAQUE_TAG2 + ASN_APP_COUNTER64)
  |  |  ------------------
  |  |  |  |  146|      7|#define ASN_APP_COUNTER64 (ASN_APPLICATION | 6)
  |  |  |  |  ------------------
  |  |  |  |  |  |   91|      7|#define ASN_APPLICATION     0x40U
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (4813:9): [True: 7, False: 441]
  ------------------
 4814|     20|        case ASN_OPAQUE_U64:
  ------------------
  |  |  192|     20|#define ASN_OPAQUE_U64 (ASN_OPAQUE_TAG2 + ASN_APP_U64)
  |  |  ------------------
  |  |  |  |  136|     20|#define ASN_OPAQUE_TAG2 0x30U
  |  |  ------------------
  |  |               #define ASN_OPAQUE_U64 (ASN_OPAQUE_TAG2 + ASN_APP_U64)
  |  |  ------------------
  |  |  |  |  150|     20|#define ASN_APP_U64 (ASN_APPLICATION | 11)
  |  |  |  |  ------------------
  |  |  |  |  |  |   91|     20|#define ASN_APPLICATION     0x40U
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (4814:9): [True: 13, False: 435]
  ------------------
 4815|     20|#endif                          /* NETSNMP_WITH_OPAQUE_SPECIAL_TYPES */
 4816|    110|        case ASN_COUNTER64:
  ------------------
  |  |   99|    110|#define ASN_COUNTER64   (ASN_APPLICATION | 6)
  |  |  ------------------
  |  |  |  |   91|    110|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (4816:9): [True: 90, False: 358]
  ------------------
 4817|    110|            vp->val.counter64 = (struct counter64 *) vp->buf;
 4818|    110|            vp->val_len = sizeof(struct counter64);
 4819|    110|            p = asn_parse_unsigned_int64(var_val, &len, &vp->type,
 4820|    110|                                     (struct counter64 *) vp->val.
 4821|    110|                                     counter64, vp->val_len);
 4822|    110|            if (!p)
  ------------------
  |  Branch (4822:17): [True: 6, False: 104]
  ------------------
 4823|      6|                goto fail;
 4824|    104|            break;
 4825|    104|#ifdef NETSNMP_WITH_OPAQUE_SPECIAL_TYPES
 4826|    104|        case ASN_OPAQUE_FLOAT:
  ------------------
  |  |  165|     15|#define ASN_OPAQUE_FLOAT (ASN_OPAQUE_TAG2 + ASN_APP_FLOAT)
  |  |  ------------------
  |  |  |  |  136|     15|#define ASN_OPAQUE_TAG2 0x30U
  |  |  ------------------
  |  |               #define ASN_OPAQUE_FLOAT (ASN_OPAQUE_TAG2 + ASN_APP_FLOAT)
  |  |  ------------------
  |  |  |  |  147|     15|#define ASN_APP_FLOAT (ASN_APPLICATION | 8)
  |  |  |  |  ------------------
  |  |  |  |  |  |   91|     15|#define ASN_APPLICATION     0x40U
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (4826:9): [True: 15, False: 433]
  ------------------
 4827|     15|            vp->val.floatVal = (float *) vp->buf;
 4828|     15|            vp->val_len = sizeof(float);
 4829|     15|            p = asn_parse_float(var_val, &len, &vp->type,
 4830|     15|                            vp->val.floatVal, vp->val_len);
 4831|     15|            if (!p)
  ------------------
  |  Branch (4831:17): [True: 11, False: 4]
  ------------------
 4832|     11|                goto fail;
 4833|      4|            break;
 4834|     10|        case ASN_OPAQUE_DOUBLE:
  ------------------
  |  |  174|     10|#define ASN_OPAQUE_DOUBLE (ASN_OPAQUE_TAG2 + ASN_APP_DOUBLE)
  |  |  ------------------
  |  |  |  |  136|     10|#define ASN_OPAQUE_TAG2 0x30U
  |  |  ------------------
  |  |               #define ASN_OPAQUE_DOUBLE (ASN_OPAQUE_TAG2 + ASN_APP_DOUBLE)
  |  |  ------------------
  |  |  |  |  148|     10|#define ASN_APP_DOUBLE (ASN_APPLICATION | 9)
  |  |  |  |  ------------------
  |  |  |  |  |  |   91|     10|#define ASN_APPLICATION     0x40U
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (4834:9): [True: 10, False: 438]
  ------------------
 4835|     10|            vp->val.doubleVal = (double *) vp->buf;
 4836|     10|            vp->val_len = sizeof(double);
 4837|     10|            p = asn_parse_double(var_val, &len, &vp->type,
 4838|     10|                             vp->val.doubleVal, vp->val_len);
 4839|     10|            if (!p)
  ------------------
  |  Branch (4839:17): [True: 9, False: 1]
  ------------------
 4840|      9|                goto fail;
 4841|      1|            break;
 4842|    108|        case ASN_OPAQUE_I64:
  ------------------
  |  |  183|    108|#define ASN_OPAQUE_I64 (ASN_OPAQUE_TAG2 + ASN_APP_I64)
  |  |  ------------------
  |  |  |  |  136|    108|#define ASN_OPAQUE_TAG2 0x30U
  |  |  ------------------
  |  |               #define ASN_OPAQUE_I64 (ASN_OPAQUE_TAG2 + ASN_APP_I64)
  |  |  ------------------
  |  |  |  |  149|    108|#define ASN_APP_I64 (ASN_APPLICATION | 10)
  |  |  |  |  ------------------
  |  |  |  |  |  |   91|    108|#define ASN_APPLICATION     0x40U
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (4842:9): [True: 108, False: 340]
  ------------------
 4843|    108|            vp->val.counter64 = (struct counter64 *) vp->buf;
 4844|    108|            vp->val_len = sizeof(struct counter64);
 4845|    108|            p = asn_parse_signed_int64(var_val, &len, &vp->type,
 4846|    108|                                   (struct counter64 *) vp->val.counter64,
 4847|    108|                                   sizeof(*vp->val.counter64));
 4848|       |
 4849|    108|            if (!p)
  ------------------
  |  Branch (4849:17): [True: 14, False: 94]
  ------------------
 4850|     14|                goto fail;
 4851|     94|            break;
 4852|     94|#endif                          /* NETSNMP_WITH_OPAQUE_SPECIAL_TYPES */
 4853|     94|        case ASN_IPADDRESS:
  ------------------
  |  |   88|     10|#define ASN_IPADDRESS   (ASN_APPLICATION | 0)
  |  |  ------------------
  |  |  |  |   91|     10|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (4853:9): [True: 10, False: 438]
  ------------------
 4854|     10|            if (vp->val_len != 4)
  ------------------
  |  Branch (4854:17): [True: 4, False: 6]
  ------------------
 4855|      4|                goto fail;
 4856|     10|            NETSNMP_FALLTHROUGH;
  ------------------
  |  | 2390|      6|#    define NETSNMP_FALLTHROUGH __attribute__((__fallthrough__))
  ------------------
 4857|     19|        case ASN_OCTET_STR:
  ------------------
  |  |   78|     19|#define ASN_OCTET_STR	    0x04U
  ------------------
  |  Branch (4857:9): [True: 13, False: 435]
  ------------------
 4858|     31|        case ASN_OPAQUE:
  ------------------
  |  |   93|     31|#define ASN_OPAQUE	(ASN_APPLICATION | 4)   /* changed so no conflict with other includes */
  |  |  ------------------
  |  |  |  |   91|     31|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (4858:9): [True: 12, False: 436]
  ------------------
 4859|     37|        case ASN_NSAP:
  ------------------
  |  |   98|     37|#define ASN_NSAP	(ASN_APPLICATION | 5)   /* historic - don't use */
  |  |  ------------------
  |  |  |  |   91|     37|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (4859:9): [True: 6, False: 442]
  ------------------
 4860|     37|            if (vp->val_len < sizeof(vp->buf)) {
  ------------------
  |  Branch (4860:17): [True: 37, False: 0]
  ------------------
 4861|     37|                vp->val.string = (u_char *) vp->buf;
 4862|     37|            } else {
 4863|      0|                vp->val.string = (u_char *) malloc(vp->val_len);
 4864|      0|            }
 4865|     37|            if (vp->val.string == NULL) {
  ------------------
  |  Branch (4865:17): [True: 0, False: 37]
  ------------------
 4866|      0|                goto fail;
 4867|      0|            }
 4868|     37|            p = asn_parse_string(var_val, &len, &vp->type, vp->val.string,
 4869|     37|                             &vp->val_len);
 4870|     37|            if (!p)
  ------------------
  |  Branch (4870:17): [True: 0, False: 37]
  ------------------
 4871|      0|                goto fail;
 4872|     37|            break;
 4873|     37|        case ASN_OBJECT_ID:
  ------------------
  |  |   81|     26|#define ASN_OBJECT_ID	    0x06U
  ------------------
  |  Branch (4873:9): [True: 26, False: 422]
  ------------------
 4874|     26|            vp->val_len = MAX_OID_LEN;
  ------------------
  |  |  103|     26|#define MAX_OID_LEN	    128 /* max subid's in an oid */
  ------------------
 4875|     26|            p = asn_parse_objid(var_val, &len, &vp->type, objid, &vp->val_len);
 4876|     26|            if (!p)
  ------------------
  |  Branch (4876:17): [True: 1, False: 25]
  ------------------
 4877|      1|                goto fail;
 4878|     25|            vp->val_len *= sizeof(oid);
 4879|     25|            vp->val.objid = netsnmp_memdup(objid, vp->val_len);
 4880|     25|            if (vp->val.objid == NULL)
  ------------------
  |  Branch (4880:17): [True: 0, False: 25]
  ------------------
 4881|      0|                goto fail;
 4882|     25|            break;
 4883|     25|        case SNMP_NOSUCHOBJECT:
  ------------------
  |  |  201|      3|#define SNMP_NOSUCHOBJECT    (ASN_CONTEXT | ASN_PRIMITIVE | 0x0) /* 80=128 */
  |  |  ------------------
  |  |  |  |   92|      3|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_NOSUCHOBJECT    (ASN_CONTEXT | ASN_PRIMITIVE | 0x0) /* 80=128 */
  |  |  ------------------
  |  |  |  |   95|      3|#define ASN_PRIMITIVE	    0x00U
  |  |  ------------------
  ------------------
  |  Branch (4883:9): [True: 3, False: 445]
  ------------------
 4884|      6|        case SNMP_NOSUCHINSTANCE:
  ------------------
  |  |  202|      6|#define SNMP_NOSUCHINSTANCE  (ASN_CONTEXT | ASN_PRIMITIVE | 0x1) /* 81=129 */
  |  |  ------------------
  |  |  |  |   92|      6|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_NOSUCHINSTANCE  (ASN_CONTEXT | ASN_PRIMITIVE | 0x1) /* 81=129 */
  |  |  ------------------
  |  |  |  |   95|      6|#define ASN_PRIMITIVE	    0x00U
  |  |  ------------------
  ------------------
  |  Branch (4884:9): [True: 3, False: 445]
  ------------------
 4885|      9|        case SNMP_ENDOFMIBVIEW:
  ------------------
  |  |  203|      9|#define SNMP_ENDOFMIBVIEW    (ASN_CONTEXT | ASN_PRIMITIVE | 0x2) /* 82=130 */
  |  |  ------------------
  |  |  |  |   92|      9|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_ENDOFMIBVIEW    (ASN_CONTEXT | ASN_PRIMITIVE | 0x2) /* 82=130 */
  |  |  ------------------
  |  |  |  |   95|      9|#define ASN_PRIMITIVE	    0x00U
  |  |  ------------------
  ------------------
  |  Branch (4885:9): [True: 3, False: 445]
  ------------------
 4886|     12|        case ASN_NULL:
  ------------------
  |  |   79|     12|#define ASN_NULL	    0x05U
  ------------------
  |  Branch (4886:9): [True: 3, False: 445]
  ------------------
 4887|     12|            break;
 4888|     11|        case ASN_BIT_STR:
  ------------------
  |  |   77|     11|#define ASN_BIT_STR	    0x03U
  ------------------
  |  Branch (4888:9): [True: 11, False: 437]
  ------------------
 4889|     11|            vp->val.bitstring = (u_char *) malloc(vp->val_len);
 4890|     11|            if (vp->val.bitstring == NULL) {
  ------------------
  |  Branch (4890:17): [True: 0, False: 11]
  ------------------
 4891|      0|                goto fail;
 4892|      0|            }
 4893|     11|            p = asn_parse_bitstring(var_val, &len, &vp->type,
 4894|     11|                                vp->val.bitstring, &vp->val_len);
 4895|     11|            if (!p)
  ------------------
  |  Branch (4895:17): [True: 4, False: 7]
  ------------------
 4896|      4|                goto fail;
 4897|      7|            break;
 4898|      7|        default:
  ------------------
  |  Branch (4898:9): [True: 2, False: 446]
  ------------------
 4899|      2|            snmp_log(LOG_ERR, "bad type returned (%x)\n", vp->type);
 4900|      2|            goto fail;
 4901|      0|            break;
 4902|    448|        }
 4903|    385|        DEBUGINDENTADD(-4);
  ------------------
  |  |   75|    385|#define DEBUGINDENTADD(x)  do {if (_DBG_IF_) {__DBGINDENTADD(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|    385|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 385, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTADD(x)  do {if (_DBG_IF_) {__DBGINDENTADD(x);} }while(0)
  |  |  ------------------
  |  |  |  |  174|    385|#define __DBGINDENTADD(x)  debug_indent_add(x)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded - Ignored]
  |  |  ------------------
  ------------------
 4904|       |
 4905|    385|        if (NULL == vplast) {
  ------------------
  |  Branch (4905:13): [True: 339, False: 46]
  ------------------
 4906|    339|            pdu->variables = vp;
 4907|    339|        } else {
 4908|     46|            vplast->next_variable = vp;
 4909|     46|        }
 4910|    385|        vplast = vp;
 4911|    385|        vp = NULL;
 4912|    385|    }
 4913|     10|    return 0;
 4914|       |
 4915|    391|  fail:
 4916|    391|    {
 4917|    391|        const char *errstr = snmp_api_errstring(SNMPERR_SUCCESS);
  ------------------
  |  |  217|    391|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 4918|    391|        DEBUGMSGTL(("recv", "error while parsing VarBindList:%s\n", errstr));
  ------------------
  |  |   68|    391|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|    391|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 391, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|    391|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|    391|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|    391|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|    391|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
 4919|    391|    }
 4920|       |    /** if we were parsing a var, remove it from the pdu and free it */
 4921|    391|    if (vp)
  ------------------
  |  Branch (4921:9): [True: 386, False: 5]
  ------------------
 4922|    386|        snmp_free_var(vp);
 4923|       |
 4924|    391|    return -1;
 4925|    396|}
snmp_free_var_internals:
 5521|    771|{
 5522|    771|    if (!var)
  ------------------
  |  Branch (5522:9): [True: 0, False: 771]
  ------------------
 5523|      0|        return;
 5524|       |
 5525|    771|    if (var->name != var->name_loc)
  ------------------
  |  Branch (5525:9): [True: 323, False: 448]
  ------------------
 5526|    323|        SNMP_FREE(var->name);
  ------------------
  |  |   62|    323|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 323]
  |  |  |  Branch (62:66): [Folded - Ignored]
  |  |  ------------------
  ------------------
 5527|    771|    if (var->val.string != var->buf)
  ------------------
  |  Branch (5527:9): [True: 378, False: 393]
  ------------------
 5528|    378|        SNMP_FREE(var->val.string);
  ------------------
  |  |   62|    378|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 36, False: 342]
  |  |  |  Branch (62:66): [Folded - Ignored]
  |  |  ------------------
  ------------------
 5529|    771|    if (var->data) {
  ------------------
  |  Branch (5529:9): [True: 0, False: 771]
  ------------------
 5530|      0|        if (var->dataFreeHook) {
  ------------------
  |  Branch (5530:13): [True: 0, False: 0]
  ------------------
 5531|      0|            var->dataFreeHook(var->data);
 5532|      0|            var->data = NULL;
 5533|      0|        } else {
 5534|      0|            SNMP_FREE(var->data);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded - Ignored]
  |  |  ------------------
  ------------------
 5535|      0|        }
 5536|      0|    }
 5537|    771|}
snmp_free_var:
 5541|    771|{
 5542|    771|    snmp_free_var_internals(var);
 5543|    771|    free(var);
 5544|    771|}
snmp_free_varbind:
 5548|  1.74k|{
 5549|  1.74k|    netsnmp_variable_list *ptr;
 5550|  2.12k|    while (var) {
  ------------------
  |  Branch (5550:12): [True: 385, False: 1.74k]
  ------------------
 5551|    385|        ptr = var->next_variable;
 5552|    385|        snmp_free_var(var);
 5553|    385|        var = ptr;
 5554|    385|    }
 5555|  1.74k|}
snmp_free_pdu:
 5562|  1.74k|{
 5563|  1.74k|    struct snmp_secmod_def *sptr;
 5564|       |
 5565|  1.74k|    if (!pdu)
  ------------------
  |  Branch (5565:9): [True: 0, False: 1.74k]
  ------------------
 5566|      0|        return;
 5567|       |
 5568|  1.74k|    free_securityStateRef(pdu);
 5569|       |
 5570|  1.74k|    sptr = find_sec_mod(pdu->securityModel);
 5571|  1.74k|    if (sptr && sptr->pdu_free)
  ------------------
  |  Branch (5571:9): [True: 0, False: 1.74k]
  |  Branch (5571:17): [True: 0, False: 0]
  ------------------
 5572|      0|        (*sptr->pdu_free)(pdu);
 5573|       |
 5574|  1.74k|    snmp_free_varbind(pdu->variables);
 5575|  1.74k|    free(pdu->enterprise);
 5576|  1.74k|    free(pdu->community);
 5577|  1.74k|    free(pdu->contextEngineID);
 5578|  1.74k|    free(pdu->securityEngineID);
 5579|  1.74k|    free(pdu->contextName);
 5580|  1.74k|    free(pdu->securityName);
 5581|  1.74k|    free(pdu->transport_data);
 5582|  1.74k|    free(pdu);
 5583|  1.74k|}
snmp_create_sess_pdu:
 5588|  1.74k|{
 5589|  1.74k|    netsnmp_pdu *pdu = calloc(1, sizeof(netsnmp_pdu));
 5590|  1.74k|    if (pdu == NULL) {
  ------------------
  |  Branch (5590:9): [True: 0, False: 1.74k]
  ------------------
 5591|      0|        DEBUGMSGTL(("sess_process_packet", "can't malloc space for PDU\n"));
  ------------------
  |  |   68|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
 5592|      0|        return NULL;
 5593|      0|    }
 5594|       |
 5595|       |    /*
 5596|       |     * Save the transport-level data specific to this reception (e.g. UDP
 5597|       |     * source address).  
 5598|       |     */
 5599|       |
 5600|  1.74k|    pdu->transport_data = opaque;
 5601|  1.74k|    pdu->transport_data_length = olength;
 5602|  1.74k|    pdu->tDomain = transport->domain;
 5603|  1.74k|    pdu->tDomainLen = transport->domain_length;
 5604|  1.74k|    return pdu;
 5605|  1.74k|}
snmp_read2:
 5994|  1.74k|{
 5995|  1.74k|    struct session_list *slp;
 5996|  1.74k|    snmp_res_lock(MT_LIBRARY_ID, MT_LIB_SESSION);
  ------------------
  |  |   79|  1.74k|#define snmp_res_lock(x,y) do {} while (0)
  |  |  ------------------
  |  |  |  Branch (79:41): [Folded - Ignored]
  |  |  ------------------
  ------------------
 5997|  1.52M|    for (slp = Sessions; slp; slp = slp->next) {
  ------------------
  |  Branch (5997:26): [True: 1.52M, False: 1.74k]
  ------------------
 5998|  1.52M|        snmp_sess_read2(slp, fdset);
 5999|  1.52M|    }
 6000|  1.74k|    snmp_res_unlock(MT_LIBRARY_ID, MT_LIB_SESSION);
  ------------------
  |  |   80|  1.74k|#define snmp_res_unlock(x,y) do {} while (0)
  |  |  ------------------
  |  |  |  Branch (80:43): [Folded - Ignored]
  |  |  ------------------
  ------------------
 6001|  1.74k|}
_sess_read:
 6160|  1.52M|{
 6161|  1.52M|    netsnmp_session *sp = slp ? slp->session : NULL;
  ------------------
  |  Branch (6161:27): [True: 1.52M, False: 0]
  ------------------
 6162|  1.52M|    struct snmp_internal_session *isp = slp ? slp->internal : NULL;
  ------------------
  |  Branch (6162:41): [True: 1.52M, False: 0]
  ------------------
 6163|  1.52M|    netsnmp_transport *transport = slp ? slp->transport : NULL;
  ------------------
  |  Branch (6163:36): [True: 1.52M, False: 0]
  ------------------
 6164|  1.52M|    size_t          pdulen = 0, rxbuf_len = SNMP_MAX_RCV_MSG_SIZE;
  ------------------
  |  |  141|  1.52M|#define SNMP_MAX_RCV_MSG_SIZE      65536
  ------------------
 6165|  1.52M|    u_char         *rxbuf = NULL;
 6166|  1.52M|    int             length = 0, olength = 0, rc = 0;
 6167|  1.52M|    void           *opaque = NULL;
 6168|       |
 6169|  1.52M|    if (NULL == slp || NULL == sp || NULL == isp || NULL == transport) {
  ------------------
  |  Branch (6169:9): [True: 0, False: 1.52M]
  |  Branch (6169:24): [True: 0, False: 1.52M]
  |  Branch (6169:38): [True: 0, False: 1.52M]
  |  Branch (6169:53): [True: 0, False: 1.52M]
  ------------------
 6170|      0|        snmp_log(LOG_ERR, "bad parameters to _sess_read\n");
 6171|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  218|      0|#define SNMPERR_GENERR			(-1)
  ------------------
 6172|      0|    }
 6173|       |
 6174|       |    /* to avoid subagent crash */ 
 6175|  1.52M|    if (transport->sock < 0) { 
  ------------------
  |  Branch (6175:9): [True: 0, False: 1.52M]
  ------------------
 6176|      0|        snmp_log (LOG_INFO, "transport->sock got negative fd value %d\n",
 6177|      0|                  transport->sock);
 6178|      0|        return 0; 
 6179|      0|    }
 6180|       |
 6181|  1.52M|    if (!fdset || !(NETSNMP_LARGE_FD_ISSET(transport->sock, fdset))) {
  ------------------
  |  |   50|  1.52M|                    netsnmp_large_fd_is_set(fd, fdset)
  ------------------
  |  Branch (6181:9): [True: 0, False: 1.52M]
  |  Branch (6181:19): [True: 1.51M, False: 10.4k]
  ------------------
 6182|  1.51M|        DEBUGMSGTL(("sess_read", "not reading %d (fdset %p set %d)\n",
  ------------------
  |  |   68|  1.51M|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|  1.51M|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 1.51M, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|  3.03M|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|  1.51M|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|  1.51M|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|  1.51M|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (166:52): [True: 1.51M, False: 0]
  |  |  |  |  |  Branch (166:64): [True: 1.51M, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
 6183|  1.51M|                    transport->sock, fdset,
 6184|  1.51M|                    fdset ? NETSNMP_LARGE_FD_ISSET(transport->sock, fdset)
 6185|  1.51M|		    : -9));
 6186|  1.51M|        return 0;
 6187|  1.51M|    }
 6188|       |
 6189|  10.4k|    sp->s_snmp_errno = 0;
 6190|  10.4k|    sp->s_errno = 0;
 6191|       |
 6192|  10.4k|    if (transport->flags & NETSNMP_TRANSPORT_FLAG_LISTEN)
  ------------------
  |  |   52|  10.4k|#define		NETSNMP_TRANSPORT_FLAG_LISTEN	 0x02
  ------------------
  |  Branch (6192:9): [True: 0, False: 10.4k]
  ------------------
 6193|      0|        return _sess_read_accept(slp);
 6194|       |
 6195|  10.4k|    if (!(transport->flags & NETSNMP_TRANSPORT_FLAG_STREAM)) {
  ------------------
  |  |   51|  10.4k|#define		NETSNMP_TRANSPORT_FLAG_STREAM	 0x01
  ------------------
  |  Branch (6195:9): [True: 10.4k, False: 0]
  ------------------
 6196|  10.4k|        snmp_rcv_packet rcvp;
 6197|  10.4k|        memset(&rcvp, 0x0, sizeof(rcvp));
 6198|       |
 6199|       |        /** read the packet */
 6200|  10.4k|        rc = _sess_read_dgram_packet(slp, fdset, &rcvp);
 6201|  10.4k|        if (-1 == rc) /* protocol error */
  ------------------
  |  Branch (6201:13): [True: 8.72k, False: 1.74k]
  ------------------
 6202|  8.72k|            return -1;
 6203|  1.74k|        else if (-2 == rc) /* no packet to process */
  ------------------
  |  Branch (6203:18): [True: 0, False: 1.74k]
  ------------------
 6204|      0|            return 0;
 6205|       |
 6206|  1.74k|        rc = _sess_process_packet(slp, sp, isp, transport,
 6207|  1.74k|                                  rcvp.opaque, rcvp.olength,
 6208|  1.74k|                                  rcvp.packet, rcvp.packet_len);
 6209|  1.74k|        SNMP_FREE(rcvp.packet);
  ------------------
  |  |   62|  1.74k|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 1.74k, False: 0]
  |  |  |  Branch (62:66): [Folded - Ignored]
  |  |  ------------------
  ------------------
 6210|       |        /** opaque is freed in _sess_process_packet */
 6211|  1.74k|        return rc;
 6212|  10.4k|    }
 6213|       |
 6214|       |    /** stream transport */
 6215|       |
 6216|      0|        if (isp->packet == NULL) {
  ------------------
  |  Branch (6216:13): [True: 0, False: 0]
  ------------------
 6217|       |            /*
 6218|       |             * We have no saved packet.  Allocate one.  
 6219|       |             */
 6220|      0|            if ((isp->packet = (u_char *) malloc(rxbuf_len)) == NULL) {
  ------------------
  |  Branch (6220:17): [True: 0, False: 0]
  ------------------
 6221|      0|                DEBUGMSGTL(("sess_read", "can't malloc %" NETSNMP_PRIz
  ------------------
  |  |   68|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
 6222|      0|                            "u bytes for rxbuf\n", rxbuf_len));
 6223|      0|                return 0;
 6224|      0|            } else {
 6225|      0|                rxbuf = isp->packet;
 6226|      0|                isp->packet_size = rxbuf_len;
 6227|      0|                isp->packet_len = 0;
 6228|      0|            }
 6229|      0|        } else {
 6230|       |            /*
 6231|       |             * We have saved a partial packet from last time.  Extend that, if
 6232|       |             * necessary, and receive new data after the old data.  
 6233|       |             */
 6234|      0|            u_char         *newbuf;
 6235|       |
 6236|      0|            if (isp->packet_size < isp->packet_len + rxbuf_len) {
  ------------------
  |  Branch (6236:17): [True: 0, False: 0]
  ------------------
 6237|      0|                newbuf =
 6238|      0|                    (u_char *) realloc(isp->packet,
 6239|      0|                                       isp->packet_len + rxbuf_len);
 6240|      0|                if (newbuf == NULL) {
  ------------------
  |  Branch (6240:21): [True: 0, False: 0]
  ------------------
 6241|      0|                    DEBUGMSGTL(("sess_read",
  ------------------
  |  |   68|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
 6242|      0|                                "can't malloc %" NETSNMP_PRIz
 6243|      0|                                "u more for rxbuf (%" NETSNMP_PRIz "u tot)\n",
 6244|      0|                                rxbuf_len, isp->packet_len + rxbuf_len));
 6245|      0|                    return 0;
 6246|      0|                } else {
 6247|      0|                    isp->packet = newbuf;
 6248|      0|                    isp->packet_size = isp->packet_len + rxbuf_len;
 6249|      0|                    rxbuf = isp->packet + isp->packet_len;
 6250|      0|                }
 6251|      0|            } else {
 6252|      0|                rxbuf = isp->packet + isp->packet_len;
 6253|      0|                rxbuf_len = isp->packet_size - isp->packet_len;
 6254|      0|            }
 6255|      0|        }
 6256|       |
 6257|      0|    length = netsnmp_transport_recv(transport, rxbuf, rxbuf_len, &opaque,
 6258|      0|                                    &olength);
 6259|       |
 6260|      0|    if (0 == length && transport->flags & NETSNMP_TRANSPORT_FLAG_EMPTY_PKT) {
  ------------------
  |  |   56|      0|#define		NETSNMP_TRANSPORT_FLAG_EMPTY_PKT 0x10
  ------------------
  |  Branch (6260:9): [True: 0, False: 0]
  |  Branch (6260:24): [True: 0, False: 0]
  ------------------
 6261|       |        /* this allows for a transport that needs to return from
 6262|       |         * packet processing that doesn't necessarily have any
 6263|       |         * consumable data in it. */
 6264|       |
 6265|       |        /* reset the flag since it's a per-message flag */
 6266|      0|        transport->flags &= (~NETSNMP_TRANSPORT_FLAG_EMPTY_PKT);
  ------------------
  |  |   56|      0|#define		NETSNMP_TRANSPORT_FLAG_EMPTY_PKT 0x10
  ------------------
 6267|       |
 6268|      0|        return 0;
 6269|      0|    }
 6270|       |
 6271|       |    /*
 6272|       |     * Remote end closed connection.  
 6273|       |     */
 6274|      0|    if (length <= 0) {
  ------------------
  |  Branch (6274:9): [True: 0, False: 0]
  ------------------
 6275|       |        /*
 6276|       |         * Alert the application if possible.  
 6277|       |         */
 6278|      0|        if (sp->callback != NULL) {
  ------------------
  |  Branch (6278:13): [True: 0, False: 0]
  ------------------
 6279|      0|            DEBUGMSGTL(("sess_read", "perform callback with op=DISCONNECT\n"));
  ------------------
  |  |   68|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
 6280|      0|            (void) sp->callback(NETSNMP_CALLBACK_OP_DISCONNECT, sp, 0,
  ------------------
  |  |  356|      0|#define NETSNMP_CALLBACK_OP_DISCONNECT		5
  ------------------
 6281|      0|                                NULL, sp->callback_magic);
 6282|      0|        }
 6283|       |        /*
 6284|       |         * Close socket and mark session for deletion.  
 6285|       |         */
 6286|      0|        DEBUGMSGTL(("sess_read", "fd %d closed\n", transport->sock));
  ------------------
  |  |   68|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
 6287|      0|        transport->f_close(transport);
 6288|      0|        SNMP_FREE(isp->packet);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded - Ignored]
  |  |  ------------------
  ------------------
 6289|      0|        SNMP_FREE(opaque);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded - Ignored]
  |  |  ------------------
  ------------------
 6290|      0|        return -1;
 6291|      0|    }
 6292|       |
 6293|      0|    {
 6294|      0|        u_char *pptr = isp->packet;
 6295|      0|	void *ocopy = NULL;
 6296|       |
 6297|      0|        isp->packet_len += length;
 6298|       |
 6299|      0|        while (isp->packet_len > 0) {
  ------------------
  |  Branch (6299:16): [True: 0, False: 0]
  ------------------
 6300|       |
 6301|       |            /*
 6302|       |             * Get the total data length we're expecting (and need to wait
 6303|       |             * for).
 6304|       |             */
 6305|      0|            if (isp->check_packet) {
  ------------------
  |  Branch (6305:17): [True: 0, False: 0]
  ------------------
 6306|      0|                pdulen = isp->check_packet(pptr, isp->packet_len);
 6307|      0|            } else {
 6308|      0|                pdulen = asn_check_packet(pptr, isp->packet_len);
 6309|      0|            }
 6310|       |
 6311|      0|            DEBUGMSGTL(("sess_read",
  ------------------
  |  |   68|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
 6312|      0|                        "  loop packet_len %" NETSNMP_PRIz "u, PDU length %"
 6313|      0|                        NETSNMP_PRIz "u\n", isp->packet_len, pdulen));
 6314|       |
 6315|      0|            if (pdulen > SNMP_MAX_PACKET_LEN) {
  ------------------
  |  |   49|      0|#define SNMP_MAX_PACKET_LEN (0x7fffffff)
  ------------------
  |  Branch (6315:17): [True: 0, False: 0]
  ------------------
 6316|       |                /*
 6317|       |                 * Illegal length, drop the connection.  
 6318|       |                 */
 6319|      0|                snmp_log(LOG_ERR, 
 6320|      0|			 "Received broken packet. Closing session.\n");
 6321|      0|		if (sp->callback != NULL) {
  ------------------
  |  Branch (6321:7): [True: 0, False: 0]
  ------------------
 6322|      0|		  DEBUGMSGTL(("sess_read",
  ------------------
  |  |   68|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
 6323|      0|			      "perform callback with op=DISCONNECT\n"));
 6324|      0|		  (void)sp->callback(NETSNMP_CALLBACK_OP_DISCONNECT,
  ------------------
  |  |  356|      0|#define NETSNMP_CALLBACK_OP_DISCONNECT		5
  ------------------
 6325|      0|				     sp, 0, NULL, sp->callback_magic);
 6326|      0|		}
 6327|      0|		DEBUGMSGTL(("sess_read", "fd %d closed\n", transport->sock));
  ------------------
  |  |   68|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
 6328|      0|                transport->f_close(transport);
 6329|      0|                SNMP_FREE(opaque);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded - Ignored]
  |  |  ------------------
  ------------------
 6330|       |                /** XXX-rks: why no SNMP_FREE(isp->packet); ?? */
 6331|      0|                return -1;
 6332|      0|            }
 6333|       |
 6334|      0|            if (pdulen > isp->packet_len || pdulen == 0) {
  ------------------
  |  Branch (6334:17): [True: 0, False: 0]
  |  Branch (6334:45): [True: 0, False: 0]
  ------------------
 6335|       |                /*
 6336|       |                 * We don't have a complete packet yet.  If we've already
 6337|       |                 * processed a packet, break out so we'll shift this packet
 6338|       |                 * to the start of the buffer. If we're already at the
 6339|       |                 * start, simply return and wait for more data to arrive.
 6340|       |                 */
 6341|      0|                DEBUGMSGTL(("sess_read",
  ------------------
  |  |   68|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
 6342|      0|                            "pkt not complete (need %" NETSNMP_PRIz "u got %"
 6343|      0|                            NETSNMP_PRIz "u so far)\n", pdulen,
 6344|      0|                            isp->packet_len));
 6345|       |
 6346|      0|                if (pptr != isp->packet)
  ------------------
  |  Branch (6346:21): [True: 0, False: 0]
  ------------------
 6347|      0|                    break; /* opaque freed for us outside of loop. */
 6348|       |
 6349|      0|                SNMP_FREE(opaque);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded - Ignored]
  |  |  ------------------
  ------------------
 6350|      0|                return 0;
 6351|      0|            }
 6352|       |
 6353|       |            /*  We have *at least* one complete packet in the buffer now.  If
 6354|       |		we have possibly more than one packet, we must copy the opaque
 6355|       |		pointer because we may need to reuse it for a later packet.  */
 6356|       |
 6357|      0|	    if (pdulen < isp->packet_len) {
  ------------------
  |  Branch (6357:10): [True: 0, False: 0]
  ------------------
 6358|      0|		if (olength > 0 && opaque != NULL) {
  ------------------
  |  Branch (6358:7): [True: 0, False: 0]
  |  Branch (6358:22): [True: 0, False: 0]
  ------------------
 6359|      0|		    ocopy = malloc(olength);
 6360|      0|		    if (ocopy != NULL) {
  ------------------
  |  Branch (6360:11): [True: 0, False: 0]
  ------------------
 6361|      0|			memcpy(ocopy, opaque, olength);
 6362|      0|		    }
 6363|      0|		}
 6364|      0|	    } else if (pdulen == isp->packet_len) {
  ------------------
  |  Branch (6364:17): [True: 0, False: 0]
  ------------------
 6365|       |		/*  Common case -- exactly one packet.  No need to copy the
 6366|       |		    opaque pointer.  */
 6367|      0|		ocopy = opaque;
 6368|      0|		opaque = NULL;
 6369|      0|	    }
 6370|       |
 6371|      0|            if ((rc = _sess_process_packet(slp, sp, isp, transport,
  ------------------
  |  Branch (6371:17): [True: 0, False: 0]
  ------------------
 6372|      0|                                           ocopy, ocopy?olength:0, pptr,
  ------------------
  |  Branch (6372:51): [True: 0, False: 0]
  ------------------
 6373|      0|                                           pdulen))) {
 6374|       |                /*
 6375|       |                 * Something went wrong while processing this packet -- set the
 6376|       |                 * errno.  
 6377|       |                 */
 6378|      0|                if (sp->s_snmp_errno != 0) {
  ------------------
  |  Branch (6378:21): [True: 0, False: 0]
  ------------------
 6379|      0|                    SET_SNMP_ERROR(sp->s_snmp_errno);
  ------------------
  |  |   56|      0|#define SET_SNMP_ERROR(x) snmp_errno=(x)
  ------------------
 6380|      0|                }
 6381|      0|            }
 6382|       |
 6383|       |	    /*  ocopy has been free()d by _sess_process_packet by this point,
 6384|       |		so set it to NULL.  */
 6385|       |
 6386|      0|	    ocopy = NULL;
 6387|       |
 6388|       |	    /*  Step past the packet we've just dealt with.  */
 6389|       |
 6390|      0|            pptr += pdulen;
 6391|      0|            isp->packet_len -= pdulen;
 6392|      0|        }
 6393|       |
 6394|       |	/*  If we had more than one packet, then we were working with copies
 6395|       |	    of the opaque pointer, so we still need to free() the opaque
 6396|       |	    pointer itself.  */
 6397|       |
 6398|      0|	SNMP_FREE(opaque);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded - Ignored]
  |  |  ------------------
  ------------------
 6399|       |
 6400|      0|        if (isp->packet_len >= SNMP_MAX_PACKET_LEN) {
  ------------------
  |  |   49|      0|#define SNMP_MAX_PACKET_LEN (0x7fffffff)
  ------------------
  |  Branch (6400:13): [True: 0, False: 0]
  ------------------
 6401|       |            /*
 6402|       |             * Obviously this should never happen!  
 6403|       |             */
 6404|      0|            snmp_log(LOG_ERR,
 6405|      0|                     "too large packet_len = %" NETSNMP_PRIz
 6406|      0|                     "u, dropping connection %d\n",
 6407|      0|                     isp->packet_len, transport->sock);
 6408|      0|            transport->f_close(transport);
 6409|       |            /** XXX-rks: why no SNMP_FREE(isp->packet); ?? */
 6410|      0|            return -1;
 6411|      0|        } else if (isp->packet_len == 0) {
  ------------------
  |  Branch (6411:20): [True: 0, False: 0]
  ------------------
 6412|       |            /*
 6413|       |             * This is good: it means the packet buffer contained an integral
 6414|       |             * number of PDUs, so we don't have to save any data for next
 6415|       |             * time.  We can free() the buffer now to keep the memory
 6416|       |             * footprint down.
 6417|       |             */
 6418|      0|            SNMP_FREE(isp->packet);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded - Ignored]
  |  |  ------------------
  ------------------
 6419|      0|            isp->packet_size = 0;
 6420|      0|            isp->packet_len = 0;
 6421|      0|            return rc;
 6422|      0|        }
 6423|       |
 6424|       |        /*
 6425|       |         * If we get here, then there is a partial packet of length
 6426|       |         * isp->packet_len bytes starting at pptr left over.  Move that to the
 6427|       |         * start of the buffer, and then realloc() the buffer down to size to
 6428|       |         * reduce the memory footprint.  
 6429|       |         */
 6430|       |
 6431|      0|        memmove(isp->packet, pptr, isp->packet_len);
 6432|      0|        DEBUGMSGTL(("sess_read",
  ------------------
  |  |   68|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
 6433|      0|                    "end: memmove(%p, %p, %" NETSNMP_PRIz "u); realloc(%p, %"
 6434|      0|                    NETSNMP_PRIz "u)\n",
 6435|      0|                    isp->packet, pptr, isp->packet_len,
 6436|      0|		    isp->packet, isp->packet_len));
 6437|       |
 6438|      0|        if ((rxbuf = (u_char *)realloc(isp->packet, isp->packet_len)) == NULL) {
  ------------------
  |  Branch (6438:13): [True: 0, False: 0]
  ------------------
 6439|       |            /*
 6440|       |             * I don't see why this should ever fail, but it's not a big deal.
 6441|       |             */
 6442|      0|            DEBUGMSGTL(("sess_read", "realloc() failed\n"));
  ------------------
  |  |   68|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
 6443|      0|        } else {
 6444|      0|            DEBUGMSGTL(("sess_read", "realloc() okay, old buffer %p, new %p\n",
  ------------------
  |  |   68|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
 6445|      0|                        isp->packet, rxbuf));
 6446|      0|            isp->packet = rxbuf;
 6447|      0|            isp->packet_size = isp->packet_len;
 6448|      0|        }
 6449|      0|    }
 6450|       |
 6451|      0|    return rc;
 6452|      0|}
snmp_sess_read2:
 6474|  1.52M|{
 6475|  1.52M|    netsnmp_session *pss;
 6476|  1.52M|    int             rc;
 6477|       |
 6478|  1.52M|    rc = _sess_read(slp, fdset);
 6479|  1.52M|    pss = slp->session;
 6480|  1.52M|    if (rc && pss->s_snmp_errno) {
  ------------------
  |  Branch (6480:9): [True: 10.4k, False: 1.51M]
  |  Branch (6480:15): [True: 10.4k, False: 0]
  ------------------
 6481|  10.4k|        SET_SNMP_ERROR(pss->s_snmp_errno);
  ------------------
  |  |   56|  10.4k|#define SET_SNMP_ERROR(x) snmp_errno=(x)
  ------------------
 6482|  10.4k|    }
 6483|  1.52M|    return rc;
 6484|  1.52M|}
snmp_oid_compare:
 6997|      6|{
 6998|      6|    register int    len;
 6999|      6|    register const oid *name1 = in_name1;
 7000|      6|    register const oid *name2 = in_name2;
 7001|       |
 7002|       |    /*
 7003|       |     * len = minimum of len1 and len2 
 7004|       |     */
 7005|      6|    if (len1 < len2)
  ------------------
  |  Branch (7005:9): [True: 0, False: 6]
  ------------------
 7006|      0|        len = len1;
 7007|      6|    else
 7008|      6|        len = len2;
 7009|       |    /*
 7010|       |     * find first non-matching OID 
 7011|       |     */
 7012|     62|    while (len-- > 0) {
  ------------------
  |  Branch (7012:12): [True: 60, False: 2]
  ------------------
 7013|       |        /*
 7014|       |         * these must be done in seperate comparisons, since
 7015|       |         * subtracting them and using that result has problems with
 7016|       |         * subids > 2^31. 
 7017|       |         */
 7018|     60|        if (*(name1) != *(name2)) {
  ------------------
  |  Branch (7018:13): [True: 4, False: 56]
  ------------------
 7019|      4|            if (*(name1) < *(name2))
  ------------------
  |  Branch (7019:17): [True: 2, False: 2]
  ------------------
 7020|      2|                return -1;
 7021|      2|            return 1;
 7022|      4|        }
 7023|     56|        name1++;
 7024|     56|        name2++;
 7025|     56|    }
 7026|       |    /*
 7027|       |     * both OIDs equal up to length of shorter OID 
 7028|       |     */
 7029|      2|    if (len1 < len2)
  ------------------
  |  Branch (7029:9): [True: 0, False: 2]
  ------------------
 7030|      0|        return -1;
 7031|      2|    if (len2 < len1)
  ------------------
  |  Branch (7031:9): [True: 0, False: 2]
  ------------------
 7032|      0|        return 1;
 7033|      2|    return 0;
 7034|      2|}
netsnmp_oid_equals:
 7134|     66|{
 7135|     66|    register const oid *name1 = in_name1;
 7136|     66|    register const oid *name2 = in_name2;
 7137|     66|    register int    len = len1;
 7138|       |
 7139|       |    /*
 7140|       |     * len = minimum of len1 and len2 
 7141|       |     */
 7142|     66|    if (len1 != len2)
  ------------------
  |  Branch (7142:9): [True: 44, False: 22]
  ------------------
 7143|     44|        return 1;
 7144|       |    /*
 7145|       |     * Handle 'null' OIDs
 7146|       |     */
 7147|     22|    if (len1 == 0)
  ------------------
  |  Branch (7147:9): [True: 0, False: 22]
  ------------------
 7148|      0|        return 0;   /* Two null OIDs are (trivially) the same */
 7149|     22|    if (!name1 || !name2)
  ------------------
  |  Branch (7149:9): [True: 0, False: 22]
  |  Branch (7149:19): [True: 0, False: 22]
  ------------------
 7150|      0|        return 1;   /* Otherwise something's wrong, so report a non-match */
 7151|       |    /*
 7152|       |     * find first non-matching OID 
 7153|       |     */
 7154|    187|    while (len-- > 0) {
  ------------------
  |  Branch (7154:12): [True: 187, False: 0]
  ------------------
 7155|       |        /*
 7156|       |         * these must be done in seperate comparisons, since
 7157|       |         * subtracting them and using that result has problems with
 7158|       |         * subids > 2^31. 
 7159|       |         */
 7160|    187|        if (*(name1++) != *(name2++))
  ------------------
  |  Branch (7160:13): [True: 22, False: 165]
  ------------------
 7161|     22|            return 1;
 7162|    187|    }
 7163|      0|    return 0;
 7164|     22|}
snmp_duplicate_objid:
 7960|  3.49k|{
 7961|  3.49k|    oid            *returnOid;
 7962|  3.49k|    if (objToCopy != NULL && objToCopyLen != 0) {
  ------------------
  |  Branch (7962:9): [True: 3.49k, False: 0]
  |  Branch (7962:30): [True: 3.49k, False: 0]
  ------------------
 7963|  3.49k|        returnOid = (oid *) malloc(objToCopyLen * sizeof(oid));
 7964|  3.49k|        if (returnOid) {
  ------------------
  |  Branch (7964:13): [True: 3.49k, False: 0]
  ------------------
 7965|  3.49k|            memcpy(returnOid, objToCopy, objToCopyLen * sizeof(oid));
 7966|  3.49k|        }
 7967|  3.49k|    } else
 7968|      0|        returnOid = NULL;
 7969|  3.49k|    return returnOid;
 7970|  3.49k|}
snmp_increment_statistic:
 7980|    782|{
 7981|    782|    if (which >= 0 && which < NETSNMP_STAT_MAX_STATS) {
  ------------------
  |  |  754|    782|#define  NETSNMP_STAT_MAX_STATS              (STAT_TLSTM_STATS_END+1)
  |  |  ------------------
  |  |  |  |  750|    782|#define  STAT_TLSTM_STATS_END          STAT_TLSTM_SNMPTLSTMSESSIONINVALIDCACHES
  |  |  |  |  ------------------
  |  |  |  |  |  |  747|    782|#define  STAT_TLSTM_SNMPTLSTMSESSIONINVALIDCACHES              56
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (7981:9): [True: 782, False: 0]
  |  Branch (7981:23): [True: 782, False: 0]
  ------------------
 7982|    782|        statistics[which]++;
 7983|    782|        return statistics[which];
 7984|    782|    }
 7985|      0|    return 0;
 7986|    782|}
snmp_init_statistics:
 8008|      1|{
 8009|      1|    memset(statistics, 0, sizeof(statistics));
 8010|      1|}
snmp_api.c:_init_snmp:
  697|  3.49k|{
  698|       |
  699|  3.49k|    struct timeval  tv;
  700|  3.49k|    long            tmpReqid, tmpMsgid;
  701|       |
  702|  3.49k|    if (_init_snmp_init_done)
  ------------------
  |  Branch (702:9): [True: 3.49k, False: 1]
  ------------------
  703|  3.49k|        return;
  704|      1|    _init_snmp_init_done = 1;
  705|      1|    Reqid = 1;
  706|       |
  707|      1|    snmp_res_init();            /* initialize the mt locking structures */
  ------------------
  |  |   78|      1|#define snmp_res_init() do {} while (0)
  |  |  ------------------
  |  |  |  Branch (78:38): [Folded - Ignored]
  |  |  ------------------
  ------------------
  708|      1|#ifndef NETSNMP_DISABLE_MIB_LOADING
  709|      1|    netsnmp_init_mib_internals();
  710|      1|#endif /* NETSNMP_DISABLE_MIB_LOADING */
  711|      1|    netsnmp_tdomain_init();
  712|       |
  713|      1|    gettimeofday(&tv, (struct timezone *) 0);
  714|       |    /*
  715|       |     * Now = tv;
  716|       |     */
  717|       |
  718|       |    /*
  719|       |     * get pseudo-random values for request ID and message ID 
  720|       |     */
  721|      1|    netsnmp_srandom((unsigned)(tv.tv_sec ^ tv.tv_usec));
  722|      1|    tmpReqid = netsnmp_random();
  723|      1|    tmpMsgid = netsnmp_random();
  724|       |
  725|       |    /*
  726|       |     * don't allow zero value to repeat init 
  727|       |     */
  728|      1|    if (tmpReqid == 0)
  ------------------
  |  Branch (728:9): [True: 0, False: 1]
  ------------------
  729|      0|        tmpReqid = 1;
  730|      1|    if (tmpMsgid == 0)
  ------------------
  |  Branch (730:9): [True: 0, False: 1]
  ------------------
  731|      0|        tmpMsgid = 1;
  732|      1|    Reqid = tmpReqid;
  733|      1|    Msgid = tmpMsgid;
  734|       |
  735|      1|    netsnmp_register_default_domain("snmp", "udp udp6");
  736|      1|    netsnmp_register_default_domain("snmptrap", "udp udp6");
  737|       |
  738|      1|    netsnmp_register_default_target("snmp", "udp", ":161");
  739|      1|    netsnmp_register_default_target("snmp", "tcp", ":161");
  740|      1|    netsnmp_register_default_target("snmp", "udp6", ":161");
  741|      1|    netsnmp_register_default_target("snmp", "tcp6", ":161");
  742|      1|    netsnmp_register_default_target("snmp", "dtlsudp", ":10161");
  743|      1|    netsnmp_register_default_target("snmp", "tlstcp", ":10161");
  744|      1|    netsnmp_register_default_target("snmp", "ipx", "/36879");
  745|       |
  746|      1|    netsnmp_register_default_target("snmptrap", "udp", ":162");
  747|      1|    netsnmp_register_default_target("snmptrap", "tcp", ":162");
  748|      1|    netsnmp_register_default_target("snmptrap", "udp6", ":162");
  749|      1|    netsnmp_register_default_target("snmptrap", "tcp6", ":162");
  750|      1|    netsnmp_register_default_target("snmptrap", "dtlsudp", ":10162");
  751|      1|    netsnmp_register_default_target("snmptrap", "tlstcp", ":10162");
  752|      1|    netsnmp_register_default_target("snmptrap", "ipx", "/36880");
  753|       |
  754|      1|    netsnmp_ds_set_int(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  755|      1|                       NETSNMP_DS_LIB_HEX_OUTPUT_LENGTH, 16);
  ------------------
  |  |  121|      1|#define NETSNMP_DS_LIB_HEX_OUTPUT_LENGTH    6
  ------------------
  756|      1|    netsnmp_ds_set_int(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_RETRIES,
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                  netsnmp_ds_set_int(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_RETRIES,
  ------------------
  |  |  131|      1|#define NETSNMP_DS_LIB_RETRIES             15
  ------------------
  757|      1|                       DEFAULT_RETRIES);
  ------------------
  |  |  185|      1|#define DEFAULT_RETRIES	    5
  ------------------
  758|      1|    netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  759|      1|			   NETSNMP_DS_LIB_MIB_ERRORS, 1);
  ------------------
  |  |   59|      1|#define NETSNMP_DS_LIB_MIB_ERRORS          0
  ------------------
  760|       |
  761|      1|#ifdef NETSNMP_USE_REVERSE_ASNENCODING
  762|      1|    netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  763|      1|			   NETSNMP_DS_LIB_REVERSE_ENCODE,
  ------------------
  |  |   80|      1|#define NETSNMP_DS_LIB_REVERSE_ENCODE      20   /* encode packets from back to front */
  ------------------
  764|      1|			   NETSNMP_DEFAULT_ASNENCODING_DIRECTION);
  ------------------
  |  | 1974|      1|#define NETSNMP_DEFAULT_ASNENCODING_DIRECTION 1 /* 1 = reverse, 0 = forwards */
  ------------------
  765|      1|#endif
  766|      1|}
snmp_api.c:register_default_handlers:
  795|      1|{
  796|      1|    netsnmp_ds_register_config(ASN_BOOLEAN, "snmp", "dumpPacket",
  ------------------
  |  |   72|      1|#define ASN_BOOLEAN	    0x01U
  ------------------
  797|      1|		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DUMP_PACKET);
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DUMP_PACKET);
  ------------------
  |  |   63|      1|#define NETSNMP_DS_LIB_DUMP_PACKET         4
  ------------------
  798|      1|    netsnmp_ds_register_config(ASN_BOOLEAN, "snmp", "reverseEncodeBER",
  ------------------
  |  |   72|      1|#define ASN_BOOLEAN	    0x01U
  ------------------
  799|      1|		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_REVERSE_ENCODE);
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_REVERSE_ENCODE);
  ------------------
  |  |   80|      1|#define NETSNMP_DS_LIB_REVERSE_ENCODE      20   /* encode packets from back to front */
  ------------------
  800|      1|    netsnmp_ds_register_config(ASN_INTEGER, "snmp", "defaultPort",
  ------------------
  |  |   75|      1|#define ASN_INTEGER	    0x02U
  ------------------
  801|      1|		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DEFAULT_PORT);
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DEFAULT_PORT);
  ------------------
  |  |  117|      1|#define NETSNMP_DS_LIB_DEFAULT_PORT         3
  ------------------
  802|      1|#ifndef NETSNMP_FEATURE_REMOVE_RUNTIME_DISABLE_VERSION
  803|      1|    netsnmp_ds_register_config(ASN_BOOLEAN, "snmp", "disableSNMPv3",
  ------------------
  |  |   72|      1|#define ASN_BOOLEAN	    0x01U
  ------------------
  804|      1|                      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DISABLE_V3);
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                    NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DISABLE_V3);
  ------------------
  |  |  105|      1|#define NETSNMP_DS_LIB_DISABLE_V3          45 /* disable SNMPv3 */
  ------------------
  805|      1|#endif /* NETSNMP_FEATURE_REMOVE_RUNTIME_DISABLE_VERSION */
  806|      1|#if !defined(NETSNMP_DISABLE_SNMPV1) || !defined(NETSNMP_DISABLE_SNMPV2C)
  807|      1|#ifndef NETSNMP_FEATURE_REMOVE_RUNTIME_DISABLE_VERSION
  808|      1|#if !defined(NETSNMP_DISABLE_SNMPV1)
  809|      1|    netsnmp_ds_register_config(ASN_BOOLEAN, "snmp", "disableSNMPv1",
  ------------------
  |  |   72|      1|#define ASN_BOOLEAN	    0x01U
  ------------------
  810|      1|                      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DISABLE_V1);
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                    NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DISABLE_V1);
  ------------------
  |  |  103|      1|#define NETSNMP_DS_LIB_DISABLE_V1          43 /* disable SNMPv1 */
  ------------------
  811|      1|#endif
  812|      1|#if !defined(NETSNMP_DISABLE_SNMPV2C)
  813|      1|    netsnmp_ds_register_config(ASN_BOOLEAN, "snmp", "disableSNMPv2c",
  ------------------
  |  |   72|      1|#define ASN_BOOLEAN	    0x01U
  ------------------
  814|      1|                      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DISABLE_V2c);
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                    NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DISABLE_V2c);
  ------------------
  |  |  104|      1|#define NETSNMP_DS_LIB_DISABLE_V2c         44 /* disable SNMPv2c */
  ------------------
  815|      1|#endif
  816|      1|#endif /* NETSNMP_FEATURE_REMOVE_RUNTIME_DISABLE_VERSION */
  817|      1|    netsnmp_ds_register_config(ASN_OCTET_STR, "snmp", "defCommunity",
  ------------------
  |  |   78|      1|#define ASN_OCTET_STR	    0x04U
  ------------------
  818|      1|                      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_COMMUNITY);
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                    NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_COMMUNITY);
  ------------------
  |  |  158|      1|#define NETSNMP_DS_LIB_COMMUNITY         7
  ------------------
  819|      1|#endif /* !defined(NETSNMP_DISABLE_SNMPV1) || !defined(NETSNMP_DISABLE_SNMPV2C) */
  820|      1|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "noTokenWarnings",
  ------------------
  |  |   72|      1|#define ASN_BOOLEAN	    0x01U
  ------------------
  821|      1|                      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_NO_TOKEN_WARNINGS);
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                    NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_NO_TOKEN_WARNINGS);
  ------------------
  |  |   77|      1|#define NETSNMP_DS_LIB_NO_TOKEN_WARNINGS   17   /* no warn about unknown config tokens */
  ------------------
  822|      1|    netsnmp_ds_register_config(ASN_BOOLEAN, "snmp", "noRangeCheck",
  ------------------
  |  |   72|      1|#define ASN_BOOLEAN	    0x01U
  ------------------
  823|      1|		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DONT_CHECK_RANGE);
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DONT_CHECK_RANGE);
  ------------------
  |  |   76|      1|#define NETSNMP_DS_LIB_DONT_CHECK_RANGE    16   /* don't check values for ranges on send */
  ------------------
  824|      1|    netsnmp_ds_register_premib(ASN_OCTET_STR, "snmp", "persistentDir",
  ------------------
  |  |   78|      1|#define ASN_OCTET_STR	    0x04U
  ------------------
  825|      1|	              NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_PERSISTENT_DIR);
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              	              NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_PERSISTENT_DIR);
  ------------------
  |  |  159|      1|#define NETSNMP_DS_LIB_PERSISTENT_DIR    8
  ------------------
  826|      1|    netsnmp_ds_register_config(ASN_OCTET_STR, "snmp", "tempFilePattern",
  ------------------
  |  |   78|      1|#define ASN_OCTET_STR	    0x04U
  ------------------
  827|      1|	              NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_TEMP_FILE_PATTERN);
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              	              NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_TEMP_FILE_PATTERN);
  ------------------
  |  |  166|      1|#define NETSNMP_DS_LIB_TEMP_FILE_PATTERN 15
  ------------------
  828|      1|    netsnmp_ds_register_config(ASN_BOOLEAN, "snmp", "noDisplayHint",
  ------------------
  |  |   72|      1|#define ASN_BOOLEAN	    0x01U
  ------------------
  829|      1|	              NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_NO_DISPLAY_HINT);
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              	              NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_NO_DISPLAY_HINT);
  ------------------
  |  |   90|      1|#define NETSNMP_DS_LIB_NO_DISPLAY_HINT     30 /* don't apply DISPLAY-HINTs */
  ------------------
  830|      1|    netsnmp_ds_register_config(ASN_BOOLEAN, "snmp", "16bitIDs",
  ------------------
  |  |   72|      1|#define ASN_BOOLEAN	    0x01U
  ------------------
  831|      1|	              NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_16BIT_IDS);
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              	              NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_16BIT_IDS);
  ------------------
  |  |   91|      1|#define NETSNMP_DS_LIB_16BIT_IDS           31   /* restrict requestIDs, etc to 16-bit values */
  ------------------
  832|      1|    netsnmp_ds_register_premib(ASN_OCTET_STR, "snmp", "clientaddr",
  ------------------
  |  |   78|      1|#define ASN_OCTET_STR	    0x04U
  ------------------
  833|      1|                      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_CLIENT_ADDR);
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                    NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_CLIENT_ADDR);
  ------------------
  |  |  165|      1|#define NETSNMP_DS_LIB_CLIENT_ADDR       14
  ------------------
  834|      1|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "clientaddrUsesPort",
  ------------------
  |  |   72|      1|#define ASN_BOOLEAN	    0x01U
  ------------------
  835|      1|                      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_CLIENT_ADDR_USES_PORT);
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                    NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_CLIENT_ADDR_USES_PORT);
  ------------------
  |  |  102|      1|#define NETSNMP_DS_LIB_CLIENT_ADDR_USES_PORT 42 /* NETSNMP_DS_LIB_CLIENT_ADDR includes address and also port */
  ------------------
  836|      1|    netsnmp_ds_register_config(ASN_INTEGER, "snmp", "serverSendBuf",
  ------------------
  |  |   75|      1|#define ASN_INTEGER	    0x02U
  ------------------
  837|      1|		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_SERVERSENDBUF);
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_SERVERSENDBUF);
  ------------------
  |  |  122|      1|#define NETSNMP_DS_LIB_SERVERSENDBUF        7 /* send buffer (server) */
  ------------------
  838|      1|    netsnmp_ds_register_config(ASN_INTEGER, "snmp", "serverRecvBuf",
  ------------------
  |  |   75|      1|#define ASN_INTEGER	    0x02U
  ------------------
  839|      1|		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_SERVERRECVBUF);
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_SERVERRECVBUF);
  ------------------
  |  |  123|      1|#define NETSNMP_DS_LIB_SERVERRECVBUF        8 /* receive buffer (server) */
  ------------------
  840|      1|    netsnmp_ds_register_config(ASN_INTEGER, "snmp", "clientSendBuf",
  ------------------
  |  |   75|      1|#define ASN_INTEGER	    0x02U
  ------------------
  841|      1|		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_CLIENTSENDBUF);
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_CLIENTSENDBUF);
  ------------------
  |  |  124|      1|#define NETSNMP_DS_LIB_CLIENTSENDBUF        9 /* send buffer (client) */
  ------------------
  842|      1|    netsnmp_ds_register_config(ASN_INTEGER, "snmp", "clientRecvBuf",
  ------------------
  |  |   75|      1|#define ASN_INTEGER	    0x02U
  ------------------
  843|      1|		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_CLIENTRECVBUF);
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_CLIENTRECVBUF);
  ------------------
  |  |  125|      1|#define NETSNMP_DS_LIB_CLIENTRECVBUF       10 /* receive buffer (client) */
  ------------------
  844|      1|    netsnmp_ds_register_config(ASN_INTEGER, "snmp", "sendMessageMaxSize",
  ------------------
  |  |   75|      1|#define ASN_INTEGER	    0x02U
  ------------------
  845|      1|                               NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  846|      1|                               NETSNMP_DS_LIB_MSG_SEND_MAX);
  ------------------
  |  |  132|      1|#define NETSNMP_DS_LIB_MSG_SEND_MAX        16 /* global max response size */
  ------------------
  847|      1|    netsnmp_ds_register_config(ASN_BOOLEAN, "snmp", "noPersistentLoad",
  ------------------
  |  |   72|      1|#define ASN_BOOLEAN	    0x01U
  ------------------
  848|      1|		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DISABLE_PERSISTENT_LOAD);
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DISABLE_PERSISTENT_LOAD);
  ------------------
  |  |   95|      1|#define NETSNMP_DS_LIB_DISABLE_PERSISTENT_LOAD  35 /* don't load persistent file */
  ------------------
  849|      1|    netsnmp_ds_register_config(ASN_BOOLEAN, "snmp", "noPersistentSave",
  ------------------
  |  |   72|      1|#define ASN_BOOLEAN	    0x01U
  ------------------
  850|      1|		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DISABLE_PERSISTENT_SAVE);
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DISABLE_PERSISTENT_SAVE);
  ------------------
  |  |   96|      1|#define NETSNMP_DS_LIB_DISABLE_PERSISTENT_SAVE  36 /* don't save persistent file */
  ------------------
  851|      1|    netsnmp_ds_register_config(ASN_BOOLEAN, "snmp",
  ------------------
  |  |   72|      1|#define ASN_BOOLEAN	    0x01U
  ------------------
  852|      1|                               "noContextEngineIDDiscovery",
  853|      1|                               NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  854|      1|                               NETSNMP_DS_LIB_NO_DISCOVERY);
  ------------------
  |  |   98|      1|#define NETSNMP_DS_LIB_NO_DISCOVERY        38 /* don't support RFC5343 contextEngineID discovery */
  ------------------
  855|      1|    netsnmp_ds_register_config(ASN_INTEGER, "snmp", "timeout",
  ------------------
  |  |   75|      1|#define ASN_INTEGER	    0x02U
  ------------------
  856|      1|		               NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_TIMEOUT);
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              		               NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_TIMEOUT);
  ------------------
  |  |  130|      1|#define NETSNMP_DS_LIB_TIMEOUT             14
  ------------------
  857|      1|    netsnmp_ds_register_config(ASN_INTEGER, "snmp", "retries",
  ------------------
  |  |   75|      1|#define ASN_INTEGER	    0x02U
  ------------------
  858|      1|		               NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_RETRIES);
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              		               NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_RETRIES);
  ------------------
  |  |  131|      1|#define NETSNMP_DS_LIB_RETRIES             15
  ------------------
  859|      1|    netsnmp_ds_register_config(ASN_OCTET_STR, "snmp", "outputPrecision",
  ------------------
  |  |   78|      1|#define ASN_OCTET_STR	    0x04U
  ------------------
  860|      1|                               NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_OUTPUT_PRECISION);
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                             NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_OUTPUT_PRECISION);
  ------------------
  |  |  186|      1|#define NETSNMP_DS_LIB_OUTPUT_PRECISION  35
  ------------------
  861|       |
  862|       |
  863|      1|    netsnmp_register_service_handlers();
  864|      1|}
snmp_api.c:snmp_sess_copy:
 1336|  1.74k|{
 1337|  1.74k|    struct session_list *psl;
 1338|  1.74k|    psl = _sess_copy(pss);
 1339|  1.74k|    if (!psl) {
  ------------------
  |  Branch (1339:9): [True: 0, False: 1.74k]
  ------------------
 1340|      0|        if (!pss->s_snmp_errno) {
  ------------------
  |  Branch (1340:13): [True: 0, False: 0]
  ------------------
 1341|      0|            pss->s_snmp_errno = SNMPERR_GENERR;
  ------------------
  |  |  218|      0|#define SNMPERR_GENERR			(-1)
  ------------------
 1342|      0|        }
 1343|      0|        SET_SNMP_ERROR(pss->s_snmp_errno);
  ------------------
  |  |   56|      0|#define SET_SNMP_ERROR(x) snmp_errno=(x)
  ------------------
 1344|      0|    }
 1345|  1.74k|    return psl;
 1346|  1.74k|}
snmp_api.c:_sess_copy:
 1090|  1.74k|{
 1091|  1.74k|    struct session_list *slp;
 1092|  1.74k|    struct snmp_internal_session *isp;
 1093|  1.74k|    netsnmp_session *session;
 1094|  1.74k|    struct snmp_secmod_def *sptr;
 1095|  1.74k|    char           *cp;
 1096|  1.74k|    u_char         *ucp;
 1097|       |
 1098|  1.74k|    in_session->s_snmp_errno = 0;
 1099|  1.74k|    in_session->s_errno = 0;
 1100|       |
 1101|       |    /*
 1102|       |     * Copy session structure and link into list 
 1103|       |     */
 1104|  1.74k|    slp = calloc(1, sizeof(struct session_list));
 1105|  1.74k|    if (slp == NULL) {
  ------------------
  |  Branch (1105:9): [True: 0, False: 1.74k]
  ------------------
 1106|      0|        in_session->s_snmp_errno = SNMPERR_MALLOC;
  ------------------
  |  |  279|      0|#define SNMPERR_MALLOC			(-62)
  ------------------
 1107|      0|        return (NULL);
 1108|      0|    }
 1109|       |
 1110|  1.74k|    slp->transport = NULL;
 1111|       |
 1112|  1.74k|    isp = calloc(1, sizeof(struct snmp_internal_session));
 1113|       |
 1114|  1.74k|    if (isp == NULL) {
  ------------------
  |  Branch (1114:9): [True: 0, False: 1.74k]
  ------------------
 1115|      0|        snmp_sess_close(slp);
 1116|      0|        in_session->s_snmp_errno = SNMPERR_MALLOC;
  ------------------
  |  |  279|      0|#define SNMPERR_MALLOC			(-62)
  ------------------
 1117|      0|        return (NULL);
 1118|      0|    }
 1119|       |
 1120|  1.74k|    slp->internal = isp;
 1121|  1.74k|    slp->session = netsnmp_memdup(in_session, sizeof(netsnmp_session));
 1122|  1.74k|    if (slp->session == NULL) {
  ------------------
  |  Branch (1122:9): [True: 0, False: 1.74k]
  ------------------
 1123|      0|        snmp_sess_close(slp);
 1124|      0|        in_session->s_snmp_errno = SNMPERR_MALLOC;
  ------------------
  |  |  279|      0|#define SNMPERR_MALLOC			(-62)
  ------------------
 1125|      0|        return (NULL);
 1126|      0|    }
 1127|  1.74k|    session = slp->session;
 1128|       |
 1129|       |    /*
 1130|       |     * zero out pointers so if we have to free the session we wont free mem
 1131|       |     * owned by in_session 
 1132|       |     */
 1133|  1.74k|    session->localname = NULL;
 1134|  1.74k|    session->peername = NULL;
 1135|  1.74k|    session->community = NULL;
 1136|  1.74k|    session->contextEngineID = NULL;
 1137|  1.74k|    session->contextName = NULL;
 1138|  1.74k|    session->securityEngineID = NULL;
 1139|  1.74k|    session->securityName = NULL;
 1140|  1.74k|    session->securityAuthProto = NULL;
 1141|  1.74k|    session->securityPrivProto = NULL;
 1142|  1.74k|    session->sessUser = NULL;
 1143|       |    /*
 1144|       |     * session now points to the new structure that still contains pointers to
 1145|       |     * data allocated elsewhere.  Some of this data is copied to space malloc'd
 1146|       |     * here, and the pointer replaced with the new one.
 1147|       |     */
 1148|       |
 1149|  1.74k|    if (in_session->peername != NULL) {
  ------------------
  |  Branch (1149:9): [True: 1.74k, False: 0]
  ------------------
 1150|  1.74k|        session->peername =
 1151|  1.74k|            netsnmp_strdup_and_null((u_char*)in_session->peername,
 1152|  1.74k|                                    strlen(in_session->peername));
 1153|  1.74k|        if (session->peername == NULL) {
  ------------------
  |  Branch (1153:13): [True: 0, False: 1.74k]
  ------------------
 1154|      0|            snmp_sess_close(slp);
 1155|      0|            in_session->s_snmp_errno = SNMPERR_MALLOC;
  ------------------
  |  |  279|      0|#define SNMPERR_MALLOC			(-62)
  ------------------
 1156|      0|            return (NULL);
 1157|      0|        }
 1158|  1.74k|    }
 1159|       |
 1160|       |    /*
 1161|       |     * Fill in defaults if necessary 
 1162|       |     */
 1163|  1.74k|#if !defined(NETSNMP_DISABLE_SNMPV1) || !defined(NETSNMP_DISABLE_SNMPV2C)
 1164|  1.74k|    if (in_session->community_len != SNMP_DEFAULT_COMMUNITY_LEN) {
  ------------------
  |  |  111|  1.74k|#define SNMP_DEFAULT_COMMUNITY_LEN  0   /* to get a default community name */
  ------------------
  |  Branch (1164:9): [True: 0, False: 1.74k]
  ------------------
 1165|      0|        ucp = netsnmp_memdup(in_session->community, in_session->community_len);
 1166|  1.74k|    } else {
 1167|  1.74k|        if ((cp = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|  1.74k|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (1167:13): [True: 0, False: 1.74k]
  ------------------
 1168|  1.74k|					NETSNMP_DS_LIB_COMMUNITY)) != NULL) {
  ------------------
  |  |  158|  1.74k|#define NETSNMP_DS_LIB_COMMUNITY         7
  ------------------
 1169|      0|            session->community_len = strlen(cp);
 1170|      0|            ucp = (u_char *) strdup(cp);
 1171|  1.74k|        } else {
 1172|       |#ifdef NETSNMP_NO_ZEROLENGTH_COMMUNITY
 1173|       |            session->community_len = strlen(DEFAULT_COMMUNITY);
 1174|       |            ucp = netsnmp_memdup(DEFAULT_COMMUNITY, session->community_len);
 1175|       |#else
 1176|  1.74k|            ucp = (u_char *) strdup("");
 1177|  1.74k|#endif
 1178|  1.74k|        }
 1179|  1.74k|    }
 1180|       |
 1181|  1.74k|    if (ucp == NULL) {
  ------------------
  |  Branch (1181:9): [True: 0, False: 1.74k]
  ------------------
 1182|      0|        snmp_sess_close(slp);
 1183|      0|        in_session->s_snmp_errno = SNMPERR_MALLOC;
  ------------------
  |  |  279|      0|#define SNMPERR_MALLOC			(-62)
  ------------------
 1184|      0|        return (NULL);
 1185|      0|    }
 1186|  1.74k|    session->community = ucp;   /* replace pointer with pointer to new data */
 1187|  1.74k|#endif
 1188|       |
 1189|  1.74k|    if (session->securityLevel <= 0) {
  ------------------
  |  Branch (1189:9): [True: 1.74k, False: 0]
  ------------------
 1190|  1.74k|        session->securityLevel =
 1191|  1.74k|            netsnmp_ds_get_int(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_SECLEVEL);
  ------------------
  |  |   48|  1.74k|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                          netsnmp_ds_get_int(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_SECLEVEL);
  ------------------
  |  |  115|  1.74k|#define NETSNMP_DS_LIB_SECLEVEL             1
  ------------------
 1192|  1.74k|    }
 1193|       |
 1194|  1.74k|    if (in_session->securityEngineIDLen > 0) {
  ------------------
  |  Branch (1194:9): [True: 0, False: 1.74k]
  ------------------
 1195|      0|        ucp = netsnmp_memdup(in_session->securityEngineID,
 1196|      0|                             in_session->securityEngineIDLen);
 1197|      0|        if (ucp == NULL) {
  ------------------
  |  Branch (1197:13): [True: 0, False: 0]
  ------------------
 1198|      0|            snmp_sess_close(slp);
 1199|      0|            in_session->s_snmp_errno = SNMPERR_MALLOC;
  ------------------
  |  |  279|      0|#define SNMPERR_MALLOC			(-62)
  ------------------
 1200|      0|            return (NULL);
 1201|      0|        }
 1202|      0|        session->securityEngineID = ucp;
 1203|       |
 1204|      0|    }
 1205|       |
 1206|  1.74k|    if (in_session->contextEngineIDLen > 0) {
  ------------------
  |  Branch (1206:9): [True: 0, False: 1.74k]
  ------------------
 1207|      0|        ucp = netsnmp_memdup(in_session->contextEngineID,
 1208|      0|                             in_session->contextEngineIDLen);
 1209|      0|        if (ucp == NULL) {
  ------------------
  |  Branch (1209:13): [True: 0, False: 0]
  ------------------
 1210|      0|            snmp_sess_close(slp);
 1211|      0|            in_session->s_snmp_errno = SNMPERR_MALLOC;
  ------------------
  |  |  279|      0|#define SNMPERR_MALLOC			(-62)
  ------------------
 1212|      0|            return (NULL);
 1213|      0|        }
 1214|      0|        session->contextEngineID = ucp;
 1215|  1.74k|    } else if (in_session->securityEngineIDLen > 0) {
  ------------------
  |  Branch (1215:16): [True: 0, False: 1.74k]
  ------------------
 1216|       |        /*
 1217|       |         * default contextEngineID to securityEngineIDLen if defined 
 1218|       |         */
 1219|      0|        ucp = netsnmp_memdup(in_session->securityEngineID,
 1220|      0|                             in_session->securityEngineIDLen);
 1221|      0|        if (ucp == NULL) {
  ------------------
  |  Branch (1221:13): [True: 0, False: 0]
  ------------------
 1222|      0|            snmp_sess_close(slp);
 1223|      0|            in_session->s_snmp_errno = SNMPERR_MALLOC;
  ------------------
  |  |  279|      0|#define SNMPERR_MALLOC			(-62)
  ------------------
 1224|      0|            return (NULL);
 1225|      0|        }
 1226|      0|        session->contextEngineID = ucp;
 1227|      0|        session->contextEngineIDLen = in_session->securityEngineIDLen;
 1228|      0|    }
 1229|       |
 1230|  1.74k|    if (in_session->contextName) {
  ------------------
  |  Branch (1230:9): [True: 0, False: 1.74k]
  ------------------
 1231|      0|        session->contextName = strdup(in_session->contextName);
 1232|      0|        if (session->contextName == NULL) {
  ------------------
  |  Branch (1232:13): [True: 0, False: 0]
  ------------------
 1233|      0|            snmp_sess_close(slp);
 1234|      0|            return (NULL);
 1235|      0|        }
 1236|      0|        session->contextNameLen = in_session->contextNameLen;
 1237|  1.74k|    } else {
 1238|  1.74k|        if ((cp = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|  1.74k|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (1238:13): [True: 0, False: 1.74k]
  ------------------
 1239|  1.74k|                                        NETSNMP_DS_LIB_CONTEXT)) != NULL)
  ------------------
  |  |  152|  1.74k|#define NETSNMP_DS_LIB_CONTEXT           1
  ------------------
 1240|      0|            cp = strdup(cp);
 1241|  1.74k|        else
 1242|  1.74k|            cp = strdup(SNMP_DEFAULT_CONTEXT);
  ------------------
  |  |  125|  1.74k|#define SNMP_DEFAULT_CONTEXT        ""
  ------------------
 1243|  1.74k|        if (cp == NULL) {
  ------------------
  |  Branch (1243:13): [True: 0, False: 1.74k]
  ------------------
 1244|      0|            snmp_sess_close(slp);
 1245|      0|            return (NULL);
 1246|      0|        }
 1247|  1.74k|        session->contextName = cp;
 1248|  1.74k|        session->contextNameLen = strlen(cp);
 1249|  1.74k|    }
 1250|       |
 1251|  1.74k|    if (in_session->securityName) {
  ------------------
  |  Branch (1251:9): [True: 0, False: 1.74k]
  ------------------
 1252|      0|        session->securityName = strdup(in_session->securityName);
 1253|      0|        if (session->securityName == NULL) {
  ------------------
  |  Branch (1253:13): [True: 0, False: 0]
  ------------------
 1254|      0|            snmp_sess_close(slp);
 1255|      0|            return (NULL);
 1256|      0|        }
 1257|  1.74k|    } else if ((cp = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|  1.74k|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (1257:16): [True: 0, False: 1.74k]
  ------------------
 1258|  1.74k|					   NETSNMP_DS_LIB_SECNAME)) != NULL) {
  ------------------
  |  |  151|  1.74k|#define NETSNMP_DS_LIB_SECNAME           0
  ------------------
 1259|      0|        cp = strdup(cp);
 1260|      0|        if (cp == NULL) {
  ------------------
  |  Branch (1260:13): [True: 0, False: 0]
  ------------------
 1261|      0|            snmp_sess_close(slp);
 1262|      0|            return (NULL);
 1263|      0|        }
 1264|      0|        session->securityName = cp;
 1265|      0|        session->securityNameLen = strlen(cp);
 1266|      0|    }
 1267|       |
 1268|  1.74k|    if (session->retries == SNMP_DEFAULT_RETRIES) {
  ------------------
  |  |  112|  1.74k|#define SNMP_DEFAULT_RETRIES	    -1
  ------------------
  |  Branch (1268:9): [True: 1.74k, False: 0]
  ------------------
 1269|  1.74k|        int retry = netsnmp_ds_get_int(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|  1.74k|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1270|  1.74k|                                       NETSNMP_DS_LIB_RETRIES);
  ------------------
  |  |  131|  1.74k|#define NETSNMP_DS_LIB_RETRIES             15
  ------------------
 1271|  1.74k|        if (retry < 0)
  ------------------
  |  Branch (1271:13): [True: 0, False: 1.74k]
  ------------------
 1272|      0|            session->retries = DEFAULT_RETRIES;
  ------------------
  |  |  185|      0|#define DEFAULT_RETRIES	    5
  ------------------
 1273|  1.74k|        else
 1274|  1.74k|            session->retries = retry;
 1275|  1.74k|    }
 1276|  1.74k|    if (session->timeout == SNMP_DEFAULT_TIMEOUT) {
  ------------------
  |  |  113|  1.74k|#define SNMP_DEFAULT_TIMEOUT	    -1
  ------------------
  |  Branch (1276:9): [True: 1.74k, False: 0]
  ------------------
 1277|  1.74k|        int timeout = netsnmp_ds_get_int(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|  1.74k|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1278|  1.74k|                                         NETSNMP_DS_LIB_TIMEOUT);
  ------------------
  |  |  130|  1.74k|#define NETSNMP_DS_LIB_TIMEOUT             14
  ------------------
 1279|  1.74k|        if (timeout <= 0)
  ------------------
  |  Branch (1279:13): [True: 1.74k, False: 0]
  ------------------
 1280|  1.74k|            session->timeout = DEFAULT_TIMEOUT;
  ------------------
  |  |  186|  1.74k|#define DEFAULT_TIMEOUT	    (1000L * 1000L)
  ------------------
 1281|      0|        else
 1282|      0|            session->timeout = timeout * 1000L * 1000L;
 1283|  1.74k|    }
 1284|  1.74k|    session->sessid = snmp_get_next_sessid();
 1285|       |
 1286|  1.74k|    snmp_call_callbacks(SNMP_CALLBACK_LIBRARY, SNMP_CALLBACK_SESSION_INIT,
  ------------------
  |  |   18|  1.74k|#define SNMP_CALLBACK_LIBRARY     0
  ------------------
                  snmp_call_callbacks(SNMP_CALLBACK_LIBRARY, SNMP_CALLBACK_SESSION_INIT,
  ------------------
  |  |   29|  1.74k|#define SNMP_CALLBACK_SESSION_INIT		5
  ------------------
 1287|  1.74k|                        session);
 1288|       |
 1289|  1.74k|    if ((sptr = find_sec_mod(session->securityModel)) != NULL) {
  ------------------
  |  Branch (1289:9): [True: 1.74k, False: 0]
  ------------------
 1290|       |        /*
 1291|       |         * security module specific copying 
 1292|       |         */
 1293|  1.74k|        if (sptr->session_setup) {
  ------------------
  |  Branch (1293:13): [True: 1.74k, False: 0]
  ------------------
 1294|  1.74k|            int ret = (*sptr->session_setup) (in_session, session);
 1295|  1.74k|            if (ret != SNMPERR_SUCCESS) {
  ------------------
  |  |  217|  1.74k|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  |  Branch (1295:17): [True: 0, False: 1.74k]
  ------------------
 1296|      0|                snmp_sess_close(slp);
 1297|      0|                return NULL;
 1298|      0|            }
 1299|  1.74k|        }
 1300|       |
 1301|       |        /*
 1302|       |         * security module specific opening
 1303|       |         */
 1304|  1.74k|        if (sptr->session_open) {
  ------------------
  |  Branch (1304:13): [True: 0, False: 1.74k]
  ------------------
 1305|      0|            int ret = (*sptr->session_open) (session);
 1306|      0|            if (ret != SNMPERR_SUCCESS) {
  ------------------
  |  |  217|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  |  Branch (1306:17): [True: 0, False: 0]
  ------------------
 1307|      0|                snmp_sess_close(slp);
 1308|      0|                return NULL;
 1309|      0|            }
 1310|      0|        }
 1311|  1.74k|    }
 1312|       |
 1313|  1.74k|#ifndef NETSNMP_NO_WRITE_SUPPORT
 1314|  1.74k|    if (in_session->sessUser) {
  ------------------
  |  Branch (1314:9): [True: 0, False: 1.74k]
  ------------------
 1315|      0|        struct usmUser *user;
 1316|       |
 1317|      0|        user = calloc(1, sizeof(struct usmUser));
 1318|      0|        if (user == NULL) {
  ------------------
  |  Branch (1318:13): [True: 0, False: 0]
  ------------------
 1319|      0|            snmp_sess_close(slp);
 1320|      0|            return NULL;
 1321|      0|        }
 1322|      0|        session->sessUser = usm_cloneFrom_user(in_session->sessUser, user);
 1323|      0|    }
 1324|  1.74k|#endif /* NETSNMP_NO_WRITE_SUPPORT */
 1325|       |
 1326|       |    /* Anything below this point should only be done if the transport
 1327|       |       had no say in the matter */
 1328|  1.74k|    if (session->securityLevel == 0)
  ------------------
  |  Branch (1328:9): [True: 1.74k, False: 0]
  ------------------
 1329|  1.74k|        session->securityLevel = SNMP_SEC_LEVEL_NOAUTH;
  ------------------
  |  |  299|  1.74k|#define SNMP_SEC_LEVEL_NOAUTH		1
  ------------------
 1330|       |
 1331|  1.74k|    return (slp);
 1332|  1.74k|}
snmp_api.c:free_securityStateRef:
 4090|  1.74k|{
 4091|  1.74k|    struct snmp_secmod_def *sptr;
 4092|       |
 4093|  1.74k|    if (!pdu->securityStateRef)
  ------------------
  |  Branch (4093:9): [True: 1.74k, False: 0]
  ------------------
 4094|  1.74k|        return;
 4095|       |
 4096|      0|    sptr = find_sec_mod(pdu->securityModel);
 4097|      0|    if (sptr) {
  ------------------
  |  Branch (4097:9): [True: 0, False: 0]
  ------------------
 4098|      0|        if (sptr->pdu_free_state_ref) {
  ------------------
  |  Branch (4098:13): [True: 0, False: 0]
  ------------------
 4099|      0|            (*sptr->pdu_free_state_ref) (pdu->securityStateRef);
 4100|      0|        } else {
 4101|      0|            snmp_log(LOG_ERR,
 4102|      0|                     "Security Model %d can't free state references\n",
 4103|      0|                     pdu->securityModel);
 4104|      0|	}
 4105|      0|    } else {
 4106|      0|	snmp_log(LOG_ERR,
 4107|      0|		 "Can't find security model to free ptr: %d\n",
 4108|      0|		 pdu->securityModel);
 4109|      0|    }
 4110|      0|    pdu->securityStateRef = NULL;
 4111|      0|}
snmp_api.c:_snmp_parse:
 4316|  1.74k|{
 4317|  1.74k|#if !defined(NETSNMP_DISABLE_SNMPV1) || !defined(NETSNMP_DISABLE_SNMPV2C)
 4318|  1.74k|    u_char          community[COMMUNITY_MAX_LEN];
 4319|  1.74k|    size_t          community_length = COMMUNITY_MAX_LEN;
  ------------------
  |  |   41|  1.74k|#define COMMUNITY_MAX_LEN	256
  ------------------
 4320|  1.74k|#endif
 4321|  1.74k|    int             result = -1;
 4322|       |
 4323|  1.74k|    static const oid snmpEngineIDoid[]   = { 1,3,6,1,6,3,10,2,1,1,0};
 4324|  1.74k|    static size_t   snmpEngineIDoid_len = 11;
 4325|       |
 4326|  1.74k|    static char     ourEngineID[SNMP_SEC_PARAM_BUF_SIZE];
 4327|  1.74k|    static size_t   ourEngineID_len = sizeof(ourEngineID);
 4328|       |
 4329|  1.74k|    netsnmp_pdu    *pdu2 = NULL;
 4330|       |
 4331|  1.74k|    session->s_snmp_errno = 0;
 4332|  1.74k|    session->s_errno = 0;
 4333|       |
 4334|       |    /*
 4335|       |     * Ensure all incoming PDUs have a unique means of identification 
 4336|       |     * (This is not restricted to AgentX handling,
 4337|       |     * though that is where the need becomes visible)   
 4338|       |     */
 4339|  1.74k|    pdu->transid = snmp_get_next_transid();
 4340|       |
 4341|  1.74k|    if (session->version != SNMP_DEFAULT_VERSION) {
  ------------------
  |  |  123|  1.74k|#define SNMP_DEFAULT_VERSION	    -1
  ------------------
  |  Branch (4341:9): [True: 1.74k, False: 0]
  ------------------
 4342|  1.74k|        pdu->version = session->version;
 4343|  1.74k|    } else {
 4344|      0|        pdu->version = snmp_parse_version(data, length);
 4345|      0|    }
 4346|       |
 4347|  1.74k|    switch (pdu->version) {
 4348|      0|#if !defined(NETSNMP_DISABLE_SNMPV1) || !defined(NETSNMP_DISABLE_SNMPV2C)
 4349|      0|#ifndef NETSNMP_DISABLE_SNMPV1
 4350|      0|    case SNMP_VERSION_1:
  ------------------
  |  |  107|      0|#define SNMP_VERSION_1	   0
  ------------------
  |  Branch (4350:5): [True: 0, False: 1.74k]
  ------------------
 4351|      0|#endif
 4352|      0|#ifndef NETSNMP_DISABLE_SNMPV2C
 4353|  1.74k|    case SNMP_VERSION_2c:
  ------------------
  |  |  110|  1.74k|#define SNMP_VERSION_2c    1
  ------------------
  |  Branch (4353:5): [True: 1.74k, False: 0]
  ------------------
 4354|  1.74k|#endif
 4355|  1.74k|        NETSNMP_RUNTIME_PROTOCOL_CHECK_V1V2(pdu->version,unsupported_version);
  ------------------
  |  |  220|  1.74k|#define NETSNMP_RUNTIME_PROTOCOL_CHECK_V1V2(pc_ver, pc_target) do {    \
  |  |  221|  1.74k|        if (NETSNMP_RUNTIME_PROTOCOL_SKIP_V1(pc_ver) ||                \
  |  |  ------------------
  |  |  |  |  205|  3.48k|    ((pc_ver) == SNMP_VERSION_1 &&                                      \
  |  |  |  |  ------------------
  |  |  |  |  |  |  107|  3.48k|#define SNMP_VERSION_1	   0
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (205:6): [True: 0, False: 1.74k]
  |  |  |  |  ------------------
  |  |  |  |  206|  3.48k|     netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,                      \
  |  |  |  |  ------------------
  |  |  |  |  |  |   48|      0|#define NETSNMP_DS_LIBRARY_ID     0
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (206:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  207|      0|                            NETSNMP_DS_LIB_DISABLE_V1))
  |  |  |  |  ------------------
  |  |  |  |  |  |  103|      0|#define NETSNMP_DS_LIB_DISABLE_V1          43 /* disable SNMPv1 */
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  222|  1.74k|            NETSNMP_RUNTIME_PROTOCOL_SKIP_V2(pc_ver)) {                \
  |  |  ------------------
  |  |  |  |  215|  1.74k|    ((pc_ver) == SNMP_VERSION_2c &&                                     \
  |  |  |  |  ------------------
  |  |  |  |  |  |  110|  3.48k|#define SNMP_VERSION_2c    1
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (215:6): [True: 1.74k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  216|  1.74k|     netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,                      \
  |  |  |  |  ------------------
  |  |  |  |  |  |   48|  1.74k|#define NETSNMP_DS_LIBRARY_ID     0
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (216:6): [True: 0, False: 1.74k]
  |  |  |  |  ------------------
  |  |  |  |  217|  1.74k|                            NETSNMP_DS_LIB_DISABLE_V2c))
  |  |  |  |  ------------------
  |  |  |  |  |  |  104|  1.74k|#define NETSNMP_DS_LIB_DISABLE_V2c         44 /* disable SNMPv2c */
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  223|      0|            DEBUGMSGTL(("snmp:protocol:disabled", "enforced\n"));      \
  |  |  ------------------
  |  |  |  |   68|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  |  166|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  156|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  157|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  224|      0|            goto pc_target;                                            \
  |  |  225|      0|        }                                                              \
  |  |  226|  1.74k|    } while(0)
  |  |  ------------------
  |  |  |  Branch (226:13): [Folded - Ignored]
  |  |  ------------------
  ------------------
 4356|  1.74k|        DEBUGMSGTL(("snmp_api", "Parsing SNMPv%ld message...\n",
  ------------------
  |  |   68|  1.74k|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|  1.74k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 1.74k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|  1.74k|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|  1.74k|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|  1.74k|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|  1.74k|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
 4357|  1.74k|                    (1 + pdu->version)));
 4358|       |
 4359|       |        /*
 4360|       |         * authenticates message and returns length if valid 
 4361|       |         */
 4362|  1.74k|#ifndef NETSNMP_DISABLE_SNMPV1
 4363|  1.74k|        if (pdu->version == SNMP_VERSION_1) {
  ------------------
  |  |  107|  1.74k|#define SNMP_VERSION_1	   0
  ------------------
  |  Branch (4363:13): [True: 0, False: 1.74k]
  ------------------
 4364|      0|            DEBUGDUMPSECTION("recv", "SNMPv1 message\n");
  ------------------
  |  |   83|      0|	do {if (_DBG_IF_) {__DBGDUMPSECTION(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPSECTION(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  193|      0|        __DBGPRINTINDENT("dumph_" token); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  177|      0|#define __DBGPRINTINDENT(token) __DBGMSGTL((token, "%*s", __DBGINDENT(), ""))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  166|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  156|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  157|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  194|      0|        debugmsg("dumph_" token,"%s\n",x);\
  |  |  |  |  195|      0|        __DBGINDENTMORE()
  |  |  |  |  ------------------
  |  |  |  |  |  |  175|      0|#define __DBGINDENTMORE()  debug_indent_add(2)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (83:56): [Folded - Ignored]
  |  |  ------------------
  ------------------
 4365|  1.74k|        } else {
 4366|  1.74k|#endif
 4367|  1.74k|            DEBUGDUMPSECTION("recv", "SNMPv2c message\n");
  ------------------
  |  |   83|  1.74k|	do {if (_DBG_IF_) {__DBGDUMPSECTION(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|  1.74k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 1.74k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPSECTION(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  193|  1.74k|        __DBGPRINTINDENT("dumph_" token); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  177|  1.74k|#define __DBGPRINTINDENT(token) __DBGMSGTL((token, "%*s", __DBGINDENT(), ""))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  166|  1.74k|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  156|  1.74k|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  149|  1.74k|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  157|  1.74k|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  194|  1.74k|        debugmsg("dumph_" token,"%s\n",x);\
  |  |  |  |  195|  1.74k|        __DBGINDENTMORE()
  |  |  |  |  ------------------
  |  |  |  |  |  |  175|  1.74k|#define __DBGINDENTMORE()  debug_indent_add(2)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (83:56): [Folded - Ignored]
  |  |  ------------------
  ------------------
 4368|  1.74k|#ifndef NETSNMP_DISABLE_SNMPV1
 4369|  1.74k|        }
 4370|  1.74k|#endif
 4371|  1.74k|        data = snmp_comstr_parse(data, &length,
 4372|  1.74k|                                 community, &community_length,
 4373|  1.74k|                                 &pdu->version);
 4374|  1.74k|        if (data == NULL)
  ------------------
  |  Branch (4374:13): [True: 791, False: 951]
  ------------------
 4375|    791|            return -1;
 4376|       |
 4377|    951|        if (pdu->version != session->version &&
  ------------------
  |  Branch (4377:13): [True: 168, False: 783]
  ------------------
 4378|    951|            session->version != SNMP_DEFAULT_VERSION) {
  ------------------
  |  |  123|    168|#define SNMP_DEFAULT_VERSION	    -1
  ------------------
  |  Branch (4378:13): [True: 168, False: 0]
  ------------------
 4379|    168|            session->s_snmp_errno = SNMPERR_BAD_VERSION;
  ------------------
  |  |  231|    168|#define SNMPERR_BAD_VERSION		(-14)
  ------------------
 4380|    168|            return -1;
 4381|    168|        }
 4382|       |
 4383|       |        /*
 4384|       |         * maybe get the community string. 
 4385|       |         */
 4386|    783|        pdu->securityLevel = SNMP_SEC_LEVEL_NOAUTH;
  ------------------
  |  |  299|    783|#define SNMP_SEC_LEVEL_NOAUTH		1
  ------------------
 4387|    783|        pdu->securityModel = 
 4388|    783|#ifndef NETSNMP_DISABLE_SNMPV1
 4389|    783|            (pdu->version == SNMP_VERSION_1) ? SNMP_SEC_MODEL_SNMPv1 : 
  ------------------
  |  |  107|    783|#define SNMP_VERSION_1	   0
  ------------------
                          (pdu->version == SNMP_VERSION_1) ? SNMP_SEC_MODEL_SNMPv1 : 
  ------------------
  |  |  293|      0|#define SNMP_SEC_MODEL_SNMPv1		1
  ------------------
  |  Branch (4389:13): [True: 0, False: 783]
  ------------------
 4390|    783|#endif
 4391|    783|                                               SNMP_SEC_MODEL_SNMPv2c;
  ------------------
  |  |  294|  1.56k|#define SNMP_SEC_MODEL_SNMPv2c		2
  ------------------
 4392|    783|        SNMP_FREE(pdu->community);
  ------------------
  |  |   62|    783|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 783]
  |  |  |  Branch (62:66): [Folded - Ignored]
  |  |  ------------------
  ------------------
 4393|    783|        pdu->community_len = 0;
 4394|    783|        pdu->community = (u_char *) 0;
 4395|    783|        if (community_length) {
  ------------------
  |  Branch (4395:13): [True: 359, False: 424]
  ------------------
 4396|    359|            pdu->community_len = community_length;
 4397|    359|            pdu->community = netsnmp_memdup(community, community_length);
 4398|    359|            if (pdu->community == NULL) {
  ------------------
  |  Branch (4398:17): [True: 0, False: 359]
  ------------------
 4399|      0|                session->s_snmp_errno = SNMPERR_MALLOC;
  ------------------
  |  |  279|      0|#define SNMPERR_MALLOC			(-62)
  ------------------
 4400|      0|                return -1;
 4401|      0|            }
 4402|    359|        }
 4403|    783|        if (session->authenticator) {
  ------------------
  |  Branch (4403:13): [True: 0, False: 783]
  ------------------
 4404|      0|            data = session->authenticator(data, &length,
 4405|      0|                                          community, community_length);
 4406|      0|            if (data == NULL) {
  ------------------
  |  Branch (4406:17): [True: 0, False: 0]
  ------------------
 4407|      0|                session->s_snmp_errno = SNMPERR_AUTHENTICATION_FAILURE;
  ------------------
  |  |  252|      0|#define SNMPERR_AUTHENTICATION_FAILURE 	(-35)
  ------------------
 4408|      0|                return -1;
 4409|      0|            }
 4410|      0|        }
 4411|       |
 4412|    783|        DEBUGDUMPSECTION("recv", "PDU");
  ------------------
  |  |   83|    783|	do {if (_DBG_IF_) {__DBGDUMPSECTION(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|    783|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 783, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPSECTION(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  193|    783|        __DBGPRINTINDENT("dumph_" token); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  177|    783|#define __DBGPRINTINDENT(token) __DBGMSGTL((token, "%*s", __DBGINDENT(), ""))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  166|    783|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  156|    783|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  149|    783|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  157|    783|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  194|    783|        debugmsg("dumph_" token,"%s\n",x);\
  |  |  |  |  195|    783|        __DBGINDENTMORE()
  |  |  |  |  ------------------
  |  |  |  |  |  |  175|    783|#define __DBGINDENTMORE()  debug_indent_add(2)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (83:56): [Folded - Ignored]
  |  |  ------------------
  ------------------
 4413|    783|        result = snmp_pdu_parse(pdu, data, &length);
 4414|    783|        if (result < 0) {
  ------------------
  |  Branch (4414:13): [True: 773, False: 10]
  ------------------
 4415|       |            /*
 4416|       |             * This indicates a parse error.  
 4417|       |             */
 4418|    773|            snmp_increment_statistic(STAT_SNMPINASNPARSEERRS);
  ------------------
  |  |  681|    773|#define  STAT_SNMPINASNPARSEERRS             14
  ------------------
 4419|    773|        }
 4420|    783|        DEBUGINDENTADD(-6);
  ------------------
  |  |   75|    783|#define DEBUGINDENTADD(x)  do {if (_DBG_IF_) {__DBGINDENTADD(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|    783|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 783, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTADD(x)  do {if (_DBG_IF_) {__DBGINDENTADD(x);} }while(0)
  |  |  ------------------
  |  |  |  |  174|    783|#define __DBGINDENTADD(x)  debug_indent_add(x)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded - Ignored]
  |  |  ------------------
  ------------------
 4421|    783|        break;
 4422|      0|#endif /* support for community based SNMP */
 4423|       |
 4424|      0|    case SNMP_VERSION_3:
  ------------------
  |  |  113|      0|#define SNMP_VERSION_3     3
  ------------------
  |  Branch (4424:5): [True: 0, False: 1.74k]
  ------------------
 4425|      0|        NETSNMP_RUNTIME_PROTOCOL_CHECK_V3(SNMP_VERSION_3,unsupported_version);
  ------------------
  |  |  233|      0|#define NETSNMP_RUNTIME_PROTOCOL_CHECK_V3(pc_ver, pc_target) do {      \
  |  |  234|      0|        if (NETSNMP_RUNTIME_PROTOCOL_SKIP_V3(pc_ver)) {                \
  |  |  ------------------
  |  |  |  |  229|      0|    ((pc_ver == SNMP_VERSION_3) &&                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  |  113|      0|#define SNMP_VERSION_3     3
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (229:6): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  |  |  230|      0|     netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,                     \
  |  |  |  |  ------------------
  |  |  |  |  |  |   48|      0|#define NETSNMP_DS_LIBRARY_ID     0
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (230:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  231|      0|                            NETSNMP_DS_LIB_DISABLE_V3))
  |  |  |  |  ------------------
  |  |  |  |  |  |  105|      0|#define NETSNMP_DS_LIB_DISABLE_V3          45 /* disable SNMPv3 */
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  235|      0|            DEBUGMSGTL(("snmp:protocol:disabled", "enforced\n"));      \
  |  |  ------------------
  |  |  |  |   68|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  |  166|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  156|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  157|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  236|      0|            goto pc_target;                                            \
  |  |  237|      0|        }                                                              \
  |  |  238|      0|    } while(0)
  |  |  ------------------
  |  |  |  Branch (238:13): [Folded - Ignored]
  |  |  ------------------
  ------------------
 4426|      0|        result = snmpv3_parse(pdu, data, &length, NULL, session);
 4427|      0|        DEBUGMSGTL(("snmp_parse",
  ------------------
  |  |   68|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
 4428|      0|                    "Parsed SNMPv3 message (secName:%s, secLevel:%s): %s\n",
 4429|      0|                    pdu->securityName, secLevelName[pdu->securityLevel],
 4430|      0|                    snmp_api_errstring(result)));
 4431|       |
 4432|      0|        if (result == SNMPERR_USM_UNKNOWNSECURITYNAME) {
  ------------------
  |  |  260|      0|#define SNMPERR_USM_UNKNOWNSECURITYNAME		(-43)
  ------------------
  |  Branch (4432:13): [True: 0, False: 0]
  ------------------
 4433|      0|            snmp_call_callbacks(SNMP_CALLBACK_APPLICATION,
  ------------------
  |  |   19|      0|#define SNMP_CALLBACK_APPLICATION 1
  ------------------
 4434|      0|                                SNMPD_CALLBACK_AUTH_FAILURE, pdu);
  ------------------
  |  |   21|      0|#define SNMPD_CALLBACK_AUTH_FAILURE             17
  ------------------
 4435|      0|        }
 4436|       |        
 4437|      0|        if (result) {
  ------------------
  |  Branch (4437:13): [True: 0, False: 0]
  ------------------
 4438|      0|            struct snmp_secmod_def *secmod =
 4439|      0|                find_sec_mod(pdu->securityModel);
 4440|      0|            if (!slp) {
  ------------------
  |  Branch (4440:17): [True: 0, False: 0]
  ------------------
 4441|      0|                session->s_snmp_errno = result;
 4442|      0|            } else {
 4443|       |                /*
 4444|       |                 * Call the security model to special handle any errors
 4445|       |                 */
 4446|       |
 4447|      0|                if (secmod && secmod->handle_report) {
  ------------------
  |  Branch (4447:21): [True: 0, False: 0]
  |  Branch (4447:31): [True: 0, False: 0]
  ------------------
 4448|      0|                    (*secmod->handle_report)(slp, slp->transport, session,
 4449|      0|                                             result, pdu);
 4450|      0|                }
 4451|      0|            }
 4452|      0|            free_securityStateRef(pdu);
 4453|      0|        }
 4454|       |
 4455|       |        /* Implement RFC5343 here for two reasons:
 4456|       |           1) From a security perspective it handles this otherwise
 4457|       |              always approved request earlier.  It bypasses the need
 4458|       |              for authorization to the snmpEngineID scalar, which is
 4459|       |              what is what RFC3415 appendix A species as ok.  Note
 4460|       |              that we haven't bypassed authentication since if there
 4461|       |              was an authentication eror it would have been handled
 4462|       |              above in the if(result) part at the lastet.
 4463|       |           2) From an application point of view if we let this request
 4464|       |              get all the way to the application, it'd require that
 4465|       |              all application types supporting discovery also fire up
 4466|       |              a minimal agent in order to handle just this request
 4467|       |              which seems like overkill.  Though there is no other
 4468|       |              application types that currently need discovery (NRs
 4469|       |              accept notifications from contextEngineIDs that derive
 4470|       |              from the NO not the NR).  Also a lame excuse for doing
 4471|       |              it here.
 4472|       |           3) Less important technically, but the net-snmp agent
 4473|       |              doesn't currently handle registrations of different
 4474|       |              engineIDs either and it would have been a lot more work
 4475|       |              to implement there since we'd need to support that
 4476|       |              first. :-/ Supporting multiple context engineIDs should
 4477|       |              be done anyway, so it's not a valid excuse here.
 4478|       |           4) There is a lot less to do if we trump the agent at this
 4479|       |              point; IE, the agent does a lot more unnecessary
 4480|       |              processing when the only thing that should ever be in
 4481|       |              this context by definition is the single scalar.
 4482|       |        */
 4483|       |
 4484|       |        /* special RFC5343 engineID discovery engineID check */
 4485|      0|        if (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      0|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (4485:13): [True: 0, False: 0]
  ------------------
 4486|      0|                                    NETSNMP_DS_LIB_NO_DISCOVERY) &&
  ------------------
  |  |   98|      0|#define NETSNMP_DS_LIB_NO_DISCOVERY        38 /* don't support RFC5343 contextEngineID discovery */
  ------------------
 4487|      0|            SNMP_MSG_RESPONSE       != pdu->command &&
  ------------------
  |  |  127|      0|#define SNMP_MSG_RESPONSE   (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x2) /* a2=162 */
  |  |  ------------------
  |  |  |  |   92|      0|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_MSG_RESPONSE   (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x2) /* a2=162 */
  |  |  ------------------
  |  |  |  |   96|      0|#define ASN_CONSTRUCTOR	    0x20U
  |  |  ------------------
  ------------------
  |  Branch (4487:13): [True: 0, False: 0]
  ------------------
 4488|      0|            NULL                    != pdu->contextEngineID &&
  ------------------
  |  Branch (4488:13): [True: 0, False: 0]
  ------------------
 4489|      0|            pdu->contextEngineIDLen == 5 &&
  ------------------
  |  Branch (4489:13): [True: 0, False: 0]
  ------------------
 4490|      0|            pdu->contextEngineID[0] == 0x80 &&
  ------------------
  |  Branch (4490:13): [True: 0, False: 0]
  ------------------
 4491|      0|            pdu->contextEngineID[1] == 0x00 &&
  ------------------
  |  Branch (4491:13): [True: 0, False: 0]
  ------------------
 4492|      0|            pdu->contextEngineID[2] == 0x00 &&
  ------------------
  |  Branch (4492:13): [True: 0, False: 0]
  ------------------
 4493|      0|            pdu->contextEngineID[3] == 0x00 &&
  ------------------
  |  Branch (4493:13): [True: 0, False: 0]
  ------------------
 4494|      0|            pdu->contextEngineID[4] == 0x06) {
  ------------------
  |  Branch (4494:13): [True: 0, False: 0]
  ------------------
 4495|       |
 4496|       |            /* define a result so it doesn't get past us at this point
 4497|       |               and gets dropped by future parts of the stack */
 4498|      0|            result = SNMPERR_JUST_A_CONTEXT_PROBE;
  ------------------
  |  |  283|      0|#define SNMPERR_JUST_A_CONTEXT_PROBE    (-66)
  ------------------
 4499|       |
 4500|      0|            DEBUGMSGTL(("snmpv3_contextid", "starting context ID discovery\n"));
  ------------------
  |  |   68|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
 4501|       |            /* ensure exactly one variable */
 4502|      0|            if (NULL != pdu->variables &&
  ------------------
  |  Branch (4502:17): [True: 0, False: 0]
  ------------------
 4503|      0|                NULL == pdu->variables->next_variable &&
  ------------------
  |  Branch (4503:17): [True: 0, False: 0]
  ------------------
 4504|       |
 4505|       |                /* if it's a GET, match it exactly */
 4506|      0|                ((SNMP_MSG_GET == pdu->command &&
  ------------------
  |  |  125|      0|#define SNMP_MSG_GET        (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x0) /* a0=160 */
  |  |  ------------------
  |  |  |  |   92|      0|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_MSG_GET        (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x0) /* a0=160 */
  |  |  ------------------
  |  |  |  |   96|      0|#define ASN_CONSTRUCTOR	    0x20U
  |  |  ------------------
  ------------------
  |  Branch (4506:19): [True: 0, False: 0]
  ------------------
 4507|      0|                  snmp_oid_compare(snmpEngineIDoid,
  ------------------
  |  Branch (4507:19): [True: 0, False: 0]
  ------------------
 4508|      0|                                   snmpEngineIDoid_len,
 4509|      0|                                   pdu->variables->name,
 4510|      0|                                   pdu->variables->name_length) == 0)
 4511|       |                 /* if it's a GETNEXT ensure it's less than the engineID oid */
 4512|      0|                 ||
 4513|      0|                 (SNMP_MSG_GETNEXT == pdu->command &&
  ------------------
  |  |  126|      0|#define SNMP_MSG_GETNEXT    (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x1) /* a1=161 */
  |  |  ------------------
  |  |  |  |   92|      0|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_MSG_GETNEXT    (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x1) /* a1=161 */
  |  |  ------------------
  |  |  |  |   96|      0|#define ASN_CONSTRUCTOR	    0x20U
  |  |  ------------------
  ------------------
  |  Branch (4513:19): [True: 0, False: 0]
  ------------------
 4514|      0|                  snmp_oid_compare(snmpEngineIDoid,
  ------------------
  |  Branch (4514:19): [True: 0, False: 0]
  ------------------
 4515|      0|                                   snmpEngineIDoid_len,
 4516|      0|                                   pdu->variables->name,
 4517|      0|                                   pdu->variables->name_length) > 0)
 4518|      0|                    )) {
 4519|       |
 4520|      0|                DEBUGMSGTL(("snmpv3_contextid",
  ------------------
  |  |   68|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
 4521|      0|                            "  One correct variable found\n"));
 4522|       |
 4523|       |                /* Note: we're explictly not handling a GETBULK.  Deal. */
 4524|       |
 4525|       |                /* set up the response */
 4526|      0|                pdu2 = snmp_clone_pdu(pdu);
 4527|       |
 4528|       |                /* free the current varbind */
 4529|      0|                snmp_free_varbind(pdu2->variables);
 4530|       |
 4531|       |                /* set the variables */
 4532|      0|                pdu2->variables = NULL;
 4533|      0|                pdu2->command = SNMP_MSG_RESPONSE;
  ------------------
  |  |  127|      0|#define SNMP_MSG_RESPONSE   (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x2) /* a2=162 */
  |  |  ------------------
  |  |  |  |   92|      0|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_MSG_RESPONSE   (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x2) /* a2=162 */
  |  |  ------------------
  |  |  |  |   96|      0|#define ASN_CONSTRUCTOR	    0x20U
  |  |  ------------------
  ------------------
 4534|      0|                pdu2->errstat = 0;
 4535|      0|                pdu2->errindex = 0;
 4536|       |
 4537|      0|                ourEngineID_len =
 4538|      0|                    snmpv3_get_engineID((u_char*)ourEngineID, ourEngineID_len);
 4539|      0|                if (0 != ourEngineID_len) {
  ------------------
  |  Branch (4539:21): [True: 0, False: 0]
  ------------------
 4540|       |
 4541|      0|                    DEBUGMSGTL(("snmpv3_contextid",
  ------------------
  |  |   68|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
 4542|      0|                                "  responding with our engineID\n"));
 4543|       |
 4544|      0|                    snmp_pdu_add_variable(pdu2,
 4545|      0|                                          snmpEngineIDoid, snmpEngineIDoid_len,
 4546|      0|                                          ASN_OCTET_STR,
  ------------------
  |  |   78|      0|#define ASN_OCTET_STR	    0x04U
  ------------------
 4547|      0|                                          ourEngineID, ourEngineID_len);
 4548|       |                    
 4549|       |                    /* send the response */
 4550|      0|                    if (0 == snmp_sess_send(slp, pdu2)) {
  ------------------
  |  Branch (4550:25): [True: 0, False: 0]
  ------------------
 4551|       |
 4552|      0|                        DEBUGMSGTL(("snmpv3_contextid",
  ------------------
  |  |   68|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
 4553|      0|                                    "  sent it off!\n"));
 4554|       |
 4555|      0|                        snmp_free_pdu(pdu2);
 4556|       |                        
 4557|      0|                        snmp_log(LOG_ERR, "sending a response to the context engineID probe failed\n");
 4558|      0|                    }
 4559|      0|                } else {
 4560|      0|                    snmp_log(LOG_ERR, "failed to get our own engineID!\n");
 4561|      0|                }
 4562|      0|            } else {
 4563|      0|                snmp_log(LOG_WARNING,
 4564|      0|                         "received an odd context engineID probe\n");
 4565|      0|            }
 4566|      0|        }
 4567|       |
 4568|      0|        break;
 4569|      0|    case SNMPERR_BAD_VERSION:
  ------------------
  |  |  231|      0|#define SNMPERR_BAD_VERSION		(-14)
  ------------------
  |  Branch (4569:5): [True: 0, False: 1.74k]
  ------------------
 4570|      0|        ERROR_MSG("error parsing snmp message version");
  ------------------
  |  |  190|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 4571|      0|        snmp_increment_statistic(STAT_SNMPINASNPARSEERRS);
  ------------------
  |  |  681|      0|#define  STAT_SNMPINASNPARSEERRS             14
  ------------------
 4572|      0|        session->s_snmp_errno = SNMPERR_BAD_VERSION;
  ------------------
  |  |  231|      0|#define SNMPERR_BAD_VERSION		(-14)
  ------------------
 4573|      0|        break;
 4574|       |
 4575|      0|        unsupported_version:  /* goto label */
 4576|      0|    case SNMP_VERSION_sec:
  ------------------
  |  |  118|      0|#define SNMP_VERSION_sec   128  /* not (will never be) supported by this code */
  ------------------
  |  Branch (4576:5): [True: 0, False: 1.74k]
  ------------------
 4577|      0|    case SNMP_VERSION_2u:
  ------------------
  |  |  112|      0|#define SNMP_VERSION_2u    2    /* not (will never be) supported by this code */
  ------------------
  |  Branch (4577:5): [True: 0, False: 1.74k]
  ------------------
 4578|      0|    case SNMP_VERSION_2star:
  ------------------
  |  |  120|      0|#define SNMP_VERSION_2star 130  /* not (will never be) supported by this code */
  ------------------
  |  Branch (4578:5): [True: 0, False: 1.74k]
  ------------------
 4579|      0|    case SNMP_VERSION_2p:
  ------------------
  |  |  119|      0|#define SNMP_VERSION_2p	   129  /* no longer supported by this code (> 4.0) */
  ------------------
  |  Branch (4579:5): [True: 0, False: 1.74k]
  ------------------
 4580|      0|    default:
  ------------------
  |  Branch (4580:5): [True: 0, False: 1.74k]
  ------------------
 4581|      0|        ERROR_MSG("unsupported snmp message version");
  ------------------
  |  |  190|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 4582|      0|        snmp_increment_statistic(STAT_SNMPINBADVERSIONS);
  ------------------
  |  |  678|      0|#define  STAT_SNMPINBADVERSIONS              11
  ------------------
 4583|       |
 4584|       |        /*
 4585|       |         * need better way to determine OS independent
 4586|       |         * INT32_MAX value, for now hardcode
 4587|       |         */
 4588|      0|        if (pdu->version < 0 || pdu->version > 2147483647) {
  ------------------
  |  Branch (4588:13): [True: 0, False: 0]
  |  Branch (4588:33): [True: 0, False: 0]
  ------------------
 4589|      0|            snmp_increment_statistic(STAT_SNMPINASNPARSEERRS);
  ------------------
  |  |  681|      0|#define  STAT_SNMPINASNPARSEERRS             14
  ------------------
 4590|      0|        }
 4591|      0|        session->s_snmp_errno = SNMPERR_BAD_VERSION;
  ------------------
  |  |  231|      0|#define SNMPERR_BAD_VERSION		(-14)
  ------------------
 4592|      0|        break;
 4593|  1.74k|    }
 4594|       |
 4595|    783|    return result;
 4596|  1.74k|}
snmp_api.c:_sess_read_dgram_packet:
 6093|  10.4k|{
 6094|  10.4k|    netsnmp_session *sp = slp ? slp->session : NULL;
  ------------------
  |  Branch (6094:27): [True: 10.4k, False: 0]
  ------------------
 6095|  10.4k|    struct snmp_internal_session *isp = slp ? slp->internal : NULL;
  ------------------
  |  Branch (6095:41): [True: 10.4k, False: 0]
  ------------------
 6096|  10.4k|    netsnmp_transport *transport = slp ? slp->transport : NULL;
  ------------------
  |  Branch (6096:36): [True: 10.4k, False: 0]
  ------------------
 6097|       |
 6098|  10.4k|    if (!sp || !isp || !transport || !rcvp ) {
  ------------------
  |  Branch (6098:9): [True: 0, False: 10.4k]
  |  Branch (6098:16): [True: 0, False: 10.4k]
  |  Branch (6098:24): [True: 0, False: 10.4k]
  |  Branch (6098:38): [True: 0, False: 10.4k]
  ------------------
 6099|      0|        DEBUGMSGTL(("sess_read_packet", "missing arguments\n"));
  ------------------
  |  |   68|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
 6100|      0|        return -2;
 6101|      0|    }
 6102|       |
 6103|  10.4k|    if (transport->flags & NETSNMP_TRANSPORT_FLAG_STREAM)
  ------------------
  |  |   51|  10.4k|#define		NETSNMP_TRANSPORT_FLAG_STREAM	 0x01
  ------------------
  |  Branch (6103:9): [True: 0, False: 10.4k]
  ------------------
 6104|      0|        return -2;
 6105|       |
 6106|  10.4k|    if (NULL != rcvp->packet) {
  ------------------
  |  Branch (6106:9): [True: 0, False: 10.4k]
  ------------------
 6107|      0|        snmp_log(LOG_WARNING, "overwriting existing saved packet; sess %p\n",
 6108|      0|                 sp);
 6109|      0|        SNMP_FREE(rcvp->packet);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded - Ignored]
  |  |  ------------------
  ------------------
 6110|      0|    }
 6111|       |
 6112|  10.4k|    if ((rcvp->packet = (u_char *) malloc(SNMP_MAX_RCV_MSG_SIZE)) == NULL) {
  ------------------
  |  |  141|  10.4k|#define SNMP_MAX_RCV_MSG_SIZE      65536
  ------------------
  |  Branch (6112:9): [True: 0, False: 10.4k]
  ------------------
 6113|      0|        DEBUGMSGTL(("sess_read_packet", "can't malloc %u bytes for packet\n",
  ------------------
  |  |   68|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
 6114|      0|                    SNMP_MAX_RCV_MSG_SIZE));
 6115|      0|        return -2;
 6116|      0|    }
 6117|       |
 6118|  10.4k|    rcvp->packet_len = netsnmp_transport_recv(transport, rcvp->packet,
 6119|  10.4k|                                              SNMP_MAX_RCV_MSG_SIZE,
  ------------------
  |  |  141|  10.4k|#define SNMP_MAX_RCV_MSG_SIZE      65536
  ------------------
 6120|  10.4k|                                              &rcvp->opaque, &rcvp->olength);
 6121|  10.4k|    if (rcvp->packet_len == -1) {
  ------------------
  |  Branch (6121:9): [True: 8.72k, False: 1.74k]
  ------------------
 6122|  8.72k|        sp->s_snmp_errno = SNMPERR_BAD_RECVFROM;
  ------------------
  |  |  242|  8.72k|#define SNMPERR_BAD_RECVFROM 		(-25)
  ------------------
 6123|  8.72k|        sp->s_errno = errno;
 6124|  8.72k|        snmp_set_detail(strerror(errno));
 6125|  8.72k|        SNMP_FREE(rcvp->packet);
  ------------------
  |  |   62|  8.72k|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 8.72k, False: 0]
  |  |  |  Branch (62:66): [Folded - Ignored]
  |  |  ------------------
  ------------------
 6126|  8.72k|        SNMP_FREE(rcvp->opaque);
  ------------------
  |  |   62|  8.72k|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 8.72k]
  |  |  |  Branch (62:66): [Folded - Ignored]
  |  |  ------------------
  ------------------
 6127|  8.72k|        return -1;
 6128|  8.72k|    }
 6129|       |
 6130|       |    /** clear so any other sess sharing this socket won't try reading again */
 6131|  1.74k|    NETSNMP_LARGE_FD_CLR(transport->sock, fdset);
  ------------------
  |  |   43|  1.74k|                    netsnmp_large_fd_clr(fd, fdset)
  ------------------
 6132|       |
 6133|  1.74k|    if (0 == rcvp->packet_len &&
  ------------------
  |  Branch (6133:9): [True: 0, False: 1.74k]
  ------------------
 6134|  1.74k|        transport->flags & NETSNMP_TRANSPORT_FLAG_EMPTY_PKT) {
  ------------------
  |  |   56|      0|#define		NETSNMP_TRANSPORT_FLAG_EMPTY_PKT 0x10
  ------------------
  |  Branch (6134:9): [True: 0, False: 0]
  ------------------
 6135|       |        /* this allows for a transport that needs to return from
 6136|       |         * packet processing that doesn't necessarily have any
 6137|       |         * consumable data in it. */
 6138|       |
 6139|       |        /* reset the flag since it's a per-message flag */
 6140|      0|        transport->flags &= (~NETSNMP_TRANSPORT_FLAG_EMPTY_PKT);
  ------------------
  |  |   56|      0|#define		NETSNMP_TRANSPORT_FLAG_EMPTY_PKT 0x10
  ------------------
 6141|       |
 6142|       |        /** free packet */
 6143|      0|        SNMP_FREE(rcvp->packet);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded - Ignored]
  |  |  ------------------
  ------------------
 6144|      0|        SNMP_FREE(rcvp->opaque);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded - Ignored]
  |  |  ------------------
  ------------------
 6145|       |
 6146|      0|        return -2;
 6147|      0|    }
 6148|       |
 6149|  1.74k|    return 0;
 6150|  1.74k|}
snmp_api.c:_sess_process_packet:
 5934|  1.74k|{
 5935|  1.74k|    netsnmp_pdu         *pdu;
 5936|  1.74k|    int                  rc;
 5937|       |
 5938|  1.74k|    pdu = _sess_process_packet_parse_pdu(slp, sp, isp, transport, opaque,
 5939|  1.74k|                                         olength, packetptr, length);
 5940|  1.74k|    if (NULL == pdu)
  ------------------
  |  Branch (5940:9): [True: 1.73k, False: 10]
  ------------------
 5941|  1.73k|        return -1;
 5942|       |
 5943|       |    /*
 5944|       |     * find session to process pdu. usually that will be the current session,
 5945|       |     * but with the introduction of shared transports, another session may
 5946|       |     * have the same socket.
 5947|       |     */
 5948|     10|    do {
 5949|     10|        rc = _sess_process_packet_handle_pdu(slp, sp, isp, transport, pdu);
 5950|     10|        if (-2 != rc || !(transport->flags & NETSNMP_TRANSPORT_FLAG_SHARED))
  ------------------
  |  |   58|      0|#define		NETSNMP_TRANSPORT_FLAG_SHARED	 0x40
  ------------------
  |  Branch (5950:13): [True: 10, False: 0]
  |  Branch (5950:25): [True: 0, False: 0]
  ------------------
 5951|     10|            break;
 5952|       |
 5953|       |        /** -2 means pdu not in request list. check other sessions */
 5954|      0|        do  {
 5955|      0|            slp = slp->next;
 5956|      0|        } while (slp && slp->transport->sock != transport->sock);
  ------------------
  |  Branch (5956:18): [True: 0, False: 0]
  |  Branch (5956:25): [True: 0, False: 0]
  ------------------
 5957|      0|        if (!slp)
  ------------------
  |  Branch (5957:13): [True: 0, False: 0]
  ------------------
 5958|      0|            break; /* no more sessions with same socket */
 5959|       |
 5960|      0|        sp = slp->session;
 5961|      0|        isp = slp->internal;
 5962|      0|        transport = slp->transport;
 5963|      0|    } while(slp);
  ------------------
  |  Branch (5963:13): [True: 0, False: 0]
  ------------------
 5964|       |
 5965|     10|    if (-2 == rc) { /* did not find session for pdu */
  ------------------
  |  Branch (5965:9): [True: 0, False: 10]
  ------------------
 5966|      0|        snmp_increment_statistic(STAT_SNMPUNKNOWNPDUHANDLERS);
  ------------------
  |  |  657|      0|#define   STAT_SNMPUNKNOWNPDUHANDLERS        2
  ------------------
 5967|      0|        DEBUGMSGTL(("sess_process_packet", "unhandled PDU\n"));
  ------------------
  |  |   68|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
 5968|      0|        snmp_free_pdu(pdu);
 5969|      0|    }
 5970|       |
 5971|     10|  return rc;
 5972|  1.74k|}
snmp_api.c:_sess_process_packet_parse_pdu:
 5617|  1.74k|{
 5618|  1.74k|  netsnmp_pdu    *pdu;
 5619|  1.74k|  int             ret = 0;
 5620|  1.74k|  int             dump = 0, filter = 0;
 5621|       |
 5622|  1.74k|  debug_indent_reset();
 5623|       |
 5624|  1.74k|  DEBUGMSGTL(("sess_process_packet",
  ------------------
  |  |   68|  1.74k|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|  1.74k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 1.74k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|  1.74k|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|  1.74k|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|  1.74k|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|  1.74k|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
 5625|  1.74k|	      "session %p fd %d pkt %p length %d\n", slp,
 5626|  1.74k|	      transport->sock, packetptr, length));
 5627|       |
 5628|  1.74k|  dump = netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|  1.74k|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 5629|  1.74k|                                NETSNMP_DS_LIB_DUMP_PACKET);
  ------------------
  |  |   63|  1.74k|#define NETSNMP_DS_LIB_DUMP_PACKET         4
  ------------------
 5630|  1.74k|#ifndef NETSNMP_FEATURE_REMOVE_FILTER_SOURCE
 5631|  1.74k|  filter = netsnmp_ds_get_int(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|  1.74k|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 5632|  1.74k|                                  NETSNMP_DS_LIB_FILTER_TYPE);
  ------------------
  |  |  133|  1.74k|#define NETSNMP_DS_LIB_FILTER_TYPE         17 /* 0=NONE, 1=whitelist, -1=blacklist */
  ------------------
 5633|  1.74k|#endif
 5634|  1.74k|  if (dump || filter) {
  ------------------
  |  Branch (5634:7): [True: 0, False: 1.74k]
  |  Branch (5634:15): [True: 0, False: 1.74k]
  ------------------
 5635|      0|      int filtered = 0;
 5636|      0|      char *addrtxt = netsnmp_transport_peer_string(transport, opaque, olength);
 5637|      0|      snmp_log(LOG_DEBUG, "\nReceived %d byte packet from %s\n",
 5638|      0|               length, addrtxt);
 5639|       |
 5640|      0|      if (dump)
  ------------------
  |  Branch (5640:11): [True: 0, False: 0]
  ------------------
 5641|      0|          xdump(packetptr, length, "");
 5642|       |
 5643|      0|#ifndef NETSNMP_FEATURE_REMOVE_FILTER_SOURCE
 5644|      0|      if (filter) {
  ------------------
  |  Branch (5644:11): [True: 0, False: 0]
  ------------------
 5645|      0|          char *sourceaddr = NULL, *c = strchr(addrtxt, '[');
 5646|      0|          const char *dropstr = NULL;
 5647|      0|          if (c) {
  ------------------
  |  Branch (5647:15): [True: 0, False: 0]
  ------------------
 5648|      0|              sourceaddr = ++c;
 5649|      0|              c = strchr(sourceaddr, ']');
 5650|      0|              if (c)
  ------------------
  |  Branch (5650:19): [True: 0, False: 0]
  ------------------
 5651|      0|                  *c = 0;
 5652|      0|              filtered = netsnmp_transport_filter_check(sourceaddr);
 5653|      0|          }
 5654|      0|          else if (!strncmp(addrtxt, "callback", 8)) {
  ------------------
  |  Branch (5654:20): [True: 0, False: 0]
  ------------------
 5655|       |              /* do not filter internal request */
 5656|      0|              DEBUGMSGTL(("sess_process_packet:filter",
  ------------------
  |  |   68|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
 5657|      0|                          "bypass packet from %s \n",
 5658|      0|                          addrtxt));
 5659|      0|              filtered = 1;
 5660|      0|          }
 5661|      0|          if ((filter == -1) && filtered)
  ------------------
  |  Branch (5661:15): [True: 0, False: 0]
  |  Branch (5661:33): [True: 0, False: 0]
  ------------------
 5662|      0|              dropstr = "matched blacklist";
 5663|      0|          else if ((filter == 1) && !filtered)
  ------------------
  |  Branch (5663:20): [True: 0, False: 0]
  |  Branch (5663:37): [True: 0, False: 0]
  ------------------
 5664|      0|              dropstr = "didn't match whitelist";
 5665|      0|          if (dropstr) {
  ------------------
  |  Branch (5665:15): [True: 0, False: 0]
  ------------------
 5666|      0|              DEBUGMSGTL(("sess_process_packet:filter",
  ------------------
  |  |   68|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (166:52): [True: 0, False: 0]
  |  |  |  |  |  Branch (166:64): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
 5667|      0|                          "packet from %s %s\n",
 5668|      0|                          sourceaddr ? sourceaddr : "UNKNOWN", dropstr));
 5669|      0|              SNMP_FREE(opaque);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded - Ignored]
  |  |  ------------------
  ------------------
 5670|      0|              SNMP_FREE(addrtxt);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded - Ignored]
  |  |  ------------------
  ------------------
 5671|      0|              return NULL;
 5672|      0|          }
 5673|      0|      }
 5674|      0|#endif
 5675|       |
 5676|      0|      SNMP_FREE(addrtxt);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded - Ignored]
  |  |  ------------------
  ------------------
 5677|      0|  }
 5678|       |
 5679|       |  /*
 5680|       |   * Do transport-level filtering (e.g. IP-address based allow/deny).  
 5681|       |   */
 5682|       |
 5683|  1.74k|  if (isp->hook_pre) {
  ------------------
  |  Branch (5683:7): [True: 0, False: 1.74k]
  ------------------
 5684|      0|    if (isp->hook_pre(sp, transport, opaque, olength) == 0) {
  ------------------
  |  Branch (5684:9): [True: 0, False: 0]
  ------------------
 5685|      0|      DEBUGMSGTL(("sess_process_packet", "pre-parse fail\n"));
  ------------------
  |  |   68|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
 5686|      0|      SNMP_FREE(opaque);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded - Ignored]
  |  |  ------------------
  ------------------
 5687|      0|      return NULL;
 5688|      0|    }
 5689|      0|  }
 5690|       |
 5691|  1.74k|  if (isp->hook_create_pdu) {
  ------------------
  |  Branch (5691:7): [True: 0, False: 1.74k]
  ------------------
 5692|      0|    pdu = isp->hook_create_pdu(transport, opaque, olength);
 5693|  1.74k|  } else {
 5694|  1.74k|    pdu = snmp_create_sess_pdu(transport, opaque, olength);
 5695|  1.74k|  }
 5696|       |
 5697|  1.74k|  if (pdu == NULL) {
  ------------------
  |  Branch (5697:7): [True: 0, False: 1.74k]
  ------------------
 5698|      0|    snmp_log(LOG_ERR, "pdu failed to be created\n");
 5699|      0|    SNMP_FREE(opaque);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded - Ignored]
  |  |  ------------------
  ------------------
 5700|      0|    return NULL;
 5701|      0|  }
 5702|       |
 5703|       |  /* if the transport was a magic tunnel, mark the PDU as having come
 5704|       |     through one. */
 5705|  1.74k|  if (transport->flags & NETSNMP_TRANSPORT_FLAG_TUNNELED) {
  ------------------
  |  |   53|  1.74k|#define		NETSNMP_TRANSPORT_FLAG_TUNNELED	 0x04
  ------------------
  |  Branch (5705:7): [True: 0, False: 1.74k]
  ------------------
 5706|      0|      pdu->flags |= UCD_MSG_FLAG_TUNNELED;
  ------------------
  |  |  317|      0|#define UCD_MSG_FLAG_TUNNELED               0x4000
  ------------------
 5707|      0|  }
 5708|       |
 5709|  1.74k|  if (isp->hook_parse) {
  ------------------
  |  Branch (5709:7): [True: 0, False: 1.74k]
  ------------------
 5710|      0|    ret = isp->hook_parse(sp, pdu, packetptr, length);
 5711|  1.74k|  } else {
 5712|  1.74k|    ret = snmp_parse(slp, sp, pdu, packetptr, length);
 5713|  1.74k|  }
 5714|       |
 5715|  1.74k|  DEBUGMSGTL(("sess_process_packet", "received message id#%ld reqid#%ld len "
  ------------------
  |  |   68|  1.74k|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|  1.74k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 1.74k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|  1.74k|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|  1.74k|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|  1.74k|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|  1.74k|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
 5716|  1.74k|              "%u\n", pdu->msgid, pdu->reqid, length));
 5717|       |
 5718|  1.74k|  if (ret != SNMP_ERR_NOERROR) {
  ------------------
  |  |  212|  1.74k|#define SNMP_ERR_NOERROR                (0)     /* XXX  Used only for PDUs? */
  ------------------
  |  Branch (5718:7): [True: 1.73k, False: 10]
  ------------------
 5719|  1.73k|    DEBUGMSGTL(("sess_process_packet", "parse fail\n"));
  ------------------
  |  |   68|  1.73k|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|  1.73k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 1.73k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|  1.73k|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|  1.73k|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|  1.73k|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|  1.73k|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
 5720|  1.73k|  }
 5721|       |
 5722|  1.74k|  if (isp->hook_post) {
  ------------------
  |  Branch (5722:7): [True: 0, False: 1.74k]
  ------------------
 5723|      0|    if (isp->hook_post(sp, pdu, ret) == 0) {
  ------------------
  |  Branch (5723:9): [True: 0, False: 0]
  ------------------
 5724|      0|      DEBUGMSGTL(("sess_process_packet", "post-parse fail\n"));
  ------------------
  |  |   68|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
 5725|      0|      ret = SNMPERR_ASN_PARSE_ERR;
  ------------------
  |  |  246|      0|#define SNMPERR_ASN_PARSE_ERR           (-29)
  ------------------
 5726|      0|    }
 5727|      0|  }
 5728|       |
 5729|  1.74k|  if (ret != SNMP_ERR_NOERROR) {
  ------------------
  |  |  212|  1.74k|#define SNMP_ERR_NOERROR                (0)     /* XXX  Used only for PDUs? */
  ------------------
  |  Branch (5729:7): [True: 1.73k, False: 10]
  ------------------
 5730|  1.73k|    snmp_free_pdu(pdu);
 5731|  1.73k|    return NULL;
 5732|  1.73k|  }
 5733|       |
 5734|     10|  return pdu;
 5735|  1.74k|}
snmp_api.c:_sess_process_packet_handle_pdu:
 5758|     10|{
 5759|     10|  netsnmp_request_list *rp, *orp = NULL;
 5760|     10|  int             handled = 0;
 5761|       |
 5762|     10|  if (pdu->flags & UCD_MSG_FLAG_RESPONSE_PDU) {
  ------------------
  |  |  311|     10|#define UCD_MSG_FLAG_RESPONSE_PDU            0x100
  ------------------
  |  Branch (5762:7): [True: 2, False: 8]
  ------------------
 5763|       |    /*
 5764|       |     * Call USM to free any securityStateRef supplied with the message.  
 5765|       |     */
 5766|      2|    free_securityStateRef(pdu);
 5767|       |
 5768|      2|    for (rp = isp->requests; rp; orp = rp, rp = rp->next_request) {
  ------------------
  |  Branch (5768:30): [True: 0, False: 2]
  ------------------
 5769|      0|      snmp_callback   callback;
 5770|      0|      void           *magic;
 5771|       |
 5772|      0|      if (pdu->version == SNMP_VERSION_3) {
  ------------------
  |  |  113|      0|#define SNMP_VERSION_3     3
  ------------------
  |  Branch (5772:11): [True: 0, False: 0]
  ------------------
 5773|       |	/*
 5774|       |	 * msgId must match for v3 messages.  
 5775|       |	 */
 5776|      0|	if (rp->message_id != pdu->msgid) {
  ------------------
  |  Branch (5776:6): [True: 0, False: 0]
  ------------------
 5777|      0|            DEBUGMSGTL(("sess_process_packet", "unmatched msg id: %ld != %ld\n",
  ------------------
  |  |   68|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
 5778|      0|                        rp->message_id, pdu->msgid));
 5779|      0|	    continue;
 5780|      0|	}
 5781|       |
 5782|       |	/*
 5783|       |	 * Check that message fields match original, if not, no further
 5784|       |	 * processing.  
 5785|       |	 */
 5786|      0|	if (!snmpv3_verify_msg(rp, pdu)) {
  ------------------
  |  Branch (5786:6): [True: 0, False: 0]
  ------------------
 5787|      0|	  break;
 5788|      0|	}
 5789|      0|      } else {
 5790|      0|	if (rp->request_id != pdu->reqid) {
  ------------------
  |  Branch (5790:6): [True: 0, False: 0]
  ------------------
 5791|      0|	  continue;
 5792|      0|	}
 5793|      0|      }
 5794|       |
 5795|      0|      if (rp->callback) {
  ------------------
  |  Branch (5795:11): [True: 0, False: 0]
  ------------------
 5796|      0|	callback = rp->callback;
 5797|      0|	magic = rp->cb_data;
 5798|      0|      } else {
 5799|      0|	callback = sp->callback;
 5800|      0|	magic = sp->callback_magic;
 5801|      0|      }
 5802|      0|      handled = 1;
 5803|       |
 5804|       |      /*
 5805|       |       * MTR snmp_res_lock(MT_LIBRARY_ID, MT_LIB_SESSION);  ?* XX lock
 5806|       |       * should be per session ! 
 5807|       |       */
 5808|       |
 5809|      0|      if (callback == NULL
  ------------------
  |  Branch (5809:11): [True: 0, False: 0]
  ------------------
 5810|      0|	  || callback(NETSNMP_CALLBACK_OP_RECEIVED_MESSAGE, sp,
  ------------------
  |  |  352|      0|#define NETSNMP_CALLBACK_OP_RECEIVED_MESSAGE	1
  ------------------
  |  Branch (5810:7): [True: 0, False: 0]
  ------------------
 5811|      0|		      pdu->reqid, pdu, magic) == 1) {
 5812|      0|	if (pdu->command == SNMP_MSG_REPORT) {
  ------------------
  |  |  147|      0|#define SNMP_MSG_REPORT     (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x8) /* a8=168 */
  |  |  ------------------
  |  |  |  |   92|      0|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_MSG_REPORT     (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x8) /* a8=168 */
  |  |  ------------------
  |  |  |  |   96|      0|#define ASN_CONSTRUCTOR	    0x20U
  |  |  ------------------
  ------------------
  |  Branch (5812:6): [True: 0, False: 0]
  ------------------
 5813|      0|	  if (sp->s_snmp_errno == SNMPERR_NOT_IN_TIME_WINDOW ||
  ------------------
  |  |  253|      0|#define SNMPERR_NOT_IN_TIME_WINDOW 	(-36)
  ------------------
  |  Branch (5813:8): [True: 0, False: 0]
  ------------------
 5814|      0|	      snmpv3_get_report_type(pdu) ==
  ------------------
  |  Branch (5814:8): [True: 0, False: 0]
  ------------------
 5815|      0|	      SNMPERR_NOT_IN_TIME_WINDOW) {
  ------------------
  |  |  253|      0|#define SNMPERR_NOT_IN_TIME_WINDOW 	(-36)
  ------------------
 5816|       |	    /*
 5817|       |	     * trigger immediate retry on recoverable Reports 
 5818|       |	     * * (notInTimeWindow), incr_retries == TRUE to prevent
 5819|       |	     * * inifinite resend                      
 5820|       |	     */
 5821|      0|	    if (rp->retries <= sp->retries) {
  ------------------
  |  Branch (5821:10): [True: 0, False: 0]
  ------------------
 5822|      0|	      snmp_resend_request(slp, orp, rp, TRUE);
  ------------------
  |  |  128|      0|#define TRUE  1
  ------------------
 5823|      0|	      break;
 5824|      0|	    } else {
 5825|       |	      /* We're done with retries, so no longer waiting for a response */
 5826|      0|	      if (callback) {
  ------------------
  |  Branch (5826:12): [True: 0, False: 0]
  ------------------
 5827|      0|	        callback(NETSNMP_CALLBACK_OP_SEC_ERROR, sp,
  ------------------
  |  |  358|      0|#define NETSNMP_CALLBACK_OP_SEC_ERROR		7
  ------------------
 5828|      0|	                 pdu->reqid, pdu, magic);
 5829|      0|	      }
 5830|      0|	    }
 5831|      0|	  } else {
 5832|      0|	    if (SNMPV3_IGNORE_UNAUTH_REPORTS) {
  ------------------
  |  |  152|      0|#define SNMPV3_IGNORE_UNAUTH_REPORTS 0
  |  |  ------------------
  |  |  |  Branch (152:38): [Folded - Ignored]
  |  |  ------------------
  ------------------
 5833|      0|	      break;
 5834|      0|	    } else { /* We're done with retries */
 5835|      0|	      if (callback) {
  ------------------
  |  Branch (5835:12): [True: 0, False: 0]
  ------------------
 5836|      0|	        callback(NETSNMP_CALLBACK_OP_SEC_ERROR, sp,
  ------------------
  |  |  358|      0|#define NETSNMP_CALLBACK_OP_SEC_ERROR		7
  ------------------
 5837|      0|	                 pdu->reqid, pdu, magic);
 5838|      0|	      }
 5839|      0|	    }
 5840|      0|	  }
 5841|       |
 5842|       |	  /*
 5843|       |	   * Handle engineID discovery.  
 5844|       |	   */
 5845|      0|	  if (!sp->securityEngineIDLen && pdu->securityEngineIDLen) {
  ------------------
  |  Branch (5845:8): [True: 0, False: 0]
  |  Branch (5845:36): [True: 0, False: 0]
  ------------------
 5846|      0|	    sp->securityEngineID =
 5847|      0|	      (u_char *) malloc(pdu->securityEngineIDLen);
 5848|      0|	    if (sp->securityEngineID == NULL) {
  ------------------
  |  Branch (5848:10): [True: 0, False: 0]
  ------------------
 5849|       |	      /*
 5850|       |	       * TODO FIX: recover after message callback *?
 5851|       |               */
 5852|      0|                snmp_log(LOG_ERR, "malloc failed handling pdu\n");
 5853|      0|                snmp_free_pdu(pdu);
 5854|      0|                return -1;
 5855|      0|	    }
 5856|      0|	    memcpy(sp->securityEngineID, pdu->securityEngineID,
 5857|      0|		   pdu->securityEngineIDLen);
 5858|      0|	    sp->securityEngineIDLen = pdu->securityEngineIDLen;
 5859|      0|	    if (!sp->contextEngineIDLen) {
  ------------------
  |  Branch (5859:10): [True: 0, False: 0]
  ------------------
 5860|      0|	      sp->contextEngineID =
 5861|      0|		(u_char *) malloc(pdu->
 5862|      0|				  securityEngineIDLen);
 5863|      0|	      if (sp->contextEngineID == NULL) {
  ------------------
  |  Branch (5863:12): [True: 0, False: 0]
  ------------------
 5864|       |		/*
 5865|       |		 * TODO FIX: recover after message callback *?
 5866|       |		 */
 5867|      0|                snmp_log(LOG_ERR, "malloc failed handling pdu\n");
 5868|      0|                snmp_free_pdu(pdu);
 5869|      0|                return -1;
 5870|      0|	      }
 5871|      0|	      memcpy(sp->contextEngineID,
 5872|      0|		     pdu->securityEngineID,
 5873|      0|		     pdu->securityEngineIDLen);
 5874|      0|	      sp->contextEngineIDLen =
 5875|      0|		pdu->securityEngineIDLen;
 5876|      0|	    }
 5877|      0|	  }
 5878|      0|	}
 5879|       |
 5880|       |	/*
 5881|       |	 * Successful, so delete request.  
 5882|       |	 */
 5883|      0|	remove_request(isp, orp, rp);
 5884|      0|	free(rp);
 5885|       |	/*
 5886|       |	 * There shouldn't be any more requests with the same reqid.  
 5887|       |	 */
 5888|      0|	break;
 5889|      0|      }
 5890|       |      /*
 5891|       |       * MTR snmp_res_unlock(MT_LIBRARY_ID, MT_LIB_SESSION);  ?* XX lock should be per session ! 
 5892|       |       */
 5893|      0|    }
 5894|      8|  } else {
 5895|      8|    if (sp->callback) {
  ------------------
  |  Branch (5895:9): [True: 8, False: 0]
  ------------------
 5896|       |      /*
 5897|       |       * MTR snmp_res_lock(MT_LIBRARY_ID, MT_LIB_SESSION); 
 5898|       |       */
 5899|      8|      handled = 1;
 5900|      8|      sp->callback(NETSNMP_CALLBACK_OP_RECEIVED_MESSAGE,
  ------------------
  |  |  352|      8|#define NETSNMP_CALLBACK_OP_RECEIVED_MESSAGE	1
  ------------------
 5901|      8|		   sp, pdu->reqid, pdu, sp->callback_magic);
 5902|       |      /*
 5903|       |       * MTR snmp_res_unlock(MT_LIBRARY_ID, MT_LIB_SESSION); 
 5904|       |       */
 5905|      8|    }
 5906|      8|  }
 5907|       |
 5908|     10|  if (!handled) {
  ------------------
  |  Branch (5908:7): [True: 2, False: 8]
  ------------------
 5909|      2|    if (sp->flags & SNMP_FLAGS_SHARED_SOCKET)
  ------------------
  |  |  192|      2|#define SNMP_FLAGS_SHARED_SOCKET   0x10 /* subsession list=related sessions */
  ------------------
  |  Branch (5909:9): [True: 0, False: 2]
  ------------------
 5910|      0|      return -2;
 5911|      2|    snmp_increment_statistic(STAT_SNMPUNKNOWNPDUHANDLERS);
  ------------------
  |  |  657|      2|#define   STAT_SNMPUNKNOWNPDUHANDLERS        2
  ------------------
 5912|      2|    DEBUGMSGTL(("sess_process_packet", "unhandled PDU\n"));
  ------------------
  |  |   68|      2|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      2|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 2, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      2|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      2|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      2|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      2|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
 5913|      2|  }
 5914|       |
 5915|     10|  snmp_free_pdu(pdu);
 5916|     10|  return 0;
 5917|     10|}

snmp_comstr_parse:
  109|  1.74k|{
  110|  1.74k|    u_char          type;
  111|  1.74k|    long            ver;
  112|  1.74k|    size_t          origlen = *slen;
  113|       |
  114|       |    /*
  115|       |     * Message is an ASN.1 SEQUENCE.
  116|       |     */
  117|  1.74k|    data = asn_parse_sequence(data, length, &type,
  118|  1.74k|                              (ASN_SEQUENCE | ASN_CONSTRUCTOR),
  ------------------
  |  |   84|  1.74k|#define ASN_SEQUENCE	    0x10U
  ------------------
                                            (ASN_SEQUENCE | ASN_CONSTRUCTOR),
  ------------------
  |  |   96|  1.74k|#define ASN_CONSTRUCTOR	    0x20U
  ------------------
  119|  1.74k|                              "auth message");
  120|  1.74k|    if (data == NULL) {
  ------------------
  |  Branch (120:9): [True: 310, False: 1.43k]
  ------------------
  121|    310|        return NULL;
  122|    310|    }
  123|       |
  124|       |    /*
  125|       |     * First field is the version.
  126|       |     */
  127|  1.43k|    DEBUGDUMPHEADER("recv", "SNMP version");
  ------------------
  |  |   81|  1.43k|	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|  1.43k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 1.43k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  180|  1.43k|        __DBGPRINTINDENT("dumph_" token); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  177|  1.43k|#define __DBGPRINTINDENT(token) __DBGMSGTL((token, "%*s", __DBGINDENT(), ""))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  166|  1.43k|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  156|  1.43k|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  149|  1.43k|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  157|  1.43k|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  181|  1.43k|        debugmsg("dumph_" token,x); \
  |  |  |  |  182|  1.43k|        if (debug_is_token_registered("dumpx" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  217|  2.86k|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (182:13): [True: 1.43k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  183|  1.43k|            debug_is_token_registered("dumpv" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  217|  1.43k|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  184|  1.43k|            (debug_is_token_registered("dumpx_" token) != SNMPERR_SUCCESS &&  \
  |  |  |  |  ------------------
  |  |  |  |  |  |  217|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (184:14): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  185|  1.43k|             debug_is_token_registered("dumpv_" token) != SNMPERR_SUCCESS)) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |  217|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (185:14): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  186|  1.43k|            debugmsg("dumph_" token,"\n"); \
  |  |  |  |  187|  1.43k|        } else { \
  |  |  |  |  188|      0|            debugmsg("dumph_" token,"  "); \
  |  |  |  |  189|      0|        } \
  |  |  |  |  190|  1.43k|        __DBGINDENTMORE()
  |  |  |  |  ------------------
  |  |  |  |  |  |  175|  1.43k|#define __DBGINDENTMORE()  debug_indent_add(2)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (81:55): [Folded - Ignored]
  |  |  ------------------
  ------------------
  128|  1.43k|    data = asn_parse_int(data, length, &type, &ver, sizeof(ver));
  129|  1.43k|    DEBUGINDENTLESS();
  ------------------
  |  |   77|  1.43k|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  146|  1.43k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 1.43k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  176|  1.43k|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (77:74): [Folded - Ignored]
  |  |  ------------------
  ------------------
  130|  1.43k|    *version = ver;
  131|  1.43k|    if (data == NULL) {
  ------------------
  |  Branch (131:9): [True: 163, False: 1.26k]
  ------------------
  132|    163|        ERROR_MSG("bad parse of version");
  ------------------
  |  |  190|    163|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
  133|    163|        return NULL;
  134|    163|    }
  135|       |
  136|       |    /*
  137|       |     * second field is the community string for SNMPv1 & SNMPv2c 
  138|       |     */
  139|  1.26k|    DEBUGDUMPHEADER("recv", "community string");
  ------------------
  |  |   81|  1.26k|	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|  1.26k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 1.26k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  180|  1.26k|        __DBGPRINTINDENT("dumph_" token); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  177|  1.26k|#define __DBGPRINTINDENT(token) __DBGMSGTL((token, "%*s", __DBGINDENT(), ""))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  166|  1.26k|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  156|  1.26k|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  149|  1.26k|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  157|  1.26k|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  181|  1.26k|        debugmsg("dumph_" token,x); \
  |  |  |  |  182|  1.26k|        if (debug_is_token_registered("dumpx" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  217|  2.53k|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (182:13): [True: 1.26k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  183|  1.26k|            debug_is_token_registered("dumpv" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  217|  1.26k|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  184|  1.26k|            (debug_is_token_registered("dumpx_" token) != SNMPERR_SUCCESS &&  \
  |  |  |  |  ------------------
  |  |  |  |  |  |  217|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (184:14): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  185|  1.26k|             debug_is_token_registered("dumpv_" token) != SNMPERR_SUCCESS)) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |  217|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (185:14): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  186|  1.26k|            debugmsg("dumph_" token,"\n"); \
  |  |  |  |  187|  1.26k|        } else { \
  |  |  |  |  188|      0|            debugmsg("dumph_" token,"  "); \
  |  |  |  |  189|      0|        } \
  |  |  |  |  190|  1.26k|        __DBGINDENTMORE()
  |  |  |  |  ------------------
  |  |  |  |  |  |  175|  1.26k|#define __DBGINDENTMORE()  debug_indent_add(2)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (81:55): [Folded - Ignored]
  |  |  ------------------
  ------------------
  140|  1.26k|    data = asn_parse_string(data, length, &type, psid, slen);
  141|  1.26k|    DEBUGINDENTLESS();
  ------------------
  |  |   77|  1.26k|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  146|  1.26k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 1.26k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  176|  1.26k|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (77:74): [Folded - Ignored]
  |  |  ------------------
  ------------------
  142|  1.26k|    if (data == NULL) {
  ------------------
  |  Branch (142:9): [True: 318, False: 951]
  ------------------
  143|    318|        ERROR_MSG("bad parse of community");
  ------------------
  |  |  190|    318|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
  144|    318|        return NULL;
  145|    318|    }
  146|    951|    psid[SNMP_MIN(*slen, origlen - 1)] = '\0';
  ------------------
  |  |  111|    951|#define SNMP_MIN(a,b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (111:24): [True: 4, False: 947]
  |  |  ------------------
  ------------------
  147|    951|    return (u_char *) data;
  148|       |
  149|  1.26k|}                               /* end snmp_comstr_parse() */

snmp_set_var_objid:
  688|    448|{
  689|    448|    size_t          len = sizeof(oid) * name_length;
  690|       |
  691|    448|    if (vp->name != vp->name_loc && vp->name != NULL) {
  ------------------
  |  Branch (691:9): [True: 448, False: 0]
  |  Branch (691:37): [True: 0, False: 448]
  ------------------
  692|       |        /*
  693|       |         * Probably previously-allocated "big storage".  Better free it
  694|       |         * else memory leaks possible.  
  695|       |         */
  696|      0|        free(vp->name);
  697|      0|    }
  698|       |
  699|       |    /*
  700|       |     * use built-in storage for smaller values 
  701|       |     */
  702|    448|    if (len <= sizeof(vp->name_loc)) {
  ------------------
  |  Branch (702:9): [True: 448, False: 0]
  ------------------
  703|    448|        vp->name = vp->name_loc;
  704|    448|    } else {
  705|      0|        vp->name = (oid *) malloc(len);
  706|      0|        if (!vp->name)
  ------------------
  |  Branch (706:13): [True: 0, False: 0]
  ------------------
  707|      0|            return 1;
  708|      0|    }
  709|    448|    if (objid)
  ------------------
  |  Branch (709:9): [True: 448, False: 0]
  ------------------
  710|    448|        memmove(vp->name, objid, len);
  711|    448|    vp->name_length = name_length;
  712|    448|    return 0;
  713|    448|}

debug_indent_get:
   77|  26.7k|{
   78|  26.7k|    return debugindent;
   79|  26.7k|}
debug_indent_add:
   97|  14.0k|{
   98|  14.0k|    if (-debugindent <= amount && amount <= INT_MAX - debugindent)
  ------------------
  |  Branch (98:9): [True: 13.6k, False: 382]
  |  Branch (98:35): [True: 13.6k, False: 0]
  ------------------
   99|  13.6k|	debugindent += amount;
  100|  14.0k|    netsnmp_assert( debugindent >= 0 ); /* no negative indents */
  ------------------
  |  |   47|  14.0k|#      define netsnmp_assert(x)  do { \
  |  |   48|  14.0k|              if ( x ) \
  |  |  ------------------
  |  |  |  Branch (48:20): [True: 14.0k, False: 0]
  |  |  ------------------
  |  |   49|  14.0k|                 ; \
  |  |   50|  14.0k|              else \
  |  |   51|  14.0k|                 snmp_log(LOG_ERR, \
  |  |   52|      0|                          "netsnmp_assert %s failed %s:%d" NETSNMP_FUNC_FMT, \
  |  |  ------------------
  |  |  |  |   40|      0|#          define NETSNMP_FUNC_FMT " %s()\n"
  |  |  ------------------
  |  |   53|      0|                          __STRING(x),__FILE__,__LINE__, \
  |  |   54|      0|                          NETSNMP_FUNC_PARAM); \
  |  |  ------------------
  |  |  |  |   41|      0|#          define NETSNMP_FUNC_PARAM NETSNMP_FUNCTION
  |  |  |  |  ------------------
  |  |  |  |  |  | 1681|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|  14.0k|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded - Ignored]
  |  |  ------------------
  ------------------
  101|  14.0k|}
debug_indent_reset:
  108|  1.74k|{
  109|  1.74k|    if (debugindent != 0)
  ------------------
  |  Branch (109:9): [True: 1.72k, False: 16]
  ------------------
  110|  1.72k|        DEBUGMSGTL(("dump_indent","indent reset from %d\n", debugindent));
  ------------------
  |  |   68|  1.72k|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|  1.72k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 1.72k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|  1.72k|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|  1.72k|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|  1.72k|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|  1.72k|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
  111|  1.74k|    debugindent = 0;
  112|  1.74k|}
debug_register_tokens:
  184|  1.74k|{
  185|  1.74k|    char           *newp, *cp;
  186|  1.74k|    char           *st = NULL;
  187|  1.74k|    int             status;
  188|       |
  189|  1.74k|    if (tokens == NULL || *tokens == 0)
  ------------------
  |  Branch (189:9): [True: 0, False: 1.74k]
  |  Branch (189:27): [True: 0, False: 1.74k]
  ------------------
  190|      0|        return;
  191|       |
  192|  1.74k|    newp = strdup(tokens);      /* strtok_r messes it up */
  193|  1.74k|    if (!newp)
  ------------------
  |  Branch (193:9): [True: 0, False: 1.74k]
  ------------------
  194|      0|        return;
  195|  1.74k|    cp = strtok_r(newp, DEBUG_TOKEN_DELIMITER, &st);
  ------------------
  |  |  228|  1.74k|#define DEBUG_TOKEN_DELIMITER ","
  ------------------
  196|  3.49k|    while (cp) {
  ------------------
  |  Branch (196:12): [True: 1.74k, False: 1.74k]
  ------------------
  197|  1.74k|        if (strlen(cp) < MAX_DEBUG_TOKEN_LEN) {
  ------------------
  |  |  227|  1.74k|#define MAX_DEBUG_TOKEN_LEN 128
  ------------------
  |  Branch (197:13): [True: 1.74k, False: 0]
  ------------------
  198|  1.74k|            if (strcasecmp(cp, DEBUG_ALWAYS_TOKEN) == 0) {
  ------------------
  |  |  229|  1.74k|#define DEBUG_ALWAYS_TOKEN "all"
  ------------------
  |  Branch (198:17): [True: 1.74k, False: 0]
  ------------------
  199|  1.74k|                debug_print_everything = 1;
  200|  1.74k|            } else if (debug_num_tokens < MAX_DEBUG_TOKENS) {
  ------------------
  |  |  226|      0|#define MAX_DEBUG_TOKENS 256
  ------------------
  |  Branch (200:24): [True: 0, False: 0]
  ------------------
  201|      0|                if ('-' == *cp) {
  ------------------
  |  Branch (201:21): [True: 0, False: 0]
  ------------------
  202|      0|                    ++cp;
  203|      0|                    status = SNMP_DEBUG_DISABLED;
  ------------------
  |  |   53|      0|#define SNMP_DEBUG_DISABLED           0
  ------------------
  204|      0|                }
  205|      0|                else
  206|      0|                    status = SNMP_DEBUG_ACTIVE;
  ------------------
  |  |   54|      0|#define SNMP_DEBUG_ACTIVE             1
  ------------------
  207|      0|                dbg_tokens[debug_num_tokens].token_name = strdup(cp);
  208|      0|                dbg_tokens[debug_num_tokens++].enabled  = status;
  209|      0|                snmp_log(LOG_NOTICE, "registered debug token %s, %d\n", cp, status);
  210|      0|            } else {
  211|      0|                snmp_log(LOG_NOTICE, "Unable to register debug token %s\n", cp);
  212|      0|            }
  213|  1.74k|        } else {
  214|      0|            snmp_log(LOG_NOTICE, "Debug token %s over length\n", cp);
  215|      0|        }
  216|  1.74k|        cp = strtok_r(NULL, DEBUG_TOKEN_DELIMITER, &st);
  ------------------
  |  |  228|  1.74k|#define DEBUG_TOKEN_DELIMITER ","
  ------------------
  217|  1.74k|    }
  218|  1.74k|    free(newp);
  219|  1.74k|}
debug_is_token_registered:
  299|  6.30M|{
  300|  6.30M|    int             i, rc;
  301|       |
  302|       |    /*
  303|       |     * debugging flag is on or off
  304|       |     */
  305|  6.30M|    if (!dodebug)
  ------------------
  |  Branch (305:9): [True: 0, False: 6.30M]
  ------------------
  306|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  218|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  307|       |
  308|  6.30M|    if (debug_num_tokens == 0 || debug_print_everything) {
  ------------------
  |  Branch (308:9): [True: 6.30M, False: 0]
  |  Branch (308:34): [True: 0, False: 0]
  ------------------
  309|       |        /*
  310|       |         * no tokens specified, print everything
  311|       |         */
  312|  6.30M|        return SNMPERR_SUCCESS;
  ------------------
  |  |  217|  6.30M|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  313|  6.30M|    }
  314|      0|    else
  315|      0|        rc = SNMPERR_GENERR; /* ! found = err */
  ------------------
  |  |  218|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  316|       |
  317|      0|    for (i = 0; i < debug_num_tokens; i++) {
  ------------------
  |  Branch (317:17): [True: 0, False: 0]
  ------------------
  318|      0|        if (SNMP_DEBUG_DISABLED == dbg_tokens[i].enabled)
  ------------------
  |  |   53|      0|#define SNMP_DEBUG_DISABLED           0
  ------------------
  |  Branch (318:13): [True: 0, False: 0]
  ------------------
  319|      0|            continue;
  320|      0|        if (dbg_tokens[i].token_name &&
  ------------------
  |  Branch (320:13): [True: 0, False: 0]
  ------------------
  321|      0|            strncmp(dbg_tokens[i].token_name, token,
  ------------------
  |  Branch (321:13): [True: 0, False: 0]
  ------------------
  322|      0|                    strlen(dbg_tokens[i].token_name)) == 0) {
  323|      0|            if (SNMP_DEBUG_ACTIVE == dbg_tokens[i].enabled)
  ------------------
  |  |   54|      0|#define SNMP_DEBUG_ACTIVE             1
  ------------------
  |  Branch (323:17): [True: 0, False: 0]
  ------------------
  324|      0|                return SNMPERR_SUCCESS; /* active */
  ------------------
  |  |  217|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  325|      0|            else
  326|      0|                return SNMPERR_GENERR; /* excluded */
  ------------------
  |  |  218|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  327|      0|        }
  328|      0|    }
  329|      0|    return rc;
  330|      0|}
debugmsg:
  334|  6.29M|{
  335|  6.29M|    if (debug_is_token_registered(token) == SNMPERR_SUCCESS) {
  ------------------
  |  |  217|  6.29M|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  |  Branch (335:9): [True: 6.29M, False: 0]
  ------------------
  336|  6.29M|	va_list         debugargs;
  337|       |
  338|  6.29M|	va_start(debugargs, format);
  339|  6.29M|	snmp_vlog(debug_log_level, format, debugargs);
  340|  6.29M|	va_end(debugargs);
  341|  6.29M|    }
  342|  6.29M|}
debugmsg_oid:
  346|    682|{
  347|    682|    u_char         *buf = NULL;
  348|    682|    size_t          buf_len = 0, out_len = 0;
  349|       |
  350|    682|    if (sprint_realloc_objid(&buf, &buf_len, &out_len, 1, theoid, len)) {
  ------------------
  |  Branch (350:9): [True: 682, False: 0]
  ------------------
  351|    682|        if (buf != NULL) {
  ------------------
  |  Branch (351:13): [True: 682, False: 0]
  ------------------
  352|    682|            debugmsg(token, "%s", buf);
  353|    682|        }
  354|    682|    } else {
  355|      0|        if (buf != NULL) {
  ------------------
  |  Branch (355:13): [True: 0, False: 0]
  ------------------
  356|      0|            debugmsg(token, "%s [TRUNCATED]", buf);
  357|      0|        }
  358|      0|    }
  359|       |
  360|    682|    if (buf != NULL) {
  ------------------
  |  Branch (360:9): [True: 682, False: 0]
  ------------------
  361|    682|        free(buf);
  362|    682|    }
  363|    682|}
debugmsg_hex:
  455|  4.88k|{
  456|  4.88k|    u_char         *buf = NULL;
  457|  4.88k|    size_t          buf_len = 0, out_len = 0;
  458|       |
  459|  4.88k|    if (sprint_realloc_hexstring
  ------------------
  |  Branch (459:9): [True: 4.88k, False: 0]
  ------------------
  460|  4.88k|        (&buf, &buf_len, &out_len, 1, thedata, len)) {
  461|  4.88k|        if (buf != NULL) {
  ------------------
  |  Branch (461:13): [True: 4.88k, False: 0]
  ------------------
  462|  4.88k|            debugmsg(token, "%s", buf);
  463|  4.88k|        }
  464|  4.88k|    } else {
  465|      0|        if (buf != NULL) {
  ------------------
  |  Branch (465:13): [True: 0, False: 0]
  ------------------
  466|      0|            debugmsg(token, "%s [TRUNCATED]", buf);
  467|      0|        }
  468|      0|    }
  469|       |
  470|  4.88k|    if (buf != NULL) {
  ------------------
  |  Branch (470:9): [True: 4.88k, False: 0]
  ------------------
  471|  4.88k|        free(buf);
  472|  4.88k|    }
  473|  4.88k|}
debugmsgtoken:
  517|  3.12M|{
  518|  3.12M|    va_list         debugargs;
  519|       |
  520|  3.12M|    va_start(debugargs, format);
  521|  3.12M|    debugmsg(token, "%s: ", token);
  522|  3.12M|    va_end(debugargs);
  523|  3.12M|}
debug_combo_nc:
  527|  1.74k|{
  528|  1.74k|    va_list         debugargs;
  529|       |
  530|  1.74k|    va_start(debugargs, format);
  531|  1.74k|    snmp_log(debug_log_level, "%s: ", token);
  532|  1.74k|    snmp_vlog(debug_log_level, format, debugargs);
  533|  1.74k|    va_end(debugargs);
  534|  1.74k|}
snmp_set_do_debugging:
  541|  1.74k|{
  542|  1.74k|    dodebug = val;
  543|  1.74k|}
snmp_get_do_debugging:
  547|  1.58M|{
  548|  1.58M|    return dodebug;
  549|  1.58M|}
snmp_debug_init:
  718|      1|{
  719|       |#ifdef HAVE_WOLFSSL_WOLFCRYPT_LOGGING_H
  720|       |    wolfSSL_Debugging_ON();
  721|       |    wolfSSL_SetLoggingCb(snmp_log_wolfssl_msg);
  722|       |#endif
  723|       |
  724|      1|    register_prenetsnmp_mib_handler("snmp", "doDebugging",
  725|      1|                                    debug_config_turn_on_debugging, NULL,
  726|      1|                                    "(1|0)");
  727|      1|    register_prenetsnmp_mib_handler("snmp", "debugTokens",
  728|      1|                                    debug_config_register_tokens, NULL,
  729|      1|                                    "token[,token...]");
  730|      1|#ifndef NETSNMP_DISABLE_DYNAMIC_LOG_LEVEL
  731|      1|    register_prenetsnmp_mib_handler("snmp", "debugLogLevel",
  732|      1|                                    debug_config_debug_log_level, NULL,
  733|      1|                                    "(emerg|alert|crit|err|warning|notice|info|debug)");
  734|      1|#endif /* NETSNMP_DISABLE_DYNAMIC_LOG_LEVEL */
  735|      1|}

init_snmp_enum:
   54|      1|{
   55|      1|    int             i;
   56|       |
   57|      1|    if (NULL != snmp_enum_lists)
  ------------------
  |  Branch (57:9): [True: 0, False: 1]
  ------------------
   58|      0|        return SE_OK;
  ------------------
  |  |   42|      0|#define SE_OK            0
  ------------------
   59|       |
   60|      1|    snmp_enum_lists = (struct snmp_enum_list ***)
   61|      1|        calloc(1, sizeof(struct snmp_enum_list **) * SE_MAX_IDS);
  ------------------
  |  |   21|      1|#define SE_MAX_IDS 5
  ------------------
   62|      1|    if (!snmp_enum_lists)
  ------------------
  |  Branch (62:9): [True: 0, False: 1]
  ------------------
   63|      0|        return SE_NOMEM;
  ------------------
  |  |   43|      0|#define SE_NOMEM         1
  ------------------
   64|      1|    current_maj_num = SE_MAX_IDS;
  ------------------
  |  |   21|      1|#define SE_MAX_IDS 5
  ------------------
   65|       |
   66|      6|    for (i = 0; i < SE_MAX_IDS; i++) {
  ------------------
  |  |   21|      6|#define SE_MAX_IDS 5
  ------------------
  |  Branch (66:17): [True: 5, False: 1]
  ------------------
   67|      5|        if (!snmp_enum_lists[i])
  ------------------
  |  Branch (67:13): [True: 5, False: 0]
  ------------------
   68|      5|            snmp_enum_lists[i] = (struct snmp_enum_list **)
   69|      5|                calloc(1, sizeof(struct snmp_enum_list *) * SE_MAX_SUBIDS);
  ------------------
  |  |   22|      5|#define SE_MAX_SUBIDS 32        /* needs to be a multiple of 8 */
  ------------------
   70|      5|        if (!snmp_enum_lists[i])
  ------------------
  |  Branch (70:13): [True: 0, False: 5]
  ------------------
   71|      0|            return SE_NOMEM;
  ------------------
  |  |   43|      0|#define SE_NOMEM         1
  ------------------
   72|      5|    }
   73|      1|    current_min_num = SE_MAX_SUBIDS;
  ------------------
  |  |   22|      1|#define SE_MAX_SUBIDS 32        /* needs to be a multiple of 8 */
  ------------------
   74|       |
   75|      1|    register_const_config_handler(type, "enum", se_read_conf, NULL, NULL);
   76|      1|    return SE_OK;
  ------------------
  |  |   42|      1|#define SE_OK            0
  ------------------
   77|      1|}
se_add_pair_to_list:
  289|     28|{
  290|     28|    struct snmp_enum_list *lastnode = NULL, *tmp;
  291|       |
  292|     28|    if (!list)
  ------------------
  |  Branch (292:9): [True: 0, False: 28]
  ------------------
  293|      0|        return SE_DNE;
  ------------------
  |  |   45|      0|#define SE_DNE           -2
  ------------------
  294|       |
  295|     28|    tmp = *list;
  296|     84|    while (tmp) {
  ------------------
  |  Branch (296:12): [True: 60, False: 24]
  ------------------
  297|     60|        if (tmp->value == value) {
  ------------------
  |  Branch (297:13): [True: 4, False: 56]
  ------------------
  298|      4|            free(label);
  299|      4|            return (SE_ALREADY_THERE);
  ------------------
  |  |   44|      4|#define SE_ALREADY_THERE 2
  ------------------
  300|      4|        }
  301|     56|        lastnode = tmp;
  302|     56|        tmp = tmp->next;
  303|     56|    }
  304|       |
  305|     24|    if (lastnode) {
  ------------------
  |  Branch (305:9): [True: 19, False: 5]
  ------------------
  306|     19|        lastnode->next = SNMP_MALLOC_STRUCT(snmp_enum_list);
  ------------------
  |  |   69|     19|#define SNMP_MALLOC_STRUCT(s)   (struct s *) calloc(1, sizeof(struct s))
  ------------------
  307|     19|        lastnode = lastnode->next;
  308|     19|    } else {
  309|      5|        (*list) = SNMP_MALLOC_STRUCT(snmp_enum_list);
  ------------------
  |  |   69|      5|#define SNMP_MALLOC_STRUCT(s)   (struct s *) calloc(1, sizeof(struct s))
  ------------------
  310|      5|        lastnode = (*list);
  311|      5|    }
  312|     24|    if (!lastnode) {
  ------------------
  |  Branch (312:9): [True: 0, False: 24]
  ------------------
  313|      0|        free(label);
  314|      0|        return (SE_NOMEM);
  ------------------
  |  |   43|      0|#define SE_NOMEM         1
  ------------------
  315|      0|    }
  316|     24|    lastnode->label = label;
  317|     24|    lastnode->value = value;
  318|     24|    lastnode->next = NULL;
  319|     24|    return (SE_OK);
  ------------------
  |  |   42|     24|#define SE_OK            0
  ------------------
  320|     24|}
se_find_slist:
  352|     28|{
  353|     28|    struct snmp_enum_list **ptr = se_find_slist_ptr(listname);
  354|     28|    return ptr ? *ptr : NULL;
  ------------------
  |  Branch (354:12): [True: 23, False: 5]
  ------------------
  355|     28|}
se_add_pair_to_slist:
  385|     28|{
  386|     28|    struct snmp_enum_list *list = se_find_slist(listname);
  387|     28|    int             created = (list) ? 1 : 0;
  ------------------
  |  Branch (387:31): [True: 23, False: 5]
  ------------------
  388|     28|    int             ret = se_add_pair_to_list(&list, label, value);
  389|       |
  390|     28|    if (!created) {
  ------------------
  |  Branch (390:9): [True: 5, False: 23]
  ------------------
  391|      5|        struct snmp_enum_list_str *sptr =
  392|      5|            SNMP_MALLOC_STRUCT(snmp_enum_list_str);
  ------------------
  |  |   69|      5|#define SNMP_MALLOC_STRUCT(s)   (struct s *) calloc(1, sizeof(struct s))
  ------------------
  393|      5|        if (!sptr) {
  ------------------
  |  Branch (393:13): [True: 0, False: 5]
  ------------------
  394|      0|            free_enum_list(list);
  395|      0|            return SE_NOMEM;
  ------------------
  |  |   43|      0|#define SE_NOMEM         1
  ------------------
  396|      0|        }
  397|      5|        sptr->next = sliststorage;
  398|      5|        sptr->name = strdup(listname);
  399|      5|        if (!sptr->name) {
  ------------------
  |  Branch (399:13): [True: 0, False: 5]
  ------------------
  400|      0|            free(sptr);
  401|      0|            free_enum_list(list);
  402|      0|            return SE_NOMEM;
  ------------------
  |  |   43|      0|#define SE_NOMEM         1
  ------------------
  403|      0|        }
  404|      5|        sptr->list = list;
  405|      5|        sliststorage = sptr;
  406|      5|    }
  407|     28|    return ret;
  408|     28|}
snmp_enum.c:se_find_slist_ptr:
  338|     28|{
  339|     28|    struct snmp_enum_list_str *sptr;
  340|     28|    if (!listname)
  ------------------
  |  Branch (340:9): [True: 0, False: 28]
  ------------------
  341|      0|        return NULL;
  342|       |
  343|     38|    for (sptr = sliststorage; sptr != NULL; sptr = sptr->next)
  ------------------
  |  Branch (343:31): [True: 33, False: 5]
  ------------------
  344|     33|        if (sptr->name && strcmp(sptr->name, listname) == 0)
  ------------------
  |  Branch (344:13): [True: 33, False: 0]
  |  Branch (344:27): [True: 23, False: 10]
  ------------------
  345|     23|            return &sptr->list;
  346|       |
  347|      5|    return NULL;
  348|     28|}

init_snmp_logging:
  168|      1|{
  169|      1|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "logTimestamp", 
  ------------------
  |  |   72|      1|#define ASN_BOOLEAN	    0x01U
  ------------------
  170|      1|			 NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_LOG_TIMESTAMP);
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              			 NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_LOG_TIMESTAMP);
  ------------------
  |  |   64|      1|#define NETSNMP_DS_LIB_LOG_TIMESTAMP       5
  ------------------
  171|      1|    register_prenetsnmp_mib_handler("snmp", "logOption",
  172|      1|                                    parse_config_logOption, NULL, "string");
  173|       |
  174|      1|}
netsnmp_set_line_buffering:
  187|      1|{
  188|       |#if defined(WIN32)
  189|       |    /*
  190|       |     * According to MSDN, the Microsoft Visual Studio C runtime library does
  191|       |     * not support line buffering, so turn off buffering completely.
  192|       |     * See also http://msdn.microsoft.com/en-us/library/86cebhfs(VS.71).aspx.
  193|       |     */
  194|       |    setvbuf(stream, NULL, _IONBF, BUFSIZ);
  195|       |#elif defined(HAVE_SETLINEBUF)
  196|       |    /* setlinefunction() is a function from the BSD Unix API. */
  197|       |    setlinebuf(stream);
  198|       |#else
  199|       |    /* See also the C89 or C99 standard for more information about setvbuf(). */
  200|      1|    setvbuf(stream, NULL, _IOLBF, BUFSIZ);
  201|      1|#endif
  202|      1|}
log_handler_stdouterr:
 1093|  6.29M|{
 1094|  6.29M|    static int      newline = 1;	 /* MTCRITICAL_RESOURCE */
 1095|  6.29M|    const char     *newline_ptr;
 1096|  6.29M|    char            sbuf[40];
 1097|       |
 1098|  6.29M|    if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|  6.29M|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (1098:9): [True: 0, False: 6.29M]
  ------------------
 1099|  6.29M|                               NETSNMP_DS_LIB_LOG_TIMESTAMP) && newline) {
  ------------------
  |  |   64|  6.29M|#define NETSNMP_DS_LIB_LOG_TIMESTAMP       5
  ------------------
  |  Branch (1099:65): [True: 0, False: 0]
  ------------------
 1100|      0|        sprintf_stamp(NULL, sbuf);
 1101|  6.29M|    } else {
 1102|  6.29M|        strcpy(sbuf, "");
 1103|  6.29M|    }
 1104|       |    /*
 1105|       |     * Remember whether or not the current line ends with a newline for the
 1106|       |     * next call of log_handler_stdouterr().
 1107|       |     */
 1108|  6.29M|    newline_ptr = strrchr(str, '\n');
 1109|  6.29M|    newline = newline_ptr && newline_ptr[1] == 0;
  ------------------
  |  Branch (1109:15): [True: 3.13M, False: 3.15M]
  |  Branch (1109:30): [True: 3.13M, False: 172]
  ------------------
 1110|       |
 1111|  6.29M|    if (logh->imagic)
  ------------------
  |  Branch (1111:9): [True: 0, False: 6.29M]
  ------------------
 1112|      0|       printf(         "%s%s", sbuf, str);
 1113|  6.29M|    else
 1114|  6.29M|       fprintf(stderr, "%s%s", sbuf, str);
 1115|       |
 1116|  6.29M|    return 1;
 1117|  6.29M|}
snmp_log_string:
 1284|  6.29M|{
 1285|  6.29M|#ifndef NETSNMP_FEATURE_REMOVE_LOGGING_STDIO
 1286|  6.29M|    static int stderr_enabled = 0;
 1287|  6.29M|    static netsnmp_log_handler lh = { 1, 0, 0, 0, "stderr",
 1288|  6.29M|                                      log_handler_stdouterr, 0, NULL,  NULL,
 1289|  6.29M|                                      NULL };
 1290|  6.29M|#endif /* NETSNMP_FEATURE_REMOVE_LOGGING_STDIO */
 1291|  6.29M|    netsnmp_log_handler *logh;
 1292|       |
 1293|       |    /*
 1294|       |     * We've got to be able to log messages *somewhere*!
 1295|       |     * If you don't want stderr logging, then enable something else.
 1296|       |     */
 1297|  6.29M|    if (0 == logh_enabled) {
  ------------------
  |  Branch (1297:9): [True: 6.29M, False: 0]
  ------------------
 1298|  6.29M|#ifndef NETSNMP_FEATURE_REMOVE_LOGGING_STDIO
 1299|  6.29M|        if (!stderr_enabled) {
  ------------------
  |  Branch (1299:13): [True: 1, False: 6.29M]
  ------------------
 1300|      1|            ++stderr_enabled;
 1301|      1|            netsnmp_set_line_buffering(stderr);
 1302|      1|        }
 1303|  6.29M|        log_handler_stdouterr( &lh, priority, str );
 1304|  6.29M|#endif /* NETSNMP_FEATURE_REMOVE_LOGGING_STDIO */
 1305|       |
 1306|  6.29M|        return;
 1307|  6.29M|    }
 1308|      0|#ifndef NETSNMP_FEATURE_REMOVE_LOGGING_STDIO
 1309|      0|    else if (stderr_enabled) {
  ------------------
  |  Branch (1309:14): [True: 0, False: 0]
  ------------------
 1310|      0|        stderr_enabled = 0;
 1311|      0|        log_handler_stdouterr( &lh, LOG_INFO,
 1312|      0|                               "Log handling defined - disabling stderr\n" );
 1313|      0|    }
 1314|      0|#endif /* NETSNMP_FEATURE_REMOVE_LOGGING_STDIO */
 1315|       |        
 1316|       |
 1317|       |    /*
 1318|       |     * Start at the given priority, and work "upwards"....
 1319|       |     */
 1320|      0|    if (priority > LOG_DEBUG)
  ------------------
  |  Branch (1320:9): [True: 0, False: 0]
  ------------------
 1321|      0|        priority = LOG_DEBUG;
 1322|      0|    logh = logh_priorities[priority];
 1323|      0|    for ( ; logh; logh = logh->next ) {
  ------------------
  |  Branch (1323:13): [True: 0, False: 0]
  ------------------
 1324|       |        /*
 1325|       |         * ... but skipping any handlers with a "maximum priority"
 1326|       |         *     that we have already exceeded. And don't forget to
 1327|       |         *     ensure this logging is turned on (see snmp_disable_stderrlog
 1328|       |         *     and its cohorts).
 1329|       |         */
 1330|      0|        if (logh->enabled && priority <= logh->pri_max)
  ------------------
  |  Branch (1330:13): [True: 0, False: 0]
  |  Branch (1330:30): [True: 0, False: 0]
  ------------------
 1331|      0|            logh->handler( logh, priority, str );
 1332|      0|    }
 1333|      0|}
snmp_vlog:
 1371|  6.29M|{
 1372|  6.29M|    char           *buffer = NULL;
 1373|  6.29M|    int             length;
 1374|       |
 1375|  6.29M|    length = vasprintf(&buffer, format, ap);
 1376|  6.29M|    if (length < 0) {
  ------------------
  |  Branch (1376:9): [True: 0, False: 6.29M]
  ------------------
 1377|      0|        snmp_log_string(LOG_ERR, "Could not format log-string\n");
 1378|      0|        return -1;
 1379|      0|    }
 1380|       |
 1381|  6.29M|    snmp_log_string(priority, buffer);
 1382|  6.29M|    free(buffer);
 1383|  6.29M|    return 0;
 1384|  6.29M|}
snmp_log:
 1395|  1.80k|{
 1396|  1.80k|    va_list         ap;
 1397|  1.80k|    int             ret;
 1398|  1.80k|    va_start(ap, format);
 1399|  1.80k|    ret = snmp_vlog(priority, format, ap);
 1400|  1.80k|    va_end(ap);
 1401|  1.80k|    return (ret);
 1402|  1.80k|}

netsnmp_init_openssl:
  114|      2|void netsnmp_init_openssl(void) {
  115|       |
  116|       |    /* avoid duplicate calls */
  117|      2|    if (have_started_already)
  ------------------
  |  Branch (117:9): [True: 1, False: 1]
  ------------------
  118|      1|        return;
  119|      1|    have_started_already = 1;
  120|       |
  121|      1|    DEBUGMSGTL(("snmp_openssl", "initializing\n"));
  ------------------
  |  |   68|      1|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
  122|       |
  123|       |    /* Initializing OpenSSL */
  124|      1|#ifdef HAVE_SSL_LIBRARY_INIT
  125|      1|    SSL_library_init();
  126|      1|#endif
  127|      1|#ifdef HAVE_SSL_LOAD_ERROR_STRINGS
  128|      1|    SSL_load_error_strings();
  129|      1|#endif
  130|       |#ifdef HAVE_ERR_LOAD_BIO_STRINGS
  131|       |    ERR_load_BIO_strings();
  132|       |#endif
  133|      1|#ifdef HAVE_OPENSSL_ADD_ALL_ALGORITHMS
  134|      1|    OpenSSL_add_all_algorithms();
  135|      1|#endif
  136|      1|}

netsnmp_parse_args:
  203|  1.74k|{
  204|  1.74k|    int             arg, ret, sp = 0;
  205|  1.74k|    const char     *cp;
  206|  1.74k|    char           *Apsz = NULL;
  207|  1.74k|    char           *Xpsz = NULL;
  208|  1.74k|    char           *Cpsz = NULL;
  209|  1.74k|    char            Opts[BUF_SIZE];
  210|  1.74k|    int             zero_sensitive = !( flags & NETSNMP_PARSE_ARGS_NOZERO );
  ------------------
  |  |   21|  1.74k|#define NETSNMP_PARSE_ARGS_NOZERO       0x0002
  ------------------
  211|  1.74k|    char           *backup_NETSNMP_DS_LIB_OUTPUT_PRECISION = NULL;
  212|       |
  213|       |    /*
  214|       |     * initialize session to default values 
  215|       |     */
  216|  1.74k|    snmp_sess_init(session);
  217|  1.74k|    strcpy(Opts, "Y:VhHm:M:O:I:P:D:dv:r:t:c:Z:e:E:n:u:l:x:X:a:A:p:T:-:3:L:s:");
  218|  1.74k|    if (localOpts) {
  ------------------
  |  Branch (218:9): [True: 1.74k, False: 0]
  ------------------
  219|  1.74k|        if (strlen(localOpts) + strlen(Opts) >= sizeof(Opts)) {
  ------------------
  |  Branch (219:13): [True: 0, False: 1.74k]
  ------------------
  220|      0|            snmp_log(LOG_ERR, "Too many localOpts in snmp_parse_args()\n");
  221|      0|            return -1;
  222|      0|        }
  223|  1.74k|        strcat(Opts, localOpts);
  224|  1.74k|    }
  225|       |
  226|       |    /*
  227|       |     * get the options 
  228|       |     */
  229|  1.74k|    DEBUGMSGTL(("snmp_parse_args", "starting: %d/%d\n", optind, argc));
  ------------------
  |  |   68|  1.74k|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|  1.74k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 1.74k, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|  1.74k|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|  1.74k|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|  1.74k|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|  1.74k|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
  230|  6.98k|    for (arg = 0; arg < argc; arg++) {
  ------------------
  |  Branch (230:19): [True: 5.24k, False: 1.74k]
  ------------------
  231|  5.24k|        DEBUGMSGTL(("snmp_parse_args", " arg %d = %s\n", arg, argv[arg]));
  ------------------
  |  |   68|  5.24k|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|  5.24k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 5.23k, False: 3]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|  5.23k|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|  5.23k|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|  5.23k|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|  5.23k|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
  232|  5.24k|    }
  233|       |
  234|  1.74k|    optind = 1;
  235|  3.49k|    while (optind < argc && (arg = getopt(argc, argv, Opts)) != EOF) {
  ------------------
  |  Branch (235:12): [True: 3.49k, False: 0]
  |  Branch (235:29): [True: 1.74k, False: 1.74k]
  ------------------
  236|  1.74k|        DEBUGMSGTL(("snmp_parse_args", "handling (#%d): %c (optarg %s) (sp %d)\n",
  ------------------
  |  |   68|  1.74k|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|  1.74k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 1.74k, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|  1.74k|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|  1.74k|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|  1.74k|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|  1.74k|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
  237|  1.74k|                    optind, arg, optarg, sp));
  238|  1.74k|        switch (arg) {
  239|      0|        case '-':
  ------------------
  |  Branch (239:9): [True: 0, False: 1.74k]
  ------------------
  240|      0|            if (strcasecmp(optarg, "help") == 0) {
  ------------------
  |  Branch (240:17): [True: 0, False: 0]
  ------------------
  241|      0|                ret = NETSNMP_PARSE_ARGS_ERROR_USAGE;
  ------------------
  |  |   37|      0|#define NETSNMP_PARSE_ARGS_ERROR_USAGE   -1
  ------------------
  242|      0|                goto out;
  243|      0|            }
  244|      0|            if (strcasecmp(optarg, "version") == 0) {
  ------------------
  |  Branch (244:17): [True: 0, False: 0]
  ------------------
  245|      0|                fprintf(stderr,"NET-SNMP version: %s\n",netsnmp_get_version());
  246|      0|                ret = NETSNMP_PARSE_ARGS_SUCCESS_EXIT;
  ------------------
  |  |   32|      0|#define NETSNMP_PARSE_ARGS_SUCCESS_EXIT  -2
  ------------------
  247|      0|                goto out;
  248|      0|            }
  249|       |
  250|      0|            handle_long_opt(optarg);
  251|      0|            break;
  252|       |
  253|      0|        case 'V':
  ------------------
  |  Branch (253:9): [True: 0, False: 1.74k]
  ------------------
  254|      0|            fprintf(stderr, "NET-SNMP version: %s\n", netsnmp_get_version());
  255|      0|            ret = NETSNMP_PARSE_ARGS_SUCCESS_EXIT;
  ------------------
  |  |   32|      0|#define NETSNMP_PARSE_ARGS_SUCCESS_EXIT  -2
  ------------------
  256|      0|            goto out;
  257|       |
  258|      0|        case 'h':
  ------------------
  |  Branch (258:9): [True: 0, False: 1.74k]
  ------------------
  259|      0|            ret = NETSNMP_PARSE_ARGS_ERROR_USAGE;
  ------------------
  |  |   37|      0|#define NETSNMP_PARSE_ARGS_ERROR_USAGE   -1
  ------------------
  260|      0|            goto out;
  261|       |
  262|      0|        case 'H':
  ------------------
  |  Branch (262:9): [True: 0, False: 1.74k]
  ------------------
  263|      0|            init_snmp(NETSNMP_APPLICATION_CONFIG_TYPE);
  ------------------
  |  |   22|      0|#define NETSNMP_APPLICATION_CONFIG_TYPE "snmpapp"
  ------------------
  264|      0|            fprintf(stderr, "Configuration directives understood:\n");
  265|      0|            read_config_print_usage("  ");
  266|      0|            ret = NETSNMP_PARSE_ARGS_SUCCESS_EXIT;
  ------------------
  |  |   32|      0|#define NETSNMP_PARSE_ARGS_SUCCESS_EXIT  -2
  ------------------
  267|      0|            goto out;
  268|       |
  269|      0|        case 'Y':
  ------------------
  |  Branch (269:9): [True: 0, False: 1.74k]
  ------------------
  270|      0|            netsnmp_config_remember(optarg);
  271|      0|            break;
  272|       |
  273|      0|#ifndef NETSNMP_DISABLE_MIB_LOADING
  274|      0|        case 'm':
  ------------------
  |  Branch (274:9): [True: 0, False: 1.74k]
  ------------------
  275|      0|            setenv("MIBS", optarg, 1);
  276|      0|            break;
  277|       |
  278|      0|        case 'M':
  ------------------
  |  Branch (278:9): [True: 0, False: 1.74k]
  ------------------
  279|      0|            netsnmp_get_mib_directory(); /* prepare the default directories */
  280|      0|            netsnmp_set_mib_directory(optarg);
  281|      0|            break;
  282|      0|#endif /* NETSNMP_DISABLE_MIB_LOADING */
  283|       |
  284|      0|        case 'O':
  ------------------
  |  Branch (284:9): [True: 0, False: 1.74k]
  ------------------
  285|      0|            cp = snmp_out_options(optarg, argc, argv);
  286|      0|            if (cp != NULL) {
  ------------------
  |  Branch (286:17): [True: 0, False: 0]
  ------------------
  287|      0|                fprintf(stderr, "Unknown output option passed to -O: %c.\n", 
  288|      0|			*cp);
  289|      0|                ret = NETSNMP_PARSE_ARGS_ERROR_USAGE;
  ------------------
  |  |   37|      0|#define NETSNMP_PARSE_ARGS_ERROR_USAGE   -1
  ------------------
  290|      0|                goto out;
  291|      0|            }
  292|      0|            break;
  293|       |
  294|      0|        case 'I':
  ------------------
  |  Branch (294:9): [True: 0, False: 1.74k]
  ------------------
  295|      0|            cp = snmp_in_options(optarg, argc, argv);
  296|      0|            if (cp != NULL) {
  ------------------
  |  Branch (296:17): [True: 0, False: 0]
  ------------------
  297|      0|                fprintf(stderr, "Unknown input option passed to -I: %c.\n",
  298|      0|			*cp);
  299|      0|                ret = NETSNMP_PARSE_ARGS_ERROR_USAGE;
  ------------------
  |  |   37|      0|#define NETSNMP_PARSE_ARGS_ERROR_USAGE   -1
  ------------------
  300|      0|                goto out;
  301|      0|            }
  302|      0|            break;
  303|       |
  304|      0|#ifndef NETSNMP_DISABLE_MIB_LOADING
  305|      0|        case 'P':
  ------------------
  |  Branch (305:9): [True: 0, False: 1.74k]
  ------------------
  306|      0|            cp = snmp_mib_toggle_options(optarg);
  307|      0|            if (cp != NULL) {
  ------------------
  |  Branch (307:17): [True: 0, False: 0]
  ------------------
  308|      0|                fprintf(stderr,
  309|      0|                        "Unknown parsing option passed to -P: %c.\n", *cp);
  310|      0|                ret = NETSNMP_PARSE_ARGS_ERROR_USAGE;
  ------------------
  |  |   37|      0|#define NETSNMP_PARSE_ARGS_ERROR_USAGE   -1
  ------------------
  311|      0|                goto out;
  312|      0|            }
  313|      0|            break;
  314|      0|#endif /* NETSNMP_DISABLE_MIB_LOADING */
  315|       |
  316|  1.74k|        case 'D':
  ------------------
  |  Branch (316:9): [True: 1.74k, False: 0]
  ------------------
  317|       |#ifdef NETSNMP_NO_DEBUGGING
  318|       |            fprintf(stderr, "Debug not configured in\n");
  319|       |            ret = NETSNMP_PARSE_ARGS_ERROR_USAGE;
  320|       |            goto out;
  321|       |#else
  322|  1.74k|            debug_register_tokens(optarg);
  323|  1.74k|            snmp_set_do_debugging(1);
  324|  1.74k|#endif
  325|  1.74k|            break;
  326|       |
  327|      0|        case 'd':
  ------------------
  |  Branch (327:9): [True: 0, False: 1.74k]
  ------------------
  328|      0|            netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|      0|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  329|      0|				   NETSNMP_DS_LIB_DUMP_PACKET, 1);
  ------------------
  |  |   63|      0|#define NETSNMP_DS_LIB_DUMP_PACKET         4
  ------------------
  330|      0|            break;
  331|       |
  332|      0|        case 's':
  ------------------
  |  Branch (332:9): [True: 0, False: 1.74k]
  ------------------
  333|      0|            session->localname = strdup(optarg);
  334|      0|            break;
  335|       |
  336|      0|        case 'v':
  ------------------
  |  Branch (336:9): [True: 0, False: 1.74k]
  ------------------
  337|      0|            session->version = -1;
  338|      0|#ifndef NETSNMP_DISABLE_SNMPV1
  339|      0|            if (!strcmp(optarg, "1")) {
  ------------------
  |  Branch (339:17): [True: 0, False: 0]
  ------------------
  340|      0|                session->version = SNMP_VERSION_1;
  ------------------
  |  |  107|      0|#define SNMP_VERSION_1	   0
  ------------------
  341|      0|            }
  342|      0|#endif
  343|      0|#ifndef NETSNMP_DISABLE_SNMPV2C
  344|      0|            if (!strcasecmp(optarg, "2c")) {
  ------------------
  |  Branch (344:17): [True: 0, False: 0]
  ------------------
  345|      0|                session->version = SNMP_VERSION_2c;
  ------------------
  |  |  110|      0|#define SNMP_VERSION_2c    1
  ------------------
  346|      0|            }
  347|      0|#endif
  348|      0|            if (!strcasecmp(optarg, "3")) {
  ------------------
  |  Branch (348:17): [True: 0, False: 0]
  ------------------
  349|      0|                session->version = SNMP_VERSION_3;
  ------------------
  |  |  113|      0|#define SNMP_VERSION_3     3
  ------------------
  350|      0|            }
  351|      0|            if (session->version == -1) {
  ------------------
  |  Branch (351:17): [True: 0, False: 0]
  ------------------
  352|      0|                fprintf(stderr,
  353|      0|                        "Invalid version specified after -v flag: %s\n",
  354|      0|                        optarg);
  355|      0|                ret = NETSNMP_PARSE_ARGS_ERROR_USAGE;
  ------------------
  |  |   37|      0|#define NETSNMP_PARSE_ARGS_ERROR_USAGE   -1
  ------------------
  356|      0|                goto out;
  357|      0|            }
  358|      0|            break;
  359|       |
  360|      0|        case 'p':
  ------------------
  |  Branch (360:9): [True: 0, False: 1.74k]
  ------------------
  361|      0|            fprintf(stderr, "Warning: -p option is no longer used - ");
  362|      0|            fprintf(stderr, "specify the remote host as HOST:PORT\n");
  363|      0|            ret = NETSNMP_PARSE_ARGS_ERROR_USAGE;
  ------------------
  |  |   37|      0|#define NETSNMP_PARSE_ARGS_ERROR_USAGE   -1
  ------------------
  364|      0|            goto out;
  365|       |
  366|      0|        case 'T':
  ------------------
  |  Branch (366:9): [True: 0, False: 1.74k]
  ------------------
  367|      0|        {
  368|      0|            char leftside[SNMP_MAXBUF_MEDIUM], rightside[SNMP_MAXBUF_MEDIUM];
  369|      0|            char *tmpcp, *tmpopt;
  370|       |            
  371|       |            /* ensure we have a proper argument */
  372|      0|            tmpopt = strdup(optarg);
  373|      0|            tmpcp = strchr(tmpopt, '=');
  374|      0|            if (!tmpcp) {
  ------------------
  |  Branch (374:17): [True: 0, False: 0]
  ------------------
  375|      0|                fprintf(stderr, "-T expects a NAME=VALUE pair.\n");
  376|      0|                free(tmpopt);
  377|      0|                ret = NETSNMP_PARSE_ARGS_ERROR_USAGE;
  ------------------
  |  |   37|      0|#define NETSNMP_PARSE_ARGS_ERROR_USAGE   -1
  ------------------
  378|      0|                goto out;
  379|      0|            }
  380|      0|            *tmpcp++ = '\0';
  381|       |
  382|       |            /* create the transport config container if this is the first */
  383|      0|            if (!session->transport_configuration) {
  ------------------
  |  Branch (383:17): [True: 0, False: 0]
  ------------------
  384|      0|                netsnmp_container_init_list();
  385|      0|                session->transport_configuration =
  386|      0|                    netsnmp_container_find("transport_configuration:fifo");
  387|      0|                if (!session->transport_configuration) {
  ------------------
  |  Branch (387:21): [True: 0, False: 0]
  ------------------
  388|      0|                    fprintf(stderr, "failed to initialize the transport configuration container\n");
  389|      0|                    free(tmpopt);
  390|      0|                    ret = NETSNMP_PARSE_ARGS_ERROR;
  ------------------
  |  |   43|      0|#define NETSNMP_PARSE_ARGS_ERROR         -3
  ------------------
  391|      0|                    goto out;
  392|      0|                }
  393|       |
  394|      0|                session->transport_configuration->compare =
  395|      0|                    (netsnmp_container_compare*)
  396|      0|                    netsnmp_transport_config_compare;
  397|      0|            }
  398|       |
  399|       |            /* set the config */
  400|      0|            strlcpy(leftside, tmpopt, sizeof(leftside));
  401|      0|            strlcpy(rightside, tmpcp, sizeof(rightside));
  402|       |
  403|      0|            CONTAINER_INSERT(session->transport_configuration,
  404|      0|                             netsnmp_transport_create_config(leftside,
  405|      0|                                                             rightside));
  406|      0|            free(tmpopt);
  407|      0|        }
  408|      0|        break;
  409|       |            
  410|      0|        case 't':
  ------------------
  |  Branch (410:9): [True: 0, False: 1.74k]
  ------------------
  411|      0|            session->timeout = (long)(atof(optarg) * 1000000L);
  412|      0|            if (session->timeout <= 0) {
  ------------------
  |  Branch (412:17): [True: 0, False: 0]
  ------------------
  413|      0|                fprintf(stderr, "Invalid timeout in seconds after -t flag.\n");
  414|      0|                ret = NETSNMP_PARSE_ARGS_ERROR_USAGE;
  ------------------
  |  |   37|      0|#define NETSNMP_PARSE_ARGS_ERROR_USAGE   -1
  ------------------
  415|      0|                goto out;
  416|      0|            }
  417|      0|            break;
  418|       |
  419|      0|        case 'r':
  ------------------
  |  Branch (419:9): [True: 0, False: 1.74k]
  ------------------
  420|      0|            session->retries = atoi(optarg);
  421|      0|            if (session->retries < 0 || !isdigit((unsigned char)(optarg[0]))) {
  ------------------
  |  Branch (421:17): [True: 0, False: 0]
  |  Branch (421:41): [True: 0, False: 0]
  ------------------
  422|      0|                fprintf(stderr, "Invalid number of retries after -r flag.\n");
  423|      0|                ret = NETSNMP_PARSE_ARGS_ERROR_USAGE;
  ------------------
  |  |   37|      0|#define NETSNMP_PARSE_ARGS_ERROR_USAGE   -1
  ------------------
  424|      0|                goto out;
  425|      0|            }
  426|      0|            break;
  427|       |
  428|      0|        case 'c':
  ------------------
  |  Branch (428:9): [True: 0, False: 1.74k]
  ------------------
  429|      0|	    if (zero_sensitive) {
  ------------------
  |  Branch (429:10): [True: 0, False: 0]
  ------------------
  430|      0|                SNMP_FREE(Cpsz); /* free any previous value */
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded - Ignored]
  |  |  ------------------
  ------------------
  431|      0|		if ((Cpsz = strdup(optarg)) != NULL) {
  ------------------
  |  Branch (431:7): [True: 0, False: 0]
  ------------------
  432|      0|		    memset(optarg, '\0', strlen(optarg));
  433|      0|		} else {
  434|      0|		    fprintf(stderr, "malloc failure processing -c flag.\n");
  435|      0|		    ret = NETSNMP_PARSE_ARGS_ERROR;
  ------------------
  |  |   43|      0|#define NETSNMP_PARSE_ARGS_ERROR         -3
  ------------------
  436|      0|                    goto out;
  437|      0|		}
  438|      0|	    } else {
  439|      0|		Cpsz = strdup(optarg);
  440|      0|	    }
  441|      0|            break;
  442|       |
  443|      0|        case '3':
  ------------------
  |  Branch (443:9): [True: 0, False: 1.74k]
  ------------------
  444|      0|            if (snmpv3_parse_args(optarg, session, &Apsz, &Xpsz, argc, argv,
  ------------------
  |  Branch (444:17): [True: 0, False: 0]
  ------------------
  445|      0|                                  flags) < 0){
  446|      0|                ret = NETSNMP_PARSE_ARGS_ERROR_USAGE;
  ------------------
  |  |   37|      0|#define NETSNMP_PARSE_ARGS_ERROR_USAGE   -1
  ------------------
  447|      0|                goto out;
  448|      0|            }
  449|      0|            break;
  450|       |
  451|      0|        case 'L':
  ------------------
  |  Branch (451:9): [True: 0, False: 1.74k]
  ------------------
  452|      0|            if (snmp_log_options(optarg, argc, argv) < 0) {
  ------------------
  |  Branch (452:17): [True: 0, False: 0]
  ------------------
  453|      0|                ret = NETSNMP_PARSE_ARGS_ERROR_USAGE;
  ------------------
  |  |   37|      0|#define NETSNMP_PARSE_ARGS_ERROR_USAGE   -1
  ------------------
  454|      0|                goto out;
  455|      0|            }
  456|      0|            break;
  457|       |
  458|      0|#define SNMPV3_CMD_OPTIONS
  459|      0|#ifdef  SNMPV3_CMD_OPTIONS
  460|      0|        case 'Z':
  ------------------
  |  Branch (460:9): [True: 0, False: 1.74k]
  ------------------
  461|      0|        case 'e':
  ------------------
  |  Branch (461:9): [True: 0, False: 1.74k]
  ------------------
  462|      0|        case 'E':
  ------------------
  |  Branch (462:9): [True: 0, False: 1.74k]
  ------------------
  463|      0|        case 'n':
  ------------------
  |  Branch (463:9): [True: 0, False: 1.74k]
  ------------------
  464|      0|        case 'l':
  ------------------
  |  Branch (464:9): [True: 0, False: 1.74k]
  ------------------
  465|      0|        case 'u':
  ------------------
  |  Branch (465:9): [True: 0, False: 1.74k]
  ------------------
  466|      0|#ifdef NETSNMP_SECMOD_USM
  467|      0|        case 'a':
  ------------------
  |  Branch (467:9): [True: 0, False: 1.74k]
  ------------------
  468|      0|        case 'x':
  ------------------
  |  Branch (468:9): [True: 0, False: 1.74k]
  ------------------
  469|      0|        case 'A':
  ------------------
  |  Branch (469:9): [True: 0, False: 1.74k]
  ------------------
  470|      0|        case 'X':
  ------------------
  |  Branch (470:9): [True: 0, False: 1.74k]
  ------------------
  471|      0|#endif             /* NETSNMP_SECMOD_USM */
  472|      0|            if (snmpv3_parse_arg(arg, optarg, session, &Apsz, &Xpsz, argc,
  ------------------
  |  Branch (472:17): [True: 0, False: 0]
  ------------------
  473|      0|                                 argv, flags) < 0){
  474|      0|                ret = NETSNMP_PARSE_ARGS_ERROR_USAGE;
  ------------------
  |  |   37|      0|#define NETSNMP_PARSE_ARGS_ERROR_USAGE   -1
  ------------------
  475|      0|                goto out;
  476|      0|            }
  477|      0|            break;
  478|      0|#endif                          /* SNMPV3_CMD_OPTIONS */
  479|       |
  480|      0|        case '?':
  ------------------
  |  Branch (480:9): [True: 0, False: 1.74k]
  ------------------
  481|      0|            ret = NETSNMP_PARSE_ARGS_ERROR_USAGE;
  ------------------
  |  |   37|      0|#define NETSNMP_PARSE_ARGS_ERROR_USAGE   -1
  ------------------
  482|      0|            goto out;
  483|       |
  484|      0|        default:
  ------------------
  |  Branch (484:9): [True: 0, False: 1.74k]
  ------------------
  485|      0|            proc(argc, argv, arg);
  486|      0|            break;
  487|  1.74k|        }
  488|  1.74k|    }
  489|  1.74k|    DEBUGMSGTL(("snmp_parse_args", "finished: %d/%d\n", optind, argc));
  ------------------
  |  |   68|  1.74k|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|  1.74k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 1.74k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|  1.74k|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|  1.74k|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|  1.74k|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|  1.74k|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
  490|       |    
  491|       |    /*
  492|       |     * save command line parameters which should have precedence above config file settings
  493|       |     *    (There ought to be a more scalable approach than this....)
  494|       |     */
  495|  1.74k|    if (netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_OUTPUT_PRECISION)) {
  ------------------
  |  |   48|  1.74k|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                  if (netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_OUTPUT_PRECISION)) {
  ------------------
  |  |  186|  1.74k|#define NETSNMP_DS_LIB_OUTPUT_PRECISION  35
  ------------------
  |  Branch (495:9): [True: 0, False: 1.74k]
  ------------------
  496|      0|        backup_NETSNMP_DS_LIB_OUTPUT_PRECISION = 
  497|      0|            strdup(netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_OUTPUT_PRECISION));
  ------------------
  |  |   48|      0|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                          strdup(netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_OUTPUT_PRECISION));
  ------------------
  |  |  186|      0|#define NETSNMP_DS_LIB_OUTPUT_PRECISION  35
  ------------------
  498|      0|    }
  499|       |
  500|       |    /*
  501|       |     * read in MIB database and initialize the snmp library, read the config file
  502|       |     */
  503|  1.74k|    init_snmp(NETSNMP_APPLICATION_CONFIG_TYPE);
  ------------------
  |  |   22|  1.74k|#define NETSNMP_APPLICATION_CONFIG_TYPE "snmpapp"
  ------------------
  504|       |
  505|       |    /*
  506|       |     * restore command line parameters which should have precedence above config file settings
  507|       |     */
  508|  1.74k|    if(backup_NETSNMP_DS_LIB_OUTPUT_PRECISION) {
  ------------------
  |  Branch (508:8): [True: 0, False: 1.74k]
  ------------------
  509|      0|        netsnmp_ds_set_string(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_OUTPUT_PRECISION, backup_NETSNMP_DS_LIB_OUTPUT_PRECISION);
  ------------------
  |  |   48|      0|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                      netsnmp_ds_set_string(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_OUTPUT_PRECISION, backup_NETSNMP_DS_LIB_OUTPUT_PRECISION);
  ------------------
  |  |  186|      0|#define NETSNMP_DS_LIB_OUTPUT_PRECISION  35
  ------------------
  510|      0|        free(backup_NETSNMP_DS_LIB_OUTPUT_PRECISION);
  511|      0|    }
  512|       |
  513|       |    /*
  514|       |     * session default version 
  515|       |     */
  516|  1.74k|    if (session->version == SNMP_DEFAULT_VERSION) {
  ------------------
  |  |  123|  1.74k|#define SNMP_DEFAULT_VERSION	    -1
  ------------------
  |  Branch (516:9): [True: 1.74k, False: 0]
  ------------------
  517|       |        /*
  518|       |         * run time default version 
  519|       |         */
  520|  1.74k|        session->version = netsnmp_ds_get_int(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|  1.74k|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  521|  1.74k|					      NETSNMP_DS_LIB_SNMPVERSION);
  ------------------
  |  |  116|  1.74k|#define NETSNMP_DS_LIB_SNMPVERSION          2
  ------------------
  522|       |
  523|       |        /*
  524|       |         * compile time default version 
  525|       |         */
  526|  1.74k|        if (!session->version) {
  ------------------
  |  Branch (526:13): [True: 1.74k, False: 0]
  ------------------
  527|  1.74k|            switch (NETSNMP_DEFAULT_SNMP_VERSION) {
  ------------------
  |  | 1956|  1.74k|#define NETSNMP_DEFAULT_SNMP_VERSION 2
  ------------------
  528|      0|#ifndef NETSNMP_DISABLE_SNMPV1
  529|      0|            case 1:
  ------------------
  |  Branch (529:13): [True: 0, False: 1.74k]
  ------------------
  530|      0|                session->version = SNMP_VERSION_1;
  ------------------
  |  |  107|      0|#define SNMP_VERSION_1	   0
  ------------------
  531|      0|                break;
  532|      0|#endif
  533|       |
  534|      0|#ifndef NETSNMP_DISABLE_SNMPV2C
  535|  1.74k|            case 2:
  ------------------
  |  Branch (535:13): [True: 1.74k, False: 0]
  ------------------
  536|  1.74k|                session->version = SNMP_VERSION_2c;
  ------------------
  |  |  110|  1.74k|#define SNMP_VERSION_2c    1
  ------------------
  537|  1.74k|                break;
  538|      0|#endif
  539|       |
  540|      0|            case 3:
  ------------------
  |  Branch (540:13): [True: 0, False: 1.74k]
  ------------------
  541|      0|                session->version = SNMP_VERSION_3;
  ------------------
  |  |  113|      0|#define SNMP_VERSION_3     3
  ------------------
  542|      0|                break;
  543|       |
  544|      0|            default:
  ------------------
  |  Branch (544:13): [True: 0, False: 1.74k]
  ------------------
  545|      0|                snmp_log(LOG_ERR, "Can't determine a valid SNMP version for the session\n");
  546|      0|                return(NETSNMP_PARSE_ARGS_ERROR);
  ------------------
  |  |   43|      0|#define NETSNMP_PARSE_ARGS_ERROR         -3
  ------------------
  547|  1.74k|            }
  548|  1.74k|        } else {
  549|      0|#ifndef NETSNMP_DISABLE_SNMPV1
  550|      0|            if (session->version == NETSNMP_DS_SNMP_VERSION_1)  /* bogus value.  version 1 actually = 0 */
  ------------------
  |  |  140|      0|#define NETSNMP_DS_SNMP_VERSION_1    128        /* bogus */
  ------------------
  |  Branch (550:17): [True: 0, False: 0]
  ------------------
  551|      0|                session->version = SNMP_VERSION_1;
  ------------------
  |  |  107|      0|#define SNMP_VERSION_1	   0
  ------------------
  552|      0|#endif
  553|      0|        }
  554|  1.74k|    }
  555|       |
  556|  1.74k|#ifdef NETSNMP_SECMOD_USM
  557|       |    /* XXX: this should ideally be moved to snmpusm.c somehow */
  558|       |
  559|       |    /*
  560|       |     * make master key from pass phrases 
  561|       |     */
  562|  1.74k|    if (Apsz) {
  ------------------
  |  Branch (562:9): [True: 0, False: 1.74k]
  ------------------
  563|      0|        session->securityAuthKeyLen = USM_AUTH_KU_LEN;
  ------------------
  |  |  254|      0|#define USM_AUTH_KU_LEN     64
  ------------------
  564|      0|        if (session->securityAuthProto == NULL) {
  ------------------
  |  Branch (564:13): [True: 0, False: 0]
  ------------------
  565|       |            /*
  566|       |             * get .conf set default 
  567|       |             */
  568|      0|            const oid      *def =
  569|      0|                get_default_authtype(&session->securityAuthProtoLen);
  570|      0|            session->securityAuthProto =
  571|      0|                snmp_duplicate_objid(def, session->securityAuthProtoLen);
  572|      0|        }
  573|      0|        if (session->securityAuthProto == NULL) {
  ------------------
  |  Branch (573:13): [True: 0, False: 0]
  ------------------
  574|      0|            session->securityAuthProto =
  575|      0|                snmp_duplicate_objid(SNMP_DEFAULT_AUTH_PROTO,
  ------------------
  |  |  127|      0|#define SNMP_DEFAULT_AUTH_PROTO     usmHMACMD5AuthProtocol
  ------------------
  576|      0|                                     SNMP_DEFAULT_AUTH_PROTOLEN);
  ------------------
  |  |  131|      0|#define SNMP_DEFAULT_AUTH_PROTOLEN  OID_LENGTH(SNMP_DEFAULT_AUTH_PROTO)
  |  |  ------------------
  |  |  |  |   64|      0|    (sizeof(x) / sizeof((x)[0]) +                                       \
  |  |  |  |   65|      0|     sizeof(int[-__builtin_types_compatible_p(typeof(x), typeof(&(x)[0]))]))
  |  |  ------------------
  ------------------
  577|      0|            session->securityAuthProtoLen = SNMP_DEFAULT_AUTH_PROTOLEN;
  ------------------
  |  |  131|      0|#define SNMP_DEFAULT_AUTH_PROTOLEN  OID_LENGTH(SNMP_DEFAULT_AUTH_PROTO)
  |  |  ------------------
  |  |  |  |   64|      0|    (sizeof(x) / sizeof((x)[0]) +                                       \
  |  |  |  |   65|      0|     sizeof(int[-__builtin_types_compatible_p(typeof(x), typeof(&(x)[0]))]))
  |  |  ------------------
  ------------------
  578|      0|        }
  579|      0|        if (generate_Ku(session->securityAuthProto,
  ------------------
  |  Branch (579:13): [True: 0, False: 0]
  ------------------
  580|      0|                        session->securityAuthProtoLen,
  581|      0|                        (u_char *) Apsz, strlen(Apsz),
  582|      0|                        session->securityAuthKey,
  583|      0|                        &session->securityAuthKeyLen) != SNMPERR_SUCCESS) {
  ------------------
  |  |  217|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  584|      0|            snmp_perror(argv[0]);
  585|      0|            fprintf(stderr,
  586|      0|                    "Error generating a key (Ku) from the supplied authentication pass phrase. \n");
  587|      0|            ret = NETSNMP_PARSE_ARGS_ERROR;
  ------------------
  |  |   43|      0|#define NETSNMP_PARSE_ARGS_ERROR         -3
  ------------------
  588|      0|            goto out;
  589|      0|        }
  590|      0|        free(Apsz);
  591|      0|        Apsz = NULL;
  592|      0|    }
  593|  1.74k|    if (Xpsz) {
  ------------------
  |  Branch (593:9): [True: 0, False: 1.74k]
  ------------------
  594|      0|        session->securityPrivKeyLen = USM_PRIV_KU_LEN;
  ------------------
  |  |  255|      0|#define USM_PRIV_KU_LEN     64
  ------------------
  595|      0|        if (session->securityPrivProto == NULL) {
  ------------------
  |  Branch (595:13): [True: 0, False: 0]
  ------------------
  596|       |            /*
  597|       |             * get .conf set default 
  598|       |             */
  599|      0|            const oid      *def =
  600|      0|                get_default_privtype(&session->securityPrivProtoLen);
  601|      0|            session->securityPrivProto =
  602|      0|                snmp_duplicate_objid(def, session->securityPrivProtoLen);
  603|      0|        }
  604|      0|        if (session->securityPrivProto == NULL) {
  ------------------
  |  Branch (604:13): [True: 0, False: 0]
  ------------------
  605|      0|            session->securityPrivProto =
  606|      0|                snmp_duplicate_objid(SNMP_DEFAULT_PRIV_PROTO,
  ------------------
  |  |  133|      0|#define SNMP_DEFAULT_PRIV_PROTO     usmDESPrivProtocol
  ------------------
  607|      0|                                     SNMP_DEFAULT_PRIV_PROTOLEN);
  ------------------
  |  |  137|      0|#define SNMP_DEFAULT_PRIV_PROTOLEN  OID_LENGTH(SNMP_DEFAULT_PRIV_PROTO)
  |  |  ------------------
  |  |  |  |   64|      0|    (sizeof(x) / sizeof((x)[0]) +                                       \
  |  |  |  |   65|      0|     sizeof(int[-__builtin_types_compatible_p(typeof(x), typeof(&(x)[0]))]))
  |  |  ------------------
  ------------------
  608|      0|            session->securityPrivProtoLen = SNMP_DEFAULT_PRIV_PROTOLEN;
  ------------------
  |  |  137|      0|#define SNMP_DEFAULT_PRIV_PROTOLEN  OID_LENGTH(SNMP_DEFAULT_PRIV_PROTO)
  |  |  ------------------
  |  |  |  |   64|      0|    (sizeof(x) / sizeof((x)[0]) +                                       \
  |  |  |  |   65|      0|     sizeof(int[-__builtin_types_compatible_p(typeof(x), typeof(&(x)[0]))]))
  |  |  ------------------
  ------------------
  609|      0|        }
  610|      0|        if (generate_Ku(session->securityAuthProto,
  ------------------
  |  Branch (610:13): [True: 0, False: 0]
  ------------------
  611|      0|                        session->securityAuthProtoLen,
  612|      0|                        (u_char *) Xpsz, strlen(Xpsz),
  613|      0|                        session->securityPrivKey,
  614|      0|                        &session->securityPrivKeyLen) != SNMPERR_SUCCESS) {
  ------------------
  |  |  217|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  615|      0|            snmp_perror(argv[0]);
  616|      0|            fprintf(stderr,
  617|      0|                    "Error generating a key (Ku) from the supplied privacy pass phrase. \n");
  618|      0|            ret = NETSNMP_PARSE_ARGS_ERROR;
  ------------------
  |  |   43|      0|#define NETSNMP_PARSE_ARGS_ERROR         -3
  ------------------
  619|      0|            goto out;
  620|      0|        }
  621|      0|        free(Xpsz);
  622|      0|        Xpsz = NULL;
  623|      0|    }
  624|  1.74k|#endif /* NETSNMP_SECMOD_USM */
  625|       |
  626|       |    /*
  627|       |     * get the hostname 
  628|       |     */
  629|  1.74k|    if (optind == argc) {
  ------------------
  |  Branch (629:9): [True: 0, False: 1.74k]
  ------------------
  630|      0|        fprintf(stderr, "No hostname specified.\n");
  631|      0|        ret = NETSNMP_PARSE_ARGS_ERROR_USAGE;
  ------------------
  |  |   37|      0|#define NETSNMP_PARSE_ARGS_ERROR_USAGE   -1
  ------------------
  632|      0|        goto out;
  633|      0|    }
  634|  1.74k|    session->peername = strdup(argv[optind++]); /* hostname */
  635|       |
  636|  1.74k|#if !defined(NETSNMP_DISABLE_SNMPV1) || !defined(NETSNMP_DISABLE_SNMPV2C)
  637|       |    /*
  638|       |     * If v1 or v2c, check community has been set, either by a -c option above,
  639|       |     * or via a default token somewhere.  
  640|       |     * If neither, it will be taken from the incoming request PDU.
  641|       |     */
  642|       |
  643|       |#if defined(NETSNMP_DISABLE_SNMPV1)
  644|       |    if (session->version == SNMP_VERSION_2c)
  645|       |#else 
  646|       |#if defined(NETSNMP_DISABLE_SNMPV2C)
  647|       |    if (session->version == SNMP_VERSION_1)
  648|       |#else
  649|  1.74k|    if (session->version == SNMP_VERSION_1 ||
  ------------------
  |  |  107|  3.49k|#define SNMP_VERSION_1	   0
  ------------------
  |  Branch (649:9): [True: 0, False: 1.74k]
  ------------------
  650|  1.74k|	session->version == SNMP_VERSION_2c)
  ------------------
  |  |  110|  1.74k|#define SNMP_VERSION_2c    1
  ------------------
  |  Branch (650:2): [True: 1.74k, False: 0]
  ------------------
  651|  1.74k|#endif
  652|  1.74k|#endif
  653|  1.74k|    {
  654|  1.74k|        if (Cpsz == NULL) {
  ------------------
  |  Branch (654:13): [True: 1.74k, False: 0]
  ------------------
  655|  1.74k|            Cpsz = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|  1.74k|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  656|  1.74k|					 NETSNMP_DS_LIB_COMMUNITY);
  ------------------
  |  |  158|  1.74k|#define NETSNMP_DS_LIB_COMMUNITY         7
  ------------------
  657|  1.74k|	    if (Cpsz == NULL) {
  ------------------
  |  Branch (657:10): [True: 1.74k, False: 0]
  ------------------
  658|  1.74k|                if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|  1.74k|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (658:21): [True: 0, False: 1.74k]
  ------------------
  659|  1.74k|                                           NETSNMP_DS_LIB_IGNORE_NO_COMMUNITY)){
  ------------------
  |  |   94|  1.74k|#define NETSNMP_DS_LIB_IGNORE_NO_COMMUNITY 34	/* don't complain if no community is specified in the command arguments */
  ------------------
  660|      0|                    DEBUGMSGTL(("snmp_parse_args",
  ------------------
  |  |   68|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
  661|      0|                                "ignoring that the community string is not present\n"));
  662|      0|                    session->community = NULL;
  663|      0|                    session->community_len = 0;
  664|  1.74k|                } else {
  665|  1.74k|                    fprintf(stderr, "No community name specified.\n");
  666|  1.74k|                    ret = NETSNMP_PARSE_ARGS_ERROR_USAGE;
  ------------------
  |  |   37|  1.74k|#define NETSNMP_PARSE_ARGS_ERROR_USAGE   -1
  ------------------
  667|  1.74k|                    goto out;
  668|  1.74k|                }
  669|  1.74k|	    } else {
  670|      0|                Cpsz = NULL;
  671|      0|            }
  672|  1.74k|	} else {
  673|      0|            session->community = (unsigned char *)Cpsz;
  674|      0|            session->community_len = strlen(Cpsz);
  675|      0|            Cpsz = NULL;
  676|      0|        }
  677|  1.74k|    }
  678|      0|#endif /* support for community based SNMP */
  679|       |
  680|      0|    ret = optind;
  681|       |
  682|  1.74k|out:
  683|  1.74k|    free(Apsz);
  684|  1.74k|    free(Xpsz);
  685|  1.74k|    free(Cpsz);
  686|  1.74k|    return ret;
  687|      0|}
snmp_parse_args:
  694|  1.74k|{
  695|  1.74k|    return netsnmp_parse_args(argc, argv, session, localOpts, proc, 0);
  696|  1.74k|}

init_secmod:
   48|      1|{
   49|      1|    snmp_register_callback(SNMP_CALLBACK_LIBRARY,
  ------------------
  |  |   18|      1|#define SNMP_CALLBACK_LIBRARY     0
  ------------------
   50|      1|                           SNMP_CALLBACK_SESSION_INIT, set_default_secmod,
  ------------------
  |  |   29|      1|#define SNMP_CALLBACK_SESSION_INIT		5
  ------------------
   51|      1|                           NULL);
   52|       |
   53|      1|    netsnmp_ds_register_config(ASN_OCTET_STR, "snmp", "defSecurityModel",
  ------------------
  |  |   78|      1|#define ASN_OCTET_STR	    0x04U
  ------------------
   54|      1|			       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_SECMODEL);
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              			       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_SECMODEL);
  ------------------
  |  |  161|      1|#define NETSNMP_DS_LIB_SECMODEL          10
  ------------------
   55|       |    /*
   56|       |     * this file is generated by configure for all the stuff we're using 
   57|       |     */
   58|      1|#include "snmpsm_init.h"
  ------------------
  |  |    1|       |/* This file is automatically generated by configure.  Do not modify by hand. */
  |  |    2|      1|init_usm();
  |  |    3|      1|init_tsm();
  |  |    4|      1|init_ksm();
  ------------------
   59|      1|}
register_sec_mod:
   70|      3|{
   71|      3|    int             result = 0;
   72|      3|    struct snmp_secmod_list *sptr;
   73|      3|    char           *othername, *modname2 = NULL;
   74|       |
   75|      6|    for (sptr = registered_services; sptr; sptr = sptr->next) {
  ------------------
  |  Branch (75:38): [True: 3, False: 3]
  ------------------
   76|      3|        if (sptr->securityModel == secmod) {
  ------------------
  |  Branch (76:13): [True: 0, False: 3]
  ------------------
   77|      0|            return SNMPERR_GENERR;
  ------------------
  |  |  218|      0|#define SNMPERR_GENERR			(-1)
  ------------------
   78|      0|        }
   79|      3|    }
   80|      3|    sptr = SNMP_MALLOC_STRUCT(snmp_secmod_list);
  ------------------
  |  |   69|      3|#define SNMP_MALLOC_STRUCT(s)   (struct s *) calloc(1, sizeof(struct s))
  ------------------
   81|      3|    if (sptr == NULL)
  ------------------
  |  Branch (81:9): [True: 0, False: 3]
  ------------------
   82|      0|        return SNMPERR_MALLOC;
  ------------------
  |  |  279|      0|#define SNMPERR_MALLOC			(-62)
  ------------------
   83|      3|    sptr->secDef = newdef;
   84|      3|    sptr->securityModel = secmod;
   85|      3|    sptr->next = registered_services;
   86|      3|    registered_services = sptr;
   87|      3|    modname2 = strdup(modname);
   88|      3|    if (!modname2)
  ------------------
  |  Branch (88:9): [True: 0, False: 3]
  ------------------
   89|      0|        result = SE_NOMEM;
  ------------------
  |  |   43|      0|#define SE_NOMEM         1
  ------------------
   90|      3|    else
   91|      3|        result = se_add_pair_to_slist("snmp_secmods", modname2, secmod);
   92|      3|    if (result != SE_OK) {
  ------------------
  |  |   42|      3|#define SE_OK            0
  ------------------
  |  Branch (92:9): [True: 0, False: 3]
  ------------------
   93|      0|        switch (result) {
   94|      0|        case SE_NOMEM:
  ------------------
  |  |   43|      0|#define SE_NOMEM         1
  ------------------
  |  Branch (94:9): [True: 0, False: 0]
  ------------------
   95|      0|            snmp_log(LOG_CRIT, "snmp_secmod: no memory\n");
   96|      0|            break;
   97|       |
   98|      0|        case SE_ALREADY_THERE:
  ------------------
  |  |   44|      0|#define SE_ALREADY_THERE 2
  ------------------
  |  Branch (98:9): [True: 0, False: 0]
  ------------------
   99|      0|            othername = se_find_label_in_slist("snmp_secmods", secmod);
  100|      0|            if (strcmp(othername, modname) != 0) {
  ------------------
  |  Branch (100:17): [True: 0, False: 0]
  ------------------
  101|      0|                snmp_log(LOG_ERR,
  102|      0|                         "snmp_secmod: two security modules %s and %s registered with the same security number\n",
  103|      0|                         modname, othername);
  104|      0|            }
  105|      0|            break;
  106|       |
  107|      0|        default:
  ------------------
  |  Branch (107:9): [True: 0, False: 0]
  ------------------
  108|      0|            snmp_log(LOG_ERR,
  109|      0|                     "snmp_secmod: unknown error trying to register a new security module\n");
  110|      0|            break;
  111|      0|        }
  112|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  218|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  113|      0|    }
  114|      3|    return SNMPERR_SUCCESS;
  ------------------
  |  |  217|      3|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  115|      3|}
find_sec_mod:
  160|  3.48k|{
  161|  3.48k|    struct snmp_secmod_list *sptr;
  162|       |
  163|  12.2k|    for (sptr = registered_services; sptr; sptr = sptr->next) {
  ------------------
  |  Branch (163:38): [True: 10.4k, False: 1.74k]
  ------------------
  164|  10.4k|        if (sptr->securityModel == secmod) {
  ------------------
  |  Branch (164:13): [True: 1.74k, False: 8.72k]
  ------------------
  165|  1.74k|            return sptr->secDef;
  166|  1.74k|        }
  167|  10.4k|    }
  168|       |    /*
  169|       |     * not registered 
  170|       |     */
  171|  1.74k|    return NULL;
  172|  3.48k|}
snmp_secmod.c:set_default_secmod:
  189|  1.74k|{
  190|  1.74k|    netsnmp_session *sess = (netsnmp_session *) serverarg;
  191|  1.74k|    char           *cptr;
  192|  1.74k|    int             model;
  193|       |
  194|  1.74k|    if (!sess)
  ------------------
  |  Branch (194:9): [True: 0, False: 1.74k]
  ------------------
  195|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  218|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  196|  1.74k|    if (sess->securityModel == SNMP_DEFAULT_SECMODEL) {
  ------------------
  |  |  124|  1.74k|#define SNMP_DEFAULT_SECMODEL	    -1
  ------------------
  |  Branch (196:9): [True: 0, False: 1.74k]
  ------------------
  197|      0|        if ((cptr = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|      0|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (197:13): [True: 0, False: 0]
  ------------------
  198|      0|					  NETSNMP_DS_LIB_SECMODEL)) != NULL) {
  ------------------
  |  |  161|      0|#define NETSNMP_DS_LIB_SECMODEL          10
  ------------------
  199|      0|            if ((model = se_find_value_in_slist("snmp_secmods", cptr))
  ------------------
  |  Branch (199:17): [True: 0, False: 0]
  ------------------
  200|      0|		!= SE_DNE) {
  ------------------
  |  |   45|      0|#define SE_DNE           -2
  ------------------
  201|      0|                sess->securityModel = model;
  202|      0|            } else {
  203|      0|                snmp_log(LOG_ERR,
  204|      0|                         "unknown security model name: %s.  Forcing USM instead.\n",
  205|      0|                         cptr);
  206|      0|                sess->securityModel = NETSNMP_SECMOD_DEFAULT_MODEL;
  ------------------
  |  |  177|      0|#define NETSNMP_SECMOD_DEFAULT_MODEL  USM_SEC_MODEL_NUMBER
  |  |  ------------------
  |  |  |  |   40|      0|#define USM_SEC_MODEL_NUMBER            SNMP_SEC_MODEL_USM
  |  |  |  |  ------------------
  |  |  |  |  |  |  295|      0|#define SNMP_SEC_MODEL_USM		3
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  207|      0|                return SNMPERR_GENERR;
  ------------------
  |  |  218|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  208|      0|            }
  209|      0|        } else {
  210|      0|            sess->securityModel = NETSNMP_SECMOD_DEFAULT_MODEL;
  ------------------
  |  |  177|      0|#define NETSNMP_SECMOD_DEFAULT_MODEL  USM_SEC_MODEL_NUMBER
  |  |  ------------------
  |  |  |  |   40|      0|#define USM_SEC_MODEL_NUMBER            SNMP_SEC_MODEL_USM
  |  |  |  |  ------------------
  |  |  |  |  |  |  295|      0|#define SNMP_SEC_MODEL_USM		3
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  211|      0|        }
  212|      0|    }
  213|  1.74k|    return SNMPERR_SUCCESS;
  ------------------
  |  |  217|  1.74k|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  214|  1.74k|}

netsnmp_register_default_domain:
   60|      2|{
   61|      2|    struct netsnmp_lookup_domain *run = domains, *prev = NULL;
   62|      2|    int res = 0;
   63|       |
   64|      3|    while (run != NULL && strcmp(run->application, application) < 0) {
  ------------------
  |  Branch (64:12): [True: 1, False: 2]
  |  Branch (64:27): [True: 1, False: 0]
  ------------------
   65|      1|	prev = run;
   66|      1|	run = run->next;
   67|      1|    }
   68|      2|    if (run && strcmp(run->application, application) == 0) {
  ------------------
  |  Branch (68:9): [True: 0, False: 2]
  |  Branch (68:16): [True: 0, False: 0]
  ------------------
   69|      0|      if (run->domain != NULL) {
  ------------------
  |  Branch (69:11): [True: 0, False: 0]
  ------------------
   70|      0|          destroy_word_array(run->domain);
   71|      0|	  run->domain = NULL;
   72|      0|	  res = 1;
   73|      0|      }
   74|      2|    } else {
   75|      2|	run = SNMP_MALLOC_STRUCT(netsnmp_lookup_domain);
  ------------------
  |  |   69|      2|#define SNMP_MALLOC_STRUCT(s)   (struct s *) calloc(1, sizeof(struct s))
  ------------------
   76|      2|	run->application = strdup(application);
   77|      2|	run->userDomain = NULL;
   78|      2|	if (prev) {
  ------------------
  |  Branch (78:6): [True: 1, False: 1]
  ------------------
   79|      1|	    run->next = prev->next;
   80|      1|	    prev->next = run;
   81|      1|	} else {
   82|      1|	    run->next = domains;
   83|      1|	    domains = run;
   84|      1|	}
   85|      2|    }
   86|      2|    if (domain) {
  ------------------
  |  Branch (86:9): [True: 2, False: 0]
  ------------------
   87|      2|        run->domain = create_word_array(domain);
   88|      2|    } else if (run->userDomain == NULL) {
  ------------------
  |  Branch (88:16): [True: 0, False: 0]
  ------------------
   89|      0|	if (prev)
  ------------------
  |  Branch (89:6): [True: 0, False: 0]
  ------------------
   90|      0|	    prev->next = run->next;
   91|      0|	else
   92|      0|	    domains = run->next;
   93|      0|	free(run->application);
   94|      0|	free(run);
   95|      0|    }
   96|      2|    return res;
   97|      2|}
netsnmp_register_default_target:
  248|     14|{
  249|     14|    struct netsnmp_lookup_target *run = targets, *prev = NULL;
  250|     14|    int i = 0, res = 0;
  251|     77|    while (run && ((i = strcmp(run->application, application)) < 0 ||
  ------------------
  |  Branch (251:12): [True: 73, False: 4]
  |  Branch (251:20): [True: 49, False: 24]
  ------------------
  252|     73|		   (i == 0 && strcmp(run->domain, domain) < 0))) {
  ------------------
  |  Branch (252:7): [True: 24, False: 0]
  |  Branch (252:17): [True: 14, False: 10]
  ------------------
  253|     63|	prev = run;
  254|     63|	run = run->next;
  255|     63|    }
  256|     14|    if (run && i == 0 && strcmp(run->domain, domain) == 0) {
  ------------------
  |  Branch (256:9): [True: 10, False: 4]
  |  Branch (256:16): [True: 10, False: 0]
  |  Branch (256:26): [True: 0, False: 10]
  ------------------
  257|      0|      if (run->target != NULL) {
  ------------------
  |  Branch (257:11): [True: 0, False: 0]
  ------------------
  258|      0|	    free(run->target);
  259|      0|	    run->target = NULL;
  260|      0|	    res = 1;
  261|      0|      }
  262|     14|    } else {
  263|     14|	run = SNMP_MALLOC_STRUCT(netsnmp_lookup_target);
  ------------------
  |  |   69|     14|#define SNMP_MALLOC_STRUCT(s)   (struct s *) calloc(1, sizeof(struct s))
  ------------------
  264|     14|	run->application = strdup(application);
  265|     14|	run->domain = strdup(domain);
  266|     14|	run->userTarget = NULL;
  267|     14|	if (prev) {
  ------------------
  |  Branch (267:6): [True: 11, False: 3]
  ------------------
  268|     11|	    run->next = prev->next;
  269|     11|	    prev->next = run;
  270|     11|	} else {
  271|      3|	    run->next = targets;
  272|      3|	    targets = run;
  273|      3|	}
  274|     14|    }
  275|     14|    if (target) {
  ------------------
  |  Branch (275:9): [True: 14, False: 0]
  ------------------
  276|     14|	run->target = strdup(target);
  277|     14|    } else if (run->userTarget == NULL) {
  ------------------
  |  Branch (277:16): [True: 0, False: 0]
  ------------------
  278|      0|	if (prev)
  ------------------
  |  Branch (278:6): [True: 0, False: 0]
  ------------------
  279|      0|	    prev->next = run->next;
  280|      0|	else
  281|      0|	    targets = run->next;
  282|      0|	free(run->domain);
  283|      0|	free(run->application);
  284|      0|	free(run);
  285|      0|    }
  286|     14|    return res;
  287|     14|}
netsnmp_register_service_handlers:
  426|      1|{
  427|      1|    register_config_handler("snmp:", "defDomain",
  428|      1|			    netsnmp_register_user_domain,
  429|      1|			    netsnmp_clear_user_domain,
  430|      1|			    "application domain");
  431|      1|    register_config_handler("snmp:", "defTarget",
  432|      1|			    netsnmp_register_user_target,
  433|      1|			    netsnmp_clear_user_target,
  434|      1|			    "application domain target");
  435|      1|}
snmp_service.c:create_word_array:
   28|      2|{
   29|      2|    size_t tmplen = strlen(cptr);
   30|      2|    char* tmp = (char*)malloc(tmplen + 1);
   31|      2|    char** res = create_word_array_helper(cptr, 0, tmp, tmplen + 1);
   32|      2|    free(tmp);
   33|      2|    return res;
   34|      2|}
snmp_service.c:create_word_array_helper:
   11|      4|{
   12|      4|    char* item;
   13|      4|    char** res;
   14|      4|    cptr = copy_nword_const(cptr, tmp, tmplen);
   15|      4|    item = strdup(tmp);
   16|      4|    if (cptr)
  ------------------
  |  Branch (16:9): [True: 2, False: 2]
  ------------------
   17|      2|        res = create_word_array_helper(cptr, idx + 1, tmp, tmplen);
   18|      2|    else {
   19|      2|        res = (char**)malloc(sizeof(char*) * (idx + 2));
   20|      2|        res[idx + 1] = NULL;
   21|      2|    }
   22|      4|    res[idx] = item;
   23|      4|    return res;
   24|      4|}
snmp_service.c:netsnmp_clear_user_domain:
  161|      2|{
  162|      2|    struct netsnmp_lookup_domain *run = domains, *prev = NULL;
  163|       |
  164|      6|    while (run) {
  ------------------
  |  Branch (164:12): [True: 4, False: 2]
  ------------------
  165|      4|	if (run->userDomain != NULL) {
  ------------------
  |  Branch (165:6): [True: 0, False: 4]
  ------------------
  166|      0|            destroy_word_array(run->userDomain);
  167|      0|	    run->userDomain = NULL;
  168|      0|	}
  169|      4|	if (run->domain == NULL) {
  ------------------
  |  Branch (169:6): [True: 0, False: 4]
  ------------------
  170|      0|	    struct netsnmp_lookup_domain *tmp = run;
  171|      0|	    if (prev)
  ------------------
  |  Branch (171:10): [True: 0, False: 0]
  ------------------
  172|      0|		run = prev->next = run->next;
  173|      0|	    else
  174|      0|		run = domains = run->next;
  175|      0|	    free(tmp->application);
  176|      0|	    free(tmp);
  177|      4|	} else {
  178|      4|	    prev = run;
  179|      4|	    run = run->next;
  180|      4|	}
  181|      4|    }
  182|      2|}
snmp_service.c:netsnmp_clear_user_target:
  371|      2|{
  372|      2|    struct netsnmp_lookup_target *run = targets, *prev = NULL;
  373|       |
  374|     30|    while (run) {
  ------------------
  |  Branch (374:12): [True: 28, False: 2]
  ------------------
  375|     28|	if (run->userTarget != NULL) {
  ------------------
  |  Branch (375:6): [True: 0, False: 28]
  ------------------
  376|      0|	    free(run->userTarget);
  377|      0|	    run->userTarget = NULL;
  378|      0|	}
  379|     28|	if (run->target == NULL) {
  ------------------
  |  Branch (379:6): [True: 0, False: 28]
  ------------------
  380|      0|	    struct netsnmp_lookup_target *tmp = run;
  381|      0|	    if (prev)
  ------------------
  |  Branch (381:10): [True: 0, False: 0]
  ------------------
  382|      0|		run = prev->next = run->next;
  383|      0|	    else
  384|      0|		run = targets = run->next;
  385|      0|	    free(tmp->application);
  386|      0|	    free(tmp->domain);
  387|      0|	    free(tmp);
  388|     28|	} else {
  389|     28|	    prev = run;
  390|     28|	    run = run->next;
  391|     28|	}
  392|     28|    }
  393|      2|}

init_snmp_transport:
  124|      1|{
  125|      1|    netsnmp_ds_register_config(ASN_BOOLEAN,
  ------------------
  |  |   72|      1|#define ASN_BOOLEAN	    0x01U
  ------------------
  126|      1|                               "snmp", "dontLoadHostConfig",
  127|      1|                               NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  128|      1|                               NETSNMP_DS_LIB_DONT_LOAD_HOST_FILES);
  ------------------
  |  |  100|      1|#define NETSNMP_DS_LIB_DONT_LOAD_HOST_FILES 40 /* don't read host.conf files */
  ------------------
  129|      1|#ifndef NETSNMP_FEATURE_REMOVE_FILTER_SOURCE
  130|      1|    register_app_config_handler("sourceFilterType",
  131|      1|                                netsnmp_transport_parse_filterType,
  132|      1|                                NULL, "none|whitelist|blacklist");
  133|      1|    register_app_config_handler("sourceFilterAddress",
  134|      1|                                netsnmp_transport_parse_filter,
  135|      1|                                netsnmp_transport_filter_cleanup,
  136|      1|                                "host");
  137|      1|#endif /* NETSNMP_FEATURE_REMOVE_FILTER_SOURCE */
  138|      1|}
netsnmp_transport_peer_string:
  259|  1.74k|{
  260|  1.74k|    char           *str;
  261|       |
  262|  1.74k|    if (NULL == t)
  ------------------
  |  Branch (262:9): [True: 0, False: 1.74k]
  ------------------
  263|      0|        return NULL;
  264|       |
  265|  1.74k|    if (t->f_fmtaddr != NULL)
  ------------------
  |  Branch (265:9): [True: 0, False: 1.74k]
  ------------------
  266|      0|        str = t->f_fmtaddr(t, data, len);
  267|  1.74k|    else
  268|  1.74k|        str = strdup("<UNKNOWN>");
  269|       |
  270|  1.74k|    return str;
  271|  1.74k|}
netsnmp_transport_filter_cleanup:
  366|      1|{
  367|      1|    if (NULL == filtered)
  ------------------
  |  Branch (367:9): [True: 1, False: 0]
  ------------------
  368|      1|        return;
  369|      0|    CONTAINER_CLEAR(filtered, filtered->free_item, NULL);
  370|      0|    CONTAINER_FREE(filtered);
  371|      0|    filtered = NULL;
  372|      0|}
netsnmp_transport_recv:
  435|  10.4k|{
  436|  10.4k|    int debugLength;
  437|       |
  438|  10.4k|    if ((NULL == t) || (NULL == t->f_recv)) {
  ------------------
  |  Branch (438:9): [True: 0, False: 10.4k]
  |  Branch (438:24): [True: 0, False: 10.4k]
  ------------------
  439|      0|        DEBUGMSGTL(("transport:recv", "NULL transport or recv function\n"));
  ------------------
  |  |   68|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
  440|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  218|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  441|      0|    }
  442|       |
  443|  10.4k|    length = t->f_recv(t, packet, length, opaque, olength);
  444|       |
  445|  10.4k|    if (length <=0)
  ------------------
  |  Branch (445:9): [True: 8.72k, False: 1.74k]
  ------------------
  446|  8.72k|        return length; /* don't log timeouts/socket closed */
  447|       |
  448|  1.74k|    debugLength = (SNMPERR_SUCCESS ==
  ------------------
  |  |  217|  1.74k|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  449|  1.74k|                   debug_is_token_registered("transport:recv"));
  450|       |
  451|  1.74k|    if (debugLength) {
  ------------------
  |  Branch (451:9): [True: 1.74k, False: 0]
  ------------------
  452|  1.74k|        char *str = netsnmp_transport_peer_string(t,
  453|  1.74k|                                                  opaque ? *opaque : NULL,
  ------------------
  |  Branch (453:51): [True: 1.74k, False: 0]
  ------------------
  454|  1.74k|                                                  olength ? *olength : 0);
  ------------------
  |  Branch (454:51): [True: 1.74k, False: 0]
  ------------------
  455|  1.74k|        if (debugLength)
  ------------------
  |  Branch (455:13): [True: 1.74k, False: 0]
  ------------------
  456|  1.74k|            DEBUGMSGT_NC(("transport:recv","%d bytes from %s\n",
  ------------------
  |  |   87|  1.74k|#define DEBUGMSGT_NC(x) do { __DBGMSGT_NC(x); }while(0)
  |  |  ------------------
  |  |  |  |  151|  1.74k|#define __DBGMSGT_NC(x)  debug_combo_nc x
  |  |  ------------------
  |  |  |  Branch (87:54): [Folded - Ignored]
  |  |  ------------------
  ------------------
  457|  1.74k|                          length, str));
  458|  1.74k|        SNMP_FREE(str);
  ------------------
  |  |   62|  1.74k|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 1.74k, False: 0]
  |  |  |  Branch (62:66): [Folded - Ignored]
  |  |  ------------------
  ------------------
  459|  1.74k|    }
  460|       |
  461|  1.74k|    return length;
  462|  10.4k|}
netsnmp_tdomain_init:
  490|      1|{
  491|      1|    DEBUGMSGTL(("tdomain", "netsnmp_tdomain_init() called\n"));
  ------------------
  |  |   68|      1|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
  492|       |
  493|       |/* include the configure generated list of constructor calls */
  494|      1|#include "transports/snmp_transport_inits.h"
  ------------------
  |  |    1|       |/* This file is automatically generated by configure.  Do not modify by hand. */
  |  |    2|      1|netsnmp_tlsbase_ctor();
  |  |    3|      1|netsnmp_tlstcp_ctor();
  |  |    4|      1|netsnmp_dtlsudp_ctor();
  |  |    5|      1|netsnmp_udpshared_ctor();
  |  |    6|      1|netsnmp_std_ctor();
  |  |    7|      1|netsnmp_ipx_ctor();
  |  |    8|      1|netsnmp_aal5pvc_ctor();
  |  |    9|      1|netsnmp_udpipv6_ctor();
  |  |   10|      1|netsnmp_tcpipv6_ctor();
  |  |   11|      1|netsnmp_udp_ctor();
  |  |   12|      1|netsnmp_tcp_ctor();
  |  |   13|      1|netsnmp_alias_ctor();
  |  |   14|      1|netsnmp_unix_ctor();
  ------------------
  495|       |
  496|      1|    netsnmp_tdomain_dump();
  497|       |
  498|       |
  499|      1|}
netsnmp_tdomain_register:
  541|     12|{
  542|     12|    netsnmp_tdomain **prevNext = &domain_list, *d;
  543|       |
  544|     12|    if (n != NULL) {
  ------------------
  |  Branch (544:9): [True: 12, False: 0]
  ------------------
  545|     78|        for (d = domain_list; d != NULL; d = d->next) {
  ------------------
  |  Branch (545:31): [True: 66, False: 12]
  ------------------
  546|     66|            if (netsnmp_oid_equals(n->name, n->name_length,
  ------------------
  |  Branch (546:17): [True: 0, False: 66]
  ------------------
  547|     66|                                d->name, d->name_length) == 0) {
  548|       |                /*
  549|       |                 * Already registered.  
  550|       |                 */
  551|      0|                return 0;
  552|      0|            }
  553|     66|            prevNext = &(d->next);
  554|     66|        }
  555|     12|        n->next = NULL;
  556|     12|        *prevNext = n;
  557|     12|        return 1;
  558|     12|    } else {
  559|      0|        return 0;
  560|      0|    }
  561|     12|}
snmp_transport.c:netsnmp_tdomain_dump:
  519|      1|{
  520|      1|    netsnmp_tdomain *d;
  521|      1|    int i = 0;
  522|       |
  523|      1|    DEBUGMSGTL(("tdomain", "domain_list -> "));
  ------------------
  |  |   68|      1|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
  524|     13|    for (d = domain_list; d != NULL; d = d->next) {
  ------------------
  |  Branch (524:27): [True: 12, False: 1]
  ------------------
  525|     12|        DEBUGMSG(("tdomain", "{ "));
  ------------------
  |  |   63|     12|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  146|     12|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 12]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (63:67): [Folded - Ignored]
  |  |  ------------------
  ------------------
  526|     12|        DEBUGMSGOID(("tdomain", d->name, d->name_length));
  ------------------
  |  |   69|     12|#define DEBUGMSGOID(x)     do {if (_DBG_IF_) {__DBGMSGOID(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|     12|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 12]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGOID(x)     do {if (_DBG_IF_) {__DBGMSGOID(x);} }while(0)
  |  |  ------------------
  |  |  |  |  167|      0|#define __DBGMSGOID(x)     debugmsg_oid x
  |  |  ------------------
  |  |  |  Branch (69:71): [Folded - Ignored]
  |  |  ------------------
  ------------------
  527|     12|        DEBUGMSG(("tdomain", ", \""));
  ------------------
  |  |   63|     12|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  146|     12|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 12]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (63:67): [Folded - Ignored]
  |  |  ------------------
  ------------------
  528|     34|        for (i = 0; d->prefix[i] != NULL; i++) {
  ------------------
  |  Branch (528:21): [True: 22, False: 12]
  ------------------
  529|     22|            DEBUGMSG(("tdomain", "%s%s", d->prefix[i],
  ------------------
  |  |   63|     22|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  146|     22|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 22]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (63:56): [True: 0, False: 0]
  |  |  |  Branch (63:67): [Folded - Ignored]
  |  |  ------------------
  ------------------
  530|     22|		      (d->prefix[i + 1]) ? "/" : ""));
  531|     22|        }
  532|     12|        DEBUGMSG(("tdomain", "\" } -> "));
  ------------------
  |  |   63|     12|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  146|     12|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 12]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (63:67): [Folded - Ignored]
  |  |  ------------------
  ------------------
  533|     12|    }
  534|      1|    DEBUGMSG(("tdomain", "[NIL]\n"));
  ------------------
  |  |   63|      1|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  146|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (63:67): [Folded - Ignored]
  |  |  ------------------
  ------------------
  535|      1|}

init_ksm:
  218|      1|{
  219|      1|    krb5_error_code retval;
  220|      1|    struct snmp_secmod_def *def;
  221|      1|    int             i;
  222|       |
  223|      1|    netsnmp_ds_register_config(ASN_OCTET_STR, "snmp", "defKSMKeytab",
  ------------------
  |  |   78|      1|#define ASN_OCTET_STR	    0x04U
  ------------------
  224|      1|                               NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_KSM_KEYTAB);
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                             NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_KSM_KEYTAB);
  ------------------
  |  |  172|      1|#define NETSNMP_DS_LIB_KSM_KEYTAB        21
  ------------------
  225|      1|    netsnmp_ds_register_config(ASN_OCTET_STR, "snmp", "defKSMServiceName",
  ------------------
  |  |   78|      1|#define ASN_OCTET_STR	    0x04U
  ------------------
  226|      1|                               NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  227|      1|			       NETSNMP_DS_LIB_KSM_SERVICE_NAME);
  ------------------
  |  |  173|      1|#define NETSNMP_DS_LIB_KSM_SERVICE_NAME  22
  ------------------
  228|      1|    snmp_register_callback(SNMP_CALLBACK_LIBRARY,
  ------------------
  |  |   18|      1|#define SNMP_CALLBACK_LIBRARY     0
  ------------------
  229|      1|			   SNMP_CALLBACK_POST_READ_CONFIG,
  ------------------
  |  |   24|      1|#define SNMP_CALLBACK_POST_READ_CONFIG	        0
  ------------------
  230|      1|			   init_snmpksm_post_config, NULL);
  231|       |
  232|       |
  233|      1|    if (kcontext == NULL) {
  ------------------
  |  Branch (233:9): [True: 1, False: 0]
  ------------------
  234|      1|        retval = krb5_init_context(&kcontext);
  235|       |
  236|      1|        if (retval) {
  ------------------
  |  Branch (236:13): [True: 0, False: 1]
  ------------------
  237|      0|            DEBUGMSGTL(("ksm", "krb5_init_context failed (%s), not "
  ------------------
  |  |   68|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
  238|      0|                        "registering KSM\n", error_message(retval)));
  239|      0|            return;
  240|      0|        }
  241|      1|    }
  242|       |
  243|     65|    for (i = 0; i < HASHSIZE; i++)
  ------------------
  |  |  129|     65|#define HASHSIZE	64
  ------------------
  |  Branch (243:17): [True: 64, False: 1]
  ------------------
  244|     64|        ksm_hash_table[i] = NULL;
  245|       |
  246|      1|    def = SNMP_MALLOC_STRUCT(snmp_secmod_def);
  ------------------
  |  |   69|      1|#define SNMP_MALLOC_STRUCT(s)   (struct s *) calloc(1, sizeof(struct s))
  ------------------
  247|       |
  248|      1|    if (!def) {
  ------------------
  |  Branch (248:9): [True: 0, False: 1]
  ------------------
  249|      0|        DEBUGMSGTL(("ksm", "Unable to malloc snmp_secmod struct, not "
  ------------------
  |  |   68|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
  250|      0|                    "registering KSM\n"));
  251|      0|        return;
  252|      0|    }
  253|       |
  254|      1|    def->encode_reverse = ksm_rgenerate_out_msg;
  255|      1|    def->decode = ksm_process_in_msg;
  256|      1|    def->session_open = ksm_session_init;
  257|      1|    def->pdu_free_state_ref = ksm_free_state_ref;
  258|      1|    def->pdu_free = ksm_free_pdu;
  259|      1|    def->pdu_clone = ksm_clone_pdu;
  260|       |
  261|      1|    register_sec_mod(NETSNMP_SEC_MODEL_KSM, "ksm", def);
  ------------------
  |  |   13|      1|#define NETSNMP_SEC_MODEL_KSM     2066432
  ------------------
  262|      1|}
snmpksm.c:init_snmpksm_post_config:
  169|      1|{
  170|       |
  171|      1|    if (kcontext == NULL) {
  ------------------
  |  Branch (171:9): [True: 0, False: 1]
  ------------------
  172|       |	/* not reached, i'd imagine */
  173|      0|        return SNMPERR_KRB5;
  ------------------
  |  |  280|      0|#define SNMPERR_KRB5			(-63)
  ------------------
  174|      0|    }
  175|       |
  176|      1|    if (service_name == NULL) {
  ------------------
  |  Branch (176:9): [True: 1, False: 0]
  ------------------
  177|       |	/* always reached, i'd imagine */
  178|      1|	char *c = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  179|      1|					NETSNMP_DS_LIB_KSM_SERVICE_NAME);
  ------------------
  |  |  173|      1|#define NETSNMP_DS_LIB_KSM_SERVICE_NAME  22
  ------------------
  180|      1|	if (c != NULL) {
  ------------------
  |  Branch (180:6): [True: 0, False: 1]
  ------------------
  181|      0|		service_name = c;
  182|      0|	}
  183|      1|	else {
  184|      1|		service_name = service_host;
  185|      1|	}
  186|      1|    }
  187|       |
  188|      1|    if (keytab_setup == 0) {
  ------------------
  |  Branch (188:9): [True: 1, False: 0]
  ------------------
  189|       |	/* always reached, i'd imagine */
  190|      1|	char *c = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  191|      1|					NETSNMP_DS_LIB_KSM_KEYTAB);
  ------------------
  |  |  172|      1|#define NETSNMP_DS_LIB_KSM_KEYTAB        21
  ------------------
  192|      1|	if (c) {
  ------------------
  |  Branch (192:6): [True: 0, False: 1]
  ------------------
  193|      0|	    krb5_error_code retval;
  194|      0|	    DEBUGMSGTL(("ksm", "Using keytab %s\n", c));
  ------------------
  |  |   68|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
  195|      0|	    retval = krb5_kt_resolve(kcontext, c, &keytab);
  196|      0|	    if (retval) {
  ------------------
  |  Branch (196:10): [True: 0, False: 0]
  ------------------
  197|      0|		DEBUGMSGTL(("ksm", "krb5_kt_resolve(\"%s\") failed. KSM "
  ------------------
  |  |   68|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
  198|      0|			    "config callback failing\n", error_message(retval)));
  199|      0|		return SNMPERR_KRB5;
  ------------------
  |  |  280|      0|#define SNMPERR_KRB5			(-63)
  ------------------
  200|      0|	    }
  201|      0|	}
  202|      1|	else {
  203|      1|	    DEBUGMSGTL(("ksm", "Using default keytab\n"));
  ------------------
  |  |   68|      1|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      1|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      1|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      1|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      1|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
  204|      1|	}
  205|      1|	keytab_setup = 1;
  206|      1|    }
  207|       |
  208|      1|    return SNMPERR_SUCCESS;
  ------------------
  |  |  217|      1|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  209|      1|}

init_tsm:
   43|      1|{
   44|      1|    struct snmp_secmod_def *def;
   45|      1|    int ret;
   46|       |
   47|      1|    def = SNMP_MALLOC_STRUCT(snmp_secmod_def);
  ------------------
  |  |   69|      1|#define SNMP_MALLOC_STRUCT(s)   (struct s *) calloc(1, sizeof(struct s))
  ------------------
   48|       |
   49|      1|    if (!def) {
  ------------------
  |  Branch (49:9): [True: 0, False: 1]
  ------------------
   50|      0|        snmp_log(LOG_ERR,
   51|      0|                 "Unable to malloc snmp_secmod struct, not registering TSM\n");
   52|      0|        return;
   53|      0|    }
   54|       |
   55|      1|    def->encode_reverse = tsm_rgenerate_out_msg;
   56|      1|    def->decode = tsm_process_in_msg;
   57|      1|    def->session_open = tsm_session_init;
   58|      1|    def->pdu_free_state_ref = tsm_free_state_ref;
   59|      1|    def->pdu_clone = tsm_clone_pdu;
   60|      1|    def->pdu_free = tsm_free_pdu;
   61|      1|    def->probe_engineid = snmpv3_probe_contextEngineID_rfc5343;
   62|       |
   63|      1|    DEBUGMSGTL(("tsm","registering ourselves\n"));
  ------------------
  |  |   68|      1|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      1|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      1|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      1|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      1|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
   64|      1|    ret = register_sec_mod(SNMP_SEC_MODEL_TSM, "tsm", def);
  ------------------
  |  |  296|      1|#define SNMP_SEC_MODEL_TSM              4
  ------------------
   65|      1|    DEBUGMSGTL(("tsm"," returned %d\n", ret));
  ------------------
  |  |   68|      1|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      1|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      1|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      1|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      1|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
   66|       |
   67|      1|    netsnmp_ds_register_config(ASN_BOOLEAN, "snmp", "tsmUseTransportPrefix",
  ------------------
  |  |   72|      1|#define ASN_BOOLEAN	    0x01U
  ------------------
   68|      1|			       NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
   69|      1|                               NETSNMP_DS_LIB_TSM_USE_PREFIX);
  ------------------
  |  |   99|      1|#define NETSNMP_DS_LIB_TSM_USE_PREFIX      39 /* TSM's simple security name mapping */
  ------------------
   70|      1|}

usm_free_user:
  747|  1.74k|{
  748|  1.74k|    if (user == NULL)
  ------------------
  |  Branch (748:9): [True: 1.74k, False: 0]
  ------------------
  749|  1.74k|        return NULL;
  750|       |
  751|      0|    SNMP_FREE(user->engineID);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded - Ignored]
  |  |  ------------------
  ------------------
  752|      0|    SNMP_FREE(user->name);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded - Ignored]
  |  |  ------------------
  ------------------
  753|      0|    SNMP_FREE(user->secName);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded - Ignored]
  |  |  ------------------
  ------------------
  754|      0|    SNMP_FREE(user->cloneFrom);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded - Ignored]
  |  |  ------------------
  ------------------
  755|      0|    SNMP_FREE(user->userPublicString);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded - Ignored]
  |  |  ------------------
  ------------------
  756|      0|    SNMP_FREE(user->authProtocol);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded - Ignored]
  |  |  ------------------
  ------------------
  757|      0|    SNMP_FREE(user->privProtocol);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded - Ignored]
  |  |  ------------------
  ------------------
  758|       |
  759|      0|    if (user->authKey != NULL) {
  ------------------
  |  Branch (759:9): [True: 0, False: 0]
  ------------------
  760|      0|        SNMP_ZERO(user->authKey, user->authKeyLen);
  ------------------
  |  |   77|      0|#define SNMP_ZERO(s,l)	do { if (s) memset(s, 0, l); } while(0)
  |  |  ------------------
  |  |  |  Branch (77:33): [True: 0, False: 0]
  |  |  |  Branch (77:61): [Folded - Ignored]
  |  |  ------------------
  ------------------
  761|      0|        SNMP_FREE(user->authKey);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded - Ignored]
  |  |  ------------------
  ------------------
  762|      0|    }
  763|       |
  764|      0|    if (user->privKey != NULL) {
  ------------------
  |  Branch (764:9): [True: 0, False: 0]
  ------------------
  765|      0|        SNMP_ZERO(user->privKey, user->privKeyLen);
  ------------------
  |  |   77|      0|#define SNMP_ZERO(s,l)	do { if (s) memset(s, 0, l); } while(0)
  |  |  ------------------
  |  |  |  Branch (77:33): [True: 0, False: 0]
  |  |  |  Branch (77:61): [Folded - Ignored]
  |  |  ------------------
  ------------------
  766|      0|        SNMP_FREE(user->privKey);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded - Ignored]
  |  |  ------------------
  ------------------
  767|      0|    }
  768|       |
  769|      0|    if (user->authKeyKu != NULL) {
  ------------------
  |  Branch (769:9): [True: 0, False: 0]
  ------------------
  770|      0|        SNMP_ZERO(user->authKeyKu, user->authKeyKuLen);
  ------------------
  |  |   77|      0|#define SNMP_ZERO(s,l)	do { if (s) memset(s, 0, l); } while(0)
  |  |  ------------------
  |  |  |  Branch (77:33): [True: 0, False: 0]
  |  |  |  Branch (77:61): [Folded - Ignored]
  |  |  ------------------
  ------------------
  771|      0|        SNMP_FREE(user->authKeyKu);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded - Ignored]
  |  |  ------------------
  ------------------
  772|      0|    }
  773|       |
  774|      0|    if (user->privKeyKu != NULL) {
  ------------------
  |  Branch (774:9): [True: 0, False: 0]
  ------------------
  775|      0|        SNMP_ZERO(user->privKeyKu, user->privKeyKuLen);
  ------------------
  |  |   77|      0|#define SNMP_ZERO(s,l)	do { if (s) memset(s, 0, l); } while(0)
  |  |  ------------------
  |  |  |  Branch (77:33): [True: 0, False: 0]
  |  |  |  Branch (77:61): [Folded - Ignored]
  |  |  ------------------
  ------------------
  776|      0|        SNMP_FREE(user->privKeyKu);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded - Ignored]
  |  |  ------------------
  ------------------
  777|      0|    }
  778|       |
  779|      0|#ifdef NETSNMP_USE_OPENSSL
  780|      0|    if (user->usmDHUserAuthKeyChange)
  ------------------
  |  Branch (780:9): [True: 0, False: 0]
  ------------------
  781|      0|    {
  782|      0|        DH_free(user->usmDHUserAuthKeyChange);
  783|      0|        user->usmDHUserAuthKeyChange = NULL;
  784|      0|    }
  785|       |
  786|      0|    if (user->usmDHUserPrivKeyChange)
  ------------------
  |  Branch (786:9): [True: 0, False: 0]
  ------------------
  787|      0|    {
  788|      0|        DH_free(user->usmDHUserPrivKeyChange);
  789|      0|        user->usmDHUserPrivKeyChange = NULL;
  790|      0|    }
  791|      0|#endif
  792|       |
  793|       |    /*
  794|       |     * FIX  Why not put this check *first?*
  795|       |     */
  796|      0|    if (user->prev != NULL && user->prev != (struct usmUser *)-1) {   /* ack, this shouldn't happen */
  ------------------
  |  Branch (796:9): [True: 0, False: 0]
  |  Branch (796:31): [True: 0, False: 0]
  ------------------
  797|      0|        user->prev->next = user->next;
  798|      0|    }
  799|      0|    if (user->next != NULL && user->next != (struct usmUser *)-1) {
  ------------------
  |  Branch (799:9): [True: 0, False: 0]
  |  Branch (799:31): [True: 0, False: 0]
  ------------------
  800|      0|        user->next->prev = user->prev;
  801|      0|        if (user->prev != NULL) /* ack this is really bad, because it means
  ------------------
  |  Branch (801:13): [True: 0, False: 0]
  ------------------
  802|       |                                 * * we'll loose the head of some structure tree */
  803|      0|            DEBUGMSGTL(("usm",
  ------------------
  |  |   68|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
  804|      0|                        "Severe: Asked to free the head of a usmUser tree somewhere."));
  805|      0|    }
  806|       |
  807|       |
  808|      0|    SNMP_ZERO(user, sizeof(*user));
  ------------------
  |  |   77|      0|#define SNMP_ZERO(s,l)	do { if (s) memset(s, 0, l); } while(0)
  |  |  ------------------
  |  |  |  Branch (77:33): [True: 0, False: 0]
  |  |  |  Branch (77:61): [Folded - Ignored]
  |  |  ------------------
  ------------------
  809|      0|    SNMP_FREE(user);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded - Ignored]
  |  |  ------------------
  ------------------
  810|       |
  811|      0|    return NULL;                /* for convenience to returns from calling functions */
  812|       |
  813|  1.74k|}                               /* end usm_free_user() */
usm_create_user_from_session:
 3601|  1.74k|{
 3602|  1.74k|    struct usmUser *user;
 3603|  1.74k|    int             user_just_created = 0;
 3604|  1.74k|    char *cp;
 3605|       |
 3606|       |    /*
 3607|       |     * If boot/time supplied set it for this engineID. Do it from hook when
 3608|       |     * creating user in case probe was sent by other means for example
 3609|       |     * asynchronously.
 3610|       |     */
 3611|  1.74k|    if (!(session->flags & SNMP_FLAGS_TIME_CREATED) &&
  ------------------
  |  |  183|  1.74k|#define SNMP_FLAGS_TIME_CREATED    0x2000
  ------------------
  |  Branch (3611:9): [True: 1.74k, False: 0]
  ------------------
 3612|  1.74k|        (session->engineBoots || session->engineTime)) {
  ------------------
  |  Branch (3612:10): [True: 0, False: 1.74k]
  |  Branch (3612:34): [True: 0, False: 1.74k]
  ------------------
 3613|      0|        set_enginetime(session->securityEngineID,
 3614|      0|                       session->securityEngineIDLen,
 3615|      0|                       session->engineBoots, session->engineTime,
 3616|      0|                       TRUE);
  ------------------
  |  |  128|      0|#define TRUE  1
  ------------------
 3617|      0|        session->flags |= SNMP_FLAGS_TIME_CREATED;
  ------------------
  |  |  183|      0|#define SNMP_FLAGS_TIME_CREATED    0x2000
  ------------------
 3618|      0|    }
 3619|       |
 3620|       |    /*
 3621|       |     * - don't create-another/copy-into user for this session by default
 3622|       |     * - bail now (no error) if we don't have an engineID
 3623|       |     */
 3624|  1.74k|    if (SNMP_FLAGS_USER_CREATED == (session->flags & SNMP_FLAGS_USER_CREATED) ||
  ------------------
  |  |  187|  1.74k|#define SNMP_FLAGS_USER_CREATED    0x200      /* USM user has been created */
  ------------------
                  if (SNMP_FLAGS_USER_CREATED == (session->flags & SNMP_FLAGS_USER_CREATED) ||
  ------------------
  |  |  187|  1.74k|#define SNMP_FLAGS_USER_CREATED    0x200      /* USM user has been created */
  ------------------
  |  Branch (3624:9): [True: 0, False: 1.74k]
  ------------------
 3625|  1.74k|        session->securityModel != SNMP_SEC_MODEL_USM ||
  ------------------
  |  |  295|  3.49k|#define SNMP_SEC_MODEL_USM		3
  ------------------
  |  Branch (3625:9): [True: 0, False: 1.74k]
  ------------------
 3626|  1.74k|        session->version != SNMP_VERSION_3 ||
  ------------------
  |  |  113|  3.49k|#define SNMP_VERSION_3     3
  ------------------
  |  Branch (3626:9): [True: 1.74k, False: 0]
  ------------------
 3627|  1.74k|        session->securityNameLen == 0 ||
  ------------------
  |  Branch (3627:9): [True: 0, False: 0]
  ------------------
 3628|  1.74k|        session->securityEngineIDLen == 0)
  ------------------
  |  Branch (3628:9): [True: 0, False: 0]
  ------------------
 3629|  1.74k|        return SNMPERR_SUCCESS;
  ------------------
  |  |  217|  1.74k|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 3630|       |
 3631|      0|    DEBUGMSGTL(("usm", "no flag defined...  continuing\n"));
  ------------------
  |  |   68|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
 3632|      0|    session->flags |= SNMP_FLAGS_USER_CREATED;
  ------------------
  |  |  187|      0|#define SNMP_FLAGS_USER_CREATED    0x200      /* USM user has been created */
  ------------------
 3633|       |
 3634|       |    /*
 3635|       |     * now that we have the engineID, create an entry in the USM list
 3636|       |     * for this user using the information in the session 
 3637|       |     */
 3638|      0|    if ((session->flags & SNMP_FLAGS_SESSION_USER) == 0)
  ------------------
  |  |  184|      0|#define SNMP_FLAGS_SESSION_USER    0x1000
  ------------------
  |  Branch (3638:9): [True: 0, False: 0]
  ------------------
 3639|      0|        user = usm_get_user_from_list(session->securityEngineID,
 3640|      0|                                      session->securityEngineIDLen,
 3641|      0|                                      session->securityName,
 3642|      0|                                      session->securityNameLen,
 3643|      0|                                      usm_get_userList(), 0);
 3644|      0|    else
 3645|      0|        user = NULL;
 3646|       |
 3647|       |
 3648|      0|    if (user) {
  ------------------
  |  Branch (3648:9): [True: 0, False: 0]
  ------------------
 3649|      0|        DEBUGMSGTL(("usm", "user exists x=%p\n", user));
  ------------------
  |  |   68|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
 3650|      0|    } else {
 3651|      0|        if (usm_build_user(&user, session) != SNMPERR_SUCCESS)
  ------------------
  |  |  217|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  |  Branch (3651:13): [True: 0, False: 0]
  ------------------
 3652|      0|            return SNMPERR_GENERR;
  ------------------
  |  |  218|      0|#define SNMPERR_GENERR			(-1)
  ------------------
 3653|      0|        user_just_created = 1;
 3654|      0|    }
 3655|       |
 3656|       |    /*
 3657|       |     * copy the auth protocol 
 3658|       |     */
 3659|      0|    if (user->authProtocol == NULL && session->securityAuthProto != NULL) {
  ------------------
  |  Branch (3659:9): [True: 0, False: 0]
  |  Branch (3659:39): [True: 0, False: 0]
  ------------------
 3660|      0|        SNMP_FREE(user->authProtocol);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded - Ignored]
  |  |  ------------------
  ------------------
 3661|      0|        user->authProtocol =
 3662|      0|            snmp_duplicate_objid(session->securityAuthProto,
 3663|      0|                                 session->securityAuthProtoLen);
 3664|      0|        if (user->authProtocol == NULL) {
  ------------------
  |  Branch (3664:13): [True: 0, False: 0]
  ------------------
 3665|      0|            usm_free_user(user);
 3666|      0|            return SNMPERR_GENERR;
  ------------------
  |  |  218|      0|#define SNMPERR_GENERR			(-1)
  ------------------
 3667|      0|        }
 3668|      0|        user->authProtocolLen = session->securityAuthProtoLen;
 3669|      0|    }
 3670|       |
 3671|       |    /*
 3672|       |     * copy the priv protocol 
 3673|       |     */
 3674|      0|    if (user->privProtocol == NULL && session->securityPrivProto != NULL) {
  ------------------
  |  Branch (3674:9): [True: 0, False: 0]
  |  Branch (3674:39): [True: 0, False: 0]
  ------------------
 3675|      0|        SNMP_FREE(user->privProtocol);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded - Ignored]
  |  |  ------------------
  ------------------
 3676|      0|        user->privProtocol =
 3677|      0|            snmp_duplicate_objid(session->securityPrivProto,
 3678|      0|                                 session->securityPrivProtoLen);
 3679|      0|        if (user->privProtocol == NULL) {
  ------------------
  |  Branch (3679:13): [True: 0, False: 0]
  ------------------
 3680|      0|            usm_free_user(user);
 3681|      0|            return SNMPERR_GENERR;
  ------------------
  |  |  218|      0|#define SNMPERR_GENERR			(-1)
  ------------------
 3682|      0|        }
 3683|      0|        user->privProtocolLen = session->securityPrivProtoLen;
 3684|      0|    }
 3685|       |
 3686|       |    /*
 3687|       |     * copy in the authentication Key.  If not localized, localize it 
 3688|       |     */
 3689|      0|    if (user->authKey == NULL) {
  ------------------
  |  Branch (3689:9): [True: 0, False: 0]
  ------------------
 3690|      0|        if (session->securityAuthLocalKey != NULL
  ------------------
  |  Branch (3690:13): [True: 0, False: 0]
  ------------------
 3691|      0|            && session->securityAuthLocalKeyLen != 0) {
  ------------------
  |  Branch (3691:16): [True: 0, False: 0]
  ------------------
 3692|       |            /* already localized key passed in.  use it */
 3693|      0|            SNMP_FREE(user->authKey);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded - Ignored]
  |  |  ------------------
  ------------------
 3694|      0|            user->authKey = netsnmp_memdup(session->securityAuthLocalKey,
 3695|      0|                                           session->securityAuthLocalKeyLen);
 3696|      0|            if (!user->authKey) {
  ------------------
  |  Branch (3696:17): [True: 0, False: 0]
  ------------------
 3697|      0|                usm_free_user(user);
 3698|      0|                return SNMPERR_GENERR;
  ------------------
  |  |  218|      0|#define SNMPERR_GENERR			(-1)
  ------------------
 3699|      0|            }
 3700|      0|            user->authKeyLen = session->securityAuthLocalKeyLen;
 3701|      0|        } else if (session->securityAuthKeyLen != 0) {
  ------------------
  |  Branch (3701:20): [True: 0, False: 0]
  ------------------
 3702|      0|            SNMP_FREE(user->authKey);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded - Ignored]
  |  |  ------------------
  ------------------
 3703|      0|            user->authKey = calloc(1, USM_LENGTH_KU_HASHBLOCK);
  ------------------
  |  |   15|      0|#define USM_LENGTH_KU_HASHBLOCK		64      /* In bytes. */
  ------------------
 3704|      0|            user->authKeyLen = USM_LENGTH_KU_HASHBLOCK;
  ------------------
  |  |   15|      0|#define USM_LENGTH_KU_HASHBLOCK		64      /* In bytes. */
  ------------------
 3705|      0|            if ((user->authKey == NULL) ||
  ------------------
  |  Branch (3705:17): [True: 0, False: 0]
  ------------------
 3706|      0|                generate_kul(user->authProtocol, user->authProtocolLen,
  ------------------
  |  Branch (3706:17): [True: 0, False: 0]
  ------------------
 3707|      0|                             user->engineID, user->engineIDLen,
 3708|      0|                             session->securityAuthKey,
 3709|      0|                             session->securityAuthKeyLen, user->authKey,
 3710|      0|                             &user->authKeyLen) != SNMPERR_SUCCESS) {
  ------------------
  |  |  217|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 3711|      0|                usm_free_user(user);
 3712|      0|                return SNMPERR_GENERR;
  ------------------
  |  |  218|      0|#define SNMPERR_GENERR			(-1)
  ------------------
 3713|      0|            }
 3714|      0|        } else if ((cp = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|      0|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (3714:20): [True: 0, False: 0]
  ------------------
 3715|      0|                                               NETSNMP_DS_LIB_AUTHLOCALIZEDKEY))) {
  ------------------
  |  |  169|      0|#define NETSNMP_DS_LIB_AUTHLOCALIZEDKEY  18
  ------------------
 3716|      0|            size_t buflen = USM_AUTH_KU_LEN;
  ------------------
  |  |  254|      0|#define USM_AUTH_KU_LEN     64
  ------------------
 3717|      0|            SNMP_FREE(user->authKey);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded - Ignored]
  |  |  ------------------
  ------------------
 3718|      0|            user->authKey = (u_char *)malloc(buflen); /* max length needed */
 3719|      0|            user->authKeyLen = 0;
 3720|       |            /* it will be a hex string */
 3721|      0|            if ((NULL == user->authKey) ||
  ------------------
  |  Branch (3721:17): [True: 0, False: 0]
  ------------------
 3722|      0|                !snmp_hex_to_binary(&user->authKey, &buflen, &user->authKeyLen,
  ------------------
  |  Branch (3722:17): [True: 0, False: 0]
  ------------------
 3723|      0|                                    0, cp)) {
 3724|      0|                usm_free_user(user);
 3725|      0|                return SNMPERR_GENERR;
  ------------------
  |  |  218|      0|#define SNMPERR_GENERR			(-1)
  ------------------
 3726|      0|            }
 3727|      0|        }
 3728|      0|    }
 3729|       |
 3730|       |    /*
 3731|       |     * copy in the privacy Key.  If not localized, localize it 
 3732|       |     */
 3733|      0|    if (user->privKey == NULL) {
  ------------------
  |  Branch (3733:9): [True: 0, False: 0]
  ------------------
 3734|       |        /** save buffer size in case we need to extend key */
 3735|      0|        int keyBufSize = USM_PRIV_KU_LEN;
  ------------------
  |  |  255|      0|#define USM_PRIV_KU_LEN     64
  ------------------
 3736|       |
 3737|      0|        DEBUGMSGTL(("usm", "copying privKey\n"));
  ------------------
  |  |   68|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
 3738|      0|        if (session->securityPrivLocalKey != NULL
  ------------------
  |  Branch (3738:13): [True: 0, False: 0]
  ------------------
 3739|      0|            && session->securityPrivLocalKeyLen != 0) {
  ------------------
  |  Branch (3739:16): [True: 0, False: 0]
  ------------------
 3740|       |            /* already localized key passed in.  use it */
 3741|      0|            SNMP_FREE(user->privKey);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded - Ignored]
  |  |  ------------------
  ------------------
 3742|      0|            user->privKey = netsnmp_memdup(session->securityPrivLocalKey,
 3743|      0|                                           session->securityPrivLocalKeyLen);
 3744|      0|            if (!user->privKey) {
  ------------------
  |  Branch (3744:17): [True: 0, False: 0]
  ------------------
 3745|      0|                usm_free_user(user);
 3746|      0|                return SNMPERR_GENERR;
  ------------------
  |  |  218|      0|#define SNMPERR_GENERR			(-1)
  ------------------
 3747|      0|            }
 3748|      0|            keyBufSize = user->privKeyLen = session->securityPrivLocalKeyLen;
 3749|      0|        } else if (session->securityPrivKeyLen != 0) {
  ------------------
  |  Branch (3749:20): [True: 0, False: 0]
  ------------------
 3750|      0|            SNMP_FREE(user->privKey);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded - Ignored]
  |  |  ------------------
  ------------------
 3751|      0|            user->privKey = calloc(1, keyBufSize);
 3752|      0|            user->privKeyLen = keyBufSize;
 3753|      0|            if ((user->privKey == NULL) ||
  ------------------
  |  Branch (3753:17): [True: 0, False: 0]
  ------------------
 3754|      0|                generate_kul(user->authProtocol, user->authProtocolLen,
  ------------------
  |  Branch (3754:17): [True: 0, False: 0]
  ------------------
 3755|      0|                             user->engineID, user->engineIDLen,
 3756|      0|                             session->securityPrivKey,
 3757|      0|                             session->securityPrivKeyLen, user->privKey,
 3758|      0|                             &user->privKeyLen) != SNMPERR_SUCCESS) {
  ------------------
  |  |  217|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 3759|      0|                usm_free_user(user);
 3760|      0|                return SNMPERR_GENERR;
  ------------------
  |  |  218|      0|#define SNMPERR_GENERR			(-1)
  ------------------
 3761|      0|            }
 3762|      0|        } else if ((cp = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|      0|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (3762:20): [True: 0, False: 0]
  ------------------
 3763|      0|                                               NETSNMP_DS_LIB_PRIVLOCALIZEDKEY))) {
  ------------------
  |  |  170|      0|#define NETSNMP_DS_LIB_PRIVLOCALIZEDKEY  19
  ------------------
 3764|      0|            size_t buflen = keyBufSize;
 3765|      0|            user->privKey = (u_char *)malloc(buflen); /* max length needed */
 3766|      0|            user->privKeyLen = 0;
 3767|       |            /* it will be a hex string */
 3768|      0|            if ((NULL == user->privKey) ||
  ------------------
  |  Branch (3768:17): [True: 0, False: 0]
  ------------------
 3769|      0|                !snmp_hex_to_binary(&user->privKey, &buflen, &user->privKeyLen,
  ------------------
  |  Branch (3769:17): [True: 0, False: 0]
  ------------------
 3770|      0|                                    0, cp)) {
 3771|      0|                usm_free_user(user);
 3772|      0|                return SNMPERR_GENERR;
  ------------------
  |  |  218|      0|#define SNMPERR_GENERR			(-1)
  ------------------
 3773|      0|            }
 3774|      0|        }
 3775|      0|        if (usm_extend_user_kul(user, keyBufSize) != SNMPERR_SUCCESS) {
  ------------------
  |  |  217|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  |  Branch (3775:13): [True: 0, False: 0]
  ------------------
 3776|      0|            usm_free_user(user);
 3777|      0|            return SNMPERR_GENERR;
  ------------------
  |  |  218|      0|#define SNMPERR_GENERR			(-1)
  ------------------
 3778|      0|        }
 3779|      0|    }
 3780|       |
 3781|      0|    if (user_just_created) {
  ------------------
  |  Branch (3781:9): [True: 0, False: 0]
  ------------------
 3782|       |        /*
 3783|       |         * add the user into the database 
 3784|       |         */
 3785|      0|        user->userStatus = RS_ACTIVE;
  ------------------
  |  |   35|      0|#define RS_ACTIVE	        1
  ------------------
 3786|      0|        user->userStorageType = ST_READONLY;
  ------------------
  |  |   54|      0|#define ST_READONLY	5
  ------------------
 3787|       |
 3788|      0|        if (session->flags & SNMP_FLAGS_SESSION_USER) {
  ------------------
  |  |  184|      0|#define SNMP_FLAGS_SESSION_USER    0x1000
  ------------------
  |  Branch (3788:13): [True: 0, False: 0]
  ------------------
 3789|      0|            if (session->sessUser)
  ------------------
  |  Branch (3789:17): [True: 0, False: 0]
  ------------------
 3790|      0|                usm_free_user(session->sessUser);
 3791|      0|            session->sessUser = user;
 3792|      0|        } else {
 3793|      0|            usm_add_user(user);
 3794|      0|        }
 3795|      0|    }
 3796|      0|    DEBUGMSGTL(("9:usm", "user created and stored in %s\n", session->flags &
  ------------------
  |  |   68|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (166:52): [True: 0, False: 0]
  |  |  |  |  |  Branch (166:64): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
 3797|      0|                SNMP_FLAGS_SESSION_USER ? "session" : "local store"));
 3798|       |
 3799|      0|    return SNMPERR_SUCCESS;
  ------------------
  |  |  217|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 3800|       |
 3801|       |
 3802|      0|}
usm_create_user:
 4095|      1|{
 4096|      1|    struct usmUser *newUser;
 4097|       |
 4098|       |    /*
 4099|       |     * create the new user 
 4100|       |     */
 4101|      1|    newUser = calloc(1, sizeof(struct usmUser));
 4102|      1|    if (newUser == NULL)
  ------------------
  |  Branch (4102:9): [True: 0, False: 1]
  ------------------
 4103|      0|        return NULL;
 4104|       |
 4105|       |    /*
 4106|       |     * fill the auth/priv protocols 
 4107|       |     */
 4108|      1|    if ((newUser->authProtocol =
  ------------------
  |  Branch (4108:9): [True: 0, False: 1]
  ------------------
 4109|      1|         snmp_duplicate_objid(usmNoAuthProtocol,
 4110|      1|                              OID_LENGTH(usmNoAuthProtocol))) ==
  ------------------
  |  |   64|      1|    (sizeof(x) / sizeof((x)[0]) +                                       \
  |  |   65|      1|     sizeof(int[-__builtin_types_compatible_p(typeof(x), typeof(&(x)[0]))]))
  ------------------
 4111|      1|        NULL)
 4112|      0|        return usm_free_user(newUser);
 4113|      1|    newUser->authProtocolLen = OID_LENGTH(usmNoAuthProtocol);
  ------------------
  |  |   64|      1|    (sizeof(x) / sizeof((x)[0]) +                                       \
  |  |   65|      1|     sizeof(int[-__builtin_types_compatible_p(typeof(x), typeof(&(x)[0]))]))
  ------------------
 4114|       |
 4115|      1|    if ((newUser->privProtocol =
  ------------------
  |  Branch (4115:9): [True: 0, False: 1]
  ------------------
 4116|      1|         snmp_duplicate_objid(usmNoPrivProtocol,
 4117|      1|                              OID_LENGTH(usmNoPrivProtocol))) ==
  ------------------
  |  |   64|      1|    (sizeof(x) / sizeof((x)[0]) +                                       \
  |  |   65|      1|     sizeof(int[-__builtin_types_compatible_p(typeof(x), typeof(&(x)[0]))]))
  ------------------
 4118|      1|        NULL)
 4119|      0|        return usm_free_user(newUser);
 4120|      1|    newUser->privProtocolLen = OID_LENGTH(usmNoPrivProtocol);
  ------------------
  |  |   64|      1|    (sizeof(x) / sizeof((x)[0]) +                                       \
  |  |   65|      1|     sizeof(int[-__builtin_types_compatible_p(typeof(x), typeof(&(x)[0]))]))
  ------------------
 4121|       |
 4122|       |    /*
 4123|       |     * set the storage type to nonvolatile, and the status to ACTIVE 
 4124|       |     */
 4125|      1|    newUser->userStorageType = ST_NONVOLATILE;
  ------------------
  |  |   52|      1|#define ST_NONVOLATILE	3
  ------------------
 4126|      1|    newUser->userStatus = RS_ACTIVE;
  ------------------
  |  |   35|      1|#define RS_ACTIVE	        1
  ------------------
 4127|      1|    return newUser;
 4128|       |
 4129|      1|}                               /* end usm_clone_user() */
get_default_authtype:
 4994|  3.49k|{
 4995|  3.49k|    if (defaultAuthType == NULL) {
  ------------------
  |  Branch (4995:9): [True: 1, False: 3.49k]
  ------------------
 4996|      1|        defaultAuthType = SNMP_DEFAULT_AUTH_PROTO;
  ------------------
  |  |  127|      1|#define SNMP_DEFAULT_AUTH_PROTO     usmHMACMD5AuthProtocol
  ------------------
 4997|      1|        defaultAuthTypeLen = SNMP_DEFAULT_AUTH_PROTOLEN;
  ------------------
  |  |  131|      1|#define SNMP_DEFAULT_AUTH_PROTOLEN  OID_LENGTH(SNMP_DEFAULT_AUTH_PROTO)
  |  |  ------------------
  |  |  |  |   64|      1|    (sizeof(x) / sizeof((x)[0]) +                                       \
  |  |  |  |   65|      1|     sizeof(int[-__builtin_types_compatible_p(typeof(x), typeof(&(x)[0]))]))
  |  |  ------------------
  ------------------
 4998|      1|    }
 4999|  3.49k|    if (len)
  ------------------
  |  Branch (4999:9): [True: 1.74k, False: 1.74k]
  ------------------
 5000|  1.74k|        *len = defaultAuthTypeLen;
 5001|  3.49k|    return defaultAuthType;
 5002|  3.49k|}
get_default_privtype:
 5016|  3.49k|{
 5017|  3.49k|    if (defaultPrivType == NULL) {
  ------------------
  |  Branch (5017:9): [True: 1, False: 3.49k]
  ------------------
 5018|      1|        defaultPrivType = SNMP_DEFAULT_PRIV_PROTO;
  ------------------
  |  |  133|      1|#define SNMP_DEFAULT_PRIV_PROTO     usmDESPrivProtocol
  ------------------
 5019|      1|        defaultPrivTypeLen = SNMP_DEFAULT_PRIV_PROTOLEN;
  ------------------
  |  |  137|      1|#define SNMP_DEFAULT_PRIV_PROTOLEN  OID_LENGTH(SNMP_DEFAULT_PRIV_PROTO)
  |  |  ------------------
  |  |  |  |   64|      1|    (sizeof(x) / sizeof((x)[0]) +                                       \
  |  |  |  |   65|      1|     sizeof(int[-__builtin_types_compatible_p(typeof(x), typeof(&(x)[0]))]))
  |  |  ------------------
  ------------------
 5020|      1|    }
 5021|  3.49k|    if (len)
  ------------------
  |  Branch (5021:9): [True: 1.74k, False: 1.74k]
  ------------------
 5022|  1.74k|        *len = defaultPrivTypeLen;
 5023|  3.49k|    return defaultPrivType;
 5024|  3.49k|}
init_usm:
 5112|      1|{
 5113|      1|    struct snmp_secmod_def *def;
 5114|      1|    char *type;
 5115|       |
 5116|      1|    DEBUGMSGTL(("init_usm", "unit_usm: %" NETSNMP_PRIo "u %" NETSNMP_PRIo "u\n",
  ------------------
  |  |   68|      1|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      1|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      1|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      1|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      1|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
 5117|      1|                usmNoPrivProtocol[0], usmNoPrivProtocol[1]));
 5118|       |
 5119|      1|    sc_init();                  /* initalize scapi code */
 5120|       |
 5121|       |    /*
 5122|       |     * register ourselves as a security service
 5123|       |     */
 5124|      1|    def = SNMP_MALLOC_STRUCT(snmp_secmod_def);
  ------------------
  |  |   69|      1|#define SNMP_MALLOC_STRUCT(s)   (struct s *) calloc(1, sizeof(struct s))
  ------------------
 5125|      1|    if (def == NULL)
  ------------------
  |  Branch (5125:9): [True: 0, False: 1]
  ------------------
 5126|      0|        return;
 5127|       |    /*
 5128|       |     * XXX: def->init_sess_secmod move stuff from snmp_api.c
 5129|       |     */
 5130|      1|    def->encode_reverse = usm_secmod_rgenerate_out_msg;
 5131|      1|    def->encode_forward = usm_secmod_generate_out_msg;
 5132|      1|    def->decode = usm_secmod_process_in_msg;
 5133|      1|    def->pdu_clone = usm_clone;
 5134|      1|    def->pdu_free_state_ref = usm_free_usmStateReference;
 5135|      1|    def->session_setup = usm_session_init;
 5136|      1|    def->handle_report = usm_handle_report;
 5137|      1|    def->probe_engineid = usm_discover_engineid;
 5138|      1|    def->post_probe_engineid = usm_create_user_from_session_hook;
 5139|      1|    if (register_sec_mod(USM_SEC_MODEL_NUMBER, "usm", def) != SNMPERR_SUCCESS) {
  ------------------
  |  |   40|      1|#define USM_SEC_MODEL_NUMBER            SNMP_SEC_MODEL_USM
  |  |  ------------------
  |  |  |  |  295|      1|#define SNMP_SEC_MODEL_USM		3
  |  |  ------------------
  ------------------
                  if (register_sec_mod(USM_SEC_MODEL_NUMBER, "usm", def) != SNMPERR_SUCCESS) {
  ------------------
  |  |  217|      1|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  |  Branch (5139:9): [True: 0, False: 1]
  ------------------
 5140|      0|        SNMP_FREE(def);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded - Ignored]
  |  |  ------------------
  ------------------
 5141|      0|        snmp_log(LOG_ERR, "could not register usm sec mod\n");
 5142|      0|        return;
 5143|      0|    }
 5144|       |
 5145|      1|    snmp_register_callback(SNMP_CALLBACK_LIBRARY,
  ------------------
  |  |   18|      1|#define SNMP_CALLBACK_LIBRARY     0
  ------------------
 5146|      1|                           SNMP_CALLBACK_POST_PREMIB_READ_CONFIG,
  ------------------
  |  |   27|      1|#define SNMP_CALLBACK_POST_PREMIB_READ_CONFIG	3
  ------------------
 5147|      1|                           init_usm_post_config, NULL);
 5148|       |
 5149|      1|    snmp_register_callback(SNMP_CALLBACK_LIBRARY,
  ------------------
  |  |   18|      1|#define SNMP_CALLBACK_LIBRARY     0
  ------------------
 5150|      1|                           SNMP_CALLBACK_SHUTDOWN,
  ------------------
  |  |   26|      1|#define SNMP_CALLBACK_SHUTDOWN		        2
  ------------------
 5151|      1|                           deinit_usm_post_config, NULL);
 5152|       |
 5153|      1|    snmp_register_callback(SNMP_CALLBACK_LIBRARY,
  ------------------
  |  |   18|      1|#define SNMP_CALLBACK_LIBRARY     0
  ------------------
 5154|      1|                           SNMP_CALLBACK_SHUTDOWN,
  ------------------
  |  |   26|      1|#define SNMP_CALLBACK_SHUTDOWN		        2
  ------------------
 5155|      1|                           free_engineID, NULL);
 5156|       |
 5157|      1|    register_config_handler("snmp", "defAuthType", snmpv3_authtype_conf,
 5158|      1|                            NULL, "MD5|SHA|SHA-512|SHA-384|SHA-256|SHA-224");
 5159|      1|    register_config_handler("snmp", "defPrivType", snmpv3_privtype_conf,
 5160|      1|                            NULL,
 5161|      1|                            "DES"
 5162|      1|#ifdef HAVE_AES
 5163|      1|                            "|AES|AES-128"
 5164|      1|#ifdef NETSNMP_DRAFT_BLUMENTHAL_AES_04
 5165|      1|                            "|AES-192|AES-256"
 5166|      1|#endif /* NETSNMP_DRAFT_BLUMENTHAL_AES_04 */
 5167|       |#else
 5168|       |                            " (AES support not available)"
 5169|       |#endif
 5170|      1|                           );
 5171|       |
 5172|       |    /*
 5173|       |     * Free stuff at shutdown time
 5174|       |     */
 5175|      1|    snmp_register_callback(SNMP_CALLBACK_LIBRARY,
  ------------------
  |  |   18|      1|#define SNMP_CALLBACK_LIBRARY     0
  ------------------
 5176|      1|                           SNMP_CALLBACK_SHUTDOWN,
  ------------------
  |  |   26|      1|#define SNMP_CALLBACK_SHUTDOWN		        2
  ------------------
 5177|      1|                           free_enginetime_on_shutdown, NULL);
 5178|       |
 5179|       |
 5180|      1|    type = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_APPTYPE);
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                  type = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_APPTYPE);
  ------------------
  |  |  157|      1|#define NETSNMP_DS_LIB_APPTYPE           6
  ------------------
 5181|       |
 5182|      1|    register_config_handler(type, "userSetAuthPass", usm_set_password,
 5183|      1|                            NULL, NULL);
 5184|      1|    register_config_handler(type, "userSetPrivPass", usm_set_password,
 5185|      1|                            NULL, NULL);
 5186|      1|    register_config_handler(type, "userSetAuthKey", usm_set_password, NULL,
 5187|      1|                            NULL);
 5188|      1|    register_config_handler(type, "userSetPrivKey", usm_set_password, NULL,
 5189|      1|                            NULL);
 5190|      1|    register_config_handler(type, "userSetAuthLocalKey", usm_set_password,
 5191|      1|                            NULL, NULL);
 5192|      1|    register_config_handler(type, "userSetPrivLocalKey", usm_set_password,
 5193|      1|                            NULL, NULL);
 5194|      1|}
snmpusm.c:usm_session_init:
 3452|  1.74k|{
 3453|  1.74k|    char *cp;
 3454|  1.74k|    size_t i;
 3455|       |    
 3456|  1.74k|    if (in_session->securityAuthProtoLen > 0) {
  ------------------
  |  Branch (3456:9): [True: 0, False: 1.74k]
  ------------------
 3457|      0|        session->securityAuthProto =
 3458|      0|            snmp_duplicate_objid(in_session->securityAuthProto,
 3459|      0|                                 in_session->securityAuthProtoLen);
 3460|      0|        if (session->securityAuthProto == NULL) {
  ------------------
  |  Branch (3460:13): [True: 0, False: 0]
  ------------------
 3461|      0|            in_session->s_snmp_errno = SNMPERR_MALLOC;
  ------------------
  |  |  279|      0|#define SNMPERR_MALLOC			(-62)
  ------------------
 3462|      0|            return SNMPERR_MALLOC;
  ------------------
  |  |  279|      0|#define SNMPERR_MALLOC			(-62)
  ------------------
 3463|      0|        }
 3464|  1.74k|    } else if (get_default_authtype(&i) != NULL) {
  ------------------
  |  Branch (3464:16): [True: 1.74k, False: 0]
  ------------------
 3465|  1.74k|        session->securityAuthProto =
 3466|  1.74k|            snmp_duplicate_objid(get_default_authtype(NULL), i);
 3467|  1.74k|        session->securityAuthProtoLen = i;
 3468|  1.74k|    }
 3469|       |
 3470|  1.74k|    if (in_session->securityPrivProtoLen > 0) {
  ------------------
  |  Branch (3470:9): [True: 0, False: 1.74k]
  ------------------
 3471|      0|        session->securityPrivProto =
 3472|      0|            snmp_duplicate_objid(in_session->securityPrivProto,
 3473|      0|                                 in_session->securityPrivProtoLen);
 3474|      0|        if (session->securityPrivProto == NULL) {
  ------------------
  |  Branch (3474:13): [True: 0, False: 0]
  ------------------
 3475|      0|            in_session->s_snmp_errno = SNMPERR_MALLOC;
  ------------------
  |  |  279|      0|#define SNMPERR_MALLOC			(-62)
  ------------------
 3476|      0|            return SNMPERR_MALLOC;
  ------------------
  |  |  279|      0|#define SNMPERR_MALLOC			(-62)
  ------------------
 3477|      0|        }
 3478|  1.74k|    } else if (get_default_privtype(&i) != NULL) {
  ------------------
  |  Branch (3478:16): [True: 1.74k, False: 0]
  ------------------
 3479|  1.74k|        session->securityPrivProto =
 3480|  1.74k|            snmp_duplicate_objid(get_default_privtype(NULL), i);
 3481|  1.74k|        session->securityPrivProtoLen = i;
 3482|  1.74k|    }
 3483|       |
 3484|  1.74k|    if ((in_session->securityAuthKeyLen <= 0) &&
  ------------------
  |  Branch (3484:9): [True: 1.74k, False: 0]
  ------------------
 3485|  1.74k|        ((cp = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|  1.74k|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (3485:9): [True: 0, False: 1.74k]
  ------------------
 3486|  1.74k|				     NETSNMP_DS_LIB_AUTHMASTERKEY)))) {
  ------------------
  |  |  167|  1.74k|#define NETSNMP_DS_LIB_AUTHMASTERKEY     16
  ------------------
 3487|      0|        size_t buflen = sizeof(session->securityAuthKey);
 3488|      0|        u_char *tmpp = session->securityAuthKey;
 3489|      0|        session->securityAuthKeyLen = 0;
 3490|       |        /* it will be a hex string */
 3491|      0|        if (!snmp_hex_to_binary(&tmpp, &buflen,
  ------------------
  |  Branch (3491:13): [True: 0, False: 0]
  ------------------
 3492|      0|                                &session->securityAuthKeyLen, 0, cp)) {
 3493|      0|            snmp_set_detail("error parsing authentication master key");
 3494|      0|            return SNMP_ERR_GENERR;
  ------------------
  |  |  217|      0|#define SNMP_ERR_GENERR	                (5)
  ------------------
 3495|      0|        }
 3496|  1.74k|    } else if ((in_session->securityAuthKeyLen <= 0) &&
  ------------------
  |  Branch (3496:16): [True: 1.74k, False: 0]
  ------------------
 3497|  1.74k|               ((cp = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|  1.74k|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (3497:17): [True: 0, False: 1.74k]
  ------------------
 3498|  1.74k|                                            NETSNMP_DS_LIB_AUTHPASSPHRASE)) ||
  ------------------
  |  |  154|  1.74k|#define NETSNMP_DS_LIB_AUTHPASSPHRASE    3
  ------------------
 3499|  1.74k|                (cp = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|  1.74k|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (3499:17): [True: 0, False: 1.74k]
  ------------------
 3500|  1.74k|                                            NETSNMP_DS_LIB_PASSPHRASE)))) {
  ------------------
  |  |  153|  1.74k|#define NETSNMP_DS_LIB_PASSPHRASE        2
  ------------------
 3501|      0|        session->securityAuthKeyLen = USM_AUTH_KU_LEN;
  ------------------
  |  |  254|      0|#define USM_AUTH_KU_LEN     64
  ------------------
 3502|      0|        if (generate_Ku(session->securityAuthProto,
  ------------------
  |  Branch (3502:13): [True: 0, False: 0]
  ------------------
 3503|      0|                        session->securityAuthProtoLen,
 3504|      0|                        (u_char *) cp, strlen(cp),
 3505|      0|                        session->securityAuthKey,
 3506|      0|                        &session->securityAuthKeyLen) != SNMPERR_SUCCESS) {
  ------------------
  |  |  217|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 3507|      0|            snmp_set_detail
 3508|      0|                ("Error generating a key (Ku) from the supplied authentication pass phrase.");
 3509|      0|            return SNMP_ERR_GENERR;
  ------------------
  |  |  217|      0|#define SNMP_ERR_GENERR	                (5)
  ------------------
 3510|      0|        }
 3511|      0|    }
 3512|       |
 3513|       |    
 3514|  1.74k|    if ((in_session->securityPrivKeyLen <= 0) &&
  ------------------
  |  Branch (3514:9): [True: 1.74k, False: 0]
  ------------------
 3515|  1.74k|        ((cp = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|  1.74k|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (3515:9): [True: 0, False: 1.74k]
  ------------------
 3516|  1.74k|				     NETSNMP_DS_LIB_PRIVMASTERKEY)))) {
  ------------------
  |  |  168|  1.74k|#define NETSNMP_DS_LIB_PRIVMASTERKEY     17
  ------------------
 3517|      0|        size_t buflen = sizeof(session->securityPrivKey);
 3518|      0|        u_char *tmpp = session->securityPrivKey;
 3519|      0|        session->securityPrivKeyLen = 0;
 3520|       |        /* it will be a hex string */
 3521|      0|        if (!snmp_hex_to_binary(&tmpp, &buflen,
  ------------------
  |  Branch (3521:13): [True: 0, False: 0]
  ------------------
 3522|      0|                                &session->securityPrivKeyLen, 0, cp)) {
 3523|      0|            snmp_set_detail("error parsing encryption master key");
 3524|      0|            return SNMP_ERR_GENERR;
  ------------------
  |  |  217|      0|#define SNMP_ERR_GENERR	                (5)
  ------------------
 3525|      0|        }
 3526|  1.74k|    } else if ((in_session->securityPrivKeyLen <= 0) &&
  ------------------
  |  Branch (3526:16): [True: 1.74k, False: 0]
  ------------------
 3527|  1.74k|               ((cp = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|  1.74k|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (3527:17): [True: 0, False: 1.74k]
  ------------------
 3528|  1.74k|                                            NETSNMP_DS_LIB_PRIVPASSPHRASE)) ||
  ------------------
  |  |  155|  1.74k|#define NETSNMP_DS_LIB_PRIVPASSPHRASE    4
  ------------------
 3529|  1.74k|                (cp = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|  1.74k|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (3529:17): [True: 0, False: 1.74k]
  ------------------
 3530|  1.74k|                                            NETSNMP_DS_LIB_PASSPHRASE)))) {
  ------------------
  |  |  153|  1.74k|#define NETSNMP_DS_LIB_PASSPHRASE        2
  ------------------
 3531|      0|        session->securityPrivKeyLen = USM_PRIV_KU_LEN;
  ------------------
  |  |  255|      0|#define USM_PRIV_KU_LEN     64
  ------------------
 3532|      0|        if (generate_Ku(session->securityAuthProto,
  ------------------
  |  Branch (3532:13): [True: 0, False: 0]
  ------------------
 3533|      0|                        session->securityAuthProtoLen,
 3534|      0|                        (u_char *) cp, strlen(cp),
 3535|      0|                        session->securityPrivKey,
 3536|      0|                        &session->securityPrivKeyLen) != SNMPERR_SUCCESS) {
  ------------------
  |  |  217|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 3537|      0|            snmp_set_detail
 3538|      0|                ("Error generating a key (Ku) from the supplied privacy pass phrase.");
 3539|      0|            return SNMP_ERR_GENERR;
  ------------------
  |  |  217|      0|#define SNMP_ERR_GENERR	                (5)
  ------------------
 3540|      0|        }
 3541|      0|    }
 3542|       |
 3543|  1.74k|    return SNMPERR_SUCCESS;
  ------------------
  |  |  217|  1.74k|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 3544|  1.74k|}
snmpusm.c:init_usm_post_config:
 5052|      1|{
 5053|      1|    size_t          salt_integer_len = sizeof(salt_integer);
 5054|       |
 5055|      1|    if (sc_random((u_char *) & salt_integer, &salt_integer_len) !=
  ------------------
  |  Branch (5055:9): [True: 0, False: 1]
  ------------------
 5056|      1|        SNMPERR_SUCCESS) {
  ------------------
  |  |  217|      1|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 5057|      0|        DEBUGMSGTL(("usm", "sc_random() failed: using time() as salt.\n"));
  ------------------
  |  |   68|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
 5058|      0|        salt_integer = (u_int) time(NULL);
 5059|      0|    }
 5060|       |
 5061|      1|#ifdef HAVE_AES
 5062|      1|    salt_integer_len = sizeof (salt_integer64_1);
 5063|      1|    if (sc_random((u_char *) & salt_integer64_1, &salt_integer_len) !=
  ------------------
  |  Branch (5063:9): [True: 0, False: 1]
  ------------------
 5064|      1|        SNMPERR_SUCCESS) {
  ------------------
  |  |  217|      1|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 5065|      0|        DEBUGMSGTL(("usm", "sc_random() failed: using time() as aes1 salt.\n"));
  ------------------
  |  |   68|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
 5066|      0|        salt_integer64_1 = (u_int) time(NULL);
 5067|      0|    }
 5068|      1|    salt_integer_len = sizeof (salt_integer64_1);
 5069|      1|    if (sc_random((u_char *) & salt_integer64_2, &salt_integer_len) !=
  ------------------
  |  Branch (5069:9): [True: 0, False: 1]
  ------------------
 5070|      1|        SNMPERR_SUCCESS) {
  ------------------
  |  |  217|      1|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 5071|      0|        DEBUGMSGTL(("usm", "sc_random() failed: using time() as aes2 salt.\n"));
  ------------------
  |  |   68|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
 5072|      0|        salt_integer64_2 = (u_int) time(NULL);
 5073|      0|    }
 5074|      1|#endif
 5075|       |
 5076|      1|#ifndef NETSNMP_DISABLE_MD5
 5077|      1|    noNameUser = usm_create_initial_user("", usmHMACMD5AuthProtocol,
 5078|      1|                                         OID_LENGTH(usmHMACMD5AuthProtocol),
  ------------------
  |  |   64|      1|    (sizeof(x) / sizeof((x)[0]) +                                       \
  |  |   65|      1|     sizeof(int[-__builtin_types_compatible_p(typeof(x), typeof(&(x)[0]))]))
  ------------------
 5079|      1|                                         SNMP_DEFAULT_PRIV_PROTO,
  ------------------
  |  |  133|      1|#define SNMP_DEFAULT_PRIV_PROTO     usmDESPrivProtocol
  ------------------
 5080|      1|                                         SNMP_DEFAULT_PRIV_PROTOLEN);
  ------------------
  |  |  137|      1|#define SNMP_DEFAULT_PRIV_PROTOLEN  OID_LENGTH(SNMP_DEFAULT_PRIV_PROTO)
  |  |  ------------------
  |  |  |  |   64|      1|    (sizeof(x) / sizeof((x)[0]) +                                       \
  |  |  |  |   65|      1|     sizeof(int[-__builtin_types_compatible_p(typeof(x), typeof(&(x)[0]))]))
  |  |  ------------------
  ------------------
 5081|       |#else
 5082|       |    noNameUser = usm_create_initial_user("", usmHMACSHA1AuthProtocol,
 5083|       |                                         OID_LENGTH(usmHMACSHA1AuthProtocol),
 5084|       |                                         SNMP_DEFAULT_PRIV_PROTO,
 5085|       |                                         SNMP_DEFAULT_PRIV_PROTOLEN);
 5086|       |#endif
 5087|       |
 5088|      1|    if ( noNameUser ) {
  ------------------
  |  Branch (5088:10): [True: 1, False: 0]
  ------------------
 5089|      1|        SNMP_FREE(noNameUser->engineID);
  ------------------
  |  |   62|      1|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 1, False: 0]
  |  |  |  Branch (62:66): [Folded - Ignored]
  |  |  ------------------
  ------------------
 5090|      1|        noNameUser->engineIDLen = 0;
 5091|      1|    }
 5092|       |
 5093|      1|    return SNMPERR_SUCCESS;
  ------------------
  |  |  217|      1|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 5094|      1|}                               /* end init_usm_post_config() */
snmpusm.c:usm_create_initial_user:
 4140|      1|{
 4141|      1|    struct usmUser *newUser = usm_create_user();
 4142|      1|    if (newUser == NULL)
  ------------------
  |  Branch (4142:9): [True: 0, False: 1]
  ------------------
 4143|      0|        return NULL;
 4144|       |
 4145|      1|    if ((newUser->name = strdup(name)) == NULL)
  ------------------
  |  Branch (4145:9): [True: 0, False: 1]
  ------------------
 4146|      0|        return usm_free_user(newUser);
 4147|       |
 4148|      1|    if ((newUser->secName = strdup(name)) == NULL)
  ------------------
  |  Branch (4148:9): [True: 0, False: 1]
  ------------------
 4149|      0|        return usm_free_user(newUser);
 4150|       |
 4151|      1|    if ((newUser->engineID =
  ------------------
  |  Branch (4151:9): [True: 0, False: 1]
  ------------------
 4152|      1|         snmpv3_generate_engineID(&newUser->engineIDLen)) == NULL)
 4153|      0|        return usm_free_user(newUser);
 4154|       |
 4155|      1|    if ((newUser->cloneFrom = (oid *) malloc(sizeof(oid) * 2)) == NULL)
  ------------------
  |  Branch (4155:9): [True: 0, False: 1]
  ------------------
 4156|      0|        return usm_free_user(newUser);
 4157|      1|    newUser->cloneFrom[0] = 0;
 4158|      1|    newUser->cloneFrom[1] = 0;
 4159|      1|    newUser->cloneFromLen = 2;
 4160|       |
 4161|      1|    SNMP_FREE(newUser->privProtocol);
  ------------------
  |  |   62|      1|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 1, False: 0]
  |  |  |  Branch (62:66): [Folded - Ignored]
  |  |  ------------------
  ------------------
 4162|      1|    if ((newUser->privProtocol = snmp_duplicate_objid(privProtocol,
  ------------------
  |  Branch (4162:9): [True: 0, False: 1]
  ------------------
 4163|      1|                                                      privProtocolLen)) ==
 4164|      1|        NULL) {
 4165|      0|        return usm_free_user(newUser);
 4166|      0|    }
 4167|      1|    newUser->privProtocolLen = privProtocolLen;
 4168|       |
 4169|      1|    SNMP_FREE(newUser->authProtocol);
  ------------------
  |  |   62|      1|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 1, False: 0]
  |  |  |  Branch (62:66): [Folded - Ignored]
  |  |  ------------------
  ------------------
 4170|      1|    if ((newUser->authProtocol = snmp_duplicate_objid(authProtocol,
  ------------------
  |  Branch (4170:9): [True: 0, False: 1]
  ------------------
 4171|      1|                                                      authProtocolLen)) ==
 4172|      1|        NULL) {
 4173|      0|        return usm_free_user(newUser);
 4174|      0|    }
 4175|      1|    newUser->authProtocolLen = authProtocolLen;
 4176|       |
 4177|      1|    newUser->userStatus = RS_ACTIVE;
  ------------------
  |  |   35|      1|#define RS_ACTIVE	        1
  ------------------
 4178|      1|    newUser->userStorageType = ST_READONLY;
  ------------------
  |  |   54|      1|#define ST_READONLY	5
  ------------------
 4179|       |
 4180|      1|    return newUser;
 4181|      1|}

setup_engineID:
  467|      1|{
  468|      1|    int             enterpriseid = htonl(NETSNMP_ENTERPRISE_OID),
  469|      1|        netsnmpoid = htonl(NETSNMP_OID),
  470|      1|        localsetup = (eidp) ? 0 : 1;
  ------------------
  |  Branch (470:22): [True: 0, False: 1]
  ------------------
  471|       |
  472|       |    /*
  473|       |     * Use local engineID if *eidp == NULL.  
  474|       |     */
  475|      1|#ifdef HAVE_GETHOSTNAME
  476|      1|    u_char          buf[SNMP_MAXBUF_SMALL];
  477|      1|    struct hostent *hent = NULL;
  478|      1|#endif
  479|      1|    u_char         *bufp = NULL;
  480|      1|    size_t          len;
  481|      1|    int             localEngineIDType = engineIDType;
  482|      1|    int             tmpint;
  483|      1|    time_t          tmptime;
  484|       |
  485|      1|    engineIDIsSet = 1;
  486|       |
  487|      1|#ifdef HAVE_GETHOSTNAME
  488|      1|#ifdef AF_INET6
  489|       |    /*
  490|       |     * see if they selected IPV4 or IPV6 support 
  491|       |     */
  492|      1|    if ((ENGINEID_TYPE_IPV6 == localEngineIDType) ||
  ------------------
  |  |   20|      1|#define ENGINEID_TYPE_IPV6    2
  ------------------
  |  Branch (492:9): [True: 0, False: 1]
  ------------------
  493|      1|        (ENGINEID_TYPE_IPV4 == localEngineIDType)) {
  ------------------
  |  |   19|      1|#define ENGINEID_TYPE_IPV4    1
  ------------------
  |  Branch (493:9): [True: 0, False: 1]
  ------------------
  494|       |        /*
  495|       |         * get the host name and save the information 
  496|       |         */
  497|      0|        gethostname((char *) buf, sizeof(buf));
  498|      0|        hent = netsnmp_gethostbyname((char *) buf);
  499|      0|        if (hent && hent->h_addrtype == AF_INET6) {
  ------------------
  |  Branch (499:13): [True: 0, False: 0]
  |  Branch (499:21): [True: 0, False: 0]
  ------------------
  500|      0|            localEngineIDType = ENGINEID_TYPE_IPV6;
  ------------------
  |  |   20|      0|#define ENGINEID_TYPE_IPV6    2
  ------------------
  501|      0|        } else {
  502|       |            /*
  503|       |             * Not IPV6 so we go with default 
  504|       |             */
  505|      0|            localEngineIDType = ENGINEID_TYPE_IPV4;
  ------------------
  |  |   19|      0|#define ENGINEID_TYPE_IPV4    1
  ------------------
  506|      0|        }
  507|      0|    }
  508|       |#else
  509|       |    /*
  510|       |     * No IPV6 support.  Check if they selected IPV6 engineID type.
  511|       |     *  If so make it IPV4 instead 
  512|       |     */
  513|       |    if (ENGINEID_TYPE_IPV6 == localEngineIDType) {
  514|       |        localEngineIDType = ENGINEID_TYPE_IPV4;
  515|       |    }
  516|       |    if (ENGINEID_TYPE_IPV4 == localEngineIDType) {
  517|       |        /*
  518|       |         * get the host name and save the information 
  519|       |         */
  520|       |        gethostname((char *) buf, sizeof(buf));
  521|       |        hent = netsnmp_gethostbyname((char *) buf);
  522|       |    }
  523|       |#endif
  524|      1|#endif                          /* HAVE_GETHOSTNAME */
  525|       |
  526|       |    /*
  527|       |     * Determine if we have text and if so setup our localEngineIDType
  528|       |     * * appropriately.  
  529|       |     */
  530|      1|    if (NULL != text) {
  ------------------
  |  Branch (530:9): [True: 0, False: 1]
  ------------------
  531|      0|        engineIDType = localEngineIDType = ENGINEID_TYPE_TEXT;
  ------------------
  |  |   22|      0|#define ENGINEID_TYPE_TEXT    4
  ------------------
  532|      0|    }
  533|       |    /*
  534|       |     * Determine length of the engineID string. 
  535|       |     */
  536|      1|    len = 5;                    /* always have 5 leading bytes */
  537|      1|    switch (localEngineIDType) {
  538|      0|    case ENGINEID_TYPE_TEXT:
  ------------------
  |  |   22|      0|#define ENGINEID_TYPE_TEXT    4
  ------------------
  |  Branch (538:5): [True: 0, False: 1]
  ------------------
  539|      0|        if (NULL == text) {
  ------------------
  |  Branch (539:13): [True: 0, False: 0]
  ------------------
  540|      0|            snmp_log(LOG_ERR,
  541|      0|                     "Can't set up engineID of type text from an empty string.\n");
  542|      0|            return -1;
  543|      0|        }
  544|      0|        len += strlen(text);    /* 5 leading bytes+text. No NULL char */
  545|      0|        break;
  546|      0|#if defined(IFHWADDRLEN) && defined(SIOCGIFHWADDR)
  547|      0|    case ENGINEID_TYPE_MACADDR:        /* MAC address */
  ------------------
  |  |   21|      0|#define ENGINEID_TYPE_MACADDR 3
  ------------------
  |  Branch (547:5): [True: 0, False: 1]
  ------------------
  548|      0|        len += 6;               /* + 6 bytes for MAC address */
  549|      0|        break;
  550|      0|#endif
  551|      0|    case ENGINEID_TYPE_IPV4:   /* IPv4 */
  ------------------
  |  |   19|      0|#define ENGINEID_TYPE_IPV4    1
  ------------------
  |  Branch (551:5): [True: 0, False: 1]
  ------------------
  552|      0|        len += 4;               /* + 4 byte IPV4 address */
  553|      0|        break;
  554|      0|    case ENGINEID_TYPE_IPV6:   /* IPv6 */
  ------------------
  |  |   20|      0|#define ENGINEID_TYPE_IPV6    2
  ------------------
  |  Branch (554:5): [True: 0, False: 1]
  ------------------
  555|      0|        len += 16;              /* + 16 byte IPV6 address */
  556|      0|        break;
  557|      1|    case ENGINEID_TYPE_NETSNMP_RND:        /* Net-SNMP specific encoding */
  ------------------
  |  |   24|      1|#define ENGINEID_TYPE_NETSNMP_RND 128
  ------------------
  |  Branch (557:5): [True: 1, False: 0]
  ------------------
  558|      1|        if (engineID)           /* already setup, keep current value */
  ------------------
  |  Branch (558:13): [True: 0, False: 1]
  ------------------
  559|      0|            return engineIDLength;
  560|      1|        if (oldEngineID) {
  ------------------
  |  Branch (560:13): [True: 0, False: 1]
  ------------------
  561|      0|            len = oldEngineIDLength;
  562|      1|        } else {
  563|      1|            len += sizeof(int) + sizeof(time_t);
  564|      1|        }
  565|      1|        break;
  566|      0|    default:
  ------------------
  |  Branch (566:5): [True: 0, False: 1]
  ------------------
  567|      0|        snmp_log(LOG_ERR,
  568|      0|                 "Unknown EngineID type requested for setup (%d).  Using IPv4.\n",
  569|      0|                 localEngineIDType);
  570|      0|        localEngineIDType = ENGINEID_TYPE_IPV4; /* make into IPV4 */
  ------------------
  |  |   19|      0|#define ENGINEID_TYPE_IPV4    1
  ------------------
  571|      0|        len += 4;               /* + 4 byte IPv4 address */
  572|      0|        break;
  573|      1|    }                           /* switch */
  574|       |
  575|       |
  576|       |    /*
  577|       |     * Allocate memory and store enterprise ID.
  578|       |     */
  579|      1|    if ((bufp = calloc(1, len)) == NULL) {
  ------------------
  |  Branch (579:9): [True: 0, False: 1]
  ------------------
  580|      0|        snmp_log_perror("setup_engineID malloc");
  581|      0|        return -1;
  582|      0|    }
  583|      1|    if (localEngineIDType == ENGINEID_TYPE_NETSNMP_RND)
  ------------------
  |  |   24|      1|#define ENGINEID_TYPE_NETSNMP_RND 128
  ------------------
  |  Branch (583:9): [True: 1, False: 0]
  ------------------
  584|       |        /*
  585|       |         * we must use the net-snmp enterprise id here, regardless 
  586|       |         */
  587|      1|        memcpy(bufp, &netsnmpoid, sizeof(netsnmpoid));    /* XXX Must be 4 bytes! */
  588|      0|    else
  589|      0|        memcpy(bufp, &enterpriseid, sizeof(enterpriseid));      /* XXX Must be 4 bytes! */
  590|       |
  591|      1|    bufp[0] |= 0x80;
  592|       |
  593|       |
  594|       |    /*
  595|       |     * Store the given text  -OR-   the first found IP address
  596|       |     *  -OR-  the MAC address  -OR-  random elements
  597|       |     * (the latter being the recommended default)
  598|       |     */
  599|      1|    switch (localEngineIDType) {
  600|      1|    case ENGINEID_TYPE_NETSNMP_RND:
  ------------------
  |  |   24|      1|#define ENGINEID_TYPE_NETSNMP_RND 128
  ------------------
  |  Branch (600:5): [True: 1, False: 0]
  ------------------
  601|      1|        if (oldEngineID) {
  ------------------
  |  Branch (601:13): [True: 0, False: 1]
  ------------------
  602|       |            /*
  603|       |             * keep our previous notion of the engineID 
  604|       |             */
  605|      0|            memcpy(bufp, oldEngineID, oldEngineIDLength);
  606|      1|        } else {
  607|       |            /*
  608|       |             * Here we've desigend our own ENGINEID that is not based on
  609|       |             * an address which may change and may even become conflicting
  610|       |             * in the future like most of the default v3 engineID types
  611|       |             * suffer from.
  612|       |             * 
  613|       |             * Ours is built from 2 fairly random elements: a random number and
  614|       |             * the current time in seconds.  This method suffers from boxes
  615|       |             * that may not have a correct clock setting and random number
  616|       |             * seed at startup, but few OSes should have that problem.
  617|       |             */
  618|      1|            bufp[4] = ENGINEID_TYPE_NETSNMP_RND;
  ------------------
  |  |   24|      1|#define ENGINEID_TYPE_NETSNMP_RND 128
  ------------------
  619|      1|            tmpint = netsnmp_random();
  620|      1|            memcpy(bufp + 5, &tmpint, sizeof(tmpint));
  621|      1|            tmptime = time(NULL);
  622|      1|            memcpy(bufp + 5 + sizeof(tmpint), &tmptime, sizeof(tmptime));
  623|      1|        }
  624|      1|        break;
  625|      0|    case ENGINEID_TYPE_TEXT:
  ------------------
  |  |   22|      0|#define ENGINEID_TYPE_TEXT    4
  ------------------
  |  Branch (625:5): [True: 0, False: 1]
  ------------------
  626|      0|        bufp[4] = ENGINEID_TYPE_TEXT;
  ------------------
  |  |   22|      0|#define ENGINEID_TYPE_TEXT    4
  ------------------
  627|      0|        memcpy((char *) bufp + 5, (text), strlen(text));
  628|      0|        break;
  629|      0|#ifdef HAVE_GETHOSTNAME
  630|      0|#ifdef AF_INET6
  631|      0|    case ENGINEID_TYPE_IPV6:
  ------------------
  |  |   20|      0|#define ENGINEID_TYPE_IPV6    2
  ------------------
  |  Branch (631:5): [True: 0, False: 1]
  ------------------
  632|      0|        bufp[4] = ENGINEID_TYPE_IPV6;
  ------------------
  |  |   20|      0|#define ENGINEID_TYPE_IPV6    2
  ------------------
  633|      0|        if (hent)
  ------------------
  |  Branch (633:13): [True: 0, False: 0]
  ------------------
  634|      0|            memcpy(bufp + 5, hent->h_addr_list[0], hent->h_length);
  635|      0|        break;
  636|      0|#endif
  637|      0|#endif
  638|      0|#if defined(IFHWADDRLEN) && defined(SIOCGIFHWADDR)
  639|      0|    case ENGINEID_TYPE_MACADDR:
  ------------------
  |  |   21|      0|#define ENGINEID_TYPE_MACADDR 3
  ------------------
  |  Branch (639:5): [True: 0, False: 1]
  ------------------
  640|      0|        {
  641|      0|            int             x;
  642|      0|            bufp[4] = ENGINEID_TYPE_MACADDR;
  ------------------
  |  |   21|      0|#define ENGINEID_TYPE_MACADDR 3
  ------------------
  643|       |            /*
  644|       |             * use default NIC if none provided 
  645|       |             */
  646|      0|            if (NULL == engineIDNic) {
  ------------------
  |  Branch (646:17): [True: 0, False: 0]
  ------------------
  647|      0|	      x = getHwAddress(DEFAULT_NIC, (char *)&bufp[5]);
  ------------------
  |  |   26|      0|#define	DEFAULT_NIC "eth0"
  ------------------
  648|      0|            } else {
  649|      0|	      x = getHwAddress((char *)engineIDNic, (char *)&bufp[5]);
  650|      0|            }
  651|      0|            if (0 != x)
  ------------------
  |  Branch (651:17): [True: 0, False: 0]
  ------------------
  652|       |                /*
  653|       |                 * function failed fill MAC address with zeros 
  654|       |                 */
  655|      0|            {
  656|      0|                memset(&bufp[5], 0, 6);
  657|      0|            }
  658|      0|        }
  659|      0|        break;
  660|      0|#endif
  661|      0|    case ENGINEID_TYPE_IPV4:
  ------------------
  |  |   19|      0|#define ENGINEID_TYPE_IPV4    1
  ------------------
  |  Branch (661:5): [True: 0, False: 1]
  ------------------
  662|      0|    default:
  ------------------
  |  Branch (662:5): [True: 0, False: 1]
  ------------------
  663|      0|        bufp[4] = ENGINEID_TYPE_IPV4;
  ------------------
  |  |   19|      0|#define ENGINEID_TYPE_IPV4    1
  ------------------
  664|      0|#ifdef HAVE_GETHOSTNAME
  665|      0|        if (hent && hent->h_addrtype == AF_INET) {
  ------------------
  |  Branch (665:13): [True: 0, False: 0]
  |  Branch (665:21): [True: 0, False: 0]
  ------------------
  666|      0|            memcpy(bufp + 5, hent->h_addr_list[0], hent->h_length);
  667|      0|        } else {                /* Unknown address type.  Default to 127.0.0.1. */
  668|       |
  669|      0|            bufp[5] = 127;
  670|      0|            bufp[6] = 0;
  671|      0|            bufp[7] = 0;
  672|      0|            bufp[8] = 1;
  673|      0|        }
  674|       |#else                           /* HAVE_GETHOSTNAME */
  675|       |        /*
  676|       |         * Unknown address type.  Default to 127.0.0.1. 
  677|       |         */
  678|       |        bufp[5] = 127;
  679|       |        bufp[6] = 0;
  680|       |        bufp[7] = 0;
  681|       |        bufp[8] = 1;
  682|       |#endif                          /* HAVE_GETHOSTNAME */
  683|      0|        break;
  684|      1|    }
  685|       |
  686|       |    /*
  687|       |     * Pass the string back to the calling environment, or use it for
  688|       |     * our local engineID.
  689|       |     */
  690|      1|    if (localsetup) {
  ------------------
  |  Branch (690:9): [True: 1, False: 0]
  ------------------
  691|      1|        SNMP_FREE(engineID);
  ------------------
  |  |   62|      1|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 1]
  |  |  |  Branch (62:66): [Folded - Ignored]
  |  |  ------------------
  ------------------
  692|      1|        engineID = bufp;
  693|      1|        engineIDLength = len;
  694|       |
  695|      1|    } else {
  696|      0|        *eidp = bufp;
  697|      0|    }
  698|       |
  699|       |
  700|      1|    return len;
  701|       |
  702|      1|}                               /* end setup_engineID() */
init_snmpv3:
  973|      1|{
  974|      1|    netsnmp_get_monotonic_clock(&snmpv3starttime);
  975|       |
  976|      1|    if (!type)
  ------------------
  |  Branch (976:9): [True: 0, False: 1]
  ------------------
  977|      0|        type = "__snmpapp__";
  978|       |
  979|       |    /*
  980|       |     * we need to be called back later 
  981|       |     */
  982|      1|    snmp_register_callback(SNMP_CALLBACK_LIBRARY,
  ------------------
  |  |   18|      1|#define SNMP_CALLBACK_LIBRARY     0
  ------------------
  983|      1|                           SNMP_CALLBACK_POST_READ_CONFIG,
  ------------------
  |  |   24|      1|#define SNMP_CALLBACK_POST_READ_CONFIG	        0
  ------------------
  984|      1|                           init_snmpv3_post_config, NULL);
  985|       |
  986|      1|    snmp_register_callback(SNMP_CALLBACK_LIBRARY,
  ------------------
  |  |   18|      1|#define SNMP_CALLBACK_LIBRARY     0
  ------------------
  987|      1|                           SNMP_CALLBACK_POST_PREMIB_READ_CONFIG,
  ------------------
  |  |   27|      1|#define SNMP_CALLBACK_POST_PREMIB_READ_CONFIG	3
  ------------------
  988|      1|                           init_snmpv3_post_premib_config, NULL);
  989|       |    /*
  990|       |     * we need to be called back later 
  991|       |     */
  992|      1|    snmp_register_callback(SNMP_CALLBACK_LIBRARY, SNMP_CALLBACK_STORE_DATA,
  ------------------
  |  |   18|      1|#define SNMP_CALLBACK_LIBRARY     0
  ------------------
                  snmp_register_callback(SNMP_CALLBACK_LIBRARY, SNMP_CALLBACK_STORE_DATA,
  ------------------
  |  |   25|      1|#define SNMP_CALLBACK_STORE_DATA	        1
  ------------------
  993|      1|                           snmpv3_store, (void *) strdup(type));
  994|       |
  995|       |    /*
  996|       |     * initialize submodules 
  997|       |     */
  998|       |    /*
  999|       |     * NOTE: this must be after the callbacks are registered above,
 1000|       |     * since they need to be called before the USM callbacks. 
 1001|       |     */
 1002|      1|    init_secmod();
 1003|       |
 1004|       |    /*
 1005|       |     * register all our configuration handlers (ack, there's a lot) 
 1006|       |     */
 1007|       |
 1008|       |    /*
 1009|       |     * handle engineID setup before everything else which may depend on it 
 1010|       |     */
 1011|      1|    register_prenetsnmp_mib_handler(type, "engineID", engineID_conf, NULL,
 1012|      1|                                    "string");
 1013|      1|    register_prenetsnmp_mib_handler(type, "oldEngineID", oldengineID_conf,
 1014|      1|                                    NULL, NULL);
 1015|      1|    register_prenetsnmp_mib_handler(type, "exactEngineID", exactEngineID_conf,
 1016|      1|                                    NULL, NULL);
 1017|      1|    register_prenetsnmp_mib_handler(type, "engineIDType",
 1018|      1|                                    engineIDType_conf, NULL, "num");
 1019|      1|    register_prenetsnmp_mib_handler(type, "engineIDNic", engineIDNic_conf,
 1020|      1|                                    NULL, "string");
 1021|      1|    register_config_handler(type, "engineBoots", engineBoots_conf, NULL,
 1022|      1|                            NULL);
 1023|       |
 1024|       |    /*
 1025|       |     * default store config entries 
 1026|       |     */
 1027|      1|    netsnmp_ds_register_config(ASN_OCTET_STR, "snmp", "defSecurityName",
  ------------------
  |  |   78|      1|#define ASN_OCTET_STR	    0x04U
  ------------------
 1028|      1|			       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_SECNAME);
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              			       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_SECNAME);
  ------------------
  |  |  151|      1|#define NETSNMP_DS_LIB_SECNAME           0
  ------------------
 1029|      1|    netsnmp_ds_register_config(ASN_OCTET_STR, "snmp", "defContext", 
  ------------------
  |  |   78|      1|#define ASN_OCTET_STR	    0x04U
  ------------------
 1030|      1|			       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_CONTEXT);
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              			       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_CONTEXT);
  ------------------
  |  |  152|      1|#define NETSNMP_DS_LIB_CONTEXT           1
  ------------------
 1031|      1|    netsnmp_ds_register_config(ASN_OCTET_STR, "snmp", "defPassphrase",
  ------------------
  |  |   78|      1|#define ASN_OCTET_STR	    0x04U
  ------------------
 1032|      1|                               NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1033|      1|                               NETSNMP_DS_LIB_PASSPHRASE);
  ------------------
  |  |  153|      1|#define NETSNMP_DS_LIB_PASSPHRASE        2
  ------------------
 1034|      1|    netsnmp_ds_register_config(ASN_OCTET_STR, "snmp", "defAuthPassphrase",
  ------------------
  |  |   78|      1|#define ASN_OCTET_STR	    0x04U
  ------------------
 1035|      1|                               NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1036|      1|                               NETSNMP_DS_LIB_AUTHPASSPHRASE);
  ------------------
  |  |  154|      1|#define NETSNMP_DS_LIB_AUTHPASSPHRASE    3
  ------------------
 1037|      1|    netsnmp_ds_register_config(ASN_OCTET_STR, "snmp", "defPrivPassphrase",
  ------------------
  |  |   78|      1|#define ASN_OCTET_STR	    0x04U
  ------------------
 1038|      1|                               NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1039|      1|                               NETSNMP_DS_LIB_PRIVPASSPHRASE);
  ------------------
  |  |  155|      1|#define NETSNMP_DS_LIB_PRIVPASSPHRASE    4
  ------------------
 1040|      1|    netsnmp_ds_register_config(ASN_OCTET_STR, "snmp", "defAuthMasterKey",
  ------------------
  |  |   78|      1|#define ASN_OCTET_STR	    0x04U
  ------------------
 1041|      1|                               NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1042|      1|                               NETSNMP_DS_LIB_AUTHMASTERKEY);
  ------------------
  |  |  167|      1|#define NETSNMP_DS_LIB_AUTHMASTERKEY     16
  ------------------
 1043|      1|    netsnmp_ds_register_config(ASN_OCTET_STR, "snmp", "defPrivMasterKey",
  ------------------
  |  |   78|      1|#define ASN_OCTET_STR	    0x04U
  ------------------
 1044|      1|                               NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1045|      1|                               NETSNMP_DS_LIB_PRIVMASTERKEY);
  ------------------
  |  |  168|      1|#define NETSNMP_DS_LIB_PRIVMASTERKEY     17
  ------------------
 1046|      1|    netsnmp_ds_register_config(ASN_OCTET_STR, "snmp", "defAuthLocalizedKey",
  ------------------
  |  |   78|      1|#define ASN_OCTET_STR	    0x04U
  ------------------
 1047|      1|                               NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1048|      1|                               NETSNMP_DS_LIB_AUTHLOCALIZEDKEY);
  ------------------
  |  |  169|      1|#define NETSNMP_DS_LIB_AUTHLOCALIZEDKEY  18
  ------------------
 1049|      1|    netsnmp_ds_register_config(ASN_OCTET_STR, "snmp", "defPrivLocalizedKey",
  ------------------
  |  |   78|      1|#define ASN_OCTET_STR	    0x04U
  ------------------
 1050|      1|                               NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1051|      1|                               NETSNMP_DS_LIB_PRIVLOCALIZEDKEY);
  ------------------
  |  |  170|      1|#define NETSNMP_DS_LIB_PRIVLOCALIZEDKEY  19
  ------------------
 1052|      1|    register_config_handler("snmp", "defVersion", version_conf, NULL,
 1053|      1|                            "1|2c|3");
 1054|       |
 1055|      1|    register_config_handler("snmp", "defSecurityLevel",
 1056|      1|                            snmpv3_secLevel_conf, NULL,
 1057|      1|                            "noAuthNoPriv|authNoPriv|authPriv");
 1058|      1|}
init_snmpv3_post_config:
 1068|      1|{
 1069|       |
 1070|      1|    size_t          engineIDLen;
 1071|      1|    u_char         *c_engineID;
 1072|      1|    u_long          localEngineTime;
 1073|      1|    u_long          localEngineBoots;
 1074|       |
 1075|      1|    c_engineID = snmpv3_generate_engineID(&engineIDLen);
 1076|       |
 1077|      1|    if (!c_engineID || engineIDLen == 0) {
  ------------------
  |  Branch (1077:9): [True: 0, False: 1]
  |  Branch (1077:24): [True: 0, False: 1]
  ------------------
 1078|       |        /*
 1079|       |         * Something went wrong - help! 
 1080|       |         */
 1081|      0|        SNMP_FREE(c_engineID);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1082|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  218|      0|#define SNMPERR_GENERR			(-1)
  ------------------
 1083|      0|    }
 1084|       |
 1085|       |    /*
 1086|       |     * if our engineID has changed at all, the boots record must be set to 1 
 1087|       |     */
 1088|      1|    if (engineIDLen != oldEngineIDLength ||
  ------------------
  |  Branch (1088:9): [True: 1, False: 0]
  ------------------
 1089|      1|        oldEngineID == NULL || c_engineID == NULL ||
  ------------------
  |  Branch (1089:9): [True: 0, False: 0]
  |  Branch (1089:32): [True: 0, False: 0]
  ------------------
 1090|      1|        memcmp(oldEngineID, c_engineID, engineIDLen) != 0) {
  ------------------
  |  Branch (1090:9): [True: 0, False: 0]
  ------------------
 1091|      1|        engineBoots = 1;
 1092|      1|    }
 1093|       |
 1094|      1|#ifdef NETSNMP_SECMOD_USM
 1095|       |    /*
 1096|       |     * for USM set our local engineTime in the LCD timing cache 
 1097|       |     */
 1098|      1|    localEngineTime = snmpv3_local_snmpEngineTime();
 1099|      1|    localEngineBoots = snmpv3_local_snmpEngineBoots();
 1100|      1|    set_enginetime(c_engineID, engineIDLen,
 1101|      1|                   localEngineBoots,
 1102|      1|                   localEngineTime, TRUE);
  ------------------
  |  |  128|      1|#define TRUE  1
  ------------------
 1103|      1|#endif /* NETSNMP_SECMOD_USM */
 1104|       |
 1105|      1|    SNMP_FREE(c_engineID);
  ------------------
  |  |   62|      1|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 1, False: 0]
  |  |  |  Branch (62:66): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1106|      1|    return SNMPERR_SUCCESS;
  ------------------
  |  |  217|      1|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 1107|      1|}
init_snmpv3_post_premib_config:
 1112|      1|{
 1113|      1|    if (!engineIDIsSet)
  ------------------
  |  Branch (1113:9): [True: 1, False: 0]
  ------------------
 1114|      1|        setup_engineID(NULL, NULL);
 1115|       |
 1116|      1|    return SNMPERR_SUCCESS;
  ------------------
  |  |  217|      1|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 1117|      1|}
snmpv3_local_snmpEngineBoots:
 1155|      1|{
 1156|      1|    return engineBoots;
 1157|      1|}
snmpv3_get_engineID:
 1177|      2|{
 1178|       |    /*
 1179|       |     * Sanity check.
 1180|       |     */
 1181|      2|    if (!buf || (buflen < engineIDLength)) {
  ------------------
  |  Branch (1181:9): [True: 0, False: 2]
  |  Branch (1181:17): [True: 0, False: 2]
  ------------------
 1182|      0|        return 0;
 1183|      0|    }
 1184|      2|    if (!engineID) {
  ------------------
  |  Branch (1184:9): [True: 0, False: 2]
  ------------------
 1185|      0|        return 0;
 1186|      0|    }
 1187|       |
 1188|      2|    memcpy(buf, engineID, engineIDLength);
 1189|      2|    return engineIDLength;
 1190|       |
 1191|      2|}                               /* end snmpv3_get_engineID() */
snmpv3_generate_engineID:
 1247|      2|{
 1248|      2|    u_char         *newID;
 1249|      2|    newID = (u_char *) malloc(engineIDLength);
 1250|       |
 1251|      2|    if (newID) {
  ------------------
  |  Branch (1251:9): [True: 2, False: 0]
  ------------------
 1252|      2|        *length = snmpv3_get_engineID(newID, engineIDLength);
 1253|      2|        if (*length == 0) {
  ------------------
  |  Branch (1253:13): [True: 0, False: 2]
  ------------------
 1254|      0|            SNMP_FREE(newID);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1255|      0|            newID = NULL;
 1256|      0|        }
 1257|      2|    }
 1258|      2|    return newID;
 1259|       |
 1260|      2|}                               /* end snmpv3_generate_engineID() */
snmpv3_local_snmpEngineTime:
 1274|      2|{
 1275|       |#ifdef NETSNMP_FEATURE_CHECKING
 1276|       |    netsnmp_feature_require(calculate_sectime_diff)
 1277|       |#endif /* NETSNMP_FEATURE_CHECKING */
 1278|       |
 1279|      2|    static uint32_t last_engineTime;
 1280|      2|    struct timeval  now;
 1281|      2|    uint32_t engineTime;
 1282|       |
 1283|      2|    netsnmp_get_monotonic_clock(&now);
 1284|      2|    engineTime = calculate_sectime_diff(&now, &snmpv3starttime) & 0x7fffffffL;
 1285|      2|    if (engineTime < last_engineTime)
  ------------------
  |  Branch (1285:9): [True: 0, False: 2]
  ------------------
 1286|      0|        engineBoots++;
 1287|      2|    last_engineTime = engineTime;
 1288|      2|    return engineTime;
 1289|      2|}

strlcpy:
   26|  10.9k|{ 
   27|  10.9k|	size_t src_len = strlen(src); 
   28|  10.9k|	size_t new_len; 
   29|       |
   30|  10.9k|	if (len == 0) {
  ------------------
  |  Branch (30:6): [True: 0, False: 10.9k]
  ------------------
   31|      0|		return (src_len);
   32|      0|	}
   33|       |
   34|  10.9k|        if (src_len >= len) {
  ------------------
  |  Branch (34:13): [True: 0, False: 10.9k]
  ------------------
   35|      0|		new_len = len - 1;
   36|  10.9k|	} else {
   37|  10.9k|                new_len = src_len;
   38|  10.9k|	}
   39|       |
   40|  10.9k|        memcpy(dest, src, new_len); 
   41|  10.9k|	dest[new_len] = '\0'; 
   42|  10.9k|	return (src_len); 
   43|  10.9k|}

calculate_sectime_diff:
 1176|      2|{
 1177|      2|    struct timeval  diff;
 1178|       |
 1179|      2|    NETSNMP_TIMERSUB(now, then, &diff);
  ------------------
  |  |  173|      2|#define NETSNMP_TIMERSUB(a, b, res) do {                        \
  |  |  174|      2|    (res)->tv_sec  = (a)->tv_sec  - (b)->tv_sec - 1;            \
  |  |  175|      2|    (res)->tv_usec = (a)->tv_usec - (b)->tv_usec + 1000000L;    \
  |  |  176|      2|    if ((res)->tv_usec >= 1000000L) {                           \
  |  |  ------------------
  |  |  |  Branch (176:9): [True: 2, False: 0]
  |  |  ------------------
  |  |  177|      2|        (res)->tv_usec -= 1000000L;                             \
  |  |  178|      2|        (res)->tv_sec++;                                        \
  |  |  179|      2|    }                                                           \
  |  |  180|      2|} while (0)
  |  |  ------------------
  |  |  |  Branch (180:10): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1180|      2|    return (u_int)(diff.tv_sec + (diff.tv_usec >= 500000L));
 1181|      2|}

snmp_realloc:
  163|  5.72k|{
  164|  5.72k|    u_char         *new_buf = NULL;
  165|  5.72k|    size_t          new_buf_len = 0;
  166|       |
  167|  5.72k|    if (buf == NULL) {
  ------------------
  |  Branch (167:9): [True: 0, False: 5.72k]
  ------------------
  168|      0|        return 0;
  169|      0|    }
  170|       |
  171|  5.72k|    if (*buf_len <= 255) {
  ------------------
  |  Branch (171:9): [True: 5.67k, False: 54]
  ------------------
  172|  5.67k|        new_buf_len = *buf_len + 256;
  173|  5.67k|    } else if (*buf_len > 255 && *buf_len <= 8191) {
  ------------------
  |  Branch (173:16): [True: 54, False: 0]
  |  Branch (173:34): [True: 54, False: 0]
  ------------------
  174|     54|        new_buf_len = *buf_len * 2;
  175|     54|    } else if (*buf_len > 8191) {
  ------------------
  |  Branch (175:16): [True: 0, False: 0]
  ------------------
  176|      0|        new_buf_len = *buf_len + 8192;
  177|      0|    }
  178|       |
  179|  5.72k|    if (*buf == NULL) {
  ------------------
  |  Branch (179:9): [True: 5.56k, False: 163]
  ------------------
  180|  5.56k|        new_buf = malloc(new_buf_len);
  181|  5.56k|    } else {
  182|    163|        new_buf = realloc(*buf, new_buf_len);
  183|    163|    }
  184|       |
  185|  5.72k|    if (new_buf != NULL) {
  ------------------
  |  Branch (185:9): [True: 5.72k, False: 0]
  ------------------
  186|  5.72k|        *buf = new_buf;
  187|  5.72k|        *buf_len = new_buf_len;
  188|  5.72k|        return 1;
  189|  5.72k|    } else {
  190|      0|        return 0;
  191|      0|    }
  192|  5.72k|}
snmp_strcat:
  197|  3.69k|{
  198|  3.69k|    if (buf == NULL || buf_len == NULL || out_len == NULL) {
  ------------------
  |  Branch (198:9): [True: 0, False: 3.69k]
  |  Branch (198:24): [True: 0, False: 3.69k]
  |  Branch (198:43): [True: 0, False: 3.69k]
  ------------------
  199|      0|        return 0;
  200|      0|    }
  201|       |
  202|  3.69k|    if (s == NULL) {
  ------------------
  |  Branch (202:9): [True: 0, False: 3.69k]
  ------------------
  203|       |        /*
  204|       |         * Appending a NULL string always succeeds since it is a NOP.  
  205|       |         */
  206|      0|        return 1;
  207|      0|    }
  208|       |
  209|  4.38k|    while ((*out_len + strlen((const char *) s) + 1) >= *buf_len) {
  ------------------
  |  Branch (209:12): [True: 686, False: 3.69k]
  ------------------
  210|    686|        if (!(allow_realloc && snmp_realloc(buf, buf_len))) {
  ------------------
  |  Branch (210:15): [True: 686, False: 0]
  |  Branch (210:32): [True: 686, False: 0]
  ------------------
  211|      0|            return 0;
  212|      0|        }
  213|    686|    }
  214|       |
  215|  3.69k|    if (!*buf)
  ------------------
  |  Branch (215:9): [True: 0, False: 3.69k]
  ------------------
  216|      0|        return 0;
  217|       |
  218|  3.69k|    strcpy((char *) (*buf + *out_len), (const char *) s);
  219|  3.69k|    *out_len += strlen((char *) (*buf + *out_len));
  220|  3.69k|    return 1;
  221|  3.69k|}
netsnmp_memdup:
  281|  2.33k|{
  282|  2.33k|    void *to = NULL;
  283|       |
  284|  2.33k|    if (from) {
  ------------------
  |  Branch (284:9): [True: 2.33k, False: 0]
  ------------------
  285|  2.33k|        to = malloc(size);
  286|  2.33k|        if (to)
  ------------------
  |  Branch (286:13): [True: 2.33k, False: 0]
  ------------------
  287|  2.33k|            memcpy(to, from, size);
  288|  2.33k|    }
  289|  2.33k|    return to;
  290|  2.33k|}                               /* end netsnmp_memdup() */
netsnmp_strdup_and_null:
  362|  1.74k|{
  363|  1.74k|    char         *ret;
  364|       |
  365|  1.74k|    if (from_len > 0 && from[from_len - 1] == '\0')
  ------------------
  |  Branch (365:9): [True: 1.74k, False: 0]
  |  Branch (365:25): [True: 0, False: 1.74k]
  ------------------
  366|      0|        from_len--;
  367|  1.74k|    ret = malloc(from_len + 1);
  368|  1.74k|    if (ret) {
  ------------------
  |  Branch (368:9): [True: 1.74k, False: 0]
  ------------------
  369|  1.74k|        memcpy(ret, from, from_len);
  370|  1.74k|        ret[from_len] = '\0';
  371|  1.74k|    }
  372|  1.74k|    return ret;
  373|  1.74k|}
netsnmp_get_monotonic_clock:
  950|      4|{
  951|      4|#if defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC)
  952|      4|    struct timespec ts;
  953|      4|    int res;
  954|       |
  955|      4|    res = clock_gettime(CLOCK_MONOTONIC, &ts);
  956|      4|    if (res >= 0) {
  ------------------
  |  Branch (956:9): [True: 4, False: 0]
  ------------------
  957|      4|        tv->tv_sec = ts.tv_sec;
  958|      4|        tv->tv_usec = ts.tv_nsec / 1000;
  959|      4|    } else {
  960|      0|        gettimeofday(tv, NULL);
  961|      0|    }
  962|       |#elif defined(WIN32)
  963|       |    /*
  964|       |     * Windows: return tick count. Note: the rate at which the tick count
  965|       |     * increases is not adjusted by the time synchronization algorithm, so
  966|       |     * expect an error of <= 100 ppm for the rate at which this clock
  967|       |     * increases.
  968|       |     */
  969|       |    typedef ULONGLONG (WINAPI * pfGetTickCount64)(void);
  970|       |    static int s_initialized;
  971|       |    static pfGetTickCount64 s_pfGetTickCount64;
  972|       |    uint64_t now64;
  973|       |
  974|       |    if (!s_initialized) {
  975|       |        HMODULE hKernel32 = GetModuleHandle("kernel32");
  976|       |        s_pfGetTickCount64 =
  977|       |            (pfGetTickCount64) GetProcAddress(hKernel32, "GetTickCount64");
  978|       |        s_initialized = TRUE;
  979|       |    }
  980|       |
  981|       |    if (s_pfGetTickCount64) {
  982|       |        /* Windows Vista, Windows 2008 or any later Windows version */
  983|       |        now64 = (*s_pfGetTickCount64)();
  984|       |    } else {
  985|       |        /* Windows XP, Windows 2003 or any earlier Windows version */
  986|       |        static uint32_t s_wraps, s_last;
  987|       |        uint32_t now;
  988|       |
  989|       |        now = GetTickCount();
  990|       |        if (now < s_last)
  991|       |            s_wraps++;
  992|       |        s_last = now;
  993|       |        now64 = ((uint64_t)s_wraps << 32) | now;
  994|       |    }
  995|       |    tv->tv_sec = now64 / 1000;
  996|       |    tv->tv_usec = (now64 % 1000) * 1000;
  997|       |#else
  998|       |    /* At least FreeBSD 4 doesn't provide monotonic clock support. */
  999|       |#warning Not sure how to query a monotonically increasing clock on your system. \
 1000|       |Timers will not work correctly if the system clock is adjusted by e.g. ntpd.
 1001|       |    gettimeofday(tv, NULL);
 1002|       |#endif
 1003|      4|}
netsnmp_getenv:
 1189|     17|{
 1190|     17|#if !defined (WIN32) && !defined (cygwin)
 1191|     17|  return (getenv(name));
 1192|       |#else
 1193|       |  char *temp = NULL;  
 1194|       |  HKEY hKey;
 1195|       |  unsigned char * key_value = NULL;
 1196|       |  DWORD key_value_size = 0;
 1197|       |  DWORD key_value_type = 0;
 1198|       |  DWORD getenv_worked = 0;
 1199|       |
 1200|       |  DEBUGMSGTL(("read_config", "netsnmp_getenv called with name: %s\n",name));
 1201|       |
 1202|       |  if (!(name))
 1203|       |    return NULL;
 1204|       |  
 1205|       |  /* Try environment variable first */ 
 1206|       |  temp = getenv(name);
 1207|       |  if (temp) {
 1208|       |    getenv_worked = 1;
 1209|       |    DEBUGMSGTL(("read_config", "netsnmp_getenv will return from ENV: %s\n",temp));
 1210|       |  }
 1211|       |  
 1212|       |  /* Next try HKCU */
 1213|       |  if (temp == NULL)
 1214|       |  {
 1215|       |    if (getenv("SNMP_IGNORE_WINDOWS_REGISTRY"))
 1216|       |      return NULL;
 1217|       |
 1218|       |    if (RegOpenKeyExA(
 1219|       |          HKEY_CURRENT_USER, 
 1220|       |          "SOFTWARE\\Net-SNMP", 
 1221|       |          0, 
 1222|       |          KEY_QUERY_VALUE, 
 1223|       |          &hKey) == ERROR_SUCCESS) {   
 1224|       |      
 1225|       |      if (RegQueryValueExA(
 1226|       |            hKey, 
 1227|       |            name, 
 1228|       |            NULL, 
 1229|       |            &key_value_type, 
 1230|       |            NULL,               /* Just get the size */
 1231|       |            &key_value_size) == ERROR_SUCCESS) {
 1232|       |
 1233|       |        SNMP_FREE(key_value);
 1234|       |
 1235|       |        /* Allocate memory needed +1 to allow RegQueryValueExA to NULL terminate the
 1236|       |         * string data in registry is missing one (which is unlikely).
 1237|       |         */
 1238|       |        key_value = malloc((sizeof(char) * key_value_size)+sizeof(char));
 1239|       |        
 1240|       |        if (RegQueryValueExA(
 1241|       |              hKey, 
 1242|       |              name, 
 1243|       |              NULL, 
 1244|       |              &key_value_type, 
 1245|       |              key_value, 
 1246|       |              &key_value_size) == ERROR_SUCCESS) {
 1247|       |        }
 1248|       |        temp = (char *) key_value;
 1249|       |      }
 1250|       |      RegCloseKey(hKey);
 1251|       |      if (temp)
 1252|       |        DEBUGMSGTL(("read_config", "netsnmp_getenv will return from HKCU: %s\n",temp));
 1253|       |    }
 1254|       |  }
 1255|       |
 1256|       |  /* Next try HKLM */
 1257|       |  if (temp == NULL)
 1258|       |  {
 1259|       |    if (RegOpenKeyExA(
 1260|       |          HKEY_LOCAL_MACHINE, 
 1261|       |          "SOFTWARE\\Net-SNMP", 
 1262|       |          0, 
 1263|       |          KEY_QUERY_VALUE, 
 1264|       |          &hKey) == ERROR_SUCCESS) {   
 1265|       |      
 1266|       |      if (RegQueryValueExA(
 1267|       |            hKey, 
 1268|       |            name, 
 1269|       |            NULL, 
 1270|       |            &key_value_type, 
 1271|       |            NULL,               /* Just get the size */
 1272|       |            &key_value_size) == ERROR_SUCCESS) {
 1273|       |
 1274|       |        SNMP_FREE(key_value);
 1275|       |
 1276|       |        /* Allocate memory needed +1 to allow RegQueryValueExA to NULL terminate the
 1277|       |         * string data in registry is missing one (which is unlikely).
 1278|       |         */
 1279|       |        key_value = malloc((sizeof(char) * key_value_size)+sizeof(char));
 1280|       |        
 1281|       |        if (RegQueryValueExA(
 1282|       |              hKey, 
 1283|       |              name, 
 1284|       |              NULL, 
 1285|       |              &key_value_type, 
 1286|       |              key_value, 
 1287|       |              &key_value_size) == ERROR_SUCCESS) {
 1288|       |        }
 1289|       |        temp = (char *) key_value;
 1290|       |
 1291|       |      }
 1292|       |      RegCloseKey(hKey);
 1293|       |      if (temp)
 1294|       |        DEBUGMSGTL(("read_config", "netsnmp_getenv will return from HKLM: %s\n",temp));
 1295|       |    }
 1296|       |  }
 1297|       |  
 1298|       |  if (temp && !getenv_worked) {
 1299|       |    setenv(name, temp, 1);
 1300|       |    SNMP_FREE(temp);
 1301|       |  }
 1302|       |
 1303|       |  DEBUGMSGTL(("read_config", "netsnmp_getenv returning: %s\n",getenv(name)));
 1304|       |
 1305|       |  return(getenv(name));
 1306|       |#endif
 1307|     17|}

netsnmp_aal5pvc_ctor:
  371|      1|{
  372|      1|    aal5pvcDomain.name = netsnmp_AAL5PVCDomain;
  373|      1|    aal5pvcDomain.name_length = OID_LENGTH(netsnmp_AAL5PVCDomain);
  ------------------
  |  |   64|      1|    (sizeof(x) / sizeof((x)[0]) +                                       \
  |  |   65|      1|     sizeof(int[-__builtin_types_compatible_p(typeof(x), typeof(&(x)[0]))]))
  ------------------
  374|      1|    aal5pvcDomain.prefix = calloc(3, sizeof(char *));
  375|      1|    if (!aal5pvcDomain.prefix) {
  ------------------
  |  Branch (375:9): [True: 0, False: 1]
  ------------------
  376|      0|        snmp_log(LOG_ERR, "calloc() failed - out of memory\n");
  377|      0|        return;
  378|      0|    }
  379|      1|    aal5pvcDomain.prefix[0] = "aal5pvc";
  380|      1|    aal5pvcDomain.prefix[1] = "pvc";
  381|       |
  382|      1|    aal5pvcDomain.f_create_from_tstring_new = netsnmp_aal5pvc_create_tstring;
  383|      1|    aal5pvcDomain.f_create_from_ostring     = netsnmp_aal5pvc_create_ostring;
  384|       |
  385|      1|    netsnmp_tdomain_register(&aal5pvcDomain);
  386|      1|}

free_alias_config:
   61|      1|free_alias_config(void) {
   62|      1|    netsnmp_free_all_list_data(alias_memory);
   63|      1|    alias_memory = NULL;
   64|      1|}
netsnmp_alias_ctor:
   98|      1|{
   99|      1|    aliasDomain.name = netsnmp_snmpALIASDomain;
  100|      1|    aliasDomain.name_length = OID_LENGTH(netsnmp_snmpALIASDomain);
  ------------------
  |  |   64|      1|    (sizeof(x) / sizeof((x)[0]) +                                       \
  |  |   65|      1|     sizeof(int[-__builtin_types_compatible_p(typeof(x), typeof(&(x)[0]))]))
  ------------------
  101|      1|    aliasDomain.prefix = calloc(2, sizeof(char *));
  102|      1|    if (!aliasDomain.prefix) {
  ------------------
  |  Branch (102:9): [True: 0, False: 1]
  ------------------
  103|      0|        snmp_log(LOG_ERR, "calloc() failed - out of memory\n");
  104|      0|        return;
  105|      0|    }
  106|      1|    aliasDomain.prefix[0] = "alias";
  107|       |
  108|      1|    aliasDomain.f_create_from_tstring_new = netsnmp_alias_create_tstring;
  109|      1|    aliasDomain.f_create_from_ostring     = netsnmp_alias_create_ostring;
  110|       |
  111|      1|    netsnmp_tdomain_register(&aliasDomain);
  112|       |
  113|      1|    register_config_handler("snmp", "alias", parse_alias_config,
  114|      1|                            free_alias_config, "NAME TRANSPORT_DEFINITION");
  115|      1|}

netsnmp_dtlsudp_ctor:
 1652|      1|{
 1653|      1|    static const char indexname[] = "_netsnmp_addr_info";
 1654|      1|    static const char *prefixes[] = { "dtlsudp", "dtls"
 1655|      1|#ifdef NETSNMP_TRANSPORT_UDPIPV6_DOMAIN
 1656|      1|                                      , "dtlsudp6", "dtls6"
 1657|      1|#endif
 1658|      1|    };
 1659|      1|    int i, num_prefixes = sizeof(prefixes) / sizeof(char *);
 1660|      1|#ifdef NETSNMP_TRANSPORT_UDPIPV6_DOMAIN
 1661|      1|    static const char indexname6[] = "_netsnmp_addr_info6";
 1662|      1|#endif
 1663|       |
 1664|      1|    DEBUGMSGTL(("dtlsudp", "registering DTLS constructor\n"));
  ------------------
  |  |   68|      1|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1665|       |
 1666|       |    /* config settings */
 1667|       |
 1668|      1|#ifdef NETSNMP_TRANSPORT_UDPIPV6_DOMAIN
 1669|      1|    if (!openssl_addr_index6)
  ------------------
  |  Branch (1669:9): [True: 1, False: 0]
  ------------------
 1670|      1|        openssl_addr_index6 =
 1671|      1|            SSL_get_ex_new_index(0, NETSNMP_REMOVE_CONST(void *, indexname6),
 1672|      1|                                 NULL, NULL, NULL);
 1673|      1|#endif
 1674|       |
 1675|      1|    dtlsudpDomain.name = netsnmpDTLSUDPDomain;
 1676|      1|    dtlsudpDomain.name_length = netsnmpDTLSUDPDomain_len;
 1677|      1|    dtlsudpDomain.prefix = calloc(num_prefixes + 1, sizeof(char *));
 1678|      1|    if (!dtlsudpDomain.prefix) {
  ------------------
  |  Branch (1678:9): [True: 0, False: 1]
  ------------------
 1679|      0|        snmp_log(LOG_ERR, "calloc() failed - out of memory\n");
 1680|      0|        return;
 1681|      0|    }
 1682|      5|    for (i = 0; i < num_prefixes; ++ i)
  ------------------
  |  Branch (1682:17): [True: 4, False: 1]
  ------------------
 1683|      4|        dtlsudpDomain.prefix[i] = prefixes[i];
 1684|       |
 1685|      1|    dtlsudpDomain.f_create_from_tstring_new = netsnmp_dtlsudp_create_tstring;
 1686|      1|    dtlsudpDomain.f_create_from_ostring     = netsnmp_dtlsudp_create_ostring;
 1687|       |
 1688|      1|    if (!openssl_addr_index)
  ------------------
  |  Branch (1688:9): [True: 1, False: 0]
  ------------------
 1689|      1|        openssl_addr_index =
 1690|      1|            SSL_get_ex_new_index(0, NETSNMP_REMOVE_CONST(void *, indexname),
 1691|      1|                                 NULL, NULL, NULL);
 1692|       |
 1693|      1|    netsnmp_tdomain_register(&dtlsudpDomain);
 1694|      1|}

netsnmp_ipx_ctor:
  476|      1|{
  477|      1|    ipxDomain.name = netsnmpIPXDomain;
  478|      1|    ipxDomain.name_length = netsnmpIPXDomain_len;
  479|      1|    ipxDomain.prefix = calloc(2, sizeof(char *));
  480|      1|    if (!ipxDomain.prefix) {
  ------------------
  |  Branch (480:9): [True: 0, False: 1]
  ------------------
  481|      0|        snmp_log(LOG_ERR, "calloc() failed - out of memory\n");
  482|      0|        return;
  483|      0|    }
  484|      1|    ipxDomain.prefix[0] = "ipx";
  485|       |
  486|      1|    ipxDomain.f_create_from_tstring_new = netsnmp_ipx_create_tstring;
  487|      1|    ipxDomain.f_create_from_ostring     = netsnmp_ipx_create_ostring;
  488|       |
  489|      1|    netsnmp_tdomain_register(&ipxDomain);
  490|      1|}

netsnmp_std_ctor:
  268|      1|{
  269|      1|    stdDomain.name = netsnmp_snmpSTDDomain;
  270|      1|    stdDomain.name_length = OID_LENGTH(netsnmp_snmpSTDDomain);
  ------------------
  |  |   64|      1|    (sizeof(x) / sizeof((x)[0]) +                                       \
  |  |   65|      1|     sizeof(int[-__builtin_types_compatible_p(typeof(x), typeof(&(x)[0]))]))
  ------------------
  271|      1|    stdDomain.prefix = calloc(2, sizeof(char *));
  272|      1|    if (!stdDomain.prefix) {
  ------------------
  |  Branch (272:9): [True: 0, False: 1]
  ------------------
  273|      0|        snmp_log(LOG_ERR, "calloc() failed - out of memory\n");
  274|      0|        return;
  275|      0|    }
  276|      1|    stdDomain.prefix[0] = "std";
  277|       |
  278|      1|    stdDomain.f_create_from_tstring_new = netsnmp_std_create_tstring;
  279|      1|    stdDomain.f_create_from_ostring     = netsnmp_std_create_ostring;
  280|       |
  281|      1|    netsnmp_tdomain_register(&stdDomain);
  282|      1|}

netsnmp_tcp_ctor:
  354|      1|{
  355|      1|    tcpDomain.name = netsnmp_snmpTCPDomain;
  356|      1|    tcpDomain.name_length = OID_LENGTH(netsnmp_snmpTCPDomain);
  ------------------
  |  |   64|      1|    (sizeof(x) / sizeof((x)[0]) +                                       \
  |  |   65|      1|     sizeof(int[-__builtin_types_compatible_p(typeof(x), typeof(&(x)[0]))]))
  ------------------
  357|      1|    tcpDomain.prefix = calloc(2, sizeof(char *));
  358|      1|    if (!tcpDomain.prefix) {
  ------------------
  |  Branch (358:9): [True: 0, False: 1]
  ------------------
  359|      0|        snmp_log(LOG_ERR, "calloc() failed - out of memory\n");
  360|      0|        return;
  361|      0|    }
  362|      1|    tcpDomain.prefix[0] = "tcp";
  363|       |
  364|      1|    tcpDomain.f_create_from_tstring_new = netsnmp_tcp_create_tstring;
  365|      1|    tcpDomain.f_create_from_ostring     = netsnmp_tcp_create_ostring;
  366|       |
  367|      1|    netsnmp_tdomain_register(&tcpDomain);
  368|      1|}

netsnmp_tcpipv6_ctor:
  364|      1|{
  365|      1|    tcp6Domain.name = netsnmp_TCPIPv6Domain;
  366|      1|    tcp6Domain.name_length = OID_LENGTH(netsnmp_TCPIPv6Domain);
  ------------------
  |  |   64|      1|    (sizeof(x) / sizeof((x)[0]) +                                       \
  |  |   65|      1|     sizeof(int[-__builtin_types_compatible_p(typeof(x), typeof(&(x)[0]))]))
  ------------------
  367|      1|    tcp6Domain.f_create_from_tstring_new = netsnmp_tcp6_create_tstring;
  368|      1|    tcp6Domain.f_create_from_ostring     = netsnmp_tcp6_create_ostring;
  369|      1|    tcp6Domain.prefix = calloc(4, sizeof(char *));
  370|      1|    if (!tcp6Domain.prefix) {
  ------------------
  |  Branch (370:9): [True: 0, False: 1]
  ------------------
  371|      0|        snmp_log(LOG_ERR, "calloc() failed - out of memory\n");
  372|      0|        return;
  373|      0|    }
  374|      1|    tcp6Domain.prefix[0] = "tcp6";
  375|      1|    tcp6Domain.prefix[1] = "tcpv6";
  376|      1|    tcp6Domain.prefix[2] = "tcpipv6";
  377|       |
  378|      1|    netsnmp_tdomain_register(&tcp6Domain);
  379|      1|}

netsnmp_tlsbase_ctor:
  887|      1|netsnmp_tlsbase_ctor(void) {
  888|       |
  889|       |    /* bootstrap ssl since we'll need it */
  890|      1|    netsnmp_init_openssl();
  891|       |
  892|       |    /* the private client cert to authenticate with */
  893|      1|    netsnmp_ds_register_config(ASN_OCTET_STR, "snmp", "extraX509SubDir",
  ------------------
  |  |   78|      1|#define ASN_OCTET_STR	    0x04U
  ------------------
  894|      1|                               NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  895|      1|                               NETSNMP_DS_LIB_CERT_EXTRA_SUBDIR);
  ------------------
  |  |  177|      1|#define NETSNMP_DS_LIB_CERT_EXTRA_SUBDIR 26
  ------------------
  896|       |
  897|       |    /* Do we have a CRL list? */
  898|      1|    netsnmp_ds_register_config(ASN_OCTET_STR, "snmp", "x509CRLFile",
  ------------------
  |  |   78|      1|#define ASN_OCTET_STR	    0x04U
  ------------------
  899|      1|                               NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  900|      1|                               NETSNMP_DS_LIB_X509_CRL_FILE);
  ------------------
  |  |  179|      1|#define NETSNMP_DS_LIB_X509_CRL_FILE     28
  ------------------
  901|       |
  902|       |    /* What TLS algorithms should be use */
  903|      1|    netsnmp_ds_register_config(ASN_OCTET_STR, "snmp", "tlsAlgorithms",
  ------------------
  |  |   78|      1|#define ASN_OCTET_STR	    0x04U
  ------------------
  904|      1|                               NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  905|      1|                               NETSNMP_DS_LIB_TLS_ALGORITMS);
  ------------------
  |  |  180|      1|#define NETSNMP_DS_LIB_TLS_ALGORITMS     29
  ------------------
  906|       |
  907|       |    /* What TLS version should be used at least */
  908|      1|    netsnmp_ds_register_config(ASN_OCTET_STR, "snmp", "tlsMinVersion",
  ------------------
  |  |   78|      1|#define ASN_OCTET_STR	    0x04U
  ------------------
  909|      1|                               NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  910|      1|                               NETSNMP_DS_LIB_TLS_MIN_VERSION);
  ------------------
  |  |  187|      1|#define NETSNMP_DS_LIB_TLS_MIN_VERSION   36
  ------------------
  911|       |
  912|       |    /* What TLS version should be used at max */
  913|      1|    netsnmp_ds_register_config(ASN_OCTET_STR, "snmp", "tlsMaxVersion",
  ------------------
  |  |   78|      1|#define ASN_OCTET_STR	    0x04U
  ------------------
  914|      1|                               NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  915|      1|                               NETSNMP_DS_LIB_TLS_MAX_VERSION);
  ------------------
  |  |  188|      1|#define NETSNMP_DS_LIB_TLS_MAX_VERSION   37
  ------------------
  916|       |
  917|       |    /*
  918|       |     * for the client
  919|       |     */
  920|       |
  921|       |    /* the public client cert to authenticate with */
  922|      1|    register_config_handler("snmp", "clientCert", _parse_client_cert, NULL,
  923|      1|                            NULL);
  924|       |
  925|       |    /*
  926|       |     * for the server
  927|       |     */
  928|       |
  929|       |    /* The X509 server key to use */
  930|      1|    register_config_handler("snmp", "serverCert", _parse_server_cert, NULL,
  931|      1|                            NULL);
  932|       |    /*
  933|       |     * remove cert config ambiguity: localCert, peerCert
  934|       |     */
  935|      1|    netsnmp_ds_register_config(ASN_OCTET_STR, "snmp", "localCert",
  ------------------
  |  |   78|      1|#define ASN_OCTET_STR	    0x04U
  ------------------
  936|      1|                               NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  937|      1|                               NETSNMP_DS_LIB_TLS_LOCAL_CERT);
  ------------------
  |  |  181|      1|#define NETSNMP_DS_LIB_TLS_LOCAL_CERT    30
  ------------------
  938|      1|    netsnmp_ds_register_config(ASN_OCTET_STR, "snmp", "peerCert",
  ------------------
  |  |   78|      1|#define ASN_OCTET_STR	    0x04U
  ------------------
  939|      1|                               NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  940|      1|                               NETSNMP_DS_LIB_TLS_PEER_CERT);
  ------------------
  |  |  182|      1|#define NETSNMP_DS_LIB_TLS_PEER_CERT     31
  ------------------
  941|       |
  942|       |    /*
  943|       |     * register our boot-strapping needs
  944|       |     */
  945|      1|    snmp_register_callback(SNMP_CALLBACK_LIBRARY,
  ------------------
  |  |   18|      1|#define SNMP_CALLBACK_LIBRARY     0
  ------------------
  946|      1|			   SNMP_CALLBACK_POST_PREMIB_READ_CONFIG,
  ------------------
  |  |   27|      1|#define SNMP_CALLBACK_POST_PREMIB_READ_CONFIG	3
  ------------------
  947|      1|			   tls_bootstrap, NULL);
  948|       |
  949|      1|}
snmpTLSBaseDomain.c:tls_bootstrap:
  839|      1|tls_bootstrap(int majorid, int minorid, void *serverarg, void *clientarg) {
  840|      1|    char indexname[] = "_netsnmp_verify_info";
  841|       |
  842|       |    /* don't do this more than once */
  843|      1|    if (have_done_bootstrap)
  ------------------
  |  Branch (843:9): [True: 0, False: 1]
  ------------------
  844|      0|        return 0;
  845|      1|    have_done_bootstrap = 1;
  846|       |
  847|      1|    netsnmp_certs_load();
  848|       |
  849|      1|    openssl_local_index =
  850|      1|        SSL_get_ex_new_index(0, indexname, NULL, NULL, NULL);
  851|       |
  852|      1|    return 0;
  853|      1|}

netsnmp_tlstcp_ctor:
 1074|      1|{
 1075|      1|    DEBUGMSGTL(("tlstcp", "registering TLS constructor\n"));
  ------------------
  |  |   68|      1|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  146|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (146:29): [True: 0, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  166|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  156|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  149|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  157|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (68:70): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1076|       |
 1077|       |    /* config settings */
 1078|       |
 1079|      1|    tlstcpDomain.name = netsnmpTLSTCPDomain;
 1080|      1|    tlstcpDomain.name_length = netsnmpTLSTCPDomain_len;
 1081|      1|    tlstcpDomain.prefix = calloc(3, sizeof(char *));
 1082|      1|    if (!tlstcpDomain.prefix) {
  ------------------
  |  Branch (1082:9): [True: 0, False: 1]
  ------------------
 1083|      0|        snmp_log(LOG_ERR, "calloc() failed - out of memory\n");
 1084|      0|        return;
 1085|      0|    }
 1086|      1|    tlstcpDomain.prefix[0] = "tlstcp";
 1087|      1|    tlstcpDomain.prefix[1] = "tls";
 1088|       |
 1089|      1|    tlstcpDomain.f_create_from_tstring_new = netsnmp_tlstcp_create_tstring;
 1090|      1|    tlstcpDomain.f_create_from_ostring     = netsnmp_tlstcp_create_ostring;
 1091|       |
 1092|      1|    netsnmp_tdomain_register(&tlstcpDomain);
 1093|      1|}

netsnmp_udp_ctor:
  703|      1|{
  704|      1|    udpDomain.name = netsnmpUDPDomain;
  705|      1|    udpDomain.name_length = netsnmpUDPDomain_len;
  706|      1|    udpDomain.prefix = calloc(2, sizeof(char *));
  707|      1|    if (!udpDomain.prefix) {
  ------------------
  |  Branch (707:9): [True: 0, False: 1]
  ------------------
  708|      0|        snmp_log(LOG_ERR, "calloc() failed - out of memory\n");
  709|      0|        return;
  710|      0|    }
  711|      1|    udpDomain.prefix[0] = "udp";
  712|       |
  713|      1|    udpDomain.f_create_from_tstring_new = netsnmp_udp_create_tstring;
  714|      1|    udpDomain.f_create_from_tspec       = netsnmp_udp_create_tspec;
  715|      1|    udpDomain.f_create_from_ostring     = netsnmp_udp_create_ostring;
  716|       |
  717|      1|    netsnmp_tdomain_register(&udpDomain);
  718|      1|}

netsnmp_udpipv6_ctor:
  985|      1|{
  986|      1|    udp6Domain.name = netsnmp_UDPIPv6Domain;
  987|      1|    udp6Domain.name_length = OID_LENGTH(netsnmp_UDPIPv6Domain);
  ------------------
  |  |   64|      1|    (sizeof(x) / sizeof((x)[0]) +                                       \
  |  |   65|      1|     sizeof(int[-__builtin_types_compatible_p(typeof(x), typeof(&(x)[0]))]))
  ------------------
  988|      1|    udp6Domain.f_create_from_tstring_new = netsnmp_udp6_create_tstring;
  989|      1|    udp6Domain.f_create_from_tspec       = netsnmp_udp6_create_tspec;
  990|      1|    udp6Domain.f_create_from_ostring     = netsnmp_udp6_create_ostring;
  991|      1|    udp6Domain.prefix = calloc(5, sizeof(char *));
  992|      1|    if (!udp6Domain.prefix) {
  ------------------
  |  Branch (992:9): [True: 0, False: 1]
  ------------------
  993|      0|        snmp_log(LOG_ERR, "calloc() failed - out of memory\n");
  994|      0|        return;
  995|      0|    }
  996|      1|    udp6Domain.prefix[0] = "udp6";
  997|      1|    udp6Domain.prefix[1] = "ipv6";
  998|      1|    udp6Domain.prefix[2] = "udpv6";
  999|      1|    udp6Domain.prefix[3] = "udpipv6";
 1000|       |
 1001|      1|    netsnmp_tdomain_register(&udp6Domain);
 1002|      1|}

netsnmp_udpshared_ctor:
  451|      1|{
  452|      1|    static netsnmp_tdomain domain;
  453|      1|    static int done = 0;
  454|       |
  455|      1|    if (done)
  ------------------
  |  Branch (455:9): [True: 0, False: 1]
  ------------------
  456|      0|        return;
  457|      1|    done = 1;
  458|       |
  459|      1|    domain.name = netsnmpUDPsharedDomain;
  460|      1|    domain.name_length = netsnmpUDPsharedDomain_len;
  461|       |
  462|      1|    domain.prefix = calloc(2, sizeof(char *));
  463|      1|    if (!domain.prefix) {
  ------------------
  |  Branch (463:9): [True: 0, False: 1]
  ------------------
  464|      0|        snmp_log(LOG_ERR, "calloc() failed - out of memory\n");
  465|      0|        return;
  466|      0|    }
  467|      1|    domain.prefix[0] = "udpshared";
  468|       |
  469|      1|    domain.f_create_from_tstring_new = netsnmp_udpshared_create_tstring;
  470|      1|    domain.f_create_from_tspec       = netsnmp_udpshared_create_tspec;
  471|      1|    domain.f_create_from_ostring     = netsnmp_udpshared_create_ostring;
  472|       |
  473|      1|    netsnmp_tdomain_register(&domain);
  474|      1|}

netsnmp_unix_ctor:
  519|      1|{
  520|      1|    unixDomain.name = netsnmp_UnixDomain;
  521|      1|    unixDomain.name_length = OID_LENGTH(netsnmp_UnixDomain);
  ------------------
  |  |   64|      1|    (sizeof(x) / sizeof((x)[0]) +                                       \
  |  |   65|      1|     sizeof(int[-__builtin_types_compatible_p(typeof(x), typeof(&(x)[0]))]))
  ------------------
  522|      1|    unixDomain.prefix = calloc(2, sizeof(char *));
  523|      1|    if (!unixDomain.prefix) {
  ------------------
  |  Branch (523:9): [True: 0, False: 1]
  ------------------
  524|      0|        snmp_log(LOG_ERR, "calloc() failed - out of memory\n");
  525|      0|        return;
  526|      0|    }
  527|      1|    unixDomain.prefix[0] = "unix";
  528|       |
  529|      1|    unixDomain.f_create_from_tstring_new = netsnmp_unix_create_tstring;
  530|      1|    unixDomain.f_create_from_ostring     = netsnmp_unix_create_ostring;
  531|       |
  532|      1|    netsnmp_tdomain_register(&unixDomain);
  533|      1|}

init_vacm:
   85|      1|{
   86|       |    /* views for access via get/set/send-notifications */
   87|      1|    se_add_pair_to_slist(VACM_VIEW_ENUM_NAME, strdup("read"),
  ------------------
  |  |  103|      1|#define VACM_VIEW_ENUM_NAME "vacmviews"
  ------------------
   88|      1|                         VACM_VIEW_READ);
  ------------------
  |  |   77|      1|#define VACM_VIEW_READ     0
  ------------------
   89|      1|    se_add_pair_to_slist(VACM_VIEW_ENUM_NAME, strdup("write"),
  ------------------
  |  |  103|      1|#define VACM_VIEW_ENUM_NAME "vacmviews"
  ------------------
   90|      1|                         VACM_VIEW_WRITE);
  ------------------
  |  |   78|      1|#define VACM_VIEW_WRITE    1
  ------------------
   91|      1|    se_add_pair_to_slist(VACM_VIEW_ENUM_NAME, strdup("notify"),
  ------------------
  |  |  103|      1|#define VACM_VIEW_ENUM_NAME "vacmviews"
  ------------------
   92|      1|                         VACM_VIEW_NOTIFY);
  ------------------
  |  |   79|      1|#define VACM_VIEW_NOTIFY   2
  ------------------
   93|       |
   94|       |    /* views for permissions when receiving notifications */
   95|      1|    se_add_pair_to_slist(VACM_VIEW_ENUM_NAME, strdup("log"),
  ------------------
  |  |  103|      1|#define VACM_VIEW_ENUM_NAME "vacmviews"
  ------------------
   96|      1|                         VACM_VIEW_LOG);
  ------------------
  |  |   82|      1|#define VACM_VIEW_LOG      3
  ------------------
   97|      1|    se_add_pair_to_slist(VACM_VIEW_ENUM_NAME, strdup("execute"),
  ------------------
  |  |  103|      1|#define VACM_VIEW_ENUM_NAME "vacmviews"
  ------------------
   98|      1|                         VACM_VIEW_EXECUTE);
  ------------------
  |  |   83|      1|#define VACM_VIEW_EXECUTE  4
  ------------------
   99|      1|    se_add_pair_to_slist(VACM_VIEW_ENUM_NAME, strdup("net"),
  ------------------
  |  |  103|      1|#define VACM_VIEW_ENUM_NAME "vacmviews"
  ------------------
  100|      1|                         VACM_VIEW_NET);
  ------------------
  |  |   84|      1|#define VACM_VIEW_NET      5
  ------------------
  101|      1|}

snmpfuzz_recv:
   50|  10.4k|{
   51|  10.4k|    if (bufsiz > recv_datalen) {
  ------------------
  |  Branch (51:9): [True: 1.74k, False: 8.72k]
  ------------------
   52|  1.74k|        memcpy(buf, recv_data, recv_datalen);
   53|  1.74k|        return recv_datalen;
   54|  8.72k|    } else {
   55|  8.72k|        return -1;
   56|  8.72k|    }
   57|  10.4k|}
fuzz_fake_pcap:
   71|  1.74k|{
   72|  1.74k|    netsnmp_large_fd_set lfdset;
   73|       |
   74|  1.74k|    recv_data = buf;
   75|  1.74k|    recv_datalen = len;
   76|       |
   77|  1.74k|    netsnmp_large_fd_set_init(&lfdset, FD_SETSIZE);
   78|  1.74k|    netsnmp_large_fd_setfd(FAKE_FD, &lfdset);
  ------------------
  |  |   42|  1.74k|#define FAKE_FD 3
  ------------------
   79|  1.74k|    snmp_read2(&lfdset);
   80|  1.74k|    netsnmp_large_fd_set_cleanup(&lfdset);
   81|  1.74k|}
LLVMFuzzerTestOneInput:
   85|  1.74k|{
   86|  1.74k|    netsnmp_session *ss;
   87|  1.74k|    netsnmp_transport *transport;
   88|       |
   89|  1.74k|    u_char         *fuzz_buf = malloc(size + 1);
   90|  1.74k|    memcpy(fuzz_buf, data, size);
   91|  1.74k|    fuzz_buf[size] = '\0';
   92|       |
   93|  1.74k|    ss = SNMP_MALLOC_TYPEDEF(netsnmp_session);
  ------------------
  |  |   73|  1.74k|#define SNMP_MALLOC_TYPEDEF(td)  (td *) calloc(1, sizeof(td))
  ------------------
   94|       |
   95|       |    /*
   96|       |     * We allocate with malloc to avoid constants
   97|       |     */
   98|  1.74k|    char          **fake_argv = malloc(sizeof(char *) * 3);
   99|  1.74k|    fake_argv[0] = strdup("snmp_e2e_fuzzer");
  100|  1.74k|    fake_argv[1] = strdup("-Dall");
  101|  1.74k|    fake_argv[2] = strdup("localhost");
  102|       |
  103|  1.74k|    snmp_parse_args(3, fake_argv, ss, "", NULL);
  104|       |
  105|  1.74k|    transport = SNMP_MALLOC_TYPEDEF(netsnmp_transport);
  ------------------
  |  |   73|  1.74k|#define SNMP_MALLOC_TYPEDEF(td)  (td *) calloc(1, sizeof(td))
  ------------------
  106|  1.74k|    transport->sock = FAKE_FD;
  ------------------
  |  |   42|  1.74k|#define FAKE_FD 3
  ------------------
  107|  1.74k|    transport->f_recv = snmpfuzz_recv;
  108|       |
  109|  1.74k|    ss->callback = snmpfuzz_callback;
  110|  1.74k|    ss->callback_magic = (void *) NULL;
  111|  1.74k|    ss->securityModel = SNMP_SEC_MODEL_USM;
  ------------------
  |  |  295|  1.74k|#define SNMP_SEC_MODEL_USM		3
  ------------------
  112|  1.74k|    create_user_from_session(ss);
  113|       |
  114|       |    /*
  115|       |     * Use snamp_add() to specify transport explicitly
  116|       |     */
  117|  1.74k|    snmp_add(ss, transport, NULL, NULL);
  118|       |
  119|  1.74k|    fuzz_fake_pcap(fuzz_buf, size);
  120|       |
  121|  1.74k|    snmp_close(ss);
  122|       |    /* To do: register session 'ss' properly and remove the call below. */
  123|  1.74k|    netsnmp_cleanup_session(ss);
  124|  1.74k|    free(ss);
  125|  1.74k|    free(fuzz_buf);
  126|       |
  127|  1.74k|    free(fake_argv[0]);
  128|  1.74k|    free(fake_argv[1]);
  129|  1.74k|    free(fake_argv[2]);
  130|  1.74k|    free(fake_argv);
  131|       |
  132|  1.74k|    return 0;
  133|  1.74k|}
snmp_e2e_fuzzer.c:snmpfuzz_callback:
   62|      8|{
   63|       |    /*
   64|       |     * We leave this empty for now
   65|       |     */
   66|      8|    return 0;
   67|      8|}

