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

asn_parse_nlength:
  325|  63.0k|{
  326|  63.0k|    int len_len;
  327|       |
  328|  63.0k|    if (pkt_len < 1)
  ------------------
  |  Branch (328:9): [True: 0, False: 63.0k]
  ------------------
  329|      0|        return NULL;               /* always too short */
  330|       |
  331|  63.0k|    if (NULL == pkt || NULL == data_len)
  ------------------
  |  Branch (331:9): [True: 0, False: 63.0k]
  |  Branch (331:24): [True: 0, False: 63.0k]
  ------------------
  332|      0|        return NULL;
  333|       |
  334|  63.0k|    *data_len = 0;
  335|       |
  336|  63.0k|    if (*pkt & 0x80) {
  ------------------
  |  Branch (336:9): [True: 3.70k, False: 59.3k]
  ------------------
  337|       |        /*
  338|       |         * long length; first byte is length of length (after masking high bit)
  339|       |         */
  340|  3.70k|        len_len = (int) ((*pkt & ~0x80) + 1);
  341|  3.70k|        if (pkt_len < len_len)
  ------------------
  |  Branch (341:13): [True: 94, False: 3.61k]
  ------------------
  342|     94|            return NULL;           /* still too short for length and data */
  343|       |
  344|       |        /* now we know we have enough data to parse length */
  345|  3.61k|        if (NULL == asn_parse_length(pkt, data_len))
  ------------------
  |  Branch (345:13): [True: 685, False: 2.93k]
  ------------------
  346|    685|            return NULL;           /* propagate error from asn_parse_length */
  347|  59.3k|    } else {
  348|       |        /*
  349|       |         * short length; first byte is the length
  350|       |         */
  351|  59.3k|        len_len = 1;
  352|  59.3k|        *data_len = *pkt;
  353|  59.3k|    }
  354|       |
  355|  62.2k|    if ((*data_len + len_len) > pkt_len)
  ------------------
  |  Branch (355:9): [True: 95, False: 62.1k]
  ------------------
  356|     95|        return NULL;
  357|       |
  358|  62.1k|    return (pkt + len_len);
  359|  62.2k|}
asn_check_packet:
  484|  20.2k|{
  485|  20.2k|    u_long          asn_length;
  486|       |
  487|  20.2k|    if (len < 2)
  ------------------
  |  Branch (487:9): [True: 40, False: 20.1k]
  ------------------
  488|     40|        return 0;               /* always too short */
  489|       |
  490|  20.1k|    if (*pkt != (u_char) (ASN_SEQUENCE | ASN_CONSTRUCTOR))
  ------------------
  |  |   84|  20.1k|#define ASN_SEQUENCE	    0x10U
  ------------------
                  if (*pkt != (u_char) (ASN_SEQUENCE | ASN_CONSTRUCTOR))
  ------------------
  |  |   96|  20.1k|#define ASN_CONSTRUCTOR	    0x20U
  ------------------
  |  Branch (490:9): [True: 1.68k, False: 18.4k]
  ------------------
  491|  1.68k|        return -1;              /* wrong type */
  492|       |
  493|  18.4k|    if (*(pkt + 1) & 0x80) {
  ------------------
  |  Branch (493:9): [True: 1.92k, False: 16.5k]
  ------------------
  494|       |        /*
  495|       |         * long length 
  496|       |         */
  497|  1.92k|        if ((int) len < (int) (*(pkt + 1) & ~0x80) + 2)
  ------------------
  |  Branch (497:13): [True: 0, False: 1.92k]
  ------------------
  498|      0|            return 0;           /* still to short, incomplete length */
  499|  1.92k|        if (NULL == asn_parse_length(pkt + 1, &asn_length))
  ------------------
  |  Branch (499:13): [True: 0, False: 1.92k]
  ------------------
  500|      0|            return 0;           /* propagate error from asn_parse_length() */
  501|  1.92k|        return (asn_length + 2 + (*(pkt + 1) & ~0x80));
  502|  16.5k|    } else {
  503|       |        /*
  504|       |         * short length 
  505|       |         */
  506|  16.5k|        return (*(pkt + 1) + 2);
  507|  16.5k|    }
  508|  18.4k|}
asn_parse_int:
  557|  21.4k|{
  558|       |    /*
  559|       |     * ASN.1 integer ::= 0x02 asnlength byte {byte}*
  560|       |     */
  561|  21.4k|    static const char *errpre = "parse int";
  562|  21.4k|    register u_char *bufp = data;
  563|  21.4k|    u_long          asn_length;
  564|  21.4k|    int             i;
  565|  21.4k|    union {
  566|  21.4k|        long          l;
  567|  21.4k|        unsigned char b[sizeof(long)];
  568|  21.4k|    } value;
  569|       |
  570|  21.4k|    if (NULL == data || NULL == datalength || NULL == type || NULL == intp) {
  ------------------
  |  Branch (570:9): [True: 0, False: 21.4k]
  |  Branch (570:25): [True: 0, False: 21.4k]
  |  Branch (570:47): [True: 0, False: 21.4k]
  |  Branch (570:63): [True: 0, False: 21.4k]
  ------------------
  571|      0|        ERROR_MSG("parse int: NULL pointer");
  ------------------
  |  |  188|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
  572|      0|        return NULL;
  573|      0|    }
  574|       |
  575|  21.4k|    if (intsize != sizeof(long)) {
  ------------------
  |  Branch (575:9): [True: 0, False: 21.4k]
  ------------------
  576|      0|        _asn_size_err(errpre, intsize, sizeof(long));
  577|      0|        return NULL;
  578|      0|    }
  579|       |
  580|       |    /** need at least 2 bytes to work with: type, length (which might be 0)  */
  581|  21.4k|    if (*datalength < 2) {
  ------------------
  |  Branch (581:9): [True: 0, False: 21.4k]
  ------------------
  582|      0|        _asn_short_err(errpre, *datalength, 2);
  583|      0|        return NULL;
  584|      0|    }
  585|       |
  586|  21.4k|    *type = *bufp++;
  587|  21.4k|    if (*type != ASN_INTEGER) {
  ------------------
  |  |   75|  21.4k|#define ASN_INTEGER	    0x02U
  ------------------
  |  Branch (587:9): [True: 2.70k, False: 18.7k]
  ------------------
  588|  2.70k|        _asn_type_err(errpre, *type);
  589|  2.70k|        return NULL;
  590|  2.70k|    }
  591|       |
  592|  18.7k|    bufp = asn_parse_nlength(bufp, *datalength - 1, &asn_length);
  593|  18.7k|    if (NULL == bufp) {
  ------------------
  |  Branch (593:9): [True: 260, False: 18.4k]
  ------------------
  594|    260|        _asn_short_err(errpre, *datalength - 1, asn_length);
  595|    260|        return NULL;
  596|    260|    }
  597|       |
  598|  18.4k|    if ((size_t) asn_length > intsize || (int) asn_length == 0) {
  ------------------
  |  Branch (598:9): [True: 570, False: 17.8k]
  |  Branch (598:42): [True: 21, False: 17.8k]
  ------------------
  599|    591|        _asn_length_err(errpre, (size_t) asn_length, intsize);
  600|    591|        return NULL;
  601|    591|    }
  602|       |
  603|  17.8k|    *datalength -= (int) asn_length + (bufp - data);
  604|       |
  605|  17.8k|    DEBUGDUMPSETUP("recv", data, bufp - data + asn_length);
  ------------------
  |  |   83|  17.8k|	do {if (_DBG_IF_) {__DBGDUMPSETUP(token,buf,len);} }while(0)
  |  |  ------------------
  |  |  |  |  144|  17.8k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 17.8k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPSETUP(token,buf,len);} }while(0)
  |  |  ------------------
  |  |  |  |  196|  17.8k|        debugmsg("dumpx" token, "dumpx_%s:%*s", token, __DBGINDENT(), ""); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  171|  17.8k|#define __DBGINDENT()      debug_indent_get()
  |  |  |  |  ------------------
  |  |  |  |  197|  17.8k|        __DBGMSGHEX(("dumpx_" token,buf,len)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  169|  17.8k|#define __DBGMSGHEX(x)     debugmsg_hex x
  |  |  |  |  ------------------
  |  |  |  |  198|  17.8k|        if (debug_is_token_registered("dumpv" token) == SNMPERR_SUCCESS || \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|  35.7k|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (198:13): [True: 17.8k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  199|  17.8k|            debug_is_token_registered("dumpv_" token) != SNMPERR_SUCCESS) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (199:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  200|  17.8k|            debugmsg("dumpx_" token,"\n"); \
  |  |  |  |  201|  17.8k|        } else { \
  |  |  |  |  202|      0|            debugmsg("dumpx_" token,"  "); \
  |  |  |  |  203|      0|        } \
  |  |  |  |  204|  17.8k|        debugmsg("dumpv" token, "dumpv_%s:%*s", token, __DBGINDENT(), "");
  |  |  |  |  ------------------
  |  |  |  |  |  |  171|  17.8k|#define __DBGINDENT()      debug_indent_get()
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (83:60): [Folded, False: 17.8k]
  |  |  ------------------
  ------------------
  606|       |
  607|  17.8k|    memset(&value.b, *bufp & 0x80 ? 0xff : 0, sizeof(value.b));
  ------------------
  |  Branch (607:22): [True: 3.51k, False: 14.3k]
  ------------------
  608|  17.8k|    if (NETSNMP_BIGENDIAN) {
  ------------------
  |  | 2396|  17.8k|#  define NETSNMP_BIGENDIAN 0
  |  |  ------------------
  |  |  |  Branch (2396:29): [Folded, False: 17.8k]
  |  |  ------------------
  ------------------
  609|      0|        for (i = sizeof(long) - asn_length; asn_length--; i++)
  ------------------
  |  Branch (609:45): [True: 0, False: 0]
  ------------------
  610|      0|            value.b[i] = *bufp++;
  611|  17.8k|    } else {
  612|  36.3k|        for (i = asn_length - 1; asn_length--; i--)
  ------------------
  |  Branch (612:34): [True: 18.5k, False: 17.8k]
  ------------------
  613|  18.5k|            value.b[i] = *bufp++;
  614|  17.8k|    }
  615|       |
  616|  17.8k|    CHECK_OVERFLOW_S(value.l, 1);
  ------------------
  |  |  214|  17.8k|#define CHECK_OVERFLOW_S(x,y) do {                                      \
  |  |  215|  17.8k|        if (x > INT32_MAX) {                                            \
  |  |  ------------------
  |  |  |  Branch (215:13): [True: 13, False: 17.8k]
  |  |  ------------------
  |  |  216|     13|            DEBUGMSG(("asn","truncating signed value %ld to 32 bits (%d)\n",(long)(x),y)); \
  |  |  ------------------
  |  |  |  |   61|     13|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  |  144|     13|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (144:29): [True: 13, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (61:67): [Folded, False: 13]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  217|     13|            x &= 0xffffffff;                                            \
  |  |  218|  17.8k|        } else if (x < INT32_MIN) {                                     \
  |  |  ------------------
  |  |  |  Branch (218:20): [True: 44, False: 17.8k]
  |  |  ------------------
  |  |  219|     44|            DEBUGMSG(("asn","truncating signed value %ld to 32 bits (%d)\n",(long)(x),y)); \
  |  |  ------------------
  |  |  |  |   61|     44|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  |  144|     44|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (144:29): [True: 44, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (61:67): [Folded, False: 44]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  220|     44|            x = 0 - (x & 0xffffffff);                                   \
  |  |  221|     44|        }                                                               \
  |  |  222|  17.8k|    } while(0)
  |  |  ------------------
  |  |  |  Branch (222:13): [Folded, False: 17.8k]
  |  |  ------------------
  ------------------
  617|       |
  618|  17.8k|    DEBUGMSG(("dumpv_recv", "  Integer:\t%ld (0x%.2lX)\n", value.l, value.l));
  ------------------
  |  |   61|  17.8k|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  144|  17.8k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 17.8k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (61:67): [Folded, False: 17.8k]
  |  |  ------------------
  ------------------
  619|       |
  620|  17.8k|    *intp = value.l;
  621|  17.8k|    return bufp;
  622|  18.4k|}
asn_parse_string:
  910|  19.9k|{
  911|  19.9k|    static const char *errpre = "parse string";
  912|  19.9k|    u_char         *bufp = data;
  913|  19.9k|    u_long          asn_length;
  914|       |
  915|  19.9k|    if (NULL == data || NULL == datalength || NULL == type || NULL == str ||
  ------------------
  |  Branch (915:9): [True: 0, False: 19.9k]
  |  Branch (915:25): [True: 0, False: 19.9k]
  |  Branch (915:47): [True: 0, False: 19.9k]
  |  Branch (915:63): [True: 0, False: 19.9k]
  ------------------
  916|  19.9k|        NULL == strlength) {
  ------------------
  |  Branch (916:9): [True: 0, False: 19.9k]
  ------------------
  917|      0|        ERROR_MSG("parse string: NULL pointer");
  ------------------
  |  |  188|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
  918|      0|        return NULL;
  919|      0|    }
  920|       |
  921|       |    /** need at least 2 bytes to work with: type, length (which might be 0)  */
  922|  19.9k|    if (*datalength < 2) {
  ------------------
  |  Branch (922:9): [True: 44, False: 19.8k]
  ------------------
  923|     44|        _asn_short_err(errpre, *datalength, 2);
  924|     44|        return NULL;
  925|     44|    }
  926|       |
  927|  19.8k|    *type = *bufp++;
  928|  19.8k|    if (*type != ASN_OCTET_STR && *type != ASN_IPADDRESS && *type != ASN_OPAQUE
  ------------------
  |  |   78|  39.7k|#define ASN_OCTET_STR	    0x04U
  ------------------
                  if (*type != ASN_OCTET_STR && *type != ASN_IPADDRESS && *type != ASN_OPAQUE
  ------------------
  |  |   88|  39.6k|#define ASN_IPADDRESS   (ASN_APPLICATION | 0)
  |  |  ------------------
  |  |  |  |   91|  19.7k|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
                  if (*type != ASN_OCTET_STR && *type != ASN_IPADDRESS && *type != ASN_OPAQUE
  ------------------
  |  |   93|  26.3k|#define ASN_OPAQUE	(ASN_APPLICATION | 4)   /* changed so no conflict with other includes */
  |  |  ------------------
  |  |  |  |   91|  6.44k|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (928:9): [True: 19.7k, False: 89]
  |  Branch (928:35): [True: 6.44k, False: 13.3k]
  |  Branch (928:61): [True: 6.44k, False: 0]
  ------------------
  929|  6.44k|            && *type != ASN_NSAP) {
  ------------------
  |  |   98|  6.44k|#define ASN_NSAP	(ASN_APPLICATION | 5)   /* historic - don't use */
  |  |  ------------------
  |  |  |  |   91|  6.44k|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (929:16): [True: 372, False: 6.07k]
  ------------------
  930|    372|        _asn_type_err(errpre, *type);
  931|    372|        return NULL;
  932|    372|    }
  933|       |
  934|  19.4k|    bufp = asn_parse_nlength(bufp, *datalength - 1, &asn_length);
  935|  19.4k|    if (NULL == bufp) {
  ------------------
  |  Branch (935:9): [True: 244, False: 19.2k]
  ------------------
  936|    244|        _asn_short_err(errpre, *datalength - 1, asn_length);
  937|    244|        return NULL;
  938|    244|    }
  939|       |
  940|  19.2k|    if (asn_length > *strlength) {
  ------------------
  |  Branch (940:9): [True: 193, False: 19.0k]
  ------------------
  941|    193|        _asn_length_err(errpre, (size_t) asn_length, *strlength);
  942|    193|        return NULL;
  943|    193|    }
  944|       |
  945|  19.0k|    DEBUGDUMPSETUP("recv", data, bufp - data + asn_length);
  ------------------
  |  |   83|  19.0k|	do {if (_DBG_IF_) {__DBGDUMPSETUP(token,buf,len);} }while(0)
  |  |  ------------------
  |  |  |  |  144|  19.0k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 19.0k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPSETUP(token,buf,len);} }while(0)
  |  |  ------------------
  |  |  |  |  196|  19.0k|        debugmsg("dumpx" token, "dumpx_%s:%*s", token, __DBGINDENT(), ""); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  171|  19.0k|#define __DBGINDENT()      debug_indent_get()
  |  |  |  |  ------------------
  |  |  |  |  197|  19.0k|        __DBGMSGHEX(("dumpx_" token,buf,len)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  169|  19.0k|#define __DBGMSGHEX(x)     debugmsg_hex x
  |  |  |  |  ------------------
  |  |  |  |  198|  19.0k|        if (debug_is_token_registered("dumpv" token) == SNMPERR_SUCCESS || \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|  38.1k|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (198:13): [True: 19.0k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  199|  19.0k|            debug_is_token_registered("dumpv_" token) != SNMPERR_SUCCESS) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (199:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  200|  19.0k|            debugmsg("dumpx_" token,"\n"); \
  |  |  |  |  201|  19.0k|        } else { \
  |  |  |  |  202|      0|            debugmsg("dumpx_" token,"  "); \
  |  |  |  |  203|      0|        } \
  |  |  |  |  204|  19.0k|        debugmsg("dumpv" token, "dumpv_%s:%*s", token, __DBGINDENT(), "");
  |  |  |  |  ------------------
  |  |  |  |  |  |  171|  19.0k|#define __DBGINDENT()      debug_indent_get()
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (83:60): [Folded, False: 19.0k]
  |  |  ------------------
  ------------------
  946|       |
  947|  19.0k|    memmove(str, bufp, asn_length);
  948|  19.0k|    if (*strlength > asn_length)
  ------------------
  |  Branch (948:9): [True: 16.4k, False: 2.56k]
  ------------------
  949|  16.4k|        str[asn_length] = 0;
  950|  19.0k|    *strlength = asn_length;
  951|  19.0k|    *datalength -= asn_length + (bufp - data);
  952|       |
  953|  19.0k|    DEBUGIF("dumpv_recv") {
  ------------------
  |  |  145|  19.0k|#define DEBUGIF(x)         if (_DBG_IF_ && debug_is_token_registered(x) == SNMPERR_SUCCESS)
  |  |  ------------------
  |  |  |  |  144|  38.1k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 19.0k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGIF(x)         if (_DBG_IF_ && debug_is_token_registered(x) == SNMPERR_SUCCESS)
  |  |  ------------------
  |  |  |  |  184|  19.0k|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  ------------------
  |  |  |  Branch (145:44): [True: 19.0k, False: 0]
  |  |  ------------------
  ------------------
  954|  19.0k|        u_char         *buf = (u_char *) malloc(1 + asn_length);
  955|  19.0k|        size_t          l = (buf != NULL) ? (1 + asn_length) : 0, ol = 0;
  ------------------
  |  Branch (955:29): [True: 19.0k, False: 0]
  ------------------
  956|       |
  957|  19.0k|        if (sprint_realloc_asciistring
  ------------------
  |  Branch (957:13): [True: 19.0k, False: 0]
  ------------------
  958|  19.0k|            (&buf, &l, &ol, 1, str, asn_length)) {
  959|  19.0k|            DEBUGMSG(("dumpv_recv", "  String:\t%s\n", buf));
  ------------------
  |  |   61|  19.0k|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  144|  19.0k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 19.0k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (61:67): [Folded, False: 19.0k]
  |  |  ------------------
  ------------------
  960|  19.0k|        } else {
  961|      0|            if (buf == NULL) {
  ------------------
  |  Branch (961:17): [True: 0, False: 0]
  ------------------
  962|      0|                DEBUGMSG(("dumpv_recv", "  String:\t[TRUNCATED]\n"));
  ------------------
  |  |   61|      0|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (61:67): [Folded, False: 0]
  |  |  ------------------
  ------------------
  963|      0|            } else {
  964|      0|                DEBUGMSG(("dumpv_recv", "  String:\t%s [TRUNCATED]\n",
  ------------------
  |  |   61|      0|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (61:67): [Folded, False: 0]
  |  |  ------------------
  ------------------
  965|      0|                          buf));
  966|      0|            }
  967|      0|        }
  968|  19.0k|        if (buf != NULL) {
  ------------------
  |  Branch (968:13): [True: 19.0k, False: 0]
  ------------------
  969|  19.0k|            free(buf);
  970|  19.0k|        }
  971|  19.0k|    }
  972|       |
  973|  19.0k|    return bufp + asn_length;
  974|  19.2k|}
asn_parse_header:
 1071|  21.8k|{
 1072|  21.8k|    register u_char *bufp;
 1073|  21.8k|    u_long          asn_length = 0;
 1074|  21.8k|    const char      *errpre = "parse header";
 1075|       |
 1076|  21.8k|    if (!data || !datalength || !type) {
  ------------------
  |  Branch (1076:9): [True: 0, False: 21.8k]
  |  Branch (1076:18): [True: 0, False: 21.8k]
  |  Branch (1076:33): [True: 0, False: 21.8k]
  ------------------
 1077|      0|        ERROR_MSG("parse header: NULL pointer");
  ------------------
  |  |  188|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 1078|      0|        return NULL;
 1079|      0|    }
 1080|       |
 1081|       |    /** need at least 2 bytes to work with: type, length (which might be 0) */
 1082|  21.8k|    if (*datalength < 2) {
  ------------------
  |  Branch (1082:9): [True: 0, False: 21.8k]
  ------------------
 1083|      0|        _asn_short_err(errpre, *datalength, 2);
 1084|      0|        return NULL;
 1085|      0|    }
 1086|       |
 1087|  21.8k|    bufp = data;
 1088|       |    /*
 1089|       |     * this only works on data types < 30, i.e. no extension octets 
 1090|       |     */
 1091|  21.8k|    if (IS_EXTENSION_ID(*bufp)) {
  ------------------
  |  |  103|  21.8k|#define IS_EXTENSION_ID(byte)	(((byte) & ASN_EXTENSION_ID) == ASN_EXTENSION_ID)
  |  |  ------------------
  |  |  |  |   99|  21.8k|#define ASN_EXTENSION_ID    0x1FU
  |  |  ------------------
  |  |               #define IS_EXTENSION_ID(byte)	(((byte) & ASN_EXTENSION_ID) == ASN_EXTENSION_ID)
  |  |  ------------------
  |  |  |  |   99|  21.8k|#define ASN_EXTENSION_ID    0x1FU
  |  |  ------------------
  |  |  |  Branch (103:31): [True: 42, False: 21.8k]
  |  |  ------------------
  ------------------
 1092|     42|        ERROR_MSG("can't process ID >= 30");
  ------------------
  |  |  188|     42|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 1093|     42|        return NULL;
 1094|     42|    }
 1095|  21.8k|    *type = *bufp++;
 1096|       |
 1097|  21.8k|    bufp = asn_parse_nlength(bufp, *datalength - 1, &asn_length);
 1098|  21.8k|    if (NULL == bufp) {
  ------------------
  |  Branch (1098:9): [True: 95, False: 21.7k]
  ------------------
 1099|     95|        _asn_short_err(errpre, *datalength - 1, asn_length);
 1100|     95|        return NULL;
 1101|     95|    }
 1102|       |
 1103|       |#ifdef DUMP_PRINT_HEADERS
 1104|       |    DEBUGDUMPSETUP("recv", data, (bufp - data));
 1105|       |    DEBUGMSG(("dumpv_recv", "  Header: 0x%.2X, len = %d (0x%X)\n", *data,
 1106|       |              asn_length, asn_length));
 1107|       |#else
 1108|       |    /*
 1109|       |     * DEBUGMSGHEXTLI(("recv",data,(bufp-data)));
 1110|       |     * DEBUGMSG(("dumpH_recv","\n"));
 1111|       |     */
 1112|  21.7k|#endif
 1113|       |
 1114|  21.7k|#ifdef NETSNMP_WITH_OPAQUE_SPECIAL_TYPES
 1115|       |
 1116|  21.7k|    if ((asn_length > 2) && (*type == ASN_OPAQUE) && (*bufp == ASN_OPAQUE_TAG1)) {
  ------------------
  |  |   93|  21.6k|#define ASN_OPAQUE	(ASN_APPLICATION | 4)   /* changed so no conflict with other includes */
  |  |  ------------------
  |  |  |  |   91|  21.6k|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
                  if ((asn_length > 2) && (*type == ASN_OPAQUE) && (*bufp == ASN_OPAQUE_TAG1)) {
  ------------------
  |  |  131|     55|#define ASN_OPAQUE_TAG1 (ASN_CONTEXT | ASN_EXTENSION_ID)
  |  |  ------------------
  |  |  |  |   92|     55|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define ASN_OPAQUE_TAG1 (ASN_CONTEXT | ASN_EXTENSION_ID)
  |  |  ------------------
  |  |  |  |   99|     55|#define ASN_EXTENSION_ID    0x1FU
  |  |  ------------------
  ------------------
  |  Branch (1116:9): [True: 21.6k, False: 71]
  |  Branch (1116:29): [True: 55, False: 21.5k]
  |  Branch (1116:54): [True: 55, False: 0]
  ------------------
 1117|       |
 1118|       |        /*
 1119|       |         * check if 64-but counter 
 1120|       |         */
 1121|     55|        switch (*(bufp + 1)) {
 1122|      0|        case ASN_OPAQUE_COUNTER64:
  ------------------
  |  |  156|      0|#define ASN_OPAQUE_COUNTER64 (ASN_OPAQUE_TAG2 + ASN_APP_COUNTER64)
  |  |  ------------------
  |  |  |  |  136|      0|#define ASN_OPAQUE_TAG2 0x30U
  |  |  ------------------
  |  |               #define ASN_OPAQUE_COUNTER64 (ASN_OPAQUE_TAG2 + ASN_APP_COUNTER64)
  |  |  ------------------
  |  |  |  |  146|      0|#define ASN_APP_COUNTER64 (ASN_APPLICATION | 6)
  |  |  |  |  ------------------
  |  |  |  |  |  |   91|      0|#define ASN_APPLICATION     0x40U
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (1122:9): [True: 0, False: 55]
  ------------------
 1123|      0|        case ASN_OPAQUE_U64:
  ------------------
  |  |  192|      0|#define ASN_OPAQUE_U64 (ASN_OPAQUE_TAG2 + ASN_APP_U64)
  |  |  ------------------
  |  |  |  |  136|      0|#define ASN_OPAQUE_TAG2 0x30U
  |  |  ------------------
  |  |               #define ASN_OPAQUE_U64 (ASN_OPAQUE_TAG2 + ASN_APP_U64)
  |  |  ------------------
  |  |  |  |  150|      0|#define ASN_APP_U64 (ASN_APPLICATION | 11)
  |  |  |  |  ------------------
  |  |  |  |  |  |   91|      0|#define ASN_APPLICATION     0x40U
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (1123:9): [True: 0, False: 55]
  ------------------
 1124|      0|        case ASN_OPAQUE_FLOAT:
  ------------------
  |  |  165|      0|#define ASN_OPAQUE_FLOAT (ASN_OPAQUE_TAG2 + ASN_APP_FLOAT)
  |  |  ------------------
  |  |  |  |  136|      0|#define ASN_OPAQUE_TAG2 0x30U
  |  |  ------------------
  |  |               #define ASN_OPAQUE_FLOAT (ASN_OPAQUE_TAG2 + ASN_APP_FLOAT)
  |  |  ------------------
  |  |  |  |  147|      0|#define ASN_APP_FLOAT (ASN_APPLICATION | 8)
  |  |  |  |  ------------------
  |  |  |  |  |  |   91|      0|#define ASN_APPLICATION     0x40U
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (1124:9): [True: 0, False: 55]
  ------------------
 1125|      0|        case ASN_OPAQUE_DOUBLE:
  ------------------
  |  |  174|      0|#define ASN_OPAQUE_DOUBLE (ASN_OPAQUE_TAG2 + ASN_APP_DOUBLE)
  |  |  ------------------
  |  |  |  |  136|      0|#define ASN_OPAQUE_TAG2 0x30U
  |  |  ------------------
  |  |               #define ASN_OPAQUE_DOUBLE (ASN_OPAQUE_TAG2 + ASN_APP_DOUBLE)
  |  |  ------------------
  |  |  |  |  148|      0|#define ASN_APP_DOUBLE (ASN_APPLICATION | 9)
  |  |  |  |  ------------------
  |  |  |  |  |  |   91|      0|#define ASN_APPLICATION     0x40U
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (1125:9): [True: 0, False: 55]
  ------------------
 1126|     55|        case ASN_OPAQUE_I64:
  ------------------
  |  |  183|     55|#define ASN_OPAQUE_I64 (ASN_OPAQUE_TAG2 + ASN_APP_I64)
  |  |  ------------------
  |  |  |  |  136|     55|#define ASN_OPAQUE_TAG2 0x30U
  |  |  ------------------
  |  |               #define ASN_OPAQUE_I64 (ASN_OPAQUE_TAG2 + ASN_APP_I64)
  |  |  ------------------
  |  |  |  |  149|     55|#define ASN_APP_I64 (ASN_APPLICATION | 10)
  |  |  |  |  ------------------
  |  |  |  |  |  |   91|     55|#define ASN_APPLICATION     0x40U
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (1126:9): [True: 55, False: 0]
  ------------------
 1127|     55|            *type = *(bufp + 1);
 1128|     55|            break;
 1129|       |
 1130|      0|        default:
  ------------------
  |  Branch (1130:9): [True: 0, False: 55]
  ------------------
 1131|       |            /*
 1132|       |             * just an Opaque 
 1133|       |             */
 1134|      0|            *datalength = (int) asn_length;
 1135|      0|            return bufp;
 1136|     55|        }
 1137|       |        /*
 1138|       |         * value is encoded as special format 
 1139|       |         */
 1140|     55|        *datalength = (int) asn_length;
 1141|     55|        bufp = asn_parse_nlength(bufp+2, *datalength - 2, &asn_length);
 1142|     55|        if (NULL == bufp) {
  ------------------
  |  Branch (1142:13): [True: 0, False: 55]
  ------------------
 1143|      0|            _asn_short_err("parse opaque header", *datalength - 2, asn_length);
 1144|      0|            return NULL;
 1145|      0|        }
 1146|     55|    }
 1147|  21.7k|#endif                          /* NETSNMP_WITH_OPAQUE_SPECIAL_TYPES */
 1148|       |
 1149|  21.7k|    *datalength = (int) asn_length;
 1150|       |
 1151|  21.7k|    return bufp;
 1152|  21.7k|}
asn_parse_sequence:
 1171|  18.5k|{                               /* error message prefix */
 1172|  18.5k|    data = asn_parse_header(data, datalength, type);
 1173|  18.5k|    if (data && (*type != expected_type)) {
  ------------------
  |  Branch (1173:9): [True: 18.4k, False: 81]
  |  Branch (1173:17): [True: 27, False: 18.4k]
  ------------------
 1174|     27|        char            ebuf[128];
 1175|     27|        snprintf(ebuf, sizeof(ebuf),
 1176|     27|                 "%s header type %02X: s/b %02X", estr,
 1177|     27|                (u_char) * type, (u_char) expected_type);
 1178|     27|        ERROR_MSG(ebuf);
  ------------------
  |  |  188|     27|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 1179|     27|        return NULL;
 1180|     27|    }
 1181|  18.5k|    return data;
 1182|  18.5k|}
asn_parse_length:
 1293|  5.53k|{
 1294|  5.53k|    static const char *errpre = "parse length";
 1295|  5.53k|    char            ebuf[128];
 1296|  5.53k|    register u_char lengthbyte;
 1297|       |
 1298|  5.53k|    if (!data || !length) {
  ------------------
  |  Branch (1298:9): [True: 0, False: 5.53k]
  |  Branch (1298:18): [True: 0, False: 5.53k]
  ------------------
 1299|      0|        ERROR_MSG("parse length: NULL pointer");
  ------------------
  |  |  188|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 1300|      0|        return NULL;
 1301|      0|    }
 1302|  5.53k|    lengthbyte = *data;
 1303|       |
 1304|  5.53k|    if (lengthbyte & ASN_LONG_LEN) {
  ------------------
  |  |   98|  5.53k|#define ASN_LONG_LEN	    0x80U
  ------------------
  |  Branch (1304:9): [True: 5.53k, False: 0]
  ------------------
 1305|  5.53k|        lengthbyte &= ~ASN_LONG_LEN;    /* turn MSb off */
  ------------------
  |  |   98|  5.53k|#define ASN_LONG_LEN	    0x80U
  ------------------
 1306|  5.53k|        if (lengthbyte == 0) {
  ------------------
  |  Branch (1306:13): [True: 0, False: 5.53k]
  ------------------
 1307|      0|            snprintf(ebuf, sizeof(ebuf),
 1308|      0|                     "%s: indefinite length not supported", errpre);
 1309|      0|            ERROR_MSG(ebuf);
  ------------------
  |  |  188|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 1310|      0|            return NULL;
 1311|      0|        }
 1312|  5.53k|        if (lengthbyte > sizeof(long)) {
  ------------------
  |  Branch (1312:13): [True: 635, False: 4.90k]
  ------------------
 1313|    635|            snprintf(ebuf, sizeof(ebuf),
 1314|    635|                    "%s: data length %d > %lu not supported", errpre,
 1315|    635|                    lengthbyte, (unsigned long)sizeof(long));
 1316|    635|            ERROR_MSG(ebuf);
  ------------------
  |  |  188|    635|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 1317|    635|            return NULL;
 1318|    635|        }
 1319|  4.90k|        data++;
 1320|  4.90k|        *length = 0;            /* protect against short lengths */
 1321|  19.9k|        while (lengthbyte--) {
  ------------------
  |  Branch (1321:16): [True: 15.0k, False: 4.90k]
  ------------------
 1322|  15.0k|            *length <<= 8;
 1323|  15.0k|            *length |= *data++;
 1324|  15.0k|        }
 1325|  4.90k|        if ((long) *length < 0) {
  ------------------
  |  Branch (1325:13): [True: 50, False: 4.85k]
  ------------------
 1326|     50|            snprintf(ebuf, sizeof(ebuf),
 1327|     50|                     "%s: negative data length %ld\n", errpre,
 1328|     50|                     (long) *length);
 1329|     50|            ERROR_MSG(ebuf);
  ------------------
  |  |  188|     50|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 1330|     50|            return NULL;
 1331|     50|        }
 1332|  4.85k|        return data;
 1333|  4.90k|    } else {                    /* short asnlength */
 1334|      0|        *length = (long) lengthbyte;
 1335|      0|        return data + 1;
 1336|      0|    }
 1337|  5.53k|}
asn_parse_objid:
 1435|  2.95k|{
 1436|  2.95k|    static const char *errpre = "parse objid";
 1437|       |    /*
 1438|       |     * ASN.1 objid ::= 0x06 asnlength subidentifier {subidentifier}*
 1439|       |     * subidentifier ::= {leadingbyte}* lastbyte
 1440|       |     * leadingbyte ::= 1 7bitvalue
 1441|       |     * lastbyte ::= 0 7bitvalue
 1442|       |     */
 1443|  2.95k|    register u_char *bufp = data;
 1444|  2.95k|    register oid   *oidp = objid + 1;
 1445|  2.95k|    register u_long subidentifier;
 1446|  2.95k|    register long   length;
 1447|  2.95k|    u_long          asn_length;
 1448|  2.95k|    size_t          original_length = *objidlength;
 1449|       |
 1450|  2.95k|    if (NULL == data || NULL == datalength || NULL == type || NULL == objid) {
  ------------------
  |  Branch (1450:9): [True: 0, False: 2.95k]
  |  Branch (1450:25): [True: 0, False: 2.95k]
  |  Branch (1450:47): [True: 0, False: 2.95k]
  |  Branch (1450:63): [True: 0, False: 2.95k]
  ------------------
 1451|      0|        ERROR_MSG("parse objid: NULL pointer");
  ------------------
  |  |  188|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 1452|      0|        return NULL;
 1453|      0|    }
 1454|       |
 1455|       |    /** need at least 2 bytes to work with: type, length (which might be 0)  */
 1456|  2.95k|    if (*datalength < 2) {
  ------------------
  |  Branch (1456:9): [True: 0, False: 2.95k]
  ------------------
 1457|      0|        _asn_short_err(errpre, *datalength, 2);
 1458|      0|        return NULL;
 1459|      0|    }
 1460|       |
 1461|  2.95k|    *type = *bufp++;
 1462|  2.95k|    if (*type != ASN_OBJECT_ID) {
  ------------------
  |  |   81|  2.95k|#define ASN_OBJECT_ID	    0x06U
  ------------------
  |  Branch (1462:9): [True: 20, False: 2.93k]
  ------------------
 1463|     20|        _asn_type_err(errpre, *type);
 1464|     20|        return NULL;
 1465|     20|    }
 1466|  2.93k|    bufp = asn_parse_nlength(bufp, *datalength - 1, &asn_length);
 1467|  2.93k|    if (NULL == bufp) {
  ------------------
  |  Branch (1467:9): [True: 275, False: 2.66k]
  ------------------
 1468|    275|        _asn_short_err(errpre, *datalength - 1, asn_length);
 1469|    275|        return NULL;
 1470|    275|    }
 1471|       |
 1472|  2.66k|    *datalength -= (int) asn_length + (bufp - data);
 1473|       |
 1474|  2.66k|    DEBUGDUMPSETUP("recv", data, bufp - data + asn_length);
  ------------------
  |  |   83|  2.66k|	do {if (_DBG_IF_) {__DBGDUMPSETUP(token,buf,len);} }while(0)
  |  |  ------------------
  |  |  |  |  144|  2.66k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 2.66k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPSETUP(token,buf,len);} }while(0)
  |  |  ------------------
  |  |  |  |  196|  2.66k|        debugmsg("dumpx" token, "dumpx_%s:%*s", token, __DBGINDENT(), ""); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  171|  2.66k|#define __DBGINDENT()      debug_indent_get()
  |  |  |  |  ------------------
  |  |  |  |  197|  2.66k|        __DBGMSGHEX(("dumpx_" token,buf,len)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  169|  2.66k|#define __DBGMSGHEX(x)     debugmsg_hex x
  |  |  |  |  ------------------
  |  |  |  |  198|  2.66k|        if (debug_is_token_registered("dumpv" token) == SNMPERR_SUCCESS || \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|  5.32k|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (198:13): [True: 2.66k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  199|  2.66k|            debug_is_token_registered("dumpv_" token) != SNMPERR_SUCCESS) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (199:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  200|  2.66k|            debugmsg("dumpx_" token,"\n"); \
  |  |  |  |  201|  2.66k|        } else { \
  |  |  |  |  202|      0|            debugmsg("dumpx_" token,"  "); \
  |  |  |  |  203|      0|        } \
  |  |  |  |  204|  2.66k|        debugmsg("dumpv" token, "dumpv_%s:%*s", token, __DBGINDENT(), "");
  |  |  |  |  ------------------
  |  |  |  |  |  |  171|  2.66k|#define __DBGINDENT()      debug_indent_get()
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (83:60): [Folded, False: 2.66k]
  |  |  ------------------
  ------------------
 1475|       |
 1476|       |    /*
 1477|       |     * Handle invalid object identifier encodings of the form 06 00 robustly 
 1478|       |     */
 1479|  2.66k|    if (asn_length == 0)
  ------------------
  |  Branch (1479:9): [True: 63, False: 2.60k]
  ------------------
 1480|     63|        objid[0] = objid[1] = 0;
 1481|       |
 1482|  2.66k|    length = asn_length;
 1483|  2.66k|    (*objidlength)--;           /* account for expansion of first byte */
 1484|       |
 1485|  33.7k|    while (length > 0 && (*objidlength)-- > 0) {
  ------------------
  |  Branch (1485:12): [True: 31.0k, False: 2.66k]
  |  Branch (1485:26): [True: 31.0k, False: 0]
  ------------------
 1486|  31.0k|        subidentifier = 0;
 1487|  38.9k|        do {                    /* shift and add in low order 7 bits */
 1488|  38.9k|            if (subidentifier > (MAX_SUBID >> 7)) {
  ------------------
  |  |   18|  38.9k|#define MAX_SUBID   0xFFFFFFFFUL
  ------------------
  |  Branch (1488:17): [True: 0, False: 38.9k]
  ------------------
 1489|      0|                ERROR_MSG("subidentifier too large / overflow");
  ------------------
  |  |  188|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 1490|      0|                return NULL;
 1491|      0|            }
 1492|  38.9k|            subidentifier =
 1493|  38.9k|                (subidentifier << 7) + (*(u_char *) bufp & ~ASN_BIT8);
  ------------------
  |  |  100|  38.9k|#define ASN_BIT8	    0x80U
  ------------------
 1494|  38.9k|            length--;
 1495|  38.9k|        } while ((*(u_char *) bufp++ & ASN_BIT8) && (length > 0));        /* last byte has high bit clear */
  ------------------
  |  |  100|  38.9k|#define ASN_BIT8	    0x80U
  ------------------
  |  Branch (1495:18): [True: 7.84k, False: 31.0k]
  |  Branch (1495:53): [True: 7.84k, False: 0]
  ------------------
 1496|       |
 1497|  31.0k|	if (length == 0) {
  ------------------
  |  Branch (1497:6): [True: 2.60k, False: 28.4k]
  ------------------
 1498|  2.60k|            u_char *last_byte = bufp - 1;
 1499|  2.60k|            if (*last_byte & ASN_BIT8) {
  ------------------
  |  |  100|  2.60k|#define ASN_BIT8	    0x80U
  ------------------
  |  Branch (1499:17): [True: 0, False: 2.60k]
  ------------------
 1500|       |                /* last byte has high bit set -> wrong BER encoded OID */
 1501|      0|                ERROR_MSG("subidentifier syntax error");
  ------------------
  |  |  188|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 1502|      0|                return NULL;
 1503|      0|            }
 1504|  2.60k|        }
 1505|  31.0k|        if (subidentifier > MAX_SUBID) {
  ------------------
  |  |   18|  31.0k|#define MAX_SUBID   0xFFFFFFFFUL
  ------------------
  |  Branch (1505:13): [True: 0, False: 31.0k]
  ------------------
 1506|      0|            ERROR_MSG("subidentifier too large");
  ------------------
  |  |  188|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 1507|      0|            return NULL;
 1508|      0|        }
 1509|  31.0k|        *oidp++ = (oid) subidentifier;
 1510|  31.0k|    }
 1511|       |
 1512|  2.66k|    if (length || oidp < objid + 1) {
  ------------------
  |  Branch (1512:9): [True: 0, False: 2.66k]
  |  Branch (1512:19): [True: 0, False: 2.66k]
  ------------------
 1513|      0|        ERROR_MSG("OID length exceeds buffer size");
  ------------------
  |  |  188|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 1514|      0|        *objidlength = original_length;
 1515|      0|        return NULL;
 1516|      0|    }
 1517|       |
 1518|       |    /*
 1519|       |     * The first two subidentifiers are encoded into the first component
 1520|       |     * with the value (X * 40) + Y, where:
 1521|       |     *  X is the value of the first subidentifier.
 1522|       |     *  Y is the value of the second subidentifier.
 1523|       |     */
 1524|  2.66k|    subidentifier = oidp - objid >= 2 ? objid[1] : 0;
  ------------------
  |  Branch (1524:21): [True: 2.60k, False: 63]
  ------------------
 1525|  2.66k|    if (subidentifier == 0x2B) {
  ------------------
  |  Branch (1525:9): [True: 0, False: 2.66k]
  ------------------
 1526|      0|        objid[0] = 1;
 1527|      0|        objid[1] = 3;
 1528|  2.66k|    } else {
 1529|  2.66k|        if (subidentifier < 40) {
  ------------------
  |  Branch (1529:13): [True: 63, False: 2.60k]
  ------------------
 1530|     63|            objid[0] = 0;
 1531|     63|            objid[1] = subidentifier;
 1532|  2.60k|        } else if (subidentifier < 80) {
  ------------------
  |  Branch (1532:20): [True: 0, False: 2.60k]
  ------------------
 1533|      0|            objid[0] = 1;
 1534|      0|            objid[1] = subidentifier - 40;
 1535|  2.60k|        } else {
 1536|  2.60k|            objid[0] = 2;
 1537|  2.60k|            objid[1] = subidentifier - 80;
 1538|  2.60k|        }
 1539|  2.66k|    }
 1540|       |
 1541|  2.66k|    *objidlength = (int) (oidp - objid);
 1542|       |
 1543|  2.66k|    DEBUGMSG(("dumpv_recv", "  ObjID: "));
  ------------------
  |  |   61|  2.66k|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  144|  2.66k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 2.66k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (61:67): [Folded, False: 2.66k]
  |  |  ------------------
  ------------------
 1544|  2.66k|    DEBUGMSGOID(("dumpv_recv", objid, *objidlength));
  ------------------
  |  |   67|  2.66k|#define DEBUGMSGOID(x)     do {if (_DBG_IF_) {__DBGMSGOID(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|  2.66k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 2.66k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGOID(x)     do {if (_DBG_IF_) {__DBGMSGOID(x);} }while(0)
  |  |  ------------------
  |  |  |  |  165|  2.66k|#define __DBGMSGOID(x)     debugmsg_oid x
  |  |  ------------------
  |  |  |  Branch (67:71): [Folded, False: 2.66k]
  |  |  ------------------
  ------------------
 1545|  2.66k|    DEBUGMSG(("dumpv_recv", "\n"));
  ------------------
  |  |   61|  2.66k|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  144|  2.66k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 2.66k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (61:67): [Folded, False: 2.66k]
  |  |  ------------------
  ------------------
 1546|  2.66k|    return bufp;
 1547|  2.66k|}
asn_parse_signed_int64:
 2222|     55|{
 2223|     55|    static const char *errpre = "parse int64";
 2224|     55|    const int       int64sizelimit = (4 * 2) + 1;
 2225|     55|    char            ebuf[128];
 2226|     55|    register u_char *bufp = data;
 2227|     55|    u_long          asn_length;
 2228|     55|    register u_int  low = 0, high = 0;
 2229|       |
 2230|     55|    if (countersize != sizeof(struct counter64)) {
  ------------------
  |  Branch (2230:9): [True: 0, False: 55]
  ------------------
 2231|      0|        _asn_size_err(errpre, countersize, sizeof(struct counter64));
 2232|      0|        return NULL;
 2233|      0|    }
 2234|       |
 2235|     55|    if (NULL == data || NULL == datalength || NULL == type || NULL == cp) {
  ------------------
  |  Branch (2235:9): [True: 0, False: 55]
  |  Branch (2235:25): [True: 0, False: 55]
  |  Branch (2235:47): [True: 0, False: 55]
  |  Branch (2235:63): [True: 0, False: 55]
  ------------------
 2236|      0|        ERROR_MSG("parse int64: NULL pointer");
  ------------------
  |  |  188|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 2237|      0|        return NULL;
 2238|      0|    }
 2239|       |
 2240|       |    /** need at least 2 bytes to work with: type, length (which might be 0) */
 2241|     55|    if (*datalength < 2) {
  ------------------
  |  Branch (2241:9): [True: 0, False: 55]
  ------------------
 2242|      0|        _asn_short_err(errpre, *datalength, 2);
 2243|      0|        return NULL;
 2244|      0|    }
 2245|       |
 2246|     55|    *type = *bufp++;
 2247|     55|    bufp = asn_parse_nlength(bufp, *datalength - 1, &asn_length);
 2248|     55|    if (NULL == bufp) {
  ------------------
  |  Branch (2248:9): [True: 0, False: 55]
  ------------------
 2249|      0|        _asn_short_err(errpre, *datalength - 1, asn_length);
 2250|      0|        return NULL;
 2251|      0|    }
 2252|       |
 2253|       |    /** need at least 2 bytes: ASN_OPAQUE_TAG1 and ASN_OPAQUE_I64 */
 2254|     55|    if (asn_length < 2) {
  ------------------
  |  Branch (2254:9): [True: 0, False: 55]
  ------------------
 2255|      0|        _asn_short_err(errpre, asn_length, 2);
 2256|      0|        return NULL;
 2257|      0|    }
 2258|       |
 2259|     55|    DEBUGDUMPSETUP("recv", data, bufp - data + asn_length);
  ------------------
  |  |   83|     55|	do {if (_DBG_IF_) {__DBGDUMPSETUP(token,buf,len);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     55|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 55, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPSETUP(token,buf,len);} }while(0)
  |  |  ------------------
  |  |  |  |  196|     55|        debugmsg("dumpx" token, "dumpx_%s:%*s", token, __DBGINDENT(), ""); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  171|     55|#define __DBGINDENT()      debug_indent_get()
  |  |  |  |  ------------------
  |  |  |  |  197|     55|        __DBGMSGHEX(("dumpx_" token,buf,len)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  169|     55|#define __DBGMSGHEX(x)     debugmsg_hex x
  |  |  |  |  ------------------
  |  |  |  |  198|     55|        if (debug_is_token_registered("dumpv" token) == SNMPERR_SUCCESS || \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|    110|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (198:13): [True: 55, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  199|     55|            debug_is_token_registered("dumpv_" token) != SNMPERR_SUCCESS) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (199:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  200|     55|            debugmsg("dumpx_" token,"\n"); \
  |  |  |  |  201|     55|        } else { \
  |  |  |  |  202|      0|            debugmsg("dumpx_" token,"  "); \
  |  |  |  |  203|      0|        } \
  |  |  |  |  204|     55|        debugmsg("dumpv" token, "dumpv_%s:%*s", token, __DBGINDENT(), "");
  |  |  |  |  ------------------
  |  |  |  |  |  |  171|     55|#define __DBGINDENT()      debug_indent_get()
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (83:60): [Folded, False: 55]
  |  |  ------------------
  ------------------
 2260|     55|    if ((*type == ASN_OPAQUE) &&
  ------------------
  |  |   93|     55|#define ASN_OPAQUE	(ASN_APPLICATION | 4)   /* changed so no conflict with other includes */
  |  |  ------------------
  |  |  |  |   91|     55|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (2260:9): [True: 55, False: 0]
  ------------------
 2261|     55|        (asn_length <= ASN_OPAQUE_COUNTER64_MX_BER_LEN) &&
  ------------------
  |  |  160|     55|#define ASN_OPAQUE_COUNTER64_MX_BER_LEN 12
  ------------------
  |  Branch (2261:9): [True: 0, False: 55]
  ------------------
 2262|      0|        (*bufp == ASN_OPAQUE_TAG1) && (*(bufp + 1) == ASN_OPAQUE_I64)) {
  ------------------
  |  |  131|      0|#define ASN_OPAQUE_TAG1 (ASN_CONTEXT | ASN_EXTENSION_ID)
  |  |  ------------------
  |  |  |  |   92|      0|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define ASN_OPAQUE_TAG1 (ASN_CONTEXT | ASN_EXTENSION_ID)
  |  |  ------------------
  |  |  |  |   99|      0|#define ASN_EXTENSION_ID    0x1FU
  |  |  ------------------
  ------------------
                      (*bufp == ASN_OPAQUE_TAG1) && (*(bufp + 1) == ASN_OPAQUE_I64)) {
  ------------------
  |  |  183|      0|#define ASN_OPAQUE_I64 (ASN_OPAQUE_TAG2 + ASN_APP_I64)
  |  |  ------------------
  |  |  |  |  136|      0|#define ASN_OPAQUE_TAG2 0x30U
  |  |  ------------------
  |  |               #define ASN_OPAQUE_I64 (ASN_OPAQUE_TAG2 + ASN_APP_I64)
  |  |  ------------------
  |  |  |  |  149|      0|#define ASN_APP_I64 (ASN_APPLICATION | 10)
  |  |  |  |  ------------------
  |  |  |  |  |  |   91|      0|#define ASN_APPLICATION     0x40U
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (2262:9): [True: 0, False: 0]
  |  Branch (2262:39): [True: 0, False: 0]
  ------------------
 2263|       |        /*
 2264|       |         * change type to Int64 
 2265|       |         */
 2266|      0|        *type = *(bufp + 1);
 2267|       |        /*
 2268|       |         * value is encoded as special format 
 2269|       |         */
 2270|      0|        *datalength = asn_length;
 2271|      0|        bufp = asn_parse_nlength(bufp+2, *datalength - 2, &asn_length);
 2272|      0|        if (NULL == bufp) {
  ------------------
  |  Branch (2272:13): [True: 0, False: 0]
  ------------------
 2273|      0|            _asn_short_err("parse opaque int64", *datalength - 2, asn_length);
 2274|      0|            return NULL;
 2275|      0|        }
 2276|      0|    }
 2277|       |    /*
 2278|       |     * this should always have been true until snmp gets int64 PDU types 
 2279|       |     */
 2280|     55|    else {
 2281|     55|        snprintf(ebuf, sizeof(ebuf),
 2282|     55|                "%s: wrong type: %d, len %d, buf bytes (%02X,%02X)",
 2283|     55|                errpre, *type, (int) asn_length, *bufp, *(bufp + 1));
 2284|     55|        ERROR_MSG(ebuf);
  ------------------
  |  |  188|     55|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 2285|     55|        return NULL;
 2286|     55|    }
 2287|      0|    if (((int) asn_length > int64sizelimit) ||
  ------------------
  |  Branch (2287:9): [True: 0, False: 0]
  ------------------
 2288|      0|        (((int) asn_length == int64sizelimit) && *bufp != 0x00)) {
  ------------------
  |  Branch (2288:10): [True: 0, False: 0]
  |  Branch (2288:50): [True: 0, False: 0]
  ------------------
 2289|      0|        _asn_length_err(errpre, (size_t) asn_length, int64sizelimit);
 2290|      0|        return NULL;
 2291|      0|    }
 2292|      0|    *datalength -= (int) asn_length + (bufp - data);
 2293|      0|    if ((asn_length > 0) && (*bufp & 0x80)) {
  ------------------
  |  Branch (2293:9): [True: 0, False: 0]
  |  Branch (2293:29): [True: 0, False: 0]
  ------------------
 2294|      0|        low = 0xFFFFFFFFU;   /* first byte bit 1 means start the data with 1s */
 2295|      0|        high = 0xFFFFFF;
 2296|      0|    }
 2297|       |
 2298|      0|    for ( ; asn_length; asn_length--) {
  ------------------
  |  Branch (2298:13): [True: 0, False: 0]
  ------------------
 2299|      0|        high = ((0x00FFFFFF & high) << 8) | ((low & 0xFF000000U) >> 24);
 2300|      0|        low = ((low & 0x00FFFFFF) << 8) | *bufp++;
 2301|      0|    }
 2302|       |
 2303|      0|    CHECK_OVERFLOW_U(high,8);
  ------------------
  |  |  224|      0|#define CHECK_OVERFLOW_U(x,y) do {                                      \
  |  |  225|      0|        if (x > UINT32_MAX) {                                           \
  |  |  ------------------
  |  |  |  Branch (225:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  226|      0|            x &= 0xffffffff;                                            \
  |  |  227|      0|            DEBUGMSG(("asn","truncating unsigned value to 32 bits (%d)\n",y)); \
  |  |  ------------------
  |  |  |  |   61|      0|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (61:67): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  228|      0|        }                                                               \
  |  |  229|      0|    } while(0)
  |  |  ------------------
  |  |  |  Branch (229:13): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2304|      0|    CHECK_OVERFLOW_U(low,8);
  ------------------
  |  |  224|      0|#define CHECK_OVERFLOW_U(x,y) do {                                      \
  |  |  225|      0|        if (x > UINT32_MAX) {                                           \
  |  |  ------------------
  |  |  |  Branch (225:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  226|      0|            x &= 0xffffffff;                                            \
  |  |  227|      0|            DEBUGMSG(("asn","truncating unsigned value to 32 bits (%d)\n",y)); \
  |  |  ------------------
  |  |  |  |   61|      0|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (61:67): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  228|      0|        }                                                               \
  |  |  229|      0|    } while(0)
  |  |  ------------------
  |  |  |  Branch (229:13): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2305|       |
 2306|      0|    cp->low = low;
 2307|      0|    cp->high = high;
 2308|       |
 2309|      0|    DEBUGIF("dumpv_recv") {
  ------------------
  |  |  145|      0|#define DEBUGIF(x)         if (_DBG_IF_ && debug_is_token_registered(x) == SNMPERR_SUCCESS)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGIF(x)         if (_DBG_IF_ && debug_is_token_registered(x) == SNMPERR_SUCCESS)
  |  |  ------------------
  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  ------------------
  |  |  |  Branch (145:44): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 2310|      0|        char            i64buf[I64CHARSZ + 1];
 2311|      0|        printI64(i64buf, cp);
 2312|      0|        DEBUGMSG(("dumpv_recv", "Integer64: %s\n", i64buf));
  ------------------
  |  |   61|      0|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (61:67): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2313|      0|    }
 2314|       |
 2315|      0|    return bufp;
 2316|      0|}
asn1.c:_asn_short_err:
  299|    918|{
  300|    918|    char            ebuf[128];
  301|       |
  302|    918|    snprintf(ebuf, sizeof(ebuf), "%s length %lu too short: need %lu", str,
  303|    918|	    (unsigned long)wrongsize, (unsigned long)rightsize);
  304|    918|    ERROR_MSG(ebuf);
  ------------------
  |  |  188|    918|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
  305|    918|}
asn1.c:_asn_type_err:
  261|  3.09k|{
  262|  3.09k|    char            ebuf[128];
  263|       |
  264|  3.09k|    snprintf(ebuf, sizeof(ebuf), "%s type %d", str, wrongtype);
  265|  3.09k|    ebuf[ sizeof(ebuf)-1 ] = 0;
  266|  3.09k|    ERROR_MSG(ebuf);
  ------------------
  |  |  188|  3.09k|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
  267|  3.09k|}
asn1.c:_asn_length_err:
  280|    784|{
  281|    784|    char            ebuf[128];
  282|       |
  283|    784|    snprintf(ebuf, sizeof(ebuf),
  284|    784|            "%s length %lu too large: exceeds %lu", str,
  285|    784|	    (unsigned long)wrongsize, (unsigned long)rightsize);
  286|    784|    ERROR_MSG(ebuf);
  ------------------
  |  |  188|    784|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
  287|    784|}

init_callbacks:
  196|      2|{
  197|       |    /*
  198|       |     * (poses a problem if you put init_callbacks() inside of
  199|       |     * init_snmp() and then want the app to register a callback before
  200|       |     * init_snmp() is called in the first place.  -- Wes 
  201|       |     */
  202|      2|    if (0 == _callback_need_init)
  ------------------
  |  Branch (202:9): [True: 1, False: 1]
  ------------------
  203|      1|        return;
  204|       |    
  205|      1|    _callback_need_init = 0;
  206|       |    
  207|      1|    memset(thecallbacks, 0, sizeof(thecallbacks)); 
  208|      1|#ifdef LOCK_PER_CALLBACK_SUBID
  209|      1|    memset(_locks, 0, sizeof(_locks));
  210|       |#else
  211|       |    _lock = 0;
  212|       |#endif
  213|       |    
  214|      1|    DEBUGMSGTL(("callback", "initialized\n"));
  ------------------
  |  |   66|      1|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 1]
  |  |  ------------------
  ------------------
  215|      1|}
snmp_register_callback:
  256|     11|{
  257|     11|    return netsnmp_register_callback( major, minor, new_callback, arg,
  258|     11|                                      NETSNMP_CALLBACK_DEFAULT_PRIORITY);
  ------------------
  |  |   40|     11|#define NETSNMP_CALLBACK_DEFAULT_PRIORITY       0
  ------------------
  259|     11|}
netsnmp_register_callback:
  278|     11|{
  279|     11|    struct snmp_gen_callback *newscp = NULL, *scp = NULL;
  280|       |
  281|     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 (281:9): [True: 0, False: 11]
  |  Branch (281:38): [True: 0, False: 11]
  ------------------
  282|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  283|      0|    }
  284|       |
  285|     11|    if (_callback_need_init)
  ------------------
  |  Branch (285:9): [True: 1, False: 10]
  ------------------
  286|      1|        init_callbacks();
  287|       |
  288|     11|    _callback_lock(major,minor, "netsnmp_register_callback", 1);
  289|       |    
  290|     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 (290:9): [True: 0, False: 11]
  ------------------
  291|      0|        _callback_unlock(major,minor);
  292|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  293|     11|    } else {
  294|     11|        struct snmp_gen_callback **prevNext = &(thecallbacks[major][minor]);
  295|       |
  296|     11|        newscp->priority = priority;
  297|     11|        newscp->sc_client_arg = arg;
  298|     11|        newscp->sc_callback = new_callback;
  299|     11|        newscp->next = NULL;
  300|       |
  301|     20|        for (scp = thecallbacks[major][minor]; scp != NULL;
  ------------------
  |  Branch (301:48): [True: 9, False: 11]
  ------------------
  302|     11|             scp = scp->next) {
  303|      9|            if (newscp->priority < scp->priority) {
  ------------------
  |  Branch (303:17): [True: 0, False: 9]
  ------------------
  304|      0|                newscp->next = scp;
  305|      0|                break;
  306|      0|            }
  307|      9|            prevNext = &(scp->next);
  308|      9|        }
  309|       |
  310|     11|        *prevNext = newscp;
  311|       |
  312|     11|        DEBUGMSGTL(("callback", "registered (%d,%d) at %p with priority %d\n",
  ------------------
  |  |   66|     11|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     11|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 10, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|     10|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|     10|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|     10|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|     10|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 11]
  |  |  ------------------
  ------------------
  313|     11|                    major, minor, newscp, priority));
  314|     11|        _callback_unlock(major,minor);
  315|     11|        return SNMPERR_SUCCESS;
  ------------------
  |  |  184|     11|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  316|     11|    }
  317|     11|}
snmp_call_callbacks:
  338|     85|{
  339|     85|    struct snmp_gen_callback *scp;
  340|     85|    unsigned int    count = 0;
  341|       |    
  342|     85|    if (major >= MAX_CALLBACK_IDS || minor >= MAX_CALLBACK_SUBIDS) {
  ------------------
  |  |   12|    170|#define MAX_CALLBACK_IDS    2
  ------------------
                  if (major >= MAX_CALLBACK_IDS || minor >= MAX_CALLBACK_SUBIDS) {
  ------------------
  |  |   13|     85|#define MAX_CALLBACK_SUBIDS 18
  ------------------
  |  Branch (342:9): [True: 0, False: 85]
  |  Branch (342:38): [True: 0, False: 85]
  ------------------
  343|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  344|      0|    }
  345|       |    
  346|     85|    if (_callback_need_init)
  ------------------
  |  Branch (346:9): [True: 0, False: 85]
  ------------------
  347|      0|        init_callbacks();
  348|       |
  349|     85|#ifdef LOCK_PER_CALLBACK_SUBID
  350|     85|    _callback_lock(major,minor,"snmp_call_callbacks", 1);
  351|       |#else
  352|       |    /*
  353|       |     * Notes:
  354|       |     * - this gets hit the first time a trap is sent after a new trap
  355|       |     *   destination has been added (session init cb during send trap cb)
  356|       |     */
  357|       |    _callback_lock(major,minor, NULL, 0);
  358|       |#endif
  359|       |
  360|     85|    DEBUGMSGTL(("callback", "START calling callbacks for maj=%d min=%d\n",
  ------------------
  |  |   66|     85|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     85|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 85, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|     85|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|     85|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|     85|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|     85|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 85]
  |  |  ------------------
  ------------------
  361|     85|                major, minor));
  362|       |
  363|       |    /*
  364|       |     * for each registered callback of type major and minor 
  365|       |     */
  366|    172|    for (scp = thecallbacks[major][minor]; scp != NULL; scp = scp->next) {
  ------------------
  |  Branch (366:44): [True: 87, False: 85]
  ------------------
  367|       |
  368|       |        /*
  369|       |         * skip unregistered callbacks
  370|       |         */
  371|     87|        if(NULL == scp->sc_callback)
  ------------------
  |  Branch (371:12): [True: 0, False: 87]
  ------------------
  372|      0|            continue;
  373|       |
  374|     87|        DEBUGMSGTL(("callback", "calling a callback for maj=%d min=%d\n",
  ------------------
  |  |   66|     87|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     87|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 87, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|     87|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|     87|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|     87|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|     87|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 87]
  |  |  ------------------
  ------------------
  375|     87|                    major, minor));
  376|       |
  377|       |        /*
  378|       |         * call them 
  379|       |         */
  380|     87|        (*(scp->sc_callback)) (major, minor, caller_arg,
  381|     87|                               scp->sc_client_arg);
  382|     87|        count++;
  383|     87|    }
  384|       |
  385|     85|    DEBUGMSGTL(("callback",
  ------------------
  |  |   66|     85|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     85|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 85, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|     85|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|     85|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|     85|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|     85|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 85]
  |  |  ------------------
  ------------------
  386|     85|                "END calling callbacks for maj=%d min=%d (%d called)\n",
  387|     85|                major, minor, count));
  388|       |
  389|     85|    _callback_unlock(major,minor);
  390|     85|    return SNMPERR_SUCCESS;
  ------------------
  |  |  184|     85|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  391|     85|}
callback.c:_callback_lock:
  119|     96|{
  120|     96|    int lock_holded=0;
  121|     96|    NETSNMP_SELECT_TIMEVAL lock_time;
  ------------------
  |  | 1755|     96|#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|     96|#ifdef CALLBACK_NAME_LOGGING
  131|     96|    DEBUGMSGTL(("9:callback:lock", "locked (%s,%s)\n",
  ------------------
  |  |   66|     96|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     96|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 95, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|    380|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|     95|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|     95|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|     95|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (164:52): [True: 93, False: 2]
  |  |  |  |  |  Branch (164:52): [True: 95, False: 0]
  |  |  |  |  |  Branch (164:64): [True: 93, False: 2]
  |  |  |  |  |  Branch (164:64): [True: 95, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 96]
  |  |  ------------------
  ------------------
  132|     96|                types[major], (SNMP_CALLBACK_LIBRARY == major) ?
  133|     96|                SNMP_STRORNULL(lib[minor]) : "null"));
  134|     96|#endif
  135|     96|    while (CALLBACK_LOCK_COUNT(major,minor) >= 1 && ++lock_holded < 100) {
  ------------------
  |  |  109|     96|#define CALLBACK_LOCK_COUNT(maj,min) _locks[maj][min]
  ------------------
  |  Branch (135:12): [True: 0, False: 96]
  |  Branch (135:53): [True: 0, False: 0]
  ------------------
  136|      0|	lock_time.tv_sec = 0;
  137|      0|	lock_time.tv_usec = 1000;
  138|      0|	select(0, NULL, NULL, NULL, &lock_time);
  139|      0|    }
  140|       |
  141|     96|    if(lock_holded >= 100) {
  ------------------
  |  Branch (141:8): [True: 0, False: 96]
  ------------------
  142|      0|        if (NULL != warn)
  ------------------
  |  Branch (142:13): [True: 0, False: 0]
  ------------------
  143|      0|            snmp_log(LOG_WARNING,
  144|      0|                     "lock in _callback_lock sleeps more than 100 milliseconds in %s\n", warn);
  145|      0|        if (do_assert)
  ------------------
  |  Branch (145:13): [True: 0, False: 0]
  ------------------
  146|      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
  |  |  |  |  ------------------
  |  |  |  |  |  | 1705|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|      0|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded, False: 0]
  |  |  ------------------
  ------------------
  147|       |        
  148|      0|        return 1;
  149|      0|    }
  150|       |
  151|     96|    CALLBACK_LOCK(major,minor);
  ------------------
  |  |  107|     96|#define CALLBACK_LOCK(maj,min) ++_locks[maj][min]
  ------------------
  152|     96|    return 0;
  153|     96|}
callback.c:_callback_unlock:
  157|     96|{
  158|       |#ifdef NETSNMP_PARANOID_LEVEL_HIGH
  159|       |    if (major >= MAX_CALLBACK_IDS || minor >= MAX_CALLBACK_SUBIDS) {
  160|       |        netsnmp_assert("bad callback id");
  161|       |        return;
  162|       |    }
  163|       |#endif
  164|       |    
  165|     96|    CALLBACK_UNLOCK(major,minor);
  ------------------
  |  |  108|     96|#define CALLBACK_UNLOCK(maj,min) --_locks[maj][min]
  ------------------
  166|       |
  167|     96|    if (CALLBACK_LOCK_COUNT(major,minor) == 0) {
  ------------------
  |  |  109|     96|#define CALLBACK_LOCK_COUNT(maj,min) _locks[maj][min]
  ------------------
  |  Branch (167:9): [True: 96, False: 0]
  ------------------
  168|     96|        struct snmp_gen_callback *scp, **prevNext;
  169|     96|        scp = thecallbacks[major][minor];
  170|     96|        prevNext = &(thecallbacks[major][minor]);
  171|    203|        while (scp != NULL) {
  ------------------
  |  Branch (171:16): [True: 107, False: 96]
  ------------------
  172|    107|            if (scp->sc_callback == NULL) {
  ------------------
  |  Branch (172:17): [True: 0, False: 107]
  ------------------
  173|      0|                *prevNext = scp->next;
  174|      0|                SNMP_FREE(scp);
  ------------------
  |  |   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, False: 0]
  |  |  ------------------
  ------------------
  175|      0|                scp = *prevNext;
  176|    107|            } else {
  177|    107|                prevNext = &(scp->next);
  178|    107|                scp = scp->next;
  179|    107|            }
  180|    107|        }
  181|     96|    }
  182|       |
  183|     96|#ifdef CALLBACK_NAME_LOGGING
  184|     96|    DEBUGMSGTL(("9:callback:lock", "unlocked (%s,%s)\n",
  ------------------
  |  |   66|     96|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     96|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 95, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|    380|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|     95|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|     95|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|     95|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (164:52): [True: 93, False: 2]
  |  |  |  |  |  Branch (164:52): [True: 95, False: 0]
  |  |  |  |  |  Branch (164:64): [True: 93, False: 2]
  |  |  |  |  |  Branch (164:64): [True: 95, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 96]
  |  |  ------------------
  ------------------
  185|     96|                types[major], (SNMP_CALLBACK_LIBRARY == major) ?
  186|     96|                SNMP_STRORNULL(lib[minor]) : "null"));
  187|     96|#endif
  188|     96|}

_netsnmp_release_trustcerts:
  175|      1|{
  176|      1|    if (NULL != _trusted_certs) {
  ------------------
  |  Branch (176:9): [True: 1, False: 0]
  ------------------
  177|      1|        CONTAINER_FREE_ALL(_trusted_certs, NULL);
  178|      1|        CONTAINER_FREE(_trusted_certs);
  179|       |        _trusted_certs = NULL;
  180|      1|    }
  181|      1|}
_setup_trusted_certs:
  185|      1|{
  186|      1|    _trusted_certs = netsnmp_container_find("trusted_certs:fifo");
  187|      1|    if (NULL == _trusted_certs) {
  ------------------
  |  Branch (187:9): [True: 0, False: 1]
  ------------------
  188|      0|        snmp_log(LOG_ERR, "could not create container for trusted certs\n");
  189|      0|        netsnmp_certs_shutdown();
  190|      0|        return;
  191|      0|    }
  192|      1|    _trusted_certs->container_name = strdup("trusted certificates");
  193|      1|    _trusted_certs->compare = netsnmp_str_compare;
  194|      1|}
netsnmp_certs_init:
  209|      1|{
  210|      1|    const char *trustCert_help = TRUSTCERT_CONFIG_TOKEN
  ------------------
  |  |  140|      1|#define TRUSTCERT_CONFIG_TOKEN "trustCert"
  ------------------
  211|      1|        " FINGERPRINT|FILENAME";
  212|       |
  213|      1|    register_config_handler("snmp", TRUSTCERT_CONFIG_TOKEN,
  ------------------
  |  |  140|      1|#define TRUSTCERT_CONFIG_TOKEN "trustCert"
  ------------------
  214|      1|                            _parse_trustcert, _netsnmp_release_trustcerts,
  215|      1|                            trustCert_help);
  216|      1|    _setup_containers();
  217|       |
  218|       |    /** add certificate type mapping */
  219|      1|    se_add_pair_to_slist("cert_types", strdup("pem"), NS_CERT_TYPE_PEM);
  220|      1|    se_add_pair_to_slist("cert_types", strdup("crt"), NS_CERT_TYPE_DER);
  221|      1|    se_add_pair_to_slist("cert_types", strdup("cer"), NS_CERT_TYPE_DER);
  222|      1|    se_add_pair_to_slist("cert_types", strdup("cert"), NS_CERT_TYPE_DER);
  223|      1|    se_add_pair_to_slist("cert_types", strdup("der"), NS_CERT_TYPE_DER);
  224|      1|    se_add_pair_to_slist("cert_types", strdup("key"), NS_CERT_TYPE_KEY);
  225|      1|    se_add_pair_to_slist("cert_types", strdup("private"), NS_CERT_TYPE_KEY);
  226|       |
  227|       |    /** hash algs */
  228|      1|    se_add_pair_to_slist("cert_hash_alg", strdup("sha1"), NS_HASH_SHA1);
  ------------------
  |  |   85|      1|#define NS_HASH_SHA1        2
  ------------------
  229|      1|    se_add_pair_to_slist("cert_hash_alg", strdup("md5"), NS_HASH_MD5);
  ------------------
  |  |   84|      1|#define NS_HASH_MD5         1
  ------------------
  230|      1|    se_add_pair_to_slist("cert_hash_alg", strdup("sha224"), NS_HASH_SHA224);
  ------------------
  |  |   86|      1|#define NS_HASH_SHA224      3
  ------------------
  231|      1|    se_add_pair_to_slist("cert_hash_alg", strdup("sha256"), NS_HASH_SHA256);
  ------------------
  |  |   87|      1|#define NS_HASH_SHA256      4
  ------------------
  232|      1|    se_add_pair_to_slist("cert_hash_alg", strdup("sha384"), NS_HASH_SHA384);
  ------------------
  |  |   88|      1|#define NS_HASH_SHA384      5
  ------------------
  233|      1|    se_add_pair_to_slist("cert_hash_alg", strdup("sha512"), NS_HASH_SHA512);
  ------------------
  |  |   89|      1|#define NS_HASH_SHA512      6
  ------------------
  234|       |
  235|       |    /** map types */
  236|      1|    se_add_pair_to_slist("cert_map_type", strdup("cn"),
  237|      1|                         TSNM_tlstmCertCommonName);
  ------------------
  |  |  129|      1|#define TSNM_tlstmCertCommonName                6
  ------------------
  238|      1|    se_add_pair_to_slist("cert_map_type", strdup("ip"),
  239|      1|                         TSNM_tlstmCertSANIpAddress);
  ------------------
  |  |  127|      1|#define TSNM_tlstmCertSANIpAddress              4
  ------------------
  240|      1|    se_add_pair_to_slist("cert_map_type", strdup("rfc822"),
  241|      1|                         TSNM_tlstmCertSANRFC822Name);
  ------------------
  |  |  125|      1|#define TSNM_tlstmCertSANRFC822Name             2
  ------------------
  242|      1|    se_add_pair_to_slist("cert_map_type", strdup("dns"),
  243|      1|                         TSNM_tlstmCertSANDNSName);
  ------------------
  |  |  126|      1|#define TSNM_tlstmCertSANDNSName                3
  ------------------
  244|      1|    se_add_pair_to_slist("cert_map_type", strdup("any"), TSNM_tlstmCertSANAny);
  ------------------
  |  |  128|      1|#define TSNM_tlstmCertSANAny                    5
  ------------------
  245|      1|    se_add_pair_to_slist("cert_map_type", strdup("sn"),
  246|      1|                         TSNM_tlstmCertSpecified);
  ------------------
  |  |  124|      1|#define TSNM_tlstmCertSpecified                 1
  ------------------
  247|       |
  248|      1|}
netsnmp_certs_load:
  271|      1|{
  272|      1|    netsnmp_iterator  *itr;
  273|      1|    netsnmp_key        *key;
  274|      1|    netsnmp_cert       *cert;
  275|       |
  276|      1|    DEBUGMSGT(("cert:util:init","init\n"));
  ------------------
  |  |   62|      1|#define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  147|      1|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  ------------------
  |  |  |  Branch (62:69): [Folded, False: 1]
  |  |  ------------------
  ------------------
  277|       |
  278|      1|    if (NULL == _certs) {
  ------------------
  |  Branch (278:9): [True: 0, False: 1]
  ------------------
  279|      0|        snmp_log(LOG_ERR, "cant load certs without container\n");
  280|      0|        return;
  281|      0|    }
  282|       |
  283|      1|    if (CONTAINER_SIZE(_certs) != 0) {
  ------------------
  |  |  403|      1|#define CONTAINER_SIZE(x)           (x)->get_size(x)
  ------------------
  |  Branch (283:9): [True: 0, False: 1]
  ------------------
  284|      0|        DEBUGMSGT(("cert:util:init", "ignoring duplicate init\n"));
  ------------------
  |  |   62|      0|#define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  ------------------
  |  |  |  Branch (62:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
  285|      0|        return;
  286|      0|    }
  287|       |
  288|      1|    netsnmp_init_openssl();
  289|       |
  290|       |    /** scan config dirs for certs */
  291|      1|    _cert_indexes_load();
  292|       |
  293|       |    /** match up keys w/certs */
  294|      1|    itr = CONTAINER_ITERATOR(_keys);
  ------------------
  |  |  404|      1|#define CONTAINER_ITERATOR(x)       (x)->get_iterator(x)
  ------------------
  295|      1|    if (NULL == itr) {
  ------------------
  |  Branch (295:9): [True: 0, False: 1]
  ------------------
  296|      0|        snmp_log(LOG_ERR, "could not get iterator for keys\n");
  297|      0|        netsnmp_certs_shutdown();
  298|      0|        return;
  299|      0|    }
  300|      1|    key = ITERATOR_FIRST(itr);
  ------------------
  |  |  546|      1|#define ITERATOR_FIRST(x)  x->first(x)
  ------------------
  301|      1|    for( ; key; key = ITERATOR_NEXT(itr))
  ------------------
  |  |  547|      0|#define ITERATOR_NEXT(x)   x->next(x)
  ------------------
  |  Branch (301:12): [True: 0, False: 1]
  ------------------
  302|      0|        _find_partner(NULL, key);
  303|      1|    ITERATOR_RELEASE(itr);
  ------------------
  |  |  550|      1|#define ITERATOR_RELEASE(x) do { x->release(x); x = NULL; } while(0)
  |  |  ------------------
  |  |  |  Branch (550:67): [Folded, False: 1]
  |  |  ------------------
  ------------------
  304|       |
  305|      1|    DEBUGIF("cert:dump") {
  ------------------
  |  |  145|      1|#define DEBUGIF(x)         if (_DBG_IF_ && debug_is_token_registered(x) == SNMPERR_SUCCESS)
  |  |  ------------------
  |  |  |  |  144|      2|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGIF(x)         if (_DBG_IF_ && debug_is_token_registered(x) == SNMPERR_SUCCESS)
  |  |  ------------------
  |  |  |  |  184|      1|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  ------------------
  |  |  |  Branch (145:44): [True: 1, False: 0]
  |  |  ------------------
  ------------------
  306|      1|        itr = CONTAINER_ITERATOR(_certs);
  ------------------
  |  |  404|      1|#define CONTAINER_ITERATOR(x)       (x)->get_iterator(x)
  ------------------
  307|      1|        if (NULL == itr) {
  ------------------
  |  Branch (307:13): [True: 0, False: 1]
  ------------------
  308|      0|            snmp_log(LOG_ERR, "could not get iterator for certs\n");
  309|      0|            netsnmp_certs_shutdown();
  310|      0|            return;
  311|      0|        }
  312|      1|        cert = ITERATOR_FIRST(itr);
  ------------------
  |  |  546|      1|#define ITERATOR_FIRST(x)  x->first(x)
  ------------------
  313|      1|        for( ; cert; cert = ITERATOR_NEXT(itr)) {
  ------------------
  |  |  547|      0|#define ITERATOR_NEXT(x)   x->next(x)
  ------------------
  |  Branch (313:16): [True: 0, False: 1]
  ------------------
  314|      0|            netsnmp_cert_load_x509(cert);
  315|      0|        }
  316|      1|        ITERATOR_RELEASE(itr);
  ------------------
  |  |  550|      1|#define ITERATOR_RELEASE(x) do { x->release(x); x = NULL; } while(0)
  |  |  ------------------
  |  |  |  Branch (550:67): [Folded, False: 1]
  |  |  ------------------
  ------------------
  317|      1|        DEBUGMSGT(("cert:dump",
  ------------------
  |  |   62|      1|#define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  147|      1|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  ------------------
  |  |  |  Branch (62:69): [Folded, False: 1]
  |  |  ------------------
  ------------------
  318|      1|                   "-------------------- Certificates -----------------\n"));
  319|      1|        netsnmp_cert_dump_all();
  320|      1|        DEBUGMSGT(("cert:dump",
  ------------------
  |  |   62|      1|#define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  147|      1|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  ------------------
  |  |  |  Branch (62:69): [Folded, False: 1]
  |  |  ------------------
  ------------------
  321|      1|                   "------------------------ End ----------------------\n"));
  322|      1|    }
  323|      1|}
netsnmp_cert_dump_all:
 1809|      1|{
 1810|      1|    CONTAINER_FOR_EACH(_certs, _cert_print, NULL);
  ------------------
  |  |  406|      1|#define CONTAINER_FOR_EACH(x,f,c)   (x)->for_each(x,f,c)
  ------------------
 1811|      1|    CONTAINER_FOR_EACH(_keys, _key_print, NULL);
  ------------------
  |  |  406|      1|#define CONTAINER_FOR_EACH(x,f,c)   (x)->for_each(x,f,c)
  ------------------
 1812|      1|}
cert_util.c:_setup_containers:
  353|      1|{
  354|      1|    netsnmp_container *additional_keys;
  355|       |
  356|      1|    int rc;
  357|       |
  358|      1|    _certs = _get_cert_container("netsnmp certificates");
  359|      1|    if (NULL == _certs)
  ------------------
  |  Branch (359:9): [True: 0, False: 1]
  ------------------
  360|      0|        return;
  361|       |
  362|       |    /** additional keys: common name */
  363|      1|    additional_keys = netsnmp_container_find("certs_cn:binary_array");
  364|      1|    if (NULL == additional_keys) {
  ------------------
  |  Branch (364:9): [True: 0, False: 1]
  ------------------
  365|      0|        snmp_log(LOG_ERR, "could not create CN container for certificates\n");
  366|      0|        netsnmp_certs_shutdown();
  367|      0|        return;
  368|      0|    }
  369|      1|    additional_keys->container_name = strdup("certs_cn");
  370|      1|    additional_keys->free_item = NULL;
  371|      1|    additional_keys->compare = _cert_cn_compare;
  372|      1|    CONTAINER_SET_OPTIONS(additional_keys, CONTAINER_KEY_ALLOW_DUPLICATES, rc);
  ------------------
  |  |  375|      1|#define CONTAINER_SET_OPTIONS(x,o,rc)  do {                             \
  |  |  376|      1|        if (NULL==(x)->options)                                         \
  |  |  ------------------
  |  |  |  Branch (376:13): [True: 0, False: 1]
  |  |  ------------------
  |  |  377|      1|            rc = -1;                                                    \
  |  |  378|      1|        else {                                                          \
  |  |  379|      1|            rc = (x)->options(x, 1, o);                                 \
  |  |  380|      1|            if (rc != -1 )                                              \
  |  |  ------------------
  |  |  |  Branch (380:17): [True: 1, False: 0]
  |  |  ------------------
  |  |  381|      1|                (x)->flags |= o;                                        \
  |  |  382|      1|        }                                                               \
  |  |  383|      1|    } while(0)
  |  |  ------------------
  |  |  |  Branch (383:13): [Folded, False: 1]
  |  |  ------------------
  ------------------
  373|      1|    netsnmp_container_add_index(_certs, additional_keys);
  374|       |
  375|       |    /** additional keys: subject name */
  376|      1|    additional_keys = netsnmp_container_find("certs_sn:binary_array");
  377|      1|    if (NULL == additional_keys) {
  ------------------
  |  Branch (377:9): [True: 0, False: 1]
  ------------------
  378|      0|        snmp_log(LOG_ERR, "could not create SN container for certificates\n");
  379|      0|        netsnmp_certs_shutdown();
  380|      0|        return;
  381|      0|    }
  382|      1|    additional_keys->container_name = strdup("certs_sn");
  383|      1|    additional_keys->free_item = NULL;
  384|      1|    additional_keys->compare = _cert_sn_compare;
  385|      1|    additional_keys->ncompare = _cert_sn_ncompare;
  386|      1|    CONTAINER_SET_OPTIONS(additional_keys, CONTAINER_KEY_ALLOW_DUPLICATES, rc);
  ------------------
  |  |  375|      1|#define CONTAINER_SET_OPTIONS(x,o,rc)  do {                             \
  |  |  376|      1|        if (NULL==(x)->options)                                         \
  |  |  ------------------
  |  |  |  Branch (376:13): [True: 0, False: 1]
  |  |  ------------------
  |  |  377|      1|            rc = -1;                                                    \
  |  |  378|      1|        else {                                                          \
  |  |  379|      1|            rc = (x)->options(x, 1, o);                                 \
  |  |  380|      1|            if (rc != -1 )                                              \
  |  |  ------------------
  |  |  |  Branch (380:17): [True: 1, False: 0]
  |  |  ------------------
  |  |  381|      1|                (x)->flags |= o;                                        \
  |  |  382|      1|        }                                                               \
  |  |  383|      1|    } while(0)
  |  |  ------------------
  |  |  |  Branch (383:13): [Folded, False: 1]
  |  |  ------------------
  ------------------
  387|      1|    netsnmp_container_add_index(_certs, additional_keys);
  388|       |
  389|       |    /** additional keys: file name */
  390|      1|    additional_keys = netsnmp_container_find("certs_fn:binary_array");
  391|      1|    if (NULL == additional_keys) {
  ------------------
  |  Branch (391:9): [True: 0, False: 1]
  ------------------
  392|      0|        snmp_log(LOG_ERR, "could not create FN container for certificates\n");
  393|      0|        netsnmp_certs_shutdown();
  394|      0|        return;
  395|      0|    }
  396|      1|    additional_keys->container_name = strdup("certs_fn");
  397|      1|    additional_keys->free_item = NULL;
  398|      1|    additional_keys->compare = _cert_fn_compare;
  399|      1|    additional_keys->ncompare = _cert_fn_ncompare;
  400|      1|    CONTAINER_SET_OPTIONS(additional_keys, CONTAINER_KEY_ALLOW_DUPLICATES, rc);
  ------------------
  |  |  375|      1|#define CONTAINER_SET_OPTIONS(x,o,rc)  do {                             \
  |  |  376|      1|        if (NULL==(x)->options)                                         \
  |  |  ------------------
  |  |  |  Branch (376:13): [True: 0, False: 1]
  |  |  ------------------
  |  |  377|      1|            rc = -1;                                                    \
  |  |  378|      1|        else {                                                          \
  |  |  379|      1|            rc = (x)->options(x, 1, o);                                 \
  |  |  380|      1|            if (rc != -1 )                                              \
  |  |  ------------------
  |  |  |  Branch (380:17): [True: 1, False: 0]
  |  |  ------------------
  |  |  381|      1|                (x)->flags |= o;                                        \
  |  |  382|      1|        }                                                               \
  |  |  383|      1|    } while(0)
  |  |  ------------------
  |  |  |  Branch (383:13): [Folded, False: 1]
  |  |  ------------------
  ------------------
  401|      1|    netsnmp_container_add_index(_certs, additional_keys);
  402|       |
  403|      1|    _keys = netsnmp_container_find("cert_keys:binary_array");
  404|      1|    if (NULL == _keys) {
  ------------------
  |  Branch (404:9): [True: 0, False: 1]
  ------------------
  405|      0|        snmp_log(LOG_ERR, "could not create container for certificate keys\n");
  406|      0|        netsnmp_certs_shutdown();
  407|      0|        return;
  408|      0|    }
  409|      1|    _keys->container_name = strdup("netsnmp certificate keys");
  410|      1|    _keys->free_item = _key_free;
  411|      1|    _keys->compare = _cert_fn_compare;
  412|       |
  413|      1|    _setup_trusted_certs();
  414|      1|}
cert_util.c:_get_cert_container:
  332|      1|{
  333|      1|    netsnmp_container *c;
  334|       |
  335|      1|    int rc;
  336|       |
  337|      1|    c = netsnmp_container_find("certs:binary_array");
  338|      1|    if (NULL == c) {
  ------------------
  |  Branch (338:9): [True: 0, False: 1]
  ------------------
  339|      0|        snmp_log(LOG_ERR, "could not create container for %s\n", use);
  340|      0|        return NULL;
  341|      0|    }
  342|      1|    c->container_name = strdup(use);
  343|      1|    c->free_item = _cert_free;
  344|      1|    c->compare = _cert_compare;
  345|       |
  346|      1|    CONTAINER_SET_OPTIONS(c, CONTAINER_KEY_ALLOW_DUPLICATES, rc);
  ------------------
  |  |  375|      1|#define CONTAINER_SET_OPTIONS(x,o,rc)  do {                             \
  |  |  376|      1|        if (NULL==(x)->options)                                         \
  |  |  ------------------
  |  |  |  Branch (376:13): [True: 0, False: 1]
  |  |  ------------------
  |  |  377|      1|            rc = -1;                                                    \
  |  |  378|      1|        else {                                                          \
  |  |  379|      1|            rc = (x)->options(x, 1, o);                                 \
  |  |  380|      1|            if (rc != -1 )                                              \
  |  |  ------------------
  |  |  |  Branch (380:17): [True: 1, False: 0]
  |  |  ------------------
  |  |  381|      1|                (x)->flags |= o;                                        \
  |  |  382|      1|        }                                                               \
  |  |  383|      1|    } while(0)
  |  |  ------------------
  |  |  |  Branch (383:13): [Folded, False: 1]
  |  |  ------------------
  ------------------
  347|       |
  348|      1|    return c;
  349|      1|}
cert_util.c:_cert_indexes_load:
 1721|      1|{
 1722|      1|    const char     *confpath;
 1723|      1|    char           *confpath_copy, *dir, *st = NULL;
 1724|      1|    char            certdir[SNMP_MAXPATH];
 1725|      1|    const char     *subdirs[] = { NULL, "ca-certs", "certs", "private", NULL };
 1726|      1|    int             i = 0;
 1727|       |
 1728|       |    /*
 1729|       |     * load indexes from persistent dir
 1730|       |     */
 1731|      1|    _certindexes_load();
 1732|       |
 1733|       |    /*
 1734|       |     * duplicate path building from read_config_files_of_type() in
 1735|       |     * read_config.c. That is, use SNMPCONFPATH environment variable if
 1736|       |     * it is defined, otherwise use configuration directory.
 1737|       |     */
 1738|      1|    confpath = netsnmp_getenv("SNMPCONFPATH");
 1739|      1|    if (NULL == confpath)
  ------------------
  |  Branch (1739:9): [True: 1, False: 0]
  ------------------
 1740|      1|        confpath = get_configuration_directory();
 1741|       |
 1742|      1|    subdirs[0] = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1743|      1|                                       NETSNMP_DS_LIB_CERT_EXTRA_SUBDIR);
  ------------------
  |  |  177|      1|#define NETSNMP_DS_LIB_CERT_EXTRA_SUBDIR 26
  ------------------
 1744|      1|    confpath_copy = strdup(confpath);
 1745|      1|    if (!confpath_copy)
  ------------------
  |  Branch (1745:9): [True: 0, False: 1]
  ------------------
 1746|      0|        return;
 1747|      1|    for ( dir = strtok_r(confpath_copy, ENV_SEPARATOR, &st);
  ------------------
  |  |   67|      1|#define ENV_SEPARATOR ":"
  ------------------
 1748|      5|          dir; dir = strtok_r(NULL, ENV_SEPARATOR, &st)) {
  ------------------
  |  |   67|      4|#define ENV_SEPARATOR ":"
  ------------------
  |  Branch (1748:11): [True: 4, False: 1]
  ------------------
 1749|       |
 1750|      4|        i = (NULL == subdirs[0]) ? 1 : 0;
  ------------------
  |  Branch (1750:13): [True: 4, False: 0]
  ------------------
 1751|     16|        for ( ; subdirs[i] ; ++i ) {
  ------------------
  |  Branch (1751:17): [True: 12, False: 4]
  ------------------
 1752|       |            /** check tls subdir */
 1753|     12|            snprintf(certdir, sizeof(certdir), "%s/tls/%s", dir, subdirs[i]);
 1754|     12|            _add_certdir(certdir);
 1755|     12|        } /* for subdirs */
 1756|      4|    } /* for conf path dirs */
 1757|       |    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, False: 1]
  |  |  ------------------
  ------------------
 1758|      1|}
cert_util.c:_certindexes_load:
  779|      1|{
  780|      1|    DIR *dir;
  781|      1|    struct dirent *file;
  782|      1|    FILE *fp;
  783|      1|    char filename[SNMP_MAXPATH], line[300];
  784|      1|    int  i;
  785|      1|    char *cp, *pos;
  786|       |
  787|       |    /*
  788|       |     * Open the CERT index directory, or create it (empty)
  789|       |     */
  790|      1|    snprintf(filename, sizeof(filename), "%s/cert_indexes",
  791|      1|             get_persistent_directory());
  792|      1|    dir = opendir( filename );
  793|      1|    if ( dir == NULL ) {
  ------------------
  |  Branch (793:10): [True: 0, False: 1]
  ------------------
  794|      0|        DEBUGMSGT(("cert:index:load",
  ------------------
  |  |   62|      0|#define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  ------------------
  |  |  |  Branch (62:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
  795|      0|                   "creating new cert_indexes directory\n"));
  796|      0|        mkdirhier( filename, NETSNMP_AGENT_DIRECTORY_MODE, 0);
  ------------------
  |  | 2008|      0|#define NETSNMP_AGENT_DIRECTORY_MODE 0700
  ------------------
  797|      0|        return;
  798|      0|    }
  799|       |
  800|       |    /*
  801|       |     * Create a list of which directory each file refers to
  802|       |     */
  803|      3|    while ((file = readdir( dir ))) {
  ------------------
  |  Branch (803:12): [True: 2, False: 1]
  ------------------
  804|      2|        if ( !isdigit(0xFF & file->d_name[0]))
  ------------------
  |  Branch (804:14): [True: 2, False: 0]
  ------------------
  805|      2|            continue;
  806|      0|        i = atoi( file->d_name );
  807|       |
  808|      0|        snprintf(filename, sizeof(filename), "%s/cert_indexes/%d",
  809|      0|                 get_persistent_directory(), i );
  810|      0|        fp = fopen( filename, "r" );
  811|      0|        if ( !fp ) {
  ------------------
  |  Branch (811:14): [True: 0, False: 0]
  ------------------
  812|      0|            DEBUGMSGT(("cert:index:load", "error opening index (%d)\n", i));
  ------------------
  |  |   62|      0|#define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  ------------------
  |  |  |  Branch (62:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
  813|      0|            continue;
  814|      0|        }
  815|      0|        cp = fgets( line, sizeof(line), fp );
  816|      0|        if ( cp ) {
  ------------------
  |  Branch (816:14): [True: 0, False: 0]
  ------------------
  817|      0|            line[strlen(line)-1] = 0;
  818|      0|            pos = strrchr(line, ' ');
  819|      0|            if (pos)
  ------------------
  |  Branch (819:17): [True: 0, False: 0]
  ------------------
  820|      0|                *pos = '\0';
  821|      0|            DEBUGMSGT(("9:cert:index:load","adding (%d) %s\n", i, line));
  ------------------
  |  |   62|      0|#define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  ------------------
  |  |  |  Branch (62:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
  822|      0|            (void)_certindex_add( line+4, i );  /* Skip 'DIR ' */
  823|      0|        } else {
  824|      0|            DEBUGMSGT(("cert:index:load", "Empty index (%d)\n", i));
  ------------------
  |  |   62|      0|#define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  ------------------
  |  |  |  Branch (62:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
  825|      0|        }
  826|      0|        fclose( fp );
  827|      0|    }
  828|      1|    closedir( dir );
  829|      1|}
cert_util.c:_add_certdir:
 1630|     12|{
 1631|     12|    FILE           *index;
 1632|     12|    char           *file;
 1633|     12|    int             count = 0;
 1634|     12|    netsnmp_container *cert_container;
 1635|     12|    netsnmp_iterator  *it;
 1636|     12|    struct stat     statbuf;
 1637|       |
 1638|     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
  |  |  |  |  ------------------
  |  |  |  |  |  | 1705|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|     12|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded, False: 12]
  |  |  ------------------
  ------------------
 1639|       |
 1640|     12|    DEBUGMSGT(("9:cert:dir:add", " config dir: %s\n", dirname ));
  ------------------
  |  |   62|     12|#define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     12|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 12, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  147|     12|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  ------------------
  |  |  |  Branch (62:69): [Folded, False: 12]
  |  |  ------------------
  ------------------
 1641|       |
 1642|     12|    if (stat(dirname, &statbuf) != 0) {
  ------------------
  |  Branch (1642:9): [True: 12, False: 0]
  ------------------
 1643|     12|        DEBUGMSGT(("9:cert:dir:add", " dir not present: %s\n",
  ------------------
  |  |   62|     12|#define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     12|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 12, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  147|     12|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  ------------------
  |  |  |  Branch (62:69): [Folded, False: 12]
  |  |  ------------------
  ------------------
 1644|     12|                   dirname ));
 1645|     12|        return -1;
 1646|     12|    }
 1647|      0|#ifdef S_ISDIR
 1648|      0|    if (!S_ISDIR(statbuf.st_mode)) {
  ------------------
  |  Branch (1648:9): [True: 0, False: 0]
  ------------------
 1649|      0|        DEBUGMSGT(("9:cert:dir:add", " not a dir: %s\n", dirname ));
  ------------------
  |  |   62|      0|#define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  ------------------
  |  |  |  Branch (62:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1650|      0|        return -1;
 1651|      0|    }
 1652|      0|#endif
 1653|       |
 1654|      0|    DEBUGMSGT(("cert:index:dir", "Scanning directory %s\n", dirname));
  ------------------
  |  |   62|      0|#define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  ------------------
  |  |  |  Branch (62:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1655|       |
 1656|       |    /*
 1657|       |     * look for existing index
 1658|       |     */
 1659|      0|    count = _cert_read_index(dirname, &statbuf);
 1660|      0|    if (count >= 0)
  ------------------
  |  Branch (1660:9): [True: 0, False: 0]
  ------------------
 1661|      0|        return count;
 1662|       |
 1663|      0|    index = _certindex_new( dirname );
 1664|      0|    if (NULL == index) {
  ------------------
  |  Branch (1664:9): [True: 0, False: 0]
  ------------------
 1665|      0|        DEBUGMSGT(("9:cert:index:dir",
  ------------------
  |  |   62|      0|#define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  ------------------
  |  |  |  Branch (62:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1666|      0|                    "error opening index for cert directory\n"));
 1667|      0|        DEBUGMSGTL(("cert:index", "could not open certificate index file\n"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1668|      0|    }
 1669|       |
 1670|       |    /*
 1671|       |     * index was missing, out of date or bad. rescan directory.
 1672|       |     */
 1673|      0|    cert_container =
 1674|      0|        netsnmp_directory_container_read_some(NULL, dirname,
 1675|      0|                                              _cert_cert_filter, NULL,
 1676|      0|                                              NETSNMP_DIR_RELATIVE_PATH |
  ------------------
  |  |   48|      0|#define NETSNMP_DIR_RELATIVE_PATH                     0x0002
  ------------------
 1677|      0|                                              NETSNMP_DIR_EMPTY_OK |
  ------------------
  |  |   51|      0|#define NETSNMP_DIR_EMPTY_OK                          0x0008
  ------------------
 1678|      0|                                              NETSNMP_DIR_ALLOW_DUPLICATES);
  ------------------
  |  |   57|      0|#define NETSNMP_DIR_ALLOW_DUPLICATES                  0x0040
  ------------------
 1679|      0|    if (NULL == cert_container) {
  ------------------
  |  Branch (1679:9): [True: 0, False: 0]
  ------------------
 1680|      0|        DEBUGMSGT(("cert:index:dir",
  ------------------
  |  |   62|      0|#define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  ------------------
  |  |  |  Branch (62:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1681|      0|                    "error creating container for cert files\n"));
 1682|      0|        goto err_index;
 1683|      0|    }
 1684|       |
 1685|       |    /*
 1686|       |     * iterate through the found files and add them to index
 1687|       |     */
 1688|      0|    it = CONTAINER_ITERATOR(cert_container);
  ------------------
  |  |  404|      0|#define CONTAINER_ITERATOR(x)       (x)->get_iterator(x)
  ------------------
 1689|      0|    if (NULL == it) {
  ------------------
  |  Branch (1689:9): [True: 0, False: 0]
  ------------------
 1690|      0|        DEBUGMSGT(("cert:index:dir",
  ------------------
  |  |   62|      0|#define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  ------------------
  |  |  |  Branch (62:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1691|      0|                    "error creating iterator for cert files\n"));
 1692|      0|        goto err_container;
 1693|      0|    }
 1694|       |
 1695|      0|    for (file = ITERATOR_FIRST(it); file; file = ITERATOR_NEXT(it)) {
  ------------------
  |  |  546|      0|#define ITERATOR_FIRST(x)  x->first(x)
  ------------------
                  for (file = ITERATOR_FIRST(it); file; file = ITERATOR_NEXT(it)) {
  ------------------
  |  |  547|      0|#define ITERATOR_NEXT(x)   x->next(x)
  ------------------
  |  Branch (1695:37): [True: 0, False: 0]
  ------------------
 1696|      0|        DEBUGMSGT(("cert:index:dir", "adding %s to index\n", file));
  ------------------
  |  |   62|      0|#define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  ------------------
  |  |  |  Branch (62:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1697|      0|        if ( 0 == _add_certfile( dirname, file, index ))
  ------------------
  |  Branch (1697:14): [True: 0, False: 0]
  ------------------
 1698|      0|            count++;
 1699|      0|        else
 1700|      0|            DEBUGMSGT(("cert:index:dir", "error adding %s to index\n",
  ------------------
  |  |   62|      0|#define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  ------------------
  |  |  |  Branch (62:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1701|      0|                        file));
 1702|      0|    }
 1703|       |
 1704|       |    /*
 1705|       |     * clean up and return
 1706|       |     */
 1707|      0|    ITERATOR_RELEASE(it);
  ------------------
  |  |  550|      0|#define ITERATOR_RELEASE(x) do { x->release(x); x = NULL; } while(0)
  |  |  ------------------
  |  |  |  Branch (550:67): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1708|       |
 1709|      0|  err_container:
 1710|      0|    netsnmp_directory_container_free(cert_container);
 1711|       |
 1712|      0|  err_index:
 1713|      0|    if (index)
  ------------------
  |  Branch (1713:9): [True: 0, False: 0]
  ------------------
 1714|      0|        fclose(index);
 1715|       |
 1716|      0|    return count;
 1717|      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 array 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 = name;
  160|     12|    ct = (container_type *)CONTAINER_FIND(containers, &tmp);
  ------------------
  |  |  394|     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",
  ------------------
  |  |   62|      0|#define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  ------------------
  |  |  |  Branch (62:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
  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",
  ------------------
  |  |   62|     12|#define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     12|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 12, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  147|     12|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  ------------------
  |  |  |  Branch (62:69): [Folded, False: 12]
  |  |  ------------------
  ------------------
  176|     12|               ct->name, f->product));
  177|       |
  178|     12|    return 0;
  179|     12|}
netsnmp_container_register:
  183|      9|{
  184|       |    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);
  ------------------
  |  |  394|      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|       |        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, False: 1]
  |  |  ------------------
  ------------------
  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|       |        x->clear(x, NULL, c);
  509|      0|        x = x->prev;
  510|      0|    }
  511|      1|    x->clear(x, f, c);
  512|      1|#ifdef HAVE_MALLOC_TRIM
  513|      1|    malloc_trim(0);
  514|      1|#endif
  515|      1|}
CONTAINER_FREE_ALL:
  524|      1|{
  525|      1|    CONTAINER_CLEAR(x, x->free_item, c);
  526|      1|}
netsnmp_init_container:
  563|      7|{
  564|      7|    if (c == NULL)
  ------------------
  |  Branch (564:9): [True: 0, False: 7]
  ------------------
  565|      0|        return;
  566|       |
  567|      7|    c->init = init;
  568|      7|    c->cfree = cfree;
  569|      7|    c->get_size = size;
  570|      7|    c->compare = cmp;
  571|      7|    c->insert = ins;
  572|      7|    c->remove = rem;
  573|      7|    c->find = fnd;
  574|      7|    c->free_item = netsnmp_container_simple_free;
  575|      7|}
netsnmp_compare_cstring:
  643|    149|{
  644|    149|    const container_type *lhs = lhs_arg;
  645|    149|    const container_type *rhs = rhs_arg;
  646|       |
  647|    149|    return strcmp(lhs->name, rhs->name);
  648|    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);
  ------------------
  |  |  394|     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:
  232|      4|{
  233|      4|#define BA_FLAGS (CONTAINER_KEY_ALLOW_DUPLICATES|CONTAINER_KEY_UNSORTED)
  234|       |
  235|      4|    if (set) {
  ------------------
  |  Branch (235:9): [True: 4, False: 0]
  ------------------
  236|      4|        if ((flags & BA_FLAGS) == flags) {
  ------------------
  |  |  233|      4|#define BA_FLAGS (CONTAINER_KEY_ALLOW_DUPLICATES|CONTAINER_KEY_UNSORTED)
  |  |  ------------------
  |  |  |  |  370|      4|#define CONTAINER_KEY_ALLOW_DUPLICATES             0x00000001
  |  |  ------------------
  |  |               #define BA_FLAGS (CONTAINER_KEY_ALLOW_DUPLICATES|CONTAINER_KEY_UNSORTED)
  |  |  ------------------
  |  |  |  |  371|      4|#define CONTAINER_KEY_UNSORTED                     0x00000002
  |  |  ------------------
  ------------------
  |  Branch (236:13): [True: 4, False: 0]
  ------------------
  237|       |            /** if turning off unsorted, do sort */
  238|      4|            int sort = ((c->flags & CONTAINER_KEY_UNSORTED) &&
  ------------------
  |  |  371|      4|#define CONTAINER_KEY_UNSORTED                     0x00000002
  ------------------
  |  Branch (238:25): [True: 0, False: 4]
  ------------------
  239|      0|                        ! (flags & CONTAINER_KEY_UNSORTED));
  ------------------
  |  |  371|      0|#define CONTAINER_KEY_UNSORTED                     0x00000002
  ------------------
  |  Branch (239:25): [True: 0, False: 0]
  ------------------
  240|      4|            c->flags = flags;
  241|      4|            if (sort) {
  ------------------
  |  Branch (241:17): [True: 0, False: 4]
  ------------------
  242|      0|                binary_array_table *t = (binary_array_table*)c->container_data;
  243|      0|                t->dirty = 1; /* force sort */
  244|      0|                Sort_Array(c);
  245|      0|            }
  246|      4|            return flags;
  247|      4|        } else {
  248|      0|            return -1; /* unsupported flag */
  249|      0|        }
  250|      4|    } else {
  251|      0|        return ((c->flags & flags) == flags);
  252|      0|    }
  253|      4|}
netsnmp_container_get_binary_array:
  816|      6|{
  817|       |    /*
  818|       |     * allocate memory
  819|       |     */
  820|      6|    netsnmp_container *c = SNMP_MALLOC_TYPEDEF(netsnmp_container);
  ------------------
  |  |   73|      6|#define SNMP_MALLOC_TYPEDEF(td)  (td *) calloc(1, sizeof(td))
  ------------------
  821|      6|    if (NULL==c) {
  ------------------
  |  Branch (821:9): [True: 0, False: 6]
  ------------------
  822|      0|        snmp_log(LOG_ERR, "couldn't allocate memory\n");
  823|      0|        return NULL;
  824|      0|    }
  825|       |
  826|      6|    c->container_data = netsnmp_binary_array_initialize();
  827|      6|    if (NULL == c->container_data) {
  ------------------
  |  Branch (827:9): [True: 0, False: 6]
  ------------------
  828|      0|        free(c);
  829|      0|        snmp_log(LOG_ERR, "couldn't allocate memory for container_data\n");
  830|      0|        return NULL;
  831|      0|    }
  832|       |
  833|       |    /*
  834|       |     * NOTE: CHANGES HERE MUST BE DUPLICATED IN duplicate AS WELL!!
  835|       |     */
  836|      6|    netsnmp_init_container(c, NULL, _ba_free, _ba_size, NULL, _ba_insert,
  837|      6|                           _ba_remove, _ba_find);
  838|      6|    c->find_next = _ba_find_next;
  839|      6|    c->get_subset = _ba_get_subset;
  840|      6|    c->get_iterator = _ba_iterator_get;
  841|      6|    c->for_each = _ba_for_each;
  842|      6|    c->clear = _ba_clear;
  843|      6|    c->options = _ba_options;
  844|      6|    c->duplicate = _ba_duplicate;
  845|      6|    c->get_at = netsnmp_binary_array_get_at;
  846|      6|    c->remove_at = netsnmp_binary_array_remove_at;
  847|      6|    c->insert_before = _ba_insert_before;
  848|       |
  849|      6|    return c;
  850|      6|}
netsnmp_container_get_binary_array_factory:
  854|      1|{
  855|      1|    static netsnmp_factory f = { "binary_array",
  856|      1|                                 netsnmp_container_get_binary_array };
  857|       |    
  858|      1|    return &f;
  859|      1|}
netsnmp_container_binary_array_init:
  863|      1|{
  864|      1|    netsnmp_container_register("binary_array",
  865|      1|                               netsnmp_container_get_binary_array_factory());
  866|      1|}
container_binary_array.c:_ba_is_sorted:
  336|     12|{
  337|       |    /*
  338|       |     * The code below has been commented out because it negatively affects
  339|       |     * performance.
  340|       |     */
  341|       |#if 0
  342|       |    const binary_array_table *t = c->container_data;
  343|       |    int i;
  344|       |
  345|       |    for (i = 0; i + 1 < t->count; ++i)
  346|       |        if (c->compare(t->data[i], t->data[i + 1]) > 0)
  347|       |            return 0;
  348|       |#endif
  349|       |
  350|     12|    return 1;
  351|     12|}
container_binary_array.c:binary_search:
  125|     40|{
  126|     40|    binary_array_table *t = (binary_array_table*)c->container_data;
  127|     40|    size_t             len = t->count;
  128|     40|    size_t             half;
  129|     40|    size_t             first = 0;
  130|     40|    size_t             middle = 0; /* init not needed; keeps compiler happy */
  131|     40|    int                result = 0; /* init not needed; keeps compiler happy */
  132|       |
  133|     40|    if (!len) {
  ------------------
  |  Branch (133:9): [True: 0, False: 40]
  ------------------
  134|      0|        if (NULL != next)
  ------------------
  |  Branch (134:13): [True: 0, False: 0]
  ------------------
  135|      0|            *next = 0;
  136|      0|        return -1;
  137|      0|    }
  138|       |
  139|     40|    if (c->flags & CONTAINER_KEY_UNSORTED) {
  ------------------
  |  |  371|     40|#define CONTAINER_KEY_UNSORTED                     0x00000002
  ------------------
  |  Branch (139:9): [True: 0, False: 40]
  ------------------
  140|      0|        if (!exact) {
  ------------------
  |  Branch (140:13): [True: 0, False: 0]
  ------------------
  141|      0|            snmp_log(LOG_ERR, "non-exact search on unsorted container %s?!?\n",
  142|      0|                     c->container_name);
  143|      0|            return -1;
  144|      0|        }
  145|      0|        return linear_search(val, c);
  146|      0|    }
  147|       |
  148|     40|    if (t->dirty)
  ------------------
  |  Branch (148:9): [True: 0, False: 40]
  ------------------
  149|      0|        Sort_Array(c);
  150|       |
  151|    157|    while (len > 0) {
  ------------------
  |  Branch (151:12): [True: 129, False: 28]
  ------------------
  152|    129|        half = len >> 1;
  153|    129|        middle = first + half;
  154|    129|        if ((result = c->compare(t->data[middle], val)) < 0) {
  ------------------
  |  Branch (154:13): [True: 43, False: 86]
  ------------------
  155|     43|            first = middle + 1;
  156|     43|            len = len - half - 1;
  157|     86|        } else if (result == 0) {
  ------------------
  |  Branch (157:20): [True: 12, False: 74]
  ------------------
  158|     12|            first = middle;
  159|     12|            break;
  160|     74|        } else {
  161|     74|            len = half;
  162|     74|        }
  163|    129|    }
  164|       |
  165|     40|    if (first >= t->count) {
  ------------------
  |  Branch (165:9): [True: 4, False: 36]
  ------------------
  166|      4|        if (exact && NULL != next)
  ------------------
  |  Branch (166:13): [True: 4, False: 0]
  |  Branch (166:22): [True: 2, False: 2]
  ------------------
  167|      2|            *next = t->count;
  168|      4|        return -1;
  169|      4|    }
  170|       |
  171|     36|    if (first != middle) {
  ------------------
  |  Branch (171:9): [True: 20, False: 16]
  ------------------
  172|       |        /* last compare wasn't against first, so get actual result */
  173|     20|        result = c->compare(t->data[first], val);
  174|     20|    }
  175|       |
  176|     36|    if(result == 0) {
  ------------------
  |  Branch (176:8): [True: 12, False: 24]
  ------------------
  177|     12|        if (exact && NULL != next)
  ------------------
  |  Branch (177:13): [True: 12, False: 0]
  |  Branch (177:22): [True: 0, False: 12]
  ------------------
  178|      0|            *next = first+1;
  179|     12|        else if (!exact && ++first == t->count) {
  ------------------
  |  Branch (179:18): [True: 0, False: 12]
  |  Branch (179:28): [True: 0, False: 0]
  ------------------
  180|      0|            if (NULL != next)
  ------------------
  |  Branch (180:17): [True: 0, False: 0]
  ------------------
  181|      0|                *next = first;
  182|      0|            first = -1;
  183|      0|        }
  184|     24|    } else if(exact) {
  ------------------
  |  Branch (184:15): [True: 24, False: 0]
  ------------------
  185|     24|        if (NULL != next) {
  ------------------
  |  Branch (185:13): [True: 9, False: 15]
  ------------------
  186|      9|            if (result > 0)
  ------------------
  |  Branch (186:17): [True: 9, False: 0]
  ------------------
  187|      9|                *next = first;
  188|      0|            else
  189|      0|                *next = t->count;
  190|      9|        }
  191|     24|        first = -1;
  192|     24|    }
  193|       |
  194|     36|    return first;
  195|     40|}
container_binary_array.c:netsnmp_binary_array_initialize:
  199|      6|{
  200|      6|    binary_array_table *t;
  201|       |
  202|      6|    t = SNMP_MALLOC_TYPEDEF(binary_array_table);
  ------------------
  |  |   73|      6|#define SNMP_MALLOC_TYPEDEF(td)  (td *) calloc(1, sizeof(td))
  ------------------
  203|      6|    if (t == NULL)
  ------------------
  |  Branch (203:9): [True: 0, False: 6]
  ------------------
  204|      0|        return NULL;
  205|       |
  206|      6|    t->max_size = 0;
  207|      6|    t->count = 0;
  208|      6|    t->dirty = 0;
  209|      6|    t->data = NULL;
  210|       |
  211|      6|    return t;
  212|      6|}
container_binary_array.c:_ba_size:
  719|      1|{
  720|      1|    return netsnmp_binary_array_count(container);
  721|      1|}
container_binary_array.c:netsnmp_binary_array_count:
  257|      1|{
  258|      1|    binary_array_table *t = (binary_array_table*)c->container_data;
  259|       |    /*
  260|       |     * return count
  261|       |     */
  262|      1|    return t ? t->count : 0;
  ------------------
  |  Branch (262:12): [True: 1, False: 0]
  ------------------
  263|      1|}
container_binary_array.c:_ba_insert:
  693|     12|{
  694|     12|    return netsnmp_binary_array_insert(container, data);
  695|     12|}
container_binary_array.c:netsnmp_binary_array_insert:
  532|     12|{
  533|     12|    binary_array_table *t = (binary_array_table*)c->container_data;
  534|     12|    const int duplicates_allowed = c->flags & CONTAINER_KEY_ALLOW_DUPLICATES;
  ------------------
  |  |  370|     12|#define CONTAINER_KEY_ALLOW_DUPLICATES             0x00000001
  ------------------
  535|     12|    const int sorted = !(c->flags & CONTAINER_KEY_UNSORTED);
  ------------------
  |  |  371|     12|#define CONTAINER_KEY_UNSORTED                     0x00000002
  ------------------
  536|     12|    int             i = -2;
  537|     12|    size_t          next, pos;
  538|     12|    void           *entry = NETSNMP_REMOVE_CONST(void *, const_entry);
  ------------------
  |  |   91|     12|    (__extension__ ({ const t tmp = (e); (t)(size_t)tmp; }))
  ------------------
  539|       |
  540|     12|    if (NULL == entry)
  ------------------
  |  Branch (540:9): [True: 0, False: 12]
  ------------------
  541|      0|        return -1;
  542|       |
  543|       |    /*
  544|       |     * check key if we have at least 1 item and duplicates aren't allowed
  545|       |     */
  546|     12|    if (!duplicates_allowed && t->count) {
  ------------------
  |  Branch (546:9): [True: 12, False: 0]
  |  Branch (546:32): [True: 11, False: 1]
  ------------------
  547|     11|        i = binary_search(entry, c, 1, &next);
  548|     11|        if (i >= 0) {
  ------------------
  |  Branch (548:13): [True: 0, False: 11]
  ------------------
  549|      0|            DEBUGMSGTL(("container","not inserting duplicate key\n"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
  550|      0|            return -1;
  551|      0|        }
  552|     11|    }
  553|       | 
  554|       |    /*
  555|       |     * if unsorted, just add at the end
  556|       |     */
  557|     12|    if (!sorted) {
  ------------------
  |  Branch (557:9): [True: 0, False: 12]
  ------------------
  558|      0|        pos = t->count;
  559|     12|    } else {
  560|       |        /** if we haven't searched for key yet, do it now */
  561|     12|        if (-2 == i) {
  ------------------
  |  Branch (561:13): [True: 1, False: 11]
  ------------------
  562|      1|            if (0 == t->count) {
  ------------------
  |  Branch (562:17): [True: 1, False: 0]
  ------------------
  563|      1|                next = 0;
  564|      1|                i = -1;
  565|      1|            } else {
  566|      0|                i = binary_search(entry, c, 1, &next);
  567|      0|            }
  568|      1|        }
  569|       |
  570|     12|        pos = next;
  571|       |        /* if key found, advance past any duplicates */
  572|     12|        if (duplicates_allowed && i >= 0)
  ------------------
  |  Branch (572:13): [True: 0, False: 12]
  |  Branch (572:35): [True: 0, False: 0]
  ------------------
  573|      0|            while (pos < t->count && c->compare(t->data[pos], entry) == 0)
  ------------------
  |  Branch (573:20): [True: 0, False: 0]
  |  Branch (573:38): [True: 0, False: 0]
  ------------------
  574|      0|                ++pos;
  575|     12|    }
  576|       |
  577|     12|    return netsnmp_binary_array_insert_before(c, pos, entry, !sorted);
  578|     12|}
container_binary_array.c:netsnmp_binary_array_insert_before:
  487|     12|{
  488|     12|    binary_array_table *t = (binary_array_table*)c->container_data;
  489|       |
  490|     12|    if (NULL == entry)
  ------------------
  |  Branch (490:9): [True: 0, False: 12]
  ------------------
  491|      0|        return -1;
  492|       |
  493|     12|    if (index > t->count) {
  ------------------
  |  Branch (493:9): [True: 0, False: 12]
  ------------------
  494|      0|        DEBUGMSGTL(("container:insert:before", "index out of range\n"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
  495|      0|        return -1;
  496|      0|    }
  497|       |
  498|       |     /*
  499|       |      * check if we need to resize the array
  500|       |      */
  501|     12|    _ba_resize_check(t);
  502|       |
  503|     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
  |  |  |  |  ------------------
  |  |  |  |  |  | 1705|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|     12|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded, False: 12]
  |  |  ------------------
  ------------------
  504|       |
  505|       |    /*
  506|       |     * shift array
  507|       |     */
  508|     12|    memmove(&t->data[index+1], &t->data[index],
  509|     12|            sizeof(void*) * (t->count - index));
  510|       |
  511|       |    /*
  512|       |     * Insert the new entry into the data array
  513|       |     */
  514|     12|    t->data[index] = NETSNMP_REMOVE_CONST(void *, entry);
  ------------------
  |  |   91|     12|    (__extension__ ({ const t tmp = (e); (t)(size_t)tmp; }))
  ------------------
  515|     12|    ++t->count;
  516|       |
  517|     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
  |  |  |  |  ------------------
  |  |  |  |  |  | 1705|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|     12|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded, False: 12]
  |  |  ------------------
  ------------------
  518|     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
  |  |  |  |  ------------------
  |  |  |  |  |  | 1705|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|     12|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded, False: 12]
  |  |  ------------------
  ------------------
  519|       |
  520|     12|    if (dirty)
  ------------------
  |  Branch (520:9): [True: 0, False: 12]
  ------------------
  521|      0|        t->dirty = 1;
  522|       |
  523|     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
  |  |  |  |  ------------------
  |  |  |  |  |  | 1705|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|     12|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded, False: 12]
  |  |  ------------------
  ------------------
  524|       |
  525|     12|    ++c->sync;
  526|       |
  527|     12|    return 0;
  528|     12|}
container_binary_array.c:_ba_resize_check:
  458|     12|{
  459|     12|    size_t new_max;
  460|     12|    void ** new_data;
  461|     12|    if (t->max_size > t->count)
  ------------------
  |  Branch (461:9): [True: 10, False: 2]
  ------------------
  462|     10|        return 0; /* resize not needed */
  463|       |
  464|       |    /*
  465|       |     * Table is full, so extend it to double the size, or use 10 elements
  466|       |     * if it is empty.
  467|       |     */
  468|      2|    new_max = t->max_size > 0 ? 2 * t->max_size : 10;
  ------------------
  |  Branch (468:15): [True: 1, False: 1]
  ------------------
  469|      2|    new_data = (void**) realloc(t->data, new_max * sizeof(void*));
  470|      2|    if (new_data == NULL) {
  ------------------
  |  Branch (470:9): [True: 0, False: 2]
  ------------------
  471|      0|        snmp_log(LOG_ERR, "malloc failed in _ba_resize_check\n");
  472|      0|        return -1; /* error */
  473|      0|    }
  474|       |
  475|      2|    memset(new_data + t->max_size, 0x0,
  476|      2|           (new_max - t->max_size) * sizeof(void*));
  477|       |
  478|      2|    t->data = new_data;
  479|      2|    t->max_size = new_max;
  480|       |
  481|      2|    return 1; /* resized */
  482|      2|}
container_binary_array.c:_ba_find:
  681|     30|{
  682|     30|    return netsnmp_binary_array_get(container, data, 1);
  683|     30|}
container_binary_array.c:netsnmp_binary_array_get:
  267|     30|{
  268|     30|    binary_array_table *t = (binary_array_table*)c->container_data;
  269|     30|    int             index = 0;
  270|       |
  271|       |    /*
  272|       |     * if there is no data, return NULL;
  273|       |     */
  274|     30|    if (!t->count)
  ------------------
  |  Branch (274:9): [True: 1, False: 29]
  ------------------
  275|      1|        return NULL;
  276|       |
  277|       |    /*
  278|       |     * if the table is dirty, sort it.
  279|       |     */
  280|     29|    if (t->dirty)
  ------------------
  |  Branch (280:9): [True: 0, False: 29]
  ------------------
  281|      0|        Sort_Array(c);
  282|       |
  283|       |    /*
  284|       |     * if there is a key, search. Otherwise default is 0;
  285|       |     */
  286|     29|    if (key) {
  ------------------
  |  Branch (286:9): [True: 29, False: 0]
  ------------------
  287|     29|        if ((index = binary_search(key, c, exact, NULL)) == -1)
  ------------------
  |  Branch (287:13): [True: 17, False: 12]
  ------------------
  288|     17|            return NULL;
  289|     12|        if (!exact &&
  ------------------
  |  Branch (289:13): [True: 0, False: 12]
  ------------------
  290|      0|            c->flags & CONTAINER_KEY_ALLOW_DUPLICATES) {
  ------------------
  |  |  370|      0|#define CONTAINER_KEY_ALLOW_DUPLICATES             0x00000001
  ------------------
  |  Branch (290:13): [True: 0, False: 0]
  ------------------
  291|      0|            int result;
  292|       |
  293|       |            /*
  294|       |             * If duplicates are allowed, we have to be extra
  295|       |             * sure that we didn't just increment to a duplicate,
  296|       |             * thus causing a getnext loop.
  297|       |             */
  298|      0|            result = c->compare(t->data[index], key);
  299|      0|            while (result == 0) {
  ------------------
  |  Branch (299:20): [True: 0, False: 0]
  ------------------
  300|      0|		DEBUGMSGTL(("container","skipping duplicate key in %s\n",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
  301|      0|					    c->container_name));
  302|      0|                if (++index == t->count)
  ------------------
  |  Branch (302:21): [True: 0, False: 0]
  ------------------
  303|      0|                   return NULL;
  304|      0|                result = c->compare(t->data[index], key);
  305|      0|            }
  306|      0|        }
  307|     12|    }
  308|       |
  309|     12|    return t->data[index];
  310|     29|}
container_binary_array.c:_ba_for_each:
  726|      2|{
  727|      2|    netsnmp_binary_array_for_each(container, f, context, 1);
  728|      2|}
container_binary_array.c:netsnmp_binary_array_for_each:
  426|      2|{
  427|      2|    binary_array_table *t = (binary_array_table*)c->container_data;
  428|      2|    size_t             i;
  429|       |
  430|      2|    if (sort && t->dirty)
  ------------------
  |  Branch (430:9): [True: 2, False: 0]
  |  Branch (430:17): [True: 0, False: 2]
  ------------------
  431|      0|        Sort_Array(c);
  432|       |
  433|      2|    for (i = 0; i < t->count; ++i)
  ------------------
  |  Branch (433:17): [True: 0, False: 2]
  ------------------
  434|      0|        (*fe) (t->data[i], context);
  435|      2|}
container_binary_array.c:_ba_options:
  761|      4|{
  762|      4|    return netsnmp_binary_array_options_set(c, set, flags);
  763|      4|}
container_binary_array.c:_ba_iterator_get:
 1020|      2|{
 1021|      2|    binary_array_iterator* it;
 1022|       |
 1023|      2|    if(NULL == c)
  ------------------
  |  Branch (1023:8): [True: 0, False: 2]
  ------------------
 1024|      0|        return NULL;
 1025|       |
 1026|      2|    it = SNMP_MALLOC_TYPEDEF(binary_array_iterator);
  ------------------
  |  |   73|      2|#define SNMP_MALLOC_TYPEDEF(td)  (td *) calloc(1, sizeof(td))
  ------------------
 1027|      2|    if(NULL == it)
  ------------------
  |  Branch (1027:8): [True: 0, False: 2]
  ------------------
 1028|      0|        return NULL;
 1029|       |
 1030|      2|    it->base.container = c;
 1031|       |    
 1032|      2|    it->base.first = _ba_iterator_first;
 1033|      2|    it->base.next = _ba_iterator_next;
 1034|      2|    it->base.curr = _ba_iterator_curr;
 1035|      2|    it->base.last = _ba_iterator_last;
 1036|      2|    it->base.remove = _ba_iterator_remove;
 1037|      2|    it->base.reset = _ba_iterator_reset;
 1038|      2|    it->base.release = _ba_iterator_release;
 1039|       |
 1040|      2|    (void)_ba_iterator_reset(&it->base);
 1041|       |
 1042|      2|    return &it->base;
 1043|      2|}
container_binary_array.c:_ba_iterator_first:
  931|      2|{
  932|      2|    binary_array_iterator *it = (void *)nit;
  933|       |
  934|      2|    return _ba_iterator_position(it, 0);
  935|      2|}
container_binary_array.c:_ba_iterator_position:
  894|      2|{
  895|      2|    binary_array_table *t = _ba_it2cont(it);
  896|      2|    if (NULL == t)
  ------------------
  |  Branch (896:9): [True: 0, False: 2]
  ------------------
  897|      0|        return t; /* msg already logged */
  898|       |
  899|      2|    if(it->base.container->sync != it->base.sync) {
  ------------------
  |  Branch (899:8): [True: 0, False: 2]
  ------------------
  900|      0|        DEBUGMSGTL(("container:iterator", "out of sync\n"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
  901|      0|        return NULL;
  902|      0|    }
  903|       |    
  904|      2|    if(0 == t->count) {
  ------------------
  |  Branch (904:8): [True: 2, False: 0]
  ------------------
  905|      2|        DEBUGMSGTL(("container:iterator", "empty\n"));
  ------------------
  |  |   66|      2|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      2|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 2, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      2|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      2|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      2|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      2|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 2]
  |  |  ------------------
  ------------------
  906|      2|        return NULL;
  907|      2|    }
  908|      0|    else if(pos >= t->count) {
  ------------------
  |  Branch (908:13): [True: 0, False: 0]
  ------------------
  909|      0|        DEBUGMSGTL(("container:iterator", "end of container\n"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
  910|      0|        return NULL;
  911|      0|    }
  912|       |
  913|      0|    return t->data[ pos ];
  914|      2|}
container_binary_array.c:_ba_it2cont:
  875|      4|{
  876|      4|    if(NULL == it) {
  ------------------
  |  Branch (876:8): [True: 0, False: 4]
  ------------------
  877|      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
  |  |  |  |  ------------------
  |  |  |  |  |  | 1705|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|      0|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded, False: 0]
  |  |  ------------------
  ------------------
  878|      0|        return NULL;
  879|      0|    }
  880|      4|    if(NULL == it->base.container) {
  ------------------
  |  Branch (880:8): [True: 0, False: 4]
  ------------------
  881|      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
  |  |  |  |  ------------------
  |  |  |  |  |  | 1705|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|      0|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded, False: 0]
  |  |  ------------------
  ------------------
  882|      0|        return NULL;
  883|      0|    }
  884|      4|    if(NULL == it->base.container->container_data) {
  ------------------
  |  Branch (884:8): [True: 0, False: 4]
  ------------------
  885|      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
  |  |  |  |  ------------------
  |  |  |  |  |  | 1705|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|      0|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded, False: 0]
  |  |  ------------------
  ------------------
  886|      0|        return NULL;
  887|      0|    }
  888|       |
  889|      4|    return (binary_array_table*)(it->base.container->container_data);
  890|      4|}
container_binary_array.c:_ba_iterator_reset:
  988|      2|{
  989|      2|    binary_array_iterator *it = (void *)nit;
  990|      2|    binary_array_table* t = _ba_it2cont(it);
  991|      2|    if(NULL == t) {
  ------------------
  |  Branch (991:8): [True: 0, False: 2]
  ------------------
  992|      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
  |  |  |  |  ------------------
  |  |  |  |  |  | 1705|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|      0|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded, False: 0]
  |  |  ------------------
  ------------------
  993|      0|        return -1;
  994|      0|    }
  995|       |
  996|      2|    if (t->dirty)
  ------------------
  |  Branch (996:9): [True: 0, False: 2]
  ------------------
  997|      0|        Sort_Array(it->base.container);
  998|       |
  999|       |    /*
 1000|       |     * save sync count, to make sure container doesn't change while
 1001|       |     * iterator is in use.
 1002|       |     */
 1003|      2|    it->base.sync = it->base.container->sync;
 1004|       |
 1005|      2|    it->pos = 0;
 1006|       |
 1007|      2|    return 0;
 1008|      2|}
container_binary_array.c:_ba_iterator_release:
 1012|      2|{
 1013|      2|    free(it);
 1014|       |
 1015|      2|    return 0;
 1016|      2|}

netsnmp_container_get_usll:
  386|      1|{
  387|       |    /*
  388|       |     * allocate memory
  389|       |     */
  390|      1|    sl_container *sl = (sl_container *)netsnmp_container_get_ssll();
  391|      1|    if (NULL==sl)
  ------------------
  |  Branch (391:9): [True: 0, False: 1]
  ------------------
  392|      0|        return NULL; /* msg already logged */
  393|       |
  394|      1|    sl->unsorted = 1;
  395|       |
  396|      1|    return (netsnmp_container*)sl;
  397|      1|}
netsnmp_container_get_singly_linked_list:
  401|      1|{
  402|      1|    sl_container *sl = (sl_container *)netsnmp_container_get_usll();
  403|      1|    if (NULL == sl)
  ------------------
  |  Branch (403:9): [True: 0, False: 1]
  ------------------
  404|      0|        return NULL; /* error already logged */
  405|       |
  406|      1|    sl->fifo = fifo;
  407|       |
  408|      1|    return (netsnmp_container *)sl;
  409|      1|}
netsnmp_container_get_fifo:
  413|      1|{
  414|      1|    return netsnmp_container_get_singly_linked_list(1);
  415|      1|}
netsnmp_container_ssll_init:
  419|      1|{
  420|      1|    static netsnmp_factory ssll = {
  421|      1|        "sorted_singly_linked_list",
  422|      1|        netsnmp_container_get_ssll
  423|      1|    };
  424|      1|    static netsnmp_factory usll = {
  425|      1|        "unsorted_singly_linked_list-lifo",
  426|      1|        netsnmp_container_get_usll
  427|      1|    };
  428|      1|    static netsnmp_factory fifo = {
  429|      1|        "unsorted_singly_linked_list-fifo",
  430|      1|        netsnmp_container_get_fifo
  431|      1|    };
  432|       |
  433|      1|    netsnmp_container_register("sorted_singly_linked_list", &ssll);
  434|      1|    netsnmp_container_register("unsorted_singly_linked_list", &usll);
  435|      1|    netsnmp_container_register("lifo", &usll);
  436|      1|    netsnmp_container_register("fifo", &fifo);
  437|      1|}
container_list_ssll.c:netsnmp_container_get_ssll:
  361|      1|{
  362|       |    /*
  363|       |     * allocate memory
  364|       |     */
  365|      1|    sl_container *sl = SNMP_MALLOC_TYPEDEF(sl_container);
  ------------------
  |  |   73|      1|#define SNMP_MALLOC_TYPEDEF(td)  (td *) calloc(1, sizeof(td))
  ------------------
  366|      1|    if (NULL==sl) {
  ------------------
  |  Branch (366:9): [True: 0, False: 1]
  ------------------
  367|      0|        snmp_log(LOG_ERR, "couldn't allocate memory\n");
  368|      0|        return NULL;
  369|      0|    }
  370|       |
  371|      1|    netsnmp_init_container((netsnmp_container *)sl, NULL, _ssll_free,
  372|      1|                           _ssll_size, NULL, _ssll_insert, _ssll_remove,
  373|      1|                           _ssll_find);
  374|      1|    sl->c.find_next = _ssll_find_next;
  375|      1|    sl->c.get_subset = NULL;
  376|      1|    sl->c.get_iterator =_ssll_iterator_get;
  377|      1|    sl->c.for_each = _ssll_for_each;
  378|      1|    sl->c.clear = _ssll_clear;
  379|      1|    sl->c.duplicate = _ssll_duplicate;
  380|       |
  381|      1|    return &sl->c;
  382|      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|       |    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"));
  ------------------
  |  |   66|      1|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      1|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      1|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      1|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      1|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 1]
  |  |  ------------------
  ------------------
  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|       |        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, False: 0]
  |  |  ------------------
  ------------------
   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;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  205|      0|    }
  206|       |
  207|      4|    DEBUGMSGTL(("netsnmp_ds_set_boolean", "Setting %s:%d = %d/%s\n",
  ------------------
  |  |   66|      4|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      4|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 2, False: 2]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      4|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      2|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      2|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      2|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (164:52): [True: 2, False: 0]
  |  |  |  |  |  Branch (164:64): [True: 2, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 4]
  |  |  ------------------
  ------------------
  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;
  ------------------
  |  |  184|      4|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  217|      4|}
netsnmp_ds_get_boolean:
  242|  1.03M|{
  243|  1.03M|    if (storeid < 0 || storeid >= NETSNMP_DS_MAX_IDS || 
  ------------------
  |  |   38|  2.06M|#define NETSNMP_DS_MAX_IDS 3
  ------------------
  |  Branch (243:9): [True: 0, False: 1.03M]
  |  Branch (243:24): [True: 0, False: 1.03M]
  ------------------
  244|  1.03M|	which   < 0 || which   >= NETSNMP_DS_MAX_SUBIDS) {
  ------------------
  |  |   39|  1.03M|#define NETSNMP_DS_MAX_SUBIDS 64        /* needs to be a multiple of 8 */
  ------------------
  |  Branch (244:2): [True: 0, False: 1.03M]
  |  Branch (244:17): [True: 0, False: 1.03M]
  ------------------
  245|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  246|      0|    }
  247|       |
  248|  1.03M|    return (netsnmp_ds_booleans[storeid][which/8] & (1 << (which % 8))) ? 1:0;
  ------------------
  |  Branch (248:12): [True: 48, False: 1.03M]
  ------------------
  249|  1.03M|}
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;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  257|      0|    }
  258|       |
  259|      2|    DEBUGMSGTL(("netsnmp_ds_set_int", "Setting %s:%d = %d\n",
  ------------------
  |  |   66|      2|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      2|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 2]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 2]
  |  |  ------------------
  ------------------
  260|      2|                stores[storeid], which, value));
  261|       |
  262|      2|    netsnmp_ds_integers[storeid][which] = value;
  263|      2|    return SNMPERR_SUCCESS;
  ------------------
  |  |  184|      2|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  264|      2|}
netsnmp_ds_get_int:
  268|  66.3k|{
  269|  66.3k|    if (storeid < 0 || storeid >= NETSNMP_DS_MAX_IDS || 
  ------------------
  |  |   38|   132k|#define NETSNMP_DS_MAX_IDS 3
  ------------------
  |  Branch (269:9): [True: 0, False: 66.3k]
  |  Branch (269:24): [True: 0, False: 66.3k]
  ------------------
  270|  66.3k|	which   < 0 || which   >= NETSNMP_DS_MAX_SUBIDS) {
  ------------------
  |  |   39|  66.3k|#define NETSNMP_DS_MAX_SUBIDS 64        /* needs to be a multiple of 8 */
  ------------------
  |  Branch (270:2): [True: 0, False: 66.3k]
  |  Branch (270:17): [True: 0, False: 66.3k]
  ------------------
  271|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  272|      0|    }
  273|       |
  274|  66.3k|    return netsnmp_ds_integers[storeid][which];
  275|  66.3k|}
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;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  283|      0|    }
  284|       |
  285|      5|    DEBUGMSGTL(("netsnmp_ds_set_string", "Setting %s:%d = \"%s\"\n",
  ------------------
  |  |   66|      5|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      5|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 5, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|     10|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      5|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      5|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      5|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (164:52): [True: 5, False: 0]
  |  |  |  |  |  Branch (164:64): [True: 5, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 5]
  |  |  ------------------
  ------------------
  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;
  ------------------
  |  |  184|      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, False: 5]
  |  |  ------------------
  ------------------
  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, False: 5]
  |  |  ------------------
  ------------------
  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;
  ------------------
  |  |  184|      5|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  308|      5|}
netsnmp_ds_get_string:
  312|    936|{
  313|    936|    if (storeid < 0 || storeid >= NETSNMP_DS_MAX_IDS || 
  ------------------
  |  |   38|  1.87k|#define NETSNMP_DS_MAX_IDS 3
  ------------------
  |  Branch (313:9): [True: 0, False: 936]
  |  Branch (313:24): [True: 0, False: 936]
  ------------------
  314|    936|	which   < 0 || which   >= NETSNMP_DS_MAX_SUBIDS) {
  ------------------
  |  |   39|    936|#define NETSNMP_DS_MAX_SUBIDS 64        /* needs to be a multiple of 8 */
  ------------------
  |  Branch (314:2): [True: 0, False: 936]
  |  Branch (314:17): [True: 0, False: 936]
  ------------------
  315|      0|        return NULL;
  316|      0|    }
  317|       |
  318|    936|    return netsnmp_ds_strings[storeid][which];
  319|    936|}
netsnmp_ds_register_config:
  447|     43|{
  448|     43|    netsnmp_ds_read_config *drsp;
  449|       |
  450|     43|    if (storeid < 0 || storeid >= NETSNMP_DS_MAX_IDS    || 
  ------------------
  |  |   38|     86|#define NETSNMP_DS_MAX_IDS 3
  ------------------
  |  Branch (450:9): [True: 0, False: 43]
  |  Branch (450:24): [True: 0, False: 43]
  ------------------
  451|     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 (451:2): [True: 0, False: 43]
  |  Branch (451:17): [True: 0, False: 43]
  |  Branch (451:53): [True: 0, False: 43]
  ------------------
  452|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  453|      0|    }
  454|       |
  455|     43|    if (netsnmp_ds_configs == NULL) {
  ------------------
  |  Branch (455:9): [True: 1, False: 42]
  ------------------
  456|      1|        netsnmp_ds_configs = SNMP_MALLOC_TYPEDEF(netsnmp_ds_read_config);
  ------------------
  |  |   73|      1|#define SNMP_MALLOC_TYPEDEF(td)  (td *) calloc(1, sizeof(td))
  ------------------
  457|      1|        if (netsnmp_ds_configs == NULL)
  ------------------
  |  Branch (457:13): [True: 0, False: 1]
  ------------------
  458|      0|            return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  459|      1|        drsp = netsnmp_ds_configs;
  460|     42|    } else {
  461|  1.69k|        for (drsp = netsnmp_ds_configs; drsp->next != NULL; drsp = drsp->next);
  ------------------
  |  Branch (461:41): [True: 1.65k, False: 42]
  ------------------
  462|     42|        drsp->next = SNMP_MALLOC_TYPEDEF(netsnmp_ds_read_config);
  ------------------
  |  |   73|     42|#define SNMP_MALLOC_TYPEDEF(td)  (td *) calloc(1, sizeof(td))
  ------------------
  463|     42|        if (drsp->next == NULL)
  ------------------
  |  Branch (463:13): [True: 0, False: 42]
  ------------------
  464|      0|            return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  465|     42|        drsp = drsp->next;
  466|     42|    }
  467|       |
  468|     43|    drsp->type    = type;
  469|     43|    drsp->ftype   = strdup(ftype);
  470|     43|    drsp->token   = strdup(token);
  471|     43|    drsp->storeid = storeid;
  472|     43|    drsp->which   = which;
  473|       |
  474|     43|    switch (type) {
  ------------------
  |  Branch (474:13): [True: 43, False: 0]
  ------------------
  475|     13|    case ASN_BOOLEAN:
  ------------------
  |  |   72|     13|#define ASN_BOOLEAN	    0x01U
  ------------------
  |  Branch (475:5): [True: 13, False: 30]
  ------------------
  476|     13|        register_config_handler(ftype, token, netsnmp_ds_handle_config, NULL,
  477|     13|                                "(1|yes|true|0|no|false)");
  478|     13|        break;
  479|       |
  480|      8|    case ASN_INTEGER:
  ------------------
  |  |   75|      8|#define ASN_INTEGER	    0x02U
  ------------------
  |  Branch (480:5): [True: 8, False: 35]
  ------------------
  481|      8|        register_config_handler(ftype, token, netsnmp_ds_handle_config, NULL,
  482|      8|                                "integerValue");
  483|      8|        break;
  484|       |
  485|     22|    case ASN_OCTET_STR:
  ------------------
  |  |   78|     22|#define ASN_OCTET_STR	    0x04U
  ------------------
  |  Branch (485:5): [True: 22, False: 21]
  ------------------
  486|     22|        register_config_handler(ftype, token, netsnmp_ds_handle_config, NULL,
  487|     22|                                "string");
  488|     22|        break;
  489|       |
  490|     43|    }
  491|     43|    return SNMPERR_SUCCESS;
  ------------------
  |  |  184|     43|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  492|     43|}
netsnmp_ds_register_premib:
  497|     23|{
  498|     23|    netsnmp_ds_read_config *drsp;
  499|       |
  500|     23|    if (storeid < 0 || storeid >= NETSNMP_DS_MAX_IDS    || 
  ------------------
  |  |   38|     46|#define NETSNMP_DS_MAX_IDS 3
  ------------------
  |  Branch (500:9): [True: 0, False: 23]
  |  Branch (500:24): [True: 0, False: 23]
  ------------------
  501|     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 (501:2): [True: 0, False: 23]
  |  Branch (501:17): [True: 0, False: 23]
  |  Branch (501:53): [True: 0, False: 23]
  ------------------
  502|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  503|      0|    }
  504|       |
  505|     23|    if (netsnmp_ds_configs == NULL) {
  ------------------
  |  Branch (505:9): [True: 0, False: 23]
  ------------------
  506|      0|        netsnmp_ds_configs = SNMP_MALLOC_TYPEDEF(netsnmp_ds_read_config);
  ------------------
  |  |   73|      0|#define SNMP_MALLOC_TYPEDEF(td)  (td *) calloc(1, sizeof(td))
  ------------------
  507|      0|        if (netsnmp_ds_configs == NULL)
  ------------------
  |  Branch (507:13): [True: 0, False: 0]
  ------------------
  508|      0|            return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  509|      0|        drsp = netsnmp_ds_configs;
  510|     23|    } else {
  511|    451|        for (drsp = netsnmp_ds_configs; drsp->next != NULL; drsp = drsp->next);
  ------------------
  |  Branch (511:41): [True: 428, False: 23]
  ------------------
  512|     23|        drsp->next = SNMP_MALLOC_TYPEDEF(netsnmp_ds_read_config);
  ------------------
  |  |   73|     23|#define SNMP_MALLOC_TYPEDEF(td)  (td *) calloc(1, sizeof(td))
  ------------------
  513|     23|        if (drsp->next == NULL)
  ------------------
  |  Branch (513:13): [True: 0, False: 23]
  ------------------
  514|      0|            return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  515|     23|        drsp = drsp->next;
  516|     23|    }
  517|       |
  518|     23|    drsp->type    = type;
  519|     23|    drsp->ftype   = strdup(ftype);
  520|     23|    drsp->token   = strdup(token);
  521|     23|    drsp->storeid = storeid;
  522|     23|    drsp->which   = which;
  523|       |
  524|     23|    switch (type) {
  ------------------
  |  Branch (524:13): [True: 23, False: 0]
  ------------------
  525|     17|    case ASN_BOOLEAN:
  ------------------
  |  |   72|     17|#define ASN_BOOLEAN	    0x01U
  ------------------
  |  Branch (525:5): [True: 17, False: 6]
  ------------------
  526|     17|        register_prenetsnmp_mib_handler(ftype, token, netsnmp_ds_handle_config,
  527|     17|                                        NULL, "(1|yes|true|0|no|false)");
  528|     17|        break;
  529|       |
  530|      4|    case ASN_INTEGER:
  ------------------
  |  |   75|      4|#define ASN_INTEGER	    0x02U
  ------------------
  |  Branch (530:5): [True: 4, False: 19]
  ------------------
  531|      4|        register_prenetsnmp_mib_handler(ftype, token, netsnmp_ds_handle_config,
  532|      4|                                        NULL, "integerValue");
  533|      4|        break;
  534|       |
  535|      2|    case ASN_OCTET_STR:
  ------------------
  |  |   78|      2|#define ASN_OCTET_STR	    0x04U
  ------------------
  |  Branch (535:5): [True: 2, False: 21]
  ------------------
  536|      2|        register_prenetsnmp_mib_handler(ftype, token, netsnmp_ds_handle_config,
  537|      2|                                        NULL, "string");
  538|      2|        break;
  539|       |
  540|     23|    }
  541|     23|    return SNMPERR_SUCCESS;
  ------------------
  |  |  184|     23|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  542|     23|}

netsnmp_large_fd_setfd:
  120|     81|{
  121|     81|    netsnmp_assert(fd >= 0);
  ------------------
  |  |   47|     81|#      define netsnmp_assert(x)  do { \
  |  |   48|     81|              if ( x ) \
  |  |  ------------------
  |  |  |  Branch (48:20): [True: 81, False: 0]
  |  |  ------------------
  |  |   49|     81|                 ; \
  |  |   50|     81|              else \
  |  |   51|     81|                 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
  |  |  |  |  ------------------
  |  |  |  |  |  | 1705|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|     81|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded, False: 81]
  |  |  ------------------
  ------------------
  122|       |
  123|     81|    while (fd >= (int)fdset->lfs_setsize)
  ------------------
  |  Branch (123:12): [True: 0, False: 81]
  ------------------
  124|      0|        netsnmp_large_fd_set_resize(fdset, 2 * (fdset->lfs_setsize + 1));
  125|       |
  126|     81|    LFD_SET(fd, fdset->lfs_setptr);
  127|     81|}
netsnmp_large_fd_is_set:
  140|  3.32k|{
  141|  3.32k|    netsnmp_assert(fd >= 0);
  ------------------
  |  |   47|  3.32k|#      define netsnmp_assert(x)  do { \
  |  |   48|  3.32k|              if ( x ) \
  |  |  ------------------
  |  |  |  Branch (48:20): [True: 3.32k, False: 0]
  |  |  ------------------
  |  |   49|  3.32k|                 ; \
  |  |   50|  3.32k|              else \
  |  |   51|  3.32k|                 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
  |  |  |  |  ------------------
  |  |  |  |  |  | 1705|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|  3.32k|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded, False: 3.32k]
  |  |  ------------------
  ------------------
  142|       |
  143|  3.32k|    return ((unsigned)fd < fdset->lfs_setsize &&
  ------------------
  |  Branch (143:13): [True: 3.32k, False: 0]
  ------------------
  144|  3.32k|            LFD_ISSET(fd, fdset->lfs_setptr));
  ------------------
  |  Branch (144:13): [True: 3.32k, False: 0]
  ------------------
  145|  3.32k|}
netsnmp_large_fd_set_init:
  151|     81|{
  152|     81|    fdset->lfs_setsize = 0;
  153|     81|    fdset->lfs_setptr  = NULL;
  154|       |#if !defined(cygwin) && defined(HAVE_WINSOCK_H)
  155|       |    fdset->lfs_set.fd_count = 0;
  156|       |#endif
  157|     81|    netsnmp_large_fd_set_resize(fdset, setsize);
  158|     81|}
netsnmp_large_fd_set_resize:
  192|    162|{
  193|    162|    int             fd_set_bytes;
  194|       |
  195|    162|    if (fdset->lfs_setsize == setsize)
  ------------------
  |  Branch (195:9): [True: 0, False: 162]
  ------------------
  196|      0|        goto success;
  197|       |
  198|    162|    if (setsize > FD_SETSIZE) {
  ------------------
  |  Branch (198:9): [True: 0, False: 162]
  ------------------
  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|    162|    } else {
  211|    162|        if (fdset->lfs_setsize > FD_SETSIZE) {
  ------------------
  |  Branch (211:13): [True: 0, False: 162]
  ------------------
  212|      0|            fdset->lfs_set = *fdset->lfs_setptr;
  213|      0|            free(fdset->lfs_setptr);
  214|      0|        }
  215|    162|        fdset->lfs_setptr = &fdset->lfs_set;
  216|    162|    }
  217|       |
  218|    162|#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|    162|    if ( fdset->lfs_setsize == 0 && setsize == FD_SETSIZE ) {
  ------------------
  |  Branch (223:10): [True: 81, False: 81]
  |  Branch (223:37): [True: 81, False: 0]
  ------------------
  224|       |        /* In this case we can use the OS's FD_ZERO */
  225|     81|        FD_ZERO(fdset->lfs_setptr);
  ------------------
  |  Branch (225:9): [Folded, False: 81]
  ------------------
  226|     81|    } else {
  227|     81|        int             i;
  228|       |
  229|     81|        for (i = fdset->lfs_setsize; i < setsize; i++)
  ------------------
  |  Branch (229:38): [True: 0, False: 81]
  ------------------
  230|      0|            LFD_CLR(i, fdset->lfs_setptr);
  231|     81|    }
  232|    162|#endif
  233|       |
  234|    162|    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|    162|success:
  240|    162|    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|    162|}
netsnmp_large_fd_set_cleanup:
  252|     81|{
  253|     81|    netsnmp_large_fd_set_resize(fdset, 0);
  254|     81|    fdset->lfs_setsize = 0;
  255|       |    fdset->lfs_setptr  = NULL;
  256|     81|}
large_fd_set.c:LFD_SET:
   95|     81|{
   96|     81|    enum { nfdbits = 8 * sizeof(p->fds_bits[0]) };
   97|     81|    NETSNMP_FD_MASK_TYPE *fds_array = p->fds_bits;
  ------------------
  |  | 1699|     81|#define NETSNMP_FD_MASK_TYPE __fd_mask
  ------------------
   98|       |
   99|     81|    fds_array[n / nfdbits] |= (1ULL << (n % nfdbits));
  100|     81|}
large_fd_set.c:LFD_ISSET:
  111|  3.32k|{
  112|  3.32k|    enum { nfdbits = 8 * sizeof(p->fds_bits[0]) };
  113|  3.32k|    const NETSNMP_FD_MASK_TYPE *fds_array = p->fds_bits;
  114|       |
  115|  3.32k|    return (fds_array[n / nfdbits] & (1ULL << (n % nfdbits))) != 0;
  116|  3.32k|}

set_enginetime:
  344|      1|{
  345|      1|    int             rval = SNMPERR_SUCCESS, iindex;
  ------------------
  |  |  184|      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) {	\
  |  |  ------------------
  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  ------------------
  |  |  |  Branch (143:7): [True: 0, Folded]
  |  |  ------------------
  |  |  144|      0|		rval = SNMPERR_GENERR;	\
  |  |  ------------------
  |  |  |  |  185|      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 "));
  ------------------
  |  |   66|      1|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      1|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      1|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      1|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      1|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 1]
  |  |  ------------------
  ------------------
  391|      1|    DEBUGMSGHEX(("lcd_set_enginetime", engineID, engineID_len));
  ------------------
  |  |   71|      1|#define DEBUGMSGHEX(x)     do {if (_DBG_IF_) {__DBGMSGHEX(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGHEX(x)     do {if (_DBG_IF_) {__DBGMSGHEX(x);} }while(0)
  |  |  ------------------
  |  |  |  |  169|      1|#define __DBGMSGHEX(x)     debugmsg_hex x
  |  |  ------------------
  |  |  |  Branch (71:71): [Folded, False: 1]
  |  |  ------------------
  ------------------
  392|      1|    DEBUGMSG(("lcd_set_enginetime", ": boots=%d, time=%d\n", engineboot,
  ------------------
  |  |   61|      1|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  144|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (61:67): [Folded, False: 1]
  |  |  ------------------
  ------------------
  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, False: 1]
  |  |  ------------------
  ------------------
  397|       |
  398|      1|    return rval;
  399|       |
  400|      1|}                               /* end set_enginetime() */
search_enginetime_list:
  423|      1|{
  424|      1|    int             rval = SNMPERR_SUCCESS;
  ------------------
  |  |  184|      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) {	\
  |  |  ------------------
  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  ------------------
  |  |  |  Branch (143:7): [True: 0, Folded]
  |  |  ------------------
  |  |  144|      0|		rval = SNMPERR_GENERR;	\
  |  |  ------------------
  |  |  |  |  185|      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) {	\
  |  |  ------------------
  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  ------------------
  |  |  |  Branch (143:7): [True: 0, Folded]
  |  |  ------------------
  |  |  144|      0|		rval = SNMPERR_GENERR;	\
  |  |  ------------------
  |  |  |  |  185|      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;
  ------------------
  |  |  185|      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) {	\
  |  |  ------------------
  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  ------------------
  |  |  |  Branch (143:7): [True: 0, Folded]
  |  |  ------------------
  |  |  144|      0|		rval = SNMPERR_GENERR;	\
  |  |  ------------------
  |  |  |  |  185|      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) {
  ------------------
  |  |  223|      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) {	\
  |  |  ------------------
  |  |  |  |  184|      2|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  ------------------
  |  |  |  Branch (143:7): [True: 0, False: 2]
  |  |  ------------------
  |  |  144|      0|		rval = SNMPERR_GENERR;	\
  |  |  ------------------
  |  |  |  |  185|      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, False: 2]
  |  |  ------------------
  ------------------
  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|  52.7k|{
  297|  52.7k|    const u_char   *tp;
  298|  52.7k|    const u_char   *cp2 = cp;
  299|  52.7k|    size_t          lenleft = line_len;
  300|       |
  301|       |    /*
  302|       |     * Make sure there's enough room for the hex output....
  303|       |     */
  304|  92.3k|    while ((*out_len + line_len*3+1) >= *buf_len) {
  ------------------
  |  Branch (304:12): [True: 39.6k, False: 52.7k]
  ------------------
  305|  39.6k|        if (!(allow_realloc && snmp_realloc(buf, buf_len))) {
  ------------------
  |  Branch (305:15): [True: 39.6k, False: 0]
  |  Branch (305:32): [True: 39.6k, False: 0]
  ------------------
  306|      0|            return 0;
  307|      0|        }
  308|  39.6k|    }
  309|       |
  310|       |    /*
  311|       |     * .... and display the hex values themselves....
  312|       |     */
  313|  79.1k|    for (; lenleft >= 8; lenleft-=8) {
  ------------------
  |  Branch (313:12): [True: 26.4k, False: 52.7k]
  ------------------
  314|  26.4k|        sprintf((char *) (*buf + *out_len),
  315|  26.4k|                "%02X %02X %02X %02X %02X %02X %02X %02X ", cp[0], cp[1],
  316|  26.4k|                cp[2], cp[3], cp[4], cp[5], cp[6], cp[7]);
  317|  26.4k|        *out_len += strlen((char *) (*buf + *out_len));
  318|  26.4k|        cp       += 8;
  319|  26.4k|    }
  320|   210k|    for (; lenleft > 0; lenleft--) {
  ------------------
  |  Branch (320:12): [True: 158k, False: 52.7k]
  ------------------
  321|   158k|        sprintf((char *) (*buf + *out_len), "%02X ", *cp++);
  322|   158k|        *out_len += strlen((char *) (*buf + *out_len));
  323|   158k|    }
  324|       |
  325|       |    /*
  326|       |     * .... plus (optionally) do the same for the ASCII equivalent.
  327|       |     */
  328|  52.7k|    if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_PRINT_HEX_TEXT)) {
  ------------------
  |  |   48|  52.7k|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                  if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_PRINT_HEX_TEXT)) {
  ------------------
  |  |   83|  52.7k|#define NETSNMP_DS_LIB_PRINT_HEX_TEXT      23   /* print ASCII text along with hex strings */
  ------------------
  |  Branch (328:9): [True: 0, False: 52.7k]
  ------------------
  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|  52.7k|    return 1;
  344|  52.7k|}
sprint_realloc_hexstring:
  349|  39.6k|{
  350|  39.6k|    int line_len = netsnmp_ds_get_int(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|  39.6k|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  351|  39.6k|                                      NETSNMP_DS_LIB_HEX_OUTPUT_LENGTH);
  ------------------
  |  |  121|  39.6k|#define NETSNMP_DS_LIB_HEX_OUTPUT_LENGTH    6
  ------------------
  352|  39.6k|    if (line_len <= 0)
  ------------------
  |  Branch (352:9): [True: 0, False: 39.6k]
  ------------------
  353|      0|        line_len = len;
  354|       |
  355|  52.7k|    for (; (int)len > line_len; len -= line_len) {
  ------------------
  |  Branch (355:12): [True: 13.1k, False: 39.6k]
  ------------------
  356|  13.1k|        if(!_sprint_hexstring_line(buf, buf_len, out_len, allow_realloc, cp, line_len))
  ------------------
  |  Branch (356:12): [True: 0, False: 13.1k]
  ------------------
  357|      0|            return 0;
  358|  13.1k|        *(*buf + (*out_len)++) = '\n';
  359|  13.1k|        *(*buf + *out_len) = 0;
  360|  13.1k|        cp += line_len;
  361|  13.1k|    }
  362|  39.6k|    if(!_sprint_hexstring_line(buf, buf_len, out_len, allow_realloc, cp, len))
  ------------------
  |  Branch (362:8): [True: 0, False: 39.6k]
  ------------------
  363|      0|        return 0;
  364|  39.6k|    *(*buf + *out_len) = 0;
  365|  39.6k|    return 1;
  366|  39.6k|}
sprint_realloc_asciistring:
  393|  19.0k|{
  394|  19.0k|    int             i;
  395|       |
  396|   251k|    for (i = 0; i < (int) len; i++) {
  ------------------
  |  Branch (396:17): [True: 232k, False: 19.0k]
  ------------------
  397|   232k|        if (isprint(*cp) || isspace(*cp)) {
  ------------------
  |  Branch (397:13): [True: 152k, False: 80.0k]
  |  Branch (397:29): [True: 33, False: 80.0k]
  ------------------
  398|   152k|            if (*cp == '\\' || *cp == '"') {
  ------------------
  |  Branch (398:17): [True: 60.0k, False: 92.0k]
  |  Branch (398:32): [True: 0, False: 92.0k]
  ------------------
  399|  60.0k|                if ((*out_len >= *buf_len) &&
  ------------------
  |  Branch (399:21): [True: 5.12k, False: 54.9k]
  ------------------
  400|  5.12k|                    !(allow_realloc && snmp_realloc(buf, buf_len))) {
  ------------------
  |  Branch (400:23): [True: 5.12k, False: 0]
  |  Branch (400:40): [True: 5.12k, False: 0]
  ------------------
  401|      0|                    return 0;
  402|      0|                }
  403|  60.0k|                *(*buf + (*out_len)++) = '\\';
  404|  60.0k|            }
  405|   152k|            if ((*out_len >= *buf_len) &&
  ------------------
  |  Branch (405:17): [True: 60, False: 152k]
  ------------------
  406|     60|                !(allow_realloc && snmp_realloc(buf, buf_len))) {
  ------------------
  |  Branch (406:19): [True: 60, False: 0]
  |  Branch (406:36): [True: 60, False: 0]
  ------------------
  407|      0|                return 0;
  408|      0|            }
  409|   152k|            *(*buf + (*out_len)++) = *cp++;
  410|   152k|        } else {
  411|  80.0k|            if ((*out_len >= *buf_len) &&
  ------------------
  |  Branch (411:17): [True: 0, False: 80.0k]
  ------------------
  412|      0|                !(allow_realloc && snmp_realloc(buf, buf_len))) {
  ------------------
  |  Branch (412:19): [True: 0, False: 0]
  |  Branch (412:36): [True: 0, False: 0]
  ------------------
  413|      0|                return 0;
  414|      0|            }
  415|  80.0k|            *(*buf + (*out_len)++) = '.';
  416|  80.0k|            cp++;
  417|  80.0k|        }
  418|   232k|    }
  419|  19.0k|    if ((*out_len >= *buf_len) &&
  ------------------
  |  Branch (419:9): [True: 13.1k, False: 5.85k]
  ------------------
  420|  13.1k|        !(allow_realloc && snmp_realloc(buf, buf_len))) {
  ------------------
  |  Branch (420:11): [True: 13.1k, False: 0]
  |  Branch (420:28): [True: 13.1k, False: 0]
  ------------------
  421|      0|        return 0;
  422|      0|    }
  423|  19.0k|    *(*buf + *out_len) = '\0';
  424|  19.0k|    return 1;
  425|  19.0k|}
register_mib_handlers:
 2480|      1|{
 2481|      1|#ifndef NETSNMP_DISABLE_MIB_LOADING
 2482|      1|    register_prenetsnmp_mib_handler("snmp", "mibdirs",
 2483|      1|                                    handle_mibdirs_conf, NULL,
 2484|      1|                                    "[mib-dirs|+mib-dirs|-mib-dirs]");
 2485|      1|    register_prenetsnmp_mib_handler("snmp", "mibs",
 2486|      1|                                    handle_mibs_conf, NULL,
 2487|      1|                                    "[mib-tokens|+mib-tokens|-mib-tokens]");
 2488|      1|    register_config_handler("snmp", "mibfile",
 2489|      1|                            handle_mibfile_conf, NULL, "mibfile-to-read");
 2490|       |    /*
 2491|       |     * register the snmp.conf configuration handlers for default
 2492|       |     * parsing behaviour 
 2493|       |     */
 2494|       |
 2495|      1|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "showMibErrors",
  ------------------
  |  |   72|      1|#define ASN_BOOLEAN	    0x01U
  ------------------
 2496|      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
  ------------------
 2497|      1|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "commentToEOL",     /* Describes actual behaviour */
  ------------------
  |  |   72|      1|#define ASN_BOOLEAN	    0x01U
  ------------------
 2498|      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
  ------------------
 2499|      1|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "strictCommentTerm",    /* Backward compatibility */
  ------------------
  |  |   72|      1|#define ASN_BOOLEAN	    0x01U
  ------------------
 2500|      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
  ------------------
 2501|      1|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "mibAllowUnderline",
  ------------------
  |  |   72|      1|#define ASN_BOOLEAN	    0x01U
  ------------------
 2502|      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
  ------------------
 2503|      1|    netsnmp_ds_register_premib(ASN_INTEGER, "snmp", "mibWarningLevel",
  ------------------
  |  |   75|      1|#define ASN_INTEGER	    0x02U
  ------------------
 2504|      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
  ------------------
 2505|      1|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "mibReplaceWithLatest",
  ------------------
  |  |   72|      1|#define ASN_BOOLEAN	    0x01U
  ------------------
 2506|      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 */
  ------------------
 2507|      1|#endif
 2508|       |
 2509|      1|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "printNumericEnums",
  ------------------
  |  |   72|      1|#define ASN_BOOLEAN	    0x01U
  ------------------
 2510|      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 */
  ------------------
 2511|      1|    register_prenetsnmp_mib_handler("snmp", "printNumericOids",
 2512|      1|                       handle_print_numeric, NULL, "(1|yes|true|0|no|false)");
 2513|      1|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "escapeQuotes",
  ------------------
  |  |   72|      1|#define ASN_BOOLEAN	    0x01U
  ------------------
 2514|      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 */
  ------------------
 2515|      1|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "dontBreakdownOids",
  ------------------
  |  |   72|      1|#define ASN_BOOLEAN	    0x01U
  ------------------
 2516|      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 */
  ------------------
 2517|      1|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "quickPrinting",
  ------------------
  |  |   72|      1|#define ASN_BOOLEAN	    0x01U
  ------------------
 2518|      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 */
  ------------------
 2519|      1|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "numericTimeticks",
  ------------------
  |  |   72|      1|#define ASN_BOOLEAN	    0x01U
  ------------------
 2520|      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 */
  ------------------
 2521|      1|    netsnmp_ds_register_premib(ASN_INTEGER, "snmp", "oidOutputFormat",
  ------------------
  |  |   75|      1|#define ASN_INTEGER	    0x02U
  ------------------
 2522|      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
  ------------------
 2523|      1|    netsnmp_ds_register_premib(ASN_INTEGER, "snmp", "suffixPrinting",
  ------------------
  |  |   75|      1|#define ASN_INTEGER	    0x02U
  ------------------
 2524|      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
  ------------------
 2525|      1|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "extendedIndex",
  ------------------
  |  |   72|      1|#define ASN_BOOLEAN	    0x01U
  ------------------
 2526|      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] */
  ------------------
 2527|      1|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "printHexText",
  ------------------
  |  |   72|      1|#define ASN_BOOLEAN	    0x01U
  ------------------
 2528|      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 */
  ------------------
 2529|      1|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "printValueOnly",
  ------------------
  |  |   72|      1|#define ASN_BOOLEAN	    0x01U
  ------------------
 2530|      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) */
  ------------------
 2531|      1|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "dontPrintUnits",
  ------------------
  |  |   72|      1|#define ASN_BOOLEAN	    0x01U
  ------------------
 2532|      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 */
  ------------------
 2533|      1|    netsnmp_ds_register_premib(ASN_INTEGER, "snmp", "hexOutputLength",
  ------------------
  |  |   75|      1|#define ASN_INTEGER	    0x02U
  ------------------
 2534|      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
  ------------------
 2535|      1|}
netsnmp_set_mib_directory:
 2550|      2|{
 2551|      2|    const char *newdir;
 2552|      2|    char *olddir, *tmpdir = NULL;
 2553|       |
 2554|      2|    DEBUGTRACE;
  ------------------
  |  |   63|      2|#define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
  |  |  ------------------
  |  |  |  |  144|      2|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 2, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
  |  |  ------------------
  |  |  |  |  154|      2|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  ------------------
  |  |  |  |  |  |  147|      2|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  155|      2|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  ------------------
  |  |  |  Branch (63:67): [Folded, False: 2]
  |  |  ------------------
  ------------------
 2555|      2|    if (NULL == dir) {
  ------------------
  |  Branch (2555:9): [True: 0, False: 2]
  ------------------
 2556|      0|        return;
 2557|      0|    }
 2558|       |    
 2559|      2|    olddir = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      2|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 2560|      2|				   NETSNMP_DS_LIB_MIBDIRS);
  ------------------
  |  |  162|      2|#define NETSNMP_DS_LIB_MIBDIRS           11
  ------------------
 2561|      2|    if (olddir) {
  ------------------
  |  Branch (2561:9): [True: 1, False: 1]
  ------------------
 2562|      1|        if ((*dir == '+') || (*dir == '-')) {
  ------------------
  |  Branch (2562:13): [True: 0, False: 1]
  |  Branch (2562:30): [True: 0, False: 1]
  ------------------
 2563|       |            /** New dir starts with '+', thus we add it. */
 2564|      0|            if (*dir++ == '+') {
  ------------------
  |  Branch (2564:17): [True: 0, False: 0]
  ------------------
 2565|      0|                if (asprintf(&tmpdir, "%s%c%s", olddir, ENV_SEPARATOR_CHAR, dir) < 0)
  ------------------
  |  |   70|      0|#define ENV_SEPARATOR_CHAR ':'
  ------------------
  |  Branch (2565:21): [True: 0, False: 0]
  ------------------
 2566|      0|                    tmpdir = NULL;
 2567|      0|            } else {
 2568|      0|                if (asprintf(&tmpdir, "%s%c%s", dir, ENV_SEPARATOR_CHAR, olddir) < 0)
  ------------------
  |  |   70|      0|#define ENV_SEPARATOR_CHAR ':'
  ------------------
  |  Branch (2568:21): [True: 0, False: 0]
  ------------------
 2569|      0|                    tmpdir = NULL;
 2570|      0|            }
 2571|      0|            if (!tmpdir) {
  ------------------
  |  Branch (2571:17): [True: 0, False: 0]
  ------------------
 2572|      0|                DEBUGMSGTL(("read_config:initmib", "set mibdir malloc failed"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2573|      0|                return;
 2574|      0|            }
 2575|      0|            newdir = tmpdir;
 2576|      1|        } else {
 2577|      1|            newdir = dir;
 2578|      1|        }
 2579|      1|    } else {
 2580|       |        /** If dir starts with '+' skip '+' it. */
 2581|      1|        newdir = ((*dir == '+') ? ++dir : dir);
  ------------------
  |  Branch (2581:19): [True: 0, False: 1]
  ------------------
 2582|      1|    }
 2583|      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
  ------------------
 2584|      2|                          newdir);
 2585|       |
 2586|       |    /** set_string calls strdup, so if we allocated memory, free it */
 2587|      2|    if (tmpdir == newdir) {
  ------------------
  |  Branch (2587:9): [True: 0, False: 2]
  ------------------
 2588|       |        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, False: 0]
  |  |  ------------------
  ------------------
 2589|      0|    }
 2590|      2|}
netsnmp_get_mib_directory:
 2607|      3|{
 2608|      3|    char *dir;
 2609|       |
 2610|      3|    DEBUGTRACE;
  ------------------
  |  |   63|      3|#define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
  |  |  ------------------
  |  |  |  |  144|      3|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 3, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
  |  |  ------------------
  |  |  |  |  154|      3|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  ------------------
  |  |  |  |  |  |  147|      3|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  155|      3|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  ------------------
  |  |  |  Branch (63:67): [Folded, False: 3]
  |  |  ------------------
  ------------------
 2611|      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
  ------------------
 2612|      3|    if (dir == NULL) {
  ------------------
  |  Branch (2612:9): [True: 1, False: 2]
  ------------------
 2613|      1|        DEBUGMSGTL(("get_mib_directory", "no mib directories set\n"));
  ------------------
  |  |   66|      1|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      1|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      1|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      1|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      1|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 1]
  |  |  ------------------
  ------------------
 2614|       |
 2615|       |        /** Check if the environment variable is set */
 2616|      1|        dir = netsnmp_getenv("MIBDIRS");
 2617|      1|        if (dir == NULL) {
  ------------------
  |  Branch (2617:13): [True: 1, False: 0]
  ------------------
 2618|      1|            DEBUGMSGTL(("get_mib_directory", "no mib directories set by environment\n"));
  ------------------
  |  |   66|      1|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      1|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      1|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      1|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      1|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 1]
  |  |  ------------------
  ------------------
 2619|       |            /** Not set use hard coded path */
 2620|      1|            if (confmibdir == NULL) {
  ------------------
  |  Branch (2620:17): [True: 1, False: 0]
  ------------------
 2621|      1|                DEBUGMSGTL(("get_mib_directory", "no mib directories set by config\n"));
  ------------------
  |  |   66|      1|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      1|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      1|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      1|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      1|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 1]
  |  |  ------------------
  ------------------
 2622|      1|                netsnmp_set_mib_directory(NETSNMP_DEFAULT_MIBDIRS);
  ------------------
  |  | 1647|      1|#define NETSNMP_DEFAULT_MIBDIRS "$HOME/.snmp/mibs:/usr/local/net-snmp-master/share/snmp/mibs"
  ------------------
 2623|      1|            }
 2624|      0|            else if ((*confmibdir == '+') || (*confmibdir == '-')) {
  ------------------
  |  Branch (2624:22): [True: 0, False: 0]
  |  Branch (2624:46): [True: 0, False: 0]
  ------------------
 2625|      0|                DEBUGMSGTL(("get_mib_directory", "mib directories set by config (but added)\n"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2626|      0|                netsnmp_set_mib_directory(NETSNMP_DEFAULT_MIBDIRS);
  ------------------
  |  | 1647|      0|#define NETSNMP_DEFAULT_MIBDIRS "$HOME/.snmp/mibs:/usr/local/net-snmp-master/share/snmp/mibs"
  ------------------
 2627|      0|                netsnmp_set_mib_directory(confmibdir);
 2628|      0|            }
 2629|      0|            else {
 2630|      0|                DEBUGMSGTL(("get_mib_directory", "mib directories set by config\n"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2631|      0|                netsnmp_set_mib_directory(confmibdir);
 2632|      0|            }
 2633|      1|        } else if ((*dir == '+') || (*dir == '-')) {
  ------------------
  |  Branch (2633:20): [True: 0, False: 0]
  |  Branch (2633:37): [True: 0, False: 0]
  ------------------
 2634|      0|            DEBUGMSGTL(("get_mib_directory", "mib directories set by environment (but added)\n"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2635|      0|            netsnmp_set_mib_directory(NETSNMP_DEFAULT_MIBDIRS);
  ------------------
  |  | 1647|      0|#define NETSNMP_DEFAULT_MIBDIRS "$HOME/.snmp/mibs:/usr/local/net-snmp-master/share/snmp/mibs"
  ------------------
 2636|      0|            netsnmp_set_mib_directory(dir);
 2637|      0|        } else {
 2638|      0|            DEBUGMSGTL(("get_mib_directory", "mib directories set by environment\n"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2639|      0|            netsnmp_set_mib_directory(dir);
 2640|      0|        }
 2641|      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
  ------------------
 2642|      1|    }
 2643|      3|    DEBUGMSGTL(("get_mib_directory", "mib directories set '%s'\n", dir));
  ------------------
  |  |   66|      3|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      3|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 3, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      3|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      3|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      3|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      3|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 3]
  |  |  ------------------
  ------------------
 2644|      3|    return(dir);
 2645|      3|}
netsnmp_fixup_mib_directory:
 2654|      1|{
 2655|      1|    const char *homepath = netsnmp_gethomedir();
 2656|      1|    char *mibpath = netsnmp_get_mib_directory();
 2657|      1|    char *oldmibpath = NULL;
 2658|      1|    char *ptr_home;
 2659|      1|    char *new_mibpath;
 2660|       |
 2661|      1|    DEBUGTRACE;
  ------------------
  |  |   63|      1|#define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
  |  |  ------------------
  |  |  |  |  144|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
  |  |  ------------------
  |  |  |  |  154|      1|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  ------------------
  |  |  |  |  |  |  147|      1|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  155|      1|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  ------------------
  |  |  |  Branch (63:67): [Folded, False: 1]
  |  |  ------------------
  ------------------
 2662|      1|    if (homepath && mibpath) {
  ------------------
  |  Branch (2662:9): [True: 1, False: 0]
  |  Branch (2662:21): [True: 1, False: 0]
  ------------------
 2663|      1|        DEBUGMSGTL(("fixup_mib_directory", "mib directories '%s'\n", mibpath));
  ------------------
  |  |   66|      1|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      1|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      1|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      1|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      1|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 1]
  |  |  ------------------
  ------------------
 2664|      2|        while ((ptr_home = strstr(mibpath, "$HOME"))) {
  ------------------
  |  Branch (2664:16): [True: 1, False: 1]
  ------------------
 2665|      1|            new_mibpath = (char *)malloc(strlen(mibpath) - strlen("$HOME") +
 2666|      1|					 strlen(homepath)+1);
 2667|      1|            if (new_mibpath) {
  ------------------
  |  Branch (2667:17): [True: 1, False: 0]
  ------------------
 2668|      1|                *ptr_home = 0; /* null out the spot where we stop copying */
 2669|      1|                sprintf(new_mibpath, "%s%s%s", mibpath, homepath,
 2670|      1|			ptr_home + strlen("$HOME"));
 2671|       |                /** swap in the new value and repeat */
 2672|      1|                mibpath = new_mibpath;
 2673|      1|		if (oldmibpath != NULL) {
  ------------------
  |  Branch (2673:7): [True: 0, False: 1]
  ------------------
 2674|      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, False: 0]
  |  |  ------------------
  ------------------
 2675|      0|		}
 2676|      1|		oldmibpath = new_mibpath;
 2677|      1|            } else {
 2678|      0|                break;
 2679|      0|            }
 2680|      1|        }
 2681|       |
 2682|      1|        netsnmp_set_mib_directory(mibpath);
 2683|       |	
 2684|       |	/*  The above copies the mibpath for us, so...  */
 2685|       |
 2686|      1|	if (oldmibpath != NULL) {
  ------------------
  |  Branch (2686:6): [True: 1, False: 0]
  ------------------
 2687|      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, False: 1]
  |  |  ------------------
  ------------------
 2688|      1|	}
 2689|       |
 2690|      1|    }
 2691|       |
 2692|      1|}
netsnmp_init_mib:
 2701|      1|{
 2702|      1|    const char     *prefix;
 2703|      1|    char           *env_var, *entry;
 2704|      1|    PrefixListPtr   pp = &mib_prefixes[0];
 2705|      1|    char           *st = NULL;
 2706|       |
 2707|      1|    if (Mib)
  ------------------
  |  Branch (2707:9): [True: 0, False: 1]
  ------------------
 2708|      0|        return;
 2709|      1|    netsnmp_init_mib_internals();
 2710|       |
 2711|       |    /*
 2712|       |     * Initialise the MIB directory/ies 
 2713|       |     */
 2714|      1|    netsnmp_fixup_mib_directory();
 2715|      1|    env_var = strdup(netsnmp_get_mib_directory());
 2716|      1|    if (!env_var)
  ------------------
  |  Branch (2716:9): [True: 0, False: 1]
  ------------------
 2717|      0|        return;
 2718|       |
 2719|      1|    DEBUGMSGTL(("init_mib",
  ------------------
  |  |   66|      1|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      1|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      1|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      1|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      1|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 1]
  |  |  ------------------
  ------------------
 2720|      1|                "Seen MIBDIRS: Looking in '%s' for mib dirs ...\n",
 2721|      1|                env_var));
 2722|       |
 2723|      1|    entry = strtok_r(env_var, ENV_SEPARATOR, &st);
  ------------------
  |  |   67|      1|#define ENV_SEPARATOR ":"
  ------------------
 2724|      3|    while (entry) {
  ------------------
  |  Branch (2724:12): [True: 2, False: 1]
  ------------------
 2725|      2|        add_mibdir(entry);
 2726|      2|        entry = strtok_r(NULL, ENV_SEPARATOR, &st);
  ------------------
  |  |   67|      2|#define ENV_SEPARATOR ":"
  ------------------
 2727|      2|    }
 2728|      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, False: 1]
  |  |  ------------------
  ------------------
 2729|       |
 2730|      1|    env_var = netsnmp_getenv("MIBFILES");
 2731|      1|    if (env_var != NULL) {
  ------------------
  |  Branch (2731:9): [True: 0, False: 1]
  ------------------
 2732|      0|        if (*env_var == '+')
  ------------------
  |  Branch (2732:13): [True: 0, False: 0]
  ------------------
 2733|      0|            entry = strtok_r(env_var+1, ENV_SEPARATOR, &st);
  ------------------
  |  |   67|      0|#define ENV_SEPARATOR ":"
  ------------------
 2734|      0|        else
 2735|      0|            entry = strtok_r(env_var, ENV_SEPARATOR, &st);
  ------------------
  |  |   67|      0|#define ENV_SEPARATOR ":"
  ------------------
 2736|      0|        while (entry) {
  ------------------
  |  Branch (2736:16): [True: 0, False: 0]
  ------------------
 2737|      0|            add_mibfile(entry, NULL);
 2738|      0|            entry = strtok_r(NULL, ENV_SEPARATOR, &st);
  ------------------
  |  |   67|      0|#define ENV_SEPARATOR ":"
  ------------------
 2739|      0|        }
 2740|      0|    }
 2741|       |
 2742|      1|    netsnmp_init_mib_internals();
 2743|       |
 2744|       |    /*
 2745|       |     * Read in any modules or mibs requested 
 2746|       |     */
 2747|       |
 2748|      1|    env_var = netsnmp_getenv("MIBS");
 2749|      1|    if (env_var == NULL) {
  ------------------
  |  Branch (2749:9): [True: 1, False: 0]
  ------------------
 2750|      1|        if (confmibs != NULL)
  ------------------
  |  Branch (2750:13): [True: 0, False: 1]
  ------------------
 2751|      0|            env_var = strdup(confmibs);
 2752|      1|        else
 2753|      1|            env_var = strdup(NETSNMP_DEFAULT_MIBS);
  ------------------
  |  | 1988|      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"
  ------------------
 2754|      1|    } else {
 2755|      0|        env_var = strdup(env_var);
 2756|      0|    }
 2757|      1|    if (env_var && ((*env_var == '+') || (*env_var == '-'))) {
  ------------------
  |  Branch (2757:9): [True: 1, False: 0]
  |  Branch (2757:21): [True: 0, False: 1]
  |  Branch (2757:42): [True: 0, False: 1]
  ------------------
 2758|      0|        int res;
 2759|       |
 2760|      0|        if (*env_var == '+')
  ------------------
  |  Branch (2760:13): [True: 0, False: 0]
  ------------------
 2761|      0|            res = asprintf(&entry, "%s%c%s", NETSNMP_DEFAULT_MIBS,
  ------------------
  |  | 1988|      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"
  ------------------
 2762|      0|                           ENV_SEPARATOR_CHAR, env_var + 1);
  ------------------
  |  |   70|      0|#define ENV_SEPARATOR_CHAR ':'
  ------------------
 2763|      0|        else
 2764|      0|            res = asprintf(&entry, "%s%c%s", env_var + 1, ENV_SEPARATOR_CHAR,
  ------------------
  |  |   70|      0|#define ENV_SEPARATOR_CHAR ':'
  ------------------
 2765|      0|                           NETSNMP_DEFAULT_MIBS);
  ------------------
  |  | 1988|      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"
  ------------------
 2766|      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, False: 0]
  |  |  ------------------
  ------------------
 2767|      0|        if (res < 0) {
  ------------------
  |  Branch (2767:13): [True: 0, False: 0]
  ------------------
 2768|      0|            DEBUGMSGTL(("init_mib", "env mibs malloc failed"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2769|      0|            return;
 2770|      0|        }
 2771|      0|        env_var = entry;
 2772|      0|    }
 2773|       |
 2774|      1|    if (env_var != NULL) {
  ------------------
  |  Branch (2774:9): [True: 1, False: 0]
  ------------------
 2775|      1|        DEBUGMSGTL(("init_mib",
  ------------------
  |  |   66|      1|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      1|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      1|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      1|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      1|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 1]
  |  |  ------------------
  ------------------
 2776|      1|                    "Seen MIBS: Looking in '%s' for mib files ...\n",
 2777|      1|                    env_var));
 2778|      1|        entry = strtok_r(env_var, ENV_SEPARATOR, &st);
  ------------------
  |  |   67|      1|#define ENV_SEPARATOR ":"
  ------------------
 2779|     49|        while (entry) {
  ------------------
  |  Branch (2779:16): [True: 48, False: 1]
  ------------------
 2780|     48|            if (strcasecmp(entry, DEBUG_ALWAYS_TOKEN) == 0) {
  ------------------
  |  |  227|     48|#define DEBUG_ALWAYS_TOKEN "all"
  ------------------
  |  Branch (2780:17): [True: 0, False: 48]
  ------------------
 2781|      0|                read_all_mibs();
 2782|     48|            } else if (strstr(entry, "/") != NULL) {
  ------------------
  |  Branch (2782:24): [True: 0, False: 48]
  ------------------
 2783|      0|                read_mib(entry);
 2784|     48|            } else {
 2785|     48|                netsnmp_read_module(entry);
 2786|     48|            }
 2787|     48|            entry = strtok_r(NULL, ENV_SEPARATOR, &st);
  ------------------
  |  |   67|     48|#define ENV_SEPARATOR ":"
  ------------------
 2788|     48|        }
 2789|      1|        adopt_orphans();
 2790|      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, False: 1]
  |  |  ------------------
  ------------------
 2791|      1|    }
 2792|       |
 2793|      1|    env_var = netsnmp_getenv("MIBFILES");
 2794|      1|    if (env_var != NULL) {
  ------------------
  |  Branch (2794:9): [True: 0, False: 1]
  ------------------
 2795|      0|        if ((*env_var == '+') || (*env_var == '-')) {
  ------------------
  |  Branch (2795:13): [True: 0, False: 0]
  |  Branch (2795:34): [True: 0, False: 0]
  ------------------
 2796|       |#ifdef NETSNMP_DEFAULT_MIBFILES
 2797|       |            entry =
 2798|       |                (char *) malloc(strlen(NETSNMP_DEFAULT_MIBFILES) +
 2799|       |                                strlen(env_var) + 2);
 2800|       |            if (!entry) {
 2801|       |                DEBUGMSGTL(("init_mib", "env mibfiles malloc failed"));
 2802|       |            } else {
 2803|       |                if (*env_var++ == '+')
 2804|       |                    sprintf(entry, "%s%c%s", NETSNMP_DEFAULT_MIBFILES, ENV_SEPARATOR_CHAR,
 2805|       |                            env_var );
 2806|       |                else
 2807|       |                    sprintf(entry, "%s%c%s", env_var, ENV_SEPARATOR_CHAR,
 2808|       |                            NETSNMP_DEFAULT_MIBFILES );
 2809|       |            }
 2810|       |            SNMP_FREE(env_var);
 2811|       |            env_var = entry;
 2812|       |#else
 2813|      0|            env_var = strdup(env_var + 1);
 2814|      0|#endif
 2815|      0|        } else {
 2816|      0|            env_var = strdup(env_var);
 2817|      0|        }
 2818|      1|    } else {
 2819|       |#ifdef NETSNMP_DEFAULT_MIBFILES
 2820|       |        env_var = strdup(NETSNMP_DEFAULT_MIBFILES);
 2821|       |#endif
 2822|      1|    }
 2823|       |
 2824|      1|    if (env_var != NULL) {
  ------------------
  |  Branch (2824:9): [True: 0, False: 1]
  ------------------
 2825|      0|        DEBUGMSGTL(("init_mib",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2826|      0|                    "Seen MIBFILES: Looking in '%s' for mib files ...\n",
 2827|      0|                    env_var));
 2828|      0|        entry = strtok_r(env_var, ENV_SEPARATOR, &st);
  ------------------
  |  |   67|      0|#define ENV_SEPARATOR ":"
  ------------------
 2829|      0|        while (entry) {
  ------------------
  |  Branch (2829:16): [True: 0, False: 0]
  ------------------
 2830|      0|            read_mib(entry);
 2831|      0|            entry = strtok_r(NULL, ENV_SEPARATOR, &st);
  ------------------
  |  |   67|      0|#define ENV_SEPARATOR ":"
  ------------------
 2832|      0|        }
 2833|      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, False: 0]
  |  |  ------------------
  ------------------
 2834|      0|    }
 2835|       |
 2836|      1|    prefix = netsnmp_getenv("PREFIX");
 2837|       |
 2838|      1|    if (!prefix)
  ------------------
  |  Branch (2838:9): [True: 1, False: 0]
  ------------------
 2839|      1|        prefix = Standard_Prefix;
 2840|       |
 2841|      1|    Prefix = (char *) malloc(strlen(prefix) + 2);
 2842|      1|    if (!Prefix)
  ------------------
  |  Branch (2842:9): [True: 0, False: 1]
  ------------------
 2843|      0|        DEBUGMSGTL(("init_mib", "Prefix malloc failed"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2844|      1|    else
 2845|      1|        strcpy(Prefix, prefix);
 2846|       |
 2847|      1|    DEBUGMSGTL(("init_mib",
  ------------------
  |  |   66|      1|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      1|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      1|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      1|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      1|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 1]
  |  |  ------------------
  ------------------
 2848|      1|                "Seen PREFIX: Looking in '%s' for prefix ...\n", Prefix));
 2849|       |
 2850|       |    /*
 2851|       |     * remove trailing dot 
 2852|       |     */
 2853|      1|    if (Prefix) {
  ------------------
  |  Branch (2853:9): [True: 1, False: 0]
  ------------------
 2854|      1|        env_var = &Prefix[strlen(Prefix) - 1];
 2855|      1|        if (*env_var == '.')
  ------------------
  |  Branch (2855:13): [True: 0, False: 1]
  ------------------
 2856|      0|            *env_var = '\0';
 2857|      1|    }
 2858|       |
 2859|      1|    pp->str = Prefix;           /* fixup first mib_prefix entry */
 2860|       |    /*
 2861|       |     * now that the list of prefixes is built, save each string length. 
 2862|       |     */
 2863|      7|    while (pp->str) {
  ------------------
  |  Branch (2863:12): [True: 6, False: 1]
  ------------------
 2864|      6|        pp->len = strlen(pp->str);
 2865|      6|        pp++;
 2866|      6|    }
 2867|       |
 2868|      1|    Mib = tree_head;            /* Backwards compatibility */
 2869|      1|    tree_top = calloc(1, sizeof(struct tree));
 2870|       |    /*
 2871|       |     * XX error check ? 
 2872|       |     */
 2873|      1|    if (tree_top) {
  ------------------
  |  Branch (2873:9): [True: 1, False: 0]
  ------------------
 2874|      1|        tree_top->label = strdup("(top)");
 2875|      1|        tree_top->child_list = tree_head;
 2876|      1|    }
 2877|      1|}
set_function:
 2940|      3|{
 2941|      3|    subtree->printer = NULL;
 2942|      3|    switch (subtree->type) {
 2943|      0|    case TYPE_OBJID:
  ------------------
  |  |  155|      0|#define TYPE_OBJID          1
  ------------------
  |  Branch (2943:5): [True: 0, False: 3]
  ------------------
 2944|      0|        subtree->printomat = sprint_realloc_object_identifier;
 2945|      0|        break;
 2946|      0|    case TYPE_OCTETSTR:
  ------------------
  |  |  156|      0|#define TYPE_OCTETSTR       2
  ------------------
  |  Branch (2946:5): [True: 0, False: 3]
  ------------------
 2947|      0|        subtree->printomat = sprint_realloc_octet_string;
 2948|      0|        break;
 2949|      0|    case TYPE_INTEGER:
  ------------------
  |  |  157|      0|#define TYPE_INTEGER        3
  ------------------
  |  Branch (2949:5): [True: 0, False: 3]
  ------------------
 2950|      0|        subtree->printomat = sprint_realloc_integer;
 2951|      0|        break;
 2952|      0|    case TYPE_INTEGER32:
  ------------------
  |  |  170|      0|#define TYPE_INTEGER32      16
  ------------------
  |  Branch (2952:5): [True: 0, False: 3]
  ------------------
 2953|      0|        subtree->printomat = sprint_realloc_integer;
 2954|      0|        break;
 2955|      0|    case TYPE_NETADDR:
  ------------------
  |  |  158|      0|#define TYPE_NETADDR        4
  ------------------
  |  Branch (2955:5): [True: 0, False: 3]
  ------------------
 2956|      0|        subtree->printomat = sprint_realloc_networkaddress;
 2957|      0|        break;
 2958|      0|    case TYPE_IPADDR:
  ------------------
  |  |  159|      0|#define TYPE_IPADDR         5
  ------------------
  |  Branch (2958:5): [True: 0, False: 3]
  ------------------
 2959|      0|        subtree->printomat = sprint_realloc_ipaddress;
 2960|      0|        break;
 2961|      0|    case TYPE_COUNTER:
  ------------------
  |  |  160|      0|#define TYPE_COUNTER        6
  ------------------
  |  Branch (2961:5): [True: 0, False: 3]
  ------------------
 2962|      0|        subtree->printomat = sprint_realloc_counter;
 2963|      0|        break;
 2964|      0|    case TYPE_GAUGE:
  ------------------
  |  |  161|      0|#define TYPE_GAUGE          7
  ------------------
  |  Branch (2964:5): [True: 0, False: 3]
  ------------------
 2965|      0|        subtree->printomat = sprint_realloc_gauge;
 2966|      0|        break;
 2967|      0|    case TYPE_TIMETICKS:
  ------------------
  |  |  162|      0|#define TYPE_TIMETICKS      8
  ------------------
  |  Branch (2967:5): [True: 0, False: 3]
  ------------------
 2968|      0|        subtree->printomat = sprint_realloc_timeticks;
 2969|      0|        break;
 2970|      0|    case TYPE_OPAQUE:
  ------------------
  |  |  163|      0|#define TYPE_OPAQUE         9
  ------------------
  |  Branch (2970:5): [True: 0, False: 3]
  ------------------
 2971|      0|        subtree->printomat = sprint_realloc_opaque;
 2972|      0|        break;
 2973|      0|    case TYPE_NULL:
  ------------------
  |  |  164|      0|#define TYPE_NULL           10
  ------------------
  |  Branch (2973:5): [True: 0, False: 3]
  ------------------
 2974|      0|        subtree->printomat = sprint_realloc_null;
 2975|      0|        break;
 2976|      0|    case TYPE_BITSTRING:
  ------------------
  |  |  166|      0|#define TYPE_BITSTRING      12
  ------------------
  |  Branch (2976:5): [True: 0, False: 3]
  ------------------
 2977|      0|        subtree->printomat = sprint_realloc_bitstring;
 2978|      0|        break;
 2979|      0|    case TYPE_NSAPADDRESS:
  ------------------
  |  |  167|      0|#define TYPE_NSAPADDRESS    13
  ------------------
  |  Branch (2979:5): [True: 0, False: 3]
  ------------------
 2980|      0|        subtree->printomat = sprint_realloc_nsapaddress;
 2981|      0|        break;
 2982|      0|    case TYPE_COUNTER64:
  ------------------
  |  |  165|      0|#define TYPE_COUNTER64      11
  ------------------
  |  Branch (2982:5): [True: 0, False: 3]
  ------------------
 2983|      0|        subtree->printomat = sprint_realloc_counter64;
 2984|      0|        break;
 2985|      0|    case TYPE_UINTEGER:
  ------------------
  |  |  168|      0|#define TYPE_UINTEGER       14
  ------------------
  |  Branch (2985:5): [True: 0, False: 3]
  ------------------
 2986|      0|        subtree->printomat = sprint_realloc_uinteger;
 2987|      0|        break;
 2988|      0|    case TYPE_UNSIGNED32:
  ------------------
  |  |  169|      0|#define TYPE_UNSIGNED32     15
  ------------------
  |  Branch (2988:5): [True: 0, False: 3]
  ------------------
 2989|      0|        subtree->printomat = sprint_realloc_gauge;
 2990|      0|        break;
 2991|      3|    case TYPE_OTHER:
  ------------------
  |  |  154|      3|#define TYPE_OTHER          0
  ------------------
  |  Branch (2991:5): [True: 3, False: 0]
  ------------------
 2992|      3|    default:
  ------------------
  |  Branch (2992:5): [True: 0, False: 3]
  ------------------
 2993|      3|        subtree->printomat = sprint_realloc_by_type;
 2994|      3|        break;
 2995|      3|    }
 2996|      3|}
netsnmp_sprint_realloc_objid_tree:
 3170|  2.66k|{
 3171|  2.66k|    u_char         *tbuf = NULL, *cp = NULL;
 3172|  2.66k|    size_t          tbuf_len = 512, tout_len = 0;
 3173|  2.66k|    struct tree    *subtree = tree_head;
 3174|  2.66k|    size_t          midpoint_offset = 0;
 3175|  2.66k|    int             tbuf_overflow = 0;
 3176|  2.66k|    int             output_format;
 3177|       |
 3178|  2.66k|    if ((tbuf = calloc(tbuf_len, 1)) == NULL) {
  ------------------
  |  Branch (3178:9): [True: 0, False: 2.66k]
  ------------------
 3179|      0|        tbuf_overflow = 1;
 3180|  2.66k|    } else {
 3181|  2.66k|        *tbuf = '.';
 3182|  2.66k|        tout_len = 1;
 3183|  2.66k|    }
 3184|       |
 3185|  2.66k|    subtree = _get_realloc_symbol(objid, objidlen, subtree,
 3186|  2.66k|                                  &tbuf, &tbuf_len, &tout_len,
 3187|  2.66k|                                  allow_realloc, &tbuf_overflow, NULL,
 3188|  2.66k|                                  &midpoint_offset);
 3189|       |
 3190|  2.66k|    if (tbuf_overflow) {
  ------------------
  |  Branch (3190:9): [True: 0, False: 2.66k]
  ------------------
 3191|      0|        if (!*buf_overflow) {
  ------------------
  |  Branch (3191:13): [True: 0, False: 0]
  ------------------
 3192|      0|            snmp_strcat(buf, buf_len, out_len, allow_realloc, tbuf);
 3193|      0|            *buf_overflow = 1;
 3194|      0|        }
 3195|      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, False: 0]
  |  |  ------------------
  ------------------
 3196|      0|        return subtree;
 3197|      0|    }
 3198|       |
 3199|  2.66k|    output_format = netsnmp_ds_get_int(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_OID_OUTPUT_FORMAT);
  ------------------
  |  |   48|  2.66k|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                  output_format = netsnmp_ds_get_int(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_OID_OUTPUT_FORMAT);
  ------------------
  |  |  118|  2.66k|#define NETSNMP_DS_LIB_OID_OUTPUT_FORMAT    4
  ------------------
 3200|  2.66k|    if (0 == output_format) {
  ------------------
  |  Branch (3200:9): [True: 2.66k, False: 0]
  ------------------
 3201|  2.66k|        output_format = NETSNMP_OID_OUTPUT_MODULE;
  ------------------
  |  |  512|  2.66k|#define NETSNMP_OID_OUTPUT_MODULE  2
  ------------------
 3202|  2.66k|    }
 3203|  2.66k|    switch (output_format) {
 3204|      0|    case NETSNMP_OID_OUTPUT_FULL:
  ------------------
  |  |  513|      0|#define NETSNMP_OID_OUTPUT_FULL    3
  ------------------
  |  Branch (3204:5): [True: 0, False: 2.66k]
  ------------------
 3205|      0|    case NETSNMP_OID_OUTPUT_FULL_AND_NUMERIC:
  ------------------
  |  |  517|      0|#define NETSNMP_OID_OUTPUT_FULL_AND_NUMERIC 7
  ------------------
  |  Branch (3205:5): [True: 0, False: 2.66k]
  ------------------
 3206|      0|    case NETSNMP_OID_OUTPUT_NUMERIC:
  ------------------
  |  |  514|      0|#define NETSNMP_OID_OUTPUT_NUMERIC 4
  ------------------
  |  Branch (3206:5): [True: 0, False: 2.66k]
  ------------------
 3207|      0|        cp = tbuf;
 3208|      0|        break;
 3209|       |
 3210|      0|    case NETSNMP_OID_OUTPUT_SUFFIX:
  ------------------
  |  |  511|      0|#define NETSNMP_OID_OUTPUT_SUFFIX  1
  ------------------
  |  Branch (3210:5): [True: 0, False: 2.66k]
  ------------------
 3211|  2.66k|    case NETSNMP_OID_OUTPUT_MODULE:
  ------------------
  |  |  512|  2.66k|#define NETSNMP_OID_OUTPUT_MODULE  2
  ------------------
  |  Branch (3211:5): [True: 2.66k, False: 0]
  ------------------
 3212|   153k|        for (cp = tbuf; *cp; cp++);
  ------------------
  |  Branch (3212:25): [True: 151k, False: 2.66k]
  ------------------
 3213|       |
 3214|  2.66k|        if (midpoint_offset != 0) {
  ------------------
  |  Branch (3214:13): [True: 2.60k, False: 63]
  ------------------
 3215|  2.60k|            cp = tbuf + midpoint_offset - 2;    /*  beyond the '.'  */
 3216|  2.60k|        } else {
 3217|    126|            while (cp >= tbuf) {
  ------------------
  |  Branch (3217:20): [True: 126, False: 0]
  ------------------
 3218|    126|                if (isalpha(*cp)) {
  ------------------
  |  Branch (3218:21): [True: 63, False: 63]
  ------------------
 3219|     63|                    break;
 3220|     63|                }
 3221|     63|                cp--;
 3222|     63|            }
 3223|     63|        }
 3224|       |
 3225|  41.9k|        while (cp >= tbuf) {
  ------------------
  |  Branch (3225:16): [True: 41.9k, False: 0]
  ------------------
 3226|  41.9k|            if (*cp == '.') {
  ------------------
  |  Branch (3226:17): [True: 2.66k, False: 39.3k]
  ------------------
 3227|  2.66k|                break;
 3228|  2.66k|            }
 3229|  39.3k|            cp--;
 3230|  39.3k|        }
 3231|       |
 3232|  2.66k|        cp++;
 3233|       |
 3234|  2.66k|        if ((NETSNMP_OID_OUTPUT_MODULE == output_format)
  ------------------
  |  |  512|  2.66k|#define NETSNMP_OID_OUTPUT_MODULE  2
  ------------------
  |  Branch (3234:13): [True: 2.66k, False: 0]
  ------------------
 3235|  2.66k|            && cp > tbuf) {
  ------------------
  |  Branch (3235:16): [True: 2.66k, False: 0]
  ------------------
 3236|  2.66k|            char            modbuf[256] = { 0 }, *mod =
 3237|  2.66k|                module_name(subtree->modid, modbuf);
 3238|       |
 3239|       |            /*
 3240|       |             * Don't add the module ID if it's just numeric (i.e. we couldn't look
 3241|       |             * it up properly.  
 3242|       |             */
 3243|       |
 3244|  2.66k|            if (!*buf_overflow && modbuf[0] != '#') {
  ------------------
  |  Branch (3244:17): [True: 2.66k, False: 0]
  |  Branch (3244:35): [True: 0, False: 2.66k]
  ------------------
 3245|      0|                if (!snmp_cstrcat(buf, buf_len, out_len, allow_realloc, mod) ||
  ------------------
  |  Branch (3245:21): [True: 0, False: 0]
  ------------------
 3246|      0|                    !snmp_cstrcat(buf, buf_len, out_len, allow_realloc, "::")) {
  ------------------
  |  Branch (3246:21): [True: 0, False: 0]
  ------------------
 3247|      0|                    *buf_overflow = 1;
 3248|      0|                }
 3249|      0|            }
 3250|  2.66k|        }
 3251|  2.66k|        break;
 3252|       |
 3253|      0|    case NETSNMP_OID_OUTPUT_UCD:
  ------------------
  |  |  515|      0|#define NETSNMP_OID_OUTPUT_UCD     5
  ------------------
  |  Branch (3253:5): [True: 0, False: 2.66k]
  ------------------
 3254|      0|    {
 3255|      0|        PrefixListPtr   pp = &mib_prefixes[0];
 3256|      0|        size_t          ilen, tlen;
 3257|      0|        const char     *testcp;
 3258|       |
 3259|      0|        cp = tbuf;
 3260|      0|        tlen = strlen((char *) tbuf);
 3261|       |
 3262|      0|        while (pp->str) {
  ------------------
  |  Branch (3262:16): [True: 0, False: 0]
  ------------------
 3263|      0|            ilen = pp->len;
 3264|      0|            testcp = pp->str;
 3265|       |
 3266|      0|            if ((tlen > ilen) && memcmp(tbuf, testcp, ilen) == 0) {
  ------------------
  |  Branch (3266:17): [True: 0, False: 0]
  |  Branch (3266:34): [True: 0, False: 0]
  ------------------
 3267|      0|                cp += (ilen + 1);
 3268|      0|                break;
 3269|      0|            }
 3270|      0|            pp++;
 3271|      0|        }
 3272|      0|        break;
 3273|      0|    }
 3274|       |
 3275|      0|    case NETSNMP_OID_OUTPUT_NONE:
  ------------------
  |  |  516|      0|#define NETSNMP_OID_OUTPUT_NONE    6
  ------------------
  |  Branch (3275:5): [True: 0, False: 2.66k]
  ------------------
 3276|      0|    default:
  ------------------
  |  Branch (3276:5): [True: 0, False: 2.66k]
  ------------------
 3277|      0|        cp = NULL;
 3278|  2.66k|    }
 3279|       |
 3280|  2.66k|    if (!*buf_overflow &&
  ------------------
  |  Branch (3280:9): [True: 2.66k, False: 0]
  ------------------
 3281|  2.66k|        !snmp_strcat(buf, buf_len, out_len, allow_realloc, cp)) {
  ------------------
  |  Branch (3281:9): [True: 0, False: 2.66k]
  ------------------
 3282|      0|        *buf_overflow = 1;
 3283|      0|    }
 3284|       |    SNMP_FREE(tbuf);
  ------------------
  |  |   62|  2.66k|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 2.66k, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 2.66k]
  |  |  ------------------
  ------------------
 3285|  2.66k|    return subtree;
 3286|  2.66k|}
sprint_realloc_objid:
 3293|  2.66k|{
 3294|  2.66k|    int             buf_overflow = 0;
 3295|       |
 3296|  2.66k|    netsnmp_sprint_realloc_objid_tree(buf, buf_len, out_len, allow_realloc,
 3297|  2.66k|                                      &buf_overflow, objid, objidlen);
 3298|  2.66k|    return !buf_overflow;
 3299|  2.66k|}
mib.c:_oid_finish_printing:
 4166|  2.60k|                     int allow_realloc, int *buf_overflow) {
 4167|  2.60k|    char            intbuf[64];
 4168|  2.60k|    if (*buf != NULL && *(*buf + *out_len - 1) != '.') {
  ------------------
  |  Branch (4168:9): [True: 2.60k, False: 0]
  |  Branch (4168:25): [True: 0, False: 2.60k]
  ------------------
 4169|      0|        if (!*buf_overflow && !snmp_cstrcat(buf, buf_len, out_len,
  ------------------
  |  Branch (4169:13): [True: 0, False: 0]
  |  Branch (4169:31): [True: 0, False: 0]
  ------------------
 4170|      0|                                            allow_realloc, ".")) {
 4171|      0|            *buf_overflow = 1;
 4172|      0|        }
 4173|      0|    }
 4174|       |
 4175|  33.6k|    while (objidlen-- > 0) {    /* output rest of name, uninterpreted */
  ------------------
  |  Branch (4175:12): [True: 31.0k, False: 2.60k]
  ------------------
 4176|  31.0k|        sprintf(intbuf, "%" NETSNMP_PRIo "u.", *objid++);
 4177|  31.0k|        if (!*buf_overflow && !snmp_cstrcat(buf, buf_len, out_len,
  ------------------
  |  Branch (4177:13): [True: 31.0k, False: 0]
  |  Branch (4177:31): [True: 0, False: 31.0k]
  ------------------
 4178|  31.0k|                                            allow_realloc, intbuf)) {
 4179|      0|            *buf_overflow = 1;
 4180|      0|        }
 4181|  31.0k|    }
 4182|       |
 4183|  2.60k|    if (*buf != NULL) {
  ------------------
  |  Branch (4183:9): [True: 2.60k, False: 0]
  ------------------
 4184|  2.60k|        *(*buf + *out_len - 1) = '\0';  /* remove trailing dot */
 4185|  2.60k|        *out_len = *out_len - 1;
 4186|  2.60k|    }
 4187|  2.60k|}
mib.c:_get_realloc_symbol:
 4221|  5.26k|{
 4222|  5.26k|    struct tree    *return_tree = NULL;
 4223|  5.26k|    int             extended_index =
 4224|  5.26k|        netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_EXTENDED_INDEX);
  ------------------
  |  |   48|  5.26k|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                      netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_EXTENDED_INDEX);
  ------------------
  |  |   82|  5.26k|#define NETSNMP_DS_LIB_EXTENDED_INDEX	   22   /* print extended index format [x1][x2] */
  ------------------
 4225|  5.26k|    int             output_format =
 4226|  5.26k|        netsnmp_ds_get_int(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_OID_OUTPUT_FORMAT);
  ------------------
  |  |   48|  5.26k|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                      netsnmp_ds_get_int(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_OID_OUTPUT_FORMAT);
  ------------------
  |  |  118|  5.26k|#define NETSNMP_DS_LIB_OID_OUTPUT_FORMAT    4
  ------------------
 4227|  5.26k|    char            intbuf[64];
 4228|  5.26k|    struct tree    *orgtree = subtree;
 4229|       |
 4230|  5.26k|    if (!objid || !buf) {
  ------------------
  |  Branch (4230:9): [True: 0, False: 5.26k]
  |  Branch (4230:19): [True: 0, False: 5.26k]
  ------------------
 4231|      0|        return NULL;
 4232|      0|    }
 4233|       |
 4234|  10.5k|    for (; subtree; subtree = subtree->next_peer) {
  ------------------
  |  Branch (4234:12): [True: 7.92k, False: 2.60k]
  ------------------
 4235|  7.92k|        if (*objid == subtree->subid) {
  ------------------
  |  Branch (4235:13): [True: 2.66k, False: 5.26k]
  ------------------
 4236|  2.66k|	    while (subtree->next_peer && subtree->next_peer->subid == *objid)
  ------------------
  |  Branch (4236:13): [True: 63, False: 2.60k]
  |  Branch (4236:35): [True: 0, False: 63]
  ------------------
 4237|      0|		subtree = subtree->next_peer;
 4238|  2.66k|            if (subtree->indexes) {
  ------------------
  |  Branch (4238:17): [True: 0, False: 2.66k]
  ------------------
 4239|      0|                in_dices = subtree->indexes;
 4240|  2.66k|            } else if (subtree->augments) {
  ------------------
  |  Branch (4240:24): [True: 0, False: 2.66k]
  ------------------
 4241|      0|                struct tree    *tp2 =
 4242|      0|                    find_tree_node(subtree->augments, -1);
 4243|      0|                if (tp2) {
  ------------------
  |  Branch (4243:21): [True: 0, False: 0]
  ------------------
 4244|      0|                    in_dices = tp2->indexes;
 4245|      0|                }
 4246|      0|            }
 4247|       |
 4248|  2.66k|            if (!strncmp(subtree->label, ANON, ANON_LEN) ||
  ------------------
  |  |  196|  2.66k|#define	ANON	"anonymous#"
  ------------------
                          if (!strncmp(subtree->label, ANON, ANON_LEN) ||
  ------------------
  |  |  197|  2.66k|#define	ANON_LEN  strlen(ANON)
  |  |  ------------------
  |  |  |  |  196|  2.66k|#define	ANON	"anonymous#"
  |  |  ------------------
  ------------------
  |  Branch (4248:17): [True: 0, False: 2.66k]
  ------------------
 4249|  2.66k|                (NETSNMP_OID_OUTPUT_NUMERIC == output_format)) {
  ------------------
  |  |  514|  2.66k|#define NETSNMP_OID_OUTPUT_NUMERIC 4
  ------------------
  |  Branch (4249:17): [True: 0, False: 2.66k]
  ------------------
 4250|      0|                sprintf(intbuf, "%lu", subtree->subid);
 4251|      0|                if (!*buf_overflow && !snmp_cstrcat(buf, buf_len, out_len,
  ------------------
  |  Branch (4251:21): [True: 0, False: 0]
  |  Branch (4251:39): [True: 0, False: 0]
  ------------------
 4252|      0|                                                    allow_realloc, intbuf)) {
 4253|      0|                    *buf_overflow = 1;
 4254|      0|                }
 4255|  2.66k|            } else {
 4256|  2.66k|                if (!*buf_overflow &&
  ------------------
  |  Branch (4256:21): [True: 2.66k, False: 0]
  ------------------
 4257|  2.66k|                    !snmp_cstrcat(buf, buf_len, out_len, allow_realloc,
  ------------------
  |  Branch (4257:21): [True: 0, False: 2.66k]
  ------------------
 4258|  2.66k|                                  subtree->label)) {
 4259|      0|                    *buf_overflow = 1;
 4260|      0|                }
 4261|  2.66k|                if (output_format == NETSNMP_OID_OUTPUT_FULL_AND_NUMERIC) {
  ------------------
  |  |  517|  2.66k|#define NETSNMP_OID_OUTPUT_FULL_AND_NUMERIC 7
  ------------------
  |  Branch (4261:21): [True: 0, False: 2.66k]
  ------------------
 4262|      0|                    snprintf(intbuf, sizeof intbuf, "(%lu)", subtree->subid);
 4263|      0|                    if (!*buf_overflow &&
  ------------------
  |  Branch (4263:25): [True: 0, False: 0]
  ------------------
 4264|      0|                        !snmp_cstrcat(buf, buf_len, out_len, allow_realloc,
  ------------------
  |  Branch (4264:25): [True: 0, False: 0]
  ------------------
 4265|      0|                                      intbuf)) {
 4266|      0|                        *buf_overflow = 1;
 4267|      0|                    }
 4268|      0|                }
 4269|  2.66k|            }
 4270|       |
 4271|  2.66k|            if (objidlen > 1) {
  ------------------
  |  Branch (4271:17): [True: 2.60k, False: 63]
  ------------------
 4272|  2.60k|                if (!*buf_overflow &&
  ------------------
  |  Branch (4272:21): [True: 2.60k, False: 0]
  ------------------
 4273|  2.60k|                    !snmp_cstrcat(buf, buf_len, out_len, allow_realloc, ".")) {
  ------------------
  |  Branch (4273:21): [True: 0, False: 2.60k]
  ------------------
 4274|      0|                    *buf_overflow = 1;
 4275|      0|                }
 4276|       |
 4277|  2.60k|                return_tree = _get_realloc_symbol(objid + 1, objidlen - 1,
 4278|  2.60k|                                                  subtree->child_list,
 4279|  2.60k|                                                  buf, buf_len, out_len,
 4280|  2.60k|                                                  allow_realloc,
 4281|  2.60k|                                                  buf_overflow, in_dices,
 4282|  2.60k|                                                  end_of_known);
 4283|  2.60k|            }
 4284|       |
 4285|  2.66k|            if (return_tree != NULL) {
  ------------------
  |  Branch (4285:17): [True: 0, False: 2.66k]
  ------------------
 4286|      0|                return return_tree;
 4287|  2.66k|            } else {
 4288|  2.66k|                return subtree;
 4289|  2.66k|            }
 4290|  2.66k|        }
 4291|  7.92k|    }
 4292|       |
 4293|  2.60k|    if (end_of_known) {
  ------------------
  |  Branch (4293:9): [True: 2.60k, False: 0]
  ------------------
 4294|  2.60k|        *end_of_known = *out_len;
 4295|  2.60k|    }
 4296|       |
 4297|       |    /*
 4298|       |     * Subtree not found.  
 4299|       |     */
 4300|       |
 4301|  2.60k|    if (orgtree && in_dices && objidlen > 0) {
  ------------------
  |  Branch (4301:9): [True: 0, False: 2.60k]
  |  Branch (4301:20): [True: 0, False: 0]
  |  Branch (4301:32): [True: 0, False: 0]
  ------------------
 4302|      0|	sprintf(intbuf, "%" NETSNMP_PRIo "u.", *objid);
 4303|      0|	if (!*buf_overflow
  ------------------
  |  Branch (4303:6): [True: 0, False: 0]
  ------------------
 4304|      0|	    && !snmp_cstrcat(buf, buf_len, out_len, allow_realloc, intbuf)) {
  ------------------
  |  Branch (4304:9): [True: 0, False: 0]
  ------------------
 4305|      0|	    *buf_overflow = 1;
 4306|      0|	}
 4307|      0|	objid++;
 4308|      0|	objidlen--;
 4309|      0|    }
 4310|       |
 4311|  2.60k|    while (in_dices && (objidlen > 0) &&
  ------------------
  |  Branch (4311:12): [True: 0, False: 2.60k]
  |  Branch (4311:24): [True: 0, False: 0]
  ------------------
 4312|      0|           (NETSNMP_OID_OUTPUT_NUMERIC != output_format) &&
  ------------------
  |  |  514|      0|#define NETSNMP_OID_OUTPUT_NUMERIC 4
  ------------------
  |  Branch (4312:12): [True: 0, False: 0]
  ------------------
 4313|      0|           !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 (4313:12): [True: 0, False: 0]
  ------------------
 4314|      0|        size_t          numids;
 4315|      0|        struct tree    *tp;
 4316|       |
 4317|      0|        tp = find_tree_node(in_dices->ilabel, -1);
 4318|       |
 4319|      0|        if (!tp) {
  ------------------
  |  Branch (4319:13): [True: 0, False: 0]
  ------------------
 4320|       |            /*
 4321|       |             * Can't find an index in the mib tree.  Bail.  
 4322|       |             */
 4323|      0|            goto finish_it;
 4324|      0|        }
 4325|       |
 4326|      0|        if (extended_index) {
  ------------------
  |  Branch (4326:13): [True: 0, False: 0]
  ------------------
 4327|      0|            if (*buf != NULL && *(*buf + *out_len - 1) == '.') {
  ------------------
  |  Branch (4327:17): [True: 0, False: 0]
  |  Branch (4327:33): [True: 0, False: 0]
  ------------------
 4328|      0|                (*out_len)--;
 4329|      0|            }
 4330|      0|            if (!*buf_overflow &&
  ------------------
  |  Branch (4330:17): [True: 0, False: 0]
  ------------------
 4331|      0|                !snmp_cstrcat(buf, buf_len, out_len, allow_realloc, "[")) {
  ------------------
  |  Branch (4331:17): [True: 0, False: 0]
  ------------------
 4332|      0|                *buf_overflow = 1;
 4333|      0|            }
 4334|      0|        }
 4335|       |
 4336|      0|        switch (tp->type) {
 4337|      0|        case TYPE_OCTETSTR:
  ------------------
  |  |  156|      0|#define TYPE_OCTETSTR       2
  ------------------
  |  Branch (4337:9): [True: 0, False: 0]
  ------------------
 4338|      0|            if (extended_index && tp->hint) {
  ------------------
  |  Branch (4338:17): [True: 0, False: 0]
  |  Branch (4338:35): [True: 0, False: 0]
  ------------------
 4339|      0|                if (in_dices->isimplied) {
  ------------------
  |  Branch (4339:21): [True: 0, False: 0]
  ------------------
 4340|      0|                    numids = objidlen;
 4341|      0|                    if (numids > objidlen)
  ------------------
  |  Branch (4341:25): [True: 0, False: 0]
  ------------------
 4342|      0|                        goto finish_it;
 4343|      0|                } else if (tp->ranges && !tp->ranges->next
  ------------------
  |  Branch (4343:28): [True: 0, False: 0]
  |  Branch (4343:42): [True: 0, False: 0]
  ------------------
 4344|      0|                           && tp->ranges->low == tp->ranges->high) {
  ------------------
  |  Branch (4344:31): [True: 0, False: 0]
  ------------------
 4345|      0|                    numids = tp->ranges->low;
 4346|      0|                    if (numids > objidlen)
  ------------------
  |  Branch (4346:25): [True: 0, False: 0]
  ------------------
 4347|      0|                        goto finish_it;
 4348|      0|                } else {
 4349|      0|                    numids = *objid;
 4350|      0|                    if (numids >= objidlen)
  ------------------
  |  Branch (4350:25): [True: 0, False: 0]
  ------------------
 4351|      0|                        goto finish_it;
 4352|      0|                    objid++;
 4353|      0|                    objidlen--;
 4354|      0|                }
 4355|      0|                if (numids > objidlen)
  ------------------
  |  Branch (4355:21): [True: 0, False: 0]
  ------------------
 4356|      0|                    goto finish_it;
 4357|      0|		_get_realloc_symbol_octet_string(numids, objid, buf, buf_len,
 4358|      0|						 out_len, allow_realloc,
 4359|      0|						 buf_overflow, tp);
 4360|      0|            } else if (in_dices->isimplied) {
  ------------------
  |  Branch (4360:24): [True: 0, False: 0]
  ------------------
 4361|      0|                numids = objidlen;
 4362|      0|                if (numids > objidlen)
  ------------------
  |  Branch (4362:21): [True: 0, False: 0]
  ------------------
 4363|      0|                    goto finish_it;
 4364|       |
 4365|      0|                if (!*buf_overflow) {
  ------------------
  |  Branch (4365:21): [True: 0, False: 0]
  ------------------
 4366|      0|                    if (!dump_realloc_oid_to_string
  ------------------
  |  Branch (4366:25): [True: 0, False: 0]
  ------------------
 4367|      0|                        (objid, numids, buf, buf_len, out_len,
 4368|      0|                         allow_realloc, '\'')) {
 4369|      0|                        *buf_overflow = 1;
 4370|      0|                    }
 4371|      0|                }
 4372|      0|            } else if (tp->ranges && !tp->ranges->next
  ------------------
  |  Branch (4372:24): [True: 0, False: 0]
  |  Branch (4372:38): [True: 0, False: 0]
  ------------------
 4373|      0|                       && tp->ranges->low == tp->ranges->high) {
  ------------------
  |  Branch (4373:27): [True: 0, False: 0]
  ------------------
 4374|       |                /*
 4375|       |                 * a fixed-length octet string 
 4376|       |                 */
 4377|      0|                numids = tp->ranges->low;
 4378|      0|                if (numids > objidlen)
  ------------------
  |  Branch (4378:21): [True: 0, False: 0]
  ------------------
 4379|      0|                    goto finish_it;
 4380|       |
 4381|      0|                if (!*buf_overflow) {
  ------------------
  |  Branch (4381:21): [True: 0, False: 0]
  ------------------
 4382|      0|                    if (!dump_realloc_oid_to_string
  ------------------
  |  Branch (4382:25): [True: 0, False: 0]
  ------------------
 4383|      0|                        (objid, numids, buf, buf_len, out_len,
 4384|      0|                         allow_realloc, '\'')) {
 4385|      0|                        *buf_overflow = 1;
 4386|      0|                    }
 4387|      0|                }
 4388|      0|            } else {
 4389|      0|                numids = (size_t) * objid + 1;
 4390|      0|                if (numids > objidlen)
  ------------------
  |  Branch (4390:21): [True: 0, False: 0]
  ------------------
 4391|      0|                    goto finish_it;
 4392|      0|                if (numids == 1) {
  ------------------
  |  Branch (4392:21): [True: 0, False: 0]
  ------------------
 4393|      0|                    if (netsnmp_ds_get_boolean
  ------------------
  |  Branch (4393:25): [True: 0, False: 0]
  ------------------
 4394|      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 */
  ------------------
 4395|      0|                        if (!*buf_overflow &&
  ------------------
  |  Branch (4395:29): [True: 0, False: 0]
  ------------------
 4396|      0|                            !snmp_cstrcat(buf, buf_len, out_len, allow_realloc,
  ------------------
  |  Branch (4396:29): [True: 0, False: 0]
  ------------------
 4397|      0|                                          "\\")) {
 4398|      0|                            *buf_overflow = 1;
 4399|      0|                        }
 4400|      0|                    }
 4401|      0|                    if (!*buf_overflow &&
  ------------------
  |  Branch (4401:25): [True: 0, False: 0]
  ------------------
 4402|      0|                        !snmp_cstrcat(buf, buf_len, out_len, allow_realloc,
  ------------------
  |  Branch (4402:25): [True: 0, False: 0]
  ------------------
 4403|      0|                                      "\"")) {
 4404|      0|                        *buf_overflow = 1;
 4405|      0|                    }
 4406|      0|                    if (netsnmp_ds_get_boolean
  ------------------
  |  Branch (4406:25): [True: 0, False: 0]
  ------------------
 4407|      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 */
  ------------------
 4408|      0|                        if (!*buf_overflow &&
  ------------------
  |  Branch (4408:29): [True: 0, False: 0]
  ------------------
 4409|      0|                            !snmp_cstrcat(buf, buf_len, out_len, allow_realloc,
  ------------------
  |  Branch (4409:29): [True: 0, False: 0]
  ------------------
 4410|      0|                                          "\\")) {
 4411|      0|                            *buf_overflow = 1;
 4412|      0|                        }
 4413|      0|                    }
 4414|      0|                    if (!*buf_overflow &&
  ------------------
  |  Branch (4414:25): [True: 0, False: 0]
  ------------------
 4415|      0|                        !snmp_cstrcat(buf, buf_len, out_len, allow_realloc,
  ------------------
  |  Branch (4415:25): [True: 0, False: 0]
  ------------------
 4416|      0|                                      "\"")) {
 4417|      0|                        *buf_overflow = 1;
 4418|      0|                    }
 4419|      0|                } else {
 4420|      0|                    if (!*buf_overflow) {
  ------------------
  |  Branch (4420:25): [True: 0, False: 0]
  ------------------
 4421|      0|                        struct tree * next_peer;
 4422|      0|                        int normal_handling = 1;
 4423|       |
 4424|      0|                        if (tp->next_peer) {
  ------------------
  |  Branch (4424:29): [True: 0, False: 0]
  ------------------
 4425|      0|                            next_peer = tp->next_peer;
 4426|      0|                        }
 4427|       |
 4428|       |                        /* Try handling the InetAddress in the OID, in case of failure,
 4429|       |                         * use the normal_handling. 
 4430|       |                         */
 4431|      0|                        if (tp->next_peer &&
  ------------------
  |  Branch (4431:29): [True: 0, False: 0]
  ------------------
 4432|      0|                            tp->tc_index != -1 &&
  ------------------
  |  Branch (4432:29): [True: 0, False: 0]
  ------------------
 4433|      0|                            next_peer->tc_index != -1 &&
  ------------------
  |  Branch (4433:29): [True: 0, False: 0]
  ------------------
 4434|      0|                            strcmp(get_tc_descriptor(tp->tc_index), "InetAddress") == 0 &&
  ------------------
  |  Branch (4434:29): [True: 0, False: 0]
  ------------------
 4435|      0|                            strcmp(get_tc_descriptor(next_peer->tc_index), 
  ------------------
  |  Branch (4435:29): [True: 0, False: 0]
  ------------------
 4436|      0|                                    "InetAddressType") == 0 ) {
 4437|       |
 4438|      0|                            int ret;
 4439|      0|                            int addr_type = *(objid - 1);
 4440|       |
 4441|      0|                            ret = dump_realloc_oid_to_inetaddress(addr_type, 
 4442|      0|                                        objid + 1, numids - 1, buf, buf_len, out_len,
 4443|      0|                                        allow_realloc, '"');
 4444|      0|                            if (ret != 2) {
  ------------------
  |  Branch (4444:33): [True: 0, False: 0]
  ------------------
 4445|      0|                                normal_handling = 0;
 4446|      0|                                if (ret == 0) {
  ------------------
  |  Branch (4446:37): [True: 0, False: 0]
  ------------------
 4447|      0|                                    *buf_overflow = 1;
 4448|      0|                                }
 4449|       |
 4450|      0|                            }
 4451|      0|                        } 
 4452|      0|                        if (normal_handling && !dump_realloc_oid_to_string
  ------------------
  |  Branch (4452:29): [True: 0, False: 0]
  |  Branch (4452:48): [True: 0, False: 0]
  ------------------
 4453|      0|                            (objid + 1, numids - 1, buf, buf_len, out_len,
 4454|      0|                             allow_realloc, '"')) {
 4455|      0|                            *buf_overflow = 1;
 4456|      0|                        }
 4457|      0|                    }
 4458|      0|                }
 4459|      0|            }
 4460|      0|            objid += numids;
 4461|      0|            objidlen -= numids;
 4462|      0|            break;
 4463|       |
 4464|      0|        case TYPE_INTEGER32:
  ------------------
  |  |  170|      0|#define TYPE_INTEGER32      16
  ------------------
  |  Branch (4464:9): [True: 0, False: 0]
  ------------------
 4465|      0|        case TYPE_UINTEGER:
  ------------------
  |  |  168|      0|#define TYPE_UINTEGER       14
  ------------------
  |  Branch (4465:9): [True: 0, False: 0]
  ------------------
 4466|      0|        case TYPE_UNSIGNED32:
  ------------------
  |  |  169|      0|#define TYPE_UNSIGNED32     15
  ------------------
  |  Branch (4466:9): [True: 0, False: 0]
  ------------------
 4467|      0|        case TYPE_GAUGE:
  ------------------
  |  |  161|      0|#define TYPE_GAUGE          7
  ------------------
  |  Branch (4467:9): [True: 0, False: 0]
  ------------------
 4468|      0|        case TYPE_INTEGER:
  ------------------
  |  |  157|      0|#define TYPE_INTEGER        3
  ------------------
  |  Branch (4468:9): [True: 0, False: 0]
  ------------------
 4469|      0|            if (tp->enums) {
  ------------------
  |  Branch (4469:17): [True: 0, False: 0]
  ------------------
 4470|      0|                struct enum_list *ep = tp->enums;
 4471|      0|                while (ep && ep->value != (int) (*objid)) {
  ------------------
  |  Branch (4471:24): [True: 0, False: 0]
  |  Branch (4471:30): [True: 0, False: 0]
  ------------------
 4472|      0|                    ep = ep->next;
 4473|      0|                }
 4474|      0|                if (ep) {
  ------------------
  |  Branch (4474:21): [True: 0, False: 0]
  ------------------
 4475|      0|                    if (!*buf_overflow &&
  ------------------
  |  Branch (4475:25): [True: 0, False: 0]
  ------------------
 4476|      0|                        !snmp_cstrcat(buf, buf_len, out_len, allow_realloc,
  ------------------
  |  Branch (4476:25): [True: 0, False: 0]
  ------------------
 4477|      0|                                      ep->label)) {
 4478|      0|                        *buf_overflow = 1;
 4479|      0|                    }
 4480|      0|                } else {
 4481|      0|                    sprintf(intbuf, "%" NETSNMP_PRIo "u", *objid);
 4482|      0|                    if (!*buf_overflow &&
  ------------------
  |  Branch (4482:25): [True: 0, False: 0]
  ------------------
 4483|      0|                        !snmp_cstrcat(buf, buf_len, out_len, allow_realloc,
  ------------------
  |  Branch (4483:25): [True: 0, False: 0]
  ------------------
 4484|      0|                                      intbuf)) {
 4485|      0|                        *buf_overflow = 1;
 4486|      0|                    }
 4487|      0|                }
 4488|      0|            } else {
 4489|      0|                sprintf(intbuf, "%" NETSNMP_PRIo "u", *objid);
 4490|      0|                if (!*buf_overflow &&
  ------------------
  |  Branch (4490:21): [True: 0, False: 0]
  ------------------
 4491|      0|                    !snmp_cstrcat(buf, buf_len, out_len, allow_realloc,
  ------------------
  |  Branch (4491:21): [True: 0, False: 0]
  ------------------
 4492|      0|                                  intbuf)) {
 4493|      0|                    *buf_overflow = 1;
 4494|      0|                }
 4495|      0|            }
 4496|      0|            objid++;
 4497|      0|            objidlen--;
 4498|      0|            break;
 4499|       |
 4500|      0|        case TYPE_TIMETICKS:
  ------------------
  |  |  162|      0|#define TYPE_TIMETICKS      8
  ------------------
  |  Branch (4500:9): [True: 0, False: 0]
  ------------------
 4501|       |            /* In an index, this is probably a timefilter */
 4502|      0|            if (extended_index) {
  ------------------
  |  Branch (4502:17): [True: 0, False: 0]
  ------------------
 4503|      0|                uptimeString( *objid, intbuf, sizeof( intbuf ) );
 4504|      0|            } else {
 4505|      0|                sprintf(intbuf, "%" NETSNMP_PRIo "u", *objid);
 4506|      0|            }   
 4507|      0|            if (!*buf_overflow &&
  ------------------
  |  Branch (4507:17): [True: 0, False: 0]
  ------------------
 4508|      0|                !snmp_cstrcat(buf, buf_len, out_len, allow_realloc, intbuf)) {
  ------------------
  |  Branch (4508:17): [True: 0, False: 0]
  ------------------
 4509|      0|                *buf_overflow = 1;
 4510|      0|            }
 4511|      0|            objid++;
 4512|      0|            objidlen--;
 4513|      0|            break;
 4514|       |
 4515|      0|        case TYPE_OBJID:
  ------------------
  |  |  155|      0|#define TYPE_OBJID          1
  ------------------
  |  Branch (4515:9): [True: 0, False: 0]
  ------------------
 4516|      0|            if (in_dices->isimplied) {
  ------------------
  |  Branch (4516:17): [True: 0, False: 0]
  ------------------
 4517|      0|                numids = objidlen;
 4518|      0|            } else {
 4519|      0|                numids = (size_t) * objid + 1;
 4520|      0|            }
 4521|      0|            if (numids > objidlen)
  ------------------
  |  Branch (4521:17): [True: 0, False: 0]
  ------------------
 4522|      0|                goto finish_it;
 4523|      0|            if (extended_index) {
  ------------------
  |  Branch (4523:17): [True: 0, False: 0]
  ------------------
 4524|      0|                if (in_dices->isimplied) {
  ------------------
  |  Branch (4524:21): [True: 0, False: 0]
  ------------------
 4525|      0|                    if (!*buf_overflow
  ------------------
  |  Branch (4525:25): [True: 0, False: 0]
  ------------------
 4526|      0|                        && !netsnmp_sprint_realloc_objid_tree(buf, buf_len,
  ------------------
  |  Branch (4526:28): [True: 0, False: 0]
  ------------------
 4527|      0|                                                              out_len,
 4528|      0|                                                              allow_realloc,
 4529|      0|                                                              buf_overflow,
 4530|      0|                                                              objid,
 4531|      0|                                                              numids)) {
 4532|      0|                        *buf_overflow = 1;
 4533|      0|                    }
 4534|      0|                } else {
 4535|      0|                    if (!*buf_overflow
  ------------------
  |  Branch (4535:25): [True: 0, False: 0]
  ------------------
 4536|      0|                        && !netsnmp_sprint_realloc_objid_tree(buf, buf_len,
  ------------------
  |  Branch (4536:28): [True: 0, False: 0]
  ------------------
 4537|      0|                                                              out_len,
 4538|      0|                                                              allow_realloc,
 4539|      0|                                                              buf_overflow,
 4540|      0|                                                              objid + 1,
 4541|      0|                                                              numids -
 4542|      0|                                                              1)) {
 4543|      0|                        *buf_overflow = 1;
 4544|      0|                    }
 4545|      0|                }
 4546|      0|            } else {
 4547|      0|                _get_realloc_symbol(objid, numids, NULL, buf, buf_len,
 4548|      0|                                    out_len, allow_realloc, buf_overflow,
 4549|      0|                                    NULL, NULL);
 4550|      0|            }
 4551|      0|            objid += (numids);
 4552|      0|            objidlen -= (numids);
 4553|      0|            break;
 4554|       |
 4555|      0|        case TYPE_IPADDR:
  ------------------
  |  |  159|      0|#define TYPE_IPADDR         5
  ------------------
  |  Branch (4555:9): [True: 0, False: 0]
  ------------------
 4556|      0|            if (objidlen < 4)
  ------------------
  |  Branch (4556:17): [True: 0, False: 0]
  ------------------
 4557|      0|                goto finish_it;
 4558|      0|            sprintf(intbuf, "%" NETSNMP_PRIo "u.%" NETSNMP_PRIo "u."
 4559|      0|                    "%" NETSNMP_PRIo "u.%" NETSNMP_PRIo "u",
 4560|      0|                    objid[0], objid[1], objid[2], objid[3]);
 4561|      0|            objid += 4;
 4562|      0|            objidlen -= 4;
 4563|      0|            if (!*buf_overflow &&
  ------------------
  |  Branch (4563:17): [True: 0, False: 0]
  ------------------
 4564|      0|                !snmp_cstrcat(buf, buf_len, out_len, allow_realloc, intbuf)) {
  ------------------
  |  Branch (4564:17): [True: 0, False: 0]
  ------------------
 4565|      0|                *buf_overflow = 1;
 4566|      0|            }
 4567|      0|            break;
 4568|       |
 4569|      0|        case TYPE_NETADDR:{
  ------------------
  |  |  158|      0|#define TYPE_NETADDR        4
  ------------------
  |  Branch (4569:9): [True: 0, False: 0]
  ------------------
 4570|      0|                oid             ntype = *objid++;
 4571|       |
 4572|      0|                objidlen--;
 4573|      0|                sprintf(intbuf, "%" NETSNMP_PRIo "u.", ntype);
 4574|      0|                if (!*buf_overflow &&
  ------------------
  |  Branch (4574:21): [True: 0, False: 0]
  ------------------
 4575|      0|                    !snmp_cstrcat(buf, buf_len, out_len, allow_realloc,
  ------------------
  |  Branch (4575:21): [True: 0, False: 0]
  ------------------
 4576|      0|                                  intbuf)) {
 4577|      0|                    *buf_overflow = 1;
 4578|      0|                }
 4579|       |
 4580|      0|                if (ntype == 1 && objidlen >= 4) {
  ------------------
  |  Branch (4580:21): [True: 0, False: 0]
  |  Branch (4580:35): [True: 0, False: 0]
  ------------------
 4581|      0|                    sprintf(intbuf, "%" NETSNMP_PRIo "u.%" NETSNMP_PRIo "u."
 4582|      0|                            "%" NETSNMP_PRIo "u.%" NETSNMP_PRIo "u",
 4583|      0|                            objid[0], objid[1], objid[2], objid[3]);
 4584|      0|                    if (!*buf_overflow &&
  ------------------
  |  Branch (4584:25): [True: 0, False: 0]
  ------------------
 4585|      0|                        !snmp_cstrcat(buf, buf_len, out_len, allow_realloc,
  ------------------
  |  Branch (4585:25): [True: 0, False: 0]
  ------------------
 4586|      0|                                      intbuf)) {
 4587|      0|                        *buf_overflow = 1;
 4588|      0|                    }
 4589|      0|                    objid += 4;
 4590|      0|                    objidlen -= 4;
 4591|      0|                } else {
 4592|      0|                    goto finish_it;
 4593|      0|                }
 4594|      0|            }
 4595|      0|            break;
 4596|       |
 4597|      0|        case TYPE_NSAPADDRESS:
  ------------------
  |  |  167|      0|#define TYPE_NSAPADDRESS    13
  ------------------
  |  Branch (4597:9): [True: 0, False: 0]
  ------------------
 4598|      0|        default:
  ------------------
  |  Branch (4598:9): [True: 0, False: 0]
  ------------------
 4599|      0|            goto finish_it;
 4600|      0|            break;
 4601|      0|        }
 4602|       |
 4603|      0|        if (extended_index) {
  ------------------
  |  Branch (4603:13): [True: 0, False: 0]
  ------------------
 4604|      0|            if (!*buf_overflow &&
  ------------------
  |  Branch (4604:17): [True: 0, False: 0]
  ------------------
 4605|      0|                !snmp_cstrcat(buf, buf_len, out_len, allow_realloc, "]")) {
  ------------------
  |  Branch (4605:17): [True: 0, False: 0]
  ------------------
 4606|      0|                *buf_overflow = 1;
 4607|      0|            }
 4608|      0|        } else {
 4609|      0|            if (!*buf_overflow &&
  ------------------
  |  Branch (4609:17): [True: 0, False: 0]
  ------------------
 4610|      0|                !snmp_cstrcat(buf, buf_len, out_len, allow_realloc, ".")) {
  ------------------
  |  Branch (4610:17): [True: 0, False: 0]
  ------------------
 4611|      0|                *buf_overflow = 1;
 4612|      0|            }
 4613|      0|        }
 4614|      0|        in_dices = in_dices->next;
 4615|      0|    }
 4616|       |
 4617|  2.60k|  finish_it:
 4618|  2.60k|    _oid_finish_printing(objid, objidlen,
 4619|  2.60k|                         buf, buf_len, out_len,
 4620|  2.60k|                         allow_realloc, buf_overflow);
 4621|       |    return NULL;
 4622|  2.60k|}

netsnmp_init_mib_internals:
  700|     51|{
  701|     51|    register struct tok *tp;
  702|     51|    register int    b, i;
  703|     51|    int             max_modc;
  704|       |
  705|     51|    if (tree_head)
  ------------------
  |  Branch (705:9): [True: 50, False: 1]
  ------------------
  706|     50|        return;
  707|       |
  708|       |    /*
  709|       |     * Set up hash list of pre-defined tokens
  710|       |     */
  711|      1|    memset(buckets, 0, sizeof(buckets));
  712|     93|    for (tp = tokens; tp->name; tp++) {
  ------------------
  |  Branch (712:23): [True: 92, False: 1]
  ------------------
  713|     92|        tp->hash = name_hash(tp->name);
  714|     92|        b = BUCKET(tp->hash);
  ------------------
  |  |  527|     92|#define BUCKET(x)       (x & (HASHSIZE-1))
  |  |  ------------------
  |  |  |  |  526|     92|#define HASHSIZE        32
  |  |  ------------------
  ------------------
  715|     92|        if (buckets[b])
  ------------------
  |  Branch (715:13): [True: 60, False: 32]
  ------------------
  716|     60|            tp->next = buckets[b];      /* BUG ??? */
  717|     92|        buckets[b] = tp;
  718|     92|    }
  719|       |
  720|       |    /*
  721|       |     * Initialise other internal structures
  722|       |     */
  723|       |
  724|      1|    max_modc = sizeof(module_map) / sizeof(module_map[0]) - 1;
  725|     22|    for (i = 0; i < max_modc; ++i)
  ------------------
  |  Branch (725:17): [True: 21, False: 1]
  ------------------
  726|     21|        module_map[i].next = &(module_map[i + 1]);
  727|      1|    module_map[max_modc].next = NULL;
  728|      1|    module_map_head = module_map;
  729|       |
  730|      1|    memset(nbuckets, 0, sizeof(nbuckets));
  731|      1|    memset(tbuckets, 0, sizeof(tbuckets));
  732|      1|    free(tclist);
  733|      1|    tc_alloc = TC_INCR;
  ------------------
  |  |  134|      1|#define TC_INCR 100
  ------------------
  734|      1|    tclist = calloc(tc_alloc, sizeof(struct tc));
  735|      1|    build_translation_table();
  736|      1|    init_tree_roots();          /* Set up initial roots */
  737|       |    /*
  738|       |     * Relies on 'add_mibdir' having set up the modules 
  739|       |     */
  740|      1|}
which_module:
 3835|      3|{
 3836|      3|    struct module  *mp;
 3837|       |
 3838|      3|    for (mp = module_head; mp; mp = mp->next)
  ------------------
  |  Branch (3838:28): [True: 0, False: 3]
  ------------------
 3839|      0|        if (!label_compare(mp->name, name))
  ------------------
  |  | 1236|      0|#define	label_compare	strcmp
  ------------------
  |  Branch (3839:13): [True: 0, False: 0]
  ------------------
 3840|      0|            return (mp->modid);
 3841|       |
 3842|      3|    DEBUGMSGTL(("parse-mibs", "Module %s not found\n", name));
  ------------------
  |  |   66|      3|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      3|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 3]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 3]
  |  |  ------------------
  ------------------
 3843|      3|    return (-1);
 3844|      3|}
module_name:
 3851|  2.66k|{
 3852|  2.66k|    struct module  *mp;
 3853|       |
 3854|  2.66k|    for (mp = module_head; mp; mp = mp->next)
  ------------------
  |  Branch (3854:28): [True: 0, False: 2.66k]
  ------------------
 3855|      0|        if (mp->modid == modid) {
  ------------------
  |  Branch (3855:13): [True: 0, False: 0]
  ------------------
 3856|      0|            strcpy(cp, mp->name);
 3857|      0|            return (cp);
 3858|      0|        }
 3859|       |
 3860|  2.66k|    if (modid != -1) DEBUGMSGTL(("parse-mibs", "Module %d not found\n", modid));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (3860:9): [True: 0, False: 2.66k]
  ------------------
 3861|  2.66k|    sprintf(cp, "#%d", modid);
 3862|  2.66k|    return (cp);
 3863|  2.66k|}
adopt_orphans:
 4033|      1|{
 4034|      1|    struct node    *np = NULL, *onp;
 4035|      1|    struct tree    *tp;
 4036|      1|    int             i, adopted = 1;
 4037|       |
 4038|      1|    if (!orphan_nodes)
  ------------------
  |  Branch (4038:9): [True: 1, False: 0]
  ------------------
 4039|      1|        return;
 4040|      0|    init_node_hash(orphan_nodes);
 4041|      0|    orphan_nodes = NULL;
 4042|       |
 4043|      0|    while (adopted) {
  ------------------
  |  Branch (4043:12): [True: 0, False: 0]
  ------------------
 4044|      0|        adopted = 0;
 4045|      0|        for (i = 0; i < NHASHSIZE; i++)
  ------------------
  |  |  529|      0|#define NHASHSIZE    128
  ------------------
  |  Branch (4045:21): [True: 0, False: 0]
  ------------------
 4046|      0|            if (nbuckets[i]) {
  ------------------
  |  Branch (4046:17): [True: 0, False: 0]
  ------------------
 4047|      0|                for (np = nbuckets[i]; np != NULL; np = np->next) {
  ------------------
  |  Branch (4047:40): [True: 0, False: 0]
  ------------------
 4048|      0|                    tp = find_tree_node(np->parent, -1);
 4049|      0|		    if (tp) {
  ------------------
  |  Branch (4049:11): [True: 0, False: 0]
  ------------------
 4050|      0|			do_subtree(tp, &np);
 4051|      0|			adopted = 1;
 4052|       |                        /*
 4053|       |                         * if do_subtree adopted the entire bucket, stop
 4054|       |                         */
 4055|      0|                        if(NULL == nbuckets[i])
  ------------------
  |  Branch (4055:28): [True: 0, False: 0]
  ------------------
 4056|      0|                            break;
 4057|       |
 4058|       |                        /*
 4059|       |                         * do_subtree may modify nbuckets, and if np
 4060|       |                         * was adopted, np->next probably isn't an orphan
 4061|       |                         * anymore. if np is still in the bucket (do_subtree
 4062|       |                         * didn't adopt it) keep on plugging. otherwise
 4063|       |                         * start over, at the top of the bucket.
 4064|       |                         */
 4065|      0|                        for(onp = nbuckets[i]; onp; onp = onp->next)
  ------------------
  |  Branch (4065:48): [True: 0, False: 0]
  ------------------
 4066|      0|                            if(onp == np)
  ------------------
  |  Branch (4066:32): [True: 0, False: 0]
  ------------------
 4067|      0|                                break;
 4068|      0|                        if(NULL == onp) { /* not in the list */
  ------------------
  |  Branch (4068:28): [True: 0, False: 0]
  ------------------
 4069|      0|                            np = nbuckets[i]; /* start over */
 4070|      0|                        }
 4071|      0|		    }
 4072|      0|		}
 4073|      0|            }
 4074|      0|    }
 4075|       |
 4076|       |    /*
 4077|       |     * Report on outstanding orphans
 4078|       |     *    and link them back into the orphan list
 4079|       |     */
 4080|      0|    for (i = 0; i < NHASHSIZE; i++)
  ------------------
  |  |  529|      0|#define NHASHSIZE    128
  ------------------
  |  Branch (4080:17): [True: 0, False: 0]
  ------------------
 4081|      0|        if (nbuckets[i]) {
  ------------------
  |  Branch (4081:13): [True: 0, False: 0]
  ------------------
 4082|      0|            if (orphan_nodes)
  ------------------
  |  Branch (4082:17): [True: 0, False: 0]
  ------------------
 4083|      0|                onp = np->next = nbuckets[i];
 4084|      0|            else
 4085|      0|                onp = orphan_nodes = nbuckets[i];
 4086|      0|            nbuckets[i] = NULL;
 4087|      0|            while (onp) {
  ------------------
  |  Branch (4087:20): [True: 0, False: 0]
  ------------------
 4088|      0|                char            modbuf[256];
 4089|      0|                snmp_log(LOG_WARNING,
 4090|      0|                         "Cannot resolve OID in %s: %s ::= { %s %ld } at line %d in %s\n",
 4091|      0|                         module_name(onp->modid, modbuf),
 4092|      0|                         (onp->label ? onp->label : "<no label>"),
  ------------------
  |  Branch (4092:27): [True: 0, False: 0]
  ------------------
 4093|      0|                         (onp->parent ? onp->parent : "<no parent>"),
  ------------------
  |  Branch (4093:27): [True: 0, False: 0]
  ------------------
 4094|      0|                         onp->subid, onp->lineno, onp->filename);
 4095|      0|                np = onp;
 4096|      0|                onp = onp->next;
 4097|      0|            }
 4098|      0|        }
 4099|      0|}
netsnmp_read_module:
 4111|     48|{
 4112|     48|    int status = 0;
 4113|     48|    status = read_module_internal(name);
 4114|       |
 4115|     48|    if (status == MODULE_NOT_FOUND) {
  ------------------
  |  |  513|     48|#define MODULE_NOT_FOUND	0
  ------------------
  |  Branch (4115:9): [True: 48, False: 0]
  ------------------
 4116|     48|        if (!read_module_replacements(name))
  ------------------
  |  Branch (4116:13): [True: 48, False: 0]
  ------------------
 4117|     48|            print_module_not_found(name);
 4118|     48|    } else if (status == MODULE_SYNTAX_ERROR) {
  ------------------
  |  |  520|      0|#define MODULE_SYNTAX_ERROR     4
  ------------------
  |  Branch (4118:16): [True: 0, False: 0]
  ------------------
 4119|      0|        gMibError = 0;
 4120|      0|        gLoop = 1;
 4121|       |
 4122|      0|        strncat(gMibNames, " ", sizeof(gMibNames) - strlen(gMibNames) - 1);
 4123|      0|        strncat(gMibNames, name, sizeof(gMibNames) - strlen(gMibNames) - 1);
 4124|      0|    }
 4125|       |
 4126|     48|    return tree_head;
 4127|     48|}
add_mibdir:
 5124|      2|{
 5125|      2|    const char     *oldFile = File;
 5126|      2|    int             oldLine = mibLine;
 5127|      2|    char          **filenames;
 5128|      2|    int             count = 0;
 5129|      2|    int             filename_count, i;
 5130|       |
 5131|      2|    DEBUGMSGTL(("parse-mibs", "Scanning directory %s\n", dirname));
  ------------------
  |  |   66|      2|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      2|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 2, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      2|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      2|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      2|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      2|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 2]
  |  |  ------------------
  ------------------
 5132|       |
 5133|      2|    filename_count = scan_directory(&filenames, dirname);
 5134|       |
 5135|      2|    if (filename_count >= 0) {
  ------------------
  |  Branch (5135:9): [True: 0, False: 2]
  ------------------
 5136|      0|        for (i = 0; i < filename_count; i++) {
  ------------------
  |  Branch (5136:21): [True: 0, False: 0]
  ------------------
 5137|      0|            if (add_mibfile(filenames[i], strrchr(filenames[i], '/')) == 0)
  ------------------
  |  Branch (5137:17): [True: 0, False: 0]
  ------------------
 5138|      0|                count++;
 5139|      0|	    free(filenames[i]);
 5140|      0|        }
 5141|      0|        File = oldFile;
 5142|      0|        mibLine = oldLine;
 5143|      0|        free(filenames);
 5144|      0|        return (count);
 5145|      0|    }
 5146|      2|    else
 5147|      2|        DEBUGMSGTL(("parse-mibs","cannot open MIB directory %s\n", dirname));
  ------------------
  |  |   66|      2|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      2|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 2, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      2|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      2|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      2|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      2|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 2]
  |  |  ------------------
  ------------------
 5148|       |
 5149|      2|    return (-1);
 5150|      2|}
parse.c:name_hash:
  687|     95|{
  688|     95|    int             hash = 0;
  689|     95|    const char     *cp;
  690|       |
  691|     95|    if (!name)
  ------------------
  |  Branch (691:9): [True: 0, False: 95]
  ------------------
  692|      0|        return 0;
  693|  1.00k|    for (cp = name; *cp; cp++)
  ------------------
  |  Branch (693:21): [True: 907, False: 95]
  ------------------
  694|    907|        hash += tolower((unsigned char)(*cp));
  ------------------
  |  Branch (694:17): [True: 0, False: 0]
  |  Branch (694:17): [True: 0, False: 0]
  |  Branch (694:17): [Folded, False: 907]
  ------------------
  695|     95|    return (hash);
  696|     95|}
parse.c:build_translation_table:
 1071|      1|{
 1072|      1|    int             count;
 1073|       |
 1074|    257|    for (count = 0; count < 256; count++) {
  ------------------
  |  Branch (1074:21): [True: 256, False: 1]
  ------------------
 1075|    256|        switch (count) {
 1076|      1|        case OBJID:
  ------------------
  |  |  167|      1|#define OBJID       (4 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|      1|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1076:9): [True: 1, False: 255]
  ------------------
 1077|      1|            translation_table[count] = TYPE_OBJID;
  ------------------
  |  |  155|      1|#define TYPE_OBJID          1
  ------------------
 1078|      1|            break;
 1079|      1|        case OCTETSTR:
  ------------------
  |  |  168|      1|#define OCTETSTR    (5 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|      1|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1079:9): [True: 1, False: 255]
  ------------------
 1080|      1|            translation_table[count] = TYPE_OCTETSTR;
  ------------------
  |  |  156|      1|#define TYPE_OCTETSTR       2
  ------------------
 1081|      1|            break;
 1082|      1|        case INTEGER:
  ------------------
  |  |  169|      1|#define INTEGER     (6 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|      1|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1082:9): [True: 1, False: 255]
  ------------------
 1083|      1|            translation_table[count] = TYPE_INTEGER;
  ------------------
  |  |  157|      1|#define TYPE_INTEGER        3
  ------------------
 1084|      1|            break;
 1085|      1|        case NETADDR:
  ------------------
  |  |  170|      1|#define NETADDR     (7 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|      1|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1085:9): [True: 1, False: 255]
  ------------------
 1086|      1|            translation_table[count] = TYPE_NETADDR;
  ------------------
  |  |  158|      1|#define TYPE_NETADDR        4
  ------------------
 1087|      1|            break;
 1088|      1|        case IPADDR:
  ------------------
  |  |  171|      1|#define IPADDR      (8 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|      1|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1088:9): [True: 1, False: 255]
  ------------------
 1089|      1|            translation_table[count] = TYPE_IPADDR;
  ------------------
  |  |  159|      1|#define TYPE_IPADDR         5
  ------------------
 1090|      1|            break;
 1091|      1|        case COUNTER:
  ------------------
  |  |  172|      1|#define COUNTER     (9 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|      1|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1091:9): [True: 1, False: 255]
  ------------------
 1092|      1|            translation_table[count] = TYPE_COUNTER;
  ------------------
  |  |  160|      1|#define TYPE_COUNTER        6
  ------------------
 1093|      1|            break;
 1094|      1|        case GAUGE:
  ------------------
  |  |  173|      1|#define GAUGE       (10 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|      1|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1094:9): [True: 1, False: 255]
  ------------------
 1095|      1|            translation_table[count] = TYPE_GAUGE;
  ------------------
  |  |  161|      1|#define TYPE_GAUGE          7
  ------------------
 1096|      1|            break;
 1097|      1|        case TIMETICKS:
  ------------------
  |  |  174|      1|#define TIMETICKS   (11 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|      1|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1097:9): [True: 1, False: 255]
  ------------------
 1098|      1|            translation_table[count] = TYPE_TIMETICKS;
  ------------------
  |  |  162|      1|#define TYPE_TIMETICKS      8
  ------------------
 1099|      1|            break;
 1100|      1|        case KW_OPAQUE:
  ------------------
  |  |  175|      1|#define KW_OPAQUE   (12 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|      1|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1100:9): [True: 1, False: 255]
  ------------------
 1101|      1|            translation_table[count] = TYPE_OPAQUE;
  ------------------
  |  |  163|      1|#define TYPE_OPAQUE         9
  ------------------
 1102|      1|            break;
 1103|      1|        case NUL:
  ------------------
  |  |  176|      1|#define NUL         (13 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|      1|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1103:9): [True: 1, False: 255]
  ------------------
 1104|      1|            translation_table[count] = TYPE_NULL;
  ------------------
  |  |  164|      1|#define TYPE_NULL           10
  ------------------
 1105|      1|            break;
 1106|      1|        case COUNTER64:
  ------------------
  |  |  211|      1|#define COUNTER64   (43 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|      1|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1106:9): [True: 1, False: 255]
  ------------------
 1107|      1|            translation_table[count] = TYPE_COUNTER64;
  ------------------
  |  |  165|      1|#define TYPE_COUNTER64      11
  ------------------
 1108|      1|            break;
 1109|      1|        case BITSTRING:
  ------------------
  |  |  209|      1|#define BITSTRING   (41 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|      1|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1109:9): [True: 1, False: 255]
  ------------------
 1110|      1|            translation_table[count] = TYPE_BITSTRING;
  ------------------
  |  |  166|      1|#define TYPE_BITSTRING      12
  ------------------
 1111|      1|            break;
 1112|      1|        case NSAPADDRESS:
  ------------------
  |  |  210|      1|#define NSAPADDRESS (42 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|      1|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1112:9): [True: 1, False: 255]
  ------------------
 1113|      1|            translation_table[count] = TYPE_NSAPADDRESS;
  ------------------
  |  |  167|      1|#define TYPE_NSAPADDRESS    13
  ------------------
 1114|      1|            break;
 1115|      1|        case INTEGER32:
  ------------------
  |  |  274|      1|#define INTEGER32	(105 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|      1|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1115:9): [True: 1, False: 255]
  ------------------
 1116|      1|            translation_table[count] = TYPE_INTEGER32;
  ------------------
  |  |  170|      1|#define TYPE_INTEGER32      16
  ------------------
 1117|      1|            break;
 1118|      1|        case UINTEGER32:
  ------------------
  |  |  224|      1|#define UINTEGER32 (56 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|      1|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1118:9): [True: 1, False: 255]
  ------------------
 1119|      1|            translation_table[count] = TYPE_UINTEGER;
  ------------------
  |  |  168|      1|#define TYPE_UINTEGER       14
  ------------------
 1120|      1|            break;
 1121|      1|        case UNSIGNED32:
  ------------------
  |  |  273|      1|#define UNSIGNED32	(104 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|      1|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1121:9): [True: 1, False: 255]
  ------------------
 1122|      1|            translation_table[count] = TYPE_UNSIGNED32;
  ------------------
  |  |  169|      1|#define TYPE_UNSIGNED32     15
  ------------------
 1123|      1|            break;
 1124|      1|        case TRAPTYPE:
  ------------------
  |  |  229|      1|#define TRAPTYPE    61
  ------------------
  |  Branch (1124:9): [True: 1, False: 255]
  ------------------
 1125|      1|            translation_table[count] = TYPE_TRAPTYPE;
  ------------------
  |  |  174|      1|#define TYPE_TRAPTYPE	    20
  ------------------
 1126|      1|            break;
 1127|      1|        case NOTIFTYPE:
  ------------------
  |  |  213|      1|#define NOTIFTYPE   45
  ------------------
  |  Branch (1127:9): [True: 1, False: 255]
  ------------------
 1128|      1|            translation_table[count] = TYPE_NOTIFTYPE;
  ------------------
  |  |  175|      1|#define TYPE_NOTIFTYPE      21
  ------------------
 1129|      1|            break;
 1130|      1|        case NOTIFGROUP:
  ------------------
  |  |  258|      1|#define NOTIFGROUP  88
  ------------------
  |  Branch (1130:9): [True: 1, False: 255]
  ------------------
 1131|      1|            translation_table[count] = TYPE_NOTIFGROUP;
  ------------------
  |  |  177|      1|#define TYPE_NOTIFGROUP	    23
  ------------------
 1132|      1|            break;
 1133|      1|        case OBJGROUP:
  ------------------
  |  |  212|      1|#define OBJGROUP    44
  ------------------
  |  Branch (1133:9): [True: 1, False: 255]
  ------------------
 1134|      1|            translation_table[count] = TYPE_OBJGROUP;
  ------------------
  |  |  176|      1|#define TYPE_OBJGROUP	    22
  ------------------
 1135|      1|            break;
 1136|      1|        case MODULEIDENTITY:
  ------------------
  |  |  220|      1|#define MODULEIDENTITY 52
  ------------------
  |  Branch (1136:9): [True: 1, False: 255]
  ------------------
 1137|      1|            translation_table[count] = TYPE_MODID;
  ------------------
  |  |  178|      1|#define TYPE_MODID	    24
  ------------------
 1138|      1|            break;
 1139|      1|        case OBJIDENTITY:
  ------------------
  |  |  275|      1|#define OBJIDENTITY	106
  ------------------
  |  Branch (1139:9): [True: 1, False: 255]
  ------------------
 1140|      1|            translation_table[count] = TYPE_OBJIDENTITY;
  ------------------
  |  |  181|      1|#define TYPE_OBJIDENTITY    27
  ------------------
 1141|      1|            break;
 1142|      1|        case AGENTCAP:
  ------------------
  |  |  243|      1|#define AGENTCAP    73
  ------------------
  |  Branch (1142:9): [True: 1, False: 255]
  ------------------
 1143|      1|            translation_table[count] = TYPE_AGENTCAP;
  ------------------
  |  |  179|      1|#define TYPE_AGENTCAP       25
  ------------------
 1144|      1|            break;
 1145|      1|        case COMPLIANCE:
  ------------------
  |  |  215|      1|#define COMPLIANCE  47
  ------------------
  |  Branch (1145:9): [True: 1, False: 255]
  ------------------
 1146|      1|            translation_table[count] = TYPE_MODCOMP;
  ------------------
  |  |  180|      1|#define TYPE_MODCOMP        26
  ------------------
 1147|      1|            break;
 1148|    232|        default:
  ------------------
  |  Branch (1148:9): [True: 232, False: 24]
  ------------------
 1149|    232|            translation_table[count] = TYPE_OTHER;
  ------------------
  |  |  154|    232|#define TYPE_OTHER          0
  ------------------
 1150|    232|            break;
 1151|    256|        }
 1152|    256|    }
 1153|      1|}
parse.c:init_tree_roots:
 1157|      1|{
 1158|      1|    struct tree    *tp, *lasttp;
 1159|      1|    int             base_modid;
 1160|      1|    int             hash;
 1161|       |
 1162|      1|    base_modid = which_module("SNMPv2-SMI");
 1163|      1|    if (base_modid == -1)
  ------------------
  |  Branch (1163:9): [True: 1, False: 0]
  ------------------
 1164|      1|        base_modid = which_module("RFC1155-SMI");
 1165|      1|    if (base_modid == -1)
  ------------------
  |  Branch (1165:9): [True: 1, False: 0]
  ------------------
 1166|      1|        base_modid = which_module("RFC1213-MIB");
 1167|       |
 1168|       |    /*
 1169|       |     * build root node 
 1170|       |     */
 1171|      1|    tp = calloc(1, sizeof(struct tree));
 1172|      1|    if (tp == NULL)
  ------------------
  |  Branch (1172:9): [True: 0, False: 1]
  ------------------
 1173|      0|        return;
 1174|      1|    tp->label = strdup("joint-iso-ccitt");
 1175|      1|    tp->modid = base_modid;
 1176|      1|    tp->number_modules = 1;
 1177|      1|    tp->module_list = &(tp->modid);
 1178|      1|    tp->subid = 2;
 1179|      1|    tp->tc_index = -1;
 1180|      1|    set_function(tp);           /* from mib.c */
 1181|      1|    hash = NBUCKET(name_hash(tp->label));
  ------------------
  |  |  530|      1|#define NBUCKET(x)   (x & (NHASHSIZE-1))
  |  |  ------------------
  |  |  |  |  529|      1|#define NHASHSIZE    128
  |  |  ------------------
  ------------------
 1182|      1|    tp->next = tbuckets[hash];
 1183|      1|    tbuckets[hash] = tp;
 1184|      1|    lasttp = tp;
 1185|      1|    root_imports[0].label = strdup(tp->label);
 1186|      1|    root_imports[0].modid = base_modid;
 1187|       |
 1188|       |    /*
 1189|       |     * build root node 
 1190|       |     */
 1191|      1|    tp = calloc(1, sizeof(struct tree));
 1192|      1|    if (tp == NULL)
  ------------------
  |  Branch (1192:9): [True: 0, False: 1]
  ------------------
 1193|      0|        return;
 1194|      1|    tp->next_peer = lasttp;
 1195|      1|    tp->label = strdup("ccitt");
 1196|      1|    tp->modid = base_modid;
 1197|      1|    tp->number_modules = 1;
 1198|      1|    tp->module_list = &(tp->modid);
 1199|      1|    tp->subid = 0;
 1200|      1|    tp->tc_index = -1;
 1201|      1|    set_function(tp);           /* from mib.c */
 1202|      1|    hash = NBUCKET(name_hash(tp->label));
  ------------------
  |  |  530|      1|#define NBUCKET(x)   (x & (NHASHSIZE-1))
  |  |  ------------------
  |  |  |  |  529|      1|#define NHASHSIZE    128
  |  |  ------------------
  ------------------
 1203|      1|    tp->next = tbuckets[hash];
 1204|      1|    tbuckets[hash] = tp;
 1205|      1|    lasttp = tp;
 1206|      1|    root_imports[1].label = strdup(tp->label);
 1207|      1|    root_imports[1].modid = base_modid;
 1208|       |
 1209|       |    /*
 1210|       |     * build root node 
 1211|       |     */
 1212|      1|    tp = calloc(1, sizeof(struct tree));
 1213|      1|    if (tp == NULL)
  ------------------
  |  Branch (1213:9): [True: 0, False: 1]
  ------------------
 1214|      0|        return;
 1215|      1|    tp->next_peer = lasttp;
 1216|      1|    tp->label = strdup("iso");
 1217|      1|    tp->modid = base_modid;
 1218|      1|    tp->number_modules = 1;
 1219|      1|    tp->module_list = &(tp->modid);
 1220|      1|    tp->subid = 1;
 1221|      1|    tp->tc_index = -1;
 1222|      1|    set_function(tp);           /* from mib.c */
 1223|      1|    hash = NBUCKET(name_hash(tp->label));
  ------------------
  |  |  530|      1|#define NBUCKET(x)   (x & (NHASHSIZE-1))
  |  |  ------------------
  |  |  |  |  529|      1|#define NHASHSIZE    128
  |  |  ------------------
  ------------------
 1224|      1|    tp->next = tbuckets[hash];
 1225|      1|    tbuckets[hash] = tp;
 1226|      1|    lasttp = tp;
 1227|      1|    root_imports[2].label = strdup(tp->label);
 1228|      1|    root_imports[2].modid = base_modid;
 1229|       |
 1230|      1|    tree_head = tp;
 1231|      1|}
parse.c:read_module_internal:
 4019|     48|{
 4020|     48|    struct module  *mp;
 4021|       |
 4022|     48|    netsnmp_init_mib_internals();
 4023|       |
 4024|     48|    for (mp = module_head; mp; mp = mp->next)
  ------------------
  |  Branch (4024:28): [True: 0, False: 48]
  ------------------
 4025|      0|        if (!label_compare(mp->name, name))
  ------------------
  |  | 1236|      0|#define	label_compare	strcmp
  ------------------
  |  Branch (4025:13): [True: 0, False: 0]
  ------------------
 4026|      0|            return read_from_file(mp, name);
 4027|       |
 4028|     48|    return MODULE_NOT_FOUND;
  ------------------
  |  |  513|     48|#define MODULE_NOT_FOUND	0
  ------------------
 4029|     48|}
parse.c:print_error:
  780|     48|{
  781|     48|    erroneousMibs++;
  782|     48|    if (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|     48|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (782:9): [True: 0, False: 48]
  ------------------
  783|     48|                                NETSNMP_DS_LIB_MIB_ERRORS))
  ------------------
  |  |   59|     48|#define NETSNMP_DS_LIB_MIB_ERRORS          0
  ------------------
  784|      0|	return;
  785|     48|    DEBUGMSGTL(("parse-mibs", "\n"));
  ------------------
  |  |   66|     48|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     48|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 48, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|     48|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|     48|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|     48|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|     48|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 48]
  |  |  ------------------
  ------------------
  786|     48|    if (type == ENDOFFILE)
  ------------------
  |  |  163|     48|#define ENDOFFILE   0
  ------------------
  |  Branch (786:9): [True: 0, False: 48]
  ------------------
  787|      0|        snmp_log(LOG_ERR, "%s (EOF): At line %d in %s\n", str, mibLine,
  788|      0|                 File);
  789|     48|    else if (token && *token)
  ------------------
  |  Branch (789:14): [True: 48, False: 0]
  |  Branch (789:23): [True: 48, False: 0]
  ------------------
  790|     48|        snmp_log(LOG_ERR, "%s (%s): At line %d in %s\n", str, token,
  791|     48|                 mibLine, File);
  792|      0|    else
  793|      0|        snmp_log(LOG_ERR, "%s: At line %d in %s\n", str, mibLine, File);
  794|     48|}
parse.c:read_module_replacements:
 3899|     48|{
 3900|     48|    struct module_compatability *mcp;
 3901|       |
 3902|  1.10k|    for (mcp = module_map_head; mcp; mcp = mcp->next) {
  ------------------
  |  Branch (3902:33): [True: 1.05k, False: 48]
  ------------------
 3903|  1.05k|        if (!label_compare(mcp->old_module, name)) {
  ------------------
  |  | 1236|  1.05k|#define	label_compare	strcmp
  ------------------
  |  Branch (3903:13): [True: 0, False: 1.05k]
  ------------------
 3904|      0|            if (netsnmp_ds_get_int(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|      0|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (3904:17): [True: 0, False: 0]
  ------------------
 3905|      0|				   NETSNMP_DS_LIB_MIB_WARNINGS)) {
  ------------------
  |  |  114|      0|#define NETSNMP_DS_LIB_MIB_WARNINGS         0
  ------------------
 3906|      0|                snmp_log(LOG_WARNING,
 3907|      0|                         "Loading replacement module %s for %s (%s)\n",
 3908|      0|                         mcp->new_module, name, File);
 3909|      0|	    }
 3910|      0|            (void) netsnmp_read_module(mcp->new_module);
 3911|      0|            return 1;
 3912|      0|        }
 3913|  1.05k|    }
 3914|     48|    return 0;
 3915|     48|}
parse.c:print_module_not_found:
  798|     48|{
  799|     48|    if (first_err_module) {
  ------------------
  |  Branch (799:9): [True: 1, False: 47]
  ------------------
  800|      1|        snmp_log(LOG_ERR, "MIB search path: %s\n",
  801|      1|                           netsnmp_get_mib_directory());
  802|      1|        first_err_module = 0;
  803|      1|    }
  804|     48|    if (!last_err_module || strcmp(cp, last_err_module))
  ------------------
  |  Branch (804:9): [True: 1, False: 47]
  |  Branch (804:29): [True: 47, False: 0]
  ------------------
  805|     48|        print_error("Cannot find module", cp, CONTINUE);
  ------------------
  |  |  162|     48|#define CONTINUE    -1
  ------------------
  806|     48|    if (last_err_module)
  ------------------
  |  Branch (806:9): [True: 47, False: 1]
  ------------------
  807|     47|        free(last_err_module);
  808|     48|    last_err_module = strdup(cp);
  809|     48|}
parse.c:scan_directory:
 5054|      2|{
 5055|      2|    DIR            *dir, *dir2;
 5056|      2|    struct dirent  *file;
 5057|      2|    char          **filenames = NULL;
 5058|      2|    int             fname_len, i, filename_count = 0, array_size = 0;
 5059|      2|    char           *tmpstr;
 5060|       |
 5061|      2|    *result = NULL;
 5062|       |
 5063|      2|    dir = opendir(dirname);
 5064|      2|    if (!dir)
  ------------------
  |  Branch (5064:9): [True: 2, False: 0]
  ------------------
 5065|      2|        return -1;
 5066|       |
 5067|      0|    while ((file = readdir(dir))) {
  ------------------
  |  Branch (5067:12): [True: 0, False: 0]
  ------------------
 5068|       |        /*
 5069|       |         * Only parse file names that don't begin with a '.'
 5070|       |         * Also skip files ending in '~', or starting/ending
 5071|       |         * with '#' which are typically editor backup files.
 5072|       |         */
 5073|      0|        fname_len = strlen(file->d_name);
 5074|      0|        if (fname_len > 0 && file->d_name[0] != '.'
  ------------------
  |  Branch (5074:13): [True: 0, False: 0]
  |  Branch (5074:30): [True: 0, False: 0]
  ------------------
 5075|      0|            && file->d_name[0] != '#'
  ------------------
  |  Branch (5075:16): [True: 0, False: 0]
  ------------------
 5076|      0|            && file->d_name[fname_len-1] != '#'
  ------------------
  |  Branch (5076:16): [True: 0, False: 0]
  ------------------
 5077|      0|            && file->d_name[fname_len-1] != '~') {
  ------------------
  |  Branch (5077:16): [True: 0, False: 0]
  ------------------
 5078|      0|            if (asprintf(&tmpstr, "%s/%s", dirname, file->d_name) < 0)
  ------------------
  |  Branch (5078:17): [True: 0, False: 0]
  ------------------
 5079|      0|                continue;
 5080|      0|            dir2 = opendir(tmpstr);
 5081|      0|            if (dir2) {
  ------------------
  |  Branch (5081:17): [True: 0, False: 0]
  ------------------
 5082|       |                /* file is a directory, don't read it */
 5083|      0|                closedir(dir2);
 5084|      0|            } else {
 5085|      0|                if (filename_count >= array_size) {
  ------------------
  |  Branch (5085:21): [True: 0, False: 0]
  ------------------
 5086|      0|                    char **new_filenames;
 5087|       |
 5088|      0|                    array_size = (array_size + 16) * 2;
 5089|      0|                    new_filenames = realloc(filenames,
 5090|      0|                                        array_size * sizeof(filenames[0]));
 5091|      0|                    if (!new_filenames) {
  ------------------
  |  Branch (5091:25): [True: 0, False: 0]
  ------------------
 5092|      0|                        free(tmpstr);
 5093|      0|                        for (i = 0; i < filename_count; i++)
  ------------------
  |  Branch (5093:37): [True: 0, False: 0]
  ------------------
 5094|      0|                            free(filenames[i]);
 5095|      0|                        free(filenames);
 5096|      0|                        closedir(dir);
 5097|      0|                        return -1;
 5098|      0|                    }
 5099|      0|                    filenames = new_filenames;
 5100|      0|                }
 5101|      0|                filenames[filename_count++] = tmpstr;
 5102|      0|                tmpstr = NULL;
 5103|      0|            }
 5104|      0|            free(tmpstr);
 5105|      0|        }
 5106|      0|    }
 5107|      0|    closedir(dir);
 5108|       |
 5109|      0|    if (filenames)
  ------------------
  |  Branch (5109:9): [True: 0, False: 0]
  ------------------
 5110|      0|        qsort(filenames, filename_count, sizeof(filenames[0]), elemcmp);
 5111|      0|    *result = filenames;
 5112|       |
 5113|      0|    return filename_count;
 5114|      0|}

register_prenetsnmp_mib_handler:
  256|     35|{
  257|     35|    return internal_register_config_handler(type, token, parser, NULL, releaser,
  258|     35|					    help, PREMIB_CONFIG);
  ------------------
  |  |   15|     35|#define PREMIB_CONFIG 1
  ------------------
  259|     35|}
register_config_handler:
  311|     63|{
  312|     63|    return internal_register_config_handler(type, token, parser, NULL, releaser,
  313|     63|					    help, NORMAL_CONFIG);
  ------------------
  |  |   14|     63|#define NORMAL_CONFIG 0
  ------------------
  314|     63|}
register_const_config_handler:
  321|      1|{
  322|      1|    return internal_register_config_handler(type, token, NULL, parser, releaser,
  323|      1|					    help, NORMAL_CONFIG);
  ------------------
  |  |   14|      1|#define NORMAL_CONFIG 0
  ------------------
  324|      1|}
register_app_config_handler:
  330|      2|{
  331|       |    return register_config_handler(NULL, token, parser, releaser, help);
  332|      2|}
netsnmp_config_remember_free_list:
  691|      1|{
  692|      1|    struct read_config_memory *tmpmem;
  693|      1|    while (*mem) {
  ------------------
  |  Branch (693:12): [True: 0, False: 1]
  ------------------
  694|      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, False: 0]
  |  |  ------------------
  ------------------
  695|      0|        tmpmem = (*mem)->next;
  696|       |        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, False: 0]
  |  |  ------------------
  ------------------
  697|      0|        *mem = tmpmem;
  698|      0|    }
  699|      1|}
netsnmp_config_process_memory_list:
  704|      2|{
  705|       |
  706|      2|    struct read_config_memory *mem;
  707|       |
  708|      2|    if (!memp)
  ------------------
  |  Branch (708:9): [True: 0, False: 2]
  ------------------
  709|      0|        return;
  710|       |
  711|      2|    mem = *memp;
  712|       |
  713|      2|    while (mem) {
  ------------------
  |  Branch (713:12): [True: 0, False: 2]
  ------------------
  714|      0|        DEBUGMSGTL(("read_config:mem", "processing memory: %s\n", mem->line));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
  715|      0|        snmp_config_when(mem->line, when);
  716|      0|        mem = mem->next;
  717|      0|    }
  718|       |
  719|      2|    if (clear)
  ------------------
  |  Branch (719:9): [True: 1, False: 1]
  ------------------
  720|      1|        netsnmp_config_remember_free_list(memp);
  721|      2|}
netsnmp_config_process_memories_when:
  742|      2|{
  743|      2|    netsnmp_config_process_memory_list(&memorylist, when, clear);
  744|      2|}
read_config:
  773|      8|{
  774|      8|    static int      depth = 0;
  775|      8|    static int      files = 0;
  776|       |
  777|      8|    const char * const prev_filename = curfilename;
  778|      8|    const unsigned int prev_linecount = linecount;
  779|       |
  780|      8|    FILE           *ifile;
  781|      8|    char           *line = NULL;  /* current line buffer */
  782|      8|    size_t          linesize = 0; /* allocated size of line */
  783|       |
  784|      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
  |  |  |  |  ------------------
  |  |  |  |  |  | 1705|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|      8|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded, False: 8]
  |  |  ------------------
  ------------------
  785|      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
  |  |  |  |  ------------------
  |  |  |  |  |  | 1705|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|      8|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded, False: 8]
  |  |  ------------------
  ------------------
  786|       |
  787|       |    /* reset file counter when recursion depth is 0 */
  788|      8|    if (depth == 0) {
  ------------------
  |  Branch (788:9): [True: 8, False: 0]
  ------------------
  789|      8|        files = 0;
  790|      8|        config_errors = 0;
  791|      8|        config_warnings = 0;
  792|      8|    }
  793|       |
  794|      8|    if ((ifile = fopen(filename, "r")) == NULL) {
  ------------------
  |  Branch (794:9): [True: 8, False: 0]
  ------------------
  795|      8|#ifdef ENOENT
  796|      8|        if (errno == ENOENT) {
  ------------------
  |  Branch (796:13): [True: 8, False: 0]
  ------------------
  797|      8|            DEBUGMSGTL(("read_config", "%s: %s\n", filename,
  ------------------
  |  |   66|      8|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      8|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 8, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      8|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      8|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      8|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      8|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 8]
  |  |  ------------------
  ------------------
  798|      8|                        strerror(errno)));
  799|      8|        } else
  800|      0|#endif                          /* ENOENT */
  801|      0|#ifdef EACCES
  802|      0|        if (errno == EACCES) {
  ------------------
  |  Branch (802:13): [True: 0, False: 0]
  ------------------
  803|      0|            DEBUGMSGTL(("read_config", "%s: %s\n", filename,
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
  804|      0|                        strerror(errno)));
  805|      0|        } else
  806|      0|#endif                          /* EACCES */
  807|      0|        {
  808|      0|            snmp_log_perror(filename);
  809|      0|        }
  810|      8|        return SNMPERR_GENERR;
  ------------------
  |  |  185|      8|#define SNMPERR_GENERR			(-1)
  ------------------
  811|      8|    }
  812|       |
  813|      0|#define CONFIG_MAX_FILES 4096
  814|      0|    if (files > CONFIG_MAX_FILES) {
  ------------------
  |  |  813|      0|#define CONFIG_MAX_FILES 4096
  ------------------
  |  Branch (814:9): [True: 0, False: 0]
  ------------------
  815|      0|        netsnmp_config_error("maximum conf file count (%d) exceeded\n",
  816|      0|                             CONFIG_MAX_FILES);
  ------------------
  |  |  813|      0|#define CONFIG_MAX_FILES 4096
  ------------------
  817|      0|	fclose(ifile);
  818|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  819|      0|    }
  820|      0|#define CONFIG_MAX_RECURSE_DEPTH 16
  821|      0|    if (depth > CONFIG_MAX_RECURSE_DEPTH) {
  ------------------
  |  |  820|      0|#define CONFIG_MAX_RECURSE_DEPTH 16
  ------------------
  |  Branch (821:9): [True: 0, False: 0]
  ------------------
  822|      0|        netsnmp_config_error("nested include depth > %d\n",
  823|      0|                             CONFIG_MAX_RECURSE_DEPTH);
  ------------------
  |  |  820|      0|#define CONFIG_MAX_RECURSE_DEPTH 16
  ------------------
  824|      0|	fclose(ifile);
  825|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  826|      0|    }
  827|       |
  828|      0|    linecount = 0;
  829|      0|    curfilename = filename;
  830|       |
  831|      0|    ++files;
  832|      0|    ++depth;
  833|       |
  834|      0|    DEBUGMSGTL(("read_config:file", "Reading configuration %s (%d)\n",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
  835|      0|                filename, when));
  836|       |
  837|      0|    while (ifile) {
  ------------------
  |  Branch (837:12): [True: 0, False: 0]
  ------------------
  838|      0|        size_t              linelen = 0; /* strlen of the current line */
  839|      0|        char               *cptr;
  840|      0|        struct config_line *lptr = line_handler;
  841|       |
  842|      0|        if (config_errors + config_warnings > 500) {
  ------------------
  |  Branch (842:13): [True: 0, False: 0]
  ------------------
  843|      0|            snmp_log(LOG_ERR, "Too many config errors/warnings. Aborting parsing of %s.\n", filename);
  844|      0|            fclose(ifile);
  845|      0|            ifile = NULL;
  846|      0|            break;
  847|      0|        }
  848|       |
  849|      0|        for (;;) {
  850|      0|            if (linesize <= linelen + 1) {
  ------------------
  |  Branch (850:17): [True: 0, False: 0]
  ------------------
  851|      0|                char *tmp = realloc(line, linesize + 256);
  852|      0|                if (tmp) {
  ------------------
  |  Branch (852:21): [True: 0, False: 0]
  ------------------
  853|      0|                    line = tmp;
  854|      0|                    linesize += 256;
  855|      0|                } else {
  856|      0|                    netsnmp_config_error("Failed to allocate memory\n");
  857|      0|                    free(line);
  858|      0|                    fclose(ifile);
  859|      0|                    return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  860|      0|                }
  861|      0|            }
  862|      0|            if (fgets(line + linelen, linesize - linelen, ifile) == NULL) {
  ------------------
  |  Branch (862:17): [True: 0, False: 0]
  ------------------
  863|      0|                line[linelen] = '\0';
  864|      0|                fclose (ifile);
  865|      0|                ifile = NULL;
  866|      0|                break;
  867|      0|            }
  868|       |
  869|      0|            linelen += strlen(line + linelen);
  870|       |
  871|      0|            if (linelen && line[linelen - 1] == '\n') {
  ------------------
  |  Branch (871:17): [True: 0, False: 0]
  |  Branch (871:28): [True: 0, False: 0]
  ------------------
  872|      0|              line[linelen - 1] = '\0';
  873|      0|              break;
  874|      0|            }
  875|      0|        }
  876|       |
  877|      0|        ++linecount;
  878|      0|        DEBUGMSGTL(("9:read_config:line", "%s:%d examining: %s\n",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
  879|      0|                    filename, linecount, line));
  880|       |        /*
  881|       |         * check blank line or # comment 
  882|       |         */
  883|      0|        if ((cptr = skip_white(line))) {
  ------------------
  |  Branch (883:13): [True: 0, False: 0]
  ------------------
  884|      0|            char token[STRINGMAX];
  885|       |
  886|      0|            cptr = copy_nword(cptr, token, sizeof(token));
  887|      0|            if (token[0] == '[') {
  ------------------
  |  Branch (887:17): [True: 0, False: 0]
  ------------------
  888|      0|                if (token[strlen(token) - 1] != ']') {
  ------------------
  |  Branch (888:21): [True: 0, False: 0]
  ------------------
  889|      0|		    netsnmp_config_error("no matching ']' for type %s.",
  890|      0|					 &token[1]);
  891|      0|                    continue;
  892|      0|                }
  893|      0|                token[strlen(token) - 1] = '\0';
  894|      0|                lptr = read_config_get_handlers(&token[1]);
  895|      0|                if (lptr == NULL) {
  ------------------
  |  Branch (895:21): [True: 0, False: 0]
  ------------------
  896|      0|		    netsnmp_config_error("No handlers registered for type %s.",
  897|      0|					 &token[1]);
  898|      0|                    continue;
  899|      0|                }
  900|      0|                DEBUGMSGTL(("read_config:context",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (164:52): [True: 0, False: 0]
  |  |  |  |  |  Branch (164:64): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
  901|      0|                            "Switching to new context: %s%s\n",
  902|      0|                            ((cptr) ? "(this line only) " : ""),
  903|      0|                            &token[1]));
  904|      0|                if (cptr == NULL) {
  ------------------
  |  Branch (904:21): [True: 0, False: 0]
  ------------------
  905|       |                    /*
  906|       |                     * change context permanently 
  907|       |                     */
  908|      0|                    line_handler = lptr;
  909|      0|                    continue;
  910|      0|                } else {
  911|       |                    /*
  912|       |                     * the rest of this line only applies. 
  913|       |                     */
  914|      0|                    cptr = copy_nword(cptr, token, sizeof(token));
  915|      0|                }
  916|      0|            } else if ((token[0] == 'i') && (strncasecmp(token,"include", 7 )==0)) {
  ------------------
  |  Branch (916:24): [True: 0, False: 0]
  |  Branch (916:45): [True: 0, False: 0]
  ------------------
  917|      0|                if ( strcasecmp( token, "include" )==0) {
  ------------------
  |  Branch (917:22): [True: 0, False: 0]
  ------------------
  918|      0|                    if (when != PREMIB_CONFIG && 
  ------------------
  |  |   15|      0|#define PREMIB_CONFIG 1
  ------------------
  |  Branch (918:25): [True: 0, False: 0]
  ------------------
  919|      0|	                !netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|      0|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (919:18): [True: 0, False: 0]
  ------------------
  920|      0|				                NETSNMP_DS_LIB_NO_TOKEN_WARNINGS)) {
  ------------------
  |  |   77|      0|#define NETSNMP_DS_LIB_NO_TOKEN_WARNINGS   17   /* no warn about unknown config tokens */
  ------------------
  921|      0|	                netsnmp_config_warn("Ambiguous token '%s' - use 'includeSearch' (or 'includeFile') instead.", token);
  922|      0|                    }
  923|      0|                    continue;
  924|      0|                } else if ( strcasecmp( token, "includedir" )==0) {
  ------------------
  |  Branch (924:29): [True: 0, False: 0]
  ------------------
  925|      0|                    DIR *d;
  926|      0|                    struct dirent *entry;
  927|      0|                    char  fname[SNMP_MAXPATH];
  928|      0|                    int   len;
  929|       |
  930|      0|                    if (cptr == NULL) {
  ------------------
  |  Branch (930:25): [True: 0, False: 0]
  ------------------
  931|      0|                        if (when != PREMIB_CONFIG)
  ------------------
  |  |   15|      0|#define PREMIB_CONFIG 1
  ------------------
  |  Branch (931:29): [True: 0, False: 0]
  ------------------
  932|      0|		            netsnmp_config_error("Blank line following %s token.", token);
  933|      0|                        continue;
  934|      0|                    }
  935|      0|                    if ((d=opendir(cptr)) == NULL ) {
  ------------------
  |  Branch (935:25): [True: 0, False: 0]
  ------------------
  936|      0|                        if (when != PREMIB_CONFIG)
  ------------------
  |  |   15|      0|#define PREMIB_CONFIG 1
  ------------------
  |  Branch (936:29): [True: 0, False: 0]
  ------------------
  937|      0|                            netsnmp_config_error("Can't open include dir '%s'.", cptr);
  938|      0|                        continue;
  939|      0|                    }
  940|      0|                    while ((entry = readdir( d )) != NULL ) {
  ------------------
  |  Branch (940:28): [True: 0, False: 0]
  ------------------
  941|      0|                        if ( entry->d_name[0] != '.') {
  ------------------
  |  Branch (941:30): [True: 0, False: 0]
  ------------------
  942|      0|                            len = strlen(entry->d_name);
  943|      0|                            if ((len > 5) && (strcmp(&(entry->d_name[len-5]),".conf") == 0)) {
  ------------------
  |  Branch (943:33): [True: 0, False: 0]
  |  Branch (943:46): [True: 0, False: 0]
  ------------------
  944|      0|                                snprintf(fname, SNMP_MAXPATH, "%s/%s",
  ------------------
  |  |   33|      0|#    define SNMP_MAXPATH PATH_MAX
  ------------------
  945|      0|                                         cptr, entry->d_name);
  946|      0|                                (void)read_config(fname, line_handler, when);
  947|      0|                            }
  948|      0|                        }
  949|      0|                    }
  950|      0|                    closedir(d);
  951|      0|                    continue;
  952|      0|                } else if ( strcasecmp( token, "includefile" )==0) {
  ------------------
  |  Branch (952:29): [True: 0, False: 0]
  ------------------
  953|      0|                    char  fname[SNMP_MAXPATH], *cp;
  954|       |
  955|      0|                    if (cptr == NULL) {
  ------------------
  |  Branch (955:25): [True: 0, False: 0]
  ------------------
  956|      0|                        if (when != PREMIB_CONFIG)
  ------------------
  |  |   15|      0|#define PREMIB_CONFIG 1
  ------------------
  |  Branch (956:29): [True: 0, False: 0]
  ------------------
  957|      0|		            netsnmp_config_error("Blank line following %s token.", token);
  958|      0|                        continue;
  959|      0|                    }
  960|      0|                    if (strlen(cptr) + 1 >= SNMP_MAXPATH) {
  ------------------
  |  |   33|      0|#    define SNMP_MAXPATH PATH_MAX
  ------------------
  |  Branch (960:25): [True: 0, False: 0]
  ------------------
  961|      0|                        netsnmp_config_error("File name '%s' is too long",
  962|      0|                                             cptr);
  963|      0|                        continue;
  964|      0|                    }
  965|      0|                    if ( cptr[0] == '/' ) {
  ------------------
  |  Branch (965:26): [True: 0, False: 0]
  ------------------
  966|      0|                        strlcpy(fname, cptr, SNMP_MAXPATH);
  ------------------
  |  |   33|      0|#    define SNMP_MAXPATH PATH_MAX
  ------------------
  967|      0|                    } else {
  968|      0|                        strlcpy(fname, filename, SNMP_MAXPATH);
  ------------------
  |  |   33|      0|#    define SNMP_MAXPATH PATH_MAX
  ------------------
  969|      0|                        cp = strrchr(fname, '/');
  970|      0|                        if (!cp)
  ------------------
  |  Branch (970:29): [True: 0, False: 0]
  ------------------
  971|      0|                            fname[0] = '\0';
  972|      0|                        else
  973|      0|                            *(++cp) = '\0';
  974|      0|                        strlcat(fname, cptr, SNMP_MAXPATH);
  ------------------
  |  |   33|      0|#    define SNMP_MAXPATH PATH_MAX
  ------------------
  975|      0|                    }
  976|      0|                    if (read_config(fname, line_handler, when) !=
  ------------------
  |  Branch (976:25): [True: 0, False: 0]
  ------------------
  977|      0|                        SNMPERR_SUCCESS && when != PREMIB_CONFIG)
  ------------------
  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
                                      SNMPERR_SUCCESS && when != PREMIB_CONFIG)
  ------------------
  |  |   15|      0|#define PREMIB_CONFIG 1
  ------------------
  |  Branch (977:44): [True: 0, False: 0]
  ------------------
  978|      0|                        netsnmp_config_error("Included file '%s' not found.",
  979|      0|                                             fname);
  980|      0|                    continue;
  981|      0|                } else if ( strcasecmp( token, "includesearch" )==0) {
  ------------------
  |  Branch (981:29): [True: 0, False: 0]
  ------------------
  982|      0|                    struct config_files ctmp;
  983|      0|                    int len, ret;
  984|       |
  985|      0|                    if (cptr == NULL) {
  ------------------
  |  Branch (985:25): [True: 0, False: 0]
  ------------------
  986|      0|                        if (when != PREMIB_CONFIG)
  ------------------
  |  |   15|      0|#define PREMIB_CONFIG 1
  ------------------
  |  Branch (986:29): [True: 0, False: 0]
  ------------------
  987|      0|		            netsnmp_config_error("Blank line following %s token.", token);
  988|      0|                        continue;
  989|      0|                    }
  990|      0|                    len = strlen(cptr);
  991|      0|                    ctmp.fileHeader = cptr;
  992|      0|                    ctmp.start = line_handler;
  993|      0|                    ctmp.next = NULL;
  994|      0|                    if ((len > 5) && (strcmp(&cptr[len-5],".conf") == 0))
  ------------------
  |  Branch (994:25): [True: 0, False: 0]
  |  Branch (994:38): [True: 0, False: 0]
  ------------------
  995|      0|                       cptr[len-5] = 0; /* chop off .conf */
  996|      0|                    ret = read_config_files_of_type(when,&ctmp);
  997|      0|                    if ((len > 5) && (cptr[len-5] == 0))
  ------------------
  |  Branch (997:25): [True: 0, False: 0]
  |  Branch (997:38): [True: 0, False: 0]
  ------------------
  998|      0|                       cptr[len-5] = '.'; /* restore .conf */
  999|      0|                    if (( ret != SNMPERR_SUCCESS ) && (when != PREMIB_CONFIG))
  ------------------
  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
                                  if (( ret != SNMPERR_SUCCESS ) && (when != PREMIB_CONFIG))
  ------------------
  |  |   15|      0|#define PREMIB_CONFIG 1
  ------------------
  |  Branch (999:25): [True: 0, False: 0]
  |  Branch (999:55): [True: 0, False: 0]
  ------------------
 1000|      0|		        netsnmp_config_error("Included config '%s' not found.", cptr);
 1001|      0|                    continue;
 1002|      0|                } else {
 1003|      0|                    lptr = line_handler;
 1004|      0|                }
 1005|      0|            } else {
 1006|      0|                lptr = line_handler;
 1007|      0|            }
 1008|      0|            if (cptr == NULL) {
  ------------------
  |  Branch (1008:17): [True: 0, False: 0]
  ------------------
 1009|      0|		netsnmp_config_error("Blank line following %s token.", token);
 1010|      0|            } else {
 1011|      0|                DEBUGMSGTL(("read_config:line", "%s:%d examining: %s\n",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1012|      0|                            filename, linecount, line));
 1013|      0|                run_config_handler(lptr, token, cptr, when);
 1014|      0|            }
 1015|      0|        }
 1016|      0|    }
 1017|      0|    free(line);
 1018|      0|    linecount = prev_linecount;
 1019|      0|    curfilename = prev_filename;
 1020|      0|    --depth;
 1021|      0|    return SNMPERR_SUCCESS;
  ------------------
  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 1022|       |
 1023|      0|}                               /* end read_config() */
free_config:
 1029|      1|{
 1030|      1|    struct config_files *ctmp = config_files;
 1031|      1|    struct config_line *ltmp;
 1032|       |
 1033|      3|    for (; ctmp != NULL; ctmp = ctmp->next)
  ------------------
  |  Branch (1033:12): [True: 2, False: 1]
  ------------------
 1034|    103|        for (ltmp = ctmp->start; ltmp != NULL; ltmp = ltmp->next)
  ------------------
  |  Branch (1034:34): [True: 101, False: 2]
  ------------------
 1035|    101|            if (ltmp->free_func)
  ------------------
  |  Branch (1035:17): [True: 7, False: 94]
  ------------------
 1036|      7|                (*(ltmp->free_func)) ();
 1037|      1|}
read_configs:
 1082|      1|{
 1083|      1|    char *optional_config = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1084|      1|					       NETSNMP_DS_LIB_OPTIONALCONFIG);
  ------------------
  |  |  156|      1|#define NETSNMP_DS_LIB_OPTIONALCONFIG    5
  ------------------
 1085|       |
 1086|      1|    snmp_call_callbacks(SNMP_CALLBACK_LIBRARY,
  ------------------
  |  |   18|      1|#define SNMP_CALLBACK_LIBRARY     0
  ------------------
 1087|      1|                        SNMP_CALLBACK_PRE_READ_CONFIG, NULL);
  ------------------
  |  |   30|      1|#define SNMP_CALLBACK_PRE_READ_CONFIG	        7
  ------------------
 1088|       |
 1089|      1|    DEBUGMSGTL(("read_config", "reading normal configuration tokens\n"));
  ------------------
  |  |   66|      1|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      1|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      1|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      1|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      1|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 1]
  |  |  ------------------
  ------------------
 1090|       |
 1091|      1|    if ((NULL != optional_config) && (*optional_config == '-')) {
  ------------------
  |  Branch (1091:9): [True: 0, False: 1]
  |  Branch (1091:38): [True: 0, False: 0]
  ------------------
 1092|      0|        (void)read_configs_optional(++optional_config, NORMAL_CONFIG);
  ------------------
  |  |   14|      0|#define NORMAL_CONFIG 0
  ------------------
 1093|      0|        optional_config = NULL; /* clear, so we don't read them twice */
 1094|      0|    }
 1095|       |
 1096|      1|    (void)read_config_files(NORMAL_CONFIG);
  ------------------
  |  |   14|      1|#define NORMAL_CONFIG 0
  ------------------
 1097|       |
 1098|       |    /*
 1099|       |     * do this even when the normal above wasn't done 
 1100|       |     */
 1101|      1|    if (NULL != optional_config)
  ------------------
  |  Branch (1101:9): [True: 0, False: 1]
  ------------------
 1102|      0|        (void)read_configs_optional(optional_config, NORMAL_CONFIG);
  ------------------
  |  |   14|      0|#define NORMAL_CONFIG 0
  ------------------
 1103|       |
 1104|      1|    netsnmp_config_process_memories_when(NORMAL_CONFIG, 1);
  ------------------
  |  |   14|      1|#define NORMAL_CONFIG 0
  ------------------
 1105|       |
 1106|      1|    netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1107|      1|			   NETSNMP_DS_LIB_HAVE_READ_CONFIG, 1);
  ------------------
  |  |   87|      1|#define NETSNMP_DS_LIB_HAVE_READ_CONFIG    27   /* have the config tokens been processed */
  ------------------
 1108|      1|    snmp_call_callbacks(SNMP_CALLBACK_LIBRARY,
  ------------------
  |  |   18|      1|#define SNMP_CALLBACK_LIBRARY     0
  ------------------
 1109|      1|                        SNMP_CALLBACK_POST_READ_CONFIG, NULL);
  ------------------
  |  |   24|      1|#define SNMP_CALLBACK_POST_READ_CONFIG	        0
  ------------------
 1110|      1|}
read_premib_configs:
 1114|      1|{
 1115|      1|    char *optional_config = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1116|      1|					       NETSNMP_DS_LIB_OPTIONALCONFIG);
  ------------------
  |  |  156|      1|#define NETSNMP_DS_LIB_OPTIONALCONFIG    5
  ------------------
 1117|       |
 1118|      1|    snmp_call_callbacks(SNMP_CALLBACK_LIBRARY,
  ------------------
  |  |   18|      1|#define SNMP_CALLBACK_LIBRARY     0
  ------------------
 1119|      1|                        SNMP_CALLBACK_PRE_PREMIB_READ_CONFIG, NULL);
  ------------------
  |  |   31|      1|#define SNMP_CALLBACK_PRE_PREMIB_READ_CONFIG	8
  ------------------
 1120|       |
 1121|      1|    DEBUGMSGTL(("read_config", "reading premib configuration tokens\n"));
  ------------------
  |  |   66|      1|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      1|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      1|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      1|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      1|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 1]
  |  |  ------------------
  ------------------
 1122|       |
 1123|      1|    if ((NULL != optional_config) && (*optional_config == '-')) {
  ------------------
  |  Branch (1123:9): [True: 0, False: 1]
  |  Branch (1123:38): [True: 0, False: 0]
  ------------------
 1124|      0|        (void)read_configs_optional(++optional_config, PREMIB_CONFIG);
  ------------------
  |  |   15|      0|#define PREMIB_CONFIG 1
  ------------------
 1125|      0|        optional_config = NULL; /* clear, so we don't read them twice */
 1126|      0|    }
 1127|       |
 1128|      1|    (void)read_config_files(PREMIB_CONFIG);
  ------------------
  |  |   15|      1|#define PREMIB_CONFIG 1
  ------------------
 1129|       |
 1130|      1|    if (NULL != optional_config)
  ------------------
  |  Branch (1130:9): [True: 0, False: 1]
  ------------------
 1131|      0|        (void)read_configs_optional(optional_config, PREMIB_CONFIG);
  ------------------
  |  |   15|      0|#define PREMIB_CONFIG 1
  ------------------
 1132|       |
 1133|      1|    netsnmp_config_process_memories_when(PREMIB_CONFIG, 0);
  ------------------
  |  |   15|      1|#define PREMIB_CONFIG 1
  ------------------
 1134|       |
 1135|      1|    netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1136|      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 */
  ------------------
 1137|      1|    snmp_call_callbacks(SNMP_CALLBACK_LIBRARY,
  ------------------
  |  |   18|      1|#define SNMP_CALLBACK_LIBRARY     0
  ------------------
 1138|      1|                        SNMP_CALLBACK_POST_PREMIB_READ_CONFIG, NULL);
  ------------------
  |  |   27|      1|#define SNMP_CALLBACK_POST_PREMIB_READ_CONFIG	3
  ------------------
 1139|      1|}
set_configuration_directory:
 1151|      1|{
 1152|      1|    netsnmp_ds_set_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1153|      1|			  NETSNMP_DS_LIB_CONFIGURATION_DIR, dir);
  ------------------
  |  |  160|      1|#define NETSNMP_DS_LIB_CONFIGURATION_DIR 9
  ------------------
 1154|      1|}
get_configuration_directory:
 1170|      5|{
 1171|      5|    char            defaultPath[SPRINT_MAX_LEN];
 1172|      5|    const char     *homepath;
 1173|       |
 1174|      5|    if (NULL == netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|      5|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (1174:9): [True: 1, False: 4]
  ------------------
 1175|      5|				      NETSNMP_DS_LIB_CONFIGURATION_DIR)) {
  ------------------
  |  |  160|      5|#define NETSNMP_DS_LIB_CONFIGURATION_DIR 9
  ------------------
 1176|      1|        homepath = netsnmp_gethomedir();
 1177|      1|        snprintf(defaultPath, sizeof(defaultPath), "%s%c%s%c%s%s%s%s",
 1178|      1|                SNMPCONFPATH, ENV_SEPARATOR_CHAR,
  ------------------
  |  | 2033|      1|#define SNMPCONFPATH "/usr/local/net-snmp-master/etc/snmp"
  ------------------
                              SNMPCONFPATH, ENV_SEPARATOR_CHAR,
  ------------------
  |  |   70|      1|#define ENV_SEPARATOR_CHAR ':'
  ------------------
 1179|      1|                SNMPSHAREPATH, ENV_SEPARATOR_CHAR, SNMPLIBPATH,
  ------------------
  |  | 2032|      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,
  ------------------
  |  | 2031|      1|#define SNMPLIBPATH "/usr/local/net-snmp-master/lib/snmp"
  ------------------
 1180|      1|                ((homepath == NULL) ? "" : ENV_SEPARATOR),
  ------------------
  |  |   67|      1|#define ENV_SEPARATOR ":"
  ------------------
  |  Branch (1180:18): [True: 0, False: 1]
  ------------------
 1181|      1|                ((homepath == NULL) ? "" : homepath),
  ------------------
  |  Branch (1181:18): [True: 0, False: 1]
  ------------------
 1182|      1|                ((homepath == NULL) ? "" : "/.snmp"));
  ------------------
  |  Branch (1182:18): [True: 0, False: 1]
  ------------------
 1183|      1|        defaultPath[ sizeof(defaultPath)-1 ] = 0;
 1184|      1|        set_configuration_directory(defaultPath);
 1185|      1|    }
 1186|      5|    return (netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|      5|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1187|      5|				  NETSNMP_DS_LIB_CONFIGURATION_DIR));
  ------------------
  |  |  160|      5|#define NETSNMP_DS_LIB_CONFIGURATION_DIR 9
  ------------------
 1188|      5|}
set_persistent_directory:
 1201|      1|{
 1202|      1|    netsnmp_ds_set_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1203|      1|			  NETSNMP_DS_LIB_PERSISTENT_DIR, dir);
  ------------------
  |  |  159|      1|#define NETSNMP_DS_LIB_PERSISTENT_DIR    8
  ------------------
 1204|      1|}
get_persistent_directory:
 1218|      9|{
 1219|      9|    if (NULL == netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|      9|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (1219:9): [True: 1, False: 8]
  ------------------
 1220|      9|				      NETSNMP_DS_LIB_PERSISTENT_DIR)) {
  ------------------
  |  |  159|      9|#define NETSNMP_DS_LIB_PERSISTENT_DIR    8
  ------------------
 1221|      1|        const char *persdir = netsnmp_getenv("SNMP_PERSISTENT_DIR");
 1222|      1|        if (NULL == persdir)
  ------------------
  |  Branch (1222:13): [True: 1, False: 0]
  ------------------
 1223|      1|            persdir = NETSNMP_PERSISTENT_DIRECTORY;
  ------------------
  |  | 2003|      1|#define NETSNMP_PERSISTENT_DIRECTORY "/var/net-snmp"
  ------------------
 1224|      1|        set_persistent_directory(persdir);
 1225|      1|    }
 1226|      9|    return (netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|      9|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1227|      9|				  NETSNMP_DS_LIB_PERSISTENT_DIR));
  ------------------
  |  |  159|      9|#define NETSNMP_DS_LIB_PERSISTENT_DIR    8
  ------------------
 1228|      9|}
read_config_files_of_type:
 1412|      4|{
 1413|      4|    const char     *confpath, *persfile, *envconfpath;
 1414|      4|    char           *perspath;
 1415|      4|    int             ret = SNMPERR_GENERR;
  ------------------
  |  |  185|      4|#define SNMPERR_GENERR			(-1)
  ------------------
 1416|       |
 1417|      4|    if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      4|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (1417:9): [True: 0, False: 4]
  ------------------
 1418|      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 */
  ------------------
 1419|      4|        || netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      4|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (1419:12): [True: 0, False: 4]
  ------------------
 1420|      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 */
  |  |  ------------------
  ------------------
 1421|      4|        || (NULL == ctmp)) return ret;
  ------------------
  |  Branch (1421:12): [True: 0, False: 4]
  ------------------
 1422|       |
 1423|       |    /*
 1424|       |     * these shouldn't change
 1425|       |     */
 1426|      4|    confpath = get_configuration_directory();
 1427|      4|    persfile = netsnmp_getenv("SNMP_PERSISTENT_FILE");
 1428|      4|    envconfpath = netsnmp_getenv("SNMPCONFPATH");
 1429|       |
 1430|       |
 1431|       |        /*
 1432|       |         * read the config files. strdup() the result of
 1433|       |         * get_persistent_directory() to avoid that parsing the "persistentDir"
 1434|       |         * keyword transforms the perspath pointer into a dangling pointer.
 1435|       |         */
 1436|      4|        perspath = strdup(get_persistent_directory());
 1437|      4|        if (perspath == NULL) {
  ------------------
  |  Branch (1437:13): [True: 0, False: 4]
  ------------------
 1438|      0|            return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
 1439|      0|        }
 1440|      4|        if (envconfpath == NULL) {
  ------------------
  |  Branch (1440:13): [True: 4, False: 0]
  ------------------
 1441|       |            /*
 1442|       |             * read just the config files (no persistent stuff), since
 1443|       |             * persistent path can change via conf file. Then get the
 1444|       |             * current persistent directory, and read files there.
 1445|       |             */
 1446|      4|            if ( read_config_files_in_path(confpath, ctmp, when, perspath,
  ------------------
  |  Branch (1446:18): [True: 0, False: 4]
  ------------------
 1447|      4|                                      persfile) == SNMPERR_SUCCESS )
  ------------------
  |  |  184|      4|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 1448|      0|                ret = SNMPERR_SUCCESS;
  ------------------
  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 1449|      4|            free(perspath);
 1450|      4|            perspath = strdup(get_persistent_directory());
 1451|      4|            if (perspath == NULL) {
  ------------------
  |  Branch (1451:17): [True: 0, False: 4]
  ------------------
 1452|      0|                return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
 1453|      0|            }
 1454|      4|            if ( read_config_files_in_path(perspath, ctmp, when, perspath,
  ------------------
  |  Branch (1454:18): [True: 0, False: 4]
  ------------------
 1455|      4|                                      persfile) == SNMPERR_SUCCESS )
  ------------------
  |  |  184|      4|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 1456|      0|                ret = SNMPERR_SUCCESS;
  ------------------
  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 1457|      4|        }
 1458|      0|        else {
 1459|       |            /*
 1460|       |             * only read path specified by user
 1461|       |             */
 1462|      0|            if ( read_config_files_in_path(envconfpath, ctmp, when, perspath,
  ------------------
  |  Branch (1462:18): [True: 0, False: 0]
  ------------------
 1463|      0|                                      persfile) == SNMPERR_SUCCESS )
  ------------------
  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 1464|      0|                ret = SNMPERR_SUCCESS;
  ------------------
  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 1465|      0|        }
 1466|      4|        free(perspath);
 1467|      4|        return ret;
 1468|      4|}
read_config_files:
 1476|      2|read_config_files(int when) {
 1477|       |
 1478|      2|    struct config_files *ctmp = config_files;
 1479|      2|    int                  ret  = SNMPERR_GENERR;
  ------------------
  |  |  185|      2|#define SNMPERR_GENERR			(-1)
  ------------------
 1480|       |
 1481|      2|    config_errors = 0;
 1482|       |
 1483|      2|    if (when == PREMIB_CONFIG)
  ------------------
  |  |   15|      2|#define PREMIB_CONFIG 1
  ------------------
  |  Branch (1483:9): [True: 1, False: 1]
  ------------------
 1484|      1|        free_config();
 1485|       |
 1486|       |    /*
 1487|       |     * read all config file types 
 1488|       |     */
 1489|      6|    for (; ctmp != NULL; ctmp = ctmp->next) {
  ------------------
  |  Branch (1489:12): [True: 4, False: 2]
  ------------------
 1490|      4|        if ( read_config_files_of_type(when, ctmp) == SNMPERR_SUCCESS )
  ------------------
  |  |  184|      4|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  |  Branch (1490:14): [True: 0, False: 4]
  ------------------
 1491|      0|            ret = SNMPERR_SUCCESS;
  ------------------
  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 1492|      4|    }
 1493|       |
 1494|      2|    if (config_errors) {
  ------------------
  |  Branch (1494:9): [True: 0, False: 2]
  ------------------
 1495|       |        snmp_log(LOG_ERR, "net-snmp: %d error(s) in config file(s)\n",
 1496|      0|                 config_errors);
 1497|      0|    }
 1498|      2|    return ret;
 1499|      2|}
skip_white_const:
 1806|      4|{
 1807|      4|    if (ptr == NULL)
  ------------------
  |  Branch (1807:9): [True: 0, False: 4]
  ------------------
 1808|      0|        return (NULL);
 1809|      6|    while (*ptr != 0 && isspace((unsigned char)*ptr))
  ------------------
  |  Branch (1809:12): [True: 4, False: 2]
  |  Branch (1809:25): [True: 2, False: 2]
  ------------------
 1810|      2|        ptr++;
 1811|      4|    if (*ptr == 0 || *ptr == '#')
  ------------------
  |  Branch (1811:9): [True: 2, False: 2]
  |  Branch (1811:22): [True: 0, False: 2]
  ------------------
 1812|      2|        return (NULL);
 1813|      2|    return (ptr);
 1814|      4|}
copy_nword_const:
 1871|      4|{
 1872|      4|    char            quote;
 1873|      4|    if (!from || !to)
  ------------------
  |  Branch (1873:9): [True: 0, False: 4]
  |  Branch (1873:18): [True: 0, False: 4]
  ------------------
 1874|      0|        return NULL;
 1875|      4|    if ((*from == '\"') || (*from == '\'')) {
  ------------------
  |  Branch (1875:9): [True: 0, False: 4]
  |  Branch (1875:28): [True: 0, False: 4]
  ------------------
 1876|      0|        quote = *(from++);
 1877|      0|        while ((*from != quote) && (*from != 0)) {
  ------------------
  |  Branch (1877:16): [True: 0, False: 0]
  |  Branch (1877:36): [True: 0, False: 0]
  ------------------
 1878|      0|            if ((*from == '\\') && (*(from + 1) != 0)) {
  ------------------
  |  Branch (1878:17): [True: 0, False: 0]
  |  Branch (1878:36): [True: 0, False: 0]
  ------------------
 1879|      0|                if (len > 0) {  /* don't copy beyond len bytes */
  ------------------
  |  Branch (1879:21): [True: 0, False: 0]
  ------------------
 1880|      0|                    *to++ = *(from + 1);
 1881|      0|                    if (--len == 0)
  ------------------
  |  Branch (1881:25): [True: 0, False: 0]
  ------------------
 1882|      0|                        *(to - 1) = '\0';       /* null protect the last spot */
 1883|      0|                }
 1884|      0|                from = from + 2;
 1885|      0|            } else {
 1886|      0|                if (len > 0) {  /* don't copy beyond len bytes */
  ------------------
  |  Branch (1886:21): [True: 0, False: 0]
  ------------------
 1887|      0|                    *to++ = *from++;
 1888|      0|                    if (--len == 0)
  ------------------
  |  Branch (1888:25): [True: 0, False: 0]
  ------------------
 1889|      0|                        *(to - 1) = '\0';       /* null protect the last spot */
 1890|      0|                } else
 1891|      0|                    from++;
 1892|      0|            }
 1893|      0|        }
 1894|      0|        if (*from == 0) {
  ------------------
  |  Branch (1894:13): [True: 0, False: 0]
  ------------------
 1895|      0|            DEBUGMSGTL(("read_config_copy_word",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1896|      0|                        "no end quote found in config string\n"));
 1897|      0|        } else
 1898|      0|            from++;
 1899|      4|    } else {
 1900|     18|        while (*from != 0 && !isspace((unsigned char)(*from))) {
  ------------------
  |  Branch (1900:16): [True: 16, False: 2]
  |  Branch (1900:30): [True: 14, False: 2]
  ------------------
 1901|     14|            if ((*from == '\\') && (*(from + 1) != 0)) {
  ------------------
  |  Branch (1901:17): [True: 0, False: 14]
  |  Branch (1901:36): [True: 0, False: 0]
  ------------------
 1902|      0|                if (len > 0) {  /* don't copy beyond len bytes */
  ------------------
  |  Branch (1902:21): [True: 0, False: 0]
  ------------------
 1903|      0|                    *to++ = *(from + 1);
 1904|      0|                    if (--len == 0)
  ------------------
  |  Branch (1904:25): [True: 0, False: 0]
  ------------------
 1905|      0|                        *(to - 1) = '\0';       /* null protect the last spot */
 1906|      0|                }
 1907|      0|                from = from + 2;
 1908|     14|            } else {
 1909|     14|                if (len > 0) {  /* don't copy beyond len bytes */
  ------------------
  |  Branch (1909:21): [True: 14, False: 0]
  ------------------
 1910|     14|                    *to++ = *from++;
 1911|     14|                    if (--len == 0)
  ------------------
  |  Branch (1911:25): [True: 0, False: 14]
  ------------------
 1912|      0|                        *(to - 1) = '\0';       /* null protect the last spot */
 1913|     14|                } else
 1914|      0|                    from++;
 1915|     14|            }
 1916|     14|        }
 1917|      4|    }
 1918|      4|    if (len > 0)
  ------------------
  |  Branch (1918:9): [True: 4, False: 0]
  ------------------
 1919|      4|        *to = 0;
 1920|      4|    from = skip_white_const(from);
 1921|      4|    return (from);
 1922|      4|}                               /* copy_nword */
read_config.c:internal_register_config_handler:
  153|    103|{
  154|    103|    struct config_files **ctmp = &config_files;
  155|    103|    struct config_line  **ltmp;
  156|    103|    const char           *type = type_param;
  157|       |
  158|    103|    if (type == NULL || *type == '\0') {
  ------------------
  |  Branch (158:9): [True: 2, False: 101]
  |  Branch (158:25): [True: 2, False: 99]
  ------------------
  159|      4|        type = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|      4|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  160|      4|				     NETSNMP_DS_LIB_APPTYPE);
  ------------------
  |  |  157|      4|#define NETSNMP_DS_LIB_APPTYPE           6
  ------------------
  161|      4|    }
  162|       |
  163|       |    /*
  164|       |     * Handle multiple types (recursively)
  165|       |     */
  166|    103|    if (strchr(type, ':')) {
  ------------------
  |  Branch (166:9): [True: 2, False: 101]
  ------------------
  167|      2|        struct config_line *ltmp2 = NULL;
  168|      2|        char                buf[STRINGMAX];
  169|      2|        char               *cptr = buf;
  170|       |
  171|      2|        strlcpy(buf, type, STRINGMAX);
  ------------------
  |  |   12|      2|#define STRINGMAX 1024
  ------------------
  172|      6|        while (cptr) {
  ------------------
  |  Branch (172:16): [True: 4, False: 2]
  ------------------
  173|      4|            char* c = cptr;
  174|      4|            cptr = strchr(cptr, ':');
  175|      4|            if(cptr) {
  ------------------
  |  Branch (175:16): [True: 2, False: 2]
  ------------------
  176|      2|                *cptr = '\0';
  177|      2|                ++cptr;
  178|      2|            }
  179|      4|            ltmp2 = internal_register_config_handler(c, token, parser1, parser2,
  180|      4|                                                     releaser, help, when);
  181|      4|        }
  182|      2|        return ltmp2;
  183|      2|    }
  184|       |    
  185|       |    /*
  186|       |     * Find type in current list  -OR-  create a new file type.
  187|       |     */
  188|    118|    while (*ctmp != NULL && strcmp((*ctmp)->fileHeader, type)) {
  ------------------
  |  Branch (188:12): [True: 116, False: 2]
  |  Branch (188:29): [True: 17, False: 99]
  ------------------
  189|     17|        ctmp = &((*ctmp)->next);
  190|     17|    }
  191|       |
  192|    101|    if (*ctmp == NULL) {
  ------------------
  |  Branch (192:9): [True: 2, False: 99]
  ------------------
  193|      2|        *ctmp = (struct config_files *)
  194|      2|            calloc(1, sizeof(struct config_files));
  195|      2|        if (!*ctmp) {
  ------------------
  |  Branch (195:13): [True: 0, False: 2]
  ------------------
  196|      0|            return NULL;
  197|      0|        }
  198|       |
  199|      2|        (*ctmp)->fileHeader = strdup(type);
  200|      2|        if (!(*ctmp)->fileHeader) {
  ------------------
  |  Branch (200:13): [True: 0, False: 2]
  ------------------
  201|      0|            free(*ctmp);
  202|      0|            *ctmp = NULL;
  203|      0|            return NULL;
  204|      0|        }
  205|      2|        DEBUGMSGTL(("9:read_config:type", "new type %s\n", type));
  ------------------
  |  |   66|      2|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      2|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 1, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      1|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      1|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      1|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      1|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 2]
  |  |  ------------------
  ------------------
  206|      2|    }
  207|       |
  208|    101|    DEBUGMSGTL(("9:read_config:register_handler", "registering %s %s\n",
  ------------------
  |  |   66|    101|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    101|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 91, False: 10]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|     91|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|     91|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|     91|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|     91|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 101]
  |  |  ------------------
  ------------------
  209|    101|                type, token));
  210|       |    /*
  211|       |     * Find parser type in current list  -OR-  create a new
  212|       |     * line parser entry.
  213|       |     */
  214|    101|    ltmp = &((*ctmp)->start);
  215|       |
  216|  3.72k|    while (*ltmp != NULL && strcmp((*ltmp)->config_token, token)) {
  ------------------
  |  Branch (216:12): [True: 3.62k, False: 101]
  |  Branch (216:29): [True: 3.62k, False: 0]
  ------------------
  217|  3.62k|        ltmp = &((*ltmp)->next);
  218|  3.62k|    }
  219|       |
  220|    101|    if (*ltmp == NULL) {
  ------------------
  |  Branch (220:9): [True: 101, False: 0]
  ------------------
  221|    101|        *ltmp = (struct config_line *)
  222|    101|            calloc(1, sizeof(struct config_line));
  223|    101|        if (!*ltmp) {
  ------------------
  |  Branch (223:13): [True: 0, False: 101]
  ------------------
  224|      0|            return NULL;
  225|      0|        }
  226|       |
  227|    101|        (*ltmp)->config_time = when;
  228|    101|        (*ltmp)->config_token = strdup(token);
  229|    101|        if (!(*ltmp)->config_token) {
  ------------------
  |  Branch (229:13): [True: 0, False: 101]
  ------------------
  230|      0|            free(*ltmp);
  231|      0|            *ltmp = NULL;
  232|      0|            return NULL;
  233|      0|        }
  234|       |
  235|    101|        if (help != NULL)
  ------------------
  |  Branch (235:13): [True: 89, False: 12]
  ------------------
  236|     89|            (*ltmp)->help = strdup(help);
  237|    101|    }
  238|       |
  239|       |    /*
  240|       |     * Add/Replace the parse/free functions for the given line type
  241|       |     * in the given file type.
  242|       |     */
  243|    101|    (*ltmp)->parse_line1 = parser1;
  244|    101|    (*ltmp)->parse_line2 = parser2;
  245|    101|    (*ltmp)->free_func = releaser;
  246|       |
  247|    101|    return (*ltmp);
  248|       |
  249|    101|}                               /* end register_config_handler() */
read_config.c:read_config_files_in_path:
 1277|      8|{
 1278|      8|    int             done, j;
 1279|      8|    char            configfile[300];
 1280|      8|    char           *cptr1, *cptr2, *envconfpath;
 1281|      8|    struct stat     statbuf;
 1282|      8|    int             ret = SNMPERR_GENERR;
  ------------------
  |  |  185|      8|#define SNMPERR_GENERR			(-1)
  ------------------
 1283|       |
 1284|      8|    if ((NULL == path) || (NULL == ctmp))
  ------------------
  |  Branch (1284:9): [True: 0, False: 8]
  |  Branch (1284:27): [True: 0, False: 8]
  ------------------
 1285|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
 1286|       |
 1287|      8|    envconfpath = strdup(path);
 1288|      8|    if (NULL == envconfpath) {
  ------------------
  |  Branch (1288:9): [True: 0, False: 8]
  ------------------
 1289|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
 1290|      0|    }
 1291|       |
 1292|      8|    DEBUGMSGTL(("read_config:path", " config path used for %s:%s (persistent path:%s)\n",
  ------------------
  |  |   66|      8|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      8|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 8, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      8|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      8|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      8|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      8|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 8]
  |  |  ------------------
  ------------------
 1293|      8|                ctmp->fileHeader, envconfpath, perspath));
 1294|      8|    cptr1 = cptr2 = envconfpath;
 1295|      8|    done = 0;
 1296|     24|    while ((!done) && (*cptr2 != 0)) {
  ------------------
  |  Branch (1296:12): [True: 20, False: 4]
  |  Branch (1296:23): [True: 20, False: 0]
  ------------------
 1297|    544|        while (*cptr1 != 0 && *cptr1 != ENV_SEPARATOR_CHAR)
  ------------------
  |  |   70|    536|#define ENV_SEPARATOR_CHAR ':'
  ------------------
  |  Branch (1297:16): [True: 536, False: 8]
  |  Branch (1297:31): [True: 524, False: 12]
  ------------------
 1298|    524|            cptr1++;
 1299|     20|        if (*cptr1 == 0)
  ------------------
  |  Branch (1299:13): [True: 8, False: 12]
  ------------------
 1300|      8|            done = 1;
 1301|     12|        else
 1302|     12|            *cptr1 = 0;
 1303|       |
 1304|     20|        DEBUGMSGTL(("read_config:dir", " config dir: %s\n", cptr2 ));
  ------------------
  |  |   66|     20|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     20|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 20, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|     20|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|     20|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|     20|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|     20|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 20]
  |  |  ------------------
  ------------------
 1305|     20|        if (stat(cptr2, &statbuf) != 0) {
  ------------------
  |  Branch (1305:13): [True: 16, False: 4]
  ------------------
 1306|       |            /*
 1307|       |             * Directory not there, continue 
 1308|       |             */
 1309|     16|            DEBUGMSGTL(("read_config:dir", " Directory not present: %s\n", cptr2 ));
  ------------------
  |  |   66|     16|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     16|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 16, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|     16|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|     16|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|     16|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|     16|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 16]
  |  |  ------------------
  ------------------
 1310|     16|            cptr2 = ++cptr1;
 1311|     16|            continue;
 1312|     16|        }
 1313|      4|#ifdef S_ISDIR
 1314|      4|        if (!S_ISDIR(statbuf.st_mode)) {
  ------------------
  |  Branch (1314:13): [True: 0, False: 4]
  ------------------
 1315|       |            /*
 1316|       |             * Not a directory, continue 
 1317|       |             */
 1318|      0|            DEBUGMSGTL(("read_config:dir", " Not a directory: %s\n", cptr2 ));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1319|      0|            cptr2 = ++cptr1;
 1320|      0|            continue;
 1321|      0|        }
 1322|      4|#endif
 1323|       |
 1324|       |        /*
 1325|       |         * for proper persistent storage retrieval, we need to read old backup
 1326|       |         * copies of the previous storage files.  If the application in
 1327|       |         * question has died without the proper call to snmp_clean_persistent,
 1328|       |         * then we read all the configuration files we can, starting with
 1329|       |         * the oldest first.
 1330|       |         */
 1331|      4|        if (strncmp(cptr2, perspath, strlen(perspath)) == 0 ||
  ------------------
  |  Branch (1331:13): [True: 4, False: 0]
  ------------------
 1332|      0|            (persfile != NULL &&
  ------------------
  |  Branch (1332:14): [True: 0, False: 0]
  ------------------
 1333|      4|             strncmp(cptr2, persfile, strlen(persfile)) == 0)) {
  ------------------
  |  Branch (1333:14): [True: 0, False: 0]
  ------------------
 1334|      4|            DEBUGMSGTL(("read_config:persist", " persist dir: %s\n", cptr2 ));
  ------------------
  |  |   66|      4|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      4|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 4, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      4|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      4|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      4|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      4|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 4]
  |  |  ------------------
  ------------------
 1335|       |            /*
 1336|       |             * limit this to the known storage directory only 
 1337|       |             */
 1338|      4|            for (j = 0; j <= NETSNMP_MAX_PERSISTENT_BACKUPS; j++) {
  ------------------
  |  | 2015|      4|#define NETSNMP_MAX_PERSISTENT_BACKUPS 10
  ------------------
  |  Branch (1338:25): [True: 4, False: 0]
  ------------------
 1339|      4|                snprintf(configfile, sizeof(configfile),
 1340|      4|                         "%s/%s.%d.conf", cptr2,
 1341|      4|                         ctmp->fileHeader, j);
 1342|      4|                if (stat(configfile, &statbuf) != 0) {
  ------------------
  |  Branch (1342:21): [True: 4, False: 0]
  ------------------
 1343|       |                    /*
 1344|       |                     * file not there, continue 
 1345|       |                     */
 1346|      4|                    break;
 1347|      4|                } else {
 1348|       |                    /*
 1349|       |                     * backup exists, read it 
 1350|       |                     */
 1351|      0|                    DEBUGMSGTL(("read_config_files",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1352|      0|                                "old config file found: %s, parsing\n",
 1353|      0|                                configfile));
 1354|      0|                    if (read_config(configfile, ctmp->start, when) == SNMPERR_SUCCESS)
  ------------------
  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  |  Branch (1354:25): [True: 0, False: 0]
  ------------------
 1355|      0|                        ret = SNMPERR_SUCCESS;
  ------------------
  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 1356|      0|                }
 1357|      4|            }
 1358|      4|        }
 1359|      4|        snprintf(configfile, sizeof(configfile),
 1360|      4|                 "%s/%s.conf", cptr2, ctmp->fileHeader);
 1361|      4|        if (read_config(configfile, ctmp->start, when) == SNMPERR_SUCCESS)
  ------------------
  |  |  184|      4|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  |  Branch (1361:13): [True: 0, False: 4]
  ------------------
 1362|      0|            ret = SNMPERR_SUCCESS;
  ------------------
  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 1363|      4|        snprintf(configfile, sizeof(configfile),
 1364|      4|                 "%s/%s.local.conf", cptr2, ctmp->fileHeader);
 1365|      4|        if (read_config(configfile, ctmp->start, when) == SNMPERR_SUCCESS)
  ------------------
  |  |  184|      4|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  |  Branch (1365:13): [True: 0, False: 4]
  ------------------
 1366|      0|            ret = SNMPERR_SUCCESS;
  ------------------
  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 1367|       |
 1368|      4|        if(done)
  ------------------
  |  Branch (1368:12): [True: 4, False: 0]
  ------------------
 1369|      4|            break;
 1370|       |
 1371|      0|        cptr2 = ++cptr1;
 1372|      0|    }
 1373|       |    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, False: 8]
  |  |  ------------------
  ------------------
 1374|      8|    return ret;
 1375|      8|}

sc_find_auth_alg_byoid:
  270|      2|{
  271|      2|    int i = 0;
  272|       |
  273|      2|    DEBUGTRACE;
  ------------------
  |  |   63|      2|#define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
  |  |  ------------------
  |  |  |  |  144|      2|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 2, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
  |  |  ------------------
  |  |  |  |  154|      2|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  ------------------
  |  |  |  |  |  |  147|      2|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  155|      2|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  ------------------
  |  |  |  Branch (63:67): [Folded, False: 2]
  |  |  ------------------
  ------------------
  274|       |
  275|      2|    if ((NULL == authoid) || (0 == len))
  ------------------
  |  Branch (275:9): [True: 0, False: 2]
  |  Branch (275:30): [True: 0, False: 2]
  ------------------
  276|      0|        return NULL;
  277|       |
  278|      6|    for( ; _auth_alg_info[i].type != -1; ++i) {
  ------------------
  |  Branch (278:12): [True: 6, False: 0]
  ------------------
  279|      6|        if (len != _auth_alg_info[i].oid_len)
  ------------------
  |  Branch (279:13): [True: 0, False: 6]
  ------------------
  280|      0|            continue;
  281|      6|        if (snmp_oid_compare(_auth_alg_info[i].alg_oid,
  ------------------
  |  Branch (281:13): [True: 2, False: 4]
  ------------------
  282|      6|                             _auth_alg_info[i].oid_len,
  283|      6|                             authoid, len) == 0 )
  284|      2|            return(&_auth_alg_info[i]);
  285|      6|    }
  286|       |
  287|       |/*    DEBUGMSGTL(("scapi", "No auth alg found for"));
  288|       |      DEBUGMSGOID(("scapi", authoid, len ));*/
  289|       |
  290|      0|    return NULL;
  291|      2|}
sc_find_auth_alg_bytype:
  317|      2|{
  318|      2|    int i = 0;
  319|       |
  320|      2|    DEBUGTRACE;
  ------------------
  |  |   63|      2|#define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
  |  |  ------------------
  |  |  |  |  144|      2|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 2, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
  |  |  ------------------
  |  |  |  |  154|      2|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  ------------------
  |  |  |  |  |  |  147|      2|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  155|      2|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  ------------------
  |  |  |  Branch (63:67): [Folded, False: 2]
  |  |  ------------------
  ------------------
  321|       |
  322|      6|    for( ; _auth_alg_info[i].type != -1; ++i) {
  ------------------
  |  Branch (322:12): [True: 6, False: 0]
  ------------------
  323|      6|        if (type != _auth_alg_info[i].type)
  ------------------
  |  Branch (323:13): [True: 4, False: 2]
  ------------------
  324|      4|            continue;
  325|      2|        return(&_auth_alg_info[i]);
  326|      6|    }
  327|       |
  328|      0|    return NULL;
  329|      2|}
sc_get_authtype:
  342|      2|{
  343|      2|    const netsnmp_auth_alg_info *aai;
  344|       |
  345|      2|    DEBUGTRACE;
  ------------------
  |  |   63|      2|#define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
  |  |  ------------------
  |  |  |  |  144|      2|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 2, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
  |  |  ------------------
  |  |  |  |  154|      2|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  ------------------
  |  |  |  |  |  |  147|      2|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  155|      2|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  ------------------
  |  |  |  Branch (63:67): [Folded, False: 2]
  |  |  ------------------
  ------------------
  346|       |
  347|      2|    aai = sc_find_auth_alg_byoid(hashtype, hashtype_len);
  348|      2|    if (NULL == aai)
  ------------------
  |  Branch (348:9): [True: 0, False: 2]
  ------------------
  349|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  350|       |
  351|      2|    return aai->type;
  352|      2|}
sc_get_proper_auth_length_bytype:
  399|      2|{
  400|      2|    const netsnmp_auth_alg_info *aai;
  401|       |
  402|      2|    DEBUGTRACE;
  ------------------
  |  |   63|      2|#define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
  |  |  ------------------
  |  |  |  |  144|      2|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 2, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
  |  |  ------------------
  |  |  |  |  154|      2|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  ------------------
  |  |  |  |  |  |  147|      2|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  155|      2|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  ------------------
  |  |  |  Branch (63:67): [Folded, False: 2]
  |  |  ------------------
  ------------------
  403|       |
  404|      2|    aai = sc_find_auth_alg_bytype(hashtype);
  405|      2|    if (NULL == aai)
  ------------------
  |  Branch (405:9): [True: 0, False: 2]
  ------------------
  406|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  407|       |
  408|      2|    return aai->proper_length;
  409|      2|}
sc_init:
  569|      1|{
  570|      1|    int             rval = SNMPERR_SUCCESS;
  ------------------
  |  |  184|      1|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  571|       |
  572|      1|#if defined(NETSNMP_USE_OPENSSL)
  573|       |#if defined(HAVE_OPENSSL_PROVIDER_H)
  574|       |    if (legacy_provider == NULL)
  575|       |        legacy_provider = OSSL_PROVIDER_load(NULL, "legacy");
  576|       |    if (default_provider == NULL)
  577|       |        default_provider = OSSL_PROVIDER_load(NULL, "default");
  578|       |    snmp_register_callback(SNMP_CALLBACK_LIBRARY,
  579|       |                           SNMP_CALLBACK_SHUTDOWN,
  580|       |                           sc_shutdown, NULL);
  581|       |#endif
  582|       |#else /* !NETSNMP_USE_OPENSSL */
  583|       |#if defined(NETSNMP_USE_INTERNAL_MD5) || defined(NETSNMP_USE_INTERNAL_CRYPTO)
  584|       |    struct timeval  tv;
  585|       |
  586|       |    DEBUGTRACE;
  587|       |
  588|       |    gettimeofday(&tv, (struct timezone *) 0);
  589|       |
  590|       |    netsnmp_srandom((unsigned)(tv.tv_sec ^ tv.tv_usec));
  591|       |#elif defined(NETSNMP_USE_PKCS11)
  592|       |    DEBUGTRACE;
  593|       |    rval = pkcs_init();
  594|       |#else
  595|       |    rval = SNMPERR_SC_NOT_CONFIGURED;
  596|       |#endif                           /* NETSNMP_USE_INTERNAL_MD5 */
  597|       |    /*
  598|       |     * XXX ogud: The only reason to do anything here with openssl is to 
  599|       |     * * XXX ogud: seed random number generator 
  600|       |     */
  601|       |#endif                          /* NETSNMP_USE_OPENSSL */
  602|       |
  603|      1|    return rval;
  604|      1|}                               /* end sc_init() */
sc_random:
  619|      3|{
  620|      3|    int             rval = SNMPERR_SUCCESS;
  ------------------
  |  |  184|      3|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  621|       |#if !defined(NETSNMP_USE_OPENSSL) && !defined(NETSNMP_USE_PKCS11)
  622|       |    int             i;
  623|       |    int             rndval;
  624|       |    u_char         *ucp = buf;
  625|       |#endif
  626|       |
  627|      3|    DEBUGTRACE;
  ------------------
  |  |   63|      3|#define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
  |  |  ------------------
  |  |  |  |  144|      3|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 3, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
  |  |  ------------------
  |  |  |  |  154|      3|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  ------------------
  |  |  |  |  |  |  147|      3|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  155|      3|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  ------------------
  |  |  |  Branch (63:67): [Folded, False: 3]
  |  |  ------------------
  ------------------
  628|       |
  629|      3|#ifdef NETSNMP_USE_OPENSSL
  630|      3|    RAND_bytes(buf, *buflen);   /* will never fail */
  631|      3|    MAKE_MEM_DEFINED(buf, *buflen);
  ------------------
  |  |    8|      3|#define MAKE_MEM_DEFINED(ptr, len) do { } while (0)
  |  |  ------------------
  |  |  |  Branch (8:50): [Folded, False: 3]
  |  |  ------------------
  ------------------
  632|       |#elif defined(NETSNMP_USE_PKCS11)  /* NETSNMP_USE_PKCS11 */
  633|       |    pkcs_random(buf, *buflen);
  634|       |#else                           /* NETSNMP_USE_INTERNAL_MD5 */
  635|       |    /*
  636|       |     * fill the buffer with random integers.  Note that random()
  637|       |     * is defined in config.h and may not be truly the random()
  638|       |     * system call if something better existed 
  639|       |     */
  640|       |    rval = *buflen - *buflen % sizeof(rndval);
  641|       |    for (i = 0; i < rval; i += sizeof(rndval)) {
  642|       |        rndval = netsnmp_random();
  643|       |        memcpy(ucp, &rndval, sizeof(rndval));
  644|       |        ucp += sizeof(rndval);
  645|       |    }
  646|       |
  647|       |    rndval = netsnmp_random();
  648|       |    memcpy(ucp, &rndval, *buflen % sizeof(rndval));
  649|       |
  650|       |    rval = SNMPERR_SUCCESS;
  651|       |#endif                          /* NETSNMP_USE_OPENSSL */
  652|      3|    return rval;
  653|       |
  654|      3|}                               /* end sc_random() */
sc_get_openssl_hashfn:
  664|      2|{
  665|      2|    const EVP_MD   *hashfn = NULL;
  666|       |
  667|      2|    DEBUGTRACE;
  ------------------
  |  |   63|      2|#define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
  |  |  ------------------
  |  |  |  |  144|      2|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 2, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
  |  |  ------------------
  |  |  |  |  154|      2|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  ------------------
  |  |  |  |  |  |  147|      2|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  155|      2|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  ------------------
  |  |  |  Branch (63:67): [Folded, False: 2]
  |  |  ------------------
  ------------------
  668|       |
  669|      2|    switch (auth_type) {
  ------------------
  |  Branch (669:13): [True: 2, False: 0]
  ------------------
  670|      0|#ifndef NETSNMP_DISABLE_MD5
  671|      2|        case NETSNMP_USMAUTH_HMACMD5:
  ------------------
  |  |   21|      2|#define NETSNMP_USMAUTH_HMACMD5           2
  ------------------
  |  Branch (671:9): [True: 2, False: 0]
  ------------------
  672|      2|            hashfn = (const EVP_MD *) EVP_md5();
  673|      2|            break;
  674|      0|#endif
  675|      0|        case NETSNMP_USMAUTH_HMACSHA1:
  ------------------
  |  |   22|      0|#define NETSNMP_USMAUTH_HMACSHA1          3
  ------------------
  |  Branch (675:9): [True: 0, False: 2]
  ------------------
  676|      0|            hashfn = (const EVP_MD *) EVP_sha1();
  677|      0|            break;
  678|       |
  679|      0|#ifdef HAVE_EVP_SHA224
  680|      0|        case NETSNMP_USMAUTH_HMAC128SHA224:
  ------------------
  |  |   24|      0|#define NETSNMP_USMAUTH_HMAC128SHA224     4 /* RFC 7860; OPTIONAL */
  ------------------
  |  Branch (680:9): [True: 0, False: 2]
  ------------------
  681|      0|            hashfn = (const EVP_MD *) EVP_sha224();
  682|      0|            break;
  683|       |
  684|      0|        case NETSNMP_USMAUTH_HMAC192SHA256:
  ------------------
  |  |   25|      0|#define NETSNMP_USMAUTH_HMAC192SHA256     5 /* RFC 7860; MUST */
  ------------------
  |  Branch (684:9): [True: 0, False: 2]
  ------------------
  685|      0|            hashfn = (const EVP_MD *) EVP_sha256();
  686|      0|            break;
  687|      0|#endif /* HAVE_EVP_SHA224 */
  688|       |
  689|      0|#ifdef HAVE_EVP_SHA384
  690|      0|        case NETSNMP_USMAUTH_HMAC256SHA384:
  ------------------
  |  |   26|      0|#define NETSNMP_USMAUTH_HMAC256SHA384     6 /* RFC 7860; OPTIONAL */
  ------------------
  |  Branch (690:9): [True: 0, False: 2]
  ------------------
  691|      0|            hashfn = (const EVP_MD *) EVP_sha384();
  692|      0|            break;
  693|       |
  694|      0|        case NETSNMP_USMAUTH_HMAC384SHA512:
  ------------------
  |  |   27|      0|#define NETSNMP_USMAUTH_HMAC384SHA512     7 /* RFC 7860; SHOULD */
  ------------------
  |  Branch (694:9): [True: 0, False: 2]
  ------------------
  695|      0|            hashfn = (const EVP_MD *) EVP_sha512();
  696|      0|            break;
  697|      2|#endif /* HAVE_EVP_SHA384 */
  698|      2|    }
  699|       |
  700|      2|    return hashfn;
  701|      2|}
sc_hash:
  924|      2|{
  925|      2|    int auth_type;
  926|       |
  927|      2|    DEBUGTRACE;
  ------------------
  |  |   63|      2|#define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
  |  |  ------------------
  |  |  |  |  144|      2|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 2, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
  |  |  ------------------
  |  |  |  |  154|      2|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  ------------------
  |  |  |  |  |  |  147|      2|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  155|      2|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  ------------------
  |  |  |  Branch (63:67): [Folded, False: 2]
  |  |  ------------------
  ------------------
  928|       |
  929|      2|    if (hashtype == NULL)
  ------------------
  |  Branch (929:9): [True: 0, False: 2]
  ------------------
  930|      0|        return (SNMPERR_GENERR);
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  931|       |
  932|      2|    auth_type = sc_get_authtype(hashtype, hashtypelen);
  933|      2|    if (auth_type < 0 )
  ------------------
  |  Branch (933:9): [True: 0, False: 2]
  ------------------
  934|      0|        return (SNMPERR_GENERR);
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  935|       |
  936|      2|    return sc_hash_type(auth_type, buf, buf_len, MAC, MAC_len);
  937|      2|}
sc_hash_type:
  963|      2|{
  964|      2|#if defined(NETSNMP_USE_OPENSSL) || defined(NETSNMP_USE_PKCS11) || defined(NETSNMP_USE_INTERNAL_CRYPTO)
  965|      2|    int            rval = SNMPERR_SUCCESS;
  ------------------
  |  |  184|      2|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  966|      2|#endif
  967|      2|#if defined(NETSNMP_USE_OPENSSL) || defined(NETSNMP_USE_PKCS11)
  968|      2|    unsigned int   tmp_len;
  969|      2|#endif
  970|      2|    int            ret;
  971|       |
  972|      2|#ifdef NETSNMP_USE_OPENSSL
  973|      2|    const EVP_MD   *hashfn;
  974|      2|    EVP_MD_CTX     *cptr;
  975|      2|#endif
  976|       |#ifdef NETSNMP_USE_INTERNAL_CRYPTO
  977|       |    MD5_CTX        cmd5;
  978|       |    SHA_CTX        csha1;
  979|       |#endif
  980|      2|    DEBUGTRACE;
  ------------------
  |  |   63|      2|#define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
  |  |  ------------------
  |  |  |  |  144|      2|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 2, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
  |  |  ------------------
  |  |  |  |  154|      2|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  ------------------
  |  |  |  |  |  |  147|      2|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  155|      2|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  ------------------
  |  |  |  Branch (63:67): [Folded, False: 2]
  |  |  ------------------
  ------------------
  981|       |
  982|      2|    if (buf == NULL || buf_len <= 0 || MAC == NULL || MAC_len == NULL )
  ------------------
  |  Branch (982:9): [True: 0, False: 2]
  |  Branch (982:24): [True: 0, False: 2]
  |  Branch (982:40): [True: 0, False: 2]
  |  Branch (982:55): [True: 0, False: 2]
  ------------------
  983|      0|        return (SNMPERR_GENERR);
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  984|       |
  985|      2|    ret = sc_get_proper_auth_length_bytype(auth_type);
  986|      2|    if (( ret < 0 ) || (*MAC_len < (size_t)ret ))
  ------------------
  |  Branch (986:9): [True: 0, False: 2]
  |  Branch (986:24): [True: 0, False: 2]
  ------------------
  987|      0|        return (SNMPERR_GENERR);
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  988|       |
  989|      2|#ifdef NETSNMP_USE_OPENSSL
  990|       |    /*
  991|       |     * Determine transform type.
  992|       |     */
  993|      2|    hashfn = sc_get_openssl_hashfn(auth_type);
  994|      2|    if (NULL == hashfn)
  ------------------
  |  Branch (994:9): [True: 0, False: 2]
  ------------------
  995|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  996|       |
  997|       |/** initialize the pointer */
  998|      2|#if defined(HAVE_EVP_MD_CTX_NEW)
  999|      2|    cptr = EVP_MD_CTX_new();
 1000|       |#elif defined(HAVE_EVP_MD_CTX_CREATE)
 1001|       |    cptr = EVP_MD_CTX_create();
 1002|       |#else
 1003|       |    cptr = malloc(sizeof(*cptr));
 1004|       |#if defined(OLD_DES)
 1005|       |    memset(cptr, 0, sizeof(*cptr));
 1006|       |#else
 1007|       |    EVP_MD_CTX_init(cptr);
 1008|       |#endif
 1009|       |#endif
 1010|      2|    if (!EVP_DigestInit(cptr, hashfn)) {
  ------------------
  |  Branch (1010:9): [True: 0, False: 2]
  ------------------
 1011|       |        /* requested hash function is not available */
 1012|      0|        rval = SNMPERR_SC_NOT_CONFIGURED;
  ------------------
  |  |  223|      0|#define SNMPERR_SC_NOT_CONFIGURED	(-39)
  ------------------
 1013|      0|        goto sc_hash_type_quit;
 1014|      0|    }
 1015|       |
 1016|       |/** pass the data */
 1017|      2|    EVP_DigestUpdate(cptr, buf, buf_len);
 1018|       |
 1019|       |/** do the final pass */
 1020|      2|    EVP_DigestFinal(cptr, MAC, &tmp_len);
 1021|      2|    *MAC_len = tmp_len;
 1022|       |
 1023|      2|sc_hash_type_quit:
 1024|      2|#if defined(HAVE_EVP_MD_CTX_FREE)
 1025|      2|    EVP_MD_CTX_free(cptr);
 1026|       |#elif defined(HAVE_EVP_MD_CTX_DESTROY)
 1027|       |    EVP_MD_CTX_destroy(cptr);
 1028|       |#else
 1029|       |#if !defined(OLD_DES)
 1030|       |    EVP_MD_CTX_cleanup(cptr);
 1031|       |#endif
 1032|       |    free(cptr);
 1033|       |#endif
 1034|      2|    return (rval);
 1035|       |
 1036|       |#elif defined(NETSNMP_USE_INTERNAL_CRYPTO)
 1037|       |#ifndef NETSNMP_DISABLE_MD5
 1038|       |    if (NETSNMP_USMAUTH_HMACMD5 == auth_type) {
 1039|       |        if (*MAC_len < MD5_DIGEST_LENGTH)
 1040|       |            return (SNMPERR_GENERR);      /* the buffer isn't big enough */
 1041|       |        MD5_Init(&cmd5);
 1042|       |        ret = !MD5_Update(&cmd5, buf, buf_len);
 1043|       |        if (ret != 0)
 1044|       |            return SNMPERR_GENERR;
 1045|       |        MD5_Final(MAC, &cmd5);
 1046|       |        *MAC_len = MD5_DIGEST_LENGTH;
 1047|       |    } else 
 1048|       |#endif
 1049|       |    if (NETSNMP_USMAUTH_HMACSHA1 == auth_type) {
 1050|       |        if (*MAC_len < SHA_DIGEST_LENGTH)
 1051|       |            return (SNMPERR_GENERR);      /* the buffer isn't big enough */
 1052|       |        SHA1_Init(&csha1);
 1053|       |        ret = !SHA1_Update(&csha1, buf, buf_len);
 1054|       |        if (ret != 0)
 1055|       |            return SNMPERR_GENERR;
 1056|       |        SHA1_Final(MAC, &csha1);
 1057|       |        *MAC_len = SHA_DIGEST_LENGTH;
 1058|       |            
 1059|       |    } else {
 1060|       |        return (SNMPERR_GENERR);
 1061|       |    }
 1062|       |    return (rval);
 1063|       |#elif defined(NETSNMP_USE_PKCS11)        /* NETSNMP_USE_PKCS11 */
 1064|       |
 1065|       |#ifndef NETSNMP_DISABLE_MD5
 1066|       |    if (NETSNMP_USMAUTH_HMACMD5 == auth_type) {
 1067|       |        rval = pkcs_digest(CKM_MD5, buf, buf_len, MAC, &tmp_len);
 1068|       |        *MAC_len = tmp_len;
 1069|       |    } else
 1070|       |#endif
 1071|       |    if (NETSNMP_USMAUTH_HMACSHA1 == auth_type) {
 1072|       |       rval = pkcs_digest(CKM_SHA_1, buf, buf_len, MAC, &tmp_len);
 1073|       |        *MAC_len = tmp_len;
 1074|       |    } else {
 1075|       |        return (SNMPERR_GENERR);
 1076|       |    }
 1077|       |
 1078|       |     return (rval);
 1079|       |
 1080|       |#else                           /* NETSNMP_USE_INTERNAL_MD5 */
 1081|       |
 1082|       |    if (MDchecksum(buf, buf_len, MAC, *MAC_len)) {
 1083|       |        return SNMPERR_GENERR;
 1084|       |    }
 1085|       |    if (*MAC_len > 16)
 1086|       |        *MAC_len = 16;
 1087|       |    return SNMPERR_SUCCESS;
 1088|       |
 1089|       |#endif                          /* NETSNMP_USE_OPENSSL */
 1090|      2|}

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

init_alarm_post_config:
   63|      1|{
   64|      1|    start_alarms = 1;
   65|      1|    set_an_alarm();
   66|      1|    return SNMPERR_SUCCESS;
  ------------------
  |  |  184|      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|       |                           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]
  |  Branch (174:35): [True: 0, False: 0]
  |  Branch (174:35): [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
  |  |  |  |  ------------------
  |  |  |  |  |  | 1705|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|      0|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded, False: 0]
  |  |  ------------------
  ------------------
  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]
  |  |  ------------------
  |  |   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
  |  |  |  |  ------------------
  |  |  |  |  |  | 1705|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|      0|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded, False: 0]
  |  |  ------------------
  ------------------
  261|      0|        if (timercmp(&sa_ptr->t_nextM, now, >))
  ------------------
  |  Branch (261:13): [True: 0, False: 0]
  |  Branch (261:13): [True: 0, False: 0]
  ------------------
  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, False: 0]
  |  |  ------------------
  ------------------
  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",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
  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"));
  ------------------
  |  |   66|      1|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      1|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      1|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      1|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      1|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 1]
  |  |  ------------------
  ------------------
  327|      1|    }
  328|      1|}

netsnmp_max_send_msg_size:
  382|    162|{
  383|    162|    u_int max = netsnmp_ds_get_int(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|    162|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  384|    162|                                   NETSNMP_DS_LIB_MSG_SEND_MAX);
  ------------------
  |  |  132|    162|#define NETSNMP_DS_LIB_MSG_SEND_MAX        16 /* global max response size */
  ------------------
  385|    162|    if (0 == max)
  ------------------
  |  Branch (385:9): [True: 162, False: 0]
  ------------------
  386|    162|        max = SNMP_MAX_PACKET_LEN;
  ------------------
  |  |   49|    162|#define SNMP_MAX_PACKET_LEN (0x7fffffff)
  ------------------
  387|      0|    else if (max < SNMP_MIN_MAX_LEN)
  ------------------
  |  |   48|      0|#define SNMP_MIN_MAX_LEN    484 /* minimum maximum message size */
  ------------------
  |  Branch (387:14): [True: 0, False: 0]
  ------------------
  388|      0|        max = SNMP_MIN_MAX_LEN; /* minimum max size per SNMP specs */
  ------------------
  |  |   48|      0|#define SNMP_MIN_MAX_LEN    484 /* minimum maximum message size */
  ------------------
  389|      0|    else if (max > SNMP_MAX_PACKET_LEN)
  ------------------
  |  |   49|      0|#define SNMP_MAX_PACKET_LEN (0x7fffffff)
  ------------------
  |  Branch (389:14): [True: 0, False: 0]
  ------------------
  390|      0|        max = SNMP_MAX_PACKET_LEN;
  ------------------
  |  |   49|      0|#define SNMP_MAX_PACKET_LEN (0x7fffffff)
  ------------------
  391|       |
  392|    162|    return max;
  393|    162|}
snmp_pdu_type:
  410|  6.32k|{
  411|  6.32k|    static char unknown[20];
  412|  6.32k|    switch(type) {
  413|    200|    case SNMP_MSG_GET:
  ------------------
  |  |  125|    200|#define SNMP_MSG_GET        (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x0) /* a0=160 */
  |  |  ------------------
  |  |  |  |   92|    200|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_MSG_GET        (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x0) /* a0=160 */
  |  |  ------------------
  |  |  |  |   96|    200|#define ASN_CONSTRUCTOR	    0x20U
  |  |  ------------------
  ------------------
  |  Branch (413:5): [True: 200, False: 6.12k]
  ------------------
  414|    200|        return "GET";
  415|      0|    case SNMP_MSG_GETNEXT:
  ------------------
  |  |  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 (415:5): [True: 0, False: 6.32k]
  ------------------
  416|      0|        return "GETNEXT";
  417|     56|    case SNMP_MSG_GETBULK:
  ------------------
  |  |  140|     56|#define SNMP_MSG_GETBULK    (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x5) /* a5=165 */
  |  |  ------------------
  |  |  |  |   92|     56|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_MSG_GETBULK    (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x5) /* a5=165 */
  |  |  ------------------
  |  |  |  |   96|     56|#define ASN_CONSTRUCTOR	    0x20U
  |  |  ------------------
  ------------------
  |  Branch (417:5): [True: 56, False: 6.26k]
  ------------------
  418|     56|        return "GETBULK";
  419|      0|#ifndef NETSNMP_NO_WRITE_SUPPORT
  420|      0|    case SNMP_MSG_SET:
  ------------------
  |  |  129|      0|#define SNMP_MSG_SET        (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x3) /* a3=163 */
  |  |  ------------------
  |  |  |  |   92|      0|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_MSG_SET        (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x3) /* a3=163 */
  |  |  ------------------
  |  |  |  |   96|      0|#define ASN_CONSTRUCTOR	    0x20U
  |  |  ------------------
  ------------------
  |  Branch (420:5): [True: 0, False: 6.32k]
  ------------------
  421|      0|        return "SET";
  422|      0|#endif /* !NETSNMP_NO_WRITE_SUPPORT */
  423|    110|    case SNMP_MSG_RESPONSE:
  ------------------
  |  |  127|    110|#define SNMP_MSG_RESPONSE   (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x2) /* a2=162 */
  |  |  ------------------
  |  |  |  |   92|    110|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_MSG_RESPONSE   (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x2) /* a2=162 */
  |  |  ------------------
  |  |  |  |   96|    110|#define ASN_CONSTRUCTOR	    0x20U
  |  |  ------------------
  ------------------
  |  Branch (423:5): [True: 110, False: 6.21k]
  ------------------
  424|    110|        return "RESPONSE";
  425|  5.75k|    case SNMP_MSG_TRAP:
  ------------------
  |  |  135|  5.75k|#define SNMP_MSG_TRAP       (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x4) /* a4=164 */
  |  |  ------------------
  |  |  |  |   92|  5.75k|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_MSG_TRAP       (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x4) /* a4=164 */
  |  |  ------------------
  |  |  |  |   96|  5.75k|#define ASN_CONSTRUCTOR	    0x20U
  |  |  ------------------
  ------------------
  |  Branch (425:5): [True: 5.75k, False: 574]
  ------------------
  426|  5.75k|        return "TRAP";
  427|      0|    case SNMP_MSG_INFORM:
  ------------------
  |  |  141|      0|#define SNMP_MSG_INFORM     (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x6) /* a6=166 */
  |  |  ------------------
  |  |  |  |   92|      0|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_MSG_INFORM     (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x6) /* a6=166 */
  |  |  ------------------
  |  |  |  |   96|      0|#define ASN_CONSTRUCTOR	    0x20U
  |  |  ------------------
  ------------------
  |  Branch (427:5): [True: 0, False: 6.32k]
  ------------------
  428|      0|        return "INFORM";
  429|      0|    case SNMP_MSG_TRAP2:
  ------------------
  |  |  142|      0|#define SNMP_MSG_TRAP2      (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x7) /* a7=167 */
  |  |  ------------------
  |  |  |  |   92|      0|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_MSG_TRAP2      (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x7) /* a7=167 */
  |  |  ------------------
  |  |  |  |   96|      0|#define ASN_CONSTRUCTOR	    0x20U
  |  |  ------------------
  ------------------
  |  Branch (429:5): [True: 0, False: 6.32k]
  ------------------
  430|      0|        return "TRAP2";
  431|      0|    case 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 (431:5): [True: 0, False: 6.32k]
  ------------------
  432|      0|        return "REPORT";
  433|    208|    default:
  ------------------
  |  Branch (433:5): [True: 208, False: 6.11k]
  ------------------
  434|    208|        snprintf(unknown, sizeof(unknown), "?0x%2X?", type);
  435|    208|	return unknown;
  436|  6.32k|    }
  437|  6.32k|}
snmp_get_next_sessid:
  486|     81|{
  487|     81|    long            retVal;
  488|     81|    snmp_res_lock(MT_LIBRARY_ID, MT_LIB_SESSIONID);
  ------------------
  |  |   79|     81|#define snmp_res_lock(x,y) do {} while (0)
  |  |  ------------------
  |  |  |  Branch (79:41): [Folded, False: 81]
  |  |  ------------------
  ------------------
  489|     81|    retVal = 1 + Sessid;        /*MTCRITICAL_RESOURCE */
  490|     81|    if (!retVal)
  ------------------
  |  Branch (490:9): [True: 0, False: 81]
  ------------------
  491|      0|        retVal = 2;
  492|     81|    Sessid = retVal;
  493|     81|    if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_16BIT_IDS))
  ------------------
  |  |   48|     81|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                  if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_16BIT_IDS))
  ------------------
  |  |   91|     81|#define NETSNMP_DS_LIB_16BIT_IDS           31   /* restrict requestIDs, etc to 16-bit values */
  ------------------
  |  Branch (493:9): [True: 0, False: 81]
  ------------------
  494|      0|        retVal &= 0x7fff;	/* mask to 15 bits */
  495|     81|    else
  496|     81|        retVal &= 0x7fffffff;	/* mask to 31 bits */
  497|       |
  498|     81|    if (!retVal) {
  ------------------
  |  Branch (498:9): [True: 0, False: 81]
  ------------------
  499|      0|        Sessid = retVal = 2;
  500|      0|    }
  501|     81|    snmp_res_unlock(MT_LIBRARY_ID, MT_LIB_SESSIONID);
  ------------------
  |  |   80|     81|#define snmp_res_unlock(x,y) do {} while (0)
  |  |  ------------------
  |  |  |  Branch (80:43): [Folded, False: 81]
  |  |  ------------------
  ------------------
  502|     81|    return retVal;
  503|     81|}
snmp_get_next_transid:
  507|  18.2k|{
  508|  18.2k|    long            retVal;
  509|  18.2k|    snmp_res_lock(MT_LIBRARY_ID, MT_LIB_TRANSID);
  ------------------
  |  |   79|  18.2k|#define snmp_res_lock(x,y) do {} while (0)
  |  |  ------------------
  |  |  |  Branch (79:41): [Folded, False: 18.2k]
  |  |  ------------------
  ------------------
  510|  18.2k|    retVal = 1 + Transid;       /*MTCRITICAL_RESOURCE */
  511|  18.2k|    if (!retVal)
  ------------------
  |  Branch (511:9): [True: 0, False: 18.2k]
  ------------------
  512|      0|        retVal = 2;
  513|  18.2k|    Transid = retVal;
  514|  18.2k|    if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_16BIT_IDS))
  ------------------
  |  |   48|  18.2k|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                  if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_16BIT_IDS))
  ------------------
  |  |   91|  18.2k|#define NETSNMP_DS_LIB_16BIT_IDS           31   /* restrict requestIDs, etc to 16-bit values */
  ------------------
  |  Branch (514:9): [True: 0, False: 18.2k]
  ------------------
  515|      0|        retVal &= 0x7fff;	/* mask to 15 bits */
  516|  18.2k|    else
  517|  18.2k|        retVal &= 0x7fffffff;	/* mask to 31 bits */
  518|       |
  519|  18.2k|    if (!retVal) {
  ------------------
  |  Branch (519:9): [True: 0, False: 18.2k]
  ------------------
  520|      0|        Transid = retVal = 2;
  521|      0|    }
  522|  18.2k|    snmp_res_unlock(MT_LIBRARY_ID, MT_LIB_TRANSID);
  ------------------
  |  |   80|  18.2k|#define snmp_res_unlock(x,y) do {} while (0)
  |  |  ------------------
  |  |  |  Branch (80:43): [Folded, False: 18.2k]
  |  |  ------------------
  ------------------
  523|  18.2k|    return retVal;
  524|  18.2k|}
snmp_set_detail:
  538|  7.89k|{
  539|  7.89k|    if (detail_string != NULL) {
  ------------------
  |  Branch (539:9): [True: 7.89k, False: 0]
  ------------------
  540|  7.89k|        strlcpy(snmp_detail, detail_string, sizeof(snmp_detail));
  541|  7.89k|        snmp_detail_f = 1;
  542|  7.89k|    }
  543|  7.89k|}
snmp_api_errstring:
  553|    183|{
  554|    183|    const char     *msg = "";
  555|    183|    static char     msg_buf[SPRINT_MAX_LEN];
  556|       |
  557|    183|    if (snmp_errnumber >= SNMPERR_MAX && snmp_errnumber <= SNMPERR_GENERR) {
  ------------------
  |  |  255|    366|#define SNMPERR_MAX			(-69)
  ------------------
                  if (snmp_errnumber >= SNMPERR_MAX && snmp_errnumber <= SNMPERR_GENERR) {
  ------------------
  |  |  185|    183|#define SNMPERR_GENERR			(-1)
  ------------------
  |  Branch (557:9): [True: 183, False: 0]
  |  Branch (557:42): [True: 0, False: 183]
  ------------------
  558|      0|        msg = api_errors[-snmp_errnumber];
  559|    183|    } else if (snmp_errnumber != SNMPERR_SUCCESS) {
  ------------------
  |  |  184|    183|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  |  Branch (559:16): [True: 0, False: 183]
  ------------------
  560|      0|        msg = NULL;
  561|      0|    }
  562|    183|    if (!msg) {
  ------------------
  |  Branch (562:9): [True: 0, False: 183]
  ------------------
  563|      0|	snprintf(msg_buf, sizeof(msg_buf), "Unknown error: %d", snmp_errnumber);
  564|      0|        msg_buf[sizeof(msg_buf)-1] = '\0';
  565|    183|    } else if (snmp_detail_f) {
  ------------------
  |  Branch (565:16): [True: 183, False: 0]
  ------------------
  566|    183|        snprintf(msg_buf, sizeof(msg_buf), "%s (%s)", msg, snmp_detail);
  567|    183|        msg_buf[sizeof(msg_buf)-1] = '\0';
  568|    183|        snmp_detail_f = 0;
  569|    183|    } else {
  570|      0|        strlcpy(msg_buf, msg, sizeof(msg_buf));
  571|      0|    }
  572|       |
  573|    183|    return (msg_buf);
  574|    183|}
netsnmp_random:
  661|      3|{
  662|      3|#if defined(HAVE_RANDOM)
  663|       |    /*
  664|       |     * The function random() is a more sophisticated random number generator
  665|       |     * which uses nonlinear feedback and an internal table that is 124 bytes
  666|       |     * (992 bits) long. The function returns random values that are 32 bits in
  667|       |     * length. All of the bits generated by random() are usable. The random()
  668|       |     * function is adequate for simulations and games, but should not be used
  669|       |     * for security related applications such as picking cryptographic keys or
  670|       |     * simulating one-time pads.
  671|       |     */
  672|      3|    return random();
  673|       |#elif defined(HAVE_LRAND48)
  674|       |    /*
  675|       |     * As with random(), lrand48() provides excellent random numbers for
  676|       |     * simulations and games, but should not be used for security-related
  677|       |     * applications such as picking cryptographic keys or simulating one-time
  678|       |     * pads; linear congruential algorithms are too easy to break.
  679|       |     */
  680|       |    return lrand48();
  681|       |#elif defined(HAVE_RAND)
  682|       |    /*
  683|       |     * The original UNIX random number generator, rand(), is not a very good
  684|       |     * random number generator. It uses a 32-bit seed and maintains a 32-bit
  685|       |     * internal state.
  686|       |     */
  687|       |    return rand();
  688|       |#else
  689|       |#error "Neither random(), nor lrand48() nor rand() are available"
  690|       |#endif
  691|      3|}
netsnmp_srandom:
  694|      1|{
  695|      1|#if defined(HAVE_SRANDOM)
  696|      1|    srandom(seed);
  697|       |#elif defined(HAVE_SRAND48)
  698|       |    srand48(seed);
  699|       |#elif defined(HAVE_SRAND)
  700|       |    srand(seed);
  701|       |#else
  702|       |#error "Neither srandom(), nor srand48() nor srand() are available"
  703|       |#endif
  704|      1|}
snmp_sess_init:
  797|     81|{
  798|     81|    _init_snmp();
  799|       |
  800|       |    /*
  801|       |     * initialize session to default values 
  802|       |     */
  803|       |
  804|     81|    memset(session, 0, sizeof(netsnmp_session));
  805|     81|    session->timeout = SNMP_DEFAULT_TIMEOUT;
  ------------------
  |  |   80|     81|#define SNMP_DEFAULT_TIMEOUT	    -1
  ------------------
  806|     81|    session->retries = SNMP_DEFAULT_RETRIES;
  ------------------
  |  |   79|     81|#define SNMP_DEFAULT_RETRIES	    -1
  ------------------
  807|     81|    session->version = SNMP_DEFAULT_VERSION;
  ------------------
  |  |   90|     81|#define SNMP_DEFAULT_VERSION	    -1
  ------------------
  808|     81|    session->securityModel = SNMP_DEFAULT_SECMODEL;
  ------------------
  |  |   91|     81|#define SNMP_DEFAULT_SECMODEL	    -1
  ------------------
  809|     81|    session->rcvMsgMaxSize = netsnmp_max_send_msg_size();
  810|     81|    session->sndMsgMaxSize = netsnmp_max_send_msg_size();
  811|     81|    session->flags |= SNMP_FLAGS_DONT_PROBE;
  ------------------
  |  |  155|     81|#define SNMP_FLAGS_DONT_PROBE      0x100      /* don't probe for an engineID */
  ------------------
  812|     81|}
init_snmp:
  901|     81|{
  902|     81|    if (init_snmp_init_done) {
  ------------------
  |  Branch (902:9): [True: 80, False: 1]
  ------------------
  903|     80|        return;
  904|     80|    }
  905|       |
  906|      1|    init_snmp_init_done = 1;
  907|       |
  908|       |    /*
  909|       |     * make the type available everywhere else 
  910|       |     */
  911|      1|    if (type && !netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (911:9): [True: 1, False: 0]
  |  Branch (911:17): [True: 1, False: 0]
  ------------------
  912|      1|				       NETSNMP_DS_LIB_APPTYPE)) {
  ------------------
  |  |  157|      1|#define NETSNMP_DS_LIB_APPTYPE           6
  ------------------
  913|      1|        netsnmp_ds_set_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  914|      1|			      NETSNMP_DS_LIB_APPTYPE, type);
  ------------------
  |  |  157|      1|#define NETSNMP_DS_LIB_APPTYPE           6
  ------------------
  915|      1|    }
  916|       |
  917|      1|    _init_snmp();
  918|       |
  919|       |    /*
  920|       |     * set our current locale properly to initialize isprint() type functions 
  921|       |     *
  922|       |     * Do not use setlocale on qnx, it is buggy 
  923|       |     * https://www.qnx.com/developers/docs/7.1/#com.qnx.doc.neutrino.lib_ref/topic/s/setlocale.html
  924|       |     */
  925|      1|#if defined(HAVE_SETLOCALE) && !defined(__QNX__)
  926|      1|    setlocale(LC_CTYPE, "");
  927|      1|#endif
  928|       |
  929|      1|    snmp_debug_init();    /* should be done first, to turn on debugging ASAP */
  930|      1|    netsnmp_container_init_list();
  931|      1|    init_callbacks();
  932|      1|    init_snmp_logging();
  933|      1|    snmp_init_statistics();
  934|      1|    register_mib_handlers();
  935|      1|    register_default_handlers();
  936|      1|    init_snmp_transport();
  937|      1|    init_snmpv3(type);
  938|      1|    init_snmp_alarm();
  939|      1|    init_snmp_enum(type);
  940|      1|    init_vacm();
  941|      1|#if defined(NETSNMP_USE_OPENSSL) && defined(HAVE_LIBSSL) && NETSNMP_TRANSPORT_TLSBASE_DOMAIN
  942|      1|    netsnmp_certs_init();
  943|      1|#endif
  944|       |#ifdef DNSSEC_LOCAL_VALIDATION
  945|       |    netsnmp_ds_register_config(ASN_BOOLEAN, "snmp", "dnssecWarnOnly",
  946|       |                               NETSNMP_DS_LIBRARY_ID,
  947|       |                               NETSNMP_DS_LIB_DNSSEC_WARN_ONLY);
  948|       |#endif
  949|       |
  950|      1|    read_premib_configs();
  951|      1|#ifndef NETSNMP_DISABLE_MIB_LOADING
  952|      1|    netsnmp_init_mib();
  953|      1|#endif /* NETSNMP_DISABLE_MIB_LOADING */
  954|       |
  955|      1|    read_configs();
  956|       |
  957|      1|}                               /* end init_snmp() */
snmp_session_insert:
 1039|     81|{
 1040|     81|    if (NULL == slp)
  ------------------
  |  Branch (1040:9): [True: 0, False: 81]
  ------------------
 1041|      0|        return;
 1042|       |
 1043|     81|    snmp_res_lock(MT_LIBRARY_ID, MT_LIB_SESSION);
  ------------------
  |  |   79|     81|#define snmp_res_lock(x,y) do {} while (0)
  |  |  ------------------
  |  |  |  Branch (79:41): [Folded, False: 81]
  |  |  ------------------
  ------------------
 1044|     81|    slp->next = Sessions;
 1045|     81|    Sessions = slp;
 1046|     81|    snmp_res_unlock(MT_LIBRARY_ID, MT_LIB_SESSION);
  ------------------
  |  |   80|     81|#define snmp_res_unlock(x,y) do {} while (0)
  |  |  ------------------
  |  |  |  Branch (80:43): [Folded, False: 81]
  |  |  ------------------
  ------------------
 1047|     81|}
netsnmp_sess_config_transport:
 1627|     81|{
 1628|       |    /* Optional supplemental transport configuration information and
 1629|       |       final call to actually open the transport */
 1630|     81|    if (transport_configuration) {
  ------------------
  |  Branch (1630:9): [True: 0, False: 81]
  ------------------
 1631|      0|        DEBUGMSGTL(("snmp_sess", "configuring transport\n"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1632|      0|        if (transport->f_config) {
  ------------------
  |  Branch (1632:13): [True: 0, False: 0]
  ------------------
 1633|      0|            netsnmp_iterator *iter;
 1634|      0|            netsnmp_transport_config *config_data;
 1635|      0|            int ret = 0;
 1636|       |
 1637|      0|            iter = CONTAINER_ITERATOR(transport_configuration);
  ------------------
  |  |  404|      0|#define CONTAINER_ITERATOR(x)       (x)->get_iterator(x)
  ------------------
 1638|      0|            if (NULL == iter) {
  ------------------
  |  Branch (1638:17): [True: 0, False: 0]
  ------------------
 1639|      0|                return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
 1640|      0|            }
 1641|       |
 1642|      0|            for(config_data = (netsnmp_transport_config*)ITERATOR_FIRST(iter); config_data;
  ------------------
  |  |  546|      0|#define ITERATOR_FIRST(x)  x->first(x)
  ------------------
  |  Branch (1642:80): [True: 0, False: 0]
  ------------------
 1643|      0|                config_data = (netsnmp_transport_config*)ITERATOR_NEXT(iter)) {
  ------------------
  |  |  547|      0|#define ITERATOR_NEXT(x)   x->next(x)
  ------------------
 1644|      0|                ret = transport->f_config(transport, config_data->key,
 1645|      0|                                          config_data->value);
 1646|      0|                if (ret)
  ------------------
  |  Branch (1646:21): [True: 0, False: 0]
  ------------------
 1647|      0|                    break;
 1648|      0|            }
 1649|      0|            ITERATOR_RELEASE(iter);
  ------------------
  |  |  550|      0|#define ITERATOR_RELEASE(x) do { x->release(x); x = NULL; } while(0)
  |  |  ------------------
  |  |  |  Branch (550:67): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1650|      0|            if (ret)
  ------------------
  |  Branch (1650:17): [True: 0, False: 0]
  ------------------
 1651|      0|                return SNMPERR_TRANSPORT_CONFIG_ERROR;
  ------------------
  |  |  252|      0|#define SNMPERR_TRANSPORT_CONFIG_ERROR  (-68)
  ------------------
 1652|      0|        } else {
 1653|      0|            return SNMPERR_TRANSPORT_NO_CONFIG;
  ------------------
  |  |  251|      0|#define SNMPERR_TRANSPORT_NO_CONFIG     (-67)
  ------------------
 1654|      0|        }
 1655|      0|    }
 1656|     81|    return SNMPERR_SUCCESS;
  ------------------
  |  |  184|     81|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 1657|     81|}
netsnmp_sess_config_and_open_transport:
 1689|     81|{
 1690|     81|    int rc;
 1691|       |    
 1692|     81|    DEBUGMSGTL(("snmp_sess", "opening transport: %x\n", transport->flags & NETSNMP_TRANSPORT_FLAG_OPENED));
  ------------------
  |  |   66|     81|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     81|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 81, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|     81|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|     81|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|     81|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|     81|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 81]
  |  |  ------------------
  ------------------
 1693|       |
 1694|       |    /* don't double open */
 1695|     81|    if (transport->flags & NETSNMP_TRANSPORT_FLAG_OPENED)
  ------------------
  |  |   57|     81|#define		NETSNMP_TRANSPORT_FLAG_OPENED	 0x20  /* f_open called */
  ------------------
  |  Branch (1695:9): [True: 0, False: 81]
  ------------------
 1696|      0|        return SNMPERR_SUCCESS;
  ------------------
  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 1697|       |
 1698|     81|    if ((rc = netsnmp_sess_config_transport(in_session->transport_configuration,
  ------------------
  |  Branch (1698:9): [True: 0, False: 81]
  ------------------
 1699|     81|                                            transport)) != SNMPERR_SUCCESS) {
  ------------------
  |  |  184|     81|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 1700|      0|        in_session->s_snmp_errno = rc;
 1701|      0|        in_session->s_errno = 0;
 1702|      0|        return rc;
 1703|      0|    }
 1704|       |        
 1705|     81|    if (transport->f_open)
  ------------------
  |  Branch (1705:9): [True: 0, False: 81]
  ------------------
 1706|      0|        transport = transport->f_open(transport);
 1707|       |
 1708|     81|    if (transport == NULL) {
  ------------------
  |  Branch (1708:9): [True: 0, False: 81]
  ------------------
 1709|      0|        DEBUGMSGTL(("snmp_sess", "couldn't open transport connection\n"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1710|      0|        in_session->s_snmp_errno = SNMPERR_BAD_ADDRESS;
  ------------------
  |  |  187|      0|#define SNMPERR_BAD_ADDRESS		(-3)
  ------------------
 1711|      0|        in_session->s_errno = errno;
 1712|      0|        snmp_set_detail(in_session->peername);
 1713|      0|        return SNMPERR_BAD_ADDRESS;
  ------------------
  |  |  187|      0|#define SNMPERR_BAD_ADDRESS		(-3)
  ------------------
 1714|      0|    }
 1715|       |
 1716|       |    /** if transport has a max size, make sure session is the same (or less) */
 1717|     81|    if (in_session->rcvMsgMaxSize > transport->msgMaxSize) {
  ------------------
  |  Branch (1717:9): [True: 81, False: 0]
  ------------------
 1718|     81|        DEBUGMSGTL(("snmp_sess",
  ------------------
  |  |   66|     81|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     81|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 81, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|     81|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|     81|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|     81|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|     81|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 81]
  |  |  ------------------
  ------------------
 1719|     81|                    "limiting session rcv size (%" NETSNMP_PRIz "d) to transport max (%" NETSNMP_PRIz "d)\n",
 1720|     81|                    in_session->rcvMsgMaxSize, transport->msgMaxSize));
 1721|     81|        in_session->rcvMsgMaxSize = transport->msgMaxSize;
 1722|     81|    }
 1723|       |
 1724|     81|    if (in_session->sndMsgMaxSize > transport->msgMaxSize) {
  ------------------
  |  Branch (1724:9): [True: 81, False: 0]
  ------------------
 1725|     81|        DEBUGMSGTL(("snmp_sess",
  ------------------
  |  |   66|     81|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     81|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 81, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|     81|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|     81|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|     81|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|     81|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 81]
  |  |  ------------------
  ------------------
 1726|     81|                    "limiting session snd size (%" NETSNMP_PRIz "d) to transport max (%" NETSNMP_PRIz "d)\n",
 1727|     81|                    in_session->sndMsgMaxSize, transport->msgMaxSize));
 1728|     81|        in_session->sndMsgMaxSize = transport->msgMaxSize;
 1729|     81|    }
 1730|       |
 1731|     81|    transport->flags |= NETSNMP_TRANSPORT_FLAG_OPENED;
  ------------------
  |  |   57|     81|#define		NETSNMP_TRANSPORT_FLAG_OPENED	 0x20  /* f_open called */
  ------------------
 1732|     81|    DEBUGMSGTL(("snmp_sess", "done opening transport: %x\n", transport->flags & NETSNMP_TRANSPORT_FLAG_OPENED));
  ------------------
  |  |   66|     81|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     81|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 81, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|     81|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|     81|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|     81|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|     81|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 81]
  |  |  ------------------
  ------------------
 1733|     81|    return SNMPERR_SUCCESS;
  ------------------
  |  |  184|     81|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 1734|     81|}
snmp_add:
 1848|     81|{
 1849|     81|    struct session_list *slp;
 1850|       |
 1851|     81|    slp = snmp_sess_add_ex(in_session, transport, fpre_parse, NULL,
 1852|     81|                           fpost_parse, NULL, NULL, NULL, NULL);
 1853|     81|    if (slp == NULL) {
  ------------------
  |  Branch (1853:9): [True: 0, False: 81]
  ------------------
 1854|      0|        return NULL;
 1855|      0|    }
 1856|       |
 1857|     81|    snmp_session_insert(slp);
 1858|       |
 1859|     81|    return (slp->session);
 1860|     81|}
snmp_sess_add_ex:
 1909|     81|{
 1910|     81|    struct session_list *slp;
 1911|     81|    int rc;
 1912|       |    
 1913|     81|    _init_snmp();
 1914|       |
 1915|     81|    if (transport == NULL)
  ------------------
  |  Branch (1915:9): [True: 0, False: 81]
  ------------------
 1916|      0|        return NULL;
 1917|       |
 1918|     81|    if (NULL != in_session && (in_session->rcvMsgMaxSize < SNMP_MIN_MAX_LEN ||
  ------------------
  |  |   48|    162|#define SNMP_MIN_MAX_LEN    484 /* minimum maximum message size */
  ------------------
  |  Branch (1918:9): [True: 81, False: 0]
  |  Branch (1918:32): [True: 0, False: 81]
  ------------------
 1919|     81|                               in_session->sndMsgMaxSize < SNMP_MIN_MAX_LEN)) {
  ------------------
  |  |   48|     81|#define SNMP_MIN_MAX_LEN    484 /* minimum maximum message size */
  ------------------
  |  Branch (1919:32): [True: 0, False: 81]
  ------------------
 1920|      0|        DEBUGMSGTL(("snmp_sess_add",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1921|      0|                    "invalid session (msg sizes). need snmp_sess_init"));
 1922|      0|        in_session = NULL; /* force transport cleanup below */
 1923|      0|    }
 1924|       |
 1925|     81|    if (in_session == NULL) {
  ------------------
  |  Branch (1925:9): [True: 0, False: 81]
  ------------------
 1926|      0|        transport->f_close(transport);
 1927|      0|        netsnmp_transport_free(transport);
 1928|      0|        return NULL;
 1929|      0|    }
 1930|       |
 1931|       |    /* if the transport hasn't been fully opened yet, open it now */
 1932|     81|    if ((rc = netsnmp_sess_config_and_open_transport(in_session, transport))
  ------------------
  |  Branch (1932:9): [True: 0, False: 81]
  ------------------
 1933|     81|        != SNMPERR_SUCCESS) {
  ------------------
  |  |  184|     81|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 1934|      0|        return NULL;
 1935|      0|    }
 1936|       |
 1937|     81|    DEBUGMSGTL(("snmp_sess_add", "fd %" NETSNMP_FMT_SKT "\n",
  ------------------
  |  |   66|     81|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     81|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 81, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|     81|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|     81|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|     81|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|     81|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 81]
  |  |  ------------------
  ------------------
 1938|     81|                transport->sock));
 1939|       |
 1940|     81|    if ((slp = snmp_sess_copy(in_session)) == NULL) {
  ------------------
  |  Branch (1940:9): [True: 0, False: 81]
  ------------------
 1941|      0|        transport->f_close(transport);
 1942|      0|        netsnmp_transport_free(transport);
 1943|      0|        return (NULL);
 1944|      0|    }
 1945|       |
 1946|     81|    slp->transport = transport;
 1947|     81|    slp->internal->hook_pre = fpre_parse;
 1948|     81|    slp->internal->hook_parse = fparse;
 1949|     81|    slp->internal->hook_post = fpost_parse;
 1950|     81|    slp->internal->hook_build = fbuild;
 1951|     81|    slp->internal->hook_realloc_build = frbuild;
 1952|     81|    slp->internal->check_packet = fcheck;
 1953|     81|    slp->internal->hook_create_pdu = fcreate_pdu;
 1954|       |
 1955|       |    /** don't let session max exceed transport max */
 1956|     81|    if (slp->session->rcvMsgMaxSize > transport->msgMaxSize) {
  ------------------
  |  Branch (1956:9): [True: 0, False: 81]
  ------------------
 1957|      0|        DEBUGMSGTL(("snmp_sess_add",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1958|      0|                    "limiting session rcv size (%" NETSNMP_PRIz "d) to transport max (%" NETSNMP_PRIz "d)\n",
 1959|      0|                    slp->session->rcvMsgMaxSize, transport->msgMaxSize));
 1960|      0|        slp->session->rcvMsgMaxSize = transport->msgMaxSize;
 1961|      0|    }
 1962|     81|    if (slp->session->sndMsgMaxSize > transport->msgMaxSize) {
  ------------------
  |  Branch (1962:9): [True: 0, False: 81]
  ------------------
 1963|      0|        DEBUGMSGTL(("snmp_sess_add",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1964|      0|                    "limiting session snd size (%" NETSNMP_PRIz "d) to transport max (%" NETSNMP_PRIz "d)\n",
 1965|      0|                    slp->session->sndMsgMaxSize, transport->msgMaxSize));
 1966|      0|        slp->session->sndMsgMaxSize = transport->msgMaxSize;
 1967|      0|    }
 1968|       |
 1969|     81|    if (transport->f_setup_session &&
  ------------------
  |  Branch (1969:9): [True: 0, False: 81]
  ------------------
 1970|      0|        transport->f_setup_session(transport, slp->session) != SNMPERR_SUCCESS)
  ------------------
  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  |  Branch (1970:9): [True: 0, False: 0]
  ------------------
 1971|      0|        goto close_session;
 1972|       |
 1973|       |    /* Anything below this point should only be done if the transport
 1974|       |       had no say in the matter */
 1975|     81|    if (slp->session->securityLevel == 0)
  ------------------
  |  Branch (1975:9): [True: 81, False: 0]
  ------------------
 1976|     81|        slp->session->securityLevel = SNMP_SEC_LEVEL_NOAUTH;
  ------------------
  |  |  299|     81|#define SNMP_SEC_LEVEL_NOAUTH		1
  ------------------
 1977|       |
 1978|     81|    if (slp->session->version == SNMP_VERSION_3) {
  ------------------
  |  |  113|     81|#define SNMP_VERSION_3     3
  ------------------
  |  Branch (1978:9): [True: 0, False: 81]
  ------------------
 1979|      0|        DEBUGMSGTL(("snmp_sess_add",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1980|      0|                    "adding v3 session -- maybe engineID probe now\n"));
 1981|      0|        if (!snmpv3_engineID_probe(slp, slp->session)) {
  ------------------
  |  Branch (1981:13): [True: 0, False: 0]
  ------------------
 1982|      0|            DEBUGMSGTL(("snmp_sess_add", "engine ID probe failed\n"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1983|      0|            goto close_session;
 1984|      0|        }
 1985|      0|    }
 1986|       |
 1987|     81|    slp->session->flags &= ~SNMP_FLAGS_DONT_PROBE;
  ------------------
  |  |  155|     81|#define SNMP_FLAGS_DONT_PROBE      0x100      /* don't probe for an engineID */
  ------------------
 1988|       |
 1989|     81|    return slp;
 1990|       |
 1991|      0|close_session:
 1992|      0|    snmp_sess_close(slp);
 1993|       |    return NULL;
 1994|     81|}                               /*  end snmp_sess_add_ex()  */
create_user_from_session:
 2024|     81|create_user_from_session(netsnmp_session * session) {
 2025|     81|#ifdef NETSNMP_SECMOD_USM
 2026|     81|    return usm_create_user_from_session(session);
 2027|       |#else
 2028|       |    snmp_log(LOG_ERR, "create_user_from_session called when USM wasn't compiled in");
 2029|       |    netsnmp_assert(0 == 1);
 2030|       |    return SNMP_ERR_GENERR;
 2031|       |#endif
 2032|     81|}
netsnmp_cleanup_session:
 2054|     81|{
 2055|     81|    free(s->localname);
 2056|     81|    free(s->peername);
 2057|     81|    free(s->community);
 2058|     81|    free(s->contextEngineID);
 2059|     81|    free(s->contextName);
 2060|     81|    free(s->securityEngineID);
 2061|     81|    free(s->securityName);
 2062|     81|    free(s->securityAuthProto);
 2063|     81|    free(s->securityAuthLocalKey);
 2064|     81|    free(s->securityPrivProto);
 2065|     81|    free(s->securityPrivLocalKey);
 2066|     81|    free(s->paramName);
 2067|     81|#ifndef NETSNMP_NO_TRAP_STATS
 2068|     81|    free(s->trap_stats);
 2069|     81|#endif /* NETSNMP_NO_TRAP_STATS */
 2070|     81|    usm_free_user(s->sessUser);
 2071|     81|    netsnmp_free_transport_config(s->transport_configuration);
 2072|     81|    memset(s, 0, sizeof(*s));
 2073|     81|}
snmp_close:
 2184|     81|{
 2185|     81|    struct session_list *slp = NULL, *oslp = NULL;
 2186|       |
 2187|     81|    {                           /*MTCRITICAL_RESOURCE */
 2188|     81|        snmp_res_lock(MT_LIBRARY_ID, MT_LIB_SESSION);
  ------------------
  |  |   79|     81|#define snmp_res_lock(x,y) do {} while (0)
  |  |  ------------------
  |  |  |  Branch (79:41): [Folded, False: 81]
  |  |  ------------------
  ------------------
 2189|     81|        if (Sessions && Sessions->session == session) { /* If first entry */
  ------------------
  |  Branch (2189:13): [True: 81, False: 0]
  |  Branch (2189:25): [True: 0, False: 81]
  ------------------
 2190|      0|            slp = Sessions;
 2191|      0|            Sessions = slp->next;
 2192|     81|        } else {
 2193|  3.40k|            for (slp = Sessions; slp; slp = slp->next) {
  ------------------
  |  Branch (2193:34): [True: 3.32k, False: 81]
  ------------------
 2194|  3.32k|                if (slp->session == session) {
  ------------------
  |  Branch (2194:21): [True: 0, False: 3.32k]
  ------------------
 2195|      0|                    if (oslp)   /* if we found entry that points here */
  ------------------
  |  Branch (2195:25): [True: 0, False: 0]
  ------------------
 2196|      0|                        oslp->next = slp->next; /* link around this entry */
 2197|      0|                    break;
 2198|      0|                }
 2199|  3.32k|                oslp = slp;
 2200|  3.32k|            }
 2201|     81|        }
 2202|     81|        snmp_res_unlock(MT_LIBRARY_ID, MT_LIB_SESSION);
  ------------------
  |  |   80|     81|#define snmp_res_unlock(x,y) do {} while (0)
  |  |  ------------------
  |  |  |  Branch (80:43): [Folded, False: 81]
  |  |  ------------------
  ------------------
 2203|     81|    }                           /*END MTCRITICAL_RESOURCE */
 2204|     81|    if (slp == NULL) {
  ------------------
  |  Branch (2204:9): [True: 81, False: 0]
  ------------------
 2205|     81|        return 0;
 2206|     81|    }
 2207|      0|    return snmp_sess_close(slp);
 2208|     81|}
snmp_parse:
 4714|  18.2k|{
 4715|  18.2k|    int             rc;
 4716|       |
 4717|  18.2k|    rc = _snmp_parse(slp, pss, pdu, data, length);
 4718|  18.2k|    if (rc) {
  ------------------
  |  Branch (4718:9): [True: 18.2k, False: 0]
  ------------------
 4719|  18.2k|        if (!pss->s_snmp_errno) {
  ------------------
  |  Branch (4719:13): [True: 5.02k, False: 13.2k]
  ------------------
 4720|  5.02k|            pss->s_snmp_errno = SNMPERR_BAD_PARSE;
  ------------------
  |  |  197|  5.02k|#define SNMPERR_BAD_PARSE		(-13)
  ------------------
 4721|  5.02k|        }
 4722|  18.2k|        SET_SNMP_ERROR(pss->s_snmp_errno);
  ------------------
  |  |   43|  18.2k|#define SET_SNMP_ERROR(x) snmp_errno=(x)
  ------------------
 4723|  18.2k|    }
 4724|       |
 4725|  18.2k|    return rc;
 4726|  18.2k|}
snmp_pdu_parse:
 4730|  3.21k|{
 4731|  3.21k|    u_char          type;
 4732|  3.21k|    u_char          msg_type;
 4733|  3.21k|    u_char         *var_val;
 4734|  3.21k|    size_t          len;
 4735|  3.21k|    size_t          four;
 4736|  3.21k|    netsnmp_variable_list *vp = NULL, *vplast = NULL;
 4737|  3.21k|    oid             objid[MAX_OID_LEN];
 4738|  3.21k|    u_char         *p;
 4739|       |
 4740|       |    /*
 4741|       |     * Get the PDU type 
 4742|       |     */
 4743|  3.21k|    data = asn_parse_header(data, length, &msg_type);
 4744|  3.21k|    if (data == NULL)
  ------------------
  |  Branch (4744:9): [True: 56, False: 3.16k]
  ------------------
 4745|     56|        return -1;
 4746|  3.16k|    DEBUGMSGTL(("dumpv_recv","    Command %s\n", snmp_pdu_type(msg_type)));
  ------------------
  |  |   66|  3.16k|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|  3.16k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 3.16k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|  3.16k|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  3.16k|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|  3.16k|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|  3.16k|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 3.16k]
  |  |  ------------------
  ------------------
 4747|  3.16k|    pdu->command = msg_type;
 4748|  3.16k|    pdu->flags &= (~UCD_MSG_FLAG_RESPONSE_PDU);
  ------------------
  |  |  311|  3.16k|#define UCD_MSG_FLAG_RESPONSE_PDU            0x100
  ------------------
 4749|       |
 4750|       |    /*
 4751|       |     * get the fields in the PDU preceding the variable-bindings sequence
 4752|       |     */
 4753|  3.16k|    switch (pdu->command) {
 4754|  2.87k|    case SNMP_MSG_TRAP:
  ------------------
  |  |  135|  2.87k|#define SNMP_MSG_TRAP       (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x4) /* a4=164 */
  |  |  ------------------
  |  |  |  |   92|  2.87k|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_MSG_TRAP       (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x4) /* a4=164 */
  |  |  ------------------
  |  |  |  |   96|  2.87k|#define ASN_CONSTRUCTOR	    0x20U
  |  |  ------------------
  ------------------
  |  Branch (4754:5): [True: 2.87k, False: 287]
  ------------------
 4755|       |        /*
 4756|       |         * enterprise 
 4757|       |         */
 4758|  2.87k|        pdu->enterprise_length = MAX_OID_LEN;
  ------------------
  |  |  120|  2.87k|#define MAX_OID_LEN	    128 /* max subid's in an oid */
  ------------------
 4759|  2.87k|        data = asn_parse_objid(data, length, &type, objid,
 4760|  2.87k|                               &pdu->enterprise_length);
 4761|  2.87k|        if (data == NULL)
  ------------------
  |  Branch (4761:13): [True: 275, False: 2.60k]
  ------------------
 4762|    275|            return -1;
 4763|  2.60k|        pdu->enterprise = netsnmp_memdup(objid,
 4764|  2.60k|                                         pdu->enterprise_length * sizeof(oid));
 4765|  2.60k|        if (pdu->enterprise == NULL) {
  ------------------
  |  Branch (4765:13): [True: 0, False: 2.60k]
  ------------------
 4766|      0|            return -1;
 4767|      0|        }
 4768|       |
 4769|       |        /*
 4770|       |         * agent-addr 
 4771|       |         */
 4772|  2.60k|        four = 4;
 4773|  2.60k|        data = asn_parse_string(data, length, &type,
 4774|  2.60k|                                (u_char *) pdu->agent_addr, &four);
 4775|  2.60k|        if (data == NULL)
  ------------------
  |  Branch (4775:13): [True: 40, False: 2.56k]
  ------------------
 4776|     40|            return -1;
 4777|       |
 4778|       |        /*
 4779|       |         * generic trap 
 4780|       |         */
 4781|  2.56k|        data = asn_parse_int(data, length, &type, (long *) &pdu->trap_type,
 4782|  2.56k|                             sizeof(pdu->trap_type));
 4783|  2.56k|        if (data == NULL)
  ------------------
  |  Branch (4783:13): [True: 2.56k, False: 0]
  ------------------
 4784|  2.56k|            return -1;
 4785|       |        /*
 4786|       |         * specific trap 
 4787|       |         */
 4788|      0|        data =
 4789|      0|            asn_parse_int(data, length, &type,
 4790|      0|                          (long *) &pdu->specific_type,
 4791|      0|                          sizeof(pdu->specific_type));
 4792|      0|        if (data == NULL)
  ------------------
  |  Branch (4792:13): [True: 0, False: 0]
  ------------------
 4793|      0|            return -1;
 4794|       |
 4795|       |        /*
 4796|       |         * timestamp  
 4797|       |         */
 4798|      0|        data = asn_parse_unsigned_int(data, length, &type, &pdu->time,
 4799|      0|                                      sizeof(pdu->time));
 4800|      0|        if (data == NULL)
  ------------------
  |  Branch (4800:13): [True: 0, False: 0]
  ------------------
 4801|      0|            return -1;
 4802|       |
 4803|      0|        break;
 4804|       |
 4805|     55|    case SNMP_MSG_RESPONSE:
  ------------------
  |  |  127|     55|#define SNMP_MSG_RESPONSE   (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x2) /* a2=162 */
  |  |  ------------------
  |  |  |  |   92|     55|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_MSG_RESPONSE   (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x2) /* a2=162 */
  |  |  ------------------
  |  |  |  |   96|     55|#define ASN_CONSTRUCTOR	    0x20U
  |  |  ------------------
  ------------------
  |  Branch (4805:5): [True: 55, False: 3.10k]
  ------------------
 4806|     55|    case SNMP_MSG_REPORT:
  ------------------
  |  |  147|     55|#define SNMP_MSG_REPORT     (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x8) /* a8=168 */
  |  |  ------------------
  |  |  |  |   92|     55|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_MSG_REPORT     (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x8) /* a8=168 */
  |  |  ------------------
  |  |  |  |   96|     55|#define ASN_CONSTRUCTOR	    0x20U
  |  |  ------------------
  ------------------
  |  Branch (4806:5): [True: 0, False: 3.16k]
  ------------------
 4807|     55|        pdu->flags |= UCD_MSG_FLAG_RESPONSE_PDU;
  ------------------
  |  |  311|     55|#define UCD_MSG_FLAG_RESPONSE_PDU            0x100
  ------------------
 4808|     55|        NETSNMP_FALLTHROUGH;
  ------------------
  |  | 2414|     55|#    define NETSNMP_FALLTHROUGH __attribute__((__fallthrough__))
  ------------------
 4809|       |
 4810|     55|    case SNMP_MSG_TRAP2:
  ------------------
  |  |  142|     55|#define SNMP_MSG_TRAP2      (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x7) /* a7=167 */
  |  |  ------------------
  |  |  |  |   92|     55|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_MSG_TRAP2      (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x7) /* a7=167 */
  |  |  ------------------
  |  |  |  |   96|     55|#define ASN_CONSTRUCTOR	    0x20U
  |  |  ------------------
  ------------------
  |  Branch (4810:5): [True: 0, False: 3.16k]
  ------------------
 4811|     55|    case SNMP_MSG_INFORM:
  ------------------
  |  |  141|     55|#define SNMP_MSG_INFORM     (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x6) /* a6=166 */
  |  |  ------------------
  |  |  |  |   92|     55|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_MSG_INFORM     (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x6) /* a6=166 */
  |  |  ------------------
  |  |  |  |   96|     55|#define ASN_CONSTRUCTOR	    0x20U
  |  |  ------------------
  ------------------
  |  Branch (4811:5): [True: 0, False: 3.16k]
  ------------------
 4812|     55|#ifndef NETSNMP_NOTIFY_ONLY
 4813|    155|    case SNMP_MSG_GET:
  ------------------
  |  |  125|    155|#define SNMP_MSG_GET        (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x0) /* a0=160 */
  |  |  ------------------
  |  |  |  |   92|    155|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_MSG_GET        (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x0) /* a0=160 */
  |  |  ------------------
  |  |  |  |   96|    155|#define ASN_CONSTRUCTOR	    0x20U
  |  |  ------------------
  ------------------
  |  Branch (4813:5): [True: 100, False: 3.06k]
  ------------------
 4814|    155|    case SNMP_MSG_GETNEXT:
  ------------------
  |  |  126|    155|#define SNMP_MSG_GETNEXT    (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x1) /* a1=161 */
  |  |  ------------------
  |  |  |  |   92|    155|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_MSG_GETNEXT    (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x1) /* a1=161 */
  |  |  ------------------
  |  |  |  |   96|    155|#define ASN_CONSTRUCTOR	    0x20U
  |  |  ------------------
  ------------------
  |  Branch (4814:5): [True: 0, False: 3.16k]
  ------------------
 4815|    183|    case SNMP_MSG_GETBULK:
  ------------------
  |  |  140|    183|#define SNMP_MSG_GETBULK    (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x5) /* a5=165 */
  |  |  ------------------
  |  |  |  |   92|    183|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_MSG_GETBULK    (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x5) /* a5=165 */
  |  |  ------------------
  |  |  |  |   96|    183|#define ASN_CONSTRUCTOR	    0x20U
  |  |  ------------------
  ------------------
  |  Branch (4815:5): [True: 28, False: 3.13k]
  ------------------
 4816|    183|#endif /* ! NETSNMP_NOTIFY_ONLY */
 4817|    183|#ifndef NETSNMP_NO_WRITE_SUPPORT
 4818|    183|    case SNMP_MSG_SET:
  ------------------
  |  |  129|    183|#define SNMP_MSG_SET        (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x3) /* a3=163 */
  |  |  ------------------
  |  |  |  |   92|    183|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_MSG_SET        (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x3) /* a3=163 */
  |  |  ------------------
  |  |  |  |   96|    183|#define ASN_CONSTRUCTOR	    0x20U
  |  |  ------------------
  ------------------
  |  Branch (4818:5): [True: 0, False: 3.16k]
  ------------------
 4819|    183|#endif /* !NETSNMP_NO_WRITE_SUPPORT */
 4820|       |        /*
 4821|       |         * PDU is not an SNMPv1 TRAP 
 4822|       |         */
 4823|       |
 4824|       |        /*
 4825|       |         * request id 
 4826|       |         */
 4827|    183|        DEBUGDUMPHEADER("recv", "request_id");
  ------------------
  |  |   79|    183|	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    183|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 183, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  178|    183|        __DBGPRINTINDENT("dumph_" token); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  175|    183|#define __DBGPRINTINDENT(token) __DBGMSGTL((token, "%*s", __DBGINDENT(), ""))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  164|    183|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  154|    183|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  147|    183|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  155|    183|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  179|    183|        debugmsg("dumph_" token,x); \
  |  |  |  |  180|    183|        if (debug_is_token_registered("dumpx" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|    366|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (180:13): [True: 183, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  181|    183|            debug_is_token_registered("dumpv" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|    183|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (181:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  182|    183|            (debug_is_token_registered("dumpx_" token) != SNMPERR_SUCCESS &&  \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (182:14): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  183|    183|             debug_is_token_registered("dumpv_" token) != SNMPERR_SUCCESS)) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:14): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  184|    183|            debugmsg("dumph_" token,"\n"); \
  |  |  |  |  185|    183|        } else { \
  |  |  |  |  186|      0|            debugmsg("dumph_" token,"  "); \
  |  |  |  |  187|      0|        } \
  |  |  |  |  188|    183|        __DBGINDENTMORE()
  |  |  |  |  ------------------
  |  |  |  |  |  |  173|    183|#define __DBGINDENTMORE()  debug_indent_add(2)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (79:55): [Folded, False: 183]
  |  |  ------------------
  ------------------
 4828|    183|        data = asn_parse_int(data, length, &type, &pdu->reqid,
 4829|    183|                             sizeof(pdu->reqid));
 4830|    183|        DEBUGINDENTLESS();
  ------------------
  |  |   75|    183|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|    183|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 183, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|    183|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 183]
  |  |  ------------------
  ------------------
 4831|    183|        if (data == NULL) {
  ------------------
  |  Branch (4831:13): [True: 0, False: 183]
  ------------------
 4832|      0|            return -1;
 4833|      0|        }
 4834|       |
 4835|       |        /*
 4836|       |         * error status (getbulk non-repeaters) 
 4837|       |         */
 4838|    183|        DEBUGDUMPHEADER("recv", "error status");
  ------------------
  |  |   79|    183|	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    183|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 183, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  178|    183|        __DBGPRINTINDENT("dumph_" token); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  175|    183|#define __DBGPRINTINDENT(token) __DBGMSGTL((token, "%*s", __DBGINDENT(), ""))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  164|    183|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  154|    183|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  147|    183|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  155|    183|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  179|    183|        debugmsg("dumph_" token,x); \
  |  |  |  |  180|    183|        if (debug_is_token_registered("dumpx" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|    366|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (180:13): [True: 183, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  181|    183|            debug_is_token_registered("dumpv" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|    183|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (181:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  182|    183|            (debug_is_token_registered("dumpx_" token) != SNMPERR_SUCCESS &&  \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (182:14): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  183|    183|             debug_is_token_registered("dumpv_" token) != SNMPERR_SUCCESS)) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:14): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  184|    183|            debugmsg("dumph_" token,"\n"); \
  |  |  |  |  185|    183|        } else { \
  |  |  |  |  186|      0|            debugmsg("dumph_" token,"  "); \
  |  |  |  |  187|      0|        } \
  |  |  |  |  188|    183|        __DBGINDENTMORE()
  |  |  |  |  ------------------
  |  |  |  |  |  |  173|    183|#define __DBGINDENTMORE()  debug_indent_add(2)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (79:55): [Folded, False: 183]
  |  |  ------------------
  ------------------
 4839|    183|        data = asn_parse_int(data, length, &type, &pdu->errstat,
 4840|    183|                             sizeof(pdu->errstat));
 4841|    183|        DEBUGINDENTLESS();
  ------------------
  |  |   75|    183|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|    183|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 183, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|    183|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 183]
  |  |  ------------------
  ------------------
 4842|    183|        if (data == NULL) {
  ------------------
  |  Branch (4842:13): [True: 0, False: 183]
  ------------------
 4843|      0|            return -1;
 4844|      0|        }
 4845|       |
 4846|       |        /*
 4847|       |         * error index (getbulk max-repetitions) 
 4848|       |         */
 4849|    183|        DEBUGDUMPHEADER("recv", "error index");
  ------------------
  |  |   79|    183|	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    183|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 183, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  178|    183|        __DBGPRINTINDENT("dumph_" token); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  175|    183|#define __DBGPRINTINDENT(token) __DBGMSGTL((token, "%*s", __DBGINDENT(), ""))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  164|    183|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  154|    183|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  147|    183|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  155|    183|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  179|    183|        debugmsg("dumph_" token,x); \
  |  |  |  |  180|    183|        if (debug_is_token_registered("dumpx" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|    366|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (180:13): [True: 183, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  181|    183|            debug_is_token_registered("dumpv" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|    183|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (181:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  182|    183|            (debug_is_token_registered("dumpx_" token) != SNMPERR_SUCCESS &&  \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (182:14): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  183|    183|             debug_is_token_registered("dumpv_" token) != SNMPERR_SUCCESS)) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:14): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  184|    183|            debugmsg("dumph_" token,"\n"); \
  |  |  |  |  185|    183|        } else { \
  |  |  |  |  186|      0|            debugmsg("dumph_" token,"  "); \
  |  |  |  |  187|      0|        } \
  |  |  |  |  188|    183|        __DBGINDENTMORE()
  |  |  |  |  ------------------
  |  |  |  |  |  |  173|    183|#define __DBGINDENTMORE()  debug_indent_add(2)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (79:55): [Folded, False: 183]
  |  |  ------------------
  ------------------
 4850|    183|        data = asn_parse_int(data, length, &type, &pdu->errindex,
 4851|    183|                             sizeof(pdu->errindex));
 4852|    183|        DEBUGINDENTLESS();
  ------------------
  |  |   75|    183|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|    183|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 183, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|    183|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 183]
  |  |  ------------------
  ------------------
 4853|    183|        if (data == NULL) {
  ------------------
  |  Branch (4853:13): [True: 0, False: 183]
  ------------------
 4854|      0|            return -1;
 4855|      0|        }
 4856|    183|	break;
 4857|       |
 4858|    183|    default:
  ------------------
  |  Branch (4858:5): [True: 104, False: 3.05k]
  ------------------
 4859|    104|        snmp_log(LOG_ERR, "Bad PDU type received: 0x%.2x\n", pdu->command);
 4860|    104|        snmp_increment_statistic(STAT_SNMPINASNPARSEERRS);
  ------------------
  |  |  637|    104|#define  STAT_SNMPINASNPARSEERRS             14
  ------------------
 4861|    104|        return -1;
 4862|  3.16k|    }
 4863|       |
 4864|       |    /*
 4865|       |     * get header for variable-bindings sequence 
 4866|       |     */
 4867|    183|    DEBUGDUMPSECTION("recv", "VarBindList");
  ------------------
  |  |   81|    183|	do {if (_DBG_IF_) {__DBGDUMPSECTION(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    183|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 183, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPSECTION(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  191|    183|        __DBGPRINTINDENT("dumph_" token); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  175|    183|#define __DBGPRINTINDENT(token) __DBGMSGTL((token, "%*s", __DBGINDENT(), ""))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  164|    183|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  154|    183|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  147|    183|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  155|    183|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  192|    183|        debugmsg("dumph_" token,"%s\n",x);\
  |  |  |  |  193|    183|        __DBGINDENTMORE()
  |  |  |  |  ------------------
  |  |  |  |  |  |  173|    183|#define __DBGINDENTMORE()  debug_indent_add(2)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (81:56): [Folded, False: 183]
  |  |  ------------------
  ------------------
 4868|    183|    data = asn_parse_sequence(data, length, &type,
 4869|    183|                              (ASN_SEQUENCE | ASN_CONSTRUCTOR),
  ------------------
  |  |   84|    183|#define ASN_SEQUENCE	    0x10U
  ------------------
                                            (ASN_SEQUENCE | ASN_CONSTRUCTOR),
  ------------------
  |  |   96|    183|#define ASN_CONSTRUCTOR	    0x20U
  ------------------
 4870|    183|                              "varbinds");
 4871|    183|    if (data == NULL)
  ------------------
  |  Branch (4871:9): [True: 100, False: 83]
  ------------------
 4872|    100|        goto fail;
 4873|       |
 4874|       |    /*
 4875|       |     * get each varBind sequence 
 4876|       |     */
 4877|     91|    while ((int) *length > 0) {
  ------------------
  |  Branch (4877:12): [True: 91, False: 0]
  ------------------
 4878|     91|        vp = SNMP_MALLOC_TYPEDEF(netsnmp_variable_list);
  ------------------
  |  |   73|     91|#define SNMP_MALLOC_TYPEDEF(td)  (td *) calloc(1, sizeof(td))
  ------------------
 4879|     91|        if (NULL == vp)
  ------------------
  |  Branch (4879:13): [True: 0, False: 91]
  ------------------
 4880|      0|            goto fail;
 4881|       |
 4882|     91|        vp->name_length = MAX_OID_LEN;
  ------------------
  |  |  120|     91|#define MAX_OID_LEN	    128 /* max subid's in an oid */
  ------------------
 4883|     91|        DEBUGDUMPSECTION("recv", "VarBind");
  ------------------
  |  |   81|     91|	do {if (_DBG_IF_) {__DBGDUMPSECTION(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     91|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 91, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPSECTION(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  191|     91|        __DBGPRINTINDENT("dumph_" token); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  175|     91|#define __DBGPRINTINDENT(token) __DBGMSGTL((token, "%*s", __DBGINDENT(), ""))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  164|     91|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  154|     91|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  147|     91|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  155|     91|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  192|     91|        debugmsg("dumph_" token,"%s\n",x);\
  |  |  |  |  193|     91|        __DBGINDENTMORE()
  |  |  |  |  ------------------
  |  |  |  |  |  |  173|     91|#define __DBGINDENTMORE()  debug_indent_add(2)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (81:56): [Folded, False: 91]
  |  |  ------------------
  ------------------
 4884|     91|        data = snmp_parse_var_op(data, objid, &vp->name_length, &vp->type,
 4885|     91|                                 &vp->val_len, &var_val, length);
 4886|     91|        if (data == NULL)
  ------------------
  |  Branch (4886:13): [True: 28, False: 63]
  ------------------
 4887|     28|            goto fail;
 4888|     63|        if (snmp_set_var_objid(vp, objid, vp->name_length))
  ------------------
  |  Branch (4888:13): [True: 0, False: 63]
  ------------------
 4889|      0|            goto fail;
 4890|       |
 4891|     63|        len = SNMP_MAX_PACKET_LEN;
  ------------------
  |  |   49|     63|#define SNMP_MAX_PACKET_LEN (0x7fffffff)
  ------------------
 4892|     63|        DEBUGDUMPHEADER("recv", "Value");
  ------------------
  |  |   79|     63|	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     63|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 63, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  178|     63|        __DBGPRINTINDENT("dumph_" token); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  175|     63|#define __DBGPRINTINDENT(token) __DBGMSGTL((token, "%*s", __DBGINDENT(), ""))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  164|     63|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  154|     63|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  147|     63|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  155|     63|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  179|     63|        debugmsg("dumph_" token,x); \
  |  |  |  |  180|     63|        if (debug_is_token_registered("dumpx" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|    126|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (180:13): [True: 63, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  181|     63|            debug_is_token_registered("dumpv" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|     63|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (181:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  182|     63|            (debug_is_token_registered("dumpx_" token) != SNMPERR_SUCCESS &&  \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (182:14): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  183|     63|             debug_is_token_registered("dumpv_" token) != SNMPERR_SUCCESS)) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:14): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  184|     63|            debugmsg("dumph_" token,"\n"); \
  |  |  |  |  185|     63|        } else { \
  |  |  |  |  186|      0|            debugmsg("dumph_" token,"  "); \
  |  |  |  |  187|      0|        } \
  |  |  |  |  188|     63|        __DBGINDENTMORE()
  |  |  |  |  ------------------
  |  |  |  |  |  |  173|     63|#define __DBGINDENTMORE()  debug_indent_add(2)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (79:55): [Folded, False: 63]
  |  |  ------------------
  ------------------
 4893|     63|        switch ((short) vp->type) {
 4894|      8|        case ASN_INTEGER:
  ------------------
  |  |   75|      8|#define ASN_INTEGER	    0x02U
  ------------------
  |  Branch (4894:9): [True: 8, False: 55]
  ------------------
 4895|      8|            vp->val.integer = (long *) vp->buf;
 4896|      8|            vp->val_len = sizeof(long);
 4897|      8|            p = asn_parse_int(var_val, &len, &vp->type,
 4898|      8|                          (long *) vp->val.integer,
 4899|      8|                          sizeof(*vp->val.integer));
 4900|      8|            if (!p)
  ------------------
  |  Branch (4900:17): [True: 0, False: 8]
  ------------------
 4901|      0|                goto fail;
 4902|      8|            break;
 4903|      8|        case ASN_COUNTER:
  ------------------
  |  |   89|      0|#define ASN_COUNTER	(ASN_APPLICATION | 1)
  |  |  ------------------
  |  |  |  |   91|      0|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (4903:9): [True: 0, False: 63]
  ------------------
 4904|      0|        case ASN_GAUGE:
  ------------------
  |  |   90|      0|#define ASN_GAUGE	(ASN_APPLICATION | 2)
  |  |  ------------------
  |  |  |  |   91|      0|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (4904:9): [True: 0, False: 63]
  ------------------
 4905|      0|        case ASN_TIMETICKS:
  ------------------
  |  |   92|      0|#define ASN_TIMETICKS   (ASN_APPLICATION | 3)
  |  |  ------------------
  |  |  |  |   91|      0|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (4905:9): [True: 0, False: 63]
  ------------------
 4906|      0|        case ASN_UINTEGER:
  ------------------
  |  |  100|      0|#define ASN_UINTEGER    (ASN_APPLICATION | 7)   /* historic - don't use */
  |  |  ------------------
  |  |  |  |   91|      0|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (4906:9): [True: 0, False: 63]
  ------------------
 4907|      0|            vp->val.integer = (long *) vp->buf;
 4908|      0|            vp->val_len = sizeof(u_long);
 4909|      0|            p = asn_parse_unsigned_int(var_val, &len, &vp->type,
 4910|      0|                                   (u_long *) vp->val.integer,
 4911|      0|                                   vp->val_len);
 4912|      0|            if (!p)
  ------------------
  |  Branch (4912:17): [True: 0, False: 0]
  ------------------
 4913|      0|                goto fail;
 4914|      0|            break;
 4915|      0|#ifdef NETSNMP_WITH_OPAQUE_SPECIAL_TYPES
 4916|      0|        case ASN_OPAQUE_COUNTER64:
  ------------------
  |  |  156|      0|#define ASN_OPAQUE_COUNTER64 (ASN_OPAQUE_TAG2 + ASN_APP_COUNTER64)
  |  |  ------------------
  |  |  |  |  136|      0|#define ASN_OPAQUE_TAG2 0x30U
  |  |  ------------------
  |  |               #define ASN_OPAQUE_COUNTER64 (ASN_OPAQUE_TAG2 + ASN_APP_COUNTER64)
  |  |  ------------------
  |  |  |  |  146|      0|#define ASN_APP_COUNTER64 (ASN_APPLICATION | 6)
  |  |  |  |  ------------------
  |  |  |  |  |  |   91|      0|#define ASN_APPLICATION     0x40U
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (4916:9): [True: 0, False: 63]
  ------------------
 4917|      0|        case ASN_OPAQUE_U64:
  ------------------
  |  |  192|      0|#define ASN_OPAQUE_U64 (ASN_OPAQUE_TAG2 + ASN_APP_U64)
  |  |  ------------------
  |  |  |  |  136|      0|#define ASN_OPAQUE_TAG2 0x30U
  |  |  ------------------
  |  |               #define ASN_OPAQUE_U64 (ASN_OPAQUE_TAG2 + ASN_APP_U64)
  |  |  ------------------
  |  |  |  |  150|      0|#define ASN_APP_U64 (ASN_APPLICATION | 11)
  |  |  |  |  ------------------
  |  |  |  |  |  |   91|      0|#define ASN_APPLICATION     0x40U
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (4917:9): [True: 0, False: 63]
  ------------------
 4918|      0|#endif                          /* NETSNMP_WITH_OPAQUE_SPECIAL_TYPES */
 4919|      0|        case ASN_COUNTER64:
  ------------------
  |  |   99|      0|#define ASN_COUNTER64   (ASN_APPLICATION | 6)
  |  |  ------------------
  |  |  |  |   91|      0|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (4919:9): [True: 0, False: 63]
  ------------------
 4920|      0|            vp->val.counter64 = (struct counter64 *) vp->buf;
 4921|      0|            vp->val_len = sizeof(struct counter64);
 4922|      0|            p = asn_parse_unsigned_int64(var_val, &len, &vp->type,
 4923|      0|                                     (struct counter64 *) vp->val.
 4924|      0|                                     counter64, vp->val_len);
 4925|      0|            if (!p)
  ------------------
  |  Branch (4925:17): [True: 0, False: 0]
  ------------------
 4926|      0|                goto fail;
 4927|      0|            break;
 4928|      0|#ifdef NETSNMP_WITH_OPAQUE_SPECIAL_TYPES
 4929|      0|        case ASN_OPAQUE_FLOAT:
  ------------------
  |  |  165|      0|#define ASN_OPAQUE_FLOAT (ASN_OPAQUE_TAG2 + ASN_APP_FLOAT)
  |  |  ------------------
  |  |  |  |  136|      0|#define ASN_OPAQUE_TAG2 0x30U
  |  |  ------------------
  |  |               #define ASN_OPAQUE_FLOAT (ASN_OPAQUE_TAG2 + ASN_APP_FLOAT)
  |  |  ------------------
  |  |  |  |  147|      0|#define ASN_APP_FLOAT (ASN_APPLICATION | 8)
  |  |  |  |  ------------------
  |  |  |  |  |  |   91|      0|#define ASN_APPLICATION     0x40U
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (4929:9): [True: 0, False: 63]
  ------------------
 4930|      0|            vp->val.floatVal = (float *) vp->buf;
 4931|      0|            vp->val_len = sizeof(float);
 4932|      0|            p = asn_parse_float(var_val, &len, &vp->type,
 4933|      0|                            vp->val.floatVal, vp->val_len);
 4934|      0|            if (!p)
  ------------------
  |  Branch (4934:17): [True: 0, False: 0]
  ------------------
 4935|      0|                goto fail;
 4936|      0|            break;
 4937|      0|        case ASN_OPAQUE_DOUBLE:
  ------------------
  |  |  174|      0|#define ASN_OPAQUE_DOUBLE (ASN_OPAQUE_TAG2 + ASN_APP_DOUBLE)
  |  |  ------------------
  |  |  |  |  136|      0|#define ASN_OPAQUE_TAG2 0x30U
  |  |  ------------------
  |  |               #define ASN_OPAQUE_DOUBLE (ASN_OPAQUE_TAG2 + ASN_APP_DOUBLE)
  |  |  ------------------
  |  |  |  |  148|      0|#define ASN_APP_DOUBLE (ASN_APPLICATION | 9)
  |  |  |  |  ------------------
  |  |  |  |  |  |   91|      0|#define ASN_APPLICATION     0x40U
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (4937:9): [True: 0, False: 63]
  ------------------
 4938|      0|            vp->val.doubleVal = (double *) vp->buf;
 4939|      0|            vp->val_len = sizeof(double);
 4940|      0|            p = asn_parse_double(var_val, &len, &vp->type,
 4941|      0|                             vp->val.doubleVal, vp->val_len);
 4942|      0|            if (!p)
  ------------------
  |  Branch (4942:17): [True: 0, False: 0]
  ------------------
 4943|      0|                goto fail;
 4944|      0|            break;
 4945|     55|        case ASN_OPAQUE_I64:
  ------------------
  |  |  183|     55|#define ASN_OPAQUE_I64 (ASN_OPAQUE_TAG2 + ASN_APP_I64)
  |  |  ------------------
  |  |  |  |  136|     55|#define ASN_OPAQUE_TAG2 0x30U
  |  |  ------------------
  |  |               #define ASN_OPAQUE_I64 (ASN_OPAQUE_TAG2 + ASN_APP_I64)
  |  |  ------------------
  |  |  |  |  149|     55|#define ASN_APP_I64 (ASN_APPLICATION | 10)
  |  |  |  |  ------------------
  |  |  |  |  |  |   91|     55|#define ASN_APPLICATION     0x40U
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (4945:9): [True: 55, False: 8]
  ------------------
 4946|     55|            vp->val.counter64 = (struct counter64 *) vp->buf;
 4947|     55|            vp->val_len = sizeof(struct counter64);
 4948|     55|            p = asn_parse_signed_int64(var_val, &len, &vp->type,
 4949|     55|                                   (struct counter64 *) vp->val.counter64,
 4950|     55|                                   sizeof(*vp->val.counter64));
 4951|       |
 4952|     55|            if (!p)
  ------------------
  |  Branch (4952:17): [True: 55, False: 0]
  ------------------
 4953|     55|                goto fail;
 4954|      0|            break;
 4955|      0|#endif                          /* NETSNMP_WITH_OPAQUE_SPECIAL_TYPES */
 4956|      0|        case ASN_IPADDRESS:
  ------------------
  |  |   88|      0|#define ASN_IPADDRESS   (ASN_APPLICATION | 0)
  |  |  ------------------
  |  |  |  |   91|      0|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (4956:9): [True: 0, False: 63]
  ------------------
 4957|      0|            if (vp->val_len != 4)
  ------------------
  |  Branch (4957:17): [True: 0, False: 0]
  ------------------
 4958|      0|                goto fail;
 4959|      0|            NETSNMP_FALLTHROUGH;
  ------------------
  |  | 2414|      0|#    define NETSNMP_FALLTHROUGH __attribute__((__fallthrough__))
  ------------------
 4960|      0|        case ASN_OCTET_STR:
  ------------------
  |  |   78|      0|#define ASN_OCTET_STR	    0x04U
  ------------------
  |  Branch (4960:9): [True: 0, False: 63]
  ------------------
 4961|      0|        case ASN_OPAQUE:
  ------------------
  |  |   93|      0|#define ASN_OPAQUE	(ASN_APPLICATION | 4)   /* changed so no conflict with other includes */
  |  |  ------------------
  |  |  |  |   91|      0|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (4961:9): [True: 0, False: 63]
  ------------------
 4962|      0|        case ASN_NSAP:
  ------------------
  |  |   98|      0|#define ASN_NSAP	(ASN_APPLICATION | 5)   /* historic - don't use */
  |  |  ------------------
  |  |  |  |   91|      0|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (4962:9): [True: 0, False: 63]
  ------------------
 4963|      0|            if (vp->val_len < sizeof(vp->buf)) {
  ------------------
  |  Branch (4963:17): [True: 0, False: 0]
  ------------------
 4964|      0|                vp->val.string = (u_char *) vp->buf;
 4965|      0|            } else {
 4966|      0|                vp->val.string = (u_char *) malloc(vp->val_len);
 4967|      0|            }
 4968|      0|            if (vp->val.string == NULL) {
  ------------------
  |  Branch (4968:17): [True: 0, False: 0]
  ------------------
 4969|      0|                goto fail;
 4970|      0|            }
 4971|      0|            p = asn_parse_string(var_val, &len, &vp->type, vp->val.string,
 4972|      0|                             &vp->val_len);
 4973|      0|            if (!p)
  ------------------
  |  Branch (4973:17): [True: 0, False: 0]
  ------------------
 4974|      0|                goto fail;
 4975|      0|            break;
 4976|      0|        case ASN_OBJECT_ID:
  ------------------
  |  |   81|      0|#define ASN_OBJECT_ID	    0x06U
  ------------------
  |  Branch (4976:9): [True: 0, False: 63]
  ------------------
 4977|      0|            vp->val_len = MAX_OID_LEN;
  ------------------
  |  |  120|      0|#define MAX_OID_LEN	    128 /* max subid's in an oid */
  ------------------
 4978|      0|            p = asn_parse_objid(var_val, &len, &vp->type, objid, &vp->val_len);
 4979|      0|            if (!p)
  ------------------
  |  Branch (4979:17): [True: 0, False: 0]
  ------------------
 4980|      0|                goto fail;
 4981|      0|            vp->val_len *= sizeof(oid);
 4982|      0|            vp->val.objid = netsnmp_memdup(objid, vp->val_len);
 4983|      0|            if (vp->val.objid == NULL)
  ------------------
  |  Branch (4983:17): [True: 0, False: 0]
  ------------------
 4984|      0|                goto fail;
 4985|      0|            break;
 4986|      0|        case SNMP_NOSUCHOBJECT:
  ------------------
  |  |  201|      0|#define SNMP_NOSUCHOBJECT    (ASN_CONTEXT | ASN_PRIMITIVE | 0x0) /* 80=128 */
  |  |  ------------------
  |  |  |  |   92|      0|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_NOSUCHOBJECT    (ASN_CONTEXT | ASN_PRIMITIVE | 0x0) /* 80=128 */
  |  |  ------------------
  |  |  |  |   95|      0|#define ASN_PRIMITIVE	    0x00U
  |  |  ------------------
  ------------------
  |  Branch (4986:9): [True: 0, False: 63]
  ------------------
 4987|      0|        case SNMP_NOSUCHINSTANCE:
  ------------------
  |  |  202|      0|#define SNMP_NOSUCHINSTANCE  (ASN_CONTEXT | ASN_PRIMITIVE | 0x1) /* 81=129 */
  |  |  ------------------
  |  |  |  |   92|      0|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_NOSUCHINSTANCE  (ASN_CONTEXT | ASN_PRIMITIVE | 0x1) /* 81=129 */
  |  |  ------------------
  |  |  |  |   95|      0|#define ASN_PRIMITIVE	    0x00U
  |  |  ------------------
  ------------------
  |  Branch (4987:9): [True: 0, False: 63]
  ------------------
 4988|      0|        case SNMP_ENDOFMIBVIEW:
  ------------------
  |  |  203|      0|#define SNMP_ENDOFMIBVIEW    (ASN_CONTEXT | ASN_PRIMITIVE | 0x2) /* 82=130 */
  |  |  ------------------
  |  |  |  |   92|      0|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_ENDOFMIBVIEW    (ASN_CONTEXT | ASN_PRIMITIVE | 0x2) /* 82=130 */
  |  |  ------------------
  |  |  |  |   95|      0|#define ASN_PRIMITIVE	    0x00U
  |  |  ------------------
  ------------------
  |  Branch (4988:9): [True: 0, False: 63]
  ------------------
 4989|      0|        case ASN_NULL:
  ------------------
  |  |   79|      0|#define ASN_NULL	    0x05U
  ------------------
  |  Branch (4989:9): [True: 0, False: 63]
  ------------------
 4990|      0|            break;
 4991|      0|        case ASN_BIT_STR:
  ------------------
  |  |   77|      0|#define ASN_BIT_STR	    0x03U
  ------------------
  |  Branch (4991:9): [True: 0, False: 63]
  ------------------
 4992|      0|            vp->val.bitstring = (u_char *) malloc(vp->val_len);
 4993|      0|            if (vp->val.bitstring == NULL) {
  ------------------
  |  Branch (4993:17): [True: 0, False: 0]
  ------------------
 4994|      0|                goto fail;
 4995|      0|            }
 4996|      0|            p = asn_parse_bitstring(var_val, &len, &vp->type,
 4997|      0|                                vp->val.bitstring, &vp->val_len);
 4998|      0|            if (!p)
  ------------------
  |  Branch (4998:17): [True: 0, False: 0]
  ------------------
 4999|      0|                goto fail;
 5000|      0|            break;
 5001|      0|        default:
  ------------------
  |  Branch (5001:9): [True: 0, False: 63]
  ------------------
 5002|      0|            snmp_log(LOG_ERR, "bad type returned (%x)\n", vp->type);
 5003|      0|            goto fail;
 5004|      0|            break;
 5005|     63|        }
 5006|      8|        DEBUGINDENTADD(-4);
  ------------------
  |  |   73|      8|#define DEBUGINDENTADD(x)  do {if (_DBG_IF_) {__DBGINDENTADD(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      8|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 8, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTADD(x)  do {if (_DBG_IF_) {__DBGINDENTADD(x);} }while(0)
  |  |  ------------------
  |  |  |  |  172|      8|#define __DBGINDENTADD(x)  debug_indent_add(x)
  |  |  ------------------
  |  |  |  Branch (73:74): [Folded, False: 8]
  |  |  ------------------
  ------------------
 5007|       |
 5008|      8|        if (NULL == vplast) {
  ------------------
  |  Branch (5008:13): [True: 8, False: 0]
  ------------------
 5009|      8|            pdu->variables = vp;
 5010|      8|        } else {
 5011|      0|            vplast->next_variable = vp;
 5012|      0|        }
 5013|      8|        vplast = vp;
 5014|      8|        vp = NULL;
 5015|      8|    }
 5016|      0|    return 0;
 5017|       |
 5018|    183|  fail:
 5019|    183|    {
 5020|    183|        const char *errstr = snmp_api_errstring(SNMPERR_SUCCESS);
  ------------------
  |  |  184|    183|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 5021|    183|        DEBUGMSGTL(("recv", "error while parsing VarBindList:%s\n", errstr));
  ------------------
  |  |   66|    183|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    183|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 183, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|    183|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|    183|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|    183|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|    183|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 183]
  |  |  ------------------
  ------------------
 5022|    183|    }
 5023|       |    /** if we were parsing a var, remove it from the pdu and free it */
 5024|    183|    if (vp)
  ------------------
  |  Branch (5024:9): [True: 83, False: 100]
  ------------------
 5025|     83|        snmp_free_var(vp);
 5026|       |
 5027|    183|    return -1;
 5028|     83|}
snmp_free_var_internals:
 5648|     91|{
 5649|     91|    if (!var)
  ------------------
  |  Branch (5649:9): [True: 0, False: 91]
  ------------------
 5650|      0|        return;
 5651|       |
 5652|     91|    if (var->name != var->name_loc)
  ------------------
  |  Branch (5652:9): [True: 28, False: 63]
  ------------------
 5653|     28|        SNMP_FREE(var->name);
  ------------------
  |  |   62|     28|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 28]
  |  |  |  Branch (62:66): [Folded, False: 28]
  |  |  ------------------
  ------------------
 5654|     91|    if (var->val.string != var->buf)
  ------------------
  |  Branch (5654:9): [True: 28, False: 63]
  ------------------
 5655|     28|        SNMP_FREE(var->val.string);
  ------------------
  |  |   62|     28|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 28]
  |  |  |  Branch (62:66): [Folded, False: 28]
  |  |  ------------------
  ------------------
 5656|     91|    if (var->data) {
  ------------------
  |  Branch (5656:9): [True: 0, False: 91]
  ------------------
 5657|      0|        if (var->dataFreeHook) {
  ------------------
  |  Branch (5657:13): [True: 0, False: 0]
  ------------------
 5658|      0|            var->dataFreeHook(var->data);
 5659|      0|            var->data = NULL;
 5660|      0|        } else {
 5661|       |            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, False: 0]
  |  |  ------------------
  ------------------
 5662|      0|        }
 5663|      0|    }
 5664|     91|}
snmp_free_var:
 5668|     91|{
 5669|     91|    snmp_free_var_internals(var);
 5670|     91|    free(var);
 5671|     91|}
snmp_free_varbind:
 5675|  18.2k|{
 5676|  18.2k|    netsnmp_variable_list *ptr;
 5677|  18.3k|    while (var) {
  ------------------
  |  Branch (5677:12): [True: 8, False: 18.2k]
  ------------------
 5678|      8|        ptr = var->next_variable;
 5679|      8|        snmp_free_var(var);
 5680|      8|        var = ptr;
 5681|      8|    }
 5682|  18.2k|}
snmp_free_pdu:
 5689|  18.2k|{
 5690|  18.2k|    struct snmp_secmod_def *sptr;
 5691|       |
 5692|  18.2k|    if (!pdu)
  ------------------
  |  Branch (5692:9): [True: 0, False: 18.2k]
  ------------------
 5693|      0|        return;
 5694|       |
 5695|  18.2k|    free_securityStateRef(pdu);
 5696|       |
 5697|  18.2k|    sptr = find_sec_mod(pdu->securityModel);
 5698|  18.2k|    if (sptr && sptr->pdu_free)
  ------------------
  |  Branch (5698:9): [True: 0, False: 18.2k]
  |  Branch (5698:17): [True: 0, False: 0]
  ------------------
 5699|      0|        (*sptr->pdu_free)(pdu);
 5700|       |
 5701|  18.2k|    snmp_free_varbind(pdu->variables);
 5702|  18.2k|    free(pdu->enterprise);
 5703|  18.2k|    free(pdu->community);
 5704|  18.2k|    free(pdu->contextEngineID);
 5705|  18.2k|    free(pdu->securityEngineID);
 5706|  18.2k|    free(pdu->contextName);
 5707|  18.2k|    free(pdu->securityName);
 5708|  18.2k|    free(pdu->transport_data);
 5709|  18.2k|    free(pdu);
 5710|  18.2k|}
snmp_create_sess_pdu:
 5715|  18.2k|{
 5716|  18.2k|    netsnmp_pdu *pdu = calloc(1, sizeof(netsnmp_pdu));
 5717|  18.2k|    if (pdu == NULL) {
  ------------------
  |  Branch (5717:9): [True: 0, False: 18.2k]
  ------------------
 5718|      0|        DEBUGMSGTL(("sess_process_packet", "can't malloc space for PDU\n"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 5719|      0|        return NULL;
 5720|      0|    }
 5721|       |
 5722|       |    /*
 5723|       |     * Save the transport-level data specific to this reception (e.g. UDP
 5724|       |     * source address).  
 5725|       |     */
 5726|       |
 5727|  18.2k|    pdu->transport_data = opaque;
 5728|  18.2k|    pdu->transport_data_length = olength;
 5729|  18.2k|    pdu->tDomain = transport->domain;
 5730|  18.2k|    pdu->tDomainLen = transport->domain_length;
 5731|  18.2k|    return pdu;
 5732|  18.2k|}
snmp_read2:
 6132|     81|{
 6133|     81|    struct session_list *slp, *next;
 6134|       |
 6135|     81|    snmp_res_lock(MT_LIBRARY_ID, MT_LIB_SESSION);
  ------------------
  |  |   79|     81|#define snmp_res_lock(x,y) do {} while (0)
  |  |  ------------------
  |  |  |  Branch (79:41): [Folded, False: 81]
  |  |  ------------------
  ------------------
 6136|  3.40k|    for (slp = Sessions; slp; slp = next) {
  ------------------
  |  Branch (6136:26): [True: 3.32k, False: 81]
  ------------------
 6137|  3.32k|        next = slp->next;
 6138|  3.32k|        snmp_sess_read2(slp, fdset);
 6139|  3.32k|    }
 6140|     81|    snmp_res_unlock(MT_LIBRARY_ID, MT_LIB_SESSION);
  ------------------
  |  |   80|     81|#define snmp_res_unlock(x,y) do {} while (0)
  |  |  ------------------
  |  |  |  Branch (80:43): [Folded, False: 81]
  |  |  ------------------
  ------------------
 6141|     81|}
_sess_read:
 6621|  3.32k|{
 6622|  3.32k|    netsnmp_transport *transport;
 6623|       |
 6624|  3.32k|    if (!slp || !fdset)
  ------------------
  |  Branch (6624:9): [True: 0, False: 3.32k]
  |  Branch (6624:17): [True: 0, False: 3.32k]
  ------------------
 6625|      0|        return 0;
 6626|       |
 6627|  3.32k|    transport = slp->transport;
 6628|       |
 6629|  3.32k|    if (!transport || !NETSNMP_LARGE_FD_ISSET(transport->sock, fdset)) {
  ------------------
  |  |   50|  3.32k|                    netsnmp_large_fd_is_set(fd, fdset)
  ------------------
  |  Branch (6629:9): [True: 0, False: 3.32k]
  |  Branch (6629:23): [True: 0, False: 3.32k]
  ------------------
 6630|      0|        DEBUGMSGTL(("sess_read", "not reading transport socket\n"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 6631|      0|        return 0;
 6632|      0|    }
 6633|       |
 6634|  3.32k|    return __sess_read(slp);
 6635|  3.32k|}
snmp_sess_read2:
 6657|  3.32k|{
 6658|  3.32k|    netsnmp_session *pss;
 6659|  3.32k|    int             rc;
 6660|       |
 6661|  3.32k|    rc = _sess_read(slp, fdset);
 6662|  3.32k|    pss = slp->session;
 6663|  3.32k|    if (rc && pss->s_snmp_errno) {
  ------------------
  |  Branch (6663:9): [True: 2.41k, False: 907]
  |  Branch (6663:15): [True: 2.41k, False: 0]
  ------------------
 6664|  2.41k|        SET_SNMP_ERROR(pss->s_snmp_errno);
  ------------------
  |  |   43|  2.41k|#define SET_SNMP_ERROR(x) snmp_errno=(x)
  ------------------
 6665|  2.41k|    }
 6666|  3.32k|    return rc;
 6667|  3.32k|}
snmp_oid_compare:
 7205|      6|{
 7206|      6|    register int    len;
 7207|      6|    register const oid *name1 = in_name1;
 7208|      6|    register const oid *name2 = in_name2;
 7209|       |
 7210|       |    /*
 7211|       |     * len = minimum of len1 and len2 
 7212|       |     */
 7213|      6|    if (len1 < len2)
  ------------------
  |  Branch (7213:9): [True: 0, False: 6]
  ------------------
 7214|      0|        len = len1;
 7215|      6|    else
 7216|      6|        len = len2;
 7217|       |    /*
 7218|       |     * find first non-matching OID 
 7219|       |     */
 7220|     62|    while (len-- > 0) {
  ------------------
  |  Branch (7220:12): [True: 60, False: 2]
  ------------------
 7221|       |        /*
 7222|       |         * these must be done in separate comparisons, since
 7223|       |         * subtracting them and using that result has problems with
 7224|       |         * subids > 2^31. 
 7225|       |         */
 7226|     60|        if (*(name1) != *(name2)) {
  ------------------
  |  Branch (7226:13): [True: 4, False: 56]
  ------------------
 7227|      4|            if (*(name1) < *(name2))
  ------------------
  |  Branch (7227:17): [True: 2, False: 2]
  ------------------
 7228|      2|                return -1;
 7229|      2|            return 1;
 7230|      4|        }
 7231|     56|        name1++;
 7232|     56|        name2++;
 7233|     56|    }
 7234|       |    /*
 7235|       |     * both OIDs equal up to length of shorter OID 
 7236|       |     */
 7237|      2|    if (len1 < len2)
  ------------------
  |  Branch (7237:9): [True: 0, False: 2]
  ------------------
 7238|      0|        return -1;
 7239|      2|    if (len2 < len1)
  ------------------
  |  Branch (7239:9): [True: 0, False: 2]
  ------------------
 7240|      0|        return 1;
 7241|      2|    return 0;
 7242|      2|}
netsnmp_oid_equals:
 7342|     66|{
 7343|     66|    register const oid *name1 = in_name1;
 7344|     66|    register const oid *name2 = in_name2;
 7345|     66|    register int    len = len1;
 7346|       |
 7347|       |    /*
 7348|       |     * len = minimum of len1 and len2 
 7349|       |     */
 7350|     66|    if (len1 != len2)
  ------------------
  |  Branch (7350:9): [True: 44, False: 22]
  ------------------
 7351|     44|        return 1;
 7352|       |    /*
 7353|       |     * Handle 'null' OIDs
 7354|       |     */
 7355|     22|    if (len1 == 0)
  ------------------
  |  Branch (7355:9): [True: 0, False: 22]
  ------------------
 7356|      0|        return 0;   /* Two null OIDs are (trivially) the same */
 7357|     22|    if (!name1 || !name2)
  ------------------
  |  Branch (7357:9): [True: 0, False: 22]
  |  Branch (7357:19): [True: 0, False: 22]
  ------------------
 7358|      0|        return 1;   /* Otherwise something's wrong, so report a non-match */
 7359|       |    /*
 7360|       |     * find first non-matching OID 
 7361|       |     */
 7362|    187|    while (len-- > 0) {
  ------------------
  |  Branch (7362:12): [True: 187, False: 0]
  ------------------
 7363|       |        /*
 7364|       |         * these must be done in separate comparisons, since
 7365|       |         * subtracting them and using that result has problems with
 7366|       |         * subids > 2^31. 
 7367|       |         */
 7368|    187|        if (*(name1++) != *(name2++))
  ------------------
  |  Branch (7368:13): [True: 22, False: 165]
  ------------------
 7369|     22|            return 1;
 7370|    187|    }
 7371|      0|    return 0;
 7372|     22|}
snmp_duplicate_objid:
 8168|    166|{
 8169|    166|    oid            *returnOid;
 8170|    166|    if (objToCopy != NULL && objToCopyLen != 0) {
  ------------------
  |  Branch (8170:9): [True: 166, False: 0]
  |  Branch (8170:30): [True: 166, False: 0]
  ------------------
 8171|    166|        returnOid = (oid *) malloc(objToCopyLen * sizeof(oid));
 8172|    166|        if (returnOid) {
  ------------------
  |  Branch (8172:13): [True: 166, False: 0]
  ------------------
 8173|    166|            memcpy(returnOid, objToCopy, objToCopyLen * sizeof(oid));
 8174|    166|        }
 8175|    166|    } else
 8176|      0|        returnOid = NULL;
 8177|    166|    return returnOid;
 8178|    166|}
snmp_increment_statistic:
 8188|  3.32k|{
 8189|  3.32k|    if (which >= 0 && which < NETSNMP_STAT_MAX_STATS) {
  ------------------
  |  |  710|  3.32k|#define  NETSNMP_STAT_MAX_STATS              (STAT_TLSTM_STATS_END+1)
  |  |  ------------------
  |  |  |  |  706|  3.32k|#define  STAT_TLSTM_STATS_END          STAT_TLSTM_SNMPTLSTMSESSIONINVALIDCACHES
  |  |  |  |  ------------------
  |  |  |  |  |  |  703|  3.32k|#define  STAT_TLSTM_SNMPTLSTMSESSIONINVALIDCACHES              56
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (8189:9): [True: 3.32k, False: 0]
  |  Branch (8189:23): [True: 3.32k, False: 0]
  ------------------
 8190|  3.32k|        statistics[which]++;
 8191|  3.32k|        return statistics[which];
 8192|  3.32k|    }
 8193|      0|    return 0;
 8194|  3.32k|}
snmp_init_statistics:
 8216|      1|{
 8217|      1|    memset(statistics, 0, sizeof(statistics));
 8218|      1|}
snmp_api.c:_init_snmp:
  719|    163|{
  720|       |
  721|    163|    struct timeval  tv;
  722|    163|    long            tmpReqid, tmpMsgid;
  723|       |
  724|    163|    if (_init_snmp_init_done)
  ------------------
  |  Branch (724:9): [True: 162, False: 1]
  ------------------
  725|    162|        return;
  726|      1|    _init_snmp_init_done = 1;
  727|      1|    Reqid = 1;
  728|       |
  729|      1|    snmp_res_init();            /* initialize the mt locking structures */
  ------------------
  |  |   78|      1|#define snmp_res_init() do {} while (0)
  |  |  ------------------
  |  |  |  Branch (78:38): [Folded, False: 1]
  |  |  ------------------
  ------------------
  730|      1|#ifndef NETSNMP_DISABLE_MIB_LOADING
  731|      1|    netsnmp_init_mib_internals();
  732|      1|#endif /* NETSNMP_DISABLE_MIB_LOADING */
  733|      1|    netsnmp_tdomain_init();
  734|       |
  735|      1|    gettimeofday(&tv, (struct timezone *) 0);
  736|       |    /*
  737|       |     * Now = tv;
  738|       |     */
  739|       |
  740|       |    /*
  741|       |     * get pseudo-random values for request ID and message ID 
  742|       |     */
  743|      1|    netsnmp_srandom((unsigned)(tv.tv_sec ^ tv.tv_usec));
  744|      1|    tmpReqid = netsnmp_random();
  745|      1|    tmpMsgid = netsnmp_random();
  746|       |
  747|       |    /*
  748|       |     * don't allow zero value to repeat init 
  749|       |     */
  750|      1|    if (tmpReqid == 0)
  ------------------
  |  Branch (750:9): [True: 0, False: 1]
  ------------------
  751|      0|        tmpReqid = 1;
  752|      1|    if (tmpMsgid == 0)
  ------------------
  |  Branch (752:9): [True: 0, False: 1]
  ------------------
  753|      0|        tmpMsgid = 1;
  754|      1|    Reqid = tmpReqid;
  755|      1|    Msgid = tmpMsgid;
  756|       |
  757|      1|    netsnmp_register_default_domain("snmp", "udp udp6");
  758|      1|    netsnmp_register_default_domain("snmptrap", "udp udp6");
  759|       |
  760|      1|    netsnmp_register_default_target("snmp", "udp", ":161");
  761|      1|    netsnmp_register_default_target("snmp", "tcp", ":161");
  762|      1|    netsnmp_register_default_target("snmp", "udp6", ":161");
  763|      1|    netsnmp_register_default_target("snmp", "tcp6", ":161");
  764|      1|    netsnmp_register_default_target("snmp", "dtlsudp", ":10161");
  765|      1|    netsnmp_register_default_target("snmp", "tlstcp", ":10161");
  766|      1|    netsnmp_register_default_target("snmp", "ipx", "/36879");
  767|       |
  768|      1|    netsnmp_register_default_target("snmptrap", "udp", ":162");
  769|      1|    netsnmp_register_default_target("snmptrap", "tcp", ":162");
  770|      1|    netsnmp_register_default_target("snmptrap", "udp6", ":162");
  771|      1|    netsnmp_register_default_target("snmptrap", "tcp6", ":162");
  772|      1|    netsnmp_register_default_target("snmptrap", "dtlsudp", ":10162");
  773|      1|    netsnmp_register_default_target("snmptrap", "tlstcp", ":10162");
  774|      1|    netsnmp_register_default_target("snmptrap", "ipx", "/36880");
  775|       |
  776|      1|    netsnmp_ds_set_int(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  777|      1|                       NETSNMP_DS_LIB_HEX_OUTPUT_LENGTH, 16);
  ------------------
  |  |  121|      1|#define NETSNMP_DS_LIB_HEX_OUTPUT_LENGTH    6
  ------------------
  778|      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
  ------------------
  779|      1|                       DEFAULT_RETRIES);
  ------------------
  |  |  184|      1|#define DEFAULT_RETRIES	    5
  ------------------
  780|      1|    netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  781|      1|			   NETSNMP_DS_LIB_MIB_ERRORS, 1);
  ------------------
  |  |   59|      1|#define NETSNMP_DS_LIB_MIB_ERRORS          0
  ------------------
  782|       |
  783|      1|#ifdef NETSNMP_USE_REVERSE_ASNENCODING
  784|      1|    netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  785|      1|			   NETSNMP_DS_LIB_REVERSE_ENCODE,
  ------------------
  |  |   80|      1|#define NETSNMP_DS_LIB_REVERSE_ENCODE      20   /* encode packets from back to front */
  ------------------
  786|      1|			   NETSNMP_DEFAULT_ASNENCODING_DIRECTION);
  ------------------
  |  | 1998|      1|#define NETSNMP_DEFAULT_ASNENCODING_DIRECTION 1 /* 1 = reverse, 0 = forwards */
  ------------------
  787|      1|#endif
  788|      1|}
snmp_api.c:register_default_handlers:
  817|      1|{
  818|      1|    netsnmp_ds_register_config(ASN_BOOLEAN, "snmp", "dumpPacket",
  ------------------
  |  |   72|      1|#define ASN_BOOLEAN	    0x01U
  ------------------
  819|      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
  ------------------
  820|      1|    netsnmp_ds_register_config(ASN_BOOLEAN, "snmp", "reverseEncodeBER",
  ------------------
  |  |   72|      1|#define ASN_BOOLEAN	    0x01U
  ------------------
  821|      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 */
  ------------------
  822|      1|    netsnmp_ds_register_config(ASN_INTEGER, "snmp", "defaultPort",
  ------------------
  |  |   75|      1|#define ASN_INTEGER	    0x02U
  ------------------
  823|      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
  ------------------
  824|      1|#ifndef NETSNMP_FEATURE_REMOVE_RUNTIME_DISABLE_VERSION
  825|      1|    netsnmp_ds_register_config(ASN_BOOLEAN, "snmp", "disableSNMPv3",
  ------------------
  |  |   72|      1|#define ASN_BOOLEAN	    0x01U
  ------------------
  826|      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 */
  ------------------
  827|      1|#endif /* NETSNMP_FEATURE_REMOVE_RUNTIME_DISABLE_VERSION */
  828|      1|#if !defined(NETSNMP_DISABLE_SNMPV1) || !defined(NETSNMP_DISABLE_SNMPV2C)
  829|      1|#ifndef NETSNMP_FEATURE_REMOVE_RUNTIME_DISABLE_VERSION
  830|      1|#if !defined(NETSNMP_DISABLE_SNMPV1)
  831|      1|    netsnmp_ds_register_config(ASN_BOOLEAN, "snmp", "disableSNMPv1",
  ------------------
  |  |   72|      1|#define ASN_BOOLEAN	    0x01U
  ------------------
  832|      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 */
  ------------------
  833|      1|#endif
  834|      1|#if !defined(NETSNMP_DISABLE_SNMPV2C)
  835|      1|    netsnmp_ds_register_config(ASN_BOOLEAN, "snmp", "disableSNMPv2c",
  ------------------
  |  |   72|      1|#define ASN_BOOLEAN	    0x01U
  ------------------
  836|      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 */
  ------------------
  837|      1|#endif
  838|      1|#endif /* NETSNMP_FEATURE_REMOVE_RUNTIME_DISABLE_VERSION */
  839|      1|    netsnmp_ds_register_config(ASN_OCTET_STR, "snmp", "defCommunity",
  ------------------
  |  |   78|      1|#define ASN_OCTET_STR	    0x04U
  ------------------
  840|      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
  ------------------
  841|      1|#endif /* !defined(NETSNMP_DISABLE_SNMPV1) || !defined(NETSNMP_DISABLE_SNMPV2C) */
  842|      1|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "noTokenWarnings",
  ------------------
  |  |   72|      1|#define ASN_BOOLEAN	    0x01U
  ------------------
  843|      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 */
  ------------------
  844|      1|    netsnmp_ds_register_config(ASN_BOOLEAN, "snmp", "noRangeCheck",
  ------------------
  |  |   72|      1|#define ASN_BOOLEAN	    0x01U
  ------------------
  845|      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 */
  ------------------
  846|      1|    netsnmp_ds_register_premib(ASN_OCTET_STR, "snmp", "persistentDir",
  ------------------
  |  |   78|      1|#define ASN_OCTET_STR	    0x04U
  ------------------
  847|      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
  ------------------
  848|      1|    netsnmp_ds_register_config(ASN_OCTET_STR, "snmp", "tempFilePattern",
  ------------------
  |  |   78|      1|#define ASN_OCTET_STR	    0x04U
  ------------------
  849|      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
  ------------------
  850|      1|    netsnmp_ds_register_config(ASN_BOOLEAN, "snmp", "noDisplayHint",
  ------------------
  |  |   72|      1|#define ASN_BOOLEAN	    0x01U
  ------------------
  851|      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 */
  ------------------
  852|      1|    netsnmp_ds_register_config(ASN_BOOLEAN, "snmp", "16bitIDs",
  ------------------
  |  |   72|      1|#define ASN_BOOLEAN	    0x01U
  ------------------
  853|      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 */
  ------------------
  854|      1|    netsnmp_ds_register_premib(ASN_OCTET_STR, "snmp", "clientaddr",
  ------------------
  |  |   78|      1|#define ASN_OCTET_STR	    0x04U
  ------------------
  855|      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
  ------------------
  856|      1|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "clientaddrUsesPort",
  ------------------
  |  |   72|      1|#define ASN_BOOLEAN	    0x01U
  ------------------
  857|      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 */
  ------------------
  858|      1|    netsnmp_ds_register_config(ASN_INTEGER, "snmp", "serverSendBuf",
  ------------------
  |  |   75|      1|#define ASN_INTEGER	    0x02U
  ------------------
  859|      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) */
  ------------------
  860|      1|    netsnmp_ds_register_config(ASN_INTEGER, "snmp", "serverRecvBuf",
  ------------------
  |  |   75|      1|#define ASN_INTEGER	    0x02U
  ------------------
  861|      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) */
  ------------------
  862|      1|    netsnmp_ds_register_config(ASN_INTEGER, "snmp", "clientSendBuf",
  ------------------
  |  |   75|      1|#define ASN_INTEGER	    0x02U
  ------------------
  863|      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) */
  ------------------
  864|      1|    netsnmp_ds_register_config(ASN_INTEGER, "snmp", "clientRecvBuf",
  ------------------
  |  |   75|      1|#define ASN_INTEGER	    0x02U
  ------------------
  865|      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) */
  ------------------
  866|      1|    netsnmp_ds_register_config(ASN_INTEGER, "snmp", "sendMessageMaxSize",
  ------------------
  |  |   75|      1|#define ASN_INTEGER	    0x02U
  ------------------
  867|      1|                               NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  868|      1|                               NETSNMP_DS_LIB_MSG_SEND_MAX);
  ------------------
  |  |  132|      1|#define NETSNMP_DS_LIB_MSG_SEND_MAX        16 /* global max response size */
  ------------------
  869|      1|    netsnmp_ds_register_config(ASN_BOOLEAN, "snmp", "noPersistentLoad",
  ------------------
  |  |   72|      1|#define ASN_BOOLEAN	    0x01U
  ------------------
  870|      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 */
  ------------------
  871|      1|    netsnmp_ds_register_config(ASN_BOOLEAN, "snmp", "noPersistentSave",
  ------------------
  |  |   72|      1|#define ASN_BOOLEAN	    0x01U
  ------------------
  872|      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 */
  ------------------
  873|      1|    netsnmp_ds_register_config(ASN_BOOLEAN, "snmp",
  ------------------
  |  |   72|      1|#define ASN_BOOLEAN	    0x01U
  ------------------
  874|      1|                               "noContextEngineIDDiscovery",
  875|      1|                               NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  876|      1|                               NETSNMP_DS_LIB_NO_DISCOVERY);
  ------------------
  |  |   98|      1|#define NETSNMP_DS_LIB_NO_DISCOVERY        38 /* don't support RFC5343 contextEngineID discovery */
  ------------------
  877|      1|    netsnmp_ds_register_config(ASN_INTEGER, "snmp", "timeout",
  ------------------
  |  |   75|      1|#define ASN_INTEGER	    0x02U
  ------------------
  878|      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
  ------------------
  879|      1|    netsnmp_ds_register_config(ASN_INTEGER, "snmp", "retries",
  ------------------
  |  |   75|      1|#define ASN_INTEGER	    0x02U
  ------------------
  880|      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
  ------------------
  881|      1|    netsnmp_ds_register_config(ASN_OCTET_STR, "snmp", "outputPrecision",
  ------------------
  |  |   78|      1|#define ASN_OCTET_STR	    0x04U
  ------------------
  882|      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
  ------------------
  883|       |
  884|       |
  885|      1|    netsnmp_register_service_handlers();
  886|      1|}
snmp_api.c:snmp_sess_copy:
 1407|     81|{
 1408|     81|    struct session_list *psl;
 1409|     81|    psl = _sess_copy(pss);
 1410|     81|    if (!psl) {
  ------------------
  |  Branch (1410:9): [True: 0, False: 81]
  ------------------
 1411|      0|        if (!pss->s_snmp_errno) {
  ------------------
  |  Branch (1411:13): [True: 0, False: 0]
  ------------------
 1412|      0|            pss->s_snmp_errno = SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
 1413|      0|        }
 1414|      0|        SET_SNMP_ERROR(pss->s_snmp_errno);
  ------------------
  |  |   43|      0|#define SET_SNMP_ERROR(x) snmp_errno=(x)
  ------------------
 1415|      0|    }
 1416|     81|    return psl;
 1417|     81|}
snmp_api.c:_sess_copy:
 1116|     81|{
 1117|     81|    struct session_list *slp;
 1118|     81|    struct snmp_internal_session *isp;
 1119|     81|    netsnmp_session *session;
 1120|     81|    struct snmp_secmod_def *sptr;
 1121|     81|    char           *cp;
 1122|     81|    u_char         *ucp;
 1123|       |
 1124|     81|    in_session->s_snmp_errno = 0;
 1125|     81|    in_session->s_errno = 0;
 1126|       |
 1127|       |    /*
 1128|       |     * Copy session structure and link into list 
 1129|       |     */
 1130|     81|    slp = calloc(1, sizeof(struct session_list));
 1131|     81|    if (slp == NULL) {
  ------------------
  |  Branch (1131:9): [True: 0, False: 81]
  ------------------
 1132|      0|        in_session->s_snmp_errno = SNMPERR_MALLOC;
  ------------------
  |  |  246|      0|#define SNMPERR_MALLOC			(-62)
  ------------------
 1133|      0|        return (NULL);
 1134|      0|    }
 1135|       |
 1136|     81|    slp->transport = NULL;
 1137|       |
 1138|     81|    isp = calloc(1, sizeof(struct snmp_internal_session));
 1139|       |
 1140|     81|    if (isp == NULL) {
  ------------------
  |  Branch (1140:9): [True: 0, False: 81]
  ------------------
 1141|      0|        snmp_sess_close(slp);
 1142|      0|        in_session->s_snmp_errno = SNMPERR_MALLOC;
  ------------------
  |  |  246|      0|#define SNMPERR_MALLOC			(-62)
  ------------------
 1143|      0|        return (NULL);
 1144|      0|    }
 1145|       |
 1146|     81|    slp->internal = isp;
 1147|     81|    slp->session = netsnmp_memdup(in_session, sizeof(netsnmp_session));
 1148|     81|    if (slp->session == NULL) {
  ------------------
  |  Branch (1148:9): [True: 0, False: 81]
  ------------------
 1149|      0|        snmp_sess_close(slp);
 1150|      0|        in_session->s_snmp_errno = SNMPERR_MALLOC;
  ------------------
  |  |  246|      0|#define SNMPERR_MALLOC			(-62)
  ------------------
 1151|      0|        return (NULL);
 1152|      0|    }
 1153|     81|    session = slp->session;
 1154|       |
 1155|       |    /*
 1156|       |     * zero out pointers so if we have to free the session we wont free mem
 1157|       |     * owned by in_session 
 1158|       |     */
 1159|     81|    session->localname = NULL;
 1160|     81|    session->peername = NULL;
 1161|     81|    session->community = NULL;
 1162|     81|    session->contextEngineID = NULL;
 1163|     81|    session->contextName = NULL;
 1164|     81|    session->securityEngineID = NULL;
 1165|     81|    session->securityName = NULL;
 1166|     81|    session->securityAuthProto = NULL;
 1167|     81|    session->securityAuthLocalKey = NULL;
 1168|     81|    session->securityPrivProto = NULL;
 1169|     81|    session->securityPrivLocalKey = NULL;
 1170|     81|    session->sessUser = NULL;
 1171|     81|    session->paramName = NULL;
 1172|     81|#ifndef NETSNMP_NO_TRAP_STATS
 1173|     81|    session->trap_stats = NULL;
 1174|     81|#endif
 1175|       |    /*
 1176|       |     * session now points to the new structure that still contains pointers to
 1177|       |     * data allocated elsewhere.  Some of this data is copied to space malloc'd
 1178|       |     * here, and the pointer replaced with the new one.
 1179|       |     */
 1180|       |
 1181|     81|    if (in_session->peername != NULL) {
  ------------------
  |  Branch (1181:9): [True: 81, False: 0]
  ------------------
 1182|     81|        session->peername =
 1183|     81|            netsnmp_strdup_and_null((u_char*)in_session->peername,
 1184|     81|                                    strlen(in_session->peername));
 1185|     81|        if (session->peername == NULL) {
  ------------------
  |  Branch (1185:13): [True: 0, False: 81]
  ------------------
 1186|      0|            snmp_sess_close(slp);
 1187|      0|            in_session->s_snmp_errno = SNMPERR_MALLOC;
  ------------------
  |  |  246|      0|#define SNMPERR_MALLOC			(-62)
  ------------------
 1188|      0|            return (NULL);
 1189|      0|        }
 1190|     81|    }
 1191|       |
 1192|       |    /*
 1193|       |     * Fill in defaults if necessary 
 1194|       |     */
 1195|     81|#if !defined(NETSNMP_DISABLE_SNMPV1) || !defined(NETSNMP_DISABLE_SNMPV2C)
 1196|     81|    if (in_session->community_len != SNMP_DEFAULT_COMMUNITY_LEN) {
  ------------------
  |  |   78|     81|#define SNMP_DEFAULT_COMMUNITY_LEN  0   /* to get a default community name */
  ------------------
  |  Branch (1196:9): [True: 0, False: 81]
  ------------------
 1197|      0|        ucp = netsnmp_memdup(in_session->community, in_session->community_len);
 1198|     81|    } else {
 1199|     81|        if ((cp = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|     81|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (1199:13): [True: 0, False: 81]
  ------------------
 1200|     81|					NETSNMP_DS_LIB_COMMUNITY)) != NULL) {
  ------------------
  |  |  158|     81|#define NETSNMP_DS_LIB_COMMUNITY         7
  ------------------
 1201|      0|            session->community_len = strlen(cp);
 1202|      0|            ucp = (u_char *) strdup(cp);
 1203|     81|        } else {
 1204|       |#ifdef NETSNMP_NO_ZEROLENGTH_COMMUNITY
 1205|       |            session->community_len = strlen(DEFAULT_COMMUNITY);
 1206|       |            ucp = netsnmp_memdup(DEFAULT_COMMUNITY, session->community_len);
 1207|       |#else
 1208|     81|            ucp = (u_char *) strdup("");
 1209|     81|#endif
 1210|     81|        }
 1211|     81|    }
 1212|       |
 1213|     81|    if (ucp == NULL) {
  ------------------
  |  Branch (1213:9): [True: 0, False: 81]
  ------------------
 1214|      0|        snmp_sess_close(slp);
 1215|      0|        in_session->s_snmp_errno = SNMPERR_MALLOC;
  ------------------
  |  |  246|      0|#define SNMPERR_MALLOC			(-62)
  ------------------
 1216|      0|        return (NULL);
 1217|      0|    }
 1218|     81|    session->community = ucp;   /* replace pointer with pointer to new data */
 1219|     81|#endif
 1220|       |
 1221|     81|    if (session->securityLevel <= 0) {
  ------------------
  |  Branch (1221:9): [True: 81, False: 0]
  ------------------
 1222|     81|        session->securityLevel =
 1223|     81|            netsnmp_ds_get_int(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_SECLEVEL);
  ------------------
  |  |   48|     81|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                          netsnmp_ds_get_int(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_SECLEVEL);
  ------------------
  |  |  115|     81|#define NETSNMP_DS_LIB_SECLEVEL             1
  ------------------
 1224|     81|    }
 1225|       |
 1226|     81|    if (in_session->securityEngineIDLen > 0) {
  ------------------
  |  Branch (1226:9): [True: 0, False: 81]
  ------------------
 1227|      0|        ucp = netsnmp_memdup(in_session->securityEngineID,
 1228|      0|                             in_session->securityEngineIDLen);
 1229|      0|        if (ucp == NULL) {
  ------------------
  |  Branch (1229:13): [True: 0, False: 0]
  ------------------
 1230|      0|            snmp_sess_close(slp);
 1231|      0|            in_session->s_snmp_errno = SNMPERR_MALLOC;
  ------------------
  |  |  246|      0|#define SNMPERR_MALLOC			(-62)
  ------------------
 1232|      0|            return (NULL);
 1233|      0|        }
 1234|      0|        session->securityEngineID = ucp;
 1235|      0|        session->securityEngineIDLen = in_session->securityEngineIDLen;
 1236|      0|    }
 1237|       |
 1238|     81|    if (in_session->contextEngineIDLen > 0) {
  ------------------
  |  Branch (1238:9): [True: 0, False: 81]
  ------------------
 1239|      0|        ucp = netsnmp_memdup(in_session->contextEngineID,
 1240|      0|                             in_session->contextEngineIDLen);
 1241|      0|        if (ucp == NULL) {
  ------------------
  |  Branch (1241:13): [True: 0, False: 0]
  ------------------
 1242|      0|            snmp_sess_close(slp);
 1243|      0|            in_session->s_snmp_errno = SNMPERR_MALLOC;
  ------------------
  |  |  246|      0|#define SNMPERR_MALLOC			(-62)
  ------------------
 1244|      0|            return (NULL);
 1245|      0|        }
 1246|      0|        session->contextEngineID = ucp;
 1247|      0|        session->contextEngineIDLen = in_session->contextEngineIDLen;
 1248|     81|    } else if (in_session->securityEngineIDLen > 0) {
  ------------------
  |  Branch (1248:16): [True: 0, False: 81]
  ------------------
 1249|       |        /*
 1250|       |         * default contextEngineID to securityEngineIDLen if defined 
 1251|       |         */
 1252|      0|        ucp = netsnmp_memdup(in_session->securityEngineID,
 1253|      0|                             in_session->securityEngineIDLen);
 1254|      0|        if (ucp == NULL) {
  ------------------
  |  Branch (1254:13): [True: 0, False: 0]
  ------------------
 1255|      0|            snmp_sess_close(slp);
 1256|      0|            in_session->s_snmp_errno = SNMPERR_MALLOC;
  ------------------
  |  |  246|      0|#define SNMPERR_MALLOC			(-62)
  ------------------
 1257|      0|            return (NULL);
 1258|      0|        }
 1259|      0|        session->contextEngineID = ucp;
 1260|      0|        session->contextEngineIDLen = in_session->securityEngineIDLen;
 1261|      0|    }
 1262|       |
 1263|     81|    if (in_session->contextName) {
  ------------------
  |  Branch (1263:9): [True: 0, False: 81]
  ------------------
 1264|      0|        session->contextName = strdup(in_session->contextName);
 1265|      0|        if (session->contextName == NULL) {
  ------------------
  |  Branch (1265:13): [True: 0, False: 0]
  ------------------
 1266|      0|            snmp_sess_close(slp);
 1267|      0|            return (NULL);
 1268|      0|        }
 1269|      0|        session->contextNameLen = in_session->contextNameLen;
 1270|     81|    } else {
 1271|     81|        if ((cp = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|     81|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (1271:13): [True: 0, False: 81]
  ------------------
 1272|     81|                                        NETSNMP_DS_LIB_CONTEXT)) != NULL)
  ------------------
  |  |  152|     81|#define NETSNMP_DS_LIB_CONTEXT           1
  ------------------
 1273|      0|            cp = strdup(cp);
 1274|     81|        else
 1275|     81|            cp = strdup(SNMP_DEFAULT_CONTEXT);
  ------------------
  |  |   92|     81|#define SNMP_DEFAULT_CONTEXT        ""
  ------------------
 1276|     81|        if (cp == NULL) {
  ------------------
  |  Branch (1276:13): [True: 0, False: 81]
  ------------------
 1277|      0|            snmp_sess_close(slp);
 1278|      0|            return (NULL);
 1279|      0|        }
 1280|     81|        session->contextName = cp;
 1281|     81|        session->contextNameLen = strlen(cp);
 1282|     81|    }
 1283|       |
 1284|     81|    if (in_session->securityName) {
  ------------------
  |  Branch (1284:9): [True: 0, False: 81]
  ------------------
 1285|      0|        session->securityName = strdup(in_session->securityName);
 1286|      0|        if (session->securityName == NULL) {
  ------------------
  |  Branch (1286:13): [True: 0, False: 0]
  ------------------
 1287|      0|            snmp_sess_close(slp);
 1288|      0|            return (NULL);
 1289|      0|        }
 1290|     81|    } else if ((cp = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|     81|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (1290:16): [True: 0, False: 81]
  ------------------
 1291|     81|					   NETSNMP_DS_LIB_SECNAME)) != NULL) {
  ------------------
  |  |  151|     81|#define NETSNMP_DS_LIB_SECNAME           0
  ------------------
 1292|      0|        cp = strdup(cp);
 1293|      0|        if (cp == NULL) {
  ------------------
  |  Branch (1293:13): [True: 0, False: 0]
  ------------------
 1294|      0|            snmp_sess_close(slp);
 1295|      0|            return (NULL);
 1296|      0|        }
 1297|      0|        session->securityName = cp;
 1298|      0|        session->securityNameLen = strlen(cp);
 1299|      0|    }
 1300|       |
 1301|     81|    if (in_session->securityAuthLocalKey) {
  ------------------
  |  Branch (1301:9): [True: 0, False: 81]
  ------------------
 1302|      0|            session->securityAuthLocalKey =
 1303|      0|                netsnmp_memdup(in_session->securityAuthLocalKey,
 1304|      0|                               in_session->securityAuthLocalKeyLen);
 1305|      0|            session->securityAuthLocalKeyLen =
 1306|      0|                in_session->securityAuthLocalKeyLen;
 1307|      0|    }
 1308|       |
 1309|     81|    if (in_session->securityPrivLocalKey) {
  ------------------
  |  Branch (1309:9): [True: 0, False: 81]
  ------------------
 1310|      0|            session->securityPrivLocalKey =
 1311|      0|                netsnmp_memdup(in_session->securityPrivLocalKey,
 1312|      0|                               in_session->securityPrivLocalKeyLen);
 1313|      0|            session->securityPrivLocalKeyLen =
 1314|      0|                in_session->securityPrivLocalKeyLen;
 1315|      0|    }
 1316|       |
 1317|     81|    if (session->transport_configuration) {
  ------------------
  |  Branch (1317:9): [True: 0, False: 81]
  ------------------
 1318|      0|        session->transport_configuration =
 1319|      0|            CONTAINER_DUP(session->transport_configuration, NULL, 0);
 1320|      0|        if (!session->transport_configuration) {
  ------------------
  |  Branch (1320:13): [True: 0, False: 0]
  ------------------
 1321|      0|            snmp_sess_close(slp);
 1322|      0|            return NULL;
 1323|      0|        }
 1324|      0|    }
 1325|       |
 1326|     81|    if (session->retries == SNMP_DEFAULT_RETRIES) {
  ------------------
  |  |   79|     81|#define SNMP_DEFAULT_RETRIES	    -1
  ------------------
  |  Branch (1326:9): [True: 81, False: 0]
  ------------------
 1327|     81|        int retry = netsnmp_ds_get_int(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|     81|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1328|     81|                                       NETSNMP_DS_LIB_RETRIES);
  ------------------
  |  |  131|     81|#define NETSNMP_DS_LIB_RETRIES             15
  ------------------
 1329|     81|        if (retry < 0)
  ------------------
  |  Branch (1329:13): [True: 0, False: 81]
  ------------------
 1330|      0|            session->retries = DEFAULT_RETRIES;
  ------------------
  |  |  184|      0|#define DEFAULT_RETRIES	    5
  ------------------
 1331|     81|        else
 1332|     81|            session->retries = retry;
 1333|     81|    }
 1334|     81|    if (session->timeout == SNMP_DEFAULT_TIMEOUT) {
  ------------------
  |  |   80|     81|#define SNMP_DEFAULT_TIMEOUT	    -1
  ------------------
  |  Branch (1334:9): [True: 81, False: 0]
  ------------------
 1335|     81|        int timeout = netsnmp_ds_get_int(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|     81|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1336|     81|                                         NETSNMP_DS_LIB_TIMEOUT);
  ------------------
  |  |  130|     81|#define NETSNMP_DS_LIB_TIMEOUT             14
  ------------------
 1337|     81|        if (timeout <= 0)
  ------------------
  |  Branch (1337:13): [True: 81, False: 0]
  ------------------
 1338|     81|            session->timeout = DEFAULT_TIMEOUT;
  ------------------
  |  |  185|     81|#define DEFAULT_TIMEOUT	    (1000L * 1000L)
  ------------------
 1339|      0|        else
 1340|      0|            session->timeout = timeout * 1000L * 1000L;
 1341|     81|    }
 1342|     81|    session->sessid = snmp_get_next_sessid();
 1343|       |
 1344|     81|    snmp_call_callbacks(SNMP_CALLBACK_LIBRARY, SNMP_CALLBACK_SESSION_INIT,
  ------------------
  |  |   18|     81|#define SNMP_CALLBACK_LIBRARY     0
  ------------------
                  snmp_call_callbacks(SNMP_CALLBACK_LIBRARY, SNMP_CALLBACK_SESSION_INIT,
  ------------------
  |  |   29|     81|#define SNMP_CALLBACK_SESSION_INIT		5
  ------------------
 1345|     81|                        session);
 1346|       |
 1347|     81|    if ((sptr = find_sec_mod(session->securityModel)) != NULL) {
  ------------------
  |  Branch (1347:9): [True: 81, False: 0]
  ------------------
 1348|       |        /*
 1349|       |         * security module specific copying 
 1350|       |         */
 1351|     81|        if (sptr->session_setup) {
  ------------------
  |  Branch (1351:13): [True: 81, False: 0]
  ------------------
 1352|     81|            int ret = (*sptr->session_setup) (in_session, session);
 1353|     81|            if (ret != SNMPERR_SUCCESS) {
  ------------------
  |  |  184|     81|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  |  Branch (1353:17): [True: 0, False: 81]
  ------------------
 1354|      0|                snmp_sess_close(slp);
 1355|      0|                return NULL;
 1356|      0|            }
 1357|     81|        }
 1358|       |
 1359|       |        /*
 1360|       |         * security module specific opening
 1361|       |         */
 1362|     81|        if (sptr->session_open) {
  ------------------
  |  Branch (1362:13): [True: 0, False: 81]
  ------------------
 1363|      0|            int ret = (*sptr->session_open) (session);
 1364|      0|            if (ret != SNMPERR_SUCCESS) {
  ------------------
  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  |  Branch (1364:17): [True: 0, False: 0]
  ------------------
 1365|      0|                snmp_sess_close(slp);
 1366|      0|                return NULL;
 1367|      0|            }
 1368|      0|        }
 1369|     81|    }
 1370|       |
 1371|     81|#ifndef NETSNMP_NO_WRITE_SUPPORT
 1372|     81|    if (in_session->sessUser) {
  ------------------
  |  Branch (1372:9): [True: 0, False: 81]
  ------------------
 1373|      0|        struct usmUser *user;
 1374|       |
 1375|      0|        user = calloc(1, sizeof(struct usmUser));
 1376|      0|        if (user == NULL) {
  ------------------
  |  Branch (1376:13): [True: 0, False: 0]
  ------------------
 1377|      0|            snmp_sess_close(slp);
 1378|      0|            return NULL;
 1379|      0|        }
 1380|      0|        session->sessUser = usm_cloneFrom_user(in_session->sessUser, user);
 1381|      0|    }
 1382|     81|#endif /* NETSNMP_NO_WRITE_SUPPORT */
 1383|       |
 1384|     81|    if (in_session->paramName) {
  ------------------
  |  Branch (1384:9): [True: 0, False: 81]
  ------------------
 1385|      0|        session->paramName = strdup(in_session->paramName);
 1386|      0|        if (session->paramName == NULL) {
  ------------------
  |  Branch (1386:13): [True: 0, False: 0]
  ------------------
 1387|      0|            snmp_sess_close(slp);
 1388|      0|            return NULL;
 1389|      0|        }
 1390|      0|    }
 1391|     81|#ifndef NETSNMP_NO_TRAP_STATS
 1392|     81|    if (in_session->trap_stats) {
  ------------------
  |  Branch (1392:9): [True: 0, False: 81]
  ------------------
 1393|      0|        session->trap_stats = netsnmp_memdup(in_session->trap_stats,
 1394|      0|                                             sizeof(*in_session->trap_stats));
 1395|      0|        if (session->trap_stats == NULL) {
  ------------------
  |  Branch (1395:13): [True: 0, False: 0]
  ------------------
 1396|      0|            snmp_sess_close(slp);
 1397|      0|            return NULL;
 1398|      0|        }
 1399|      0|    }
 1400|     81|#endif
 1401|       |
 1402|     81|    return (slp);
 1403|     81|}
snmp_api.c:netsnmp_free_transport_config:
 2044|     81|{
 2045|     81|    if (!tc)
  ------------------
  |  Branch (2045:9): [True: 81, False: 0]
  ------------------
 2046|     81|        return;
 2047|       |
 2048|      0|    CONTAINER_CLEAR(tc, netsnmp_free_one_tr_cfg, NULL);
 2049|      0|    CONTAINER_FREE(tc);
 2050|      0|}
snmp_api.c:free_securityStateRef:
 4192|  18.2k|{
 4193|  18.2k|    struct snmp_secmod_def *sptr;
 4194|       |
 4195|  18.2k|    if (!pdu->securityStateRef)
  ------------------
  |  Branch (4195:9): [True: 18.2k, False: 0]
  ------------------
 4196|  18.2k|        return;
 4197|       |
 4198|      0|    sptr = find_sec_mod(pdu->securityModel);
 4199|      0|    if (sptr) {
  ------------------
  |  Branch (4199:9): [True: 0, False: 0]
  ------------------
 4200|      0|        if (sptr->pdu_free_state_ref) {
  ------------------
  |  Branch (4200:13): [True: 0, False: 0]
  ------------------
 4201|      0|            (*sptr->pdu_free_state_ref) (pdu->securityStateRef);
 4202|      0|        } else {
 4203|      0|            snmp_log(LOG_ERR,
 4204|      0|                     "Security Model %d can't free state references\n",
 4205|      0|                     pdu->securityModel);
 4206|      0|	}
 4207|      0|    } else {
 4208|      0|	snmp_log(LOG_ERR,
 4209|      0|		 "Can't find security model to free ptr: %d\n",
 4210|      0|		 pdu->securityModel);
 4211|      0|    }
 4212|       |    pdu->securityStateRef = NULL;
 4213|      0|}
snmp_api.c:_snmp_parse:
 4418|  18.2k|{
 4419|  18.2k|#if !defined(NETSNMP_DISABLE_SNMPV1) || !defined(NETSNMP_DISABLE_SNMPV2C)
 4420|  18.2k|    u_char          community[COMMUNITY_MAX_LEN];
 4421|  18.2k|    size_t          community_length = COMMUNITY_MAX_LEN;
  ------------------
  |  |   41|  18.2k|#define COMMUNITY_MAX_LEN	256
  ------------------
 4422|  18.2k|#endif
 4423|  18.2k|    int             result = -1;
 4424|       |
 4425|  18.2k|    static const oid snmpEngineIDoid[]   = { 1,3,6,1,6,3,10,2,1,1,0};
 4426|  18.2k|    static size_t   snmpEngineIDoid_len = 11;
 4427|       |
 4428|  18.2k|    static char     ourEngineID[SNMP_SEC_PARAM_BUF_SIZE];
 4429|  18.2k|    static size_t   ourEngineID_len = sizeof(ourEngineID);
 4430|       |
 4431|  18.2k|    netsnmp_pdu    *pdu2 = NULL;
 4432|       |
 4433|  18.2k|    session->s_snmp_errno = 0;
 4434|  18.2k|    session->s_errno = 0;
 4435|       |
 4436|       |    /*
 4437|       |     * Ensure all incoming PDUs have a unique means of identification 
 4438|       |     * (This is not restricted to AgentX handling,
 4439|       |     * though that is where the need becomes visible)   
 4440|       |     */
 4441|  18.2k|    pdu->transid = snmp_get_next_transid();
 4442|       |
 4443|  18.2k|    if (session->version != SNMP_DEFAULT_VERSION) {
  ------------------
  |  |   90|  18.2k|#define SNMP_DEFAULT_VERSION	    -1
  ------------------
  |  Branch (4443:9): [True: 18.2k, False: 0]
  ------------------
 4444|  18.2k|        pdu->version = session->version;
 4445|  18.2k|    } else {
 4446|      0|        pdu->version = snmp_parse_version(data, length);
 4447|      0|    }
 4448|       |
 4449|  18.2k|    switch (pdu->version) {
 4450|      0|#if !defined(NETSNMP_DISABLE_SNMPV1) || !defined(NETSNMP_DISABLE_SNMPV2C)
 4451|      0|#ifndef NETSNMP_DISABLE_SNMPV1
 4452|      0|    case SNMP_VERSION_1:
  ------------------
  |  |  107|      0|#define SNMP_VERSION_1	   0
  ------------------
  |  Branch (4452:5): [True: 0, False: 18.2k]
  ------------------
 4453|      0|#endif
 4454|      0|#ifndef NETSNMP_DISABLE_SNMPV2C
 4455|  18.2k|    case SNMP_VERSION_2c:
  ------------------
  |  |  110|  18.2k|#define SNMP_VERSION_2c    1
  ------------------
  |  Branch (4455:5): [True: 18.2k, False: 0]
  ------------------
 4456|  18.2k|#endif
 4457|  18.2k|        NETSNMP_RUNTIME_PROTOCOL_CHECK_V1V2(pdu->version,unsupported_version);
  ------------------
  |  |  220|  18.2k|#define NETSNMP_RUNTIME_PROTOCOL_CHECK_V1V2(pc_ver, pc_target) do {    \
  |  |  221|  18.2k|        if (NETSNMP_RUNTIME_PROTOCOL_SKIP_V1(pc_ver) ||                \
  |  |  ------------------
  |  |  |  |  205|  36.5k|    ((pc_ver) == SNMP_VERSION_1 &&                                      \
  |  |  |  |  ------------------
  |  |  |  |  |  |  107|  36.5k|#define SNMP_VERSION_1	   0
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (205:6): [True: 0, False: 18.2k]
  |  |  |  |  ------------------
  |  |  |  |  206|  36.5k|     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|  18.2k|            NETSNMP_RUNTIME_PROTOCOL_SKIP_V2(pc_ver)) {                \
  |  |  ------------------
  |  |  |  |  215|  18.2k|    ((pc_ver) == SNMP_VERSION_2c &&                                     \
  |  |  |  |  ------------------
  |  |  |  |  |  |  110|  36.5k|#define SNMP_VERSION_2c    1
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (215:6): [True: 18.2k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  216|  18.2k|     netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,                      \
  |  |  |  |  ------------------
  |  |  |  |  |  |   48|  18.2k|#define NETSNMP_DS_LIBRARY_ID     0
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (216:6): [True: 0, False: 18.2k]
  |  |  |  |  ------------------
  |  |  |  |  217|  18.2k|                            NETSNMP_DS_LIB_DISABLE_V2c))
  |  |  |  |  ------------------
  |  |  |  |  |  |  104|  18.2k|#define NETSNMP_DS_LIB_DISABLE_V2c         44 /* disable SNMPv2c */
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  223|      0|            DEBUGMSGTL(("snmp:protocol:disabled", "enforced\n"));      \
  |  |  ------------------
  |  |  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  224|      0|            goto pc_target;                                            \
  |  |  225|      0|        }                                                              \
  |  |  226|  18.2k|    } while(0)
  |  |  ------------------
  |  |  |  Branch (226:13): [Folded, False: 18.2k]
  |  |  ------------------
  ------------------
 4458|  18.2k|        DEBUGMSGTL(("snmp_api", "Parsing SNMPv%ld message...\n",
  ------------------
  |  |   66|  18.2k|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|  18.2k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 18.2k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|  18.2k|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  18.2k|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|  18.2k|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|  18.2k|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 18.2k]
  |  |  ------------------
  ------------------
 4459|  18.2k|                    (1 + pdu->version)));
 4460|       |
 4461|       |        /*
 4462|       |         * authenticates message and returns length if valid 
 4463|       |         */
 4464|  18.2k|#ifndef NETSNMP_DISABLE_SNMPV1
 4465|  18.2k|        if (pdu->version == SNMP_VERSION_1) {
  ------------------
  |  |  107|  18.2k|#define SNMP_VERSION_1	   0
  ------------------
  |  Branch (4465:13): [True: 0, False: 18.2k]
  ------------------
 4466|      0|            DEBUGDUMPSECTION("recv", "SNMPv1 message\n");
  ------------------
  |  |   81|      0|	do {if (_DBG_IF_) {__DBGDUMPSECTION(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPSECTION(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  191|      0|        __DBGPRINTINDENT("dumph_" token); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  175|      0|#define __DBGPRINTINDENT(token) __DBGMSGTL((token, "%*s", __DBGINDENT(), ""))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  192|      0|        debugmsg("dumph_" token,"%s\n",x);\
  |  |  |  |  193|      0|        __DBGINDENTMORE()
  |  |  |  |  ------------------
  |  |  |  |  |  |  173|      0|#define __DBGINDENTMORE()  debug_indent_add(2)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (81:56): [Folded, False: 0]
  |  |  ------------------
  ------------------
 4467|  18.2k|        } else {
 4468|  18.2k|#endif
 4469|  18.2k|            DEBUGDUMPSECTION("recv", "SNMPv2c message\n");
  ------------------
  |  |   81|  18.2k|	do {if (_DBG_IF_) {__DBGDUMPSECTION(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|  18.2k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 18.2k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPSECTION(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  191|  18.2k|        __DBGPRINTINDENT("dumph_" token); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  175|  18.2k|#define __DBGPRINTINDENT(token) __DBGMSGTL((token, "%*s", __DBGINDENT(), ""))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  164|  18.2k|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  154|  18.2k|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  147|  18.2k|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  155|  18.2k|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  192|  18.2k|        debugmsg("dumph_" token,"%s\n",x);\
  |  |  |  |  193|  18.2k|        __DBGINDENTMORE()
  |  |  |  |  ------------------
  |  |  |  |  |  |  173|  18.2k|#define __DBGINDENTMORE()  debug_indent_add(2)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (81:56): [Folded, False: 18.2k]
  |  |  ------------------
  ------------------
 4470|  18.2k|#ifndef NETSNMP_DISABLE_SNMPV1
 4471|  18.2k|        }
 4472|  18.2k|#endif
 4473|  18.2k|        data = snmp_comstr_parse(data, &length,
 4474|  18.2k|                                 community, &community_length,
 4475|  18.2k|                                 &pdu->version);
 4476|  18.2k|        if (data == NULL)
  ------------------
  |  Branch (4476:13): [True: 1.80k, False: 16.4k]
  ------------------
 4477|  1.80k|            return -1;
 4478|       |
 4479|  16.4k|        if (pdu->version != session->version &&
  ------------------
  |  Branch (4479:13): [True: 13.2k, False: 3.21k]
  ------------------
 4480|  13.2k|            session->version != SNMP_DEFAULT_VERSION) {
  ------------------
  |  |   90|  13.2k|#define SNMP_DEFAULT_VERSION	    -1
  ------------------
  |  Branch (4480:13): [True: 13.2k, False: 0]
  ------------------
 4481|  13.2k|            session->s_snmp_errno = SNMPERR_BAD_VERSION;
  ------------------
  |  |  198|  13.2k|#define SNMPERR_BAD_VERSION		(-14)
  ------------------
 4482|  13.2k|            return -1;
 4483|  13.2k|        }
 4484|       |
 4485|       |        /*
 4486|       |         * maybe get the community string. 
 4487|       |         */
 4488|  3.21k|        pdu->securityLevel = SNMP_SEC_LEVEL_NOAUTH;
  ------------------
  |  |  299|  3.21k|#define SNMP_SEC_LEVEL_NOAUTH		1
  ------------------
 4489|  3.21k|        pdu->securityModel = 
 4490|  3.21k|#ifndef NETSNMP_DISABLE_SNMPV1
 4491|  3.21k|            (pdu->version == SNMP_VERSION_1) ? SNMP_SEC_MODEL_SNMPv1 : 
  ------------------
  |  |  107|  3.21k|#define SNMP_VERSION_1	   0
  ------------------
                          (pdu->version == SNMP_VERSION_1) ? SNMP_SEC_MODEL_SNMPv1 : 
  ------------------
  |  |  293|      0|#define SNMP_SEC_MODEL_SNMPv1		1
  ------------------
  |  Branch (4491:13): [True: 0, False: 3.21k]
  ------------------
 4492|  3.21k|#endif
 4493|  3.21k|                                               SNMP_SEC_MODEL_SNMPv2c;
  ------------------
  |  |  294|  6.43k|#define SNMP_SEC_MODEL_SNMPv2c		2
  ------------------
 4494|  3.21k|        SNMP_FREE(pdu->community);
  ------------------
  |  |   62|  3.21k|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 3.21k]
  |  |  |  Branch (62:66): [Folded, False: 3.21k]
  |  |  ------------------
  ------------------
 4495|  3.21k|        pdu->community_len = 0;
 4496|  3.21k|        pdu->community = (u_char *) 0;
 4497|  3.21k|        if (community_length) {
  ------------------
  |  Branch (4497:13): [True: 2.68k, False: 531]
  ------------------
 4498|  2.68k|            pdu->community_len = community_length;
 4499|  2.68k|            pdu->community = netsnmp_memdup(community, community_length);
 4500|  2.68k|            if (pdu->community == NULL) {
  ------------------
  |  Branch (4500:17): [True: 0, False: 2.68k]
  ------------------
 4501|      0|                session->s_snmp_errno = SNMPERR_MALLOC;
  ------------------
  |  |  246|      0|#define SNMPERR_MALLOC			(-62)
  ------------------
 4502|      0|                return -1;
 4503|      0|            }
 4504|  2.68k|        }
 4505|  3.21k|        if (session->authenticator) {
  ------------------
  |  Branch (4505:13): [True: 0, False: 3.21k]
  ------------------
 4506|      0|            data = session->authenticator(data, &length,
 4507|      0|                                          community, community_length);
 4508|      0|            if (data == NULL) {
  ------------------
  |  Branch (4508:17): [True: 0, False: 0]
  ------------------
 4509|      0|                session->s_snmp_errno = SNMPERR_AUTHENTICATION_FAILURE;
  ------------------
  |  |  219|      0|#define SNMPERR_AUTHENTICATION_FAILURE 	(-35)
  ------------------
 4510|      0|                return -1;
 4511|      0|            }
 4512|      0|        }
 4513|       |
 4514|  3.21k|        DEBUGDUMPSECTION("recv", "PDU");
  ------------------
  |  |   81|  3.21k|	do {if (_DBG_IF_) {__DBGDUMPSECTION(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|  3.21k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 3.21k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPSECTION(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  191|  3.21k|        __DBGPRINTINDENT("dumph_" token); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  175|  3.21k|#define __DBGPRINTINDENT(token) __DBGMSGTL((token, "%*s", __DBGINDENT(), ""))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  164|  3.21k|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  154|  3.21k|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  147|  3.21k|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  155|  3.21k|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  192|  3.21k|        debugmsg("dumph_" token,"%s\n",x);\
  |  |  |  |  193|  3.21k|        __DBGINDENTMORE()
  |  |  |  |  ------------------
  |  |  |  |  |  |  173|  3.21k|#define __DBGINDENTMORE()  debug_indent_add(2)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (81:56): [Folded, False: 3.21k]
  |  |  ------------------
  ------------------
 4515|  3.21k|        result = snmp_pdu_parse(pdu, data, &length);
 4516|  3.21k|        if (result < 0) {
  ------------------
  |  Branch (4516:13): [True: 3.21k, False: 0]
  ------------------
 4517|       |            /*
 4518|       |             * This indicates a parse error.  
 4519|       |             */
 4520|  3.21k|            snmp_increment_statistic(STAT_SNMPINASNPARSEERRS);
  ------------------
  |  |  637|  3.21k|#define  STAT_SNMPINASNPARSEERRS             14
  ------------------
 4521|  3.21k|        }
 4522|  3.21k|        DEBUGINDENTADD(-6);
  ------------------
  |  |   73|  3.21k|#define DEBUGINDENTADD(x)  do {if (_DBG_IF_) {__DBGINDENTADD(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|  3.21k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 3.21k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTADD(x)  do {if (_DBG_IF_) {__DBGINDENTADD(x);} }while(0)
  |  |  ------------------
  |  |  |  |  172|  3.21k|#define __DBGINDENTADD(x)  debug_indent_add(x)
  |  |  ------------------
  |  |  |  Branch (73:74): [Folded, False: 3.21k]
  |  |  ------------------
  ------------------
 4523|  3.21k|        break;
 4524|      0|#endif /* support for community based SNMP */
 4525|       |
 4526|      0|    case SNMP_VERSION_3:
  ------------------
  |  |  113|      0|#define SNMP_VERSION_3     3
  ------------------
  |  Branch (4526:5): [True: 0, False: 18.2k]
  ------------------
 4527|      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): [True: 0, Folded]
  |  |  |  |  ------------------
  |  |  |  |  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"));      \
  |  |  ------------------
  |  |  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  236|      0|            goto pc_target;                                            \
  |  |  237|      0|        }                                                              \
  |  |  238|      0|    } while(0)
  |  |  ------------------
  |  |  |  Branch (238:13): [Folded, False: 0]
  |  |  ------------------
  ------------------
 4528|      0|        result = snmpv3_parse(pdu, data, &length, NULL, session);
 4529|      0|        DEBUGMSGTL(("snmp_parse",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 4530|      0|                    "Parsed SNMPv3 message (secName:%s, secLevel:%s): %s\n",
 4531|      0|                    pdu->securityName, secLevelName[pdu->securityLevel],
 4532|      0|                    snmp_api_errstring(result)));
 4533|       |
 4534|      0|        if (result == SNMPERR_USM_UNKNOWNSECURITYNAME) {
  ------------------
  |  |  227|      0|#define SNMPERR_USM_UNKNOWNSECURITYNAME		(-43)
  ------------------
  |  Branch (4534:13): [True: 0, False: 0]
  ------------------
 4535|      0|            snmp_call_callbacks(SNMP_CALLBACK_APPLICATION,
  ------------------
  |  |   19|      0|#define SNMP_CALLBACK_APPLICATION 1
  ------------------
 4536|      0|                                SNMPD_CALLBACK_AUTH_FAILURE, pdu);
  ------------------
  |  |   21|      0|#define SNMPD_CALLBACK_AUTH_FAILURE             17
  ------------------
 4537|      0|        }
 4538|       |        
 4539|      0|        if (result) {
  ------------------
  |  Branch (4539:13): [True: 0, False: 0]
  ------------------
 4540|      0|            struct snmp_secmod_def *secmod =
 4541|      0|                find_sec_mod(pdu->securityModel);
 4542|      0|            if (!slp) {
  ------------------
  |  Branch (4542:17): [True: 0, False: 0]
  ------------------
 4543|      0|                session->s_snmp_errno = result;
 4544|      0|            } else {
 4545|       |                /*
 4546|       |                 * Call the security model to special handle any errors
 4547|       |                 */
 4548|       |
 4549|      0|                if (secmod && secmod->handle_report) {
  ------------------
  |  Branch (4549:21): [True: 0, False: 0]
  |  Branch (4549:31): [True: 0, False: 0]
  ------------------
 4550|      0|                    (*secmod->handle_report)(slp, slp->transport, session,
 4551|      0|                                             result, pdu);
 4552|      0|                }
 4553|      0|            }
 4554|      0|            free_securityStateRef(pdu);
 4555|      0|        }
 4556|       |
 4557|       |        /* Implement RFC5343 here for two reasons:
 4558|       |           1) From a security perspective it handles this otherwise
 4559|       |              always approved request earlier.  It bypasses the need
 4560|       |              for authorization to the snmpEngineID scalar, which is
 4561|       |              what is what RFC3415 appendix A species as ok.  Note
 4562|       |              that we haven't bypassed authentication since if there
 4563|       |              was an authentication error it would have been handled
 4564|       |              above in the if(result) part at the latest.
 4565|       |           2) From an application point of view if we let this request
 4566|       |              get all the way to the application, it'd require that
 4567|       |              all application types supporting discovery also fire up
 4568|       |              a minimal agent in order to handle just this request
 4569|       |              which seems like overkill.  Though there is no other
 4570|       |              application types that currently need discovery (NRs
 4571|       |              accept notifications from contextEngineIDs that derive
 4572|       |              from the NO not the NR).  Also a lame excuse for doing
 4573|       |              it here.
 4574|       |           3) Less important technically, but the net-snmp agent
 4575|       |              doesn't currently handle registrations of different
 4576|       |              engineIDs either and it would have been a lot more work
 4577|       |              to implement there since we'd need to support that
 4578|       |              first. :-/ Supporting multiple context engineIDs should
 4579|       |              be done anyway, so it's not a valid excuse here.
 4580|       |           4) There is a lot less to do if we trump the agent at this
 4581|       |              point; IE, the agent does a lot more unnecessary
 4582|       |              processing when the only thing that should ever be in
 4583|       |              this context by definition is the single scalar.
 4584|       |        */
 4585|       |
 4586|       |        /* special RFC5343 engineID discovery engineID check */
 4587|      0|        if (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      0|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (4587:13): [True: 0, False: 0]
  ------------------
 4588|      0|                                    NETSNMP_DS_LIB_NO_DISCOVERY) &&
  ------------------
  |  |   98|      0|#define NETSNMP_DS_LIB_NO_DISCOVERY        38 /* don't support RFC5343 contextEngineID discovery */
  ------------------
 4589|      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 (4589:13): [True: 0, False: 0]
  ------------------
 4590|      0|            NULL                    != pdu->contextEngineID &&
  ------------------
  |  Branch (4590:13): [True: 0, False: 0]
  ------------------
 4591|      0|            pdu->contextEngineIDLen == 5 &&
  ------------------
  |  Branch (4591:13): [True: 0, False: 0]
  ------------------
 4592|      0|            pdu->contextEngineID[0] == 0x80 &&
  ------------------
  |  Branch (4592:13): [True: 0, False: 0]
  ------------------
 4593|      0|            pdu->contextEngineID[1] == 0x00 &&
  ------------------
  |  Branch (4593:13): [True: 0, False: 0]
  ------------------
 4594|      0|            pdu->contextEngineID[2] == 0x00 &&
  ------------------
  |  Branch (4594:13): [True: 0, False: 0]
  ------------------
 4595|      0|            pdu->contextEngineID[3] == 0x00 &&
  ------------------
  |  Branch (4595:13): [True: 0, False: 0]
  ------------------
 4596|      0|            pdu->contextEngineID[4] == 0x06) {
  ------------------
  |  Branch (4596:13): [True: 0, False: 0]
  ------------------
 4597|       |
 4598|       |            /* define a result so it doesn't get past us at this point
 4599|       |               and gets dropped by future parts of the stack */
 4600|      0|            result = SNMPERR_JUST_A_CONTEXT_PROBE;
  ------------------
  |  |  250|      0|#define SNMPERR_JUST_A_CONTEXT_PROBE    (-66)
  ------------------
 4601|       |
 4602|      0|            DEBUGMSGTL(("snmpv3_contextid", "starting context ID discovery\n"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 4603|       |            /* ensure exactly one variable */
 4604|      0|            if (NULL != pdu->variables &&
  ------------------
  |  Branch (4604:17): [True: 0, False: 0]
  ------------------
 4605|      0|                NULL == pdu->variables->next_variable &&
  ------------------
  |  Branch (4605:17): [True: 0, False: 0]
  ------------------
 4606|       |
 4607|       |                /* if it's a GET, match it exactly */
 4608|      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 (4608:19): [True: 0, False: 0]
  ------------------
 4609|      0|                  snmp_oid_compare(snmpEngineIDoid,
  ------------------
  |  Branch (4609:19): [True: 0, False: 0]
  ------------------
 4610|      0|                                   snmpEngineIDoid_len,
 4611|      0|                                   pdu->variables->name,
 4612|      0|                                   pdu->variables->name_length) == 0)
 4613|       |                 /* if it's a GETNEXT ensure it's less than the engineID oid */
 4614|      0|                 ||
 4615|      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 (4615:19): [True: 0, False: 0]
  ------------------
 4616|      0|                  snmp_oid_compare(snmpEngineIDoid,
  ------------------
  |  Branch (4616:19): [True: 0, False: 0]
  ------------------
 4617|      0|                                   snmpEngineIDoid_len,
 4618|      0|                                   pdu->variables->name,
 4619|      0|                                   pdu->variables->name_length) > 0)
 4620|      0|                    )) {
 4621|       |
 4622|      0|                DEBUGMSGTL(("snmpv3_contextid",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 4623|      0|                            "  One correct variable found\n"));
 4624|       |
 4625|       |                /* Note: we're explicitly not handling a GETBULK.  Deal. */
 4626|       |
 4627|       |                /* set up the response */
 4628|      0|                pdu2 = snmp_clone_pdu(pdu);
 4629|       |
 4630|       |                /* free the current varbind */
 4631|      0|                snmp_free_varbind(pdu2->variables);
 4632|       |
 4633|       |                /* set the variables */
 4634|      0|                pdu2->variables = NULL;
 4635|      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
  |  |  ------------------
  ------------------
 4636|      0|                pdu2->errstat = 0;
 4637|      0|                pdu2->errindex = 0;
 4638|       |
 4639|      0|                ourEngineID_len =
 4640|      0|                    snmpv3_get_engineID((u_char*)ourEngineID, ourEngineID_len);
 4641|      0|                if (0 != ourEngineID_len) {
  ------------------
  |  Branch (4641:21): [True: 0, False: 0]
  ------------------
 4642|       |
 4643|      0|                    DEBUGMSGTL(("snmpv3_contextid",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 4644|      0|                                "  responding with our engineID\n"));
 4645|       |
 4646|      0|                    snmp_pdu_add_variable(pdu2,
 4647|      0|                                          snmpEngineIDoid, snmpEngineIDoid_len,
 4648|      0|                                          ASN_OCTET_STR,
  ------------------
  |  |   78|      0|#define ASN_OCTET_STR	    0x04U
  ------------------
 4649|      0|                                          ourEngineID, ourEngineID_len);
 4650|       |                    
 4651|       |                    /* send the response */
 4652|      0|                    if (0 == snmp_sess_send(slp, pdu2)) {
  ------------------
  |  Branch (4652:25): [True: 0, False: 0]
  ------------------
 4653|       |
 4654|      0|                        DEBUGMSGTL(("snmpv3_contextid",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 4655|      0|                                    "  sent it off!\n"));
 4656|       |
 4657|      0|                        snmp_free_pdu(pdu2);
 4658|       |                        
 4659|      0|                        snmp_log(LOG_ERR, "sending a response to the context engineID probe failed\n");
 4660|      0|                    }
 4661|      0|                } else {
 4662|      0|                    snmp_log(LOG_ERR, "failed to get our own engineID!\n");
 4663|      0|                    snmp_free_pdu(pdu2);
 4664|      0|                }
 4665|      0|            } else {
 4666|      0|                snmp_log(LOG_WARNING,
 4667|      0|                         "received an odd context engineID probe\n");
 4668|      0|            }
 4669|      0|        }
 4670|       |
 4671|      0|        break;
 4672|      0|    case SNMPERR_BAD_VERSION:
  ------------------
  |  |  198|      0|#define SNMPERR_BAD_VERSION		(-14)
  ------------------
  |  Branch (4672:5): [True: 0, False: 18.2k]
  ------------------
 4673|      0|        ERROR_MSG("error parsing snmp message version");
  ------------------
  |  |  188|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 4674|      0|        snmp_increment_statistic(STAT_SNMPINASNPARSEERRS);
  ------------------
  |  |  637|      0|#define  STAT_SNMPINASNPARSEERRS             14
  ------------------
 4675|      0|        session->s_snmp_errno = SNMPERR_BAD_VERSION;
  ------------------
  |  |  198|      0|#define SNMPERR_BAD_VERSION		(-14)
  ------------------
 4676|      0|        break;
 4677|       |
 4678|      0|        unsupported_version:  /* goto label */
 4679|      0|    case SNMP_VERSION_sec:
  ------------------
  |  |  118|      0|#define SNMP_VERSION_sec   128  /* not (will never be) supported by this code */
  ------------------
  |  Branch (4679:5): [True: 0, False: 18.2k]
  ------------------
 4680|      0|    case SNMP_VERSION_2u:
  ------------------
  |  |  112|      0|#define SNMP_VERSION_2u    2    /* not (will never be) supported by this code */
  ------------------
  |  Branch (4680:5): [True: 0, False: 18.2k]
  ------------------
 4681|      0|    case SNMP_VERSION_2star:
  ------------------
  |  |  120|      0|#define SNMP_VERSION_2star 130  /* not (will never be) supported by this code */
  ------------------
  |  Branch (4681:5): [True: 0, False: 18.2k]
  ------------------
 4682|      0|    case SNMP_VERSION_2p:
  ------------------
  |  |  119|      0|#define SNMP_VERSION_2p	   129  /* no longer supported by this code (> 4.0) */
  ------------------
  |  Branch (4682:5): [True: 0, False: 18.2k]
  ------------------
 4683|      0|    default:
  ------------------
  |  Branch (4683:5): [True: 0, False: 18.2k]
  ------------------
 4684|      0|        ERROR_MSG("unsupported snmp message version");
  ------------------
  |  |  188|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 4685|      0|        snmp_increment_statistic(STAT_SNMPINBADVERSIONS);
  ------------------
  |  |  634|      0|#define  STAT_SNMPINBADVERSIONS              11
  ------------------
 4686|       |
 4687|       |        /*
 4688|       |         * need better way to determine OS independent
 4689|       |         * INT32_MAX value, for now hardcode
 4690|       |         */
 4691|      0|        if (pdu->version < 0 || pdu->version > 2147483647) {
  ------------------
  |  Branch (4691:13): [True: 0, False: 0]
  |  Branch (4691:33): [True: 0, False: 0]
  ------------------
 4692|      0|            snmp_increment_statistic(STAT_SNMPINASNPARSEERRS);
  ------------------
  |  |  637|      0|#define  STAT_SNMPINASNPARSEERRS             14
  ------------------
 4693|      0|        }
 4694|      0|        session->s_snmp_errno = SNMPERR_BAD_VERSION;
  ------------------
  |  |  198|      0|#define SNMPERR_BAD_VERSION		(-14)
  ------------------
 4695|      0|        break;
 4696|  18.2k|    }
 4697|       |
 4698|  3.21k|    return result;
 4699|  18.2k|}
snmp_api.c:__sess_read:
 6290|  3.32k|{
 6291|  3.32k|    netsnmp_session *sp = slp ? slp->session : NULL;
  ------------------
  |  Branch (6291:27): [True: 3.32k, False: 0]
  ------------------
 6292|  3.32k|    struct snmp_internal_session *isp = slp ? slp->internal : NULL;
  ------------------
  |  Branch (6292:41): [True: 3.32k, False: 0]
  ------------------
 6293|  3.32k|    netsnmp_transport *transport = slp ? slp->transport : NULL;
  ------------------
  |  Branch (6293:36): [True: 3.32k, False: 0]
  ------------------
 6294|  3.32k|    size_t          pdulen = 0, rxbuf_len = SNMP_MAX_RCV_MSG_SIZE;
  ------------------
  |  |  108|  3.32k|#define SNMP_MAX_RCV_MSG_SIZE      65536
  ------------------
 6295|  3.32k|    u_char         *rxbuf = NULL;
 6296|  3.32k|    int             length = 0, olength = 0, rc = 0;
 6297|  3.32k|    void           *opaque = NULL;
 6298|       |
 6299|  3.32k|    if (NULL == slp || NULL == sp || NULL == isp || NULL == transport) {
  ------------------
  |  Branch (6299:9): [True: 0, False: 3.32k]
  |  Branch (6299:24): [True: 0, False: 3.32k]
  |  Branch (6299:38): [True: 0, False: 3.32k]
  |  Branch (6299:53): [True: 0, False: 3.32k]
  ------------------
 6300|      0|        snmp_log(LOG_ERR, "bad parameters to __sess_read\n");
 6301|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
 6302|      0|    }
 6303|       |
 6304|       |    /* to avoid subagent crash */
 6305|  3.32k|    if (!NETSNMP_IS_VALID_SOCKET(transport->sock)) {
  ------------------
  |  |   44|  3.32k|#define NETSNMP_IS_VALID_SOCKET(_sock) ((_sock) != -1)
  ------------------
  |  Branch (6305:9): [True: 0, False: 3.32k]
  ------------------
 6306|      0|        snmp_log(LOG_INFO, "transport->sock is invalid\n");
 6307|      0|        return 0; 
 6308|      0|    }
 6309|       |
 6310|  3.32k|    sp->s_snmp_errno = 0;
 6311|  3.32k|    sp->s_errno = 0;
 6312|       |
 6313|  3.32k|    if (transport->flags & NETSNMP_TRANSPORT_FLAG_LISTEN)
  ------------------
  |  |   52|  3.32k|#define		NETSNMP_TRANSPORT_FLAG_LISTEN	 0x02
  ------------------
  |  Branch (6313:9): [True: 0, False: 3.32k]
  ------------------
 6314|      0|        return _sess_read_accept(slp);
 6315|       |
 6316|  3.32k|    if (!(transport->flags & NETSNMP_TRANSPORT_FLAG_STREAM)) {
  ------------------
  |  |   51|  3.32k|#define		NETSNMP_TRANSPORT_FLAG_STREAM	 0x01
  ------------------
  |  Branch (6316:9): [True: 3.32k, False: 0]
  ------------------
 6317|  3.32k|        snmp_rcv_packet rcvp;
 6318|  3.32k|        u_char *pptr;
 6319|  3.32k|        size_t len_remaining, pdulen;
 6320|  3.32k|        void *ocopy = NULL;
 6321|       |
 6322|  3.32k|        memset(&rcvp, 0x0, sizeof(rcvp));
 6323|       |
 6324|       |        /** read the packet */
 6325|  3.32k|        rc = _sess_read_dgram_packet(slp, &rcvp);
 6326|  3.32k|        if (-1 == rc) /* protocol error */
  ------------------
  |  Branch (6326:13): [True: 471, False: 2.85k]
  ------------------
 6327|    471|            return -1;
 6328|  2.85k|        else if (-2 == rc) /* no packet to process */
  ------------------
  |  Branch (6328:18): [True: 0, False: 2.85k]
  ------------------
 6329|      0|            return 0;
 6330|       |
 6331|  2.85k|        pptr = rcvp.packet;
 6332|  2.85k|        len_remaining = rcvp.packet_len;
 6333|  2.85k|        rc = 0;
 6334|       |
 6335|  21.1k|        while (len_remaining > 0) {
  ------------------
  |  Branch (6335:16): [True: 20.2k, False: 924]
  ------------------
 6336|  20.2k|            if (isp->check_packet) {
  ------------------
  |  Branch (6336:17): [True: 0, False: 20.2k]
  ------------------
 6337|      0|                pdulen = isp->check_packet(pptr, len_remaining);
 6338|  20.2k|            } else {
 6339|  20.2k|                pdulen = asn_check_packet(pptr, len_remaining);
 6340|  20.2k|            }
 6341|  20.2k|            if (pdulen == 0 || pdulen > len_remaining || pdulen > SNMP_MAX_PACKET_LEN) {
  ------------------
  |  |   49|  18.2k|#define SNMP_MAX_PACKET_LEN (0x7fffffff)
  ------------------
  |  Branch (6341:17): [True: 40, False: 20.1k]
  |  Branch (6341:32): [True: 1.88k, False: 18.2k]
  |  Branch (6341:58): [True: 0, False: 18.2k]
  ------------------
 6342|       |                /* Not a valid packet or incomplete in datagram mode */
 6343|  1.92k|                if (pptr == rcvp.packet) {
  ------------------
  |  Branch (6343:21): [True: 907, False: 1.01k]
  ------------------
 6344|    907|                    SNMP_FREE(rcvp.opaque);
  ------------------
  |  |   62|    907|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 907]
  |  |  |  Branch (62:66): [Folded, False: 907]
  |  |  ------------------
  ------------------
 6345|    907|                }
 6346|  1.92k|                break;
 6347|  1.92k|            }
 6348|  18.2k|            if (pdulen < len_remaining) {
  ------------------
  |  Branch (6348:17): [True: 17.3k, False: 924]
  ------------------
 6349|  17.3k|                if (rcvp.olength > 0 && rcvp.opaque != NULL) {
  ------------------
  |  Branch (6349:21): [True: 0, False: 17.3k]
  |  Branch (6349:41): [True: 0, False: 0]
  ------------------
 6350|      0|                    ocopy = malloc(rcvp.olength);
 6351|      0|                    if (ocopy != NULL) {
  ------------------
  |  Branch (6351:25): [True: 0, False: 0]
  ------------------
 6352|      0|                        memcpy(ocopy, rcvp.opaque, rcvp.olength);
 6353|      0|                    }
 6354|      0|                }
 6355|  17.3k|            } else {
 6356|    924|                ocopy = rcvp.opaque;
 6357|    924|                rcvp.opaque = NULL;
 6358|    924|            }
 6359|  18.2k|            rc = _sess_process_packet(slp, sp, isp, transport,
 6360|  18.2k|                                      ocopy, ocopy ? rcvp.olength : 0,
  ------------------
  |  Branch (6360:46): [True: 0, False: 18.2k]
  ------------------
 6361|  18.2k|                                      pptr, pdulen);
 6362|  18.2k|            ocopy = NULL;
 6363|  18.2k|            pptr += pdulen;
 6364|  18.2k|            len_remaining -= pdulen;
 6365|  18.2k|        }
 6366|  2.85k|        SNMP_FREE(rcvp.packet);
  ------------------
  |  |   62|  2.85k|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 2.85k, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 2.85k]
  |  |  ------------------
  ------------------
 6367|  2.85k|        SNMP_FREE(rcvp.opaque);
  ------------------
  |  |   62|  2.85k|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 2.85k]
  |  |  |  Branch (62:66): [Folded, False: 2.85k]
  |  |  ------------------
  ------------------
 6368|  2.85k|        return rc;
 6369|  3.32k|    }
 6370|       |
 6371|       |    /** stream transport */
 6372|       |
 6373|      0|        if (isp->packet == NULL) {
  ------------------
  |  Branch (6373:13): [True: 0, False: 0]
  ------------------
 6374|       |            /*
 6375|       |             * We have no saved packet.  Allocate one.  
 6376|       |             */
 6377|      0|            if ((isp->packet = (u_char *) malloc(rxbuf_len)) == NULL) {
  ------------------
  |  Branch (6377:17): [True: 0, False: 0]
  ------------------
 6378|      0|                DEBUGMSGTL(("sess_read", "can't malloc %" NETSNMP_PRIz
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 6379|      0|                            "u bytes for rxbuf\n", rxbuf_len));
 6380|      0|                return 0;
 6381|      0|            } else {
 6382|      0|                rxbuf = isp->packet;
 6383|      0|                isp->packet_size = rxbuf_len;
 6384|      0|                isp->packet_len = 0;
 6385|      0|            }
 6386|      0|        } else {
 6387|       |            /*
 6388|       |             * We have saved a partial packet from last time.  Extend that, if
 6389|       |             * necessary, and receive new data after the old data.  
 6390|       |             */
 6391|      0|            u_char         *newbuf;
 6392|       |
 6393|      0|            if (isp->packet_size < isp->packet_len + rxbuf_len) {
  ------------------
  |  Branch (6393:17): [True: 0, False: 0]
  ------------------
 6394|      0|                newbuf =
 6395|      0|                    (u_char *) realloc(isp->packet,
 6396|      0|                                       isp->packet_len + rxbuf_len);
 6397|      0|                if (newbuf == NULL) {
  ------------------
  |  Branch (6397:21): [True: 0, False: 0]
  ------------------
 6398|      0|                    DEBUGMSGTL(("sess_read",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 6399|      0|                                "can't malloc %" NETSNMP_PRIz
 6400|      0|                                "u more for rxbuf (%" NETSNMP_PRIz "u tot)\n",
 6401|      0|                                rxbuf_len, isp->packet_len + rxbuf_len));
 6402|      0|                    return 0;
 6403|      0|                } else {
 6404|      0|                    isp->packet = newbuf;
 6405|      0|                    isp->packet_size = isp->packet_len + rxbuf_len;
 6406|      0|                    rxbuf = isp->packet + isp->packet_len;
 6407|      0|                }
 6408|      0|            } else {
 6409|      0|                rxbuf = isp->packet + isp->packet_len;
 6410|      0|                rxbuf_len = isp->packet_size - isp->packet_len;
 6411|      0|            }
 6412|      0|        }
 6413|       |
 6414|      0|    length = netsnmp_transport_recv(transport, rxbuf, rxbuf_len, &opaque,
 6415|      0|                                    &olength);
 6416|       |
 6417|      0|    if (0 == length && transport->flags & NETSNMP_TRANSPORT_FLAG_EMPTY_PKT) {
  ------------------
  |  |   56|      0|#define		NETSNMP_TRANSPORT_FLAG_EMPTY_PKT 0x10
  ------------------
  |  Branch (6417:9): [True: 0, False: 0]
  |  Branch (6417:24): [True: 0, False: 0]
  ------------------
 6418|       |        /* this allows for a transport that needs to return from
 6419|       |         * packet processing that doesn't necessarily have any
 6420|       |         * consumable data in it. */
 6421|       |
 6422|       |        /* reset the flag since it's a per-message flag */
 6423|      0|        transport->flags &= (~NETSNMP_TRANSPORT_FLAG_EMPTY_PKT);
  ------------------
  |  |   56|      0|#define		NETSNMP_TRANSPORT_FLAG_EMPTY_PKT 0x10
  ------------------
 6424|       |
 6425|      0|        return 0;
 6426|      0|    }
 6427|       |
 6428|       |    /*
 6429|       |     * Remote end closed connection.  
 6430|       |     */
 6431|      0|    if (length <= 0) {
  ------------------
  |  Branch (6431:9): [True: 0, False: 0]
  ------------------
 6432|       |        /*
 6433|       |         * Alert the application if possible.  
 6434|       |         */
 6435|      0|        if (sp->callback != NULL) {
  ------------------
  |  Branch (6435:13): [True: 0, False: 0]
  ------------------
 6436|      0|            DEBUGMSGTL(("sess_read", "perform callback with op=DISCONNECT\n"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 6437|      0|            (void) sp->callback(NETSNMP_CALLBACK_OP_DISCONNECT, sp, 0,
  ------------------
  |  |  323|      0|#define NETSNMP_CALLBACK_OP_DISCONNECT		5
  ------------------
 6438|      0|                                NULL, sp->callback_magic);
 6439|      0|        }
 6440|       |        /*
 6441|       |         * Close socket and mark session for deletion.  
 6442|       |         */
 6443|      0|        DEBUGMSGTL(("sess_read", "fd %" NETSNMP_FMT_SKT " closed\n",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 6444|      0|                    transport->sock));
 6445|      0|        transport->f_close(transport);
 6446|      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, False: 0]
  |  |  ------------------
  ------------------
 6447|      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, False: 0]
  |  |  ------------------
  ------------------
 6448|      0|        return -1;
 6449|      0|    }
 6450|       |
 6451|      0|    {
 6452|      0|        u_char *pptr = isp->packet;
 6453|      0|	void *ocopy = NULL;
 6454|       |
 6455|      0|        isp->packet_len += length;
 6456|       |
 6457|      0|        while (isp->packet_len > 0) {
  ------------------
  |  Branch (6457:16): [True: 0, False: 0]
  ------------------
 6458|       |
 6459|       |            /*
 6460|       |             * Get the total data length we're expecting (and need to wait
 6461|       |             * for).
 6462|       |             */
 6463|      0|            if (isp->check_packet) {
  ------------------
  |  Branch (6463:17): [True: 0, False: 0]
  ------------------
 6464|      0|                pdulen = isp->check_packet(pptr, isp->packet_len);
 6465|      0|            } else {
 6466|      0|                pdulen = asn_check_packet(pptr, isp->packet_len);
 6467|      0|            }
 6468|       |
 6469|      0|            DEBUGMSGTL(("sess_read",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 6470|      0|                        "  loop packet_len %" NETSNMP_PRIz "u, PDU length %"
 6471|      0|                        NETSNMP_PRIz "u\n", isp->packet_len, pdulen));
 6472|       |
 6473|      0|            if (pdulen > SNMP_MAX_PACKET_LEN) {
  ------------------
  |  |   49|      0|#define SNMP_MAX_PACKET_LEN (0x7fffffff)
  ------------------
  |  Branch (6473:17): [True: 0, False: 0]
  ------------------
 6474|       |                /*
 6475|       |                 * Illegal length, drop the connection.  
 6476|       |                 */
 6477|      0|                snmp_log(LOG_ERR, 
 6478|      0|			 "Received broken packet. Closing session.\n");
 6479|      0|		if (sp->callback != NULL) {
  ------------------
  |  Branch (6479:7): [True: 0, False: 0]
  ------------------
 6480|      0|		  DEBUGMSGTL(("sess_read",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 6481|      0|			      "perform callback with op=DISCONNECT\n"));
 6482|      0|		  (void)sp->callback(NETSNMP_CALLBACK_OP_DISCONNECT,
  ------------------
  |  |  323|      0|#define NETSNMP_CALLBACK_OP_DISCONNECT		5
  ------------------
 6483|      0|				     sp, 0, NULL, sp->callback_magic);
 6484|      0|		}
 6485|      0|		DEBUGMSGTL(("sess_read", "fd %" NETSNMP_FMT_SKT " closed\n",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 6486|      0|                            transport->sock));
 6487|      0|                transport->f_close(transport);
 6488|      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, False: 0]
  |  |  ------------------
  ------------------
 6489|       |                /** XXX-rks: why no SNMP_FREE(isp->packet); ?? */
 6490|      0|                return -1;
 6491|      0|            }
 6492|       |
 6493|      0|            if (pdulen > isp->packet_len || pdulen == 0) {
  ------------------
  |  Branch (6493:17): [True: 0, False: 0]
  |  Branch (6493:45): [True: 0, False: 0]
  ------------------
 6494|       |                /*
 6495|       |                 * We don't have a complete packet yet.  If we've already
 6496|       |                 * processed a packet, break out so we'll shift this packet
 6497|       |                 * to the start of the buffer. If we're already at the
 6498|       |                 * start, simply return and wait for more data to arrive.
 6499|       |                 */
 6500|      0|                DEBUGMSGTL(("sess_read",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 6501|      0|                            "pkt not complete (need %" NETSNMP_PRIz "u got %"
 6502|      0|                            NETSNMP_PRIz "u so far)\n", pdulen,
 6503|      0|                            isp->packet_len));
 6504|       |
 6505|      0|                if (pptr != isp->packet)
  ------------------
  |  Branch (6505:21): [True: 0, False: 0]
  ------------------
 6506|      0|                    break; /* opaque freed for us outside of loop. */
 6507|       |
 6508|      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, False: 0]
  |  |  ------------------
  ------------------
 6509|      0|                return 0;
 6510|      0|            }
 6511|       |
 6512|       |            /*  We have *at least* one complete packet in the buffer now.  If
 6513|       |		we have possibly more than one packet, we must copy the opaque
 6514|       |		pointer because we may need to reuse it for a later packet.  */
 6515|       |
 6516|      0|	    if (pdulen < isp->packet_len) {
  ------------------
  |  Branch (6516:10): [True: 0, False: 0]
  ------------------
 6517|      0|		if (olength > 0 && opaque != NULL) {
  ------------------
  |  Branch (6517:7): [True: 0, False: 0]
  |  Branch (6517:22): [True: 0, False: 0]
  ------------------
 6518|      0|		    ocopy = malloc(olength);
 6519|      0|		    if (ocopy != NULL) {
  ------------------
  |  Branch (6519:11): [True: 0, False: 0]
  ------------------
 6520|      0|			memcpy(ocopy, opaque, olength);
 6521|      0|		    }
 6522|      0|		}
 6523|      0|	    } else if (pdulen == isp->packet_len) {
  ------------------
  |  Branch (6523:17): [True: 0, False: 0]
  ------------------
 6524|       |		/*  Common case -- exactly one packet.  No need to copy the
 6525|       |		    opaque pointer.  */
 6526|      0|		ocopy = opaque;
 6527|      0|		opaque = NULL;
 6528|      0|	    }
 6529|       |
 6530|      0|            if ((rc = _sess_process_packet(slp, sp, isp, transport,
  ------------------
  |  Branch (6530:17): [True: 0, False: 0]
  ------------------
 6531|      0|                                           ocopy, ocopy?olength:0, pptr,
  ------------------
  |  Branch (6531:51): [True: 0, False: 0]
  ------------------
 6532|      0|                                           pdulen))) {
 6533|       |                /*
 6534|       |                 * Something went wrong while processing this packet -- set the
 6535|       |                 * errno.  
 6536|       |                 */
 6537|      0|                if (sp->s_snmp_errno != 0) {
  ------------------
  |  Branch (6537:21): [True: 0, False: 0]
  ------------------
 6538|      0|                    SET_SNMP_ERROR(sp->s_snmp_errno);
  ------------------
  |  |   43|      0|#define SET_SNMP_ERROR(x) snmp_errno=(x)
  ------------------
 6539|      0|                }
 6540|      0|            }
 6541|       |
 6542|       |	    /*  ocopy has been free()d by _sess_process_packet by this point,
 6543|       |		so set it to NULL.  */
 6544|       |
 6545|      0|	    ocopy = NULL;
 6546|       |
 6547|       |	    /*  Step past the packet we've just dealt with.  */
 6548|       |
 6549|      0|            pptr += pdulen;
 6550|      0|            isp->packet_len -= pdulen;
 6551|      0|        }
 6552|       |
 6553|       |	/*  If we had more than one packet, then we were working with copies
 6554|       |	    of the opaque pointer, so we still need to free() the opaque
 6555|       |	    pointer itself.  */
 6556|       |
 6557|      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, False: 0]
  |  |  ------------------
  ------------------
 6558|       |
 6559|      0|        if (isp->packet_len >= SNMP_MAX_PACKET_LEN) {
  ------------------
  |  |   49|      0|#define SNMP_MAX_PACKET_LEN (0x7fffffff)
  ------------------
  |  Branch (6559:13): [True: 0, False: 0]
  ------------------
 6560|       |            /*
 6561|       |             * Obviously this should never happen!  
 6562|       |             */
 6563|      0|            snmp_log(LOG_ERR,
 6564|      0|                     "too large packet_len = %" NETSNMP_PRIz
 6565|      0|                     "u, dropping connection %" NETSNMP_FMT_SKT "\n",
 6566|      0|                     isp->packet_len, transport->sock);
 6567|      0|            transport->f_close(transport);
 6568|       |            /** XXX-rks: why no SNMP_FREE(isp->packet); ?? */
 6569|      0|            return -1;
 6570|      0|        } else if (isp->packet_len == 0) {
  ------------------
  |  Branch (6570:20): [True: 0, False: 0]
  ------------------
 6571|       |            /*
 6572|       |             * This is good: it means the packet buffer contained an integral
 6573|       |             * number of PDUs, so we don't have to save any data for next
 6574|       |             * time.  We can free() the buffer now to keep the memory
 6575|       |             * footprint down.
 6576|       |             */
 6577|      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, False: 0]
  |  |  ------------------
  ------------------
 6578|      0|            isp->packet_size = 0;
 6579|      0|            isp->packet_len = 0;
 6580|      0|            return rc;
 6581|      0|        }
 6582|       |
 6583|       |        /*
 6584|       |         * If we get here, then there is a partial packet of length
 6585|       |         * isp->packet_len bytes starting at pptr left over.  Move that to the
 6586|       |         * start of the buffer, and then realloc() the buffer down to size to
 6587|       |         * reduce the memory footprint.  
 6588|       |         */
 6589|       |
 6590|      0|        memmove(isp->packet, pptr, isp->packet_len);
 6591|      0|        DEBUGMSGTL(("sess_read",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 6592|      0|                    "end: memmove(%p, %p, %" NETSNMP_PRIz "u); realloc(%p, %"
 6593|      0|                    NETSNMP_PRIz "u)\n",
 6594|      0|                    isp->packet, pptr, isp->packet_len,
 6595|      0|		    isp->packet, isp->packet_len));
 6596|       |
 6597|      0|        if ((rxbuf = (u_char *)realloc(isp->packet, isp->packet_len)) == NULL) {
  ------------------
  |  Branch (6597:13): [True: 0, False: 0]
  ------------------
 6598|       |            /*
 6599|       |             * I don't see why this should ever fail, but it's not a big deal.
 6600|       |             */
 6601|      0|            DEBUGMSGTL(("sess_read", "realloc() failed\n"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 6602|      0|        } else {
 6603|      0|            DEBUGMSGTL(("sess_read", "realloc() okay, old buffer %p, new %p\n",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 6604|      0|                        isp->packet, rxbuf));
 6605|      0|            isp->packet = rxbuf;
 6606|      0|            isp->packet_size = isp->packet_len;
 6607|      0|        }
 6608|      0|    }
 6609|       |
 6610|      0|    return rc;
 6611|      0|}
snmp_api.c:_sess_read_dgram_packet:
 6232|  3.32k|{
 6233|  3.32k|    netsnmp_session *sp = slp ? slp->session : NULL;
  ------------------
  |  Branch (6233:27): [True: 3.32k, False: 0]
  ------------------
 6234|  3.32k|    struct snmp_internal_session *isp = slp ? slp->internal : NULL;
  ------------------
  |  Branch (6234:41): [True: 3.32k, False: 0]
  ------------------
 6235|  3.32k|    netsnmp_transport *transport = slp ? slp->transport : NULL;
  ------------------
  |  Branch (6235:36): [True: 3.32k, False: 0]
  ------------------
 6236|       |
 6237|  3.32k|    if (!sp || !isp || !transport || !rcvp ) {
  ------------------
  |  Branch (6237:9): [True: 0, False: 3.32k]
  |  Branch (6237:16): [True: 0, False: 3.32k]
  |  Branch (6237:24): [True: 0, False: 3.32k]
  |  Branch (6237:38): [True: 0, False: 3.32k]
  ------------------
 6238|      0|        DEBUGMSGTL(("sess_read_packet", "missing arguments\n"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 6239|      0|        return -2;
 6240|      0|    }
 6241|       |
 6242|  3.32k|    if (transport->flags & NETSNMP_TRANSPORT_FLAG_STREAM)
  ------------------
  |  |   51|  3.32k|#define		NETSNMP_TRANSPORT_FLAG_STREAM	 0x01
  ------------------
  |  Branch (6242:9): [True: 0, False: 3.32k]
  ------------------
 6243|      0|        return -2;
 6244|       |
 6245|  3.32k|    if (NULL != rcvp->packet) {
  ------------------
  |  Branch (6245:9): [True: 0, False: 3.32k]
  ------------------
 6246|      0|        snmp_log(LOG_WARNING, "overwriting existing saved packet; sess %p\n",
 6247|      0|                 sp);
 6248|      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, False: 0]
  |  |  ------------------
  ------------------
 6249|      0|    }
 6250|       |
 6251|  3.32k|    if ((rcvp->packet = (u_char *) malloc(SNMP_MAX_RCV_MSG_SIZE)) == NULL) {
  ------------------
  |  |  108|  3.32k|#define SNMP_MAX_RCV_MSG_SIZE      65536
  ------------------
  |  Branch (6251:9): [True: 0, False: 3.32k]
  ------------------
 6252|      0|        DEBUGMSGTL(("sess_read_packet", "can't malloc %u bytes for packet\n",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 6253|      0|                    SNMP_MAX_RCV_MSG_SIZE));
 6254|      0|        return -2;
 6255|      0|    }
 6256|       |
 6257|  3.32k|    rcvp->packet_len = netsnmp_transport_recv(transport, rcvp->packet,
 6258|  3.32k|                                              SNMP_MAX_RCV_MSG_SIZE,
  ------------------
  |  |  108|  3.32k|#define SNMP_MAX_RCV_MSG_SIZE      65536
  ------------------
 6259|  3.32k|                                              &rcvp->opaque, &rcvp->olength);
 6260|  3.32k|    if (rcvp->packet_len == -1) {
  ------------------
  |  Branch (6260:9): [True: 471, False: 2.85k]
  ------------------
 6261|    471|        sp->s_snmp_errno = SNMPERR_BAD_RECVFROM;
  ------------------
  |  |  209|    471|#define SNMPERR_BAD_RECVFROM 		(-25)
  ------------------
 6262|    471|        sp->s_errno = errno;
 6263|    471|        snmp_set_detail(strerror(errno));
 6264|    471|        SNMP_FREE(rcvp->packet);
  ------------------
  |  |   62|    471|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 471, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 471]
  |  |  ------------------
  ------------------
 6265|    471|        SNMP_FREE(rcvp->opaque);
  ------------------
  |  |   62|    471|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 471]
  |  |  |  Branch (62:66): [Folded, False: 471]
  |  |  ------------------
  ------------------
 6266|    471|        return -1;
 6267|    471|    }
 6268|       |
 6269|  2.85k|    if (0 == rcvp->packet_len &&
  ------------------
  |  Branch (6269:9): [True: 0, False: 2.85k]
  ------------------
 6270|      0|        transport->flags & NETSNMP_TRANSPORT_FLAG_EMPTY_PKT) {
  ------------------
  |  |   56|      0|#define		NETSNMP_TRANSPORT_FLAG_EMPTY_PKT 0x10
  ------------------
  |  Branch (6270:9): [True: 0, False: 0]
  ------------------
 6271|       |        /* this allows for a transport that needs to return from
 6272|       |         * packet processing that doesn't necessarily have any
 6273|       |         * consumable data in it. */
 6274|       |
 6275|       |        /* reset the flag since it's a per-message flag */
 6276|      0|        transport->flags &= (~NETSNMP_TRANSPORT_FLAG_EMPTY_PKT);
  ------------------
  |  |   56|      0|#define		NETSNMP_TRANSPORT_FLAG_EMPTY_PKT 0x10
  ------------------
 6277|       |
 6278|       |        /** free packet */
 6279|      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, False: 0]
  |  |  ------------------
  ------------------
 6280|      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, False: 0]
  |  |  ------------------
  ------------------
 6281|       |
 6282|      0|        return -2;
 6283|      0|    }
 6284|       |
 6285|  2.85k|    return 0;
 6286|  2.85k|}
snmp_api.c:_sess_process_packet:
 6072|  18.2k|{
 6073|  18.2k|    netsnmp_pdu         *pdu;
 6074|  18.2k|    int                  rc;
 6075|       |
 6076|  18.2k|    pdu = _sess_process_packet_parse_pdu(slp, sp, isp, transport, opaque,
 6077|  18.2k|                                         olength, packetptr, length);
 6078|  18.2k|    if (NULL == pdu)
  ------------------
  |  Branch (6078:9): [True: 18.2k, False: 0]
  ------------------
 6079|  18.2k|        return -1;
 6080|       |
 6081|       |    /*
 6082|       |     * find session to process pdu. usually that will be the current session,
 6083|       |     * but with the introduction of shared transports, another session may
 6084|       |     * have the same socket.
 6085|       |     */
 6086|      0|    do {
 6087|      0|        rc = _sess_process_packet_handle_pdu(slp, sp, isp, transport, pdu);
 6088|      0|        if (-2 != rc || !(transport->flags & NETSNMP_TRANSPORT_FLAG_SHARED))
  ------------------
  |  |   58|      0|#define		NETSNMP_TRANSPORT_FLAG_SHARED	 0x40
  ------------------
  |  Branch (6088:13): [True: 0, False: 0]
  |  Branch (6088:25): [True: 0, False: 0]
  ------------------
 6089|      0|            break;
 6090|       |
 6091|       |        /** -2 means pdu not in request list. check other sessions */
 6092|      0|        do  {
 6093|      0|            slp = slp->next;
 6094|      0|        } while (slp && slp->transport->sock != transport->sock);
  ------------------
  |  Branch (6094:18): [True: 0, False: 0]
  |  Branch (6094:25): [True: 0, False: 0]
  ------------------
 6095|      0|        if (!slp)
  ------------------
  |  Branch (6095:13): [True: 0, False: 0]
  ------------------
 6096|      0|            break; /* no more sessions with same socket */
 6097|       |
 6098|      0|        sp = slp->session;
 6099|      0|        isp = slp->internal;
 6100|      0|        transport = slp->transport;
 6101|      0|    } while(slp);
  ------------------
  |  Branch (6101:13): [True: 0, False: 0]
  ------------------
 6102|       |
 6103|      0|    if (-2 == rc) { /* did not find session for pdu */
  ------------------
  |  Branch (6103:9): [True: 0, False: 0]
  ------------------
 6104|      0|        snmp_increment_statistic(STAT_SNMPUNKNOWNPDUHANDLERS);
  ------------------
  |  |  613|      0|#define   STAT_SNMPUNKNOWNPDUHANDLERS        2
  ------------------
 6105|      0|        DEBUGMSGTL(("sess_process_packet", "unhandled PDU\n"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 6106|      0|        snmp_free_pdu(pdu);
 6107|      0|    }
 6108|       |
 6109|      0|  return rc;
 6110|  18.2k|}
snmp_api.c:_sess_process_packet_parse_pdu:
 5744|  18.2k|{
 5745|  18.2k|  netsnmp_pdu    *pdu;
 5746|  18.2k|  int             ret = 0;
 5747|  18.2k|  int             dump = 0, filter = 0;
 5748|       |
 5749|  18.2k|  debug_indent_reset();
 5750|       |
 5751|  18.2k|  DEBUGMSGTL(("sess_process_packet",
  ------------------
  |  |   66|  18.2k|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|  18.2k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 18.2k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|  18.2k|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  18.2k|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|  18.2k|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|  18.2k|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 18.2k]
  |  |  ------------------
  ------------------
 5752|  18.2k|	      "session %p fd %" NETSNMP_FMT_SKT " pkt %p length %d\n", slp,
 5753|  18.2k|	      transport->sock, packetptr, length));
 5754|       |
 5755|  18.2k|  dump = netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|  18.2k|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 5756|  18.2k|                                NETSNMP_DS_LIB_DUMP_PACKET);
  ------------------
  |  |   63|  18.2k|#define NETSNMP_DS_LIB_DUMP_PACKET         4
  ------------------
 5757|  18.2k|#ifndef NETSNMP_FEATURE_REMOVE_FILTER_SOURCE
 5758|  18.2k|  filter = netsnmp_ds_get_int(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|  18.2k|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 5759|  18.2k|                                  NETSNMP_DS_LIB_FILTER_TYPE);
  ------------------
  |  |  133|  18.2k|#define NETSNMP_DS_LIB_FILTER_TYPE         17 /* 0=NONE, 1=whitelist, -1=blacklist */
  ------------------
 5760|  18.2k|#endif
 5761|  18.2k|  if (dump || filter) {
  ------------------
  |  Branch (5761:7): [True: 0, False: 18.2k]
  |  Branch (5761:15): [True: 0, False: 18.2k]
  ------------------
 5762|      0|      int filtered = 0;
 5763|      0|      char *addrtxt = netsnmp_transport_peer_string(transport, opaque, olength);
 5764|       |
 5765|      0|      if (!addrtxt) {
  ------------------
  |  Branch (5765:11): [True: 0, False: 0]
  ------------------
 5766|      0|          DEBUGMSGTL(("sess_process_packet",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 5767|      0|                      "Failed to resolve peer address\n"));
 5768|      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, False: 0]
  |  |  ------------------
  ------------------
 5769|      0|          return NULL;
 5770|      0|      }
 5771|       |
 5772|      0|      snmp_log(LOG_DEBUG, "\nReceived %d byte packet from %s\n",
 5773|      0|               length, addrtxt);
 5774|       |
 5775|      0|      if (dump)
  ------------------
  |  Branch (5775:11): [True: 0, False: 0]
  ------------------
 5776|      0|          xdump(packetptr, length, "");
 5777|       |
 5778|      0|#ifndef NETSNMP_FEATURE_REMOVE_FILTER_SOURCE
 5779|      0|      if (filter) {
  ------------------
  |  Branch (5779:11): [True: 0, False: 0]
  ------------------
 5780|      0|          char *sourceaddr = NULL, *c = strchr(addrtxt, '[');
 5781|      0|          const char *dropstr = NULL;
 5782|      0|          if (c) {
  ------------------
  |  Branch (5782:15): [True: 0, False: 0]
  ------------------
 5783|      0|              sourceaddr = ++c;
 5784|      0|              c = strchr(sourceaddr, ']');
 5785|      0|              if (c)
  ------------------
  |  Branch (5785:19): [True: 0, False: 0]
  ------------------
 5786|      0|                  *c = 0;
 5787|      0|              filtered = netsnmp_transport_filter_check(sourceaddr);
 5788|      0|          }
 5789|      0|          else if (!strncmp(addrtxt, "callback", 8)) {
  ------------------
  |  Branch (5789:20): [True: 0, False: 0]
  ------------------
 5790|       |              /* do not filter internal request */
 5791|      0|              DEBUGMSGTL(("sess_process_packet:filter",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 5792|      0|                          "bypass packet from %s \n",
 5793|      0|                          addrtxt));
 5794|      0|              filtered = 1;
 5795|      0|          }
 5796|      0|          if ((filter == -1) && filtered)
  ------------------
  |  Branch (5796:15): [True: 0, False: 0]
  |  Branch (5796:33): [True: 0, False: 0]
  ------------------
 5797|      0|              dropstr = "matched blacklist";
 5798|      0|          else if ((filter == 1) && !filtered)
  ------------------
  |  Branch (5798:20): [True: 0, False: 0]
  |  Branch (5798:37): [True: 0, False: 0]
  ------------------
 5799|      0|              dropstr = "didn't match whitelist";
 5800|      0|          if (dropstr) {
  ------------------
  |  Branch (5800:15): [True: 0, False: 0]
  ------------------
 5801|      0|              DEBUGMSGTL(("sess_process_packet:filter",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (164:52): [True: 0, False: 0]
  |  |  |  |  |  Branch (164:64): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 5802|      0|                          "packet from %s %s\n",
 5803|      0|                          sourceaddr ? sourceaddr : "UNKNOWN", dropstr));
 5804|      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, False: 0]
  |  |  ------------------
  ------------------
 5805|      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, False: 0]
  |  |  ------------------
  ------------------
 5806|      0|              return NULL;
 5807|      0|          }
 5808|      0|      }
 5809|      0|#endif
 5810|       |
 5811|      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, False: 0]
  |  |  ------------------
  ------------------
 5812|      0|  }
 5813|       |
 5814|       |  /*
 5815|       |   * Do transport-level filtering (e.g. IP-address based allow/deny).  
 5816|       |   */
 5817|       |
 5818|  18.2k|  if (isp->hook_pre) {
  ------------------
  |  Branch (5818:7): [True: 0, False: 18.2k]
  ------------------
 5819|      0|    if (isp->hook_pre(sp, transport, opaque, olength) == 0) {
  ------------------
  |  Branch (5819:9): [True: 0, False: 0]
  ------------------
 5820|      0|      DEBUGMSGTL(("sess_process_packet", "pre-parse fail\n"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 5821|      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, False: 0]
  |  |  ------------------
  ------------------
 5822|      0|      return NULL;
 5823|      0|    }
 5824|      0|  }
 5825|       |
 5826|  18.2k|  if (isp->hook_create_pdu) {
  ------------------
  |  Branch (5826:7): [True: 0, False: 18.2k]
  ------------------
 5827|      0|    pdu = isp->hook_create_pdu(transport, opaque, olength);
 5828|  18.2k|  } else {
 5829|  18.2k|    pdu = snmp_create_sess_pdu(transport, opaque, olength);
 5830|  18.2k|  }
 5831|       |
 5832|  18.2k|  if (pdu == NULL) {
  ------------------
  |  Branch (5832:7): [True: 0, False: 18.2k]
  ------------------
 5833|      0|    snmp_log(LOG_ERR, "pdu failed to be created\n");
 5834|      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, False: 0]
  |  |  ------------------
  ------------------
 5835|      0|    return NULL;
 5836|      0|  }
 5837|       |
 5838|       |  /* if the transport was a magic tunnel, mark the PDU as having come
 5839|       |     through one. */
 5840|  18.2k|  if (transport->flags & NETSNMP_TRANSPORT_FLAG_TUNNELED) {
  ------------------
  |  |   53|  18.2k|#define		NETSNMP_TRANSPORT_FLAG_TUNNELED	 0x04
  ------------------
  |  Branch (5840:7): [True: 0, False: 18.2k]
  ------------------
 5841|      0|      pdu->flags |= UCD_MSG_FLAG_TUNNELED;
  ------------------
  |  |  317|      0|#define UCD_MSG_FLAG_TUNNELED               0x4000
  ------------------
 5842|      0|  }
 5843|       |
 5844|  18.2k|  if (isp->hook_parse) {
  ------------------
  |  Branch (5844:7): [True: 0, False: 18.2k]
  ------------------
 5845|      0|    ret = isp->hook_parse(sp, pdu, packetptr, length);
 5846|  18.2k|  } else {
 5847|  18.2k|    ret = snmp_parse(slp, sp, pdu, packetptr, length);
 5848|  18.2k|  }
 5849|       |
 5850|  18.2k|  DEBUGMSGTL(("sess_process_packet", "received message id#%ld reqid#%ld len "
  ------------------
  |  |   66|  18.2k|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|  18.2k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 18.2k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|  18.2k|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  18.2k|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|  18.2k|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|  18.2k|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 18.2k]
  |  |  ------------------
  ------------------
 5851|  18.2k|              "%u\n", pdu->msgid, pdu->reqid, length));
 5852|       |
 5853|  18.2k|  if (ret != SNMP_ERR_NOERROR) {
  ------------------
  |  |  212|  18.2k|#define SNMP_ERR_NOERROR                (0)     /* XXX  Used only for PDUs? */
  ------------------
  |  Branch (5853:7): [True: 18.2k, False: 0]
  ------------------
 5854|  18.2k|    DEBUGMSGTL(("sess_process_packet", "parse fail\n"));
  ------------------
  |  |   66|  18.2k|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|  18.2k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 18.2k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|  18.2k|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  18.2k|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|  18.2k|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|  18.2k|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 18.2k]
  |  |  ------------------
  ------------------
 5855|  18.2k|  }
 5856|       |
 5857|  18.2k|  if (isp->hook_post) {
  ------------------
  |  Branch (5857:7): [True: 0, False: 18.2k]
  ------------------
 5858|      0|    if (isp->hook_post(sp, pdu, ret) == 0) {
  ------------------
  |  Branch (5858:9): [True: 0, False: 0]
  ------------------
 5859|      0|      DEBUGMSGTL(("sess_process_packet", "post-parse fail\n"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 5860|      0|      ret = SNMPERR_ASN_PARSE_ERR;
  ------------------
  |  |  213|      0|#define SNMPERR_ASN_PARSE_ERR           (-29)
  ------------------
 5861|      0|    }
 5862|      0|  }
 5863|       |
 5864|  18.2k|  if (ret != SNMP_ERR_NOERROR) {
  ------------------
  |  |  212|  18.2k|#define SNMP_ERR_NOERROR                (0)     /* XXX  Used only for PDUs? */
  ------------------
  |  Branch (5864:7): [True: 18.2k, False: 0]
  ------------------
 5865|  18.2k|    snmp_free_pdu(pdu);
 5866|  18.2k|    return NULL;
 5867|  18.2k|  }
 5868|       |
 5869|      0|  return pdu;
 5870|  18.2k|}

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

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

debug_indent_get:
   81|   195k|{
   82|   195k|    return debugindent;
   83|   195k|}
debug_indent_add:
  101|  97.5k|{
  102|  97.5k|    if (-debugindent <= amount && amount <= INT_MAX - debugindent)
  ------------------
  |  Branch (102:9): [True: 94.4k, False: 3.03k]
  |  Branch (102:35): [True: 94.4k, False: 0]
  ------------------
  103|  94.4k|	debugindent += amount;
  104|       |    netsnmp_assert( debugindent >= 0 ); /* no negative indents */
  ------------------
  |  |   47|  97.5k|#      define netsnmp_assert(x)  do { \
  |  |   48|  97.5k|              if ( x ) \
  |  |  ------------------
  |  |  |  Branch (48:20): [True: 97.5k, False: 0]
  |  |  ------------------
  |  |   49|  97.5k|                 ; \
  |  |   50|  97.5k|              else \
  |  |   51|  97.5k|                 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
  |  |  |  |  ------------------
  |  |  |  |  |  | 1705|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|  97.5k|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded, False: 97.5k]
  |  |  ------------------
  ------------------
  105|  97.5k|}
debug_indent_reset:
  112|  18.2k|{
  113|  18.2k|    if (debugindent != 0)
  ------------------
  |  Branch (113:9): [True: 18.1k, False: 101]
  ------------------
  114|  18.1k|        DEBUGMSGTL(("dump_indent","indent reset from %d\n", debugindent));
  ------------------
  |  |   66|  18.1k|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|  18.1k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 18.1k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|  18.1k|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  18.1k|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|  18.1k|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|  18.1k|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 18.1k]
  |  |  ------------------
  ------------------
  115|  18.2k|    debugindent = 0;
  116|  18.2k|}
debug_register_tokens:
  188|     81|{
  189|     81|    char           *newp, *cp;
  190|     81|    char           *st = NULL;
  191|     81|    int             status;
  192|       |
  193|     81|    if (tokens == NULL || *tokens == 0)
  ------------------
  |  Branch (193:9): [True: 0, False: 81]
  |  Branch (193:27): [True: 0, False: 81]
  ------------------
  194|      0|        return;
  195|       |
  196|     81|    newp = strdup(tokens);      /* strtok_r messes it up */
  197|     81|    if (!newp)
  ------------------
  |  Branch (197:9): [True: 0, False: 81]
  ------------------
  198|      0|        return;
  199|     81|    cp = strtok_r(newp, DEBUG_TOKEN_DELIMITER, &st);
  ------------------
  |  |  226|     81|#define DEBUG_TOKEN_DELIMITER ","
  ------------------
  200|    162|    while (cp) {
  ------------------
  |  Branch (200:12): [True: 81, False: 81]
  ------------------
  201|     81|        if (strlen(cp) < MAX_DEBUG_TOKEN_LEN) {
  ------------------
  |  |  225|     81|#define MAX_DEBUG_TOKEN_LEN 128
  ------------------
  |  Branch (201:13): [True: 81, False: 0]
  ------------------
  202|     81|            if (strcasecmp(cp, DEBUG_ALWAYS_TOKEN) == 0) {
  ------------------
  |  |  227|     81|#define DEBUG_ALWAYS_TOKEN "all"
  ------------------
  |  Branch (202:17): [True: 81, False: 0]
  ------------------
  203|     81|                debug_print_everything = 1;
  204|     81|            } else if (debug_num_tokens < MAX_DEBUG_TOKENS) {
  ------------------
  |  |  224|      0|#define MAX_DEBUG_TOKENS 256
  ------------------
  |  Branch (204:24): [True: 0, False: 0]
  ------------------
  205|      0|                if ('-' == *cp) {
  ------------------
  |  Branch (205:21): [True: 0, False: 0]
  ------------------
  206|      0|                    ++cp;
  207|      0|                    status = SNMP_DEBUG_DISABLED;
  ------------------
  |  |   57|      0|#define SNMP_DEBUG_DISABLED           0
  ------------------
  208|      0|                }
  209|      0|                else
  210|      0|                    status = SNMP_DEBUG_ACTIVE;
  ------------------
  |  |   58|      0|#define SNMP_DEBUG_ACTIVE             1
  ------------------
  211|      0|                dbg_tokens[debug_num_tokens].token_name = strdup(cp);
  212|      0|                dbg_tokens[debug_num_tokens++].enabled  = status;
  213|      0|                snmp_log(LOG_NOTICE, "registered debug token %s, %d\n", cp, status);
  214|      0|            } else {
  215|      0|                snmp_log(LOG_NOTICE, "Unable to register debug token %s\n", cp);
  216|      0|            }
  217|     81|        } else {
  218|      0|            snmp_log(LOG_NOTICE, "Debug token %s over length\n", cp);
  219|      0|        }
  220|     81|        cp = strtok_r(NULL, DEBUG_TOKEN_DELIMITER, &st);
  ------------------
  |  |  226|     81|#define DEBUG_TOKEN_DELIMITER ","
  ------------------
  221|     81|    }
  222|     81|    free(newp);
  223|     81|}
debug_is_token_registered:
  303|  1.01M|{
  304|  1.01M|    int             i, rc;
  305|       |
  306|       |    /*
  307|       |     * debugging flag is on or off
  308|       |     */
  309|  1.01M|    if (!dodebug)
  ------------------
  |  Branch (309:9): [True: 0, False: 1.01M]
  ------------------
  310|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  311|       |
  312|  1.01M|    if (debug_num_tokens == 0 || debug_print_everything) {
  ------------------
  |  Branch (312:9): [True: 1.01M, False: 0]
  |  Branch (312:34): [True: 0, False: 0]
  ------------------
  313|       |        /*
  314|       |         * no tokens specified, print everything
  315|       |         */
  316|  1.01M|        return SNMPERR_SUCCESS;
  ------------------
  |  |  184|  1.01M|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  317|  1.01M|    }
  318|      0|    else
  319|      0|        rc = SNMPERR_GENERR; /* ! found = err */
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  320|       |
  321|      0|    for (i = 0; i < debug_num_tokens; i++) {
  ------------------
  |  Branch (321:17): [True: 0, False: 0]
  ------------------
  322|      0|        if (SNMP_DEBUG_DISABLED == dbg_tokens[i].enabled)
  ------------------
  |  |   57|      0|#define SNMP_DEBUG_DISABLED           0
  ------------------
  |  Branch (322:13): [True: 0, False: 0]
  ------------------
  323|      0|            continue;
  324|      0|        if (dbg_tokens[i].token_name &&
  ------------------
  |  Branch (324:13): [True: 0, False: 0]
  ------------------
  325|      0|            strncmp(dbg_tokens[i].token_name, token,
  ------------------
  |  Branch (325:13): [True: 0, False: 0]
  ------------------
  326|      0|                    strlen(dbg_tokens[i].token_name)) == 0) {
  327|      0|            if (SNMP_DEBUG_ACTIVE == dbg_tokens[i].enabled)
  ------------------
  |  |   58|      0|#define SNMP_DEBUG_ACTIVE             1
  ------------------
  |  Branch (327:17): [True: 0, False: 0]
  ------------------
  328|      0|                return SNMPERR_SUCCESS; /* active */
  ------------------
  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  329|      0|            else
  330|      0|                return SNMPERR_GENERR; /* excluded */
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  331|      0|        }
  332|      0|    }
  333|      0|    return rc;
  334|      0|}
debugmsg:
  338|   915k|{
  339|   915k|    if (debug_is_token_registered(token) == SNMPERR_SUCCESS) {
  ------------------
  |  |  184|   915k|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  |  Branch (339:9): [True: 915k, False: 0]
  ------------------
  340|   915k|	va_list         debugargs;
  341|       |
  342|   915k|	va_start(debugargs, format);
  343|   915k|	snmp_vlog(debug_log_level, format, debugargs);
  344|       |	va_end(debugargs);
  345|   915k|    }
  346|   915k|}
debugmsg_oid:
  350|  2.66k|{
  351|  2.66k|    u_char         *buf = NULL;
  352|  2.66k|    size_t          buf_len = 0, out_len = 0;
  353|       |
  354|  2.66k|    if (sprint_realloc_objid(&buf, &buf_len, &out_len, 1, theoid, len)) {
  ------------------
  |  Branch (354:9): [True: 2.66k, False: 0]
  ------------------
  355|  2.66k|        if (buf != NULL) {
  ------------------
  |  Branch (355:13): [True: 2.66k, False: 0]
  ------------------
  356|  2.66k|            debugmsg(token, "%s", buf);
  357|  2.66k|        }
  358|  2.66k|    } else {
  359|      0|        if (buf != NULL) {
  ------------------
  |  Branch (359:13): [True: 0, False: 0]
  ------------------
  360|      0|            debugmsg(token, "%s [TRUNCATED]", buf);
  361|      0|        }
  362|      0|    }
  363|       |
  364|  2.66k|    if (buf != NULL) {
  ------------------
  |  Branch (364:9): [True: 2.66k, False: 0]
  ------------------
  365|  2.66k|        free(buf);
  366|  2.66k|    }
  367|  2.66k|}
debugmsg_hex:
  459|  39.6k|{
  460|  39.6k|    u_char         *buf = NULL;
  461|  39.6k|    size_t          buf_len = 0, out_len = 0;
  462|       |
  463|  39.6k|    if (sprint_realloc_hexstring
  ------------------
  |  Branch (463:9): [True: 39.6k, False: 0]
  ------------------
  464|  39.6k|        (&buf, &buf_len, &out_len, 1, thedata, len)) {
  465|  39.6k|        if (buf != NULL) {
  ------------------
  |  Branch (465:13): [True: 39.6k, False: 0]
  ------------------
  466|  39.6k|            debugmsg(token, "%s", buf);
  467|  39.6k|        }
  468|  39.6k|    } else {
  469|      0|        if (buf != NULL) {
  ------------------
  |  Branch (469:13): [True: 0, False: 0]
  ------------------
  470|      0|            debugmsg(token, "%s [TRUNCATED]", buf);
  471|      0|        }
  472|      0|    }
  473|       |
  474|  39.6k|    if (buf != NULL) {
  ------------------
  |  Branch (474:9): [True: 39.6k, False: 0]
  ------------------
  475|  39.6k|        free(buf);
  476|  39.6k|    }
  477|  39.6k|}
debugmsgtoken:
  521|   308k|{
  522|   308k|    va_list         debugargs;
  523|       |
  524|   308k|    va_start(debugargs, format);
  525|   308k|    debugmsg(token, "%s: ", token);
  526|       |    va_end(debugargs);
  527|   308k|}
debug_combo_nc:
  531|  2.85k|{
  532|  2.85k|    va_list         debugargs;
  533|       |
  534|  2.85k|    va_start(debugargs, format);
  535|  2.85k|    snmp_log(debug_log_level, "%s: ", token);
  536|  2.85k|    snmp_vlog(debug_log_level, format, debugargs);
  537|       |    va_end(debugargs);
  538|  2.85k|}
snmp_set_do_debugging:
  545|     81|{
  546|     81|    dodebug = val;
  547|     81|}
snmp_get_do_debugging:
  551|   297k|{
  552|   297k|    return dodebug;
  553|   297k|}
snmp_debug_init:
  722|      1|{
  723|       |#ifdef HAVE_WOLFSSL_WOLFCRYPT_LOGGING_H
  724|       |    wolfSSL_Debugging_ON();
  725|       |    wolfSSL_SetLoggingCb(snmp_log_wolfssl_msg);
  726|       |#endif
  727|       |
  728|      1|    register_prenetsnmp_mib_handler("snmp", "doDebugging",
  729|      1|                                    debug_config_turn_on_debugging, NULL,
  730|      1|                                    "(1|0)");
  731|      1|    register_prenetsnmp_mib_handler("snmp", "debugTokens",
  732|      1|                                    debug_config_register_tokens, NULL,
  733|      1|                                    "token[,token...]");
  734|      1|#ifndef NETSNMP_DISABLE_DYNAMIC_LOG_LEVEL
  735|      1|    register_prenetsnmp_mib_handler("snmp", "debugLogLevel",
  736|       |                                    debug_config_debug_log_level, NULL,
  737|      1|                                    "(emerg|alert|crit|err|warning|notice|info|debug)");
  738|      1|#endif /* NETSNMP_DISABLE_DYNAMIC_LOG_LEVEL */
  739|      1|}

init_snmp_enum:
   54|      1|{
   55|      1|    if (NULL != snmp_enum_lists)
  ------------------
  |  Branch (55:9): [True: 0, False: 1]
  ------------------
   56|      0|        return SE_OK;
  ------------------
  |  |   42|      0|#define SE_OK            0
  ------------------
   57|       |
   58|      1|    snmp_enum_lists = calloc(SE_MAX_IDS * SE_MAX_SUBIDS,
  ------------------
  |  |   21|      1|#define SE_MAX_IDS 5
  ------------------
                  snmp_enum_lists = calloc(SE_MAX_IDS * SE_MAX_SUBIDS,
  ------------------
  |  |   22|      1|#define SE_MAX_SUBIDS 32        /* needs to be a multiple of 8 */
  ------------------
   59|      1|                             sizeof(*snmp_enum_lists));
   60|      1|    if (!snmp_enum_lists)
  ------------------
  |  Branch (60:9): [True: 0, False: 1]
  ------------------
   61|      0|        return SE_NOMEM;
  ------------------
  |  |   43|      0|#define SE_NOMEM         1
  ------------------
   62|      1|    current_maj_num = SE_MAX_IDS;
  ------------------
  |  |   21|      1|#define SE_MAX_IDS 5
  ------------------
   63|      1|    current_min_num = SE_MAX_SUBIDS;
  ------------------
  |  |   22|      1|#define SE_MAX_SUBIDS 32        /* needs to be a multiple of 8 */
  ------------------
   64|       |
   65|      1|    register_const_config_handler(type, "enum", se_read_conf, NULL, NULL);
   66|      1|    return SE_OK;
  ------------------
  |  |   42|      1|#define SE_OK            0
  ------------------
   67|      1|}
se_add_pair_to_list:
  269|     28|{
  270|     28|    struct snmp_enum_list *lastnode = NULL, *new_node, *tmp;
  271|       |
  272|     28|    if (!list) {
  ------------------
  |  Branch (272:9): [True: 0, False: 28]
  ------------------
  273|      0|        free(label);
  274|      0|        return SE_DNE;
  ------------------
  |  |   45|      0|#define SE_DNE           -2
  ------------------
  275|      0|    }
  276|       |
  277|     28|    tmp = *list;
  278|     84|    while (tmp) {
  ------------------
  |  Branch (278:12): [True: 60, False: 24]
  ------------------
  279|     60|        if (tmp->value == value) {
  ------------------
  |  Branch (279:13): [True: 4, False: 56]
  ------------------
  280|      4|            free(label);
  281|      4|            return (SE_ALREADY_THERE);
  ------------------
  |  |   44|      4|#define SE_ALREADY_THERE 2
  ------------------
  282|      4|        }
  283|     56|        lastnode = tmp;
  284|     56|        tmp = tmp->next;
  285|     56|    }
  286|       |
  287|     24|    new_node = SNMP_MALLOC_STRUCT(snmp_enum_list);
  ------------------
  |  |   69|     24|#define SNMP_MALLOC_STRUCT(s)   (struct s *) calloc(1, sizeof(struct s))
  ------------------
  288|     24|    if (!new_node) {
  ------------------
  |  Branch (288:9): [True: 0, False: 24]
  ------------------
  289|      0|        free(label);
  290|      0|        return (SE_NOMEM);
  ------------------
  |  |   43|      0|#define SE_NOMEM         1
  ------------------
  291|      0|    }
  292|       |
  293|     24|    if (lastnode)
  ------------------
  |  Branch (293:9): [True: 19, False: 5]
  ------------------
  294|     19|        lastnode->next = new_node;
  295|      5|    else
  296|      5|        *list = new_node;
  297|     24|    new_node->label = label;
  298|     24|    new_node->value = value;
  299|     24|    new_node->next = NULL;
  300|     24|    return (SE_OK);
  ------------------
  |  |   42|     24|#define SE_OK            0
  ------------------
  301|     24|}
se_add_pair_to_slist:
  365|     28|{
  366|     28|    struct snmp_enum_list **list_p = se_find_slist_ptr(listname);
  367|       |
  368|     28|    if (!list_p) {
  ------------------
  |  Branch (368:9): [True: 5, False: 23]
  ------------------
  369|      5|        struct snmp_enum_list_str *sptr =
  370|      5|            SNMP_MALLOC_STRUCT(snmp_enum_list_str);
  ------------------
  |  |   69|      5|#define SNMP_MALLOC_STRUCT(s)   (struct s *) calloc(1, sizeof(struct s))
  ------------------
  371|      5|        if (!sptr) {
  ------------------
  |  Branch (371:13): [True: 0, False: 5]
  ------------------
  372|      0|            free(label);
  373|      0|            return SE_NOMEM;
  ------------------
  |  |   43|      0|#define SE_NOMEM         1
  ------------------
  374|      0|        }
  375|      5|        sptr->next = sliststorage;
  376|      5|        sptr->name = strdup(listname);
  377|      5|        if (!sptr->name) {
  ------------------
  |  Branch (377:13): [True: 0, False: 5]
  ------------------
  378|      0|            free(sptr);
  379|      0|            free(label);
  380|      0|            return SE_NOMEM;
  ------------------
  |  |   43|      0|#define SE_NOMEM         1
  ------------------
  381|      0|        }
  382|      5|        list_p = &sptr->list;
  383|      5|        sliststorage = sptr;
  384|      5|    }
  385|       |
  386|     28|    return se_add_pair_to_list(list_p, label, value);
  387|     28|}
snmp_enum.c:se_find_slist_ptr:
  314|     28|{
  315|     28|    struct snmp_enum_list_str *sptr;
  316|     28|    if (!listname)
  ------------------
  |  Branch (316:9): [True: 0, False: 28]
  ------------------
  317|      0|        return NULL;
  318|       |
  319|     38|    for (sptr = sliststorage; sptr != NULL; sptr = sptr->next)
  ------------------
  |  Branch (319:31): [True: 33, False: 5]
  ------------------
  320|     33|        if (sptr->name && strcmp(sptr->name, listname) == 0)
  ------------------
  |  Branch (320:13): [True: 33, False: 0]
  |  Branch (320:27): [True: 23, False: 10]
  ------------------
  321|     23|            return &sptr->list;
  322|       |
  323|      5|    return NULL;
  324|     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:
 1101|   921k|{
 1102|   921k|    static int      newline = 1;	 /* MTCRITICAL_RESOURCE */
 1103|   921k|    const char     *newline_ptr;
 1104|   921k|    char            sbuf[40];
 1105|       |
 1106|   921k|    if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|   921k|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (1106:9): [True: 0, False: 921k]
  ------------------
 1107|   921k|                               NETSNMP_DS_LIB_LOG_TIMESTAMP) && newline) {
  ------------------
  |  |   64|   921k|#define NETSNMP_DS_LIB_LOG_TIMESTAMP       5
  ------------------
  |  Branch (1107:65): [True: 0, False: 0]
  ------------------
 1108|      0|        sprintf_stamp(NULL, sbuf);
 1109|   921k|    } else {
 1110|   921k|        strcpy(sbuf, "");
 1111|   921k|    }
 1112|       |    /*
 1113|       |     * Remember whether or not the current line ends with a newline for the
 1114|       |     * next call of log_handler_stdouterr().
 1115|       |     */
 1116|   921k|    newline_ptr = strrchr(str, '\n');
 1117|   921k|    newline = newline_ptr && newline_ptr[1] == 0;
  ------------------
  |  Branch (1117:15): [True: 396k, False: 524k]
  |  Branch (1117:30): [True: 391k, False: 5.25k]
  ------------------
 1118|       |
 1119|   921k|    if (logh->imagic)
  ------------------
  |  Branch (1119:9): [True: 0, False: 921k]
  ------------------
 1120|      0|       printf(         "%s%s", sbuf, str);
 1121|   921k|    else
 1122|   921k|       fprintf(stderr, "%s%s", sbuf, str);
 1123|       |
 1124|   921k|    return 1;
 1125|   921k|}
snmp_log_string:
 1292|   921k|{
 1293|   921k|#ifndef NETSNMP_FEATURE_REMOVE_LOGGING_STDIO
 1294|   921k|    static int stderr_enabled = 0;
 1295|   921k|    static netsnmp_log_handler lh = { 1, 0, 0, 0, "stderr",
 1296|   921k|                                      log_handler_stdouterr, 0, NULL,  NULL,
 1297|   921k|                                      NULL };
 1298|   921k|#endif /* NETSNMP_FEATURE_REMOVE_LOGGING_STDIO */
 1299|   921k|    netsnmp_log_handler *logh;
 1300|       |
 1301|       |    /*
 1302|       |     * We've got to be able to log messages *somewhere*!
 1303|       |     * If you don't want stderr logging, then enable something else.
 1304|       |     */
 1305|   921k|    if (0 == logh_enabled) {
  ------------------
  |  Branch (1305:9): [True: 921k, False: 0]
  ------------------
 1306|   921k|#ifndef NETSNMP_FEATURE_REMOVE_LOGGING_STDIO
 1307|   921k|        if (!stderr_enabled) {
  ------------------
  |  Branch (1307:13): [True: 1, False: 921k]
  ------------------
 1308|      1|            ++stderr_enabled;
 1309|      1|            netsnmp_set_line_buffering(stderr);
 1310|      1|        }
 1311|   921k|        log_handler_stdouterr( &lh, priority, str );
 1312|   921k|#endif /* NETSNMP_FEATURE_REMOVE_LOGGING_STDIO */
 1313|       |
 1314|   921k|        return;
 1315|   921k|    }
 1316|      0|#ifndef NETSNMP_FEATURE_REMOVE_LOGGING_STDIO
 1317|      0|    else if (stderr_enabled) {
  ------------------
  |  Branch (1317:14): [True: 0, False: 0]
  ------------------
 1318|      0|        stderr_enabled = 0;
 1319|      0|        log_handler_stdouterr( &lh, LOG_INFO,
 1320|      0|                               "Log handling defined - disabling stderr\n" );
 1321|      0|    }
 1322|      0|#endif /* NETSNMP_FEATURE_REMOVE_LOGGING_STDIO */
 1323|       |        
 1324|       |
 1325|       |    /*
 1326|       |     * Start at the given priority, and work "upwards"....
 1327|       |     */
 1328|      0|    if (priority > LOG_DEBUG)
  ------------------
  |  Branch (1328:9): [True: 0, False: 0]
  ------------------
 1329|      0|        priority = LOG_DEBUG;
 1330|      0|    logh = logh_priorities[priority];
 1331|      0|    for ( ; logh; logh = logh->next ) {
  ------------------
  |  Branch (1331:13): [True: 0, False: 0]
  ------------------
 1332|       |        /*
 1333|       |         * ... but skipping any handlers with a "maximum priority"
 1334|       |         *     that we have already exceeded. And don't forget to
 1335|       |         *     ensure this logging is turned on (see snmp_disable_stderrlog
 1336|       |         *     and its cohorts).
 1337|       |         */
 1338|      0|        if (logh->enabled && priority <= logh->pri_max)
  ------------------
  |  Branch (1338:13): [True: 0, False: 0]
  |  Branch (1338:30): [True: 0, False: 0]
  ------------------
 1339|      0|            logh->handler( logh, priority, str );
 1340|      0|    }
 1341|      0|}
snmp_vlog:
 1379|   921k|{
 1380|   921k|    char           *buffer = NULL;
 1381|   921k|    int             length;
 1382|       |
 1383|   921k|    length = vasprintf(&buffer, format, ap);
 1384|   921k|    if (length < 0) {
  ------------------
  |  Branch (1384:9): [True: 0, False: 921k]
  ------------------
 1385|      0|        snmp_log_string(LOG_ERR, "Could not format log-string\n");
 1386|      0|        return -1;
 1387|      0|    }
 1388|       |
 1389|   921k|    snmp_log_string(priority, buffer);
 1390|   921k|    free(buffer);
 1391|   921k|    return 0;
 1392|   921k|}
snmp_log:
 1403|  3.00k|{
 1404|  3.00k|    va_list         ap;
 1405|  3.00k|    int             ret;
 1406|  3.00k|    va_start(ap, format);
 1407|  3.00k|    ret = snmp_vlog(priority, format, ap);
 1408|       |    va_end(ap);
 1409|  3.00k|    return (ret);
 1410|  3.00k|}

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

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

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;
  ------------------
  |  |  185|      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;
  ------------------
  |  |  246|      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;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  113|      0|    }
  114|      3|    return SNMPERR_SUCCESS;
  ------------------
  |  |  184|      3|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  115|      3|}
find_sec_mod:
  160|  18.3k|{
  161|  18.3k|    struct snmp_secmod_list *sptr;
  162|       |
  163|  73.4k|    for (sptr = registered_services; sptr; sptr = sptr->next) {
  ------------------
  |  Branch (163:38): [True: 55.1k, False: 18.2k]
  ------------------
  164|  55.1k|        if (sptr->securityModel == secmod) {
  ------------------
  |  Branch (164:13): [True: 81, False: 55.0k]
  ------------------
  165|     81|            return sptr->secDef;
  166|     81|        }
  167|  55.1k|    }
  168|       |    /*
  169|       |     * not registered 
  170|       |     */
  171|  18.2k|    return NULL;
  172|  18.3k|}
snmp_secmod.c:set_default_secmod:
  189|     81|{
  190|     81|    netsnmp_session *sess = (netsnmp_session *) serverarg;
  191|     81|    char           *cptr;
  192|     81|    int             model;
  193|       |
  194|     81|    if (!sess)
  ------------------
  |  Branch (194:9): [True: 0, False: 81]
  ------------------
  195|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  196|     81|    if (sess->securityModel == SNMP_DEFAULT_SECMODEL) {
  ------------------
  |  |   91|     81|#define SNMP_DEFAULT_SECMODEL	    -1
  ------------------
  |  Branch (196:9): [True: 0, False: 81]
  ------------------
  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;
  ------------------
  |  |  185|      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|     81|    return SNMPERR_SUCCESS;
  ------------------
  |  |  184|     81|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  214|     81|}

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|     63|		   (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|       |        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|       |                                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_alloc:
  231|     81|{
  232|     81|    netsnmp_transport *transport;
  233|       |
  234|     81|    transport = SNMP_MALLOC_TYPEDEF(netsnmp_transport);
  ------------------
  |  |   73|     81|#define SNMP_MALLOC_TYPEDEF(td)  (td *) calloc(1, sizeof(td))
  ------------------
  235|     81|    if (!transport)
  ------------------
  |  Branch (235:9): [True: 0, False: 81]
  ------------------
  236|      0|        return NULL;
  237|     81|    transport->sock = NETSNMP_INVALID_SOCKET;
  ------------------
  |  |   43|     81|#define NETSNMP_INVALID_SOCKET -1
  ------------------
  238|     81|    return transport;
  239|     81|}
netsnmp_transport_peer_string:
  270|  2.85k|{
  271|  2.85k|    char           *str;
  272|       |
  273|  2.85k|    if (NULL == t)
  ------------------
  |  Branch (273:9): [True: 0, False: 2.85k]
  ------------------
  274|      0|        return NULL;
  275|       |
  276|  2.85k|    if (t->f_fmtaddr != NULL)
  ------------------
  |  Branch (276:9): [True: 0, False: 2.85k]
  ------------------
  277|      0|        str = t->f_fmtaddr(t, data, len);
  278|  2.85k|    else
  279|  2.85k|        str = strdup("<UNKNOWN>");
  280|       |
  281|  2.85k|    return str;
  282|  2.85k|}
netsnmp_transport_filter_cleanup:
  381|      1|{
  382|      1|    if (NULL == filtered)
  ------------------
  |  Branch (382:9): [True: 1, False: 0]
  ------------------
  383|      1|        return;
  384|      0|    CONTAINER_CLEAR(filtered, filtered->free_item, NULL);
  385|      0|    CONTAINER_FREE(filtered);
  386|       |    filtered = NULL;
  387|      0|}
netsnmp_transport_recv:
  450|  3.32k|{
  451|  3.32k|    int debugLength;
  452|       |
  453|  3.32k|    if ((NULL == t) || (NULL == t->f_recv)) {
  ------------------
  |  Branch (453:9): [True: 0, False: 3.32k]
  |  Branch (453:24): [True: 0, False: 3.32k]
  ------------------
  454|      0|        DEBUGMSGTL(("transport:recv", "NULL transport or recv function\n"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
  455|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  456|      0|    }
  457|       |
  458|  3.32k|    length = t->f_recv(t, packet, length, opaque, olength);
  459|       |
  460|  3.32k|    if (length <=0)
  ------------------
  |  Branch (460:9): [True: 471, False: 2.85k]
  ------------------
  461|    471|        return length; /* don't log timeouts/socket closed */
  462|       |
  463|  2.85k|    debugLength = (SNMPERR_SUCCESS ==
  ------------------
  |  |  184|  2.85k|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  464|  2.85k|                   debug_is_token_registered("transport:recv"));
  465|       |
  466|  2.85k|    if (debugLength) {
  ------------------
  |  Branch (466:9): [True: 2.85k, False: 0]
  ------------------
  467|  2.85k|        char *str = netsnmp_transport_peer_string(t,
  468|  2.85k|                                                  opaque ? *opaque : NULL,
  ------------------
  |  Branch (468:51): [True: 2.85k, False: 0]
  ------------------
  469|  2.85k|                                                  olength ? *olength : 0);
  ------------------
  |  Branch (469:51): [True: 2.85k, False: 0]
  ------------------
  470|  2.85k|        DEBUGMSGT_NC(("transport:recv","%d bytes from %s\n", length, str));
  ------------------
  |  |   85|  2.85k|#define DEBUGMSGT_NC(x) do { __DBGMSGT_NC(x); }while(0)
  |  |  ------------------
  |  |  |  |  149|  2.85k|#define __DBGMSGT_NC(x)  debug_combo_nc x
  |  |  ------------------
  |  |  |  Branch (85:54): [Folded, False: 2.85k]
  |  |  ------------------
  ------------------
  471|  2.85k|        SNMP_FREE(str);
  ------------------
  |  |   62|  2.85k|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 2.85k, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 2.85k]
  |  |  ------------------
  ------------------
  472|  2.85k|    }
  473|       |
  474|  2.85k|    return length;
  475|  3.32k|}
netsnmp_tdomain_init:
  503|      1|{
  504|      1|    DEBUGMSGTL(("tdomain", "netsnmp_tdomain_init() called\n"));
  ------------------
  |  |   66|      1|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 1]
  |  |  ------------------
  ------------------
  505|       |
  506|       |/* include the configure generated list of constructor calls */
  507|      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();
  ------------------
  508|       |
  509|      1|    netsnmp_tdomain_dump();
  510|       |
  511|       |
  512|      1|}
netsnmp_tdomain_register:
  554|     12|{
  555|     12|    netsnmp_tdomain **prevNext = &domain_list, *d;
  556|       |
  557|     12|    if (n != NULL) {
  ------------------
  |  Branch (557:9): [True: 12, False: 0]
  ------------------
  558|     78|        for (d = domain_list; d != NULL; d = d->next) {
  ------------------
  |  Branch (558:31): [True: 66, False: 12]
  ------------------
  559|     66|            if (netsnmp_oid_equals(n->name, n->name_length,
  ------------------
  |  Branch (559:17): [True: 0, False: 66]
  ------------------
  560|     66|                                d->name, d->name_length) == 0) {
  561|       |                /*
  562|       |                 * Already registered.  
  563|       |                 */
  564|      0|                return 0;
  565|      0|            }
  566|     66|            prevNext = &(d->next);
  567|     66|        }
  568|     12|        n->next = NULL;
  569|     12|        *prevNext = n;
  570|     12|        return 1;
  571|     12|    } else {
  572|      0|        return 0;
  573|      0|    }
  574|     12|}
snmp_transport.c:netsnmp_tdomain_dump:
  532|      1|{
  533|      1|    netsnmp_tdomain *d;
  534|      1|    int i = 0;
  535|       |
  536|      1|    DEBUGMSGTL(("tdomain", "domain_list -> "));
  ------------------
  |  |   66|      1|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 1]
  |  |  ------------------
  ------------------
  537|     13|    for (d = domain_list; d != NULL; d = d->next) {
  ------------------
  |  Branch (537:27): [True: 12, False: 1]
  ------------------
  538|     12|        DEBUGMSG(("tdomain", "{ "));
  ------------------
  |  |   61|     12|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  144|     12|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 12]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (61:67): [Folded, False: 12]
  |  |  ------------------
  ------------------
  539|     12|        DEBUGMSGOID(("tdomain", d->name, d->name_length));
  ------------------
  |  |   67|     12|#define DEBUGMSGOID(x)     do {if (_DBG_IF_) {__DBGMSGOID(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     12|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 12]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGOID(x)     do {if (_DBG_IF_) {__DBGMSGOID(x);} }while(0)
  |  |  ------------------
  |  |  |  |  165|      0|#define __DBGMSGOID(x)     debugmsg_oid x
  |  |  ------------------
  |  |  |  Branch (67:71): [Folded, False: 12]
  |  |  ------------------
  ------------------
  540|     12|        DEBUGMSG(("tdomain", ", \""));
  ------------------
  |  |   61|     12|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  144|     12|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 12]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (61:67): [Folded, False: 12]
  |  |  ------------------
  ------------------
  541|     34|        for (i = 0; d->prefix[i] != NULL; i++) {
  ------------------
  |  Branch (541:21): [True: 22, False: 12]
  ------------------
  542|     22|            DEBUGMSG(("tdomain", "%s%s", d->prefix[i],
  ------------------
  |  |   61|     22|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  144|     22|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 22]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (61:56): [True: 0, False: 0]
  |  |  |  Branch (61:67): [Folded, False: 22]
  |  |  ------------------
  ------------------
  543|     22|		      (d->prefix[i + 1]) ? "/" : ""));
  544|     22|        }
  545|     12|        DEBUGMSG(("tdomain", "\" } -> "));
  ------------------
  |  |   61|     12|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  144|     12|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 12]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (61:67): [Folded, False: 12]
  |  |  ------------------
  ------------------
  546|     12|    }
  547|      1|    DEBUGMSG(("tdomain", "[NIL]\n"));
  ------------------
  |  |   61|      1|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  144|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (61:67): [Folded, False: 1]
  |  |  ------------------
  ------------------
  548|      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 "
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
  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 "
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
  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;
  ------------------
  |  |  247|      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));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
  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 "
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
  198|      0|			    "config callback failing\n", error_message(retval)));
  199|      0|		return SNMPERR_KRB5;
  ------------------
  |  |  247|      0|#define SNMPERR_KRB5			(-63)
  ------------------
  200|      0|	    }
  201|      0|	}
  202|      1|	else {
  203|      1|	    DEBUGMSGTL(("ksm", "Using default keytab\n"));
  ------------------
  |  |   66|      1|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      1|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      1|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      1|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      1|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 1]
  |  |  ------------------
  ------------------
  204|      1|	}
  205|      1|	keytab_setup = 1;
  206|      1|    }
  207|       |
  208|      1|    return SNMPERR_SUCCESS;
  ------------------
  |  |  184|      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"));
  ------------------
  |  |   66|      1|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      1|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      1|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      1|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      1|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 1]
  |  |  ------------------
  ------------------
   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));
  ------------------
  |  |   66|      1|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      1|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      1|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      1|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      1|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 1]
  |  |  ------------------
  ------------------
   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:
  749|     82|{
  750|     82|    if (user == NULL)
  ------------------
  |  Branch (750:9): [True: 82, False: 0]
  ------------------
  751|     82|        return NULL;
  752|       |
  753|      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, False: 0]
  |  |  ------------------
  ------------------
  754|      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, False: 0]
  |  |  ------------------
  ------------------
  755|      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, False: 0]
  |  |  ------------------
  ------------------
  756|      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, False: 0]
  |  |  ------------------
  ------------------
  757|      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, False: 0]
  |  |  ------------------
  ------------------
  758|      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, False: 0]
  |  |  ------------------
  ------------------
  759|      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, False: 0]
  |  |  ------------------
  ------------------
  760|       |
  761|      0|    if (user->authKey != NULL) {
  ------------------
  |  Branch (761:9): [True: 0, False: 0]
  ------------------
  762|      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, False: 0]
  |  |  ------------------
  ------------------
  763|      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, False: 0]
  |  |  ------------------
  ------------------
  764|      0|    }
  765|       |
  766|      0|    if (user->privKey != NULL) {
  ------------------
  |  Branch (766:9): [True: 0, False: 0]
  ------------------
  767|      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, False: 0]
  |  |  ------------------
  ------------------
  768|      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, False: 0]
  |  |  ------------------
  ------------------
  769|      0|    }
  770|       |
  771|      0|    if (user->authKeyKu != NULL) {
  ------------------
  |  Branch (771:9): [True: 0, False: 0]
  ------------------
  772|      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, False: 0]
  |  |  ------------------
  ------------------
  773|      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, False: 0]
  |  |  ------------------
  ------------------
  774|      0|    }
  775|       |
  776|      0|    if (user->privKeyKu != NULL) {
  ------------------
  |  Branch (776:9): [True: 0, False: 0]
  ------------------
  777|      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, False: 0]
  |  |  ------------------
  ------------------
  778|      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, False: 0]
  |  |  ------------------
  ------------------
  779|      0|    }
  780|       |
  781|      0|#ifdef NETSNMP_USE_OPENSSL
  782|      0|    if (user->usmDHUserAuthKeyChange)
  ------------------
  |  Branch (782:9): [True: 0, False: 0]
  ------------------
  783|      0|    {
  784|      0|        DH_free(user->usmDHUserAuthKeyChange);
  785|      0|        user->usmDHUserAuthKeyChange = NULL;
  786|      0|    }
  787|       |
  788|      0|    if (user->usmDHUserPrivKeyChange)
  ------------------
  |  Branch (788:9): [True: 0, False: 0]
  ------------------
  789|      0|    {
  790|      0|        DH_free(user->usmDHUserPrivKeyChange);
  791|      0|        user->usmDHUserPrivKeyChange = NULL;
  792|      0|    }
  793|      0|#endif
  794|       |
  795|       |    /*
  796|       |     * FIX  Why not put this check *first?*
  797|       |     */
  798|      0|    if (user->prev != NULL && user->prev != (struct usmUser *)-1) {   /* ack, this shouldn't happen */
  ------------------
  |  Branch (798:9): [True: 0, False: 0]
  |  Branch (798:31): [True: 0, False: 0]
  ------------------
  799|      0|        user->prev->next = user->next;
  800|      0|    }
  801|      0|    if (user->next != NULL && user->next != (struct usmUser *)-1) {
  ------------------
  |  Branch (801:9): [True: 0, False: 0]
  |  Branch (801:31): [True: 0, False: 0]
  ------------------
  802|      0|        user->next->prev = user->prev;
  803|      0|        if (user->prev != NULL) /* ack this is really bad, because it means
  ------------------
  |  Branch (803:13): [True: 0, False: 0]
  ------------------
  804|       |                                 * * we'll loose the head of some structure tree */
  805|      0|            DEBUGMSGTL(("usm",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
  806|      0|                        "Severe: Asked to free the head of a usmUser tree somewhere."));
  807|      0|    }
  808|       |
  809|       |
  810|      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, False: 0]
  |  |  ------------------
  ------------------
  811|      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, False: 0]
  |  |  ------------------
  ------------------
  812|       |
  813|      0|    return NULL;                /* for convenience to returns from calling functions */
  814|       |
  815|     82|}                               /* end usm_free_user() */
usm_create_user_from_session:
 3610|     81|{
 3611|     81|    struct usmUser *user;
 3612|     81|    int             user_just_created = 0;
 3613|     81|    char *cp;
 3614|       |
 3615|       |    /*
 3616|       |     * If boot/time supplied set it for this engineID. Do it from hook when
 3617|       |     * creating user in case probe was sent by other means for example
 3618|       |     * asynchronously.
 3619|       |     */
 3620|     81|    if (!(session->flags & SNMP_FLAGS_TIME_CREATED) &&
  ------------------
  |  |  150|     81|#define SNMP_FLAGS_TIME_CREATED    0x2000
  ------------------
  |  Branch (3620:9): [True: 81, False: 0]
  ------------------
 3621|     81|        (session->engineBoots || session->engineTime)) {
  ------------------
  |  Branch (3621:10): [True: 0, False: 81]
  |  Branch (3621:34): [True: 0, False: 81]
  ------------------
 3622|      0|        set_enginetime(session->securityEngineID,
 3623|      0|                       session->securityEngineIDLen,
 3624|      0|                       session->engineBoots, session->engineTime,
 3625|      0|                       TRUE);
  ------------------
  |  |  128|      0|#define TRUE  1
  ------------------
 3626|      0|        session->flags |= SNMP_FLAGS_TIME_CREATED;
  ------------------
  |  |  150|      0|#define SNMP_FLAGS_TIME_CREATED    0x2000
  ------------------
 3627|      0|    }
 3628|       |
 3629|       |    /*
 3630|       |     * - don't create-another/copy-into user for this session by default
 3631|       |     * - bail now (no error) if we don't have an engineID
 3632|       |     */
 3633|     81|    if (SNMP_FLAGS_USER_CREATED == (session->flags & SNMP_FLAGS_USER_CREATED) ||
  ------------------
  |  |  154|     81|#define SNMP_FLAGS_USER_CREATED    0x200      /* USM user has been created */
  ------------------
                  if (SNMP_FLAGS_USER_CREATED == (session->flags & SNMP_FLAGS_USER_CREATED) ||
  ------------------
  |  |  154|     81|#define SNMP_FLAGS_USER_CREATED    0x200      /* USM user has been created */
  ------------------
  |  Branch (3633:9): [True: 0, False: 81]
  ------------------
 3634|     81|        session->securityModel != SNMP_SEC_MODEL_USM ||
  ------------------
  |  |  295|    162|#define SNMP_SEC_MODEL_USM		3
  ------------------
  |  Branch (3634:9): [True: 0, False: 81]
  ------------------
 3635|     81|        session->version != SNMP_VERSION_3 ||
  ------------------
  |  |  113|    162|#define SNMP_VERSION_3     3
  ------------------
  |  Branch (3635:9): [True: 81, False: 0]
  ------------------
 3636|      0|        session->securityNameLen == 0 ||
  ------------------
  |  Branch (3636:9): [True: 0, False: 0]
  ------------------
 3637|      0|        session->securityEngineIDLen == 0)
  ------------------
  |  Branch (3637:9): [True: 0, False: 0]
  ------------------
 3638|     81|        return SNMPERR_SUCCESS;
  ------------------
  |  |  184|     81|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 3639|       |
 3640|      0|    DEBUGMSGTL(("usm", "no flag defined...  continuing\n"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 3641|      0|    session->flags |= SNMP_FLAGS_USER_CREATED;
  ------------------
  |  |  154|      0|#define SNMP_FLAGS_USER_CREATED    0x200      /* USM user has been created */
  ------------------
 3642|       |
 3643|       |    /*
 3644|       |     * now that we have the engineID, create an entry in the USM list
 3645|       |     * for this user using the information in the session 
 3646|       |     */
 3647|      0|    if ((session->flags & SNMP_FLAGS_SESSION_USER) == 0)
  ------------------
  |  |  151|      0|#define SNMP_FLAGS_SESSION_USER    0x1000
  ------------------
  |  Branch (3647:9): [True: 0, False: 0]
  ------------------
 3648|      0|        user = usm_get_user_from_list(session->securityEngineID,
 3649|      0|                                      session->securityEngineIDLen,
 3650|      0|                                      session->securityName,
 3651|      0|                                      session->securityNameLen,
 3652|      0|                                      usm_get_userList(), 0);
 3653|      0|    else
 3654|      0|        user = NULL;
 3655|       |
 3656|       |
 3657|      0|    if (user) {
  ------------------
  |  Branch (3657:9): [True: 0, False: 0]
  ------------------
 3658|      0|        DEBUGMSGTL(("usm", "user exists x=%p\n", user));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 3659|      0|    } else {
 3660|      0|        if (usm_build_user(&user, session) != SNMPERR_SUCCESS)
  ------------------
  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  |  Branch (3660:13): [True: 0, False: 0]
  ------------------
 3661|      0|            return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
 3662|      0|        user_just_created = 1;
 3663|      0|    }
 3664|       |
 3665|       |    /*
 3666|       |     * copy the auth protocol 
 3667|       |     */
 3668|      0|    if (user->authProtocol == NULL && session->securityAuthProto != NULL) {
  ------------------
  |  Branch (3668:9): [True: 0, False: 0]
  |  Branch (3668:39): [True: 0, False: 0]
  ------------------
 3669|      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, False: 0]
  |  |  ------------------
  ------------------
 3670|      0|        user->authProtocol =
 3671|      0|            snmp_duplicate_objid(session->securityAuthProto,
 3672|      0|                                 session->securityAuthProtoLen);
 3673|      0|        if (user->authProtocol == NULL) {
  ------------------
  |  Branch (3673:13): [True: 0, False: 0]
  ------------------
 3674|      0|            usm_free_user(user);
 3675|      0|            return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
 3676|      0|        }
 3677|      0|        user->authProtocolLen = session->securityAuthProtoLen;
 3678|      0|    }
 3679|       |
 3680|       |    /*
 3681|       |     * copy the priv protocol 
 3682|       |     */
 3683|      0|    if (user->privProtocol == NULL && session->securityPrivProto != NULL) {
  ------------------
  |  Branch (3683:9): [True: 0, False: 0]
  |  Branch (3683:39): [True: 0, False: 0]
  ------------------
 3684|      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, False: 0]
  |  |  ------------------
  ------------------
 3685|      0|        user->privProtocol =
 3686|      0|            snmp_duplicate_objid(session->securityPrivProto,
 3687|      0|                                 session->securityPrivProtoLen);
 3688|      0|        if (user->privProtocol == NULL) {
  ------------------
  |  Branch (3688:13): [True: 0, False: 0]
  ------------------
 3689|      0|            usm_free_user(user);
 3690|      0|            return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
 3691|      0|        }
 3692|      0|        user->privProtocolLen = session->securityPrivProtoLen;
 3693|      0|    }
 3694|       |
 3695|       |    /*
 3696|       |     * copy in the authentication Key.  If not localized, localize it 
 3697|       |     */
 3698|      0|    if (user->authKey == NULL) {
  ------------------
  |  Branch (3698:9): [True: 0, False: 0]
  ------------------
 3699|      0|        if (session->securityAuthLocalKey != NULL
  ------------------
  |  Branch (3699:13): [True: 0, False: 0]
  ------------------
 3700|      0|            && session->securityAuthLocalKeyLen != 0) {
  ------------------
  |  Branch (3700:16): [True: 0, False: 0]
  ------------------
 3701|       |            /* already localized key passed in.  use it */
 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, False: 0]
  |  |  ------------------
  ------------------
 3703|      0|            user->authKey = netsnmp_memdup(session->securityAuthLocalKey,
 3704|      0|                                           session->securityAuthLocalKeyLen);
 3705|      0|            if (!user->authKey) {
  ------------------
  |  Branch (3705:17): [True: 0, False: 0]
  ------------------
 3706|      0|                usm_free_user(user);
 3707|      0|                return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
 3708|      0|            }
 3709|      0|            user->authKeyLen = session->securityAuthLocalKeyLen;
 3710|      0|        } else if (session->securityAuthKeyLen != 0) {
  ------------------
  |  Branch (3710:20): [True: 0, False: 0]
  ------------------
 3711|      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, False: 0]
  |  |  ------------------
  ------------------
 3712|      0|            user->authKey = calloc(1, USM_LENGTH_KU_HASHBLOCK);
  ------------------
  |  |   15|      0|#define USM_LENGTH_KU_HASHBLOCK		64      /* In bytes. */
  ------------------
 3713|      0|            user->authKeyLen = USM_LENGTH_KU_HASHBLOCK;
  ------------------
  |  |   15|      0|#define USM_LENGTH_KU_HASHBLOCK		64      /* In bytes. */
  ------------------
 3714|      0|            if ((user->authKey == NULL) ||
  ------------------
  |  Branch (3714:17): [True: 0, False: 0]
  ------------------
 3715|      0|                generate_kul(user->authProtocol, user->authProtocolLen,
  ------------------
  |  Branch (3715:17): [True: 0, False: 0]
  ------------------
 3716|      0|                             user->engineID, user->engineIDLen,
 3717|      0|                             session->securityAuthKey,
 3718|      0|                             session->securityAuthKeyLen, user->authKey,
 3719|      0|                             &user->authKeyLen) != SNMPERR_SUCCESS) {
  ------------------
  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 3720|      0|                usm_free_user(user);
 3721|      0|                return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
 3722|      0|            }
 3723|      0|        } else if ((cp = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|      0|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (3723:20): [True: 0, False: 0]
  ------------------
 3724|      0|                                               NETSNMP_DS_LIB_AUTHLOCALIZEDKEY))) {
  ------------------
  |  |  169|      0|#define NETSNMP_DS_LIB_AUTHLOCALIZEDKEY  18
  ------------------
 3725|      0|            size_t buflen = USM_AUTH_KU_LEN;
  ------------------
  |  |  271|      0|#define USM_AUTH_KU_LEN     64
  ------------------
 3726|      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, False: 0]
  |  |  ------------------
  ------------------
 3727|      0|            user->authKey = (u_char *)malloc(buflen); /* max length needed */
 3728|      0|            user->authKeyLen = 0;
 3729|       |            /* it will be a hex string */
 3730|      0|            if ((NULL == user->authKey) ||
  ------------------
  |  Branch (3730:17): [True: 0, False: 0]
  ------------------
 3731|      0|                !snmp_hex_to_binary(&user->authKey, &buflen, &user->authKeyLen,
  ------------------
  |  Branch (3731:17): [True: 0, False: 0]
  ------------------
 3732|      0|                                    0, cp)) {
 3733|      0|                usm_free_user(user);
 3734|      0|                return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
 3735|      0|            }
 3736|      0|        }
 3737|      0|    }
 3738|       |
 3739|       |    /*
 3740|       |     * copy in the privacy Key.  If not localized, localize it 
 3741|       |     */
 3742|      0|    if (user->privKey == NULL) {
  ------------------
  |  Branch (3742:9): [True: 0, False: 0]
  ------------------
 3743|       |        /** save buffer size in case we need to extend key */
 3744|      0|        int keyBufSize = USM_PRIV_KU_LEN;
  ------------------
  |  |  272|      0|#define USM_PRIV_KU_LEN     64
  ------------------
 3745|       |
 3746|      0|        DEBUGMSGTL(("usm", "copying privKey\n"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 3747|      0|        if (session->securityPrivLocalKey != NULL
  ------------------
  |  Branch (3747:13): [True: 0, False: 0]
  ------------------
 3748|      0|            && session->securityPrivLocalKeyLen != 0) {
  ------------------
  |  Branch (3748:16): [True: 0, False: 0]
  ------------------
 3749|       |            /* already localized key passed in.  use it */
 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, False: 0]
  |  |  ------------------
  ------------------
 3751|      0|            user->privKey = netsnmp_memdup(session->securityPrivLocalKey,
 3752|      0|                                           session->securityPrivLocalKeyLen);
 3753|      0|            if (!user->privKey) {
  ------------------
  |  Branch (3753:17): [True: 0, False: 0]
  ------------------
 3754|      0|                usm_free_user(user);
 3755|      0|                return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
 3756|      0|            }
 3757|      0|            keyBufSize = user->privKeyLen = session->securityPrivLocalKeyLen;
 3758|      0|        } else if (session->securityPrivKeyLen != 0) {
  ------------------
  |  Branch (3758:20): [True: 0, False: 0]
  ------------------
 3759|      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, False: 0]
  |  |  ------------------
  ------------------
 3760|      0|            user->privKey = calloc(1, keyBufSize);
 3761|      0|            user->privKeyLen = keyBufSize;
 3762|      0|            if ((user->privKey == NULL) ||
  ------------------
  |  Branch (3762:17): [True: 0, False: 0]
  ------------------
 3763|      0|                generate_kul(user->authProtocol, user->authProtocolLen,
  ------------------
  |  Branch (3763:17): [True: 0, False: 0]
  ------------------
 3764|      0|                             user->engineID, user->engineIDLen,
 3765|      0|                             session->securityPrivKey,
 3766|      0|                             session->securityPrivKeyLen, user->privKey,
 3767|      0|                             &user->privKeyLen) != SNMPERR_SUCCESS) {
  ------------------
  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 3768|      0|                usm_free_user(user);
 3769|      0|                return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
 3770|      0|            }
 3771|      0|        } else if ((cp = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|      0|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (3771:20): [True: 0, False: 0]
  ------------------
 3772|      0|                                               NETSNMP_DS_LIB_PRIVLOCALIZEDKEY))) {
  ------------------
  |  |  170|      0|#define NETSNMP_DS_LIB_PRIVLOCALIZEDKEY  19
  ------------------
 3773|      0|            size_t buflen = keyBufSize;
 3774|      0|            user->privKey = (u_char *)malloc(buflen); /* max length needed */
 3775|      0|            user->privKeyLen = 0;
 3776|       |            /* it will be a hex string */
 3777|      0|            if ((NULL == user->privKey) ||
  ------------------
  |  Branch (3777:17): [True: 0, False: 0]
  ------------------
 3778|      0|                !snmp_hex_to_binary(&user->privKey, &buflen, &user->privKeyLen,
  ------------------
  |  Branch (3778:17): [True: 0, False: 0]
  ------------------
 3779|      0|                                    0, cp)) {
 3780|      0|                usm_free_user(user);
 3781|      0|                return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
 3782|      0|            }
 3783|      0|        }
 3784|      0|        if (usm_extend_user_kul(user, keyBufSize) != SNMPERR_SUCCESS) {
  ------------------
  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  |  Branch (3784:13): [True: 0, False: 0]
  ------------------
 3785|      0|            usm_free_user(user);
 3786|      0|            return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
 3787|      0|        }
 3788|      0|    }
 3789|       |
 3790|      0|    if (user_just_created) {
  ------------------
  |  Branch (3790:9): [True: 0, False: 0]
  ------------------
 3791|       |        /*
 3792|       |         * add the user into the database 
 3793|       |         */
 3794|      0|        user->userStatus = RS_ACTIVE;
  ------------------
  |  |   35|      0|#define RS_ACTIVE	        1
  ------------------
 3795|      0|        user->userStorageType = ST_READONLY;
  ------------------
  |  |   54|      0|#define ST_READONLY	5
  ------------------
 3796|       |
 3797|      0|        if (session->flags & SNMP_FLAGS_SESSION_USER) {
  ------------------
  |  |  151|      0|#define SNMP_FLAGS_SESSION_USER    0x1000
  ------------------
  |  Branch (3797:13): [True: 0, False: 0]
  ------------------
 3798|      0|            if (session->sessUser)
  ------------------
  |  Branch (3798:17): [True: 0, False: 0]
  ------------------
 3799|      0|                usm_free_user(session->sessUser);
 3800|      0|            session->sessUser = user;
 3801|      0|        } else {
 3802|      0|            usm_add_user(user);
 3803|      0|        }
 3804|      0|    }
 3805|      0|    DEBUGMSGTL(("9:usm", "user created and stored in %s\n", session->flags &
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (164:52): [True: 0, False: 0]
  |  |  |  |  |  Branch (164:64): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 3806|      0|                SNMP_FLAGS_SESSION_USER ? "session" : "local store"));
 3807|       |
 3808|      0|    return SNMPERR_SUCCESS;
  ------------------
  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 3809|       |
 3810|       |
 3811|      0|}
usm_create_user:
 4097|      1|{
 4098|      1|    struct usmUser *newUser;
 4099|       |
 4100|       |    /*
 4101|       |     * create the new user 
 4102|       |     */
 4103|      1|    newUser = calloc(1, sizeof(struct usmUser));
 4104|      1|    if (newUser == NULL)
  ------------------
  |  Branch (4104:9): [True: 0, False: 1]
  ------------------
 4105|      0|        return NULL;
 4106|       |
 4107|       |    /*
 4108|       |     * fill the auth/priv protocols 
 4109|       |     */
 4110|      1|    if ((newUser->authProtocol =
  ------------------
  |  Branch (4110:9): [True: 0, False: 1]
  ------------------
 4111|      1|         snmp_duplicate_objid(usmNoAuthProtocol,
 4112|      1|                              OID_LENGTH(usmNoAuthProtocol))) ==
  ------------------
  |  |   64|      1|    (sizeof(x) / sizeof((x)[0]) +                                       \
  |  |   65|      1|     sizeof(int[-__builtin_types_compatible_p(typeof(x), typeof(&(x)[0]))]))
  ------------------
 4113|      1|        NULL)
 4114|      0|        return usm_free_user(newUser);
 4115|      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]))]))
  ------------------
 4116|       |
 4117|      1|    if ((newUser->privProtocol =
  ------------------
  |  Branch (4117:9): [True: 0, False: 1]
  ------------------
 4118|      1|         snmp_duplicate_objid(usmNoPrivProtocol,
 4119|      1|                              OID_LENGTH(usmNoPrivProtocol))) ==
  ------------------
  |  |   64|      1|    (sizeof(x) / sizeof((x)[0]) +                                       \
  |  |   65|      1|     sizeof(int[-__builtin_types_compatible_p(typeof(x), typeof(&(x)[0]))]))
  ------------------
 4120|      1|        NULL)
 4121|      0|        return usm_free_user(newUser);
 4122|      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]))]))
  ------------------
 4123|       |
 4124|       |    /*
 4125|       |     * set the storage type to nonvolatile, and the status to ACTIVE 
 4126|       |     */
 4127|      1|    newUser->userStorageType = ST_NONVOLATILE;
  ------------------
  |  |   52|      1|#define ST_NONVOLATILE	3
  ------------------
 4128|      1|    newUser->userStatus = RS_ACTIVE;
  ------------------
  |  |   35|      1|#define RS_ACTIVE	        1
  ------------------
 4129|      1|    return newUser;
 4130|       |
 4131|      1|}                               /* end usm_clone_user() */
get_default_authtype:
 5076|    162|{
 5077|    162|    if (defaultAuthType == NULL) {
  ------------------
  |  Branch (5077:9): [True: 1, False: 161]
  ------------------
 5078|      1|        defaultAuthType = SNMP_DEFAULT_AUTH_PROTO;
  ------------------
  |  |   94|      1|#define SNMP_DEFAULT_AUTH_PROTO     usmHMACMD5AuthProtocol
  ------------------
 5079|      1|        defaultAuthTypeLen = SNMP_DEFAULT_AUTH_PROTOLEN;
  ------------------
  |  |   98|      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]))]))
  |  |  ------------------
  ------------------
 5080|      1|    }
 5081|    162|    if (len)
  ------------------
  |  Branch (5081:9): [True: 81, False: 81]
  ------------------
 5082|     81|        *len = defaultAuthTypeLen;
 5083|    162|    return defaultAuthType;
 5084|    162|}
get_default_privtype:
 5098|    162|{
 5099|    162|    if (defaultPrivType == NULL) {
  ------------------
  |  Branch (5099:9): [True: 1, False: 161]
  ------------------
 5100|      1|        defaultPrivType = SNMP_DEFAULT_PRIV_PROTO;
  ------------------
  |  |  100|      1|#define SNMP_DEFAULT_PRIV_PROTO     usmDESPrivProtocol
  ------------------
 5101|      1|        defaultPrivTypeLen = SNMP_DEFAULT_PRIV_PROTOLEN;
  ------------------
  |  |  104|      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]))]))
  |  |  ------------------
  ------------------
 5102|      1|    }
 5103|    162|    if (len)
  ------------------
  |  Branch (5103:9): [True: 81, False: 81]
  ------------------
 5104|     81|        *len = defaultPrivTypeLen;
 5105|    162|    return defaultPrivType;
 5106|    162|}
init_usm:
 5198|      1|{
 5199|      1|    struct snmp_secmod_def *def;
 5200|      1|    char *type;
 5201|       |
 5202|      1|    DEBUGMSGTL(("init_usm", "unit_usm: %" NETSNMP_PRIo "u %" NETSNMP_PRIo "u\n",
  ------------------
  |  |   66|      1|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      1|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      1|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      1|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      1|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 1]
  |  |  ------------------
  ------------------
 5203|      1|                usmNoPrivProtocol[0], usmNoPrivProtocol[1]));
 5204|       |
 5205|      1|    sc_init();                  /* initialize scapi code */
 5206|       |
 5207|       |    /*
 5208|       |     * register ourselves as a security service
 5209|       |     */
 5210|      1|    def = SNMP_MALLOC_STRUCT(snmp_secmod_def);
  ------------------
  |  |   69|      1|#define SNMP_MALLOC_STRUCT(s)   (struct s *) calloc(1, sizeof(struct s))
  ------------------
 5211|      1|    if (def == NULL)
  ------------------
  |  Branch (5211:9): [True: 0, False: 1]
  ------------------
 5212|      0|        return;
 5213|       |    /*
 5214|       |     * XXX: def->init_sess_secmod move stuff from snmp_api.c
 5215|       |     */
 5216|      1|    def->encode_reverse = usm_secmod_rgenerate_out_msg;
 5217|      1|    def->encode_forward = usm_secmod_generate_out_msg;
 5218|      1|    def->decode = usm_secmod_process_in_msg;
 5219|      1|    def->pdu_clone = usm_clone;
 5220|      1|    def->pdu_free_state_ref = usm_free_usmStateReference;
 5221|      1|    def->session_setup = usm_session_init;
 5222|      1|    def->handle_report = usm_handle_report;
 5223|      1|    def->probe_engineid = usm_discover_engineid;
 5224|      1|    def->post_probe_engineid = usm_create_user_from_session_hook;
 5225|      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) {
  ------------------
  |  |  184|      1|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  |  Branch (5225:9): [True: 0, False: 1]
  ------------------
 5226|      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, False: 0]
  |  |  ------------------
  ------------------
 5227|      0|        snmp_log(LOG_ERR, "could not register usm sec mod\n");
 5228|      0|        return;
 5229|      0|    }
 5230|       |
 5231|      1|    snmp_register_callback(SNMP_CALLBACK_LIBRARY,
  ------------------
  |  |   18|      1|#define SNMP_CALLBACK_LIBRARY     0
  ------------------
 5232|      1|                           SNMP_CALLBACK_POST_PREMIB_READ_CONFIG,
  ------------------
  |  |   27|      1|#define SNMP_CALLBACK_POST_PREMIB_READ_CONFIG	3
  ------------------
 5233|      1|                           init_usm_post_config, NULL);
 5234|       |
 5235|      1|    snmp_register_callback(SNMP_CALLBACK_LIBRARY,
  ------------------
  |  |   18|      1|#define SNMP_CALLBACK_LIBRARY     0
  ------------------
 5236|      1|                           SNMP_CALLBACK_SHUTDOWN,
  ------------------
  |  |   26|      1|#define SNMP_CALLBACK_SHUTDOWN		        2
  ------------------
 5237|      1|                           deinit_usm_post_config, NULL);
 5238|       |
 5239|      1|    snmp_register_callback(SNMP_CALLBACK_LIBRARY,
  ------------------
  |  |   18|      1|#define SNMP_CALLBACK_LIBRARY     0
  ------------------
 5240|      1|                           SNMP_CALLBACK_SHUTDOWN,
  ------------------
  |  |   26|      1|#define SNMP_CALLBACK_SHUTDOWN		        2
  ------------------
 5241|      1|                           free_engineID, NULL);
 5242|       |
 5243|      1|    register_config_handler("snmp", "defAuthType", snmpv3_authtype_conf,
 5244|      1|                            NULL, "MD5|SHA|SHA-512|SHA-384|SHA-256|SHA-224");
 5245|      1|    register_config_handler("snmp", "defPrivType", snmpv3_privtype_conf,
 5246|      1|                            NULL,
 5247|      1|                            "DES"
 5248|      1|#ifdef HAVE_AES
 5249|      1|                            "|AES|AES-128"
 5250|      1|#ifdef NETSNMP_DRAFT_BLUMENTHAL_AES_04
 5251|      1|                            "|AES-192|AES-256"
 5252|      1|#endif /* NETSNMP_DRAFT_BLUMENTHAL_AES_04 */
 5253|       |#else
 5254|       |                            " (AES support not available)"
 5255|       |#endif
 5256|      1|                           );
 5257|       |
 5258|       |    /*
 5259|       |     * Free stuff at shutdown time
 5260|       |     */
 5261|      1|    snmp_register_callback(SNMP_CALLBACK_LIBRARY,
  ------------------
  |  |   18|      1|#define SNMP_CALLBACK_LIBRARY     0
  ------------------
 5262|      1|                           SNMP_CALLBACK_SHUTDOWN,
  ------------------
  |  |   26|      1|#define SNMP_CALLBACK_SHUTDOWN		        2
  ------------------
 5263|      1|                           free_enginetime_on_shutdown, NULL);
 5264|       |
 5265|       |
 5266|      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
  ------------------
 5267|       |
 5268|      1|    register_config_handler(type, "userSetAuthPass", usm_set_password,
 5269|      1|                            NULL, NULL);
 5270|      1|    register_config_handler(type, "userSetPrivPass", usm_set_password,
 5271|      1|                            NULL, NULL);
 5272|      1|    register_config_handler(type, "userSetAuthKey", usm_set_password, NULL,
 5273|      1|                            NULL);
 5274|      1|    register_config_handler(type, "userSetPrivKey", usm_set_password, NULL,
 5275|      1|                            NULL);
 5276|      1|    register_config_handler(type, "userSetAuthLocalKey", usm_set_password,
 5277|      1|                            NULL, NULL);
 5278|      1|    register_config_handler(type, "userSetPrivLocalKey", usm_set_password,
 5279|      1|                            NULL, NULL);
 5280|      1|}
snmpusm.c:usm_session_init:
 3461|     81|{
 3462|     81|    char *cp;
 3463|     81|    size_t i;
 3464|       |    
 3465|     81|    if (in_session->securityAuthProtoLen > 0) {
  ------------------
  |  Branch (3465:9): [True: 0, False: 81]
  ------------------
 3466|      0|        session->securityAuthProto =
 3467|      0|            snmp_duplicate_objid(in_session->securityAuthProto,
 3468|      0|                                 in_session->securityAuthProtoLen);
 3469|      0|        if (session->securityAuthProto == NULL) {
  ------------------
  |  Branch (3469:13): [True: 0, False: 0]
  ------------------
 3470|      0|            in_session->s_snmp_errno = SNMPERR_MALLOC;
  ------------------
  |  |  246|      0|#define SNMPERR_MALLOC			(-62)
  ------------------
 3471|      0|            return SNMPERR_MALLOC;
  ------------------
  |  |  246|      0|#define SNMPERR_MALLOC			(-62)
  ------------------
 3472|      0|        }
 3473|     81|    } else if (get_default_authtype(&i) != NULL) {
  ------------------
  |  Branch (3473:16): [True: 81, False: 0]
  ------------------
 3474|     81|        session->securityAuthProto =
 3475|     81|            snmp_duplicate_objid(get_default_authtype(NULL), i);
 3476|     81|        session->securityAuthProtoLen = i;
 3477|     81|    }
 3478|       |
 3479|     81|    if (in_session->securityPrivProtoLen > 0) {
  ------------------
  |  Branch (3479:9): [True: 0, False: 81]
  ------------------
 3480|      0|        session->securityPrivProto =
 3481|      0|            snmp_duplicate_objid(in_session->securityPrivProto,
 3482|      0|                                 in_session->securityPrivProtoLen);
 3483|      0|        if (session->securityPrivProto == NULL) {
  ------------------
  |  Branch (3483:13): [True: 0, False: 0]
  ------------------
 3484|      0|            in_session->s_snmp_errno = SNMPERR_MALLOC;
  ------------------
  |  |  246|      0|#define SNMPERR_MALLOC			(-62)
  ------------------
 3485|      0|            return SNMPERR_MALLOC;
  ------------------
  |  |  246|      0|#define SNMPERR_MALLOC			(-62)
  ------------------
 3486|      0|        }
 3487|     81|    } else if (get_default_privtype(&i) != NULL) {
  ------------------
  |  Branch (3487:16): [True: 81, False: 0]
  ------------------
 3488|     81|        session->securityPrivProto =
 3489|     81|            snmp_duplicate_objid(get_default_privtype(NULL), i);
 3490|     81|        session->securityPrivProtoLen = i;
 3491|     81|    }
 3492|       |
 3493|     81|    if ((in_session->securityAuthKeyLen <= 0) &&
  ------------------
  |  Branch (3493:9): [True: 81, False: 0]
  ------------------
 3494|     81|        ((cp = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|     81|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (3494:9): [True: 0, False: 81]
  ------------------
 3495|     81|				     NETSNMP_DS_LIB_AUTHMASTERKEY)))) {
  ------------------
  |  |  167|     81|#define NETSNMP_DS_LIB_AUTHMASTERKEY     16
  ------------------
 3496|      0|        size_t buflen = sizeof(session->securityAuthKey);
 3497|      0|        u_char *tmpp = session->securityAuthKey;
 3498|      0|        session->securityAuthKeyLen = 0;
 3499|       |        /* it will be a hex string */
 3500|      0|        if (!snmp_hex_to_binary(&tmpp, &buflen,
  ------------------
  |  Branch (3500:13): [True: 0, False: 0]
  ------------------
 3501|      0|                                &session->securityAuthKeyLen, 0, cp)) {
 3502|      0|            snmp_set_detail("error parsing authentication master key");
 3503|      0|            return SNMP_ERR_GENERR;
  ------------------
  |  |  217|      0|#define SNMP_ERR_GENERR	                (5)
  ------------------
 3504|      0|        }
 3505|     81|    } else if ((in_session->securityAuthKeyLen <= 0) &&
  ------------------
  |  Branch (3505:16): [True: 81, False: 0]
  ------------------
 3506|     81|               ((cp = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|     81|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (3506:17): [True: 0, False: 81]
  ------------------
 3507|     81|                                            NETSNMP_DS_LIB_AUTHPASSPHRASE)) ||
  ------------------
  |  |  154|     81|#define NETSNMP_DS_LIB_AUTHPASSPHRASE    3
  ------------------
 3508|     81|                (cp = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|     81|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (3508:17): [True: 0, False: 81]
  ------------------
 3509|     81|                                            NETSNMP_DS_LIB_PASSPHRASE)))) {
  ------------------
  |  |  153|     81|#define NETSNMP_DS_LIB_PASSPHRASE        2
  ------------------
 3510|      0|        session->securityAuthKeyLen = USM_AUTH_KU_LEN;
  ------------------
  |  |  271|      0|#define USM_AUTH_KU_LEN     64
  ------------------
 3511|      0|        if (generate_Ku(session->securityAuthProto,
  ------------------
  |  Branch (3511:13): [True: 0, False: 0]
  ------------------
 3512|      0|                        session->securityAuthProtoLen,
 3513|      0|                        (u_char *) cp, strlen(cp),
 3514|      0|                        session->securityAuthKey,
 3515|      0|                        &session->securityAuthKeyLen) != SNMPERR_SUCCESS) {
  ------------------
  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 3516|      0|            snmp_set_detail
 3517|      0|                ("Error generating a key (Ku) from the supplied authentication pass phrase.");
 3518|      0|            return SNMP_ERR_GENERR;
  ------------------
  |  |  217|      0|#define SNMP_ERR_GENERR	                (5)
  ------------------
 3519|      0|        }
 3520|      0|    }
 3521|       |
 3522|       |    
 3523|     81|    if ((in_session->securityPrivKeyLen <= 0) &&
  ------------------
  |  Branch (3523:9): [True: 81, False: 0]
  ------------------
 3524|     81|        ((cp = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|     81|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (3524:9): [True: 0, False: 81]
  ------------------
 3525|     81|				     NETSNMP_DS_LIB_PRIVMASTERKEY)))) {
  ------------------
  |  |  168|     81|#define NETSNMP_DS_LIB_PRIVMASTERKEY     17
  ------------------
 3526|      0|        size_t buflen = sizeof(session->securityPrivKey);
 3527|      0|        u_char *tmpp = session->securityPrivKey;
 3528|      0|        session->securityPrivKeyLen = 0;
 3529|       |        /* it will be a hex string */
 3530|      0|        if (!snmp_hex_to_binary(&tmpp, &buflen,
  ------------------
  |  Branch (3530:13): [True: 0, False: 0]
  ------------------
 3531|      0|                                &session->securityPrivKeyLen, 0, cp)) {
 3532|      0|            snmp_set_detail("error parsing encryption master key");
 3533|      0|            return SNMP_ERR_GENERR;
  ------------------
  |  |  217|      0|#define SNMP_ERR_GENERR	                (5)
  ------------------
 3534|      0|        }
 3535|     81|    } else if ((in_session->securityPrivKeyLen <= 0) &&
  ------------------
  |  Branch (3535:16): [True: 81, False: 0]
  ------------------
 3536|     81|               ((cp = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|     81|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (3536:17): [True: 0, False: 81]
  ------------------
 3537|     81|                                            NETSNMP_DS_LIB_PRIVPASSPHRASE)) ||
  ------------------
  |  |  155|     81|#define NETSNMP_DS_LIB_PRIVPASSPHRASE    4
  ------------------
 3538|     81|                (cp = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|     81|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (3538:17): [True: 0, False: 81]
  ------------------
 3539|     81|                                            NETSNMP_DS_LIB_PASSPHRASE)))) {
  ------------------
  |  |  153|     81|#define NETSNMP_DS_LIB_PASSPHRASE        2
  ------------------
 3540|      0|        session->securityPrivKeyLen = USM_PRIV_KU_LEN;
  ------------------
  |  |  272|      0|#define USM_PRIV_KU_LEN     64
  ------------------
 3541|      0|        if (generate_Ku(session->securityAuthProto,
  ------------------
  |  Branch (3541:13): [True: 0, False: 0]
  ------------------
 3542|      0|                        session->securityAuthProtoLen,
 3543|      0|                        (u_char *) cp, strlen(cp),
 3544|      0|                        session->securityPrivKey,
 3545|      0|                        &session->securityPrivKeyLen) != SNMPERR_SUCCESS) {
  ------------------
  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 3546|      0|            snmp_set_detail
 3547|      0|                ("Error generating a key (Ku) from the supplied privacy pass phrase.");
 3548|      0|            return SNMP_ERR_GENERR;
  ------------------
  |  |  217|      0|#define SNMP_ERR_GENERR	                (5)
  ------------------
 3549|      0|        }
 3550|      0|    }
 3551|       |
 3552|     81|    return SNMPERR_SUCCESS;
  ------------------
  |  |  184|     81|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 3553|     81|}
snmpusm.c:init_usm_post_config:
 5134|      1|{
 5135|      1|    size_t          salt_integer_len = sizeof(salt_integer);
 5136|      1|    uint64_t        current_time;
 5137|       |
 5138|      1|    if (sc_random((u_char *) & salt_integer, &salt_integer_len) !=
  ------------------
  |  Branch (5138:9): [True: 0, False: 1]
  ------------------
 5139|      1|        SNMPERR_SUCCESS) {
  ------------------
  |  |  184|      1|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 5140|      0|        DEBUGMSGTL(("usm", "sc_random() failed: using time() as salt.\n"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 5141|      0|        current_time = time(NULL);
 5142|      0|        salt_integer = current_time;
 5143|      0|    }
 5144|       |
 5145|      1|#ifdef HAVE_AES
 5146|      1|    salt_integer_len = sizeof (salt_integer64_1);
 5147|      1|    if (sc_random((u_char *) & salt_integer64_1, &salt_integer_len) !=
  ------------------
  |  Branch (5147:9): [True: 0, False: 1]
  ------------------
 5148|      1|        SNMPERR_SUCCESS) {
  ------------------
  |  |  184|      1|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 5149|      0|        DEBUGMSGTL(("usm", "sc_random() failed: using time() as aes1 salt.\n"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 5150|      0|        current_time = time(NULL);
 5151|      0|        salt_integer64_1 = current_time;
 5152|      0|    }
 5153|      1|    salt_integer_len = sizeof (salt_integer64_1);
 5154|      1|    if (sc_random((u_char *) & salt_integer64_2, &salt_integer_len) !=
  ------------------
  |  Branch (5154:9): [True: 0, False: 1]
  ------------------
 5155|      1|        SNMPERR_SUCCESS) {
  ------------------
  |  |  184|      1|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 5156|      0|        DEBUGMSGTL(("usm", "sc_random() failed: using time() as aes2 salt.\n"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 5157|      0|        current_time = time(NULL);
 5158|      0|        salt_integer64_2 = current_time;
 5159|      0|    }
 5160|      1|#endif
 5161|       |
 5162|       |    // Free noNameUser before it is assigned
 5163|      1|    usm_free_user(noNameUser);
 5164|       |
 5165|      1|#ifndef NETSNMP_DISABLE_MD5
 5166|      1|    noNameUser = usm_create_initial_user("", usmHMACMD5AuthProtocol,
 5167|      1|                                         OID_LENGTH(usmHMACMD5AuthProtocol),
  ------------------
  |  |   64|      1|    (sizeof(x) / sizeof((x)[0]) +                                       \
  |  |   65|      1|     sizeof(int[-__builtin_types_compatible_p(typeof(x), typeof(&(x)[0]))]))
  ------------------
 5168|      1|                                         SNMP_DEFAULT_PRIV_PROTO,
  ------------------
  |  |  100|      1|#define SNMP_DEFAULT_PRIV_PROTO     usmDESPrivProtocol
  ------------------
 5169|      1|                                         SNMP_DEFAULT_PRIV_PROTOLEN);
  ------------------
  |  |  104|      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]))]))
  |  |  ------------------
  ------------------
 5170|       |#else
 5171|       |    noNameUser = usm_create_initial_user("", usmHMACSHA1AuthProtocol,
 5172|       |                                         OID_LENGTH(usmHMACSHA1AuthProtocol),
 5173|       |                                         SNMP_DEFAULT_PRIV_PROTO,
 5174|       |                                         SNMP_DEFAULT_PRIV_PROTOLEN);
 5175|       |#endif
 5176|       |
 5177|      1|    if ( noNameUser ) {
  ------------------
  |  Branch (5177:10): [True: 1, False: 0]
  ------------------
 5178|      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, False: 1]
  |  |  ------------------
  ------------------
 5179|      1|        noNameUser->engineIDLen = 0;
 5180|      1|    }
 5181|       |
 5182|      1|    return SNMPERR_SUCCESS;
  ------------------
  |  |  184|      1|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 5183|      1|}                               /* end init_usm_post_config() */
snmpusm.c:usm_create_initial_user:
 4142|      1|{
 4143|      1|    struct usmUser *newUser = usm_create_user();
 4144|      1|    if (newUser == NULL)
  ------------------
  |  Branch (4144:9): [True: 0, False: 1]
  ------------------
 4145|      0|        return NULL;
 4146|       |
 4147|      1|    if ((newUser->name = strdup(name)) == NULL)
  ------------------
  |  Branch (4147:9): [True: 0, False: 1]
  ------------------
 4148|      0|        return usm_free_user(newUser);
 4149|       |
 4150|      1|    if ((newUser->secName = strdup(name)) == NULL)
  ------------------
  |  Branch (4150:9): [True: 0, False: 1]
  ------------------
 4151|      0|        return usm_free_user(newUser);
 4152|       |
 4153|      1|    if ((newUser->engineID =
  ------------------
  |  Branch (4153:9): [True: 0, False: 1]
  ------------------
 4154|      1|         snmpv3_generate_engineID(&newUser->engineIDLen)) == NULL)
 4155|      0|        return usm_free_user(newUser);
 4156|       |
 4157|      1|    if ((newUser->cloneFrom = (oid *) malloc(sizeof(oid) * 2)) == NULL)
  ------------------
  |  Branch (4157:9): [True: 0, False: 1]
  ------------------
 4158|      0|        return usm_free_user(newUser);
 4159|      1|    newUser->cloneFrom[0] = 0;
 4160|      1|    newUser->cloneFrom[1] = 0;
 4161|      1|    newUser->cloneFromLen = 2;
 4162|       |
 4163|      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, False: 1]
  |  |  ------------------
  ------------------
 4164|      1|    if ((newUser->privProtocol = snmp_duplicate_objid(privProtocol,
  ------------------
  |  Branch (4164:9): [True: 0, False: 1]
  ------------------
 4165|      1|                                                      privProtocolLen)) ==
 4166|      1|        NULL) {
 4167|      0|        return usm_free_user(newUser);
 4168|      0|    }
 4169|      1|    newUser->privProtocolLen = privProtocolLen;
 4170|       |
 4171|      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, False: 1]
  |  |  ------------------
  ------------------
 4172|      1|    if ((newUser->authProtocol = snmp_duplicate_objid(authProtocol,
  ------------------
  |  Branch (4172:9): [True: 0, False: 1]
  ------------------
 4173|      1|                                                      authProtocolLen)) ==
 4174|      1|        NULL) {
 4175|      0|        return usm_free_user(newUser);
 4176|      0|    }
 4177|      1|    newUser->authProtocolLen = authProtocolLen;
 4178|       |
 4179|      1|    newUser->userStatus = RS_ACTIVE;
  ------------------
  |  |   35|      1|#define RS_ACTIVE	        1
  ------------------
 4180|      1|    newUser->userStorageType = ST_READONLY;
  ------------------
  |  |   54|      1|#define ST_READONLY	5
  ------------------
 4181|       |
 4182|      1|    return newUser;
 4183|      1|}

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

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

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, False: 2]
  |  |  ------------------
  ------------------
 1180|      2|    return (u_int)(diff.tv_sec + (diff.tv_usec >= 500000L));
 1181|      2|}

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

netsnmp_aal5pvc_ctor:
  374|      1|{
  375|      1|    aal5pvcDomain.name = netsnmp_AAL5PVCDomain;
  376|      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]))]))
  ------------------
  377|      1|    aal5pvcDomain.prefix = calloc(3, sizeof(char *));
  378|      1|    if (!aal5pvcDomain.prefix) {
  ------------------
  |  Branch (378:9): [True: 0, False: 1]
  ------------------
  379|      0|        snmp_log(LOG_ERR, "calloc() failed - out of memory\n");
  380|      0|        return;
  381|      0|    }
  382|      1|    aal5pvcDomain.prefix[0] = "aal5pvc";
  383|      1|    aal5pvcDomain.prefix[1] = "pvc";
  384|       |
  385|      1|    aal5pvcDomain.f_create_from_tstring_new = netsnmp_aal5pvc_create_tstring;
  386|      1|    aal5pvcDomain.f_create_from_ostring     = netsnmp_aal5pvc_create_ostring;
  387|       |
  388|      1|    netsnmp_tdomain_register(&aal5pvcDomain);
  389|      1|}

free_alias_config:
   61|      1|free_alias_config(void) {
   62|      1|    netsnmp_free_all_list_data(alias_memory);
   63|       |    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:
 1711|      1|{
 1712|      1|    static const char indexname[] = "_netsnmp_addr_info";
 1713|      1|    static const char *prefixes[] = { "dtlsudp", "dtls"
 1714|      1|#ifdef NETSNMP_TRANSPORT_UDPIPV6_DOMAIN
 1715|      1|                                      , "dtlsudp6", "dtls6"
 1716|      1|#endif
 1717|      1|    };
 1718|      1|    int i, num_prefixes = sizeof(prefixes) / sizeof(char *);
 1719|      1|#ifdef NETSNMP_TRANSPORT_UDPIPV6_DOMAIN
 1720|      1|    static const char indexname6[] = "_netsnmp_addr_info6";
 1721|      1|#endif
 1722|       |
 1723|      1|    DEBUGMSGTL(("dtlsudp", "registering DTLS constructor\n"));
  ------------------
  |  |   66|      1|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 1]
  |  |  ------------------
  ------------------
 1724|       |
 1725|       |    /* config settings */
 1726|       |
 1727|      1|#ifdef NETSNMP_TRANSPORT_UDPIPV6_DOMAIN
 1728|      1|    if (!openssl_addr_index6)
  ------------------
  |  Branch (1728:9): [True: 1, False: 0]
  ------------------
 1729|      1|        openssl_addr_index6 =
 1730|      1|            SSL_get_ex_new_index(0, NETSNMP_REMOVE_CONST(void *, indexname6),
 1731|      1|                                 NULL, NULL, NULL);
 1732|      1|#endif
 1733|       |
 1734|      1|    dtlsudpDomain.name = netsnmpDTLSUDPDomain;
 1735|      1|    dtlsudpDomain.name_length = netsnmpDTLSUDPDomain_len;
 1736|      1|    dtlsudpDomain.prefix = calloc(num_prefixes + 1, sizeof(char *));
 1737|      1|    if (!dtlsudpDomain.prefix) {
  ------------------
  |  Branch (1737:9): [True: 0, False: 1]
  ------------------
 1738|      0|        snmp_log(LOG_ERR, "calloc() failed - out of memory\n");
 1739|      0|        return;
 1740|      0|    }
 1741|      5|    for (i = 0; i < num_prefixes; ++ i)
  ------------------
  |  Branch (1741:17): [True: 4, False: 1]
  ------------------
 1742|      4|        dtlsudpDomain.prefix[i] = prefixes[i];
 1743|       |
 1744|      1|    dtlsudpDomain.f_create_from_tstring_new = netsnmp_dtlsudp_create_tstring;
 1745|      1|    dtlsudpDomain.f_create_from_ostring     = netsnmp_dtlsudp_create_ostring;
 1746|       |
 1747|      1|    if (!openssl_addr_index)
  ------------------
  |  Branch (1747:9): [True: 1, False: 0]
  ------------------
 1748|      1|        openssl_addr_index =
 1749|      1|            SSL_get_ex_new_index(0, NETSNMP_REMOVE_CONST(void *, indexname),
 1750|      1|                                 NULL, NULL, NULL);
 1751|       |
 1752|      1|    netsnmp_tdomain_register(&dtlsudpDomain);
 1753|      1|}

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

netsnmp_std_ctor:
  269|      1|{
  270|      1|    stdDomain.name = netsnmp_snmpSTDDomain;
  271|      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]))]))
  ------------------
  272|      1|    stdDomain.prefix = calloc(2, sizeof(char *));
  273|      1|    if (!stdDomain.prefix) {
  ------------------
  |  Branch (273:9): [True: 0, False: 1]
  ------------------
  274|      0|        snmp_log(LOG_ERR, "calloc() failed - out of memory\n");
  275|      0|        return;
  276|      0|    }
  277|      1|    stdDomain.prefix[0] = "std";
  278|       |
  279|      1|    stdDomain.f_create_from_tstring_new = netsnmp_std_create_tstring;
  280|      1|    stdDomain.f_create_from_ostring     = netsnmp_std_create_ostring;
  281|       |
  282|      1|    netsnmp_tdomain_register(&stdDomain);
  283|      1|}

netsnmp_tcp_ctor:
  349|      1|{
  350|      1|    tcpDomain.name = netsnmp_snmpTCPDomain;
  351|      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]))]))
  ------------------
  352|      1|    tcpDomain.prefix = calloc(2, sizeof(char *));
  353|      1|    if (!tcpDomain.prefix) {
  ------------------
  |  Branch (353:9): [True: 0, False: 1]
  ------------------
  354|      0|        snmp_log(LOG_ERR, "calloc() failed - out of memory\n");
  355|      0|        return;
  356|      0|    }
  357|      1|    tcpDomain.prefix[0] = "tcp";
  358|       |
  359|      1|    tcpDomain.f_create_from_tstring_new = netsnmp_tcp_create_tstring;
  360|      1|    tcpDomain.f_create_from_ostring     = netsnmp_tcp_create_ostring;
  361|       |
  362|      1|    netsnmp_tdomain_register(&tcpDomain);
  363|      1|}

netsnmp_tcpipv6_ctor:
  380|      1|{
  381|      1|    tcp6Domain.name = netsnmp_TCPIPv6Domain;
  382|      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]))]))
  ------------------
  383|      1|    tcp6Domain.f_create_from_tstring_new = netsnmp_tcp6_create_tstring;
  384|      1|    tcp6Domain.f_create_from_ostring     = netsnmp_tcp6_create_ostring;
  385|      1|    tcp6Domain.prefix = calloc(4, sizeof(char *));
  386|      1|    if (!tcp6Domain.prefix) {
  ------------------
  |  Branch (386:9): [True: 0, False: 1]
  ------------------
  387|      0|        snmp_log(LOG_ERR, "calloc() failed - out of memory\n");
  388|      0|        return;
  389|      0|    }
  390|      1|    tcp6Domain.prefix[0] = "tcp6";
  391|      1|    tcp6Domain.prefix[1] = "tcpv6";
  392|      1|    tcp6Domain.prefix[2] = "tcpipv6";
  393|       |
  394|      1|    netsnmp_tdomain_register(&tcp6Domain);
  395|      1|}

netsnmp_tlsbase_ctor:
  987|      1|netsnmp_tlsbase_ctor(void) {
  988|       |
  989|       |    /* bootstrap ssl since we'll need it */
  990|      1|    netsnmp_init_openssl();
  991|       |
  992|       |    /* the private client cert to authenticate with */
  993|      1|    netsnmp_ds_register_config(ASN_OCTET_STR, "snmp", "extraX509SubDir",
  ------------------
  |  |   78|      1|#define ASN_OCTET_STR	    0x04U
  ------------------
  994|      1|                               NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  995|      1|                               NETSNMP_DS_LIB_CERT_EXTRA_SUBDIR);
  ------------------
  |  |  177|      1|#define NETSNMP_DS_LIB_CERT_EXTRA_SUBDIR 26
  ------------------
  996|       |
  997|       |    /* Do we have a CRL list? */
  998|      1|    netsnmp_ds_register_config(ASN_OCTET_STR, "snmp", "x509CRLFile",
  ------------------
  |  |   78|      1|#define ASN_OCTET_STR	    0x04U
  ------------------
  999|      1|                               NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1000|      1|                               NETSNMP_DS_LIB_X509_CRL_FILE);
  ------------------
  |  |  179|      1|#define NETSNMP_DS_LIB_X509_CRL_FILE     28
  ------------------
 1001|       |
 1002|       |    /* What TLS algorithms should be use */
 1003|      1|    netsnmp_ds_register_config(ASN_OCTET_STR, "snmp", "tlsAlgorithms",
  ------------------
  |  |   78|      1|#define ASN_OCTET_STR	    0x04U
  ------------------
 1004|      1|                               NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1005|      1|                               NETSNMP_DS_LIB_TLS_ALGORITMS);
  ------------------
  |  |  180|      1|#define NETSNMP_DS_LIB_TLS_ALGORITMS     29
  ------------------
 1006|       |
 1007|       |    /* What TLS version should be used at least */
 1008|      1|    netsnmp_ds_register_config(ASN_OCTET_STR, "snmp", "tlsMinVersion",
  ------------------
  |  |   78|      1|#define ASN_OCTET_STR	    0x04U
  ------------------
 1009|      1|                               NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1010|      1|                               NETSNMP_DS_LIB_TLS_MIN_VERSION);
  ------------------
  |  |  187|      1|#define NETSNMP_DS_LIB_TLS_MIN_VERSION   36
  ------------------
 1011|       |
 1012|       |    /* What TLS version should be used at max */
 1013|      1|    netsnmp_ds_register_config(ASN_OCTET_STR, "snmp", "tlsMaxVersion",
  ------------------
  |  |   78|      1|#define ASN_OCTET_STR	    0x04U
  ------------------
 1014|      1|                               NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1015|      1|                               NETSNMP_DS_LIB_TLS_MAX_VERSION);
  ------------------
  |  |  188|      1|#define NETSNMP_DS_LIB_TLS_MAX_VERSION   37
  ------------------
 1016|       |
 1017|       |    /*
 1018|       |     * for the client
 1019|       |     */
 1020|       |
 1021|       |    /* the public client cert to authenticate with */
 1022|      1|    register_config_handler("snmp", "clientCert", _parse_client_cert, NULL,
 1023|      1|                            NULL);
 1024|       |
 1025|       |    /*
 1026|       |     * for the server
 1027|       |     */
 1028|       |
 1029|       |    /* The X509 server key to use */
 1030|      1|    register_config_handler("snmp", "serverCert", _parse_server_cert, NULL,
 1031|      1|                            NULL);
 1032|       |    /*
 1033|       |     * remove cert config ambiguity: localCert, peerCert
 1034|       |     */
 1035|      1|    netsnmp_ds_register_config(ASN_OCTET_STR, "snmp", "localCert",
  ------------------
  |  |   78|      1|#define ASN_OCTET_STR	    0x04U
  ------------------
 1036|      1|                               NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1037|      1|                               NETSNMP_DS_LIB_TLS_LOCAL_CERT);
  ------------------
  |  |  181|      1|#define NETSNMP_DS_LIB_TLS_LOCAL_CERT    30
  ------------------
 1038|      1|    netsnmp_ds_register_config(ASN_OCTET_STR, "snmp", "peerCert",
  ------------------
  |  |   78|      1|#define ASN_OCTET_STR	    0x04U
  ------------------
 1039|      1|                               NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1040|      1|                               NETSNMP_DS_LIB_TLS_PEER_CERT);
  ------------------
  |  |  182|      1|#define NETSNMP_DS_LIB_TLS_PEER_CERT     31
  ------------------
 1041|       |
 1042|       |    /*
 1043|       |     * register our boot-strapping needs
 1044|       |     */
 1045|      1|    snmp_register_callback(SNMP_CALLBACK_LIBRARY,
  ------------------
  |  |   18|      1|#define SNMP_CALLBACK_LIBRARY     0
  ------------------
 1046|      1|			   SNMP_CALLBACK_POST_PREMIB_READ_CONFIG,
  ------------------
  |  |   27|      1|#define SNMP_CALLBACK_POST_PREMIB_READ_CONFIG	3
  ------------------
 1047|      1|			   tls_bootstrap, NULL);
 1048|       |
 1049|      1|}
snmpTLSBaseDomain.c:tls_bootstrap:
  939|      1|tls_bootstrap(int majorid, int minorid, void *serverarg, void *clientarg) {
  940|      1|    char indexname[] = "_netsnmp_verify_info";
  941|       |
  942|       |    /* don't do this more than once */
  943|      1|    if (have_done_bootstrap)
  ------------------
  |  Branch (943:9): [True: 0, False: 1]
  ------------------
  944|      0|        return 0;
  945|      1|    have_done_bootstrap = 1;
  946|       |
  947|      1|    netsnmp_certs_load();
  948|       |
  949|      1|    openssl_local_index =
  950|      1|        SSL_get_ex_new_index(0, indexname, NULL, NULL, verify_info_free);
  951|       |
  952|      1|    return 0;
  953|      1|}

netsnmp_tlstcp_ctor:
 1040|      1|{
 1041|      1|    DEBUGMSGTL(("tlstcp", "registering TLS constructor\n"));
  ------------------
  |  |   66|      1|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 1]
  |  |  ------------------
  ------------------
 1042|       |
 1043|       |    /* config settings */
 1044|       |
 1045|      1|    tlstcpDomain.name = netsnmpTLSTCPDomain;
 1046|      1|    tlstcpDomain.name_length = netsnmpTLSTCPDomain_len;
 1047|      1|    tlstcpDomain.prefix = calloc(3, sizeof(char *));
 1048|      1|    if (!tlstcpDomain.prefix) {
  ------------------
  |  Branch (1048:9): [True: 0, False: 1]
  ------------------
 1049|      0|        snmp_log(LOG_ERR, "calloc() failed - out of memory\n");
 1050|      0|        return;
 1051|      0|    }
 1052|      1|    tlstcpDomain.prefix[0] = "tlstcp";
 1053|      1|    tlstcpDomain.prefix[1] = "tls";
 1054|       |
 1055|      1|    tlstcpDomain.f_create_from_tstring_new = netsnmp_tlstcp_create_tstring;
 1056|      1|    tlstcpDomain.f_create_from_ostring     = netsnmp_tlstcp_create_ostring;
 1057|       |
 1058|      1|    netsnmp_tdomain_register(&tlstcpDomain);
 1059|      1|}

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

netsnmp_udpipv6_ctor:
 1247|      1|{
 1248|      1|    udp6Domain.name = netsnmp_UDPIPv6Domain;
 1249|      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]))]))
  ------------------
 1250|      1|    udp6Domain.f_create_from_tstring_new = netsnmp_udp6_create_tstring;
 1251|      1|    udp6Domain.f_create_from_tspec       = netsnmp_udp6_create_tspec;
 1252|      1|    udp6Domain.f_create_from_ostring     = netsnmp_udp6_create_ostring;
 1253|      1|    udp6Domain.prefix = calloc(5, sizeof(char *));
 1254|      1|    if (!udp6Domain.prefix) {
  ------------------
  |  Branch (1254:9): [True: 0, False: 1]
  ------------------
 1255|      0|        snmp_log(LOG_ERR, "calloc() failed - out of memory\n");
 1256|      0|        return;
 1257|      0|    }
 1258|      1|    udp6Domain.prefix[0] = "udp6";
 1259|      1|    udp6Domain.prefix[1] = "ipv6";
 1260|      1|    udp6Domain.prefix[2] = "udpv6";
 1261|      1|    udp6Domain.prefix[3] = "udpipv6";
 1262|       |
 1263|      1|    netsnmp_tdomain_register(&udp6Domain);
 1264|      1|}

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

netsnmp_unix_ctor:
  523|      1|{
  524|      1|    unixDomain.name = netsnmp_UnixDomain;
  525|      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]))]))
  ------------------
  526|      1|    unixDomain.prefix = calloc(2, sizeof(char *));
  527|      1|    if (!unixDomain.prefix) {
  ------------------
  |  Branch (527:9): [True: 0, False: 1]
  ------------------
  528|      0|        snmp_log(LOG_ERR, "calloc() failed - out of memory\n");
  529|      0|        return;
  530|      0|    }
  531|      1|    unixDomain.prefix[0] = "unix";
  532|       |
  533|      1|    unixDomain.f_create_from_tstring_new = netsnmp_unix_create_tstring;
  534|      1|    unixDomain.f_create_from_ostring     = netsnmp_unix_create_ostring;
  535|       |
  536|      1|    netsnmp_tdomain_register(&unixDomain);
  537|      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|  3.32k|{
   51|  3.32k|    if (bufsiz > recv_datalen) {
  ------------------
  |  Branch (51:9): [True: 2.85k, False: 471]
  ------------------
   52|  2.85k|        memcpy(buf, recv_data, recv_datalen);
   53|  2.85k|        return recv_datalen;
   54|  2.85k|    } else {
   55|    471|        return -1;
   56|    471|    }
   57|  3.32k|}
fuzz_fake_pcap:
   71|     81|{
   72|     81|    netsnmp_large_fd_set lfdset;
   73|       |
   74|     81|    recv_data = buf;
   75|     81|    recv_datalen = len;
   76|       |
   77|     81|    netsnmp_large_fd_set_init(&lfdset, FD_SETSIZE);
   78|     81|    netsnmp_large_fd_setfd(FAKE_FD, &lfdset);
  ------------------
  |  |   42|     81|#define FAKE_FD 3
  ------------------
   79|     81|    snmp_read2(&lfdset);
   80|     81|    netsnmp_large_fd_set_cleanup(&lfdset);
   81|     81|}
LLVMFuzzerTestOneInput:
   85|     81|{
   86|     81|    netsnmp_session *ss;
   87|     81|    netsnmp_transport *transport;
   88|       |
   89|     81|    u_char         *fuzz_buf = malloc(size + 1);
   90|     81|    memcpy(fuzz_buf, data, size);
   91|     81|    fuzz_buf[size] = '\0';
   92|       |
   93|     81|    ss = SNMP_MALLOC_TYPEDEF(netsnmp_session);
  ------------------
  |  |   73|     81|#define SNMP_MALLOC_TYPEDEF(td)  (td *) calloc(1, sizeof(td))
  ------------------
   94|       |
   95|       |    /*
   96|       |     * We allocate with malloc to avoid constants
   97|       |     */
   98|     81|    char          **fake_argv = malloc(sizeof(char *) * 3);
   99|     81|    fake_argv[0] = strdup("snmp_e2e_fuzzer");
  100|     81|    fake_argv[1] = strdup("-Dall");
  101|     81|    fake_argv[2] = strdup("localhost");
  102|       |
  103|     81|    snmp_parse_args(3, fake_argv, ss, "", NULL);
  104|       |
  105|     81|    transport = netsnmp_transport_alloc();
  106|     81|    transport->sock = FAKE_FD;
  ------------------
  |  |   42|     81|#define FAKE_FD 3
  ------------------
  107|     81|    transport->f_recv = snmpfuzz_recv;
  108|       |
  109|     81|    ss->callback = snmpfuzz_callback;
  110|     81|    ss->callback_magic = (void *) NULL;
  111|     81|    ss->securityModel = SNMP_SEC_MODEL_USM;
  ------------------
  |  |  295|     81|#define SNMP_SEC_MODEL_USM		3
  ------------------
  112|     81|    create_user_from_session(ss);
  113|       |
  114|       |    /*
  115|       |     * Use snmp_add() to specify transport explicitly
  116|       |     */
  117|     81|    snmp_add(ss, transport, NULL, NULL);
  118|       |
  119|     81|    fuzz_fake_pcap(fuzz_buf, size);
  120|       |
  121|     81|    snmp_close(ss);
  122|       |    /* To do: register session 'ss' properly and remove the call below. */
  123|     81|    netsnmp_cleanup_session(ss);
  124|     81|    free(ss);
  125|     81|    free(fuzz_buf);
  126|       |
  127|     81|    free(fake_argv[0]);
  128|     81|    free(fake_argv[1]);
  129|     81|    free(fake_argv[2]);
  130|     81|    free(fake_argv);
  131|       |
  132|     81|    return 0;
  133|     81|}

