asn_parse_nlength:
  325|    334|{
  326|    334|    int len_len;
  327|       |
  328|    334|    if (pkt_len < 1)
  ------------------
  |  Branch (328:9): [True: 0, False: 334]
  ------------------
  329|      0|        return NULL;               /* always too short */
  330|       |
  331|    334|    if (NULL == pkt || NULL == data_len)
  ------------------
  |  Branch (331:9): [True: 0, False: 334]
  |  Branch (331:24): [True: 0, False: 334]
  ------------------
  332|      0|        return NULL;
  333|       |
  334|    334|    *data_len = 0;
  335|       |
  336|    334|    if (*pkt & 0x80) {
  ------------------
  |  Branch (336:9): [True: 7, False: 327]
  ------------------
  337|       |        /*
  338|       |         * long length; first byte is length of length (after masking high bit)
  339|       |         */
  340|      7|        len_len = (int) ((*pkt & ~0x80) + 1);
  341|      7|        if (pkt_len < len_len)
  ------------------
  |  Branch (341:13): [True: 1, False: 6]
  ------------------
  342|      1|            return NULL;           /* still too short for length and data */
  343|       |
  344|       |        /* now we know we have enough data to parse length */
  345|      6|        if (NULL == asn_parse_length(pkt, data_len))
  ------------------
  |  Branch (345:13): [True: 1, False: 5]
  ------------------
  346|      1|            return NULL;           /* propagate error from asn_parse_length */
  347|    327|    } else {
  348|       |        /*
  349|       |         * short length; first byte is the length
  350|       |         */
  351|    327|        len_len = 1;
  352|    327|        *data_len = *pkt;
  353|    327|    }
  354|       |
  355|    332|    if ((*data_len + len_len) > pkt_len)
  ------------------
  |  Branch (355:9): [True: 10, False: 322]
  ------------------
  356|     10|        return NULL;
  357|       |
  358|    322|    return (pkt + len_len);
  359|    332|}
asn_check_packet:
  484|    170|{
  485|    170|    u_long          asn_length;
  486|       |
  487|    170|    if (len < 2)
  ------------------
  |  Branch (487:9): [True: 20, False: 150]
  ------------------
  488|     20|        return 0;               /* always too short */
  489|       |
  490|    150|    if (*pkt != (u_char) (ASN_SEQUENCE | ASN_CONSTRUCTOR))
  ------------------
  |  |   84|    150|#define ASN_SEQUENCE	    0x10U
  ------------------
                  if (*pkt != (u_char) (ASN_SEQUENCE | ASN_CONSTRUCTOR))
  ------------------
  |  |   96|    150|#define ASN_CONSTRUCTOR	    0x20U
  ------------------
  |  Branch (490:9): [True: 16, False: 134]
  ------------------
  491|     16|        return -1;              /* wrong type */
  492|       |
  493|    134|    if (*(pkt + 1) & 0x80) {
  ------------------
  |  Branch (493:9): [True: 14, False: 120]
  ------------------
  494|       |        /*
  495|       |         * long length 
  496|       |         */
  497|     14|        if (len < (size_t)(*(pkt + 1) & ~0x80) + 2)
  ------------------
  |  Branch (497:13): [True: 0, False: 14]
  ------------------
  498|      0|            return 0;           /* still to short, incomplete length */
  499|     14|        if (NULL == asn_parse_length(pkt + 1, &asn_length))
  ------------------
  |  Branch (499:13): [True: 4, False: 10]
  ------------------
  500|      4|            return 0;           /* propagate error from asn_parse_length() */
  501|     10|        if (asn_length > (u_long)(INT_MAX - 2 - (*(pkt + 1) & ~0x80)))
  ------------------
  |  Branch (501:13): [True: 6, False: 4]
  ------------------
  502|      6|            return -1;
  503|      4|        return (asn_length + 2 + (*(pkt + 1) & ~0x80));
  504|    120|    } else {
  505|       |        /*
  506|       |         * short length 
  507|       |         */
  508|    120|        return (*(pkt + 1) + 2);
  509|    120|    }
  510|    134|}
asn_parse_int:
  559|    192|{
  560|       |    /*
  561|       |     * ASN.1 integer ::= 0x02 asnlength byte {byte}*
  562|       |     */
  563|    192|    static const char *errpre = "parse int";
  564|    192|    register u_char *bufp = data;
  565|    192|    u_long          asn_length;
  566|    192|    int             i;
  567|    192|    union {
  568|    192|        long          l;
  569|    192|        unsigned char b[sizeof(long)];
  570|    192|    } value;
  571|       |
  572|    192|    if (NULL == data || NULL == datalength || NULL == type || NULL == intp) {
  ------------------
  |  Branch (572:9): [True: 0, False: 192]
  |  Branch (572:25): [True: 0, False: 192]
  |  Branch (572:47): [True: 0, False: 192]
  |  Branch (572:63): [True: 0, False: 192]
  ------------------
  573|      0|        ERROR_MSG("parse int: NULL pointer");
  ------------------
  |  |  188|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
  574|      0|        return NULL;
  575|      0|    }
  576|       |
  577|    192|    if (intsize != sizeof(long)) {
  ------------------
  |  Branch (577:9): [True: 0, False: 192]
  ------------------
  578|      0|        _asn_size_err(errpre, intsize, sizeof(long));
  579|      0|        return NULL;
  580|      0|    }
  581|       |
  582|       |    /** need at least 2 bytes to work with: type, length (which might be 0)  */
  583|    192|    if (*datalength < 2) {
  ------------------
  |  Branch (583:9): [True: 72, False: 120]
  ------------------
  584|     72|        _asn_short_err(errpre, *datalength, 2);
  585|     72|        return NULL;
  586|     72|    }
  587|       |
  588|    120|    *type = *bufp++;
  589|    120|    if (*type != ASN_INTEGER) {
  ------------------
  |  |   75|    120|#define ASN_INTEGER	    0x02U
  ------------------
  |  Branch (589:9): [True: 4, False: 116]
  ------------------
  590|      4|        _asn_type_err(errpre, *type);
  591|      4|        return NULL;
  592|      4|    }
  593|       |
  594|    116|    bufp = asn_parse_nlength(bufp, *datalength - 1, &asn_length);
  595|    116|    if (NULL == bufp) {
  ------------------
  |  Branch (595:9): [True: 4, False: 112]
  ------------------
  596|      4|        _asn_short_err(errpre, *datalength - 1, asn_length);
  597|      4|        return NULL;
  598|      4|    }
  599|       |
  600|    112|    if ((size_t) asn_length > intsize || (int) asn_length == 0) {
  ------------------
  |  Branch (600:9): [True: 1, False: 111]
  |  Branch (600:42): [True: 4, False: 107]
  ------------------
  601|      5|        _asn_length_err(errpre, (size_t) asn_length, intsize);
  602|      5|        return NULL;
  603|      5|    }
  604|       |
  605|    107|    *datalength -= (int) asn_length + (bufp - data);
  606|       |
  607|    107|    DEBUGDUMPSETUP("recv", data, bufp - data + asn_length);
  ------------------
  |  |   83|    107|	do {if (_DBG_IF_) {__DBGDUMPSETUP(token,buf,len);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    107|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 107]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPSETUP(token,buf,len);} }while(0)
  |  |  ------------------
  |  |  |  |  196|      0|        debugmsg("dumpx" token, "dumpx_%s:%*s", token, __DBGINDENT(), ""); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  171|      0|#define __DBGINDENT()      debug_indent_get()
  |  |  |  |  ------------------
  |  |  |  |  197|      0|        __DBGMSGHEX(("dumpx_" token,buf,len)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  169|      0|#define __DBGMSGHEX(x)     debugmsg_hex x
  |  |  |  |  ------------------
  |  |  |  |  198|      0|        if (debug_is_token_registered("dumpv" token) == SNMPERR_SUCCESS || \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (198:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  199|      0|            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|      0|            debugmsg("dumpx_" token,"\n"); \
  |  |  |  |  201|      0|        } else { \
  |  |  |  |  202|      0|            debugmsg("dumpx_" token,"  "); \
  |  |  |  |  203|      0|        } \
  |  |  |  |  204|      0|        debugmsg("dumpv" token, "dumpv_%s:%*s", token, __DBGINDENT(), "");
  |  |  |  |  ------------------
  |  |  |  |  |  |  171|      0|#define __DBGINDENT()      debug_indent_get()
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (83:60): [Folded, False: 107]
  |  |  ------------------
  ------------------
  608|       |
  609|    107|    memset(&value.b, *bufp & 0x80 ? 0xff : 0, sizeof(value.b));
  ------------------
  |  Branch (609:22): [True: 7, False: 100]
  ------------------
  610|    107|    if (NETSNMP_BIGENDIAN) {
  ------------------
  |  | 2425|    107|#  define NETSNMP_BIGENDIAN 0
  |  |  ------------------
  |  |  |  Branch (2425:29): [Folded, False: 107]
  |  |  ------------------
  ------------------
  611|      0|        for (i = sizeof(long) - asn_length; asn_length--; i++)
  ------------------
  |  Branch (611:45): [True: 0, False: 0]
  ------------------
  612|      0|            value.b[i] = *bufp++;
  613|    107|    } else {
  614|    307|        for (i = asn_length - 1; asn_length--; i--)
  ------------------
  |  Branch (614:34): [True: 200, False: 107]
  ------------------
  615|    200|            value.b[i] = *bufp++;
  616|    107|    }
  617|       |
  618|    107|    CHECK_OVERFLOW_S(value.l, 1);
  ------------------
  |  |  214|    107|#define CHECK_OVERFLOW_S(x,y) do {                                      \
  |  |  215|    107|        if (x > INT32_MAX) {                                            \
  |  |  ------------------
  |  |  |  Branch (215:13): [True: 1, False: 106]
  |  |  ------------------
  |  |  216|      1|            DEBUGMSG(("asn","truncating signed value %ld to 32 bits (%d)\n",(long)(x),y)); \
  |  |  ------------------
  |  |  |  |   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]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  217|      1|            x &= 0xffffffff;                                            \
  |  |  218|    106|        } else if (x < INT32_MIN) {                                     \
  |  |  ------------------
  |  |  |  Branch (218:20): [True: 3, False: 103]
  |  |  ------------------
  |  |  219|      3|            DEBUGMSG(("asn","truncating signed value %ld to 32 bits (%d)\n",(long)(x),y)); \
  |  |  ------------------
  |  |  |  |   61|      3|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  |  144|      3|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (144:29): [True: 0, False: 3]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (61:67): [Folded, False: 3]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  220|      3|            x = 0 - (x & 0xffffffff);                                   \
  |  |  221|      3|        }                                                               \
  |  |  222|    107|    } while(0)
  |  |  ------------------
  |  |  |  Branch (222:13): [Folded, False: 107]
  |  |  ------------------
  ------------------
  619|       |
  620|    107|    DEBUGMSG(("dumpv_recv", "  Integer:\t%ld (0x%.2lX)\n", value.l, value.l));
  ------------------
  |  |   61|    107|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  144|    107|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 107]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (61:67): [Folded, False: 107]
  |  |  ------------------
  ------------------
  621|       |
  622|    107|    *intp = value.l;
  623|    107|    return bufp;
  624|    112|}
asn_parse_string:
  912|     28|{
  913|     28|    static const char *errpre = "parse string";
  914|     28|    u_char         *bufp = data;
  915|     28|    u_long          asn_length;
  916|       |
  917|     28|    if (NULL == data || NULL == datalength || NULL == type || NULL == str ||
  ------------------
  |  Branch (917:9): [True: 0, False: 28]
  |  Branch (917:25): [True: 0, False: 28]
  |  Branch (917:47): [True: 0, False: 28]
  |  Branch (917:63): [True: 0, False: 28]
  ------------------
  918|     28|        NULL == strlength) {
  ------------------
  |  Branch (918:9): [True: 0, False: 28]
  ------------------
  919|      0|        ERROR_MSG("parse string: NULL pointer");
  ------------------
  |  |  188|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
  920|      0|        return NULL;
  921|      0|    }
  922|       |
  923|       |    /** need at least 2 bytes to work with: type, length (which might be 0)  */
  924|     28|    if (*datalength < 2) {
  ------------------
  |  Branch (924:9): [True: 0, False: 28]
  ------------------
  925|      0|        _asn_short_err(errpre, *datalength, 2);
  926|      0|        return NULL;
  927|      0|    }
  928|       |
  929|     28|    *type = *bufp++;
  930|     28|    if (*type != ASN_OCTET_STR && *type != ASN_IPADDRESS && *type != ASN_OPAQUE
  ------------------
  |  |   78|     56|#define ASN_OCTET_STR	    0x04U
  ------------------
                  if (*type != ASN_OCTET_STR && *type != ASN_IPADDRESS && *type != ASN_OPAQUE
  ------------------
  |  |   88|     48|#define ASN_IPADDRESS   (ASN_APPLICATION | 0)
  |  |  ------------------
  |  |  |  |   91|     20|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
                  if (*type != ASN_OCTET_STR && *type != ASN_IPADDRESS && *type != ASN_OPAQUE
  ------------------
  |  |   93|     48|#define ASN_OPAQUE	(ASN_APPLICATION | 4)   /* changed so no conflict with other includes */
  |  |  ------------------
  |  |  |  |   91|     20|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (930:9): [True: 20, False: 8]
  |  Branch (930:35): [True: 20, False: 0]
  |  Branch (930:61): [True: 10, False: 10]
  ------------------
  931|     10|            && *type != ASN_NSAP) {
  ------------------
  |  |   98|     10|#define ASN_NSAP	(ASN_APPLICATION | 5)   /* historic - don't use */
  |  |  ------------------
  |  |  |  |   91|     10|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (931:16): [True: 8, False: 2]
  ------------------
  932|      8|        _asn_type_err(errpre, *type);
  933|      8|        return NULL;
  934|      8|    }
  935|       |
  936|     20|    bufp = asn_parse_nlength(bufp, *datalength - 1, &asn_length);
  937|     20|    if (NULL == bufp) {
  ------------------
  |  Branch (937:9): [True: 3, False: 17]
  ------------------
  938|      3|        _asn_short_err(errpre, *datalength - 1, asn_length);
  939|      3|        return NULL;
  940|      3|    }
  941|       |
  942|     17|    if (asn_length > *strlength) {
  ------------------
  |  Branch (942:9): [True: 0, False: 17]
  ------------------
  943|      0|        _asn_length_err(errpre, (size_t) asn_length, *strlength);
  944|      0|        return NULL;
  945|      0|    }
  946|       |
  947|     17|    DEBUGDUMPSETUP("recv", data, bufp - data + asn_length);
  ------------------
  |  |   83|     17|	do {if (_DBG_IF_) {__DBGDUMPSETUP(token,buf,len);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     17|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 17]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPSETUP(token,buf,len);} }while(0)
  |  |  ------------------
  |  |  |  |  196|      0|        debugmsg("dumpx" token, "dumpx_%s:%*s", token, __DBGINDENT(), ""); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  171|      0|#define __DBGINDENT()      debug_indent_get()
  |  |  |  |  ------------------
  |  |  |  |  197|      0|        __DBGMSGHEX(("dumpx_" token,buf,len)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  169|      0|#define __DBGMSGHEX(x)     debugmsg_hex x
  |  |  |  |  ------------------
  |  |  |  |  198|      0|        if (debug_is_token_registered("dumpv" token) == SNMPERR_SUCCESS || \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (198:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  199|      0|            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|      0|            debugmsg("dumpx_" token,"\n"); \
  |  |  |  |  201|      0|        } else { \
  |  |  |  |  202|      0|            debugmsg("dumpx_" token,"  "); \
  |  |  |  |  203|      0|        } \
  |  |  |  |  204|      0|        debugmsg("dumpv" token, "dumpv_%s:%*s", token, __DBGINDENT(), "");
  |  |  |  |  ------------------
  |  |  |  |  |  |  171|      0|#define __DBGINDENT()      debug_indent_get()
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (83:60): [Folded, False: 17]
  |  |  ------------------
  ------------------
  948|       |
  949|     17|    memmove(str, bufp, asn_length);
  950|     17|    if (*strlength > asn_length)
  ------------------
  |  Branch (950:9): [True: 17, False: 0]
  ------------------
  951|     17|        str[asn_length] = 0;
  952|     17|    *strlength = asn_length;
  953|     17|    *datalength -= asn_length + (bufp - data);
  954|       |
  955|     17|    DEBUGIF("dumpv_recv") {
  ------------------
  |  |  145|     17|#define DEBUGIF(x)         if (_DBG_IF_ && debug_is_token_registered(x) == SNMPERR_SUCCESS)
  |  |  ------------------
  |  |  |  |  144|     34|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 17]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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]
  |  |  ------------------
  ------------------
  956|      0|        u_char         *buf = (u_char *) malloc(1 + asn_length);
  957|      0|        size_t          l = (buf != NULL) ? (1 + asn_length) : 0, ol = 0;
  ------------------
  |  Branch (957:29): [True: 0, False: 0]
  ------------------
  958|       |
  959|      0|        if (sprint_realloc_asciistring
  ------------------
  |  Branch (959:13): [True: 0, False: 0]
  ------------------
  960|      0|            (&buf, &l, &ol, 1, str, asn_length)) {
  961|      0|            DEBUGMSG(("dumpv_recv", "  String:\t%s\n", buf));
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
  962|      0|        } else {
  963|      0|            if (buf == NULL) {
  ------------------
  |  Branch (963:17): [True: 0, False: 0]
  ------------------
  964|      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]
  |  |  ------------------
  ------------------
  965|      0|            } else {
  966|      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]
  |  |  ------------------
  ------------------
  967|      0|                          buf));
  968|      0|            }
  969|      0|        }
  970|      0|        if (buf != NULL) {
  ------------------
  |  Branch (970:13): [True: 0, False: 0]
  ------------------
  971|      0|            free(buf);
  972|      0|        }
  973|      0|    }
  974|       |
  975|     17|    return bufp + asn_length;
  976|     17|}
asn_parse_header:
 1073|    192|{
 1074|    192|    register u_char *bufp;
 1075|    192|    u_long          asn_length = 0;
 1076|    192|    const char      *errpre = "parse header";
 1077|       |
 1078|    192|    if (!data || !datalength || !type) {
  ------------------
  |  Branch (1078:9): [True: 0, False: 192]
  |  Branch (1078:18): [True: 0, False: 192]
  |  Branch (1078:33): [True: 0, False: 192]
  ------------------
 1079|      0|        ERROR_MSG("parse header: NULL pointer");
  ------------------
  |  |  188|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 1080|      0|        return NULL;
 1081|      0|    }
 1082|       |
 1083|       |    /** need at least 2 bytes to work with: type, length (which might be 0) */
 1084|    192|    if (*datalength < 2) {
  ------------------
  |  Branch (1084:9): [True: 0, False: 192]
  ------------------
 1085|      0|        _asn_short_err(errpre, *datalength, 2);
 1086|      0|        return NULL;
 1087|      0|    }
 1088|       |
 1089|    192|    bufp = data;
 1090|       |    /*
 1091|       |     * this only works on data types < 30, i.e. no extension octets 
 1092|       |     */
 1093|    192|    if (IS_EXTENSION_ID(*bufp)) {
  ------------------
  |  |  103|    192|#define IS_EXTENSION_ID(byte)	(((byte) & ASN_EXTENSION_ID) == ASN_EXTENSION_ID)
  |  |  ------------------
  |  |  |  |   99|    192|#define ASN_EXTENSION_ID    0x1FU
  |  |  ------------------
  |  |               #define IS_EXTENSION_ID(byte)	(((byte) & ASN_EXTENSION_ID) == ASN_EXTENSION_ID)
  |  |  ------------------
  |  |  |  |   99|    192|#define ASN_EXTENSION_ID    0x1FU
  |  |  ------------------
  |  |  |  Branch (103:31): [True: 0, False: 192]
  |  |  ------------------
  ------------------
 1094|      0|        ERROR_MSG("can't process ID >= 30");
  ------------------
  |  |  188|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 1095|      0|        return NULL;
 1096|      0|    }
 1097|    192|    *type = *bufp++;
 1098|       |
 1099|    192|    bufp = asn_parse_nlength(bufp, *datalength - 1, &asn_length);
 1100|    192|    if (NULL == bufp) {
  ------------------
  |  Branch (1100:9): [True: 3, False: 189]
  ------------------
 1101|      3|        _asn_short_err(errpre, *datalength - 1, asn_length);
 1102|      3|        return NULL;
 1103|      3|    }
 1104|       |
 1105|       |#ifdef DUMP_PRINT_HEADERS
 1106|       |    DEBUGDUMPSETUP("recv", data, (bufp - data));
 1107|       |    DEBUGMSG(("dumpv_recv", "  Header: 0x%.2X, len = %d (0x%X)\n", *data,
 1108|       |              asn_length, asn_length));
 1109|       |#else
 1110|       |    /*
 1111|       |     * DEBUGMSGHEXTLI(("recv",data,(bufp-data)));
 1112|       |     * DEBUGMSG(("dumpH_recv","\n"));
 1113|       |     */
 1114|    189|#endif
 1115|       |
 1116|    189|#ifdef NETSNMP_WITH_OPAQUE_SPECIAL_TYPES
 1117|       |
 1118|    189|    if ((asn_length > 2) && (*type == ASN_OPAQUE) && (*bufp == ASN_OPAQUE_TAG1)) {
  ------------------
  |  |   93|    112|#define ASN_OPAQUE	(ASN_APPLICATION | 4)   /* changed so no conflict with other includes */
  |  |  ------------------
  |  |  |  |   91|    112|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
                  if ((asn_length > 2) && (*type == ASN_OPAQUE) && (*bufp == ASN_OPAQUE_TAG1)) {
  ------------------
  |  |  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
  |  |  ------------------
  ------------------
  |  Branch (1118:9): [True: 112, False: 77]
  |  Branch (1118:29): [True: 0, False: 112]
  |  Branch (1118:54): [True: 0, False: 0]
  ------------------
 1119|       |
 1120|       |        /*
 1121|       |         * check if 64-but counter 
 1122|       |         */
 1123|      0|        switch (*(bufp + 1)) {
 1124|      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 (1124:9): [True: 0, False: 0]
  ------------------
 1125|      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 (1125:9): [True: 0, False: 0]
  ------------------
 1126|      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 (1126:9): [True: 0, False: 0]
  ------------------
 1127|      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 (1127:9): [True: 0, False: 0]
  ------------------
 1128|      0|        case 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 (1128:9): [True: 0, False: 0]
  ------------------
 1129|      0|            *type = *(bufp + 1);
 1130|      0|            break;
 1131|       |
 1132|      0|        default:
  ------------------
  |  Branch (1132:9): [True: 0, False: 0]
  ------------------
 1133|       |            /*
 1134|       |             * just an Opaque 
 1135|       |             */
 1136|      0|            *datalength = (int) asn_length;
 1137|      0|            return bufp;
 1138|      0|        }
 1139|       |        /*
 1140|       |         * value is encoded as special format 
 1141|       |         */
 1142|      0|        *datalength = (int) asn_length;
 1143|      0|        bufp = asn_parse_nlength(bufp+2, *datalength - 2, &asn_length);
 1144|      0|        if (NULL == bufp) {
  ------------------
  |  Branch (1144:13): [True: 0, False: 0]
  ------------------
 1145|      0|            _asn_short_err("parse opaque header", *datalength - 2, asn_length);
 1146|      0|            return NULL;
 1147|      0|        }
 1148|      0|    }
 1149|    189|#endif                          /* NETSNMP_WITH_OPAQUE_SPECIAL_TYPES */
 1150|       |
 1151|    189|    *datalength = (int) asn_length;
 1152|       |
 1153|    189|    return bufp;
 1154|    189|}
asn_parse_sequence:
 1173|    182|{                               /* error message prefix */
 1174|    182|    data = asn_parse_header(data, datalength, type);
 1175|    182|    if (data && (*type != expected_type)) {
  ------------------
  |  Branch (1175:9): [True: 181, False: 1]
  |  Branch (1175:17): [True: 5, False: 176]
  ------------------
 1176|      5|        char            ebuf[128];
 1177|      5|        snprintf(ebuf, sizeof(ebuf),
 1178|      5|                 "%s header type %02X: s/b %02X", estr,
 1179|      5|                (u_char) * type, (u_char) expected_type);
 1180|      5|        ERROR_MSG(ebuf);
  ------------------
  |  |  188|      5|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 1181|      5|        return NULL;
 1182|      5|    }
 1183|    177|    return data;
 1184|    182|}
asn_parse_length:
 1295|     20|{
 1296|     20|    static const char *errpre = "parse length";
 1297|     20|    char            ebuf[128];
 1298|     20|    register u_char lengthbyte;
 1299|       |
 1300|     20|    if (!data || !length) {
  ------------------
  |  Branch (1300:9): [True: 0, False: 20]
  |  Branch (1300:18): [True: 0, False: 20]
  ------------------
 1301|      0|        ERROR_MSG("parse length: NULL pointer");
  ------------------
  |  |  188|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 1302|      0|        return NULL;
 1303|      0|    }
 1304|     20|    lengthbyte = *data;
 1305|       |
 1306|     20|    if (lengthbyte & ASN_LONG_LEN) {
  ------------------
  |  |   98|     20|#define ASN_LONG_LEN	    0x80U
  ------------------
  |  Branch (1306:9): [True: 20, False: 0]
  ------------------
 1307|     20|        lengthbyte &= ~ASN_LONG_LEN;    /* turn MSb off */
  ------------------
  |  |   98|     20|#define ASN_LONG_LEN	    0x80U
  ------------------
 1308|     20|        if (lengthbyte == 0) {
  ------------------
  |  Branch (1308:13): [True: 2, False: 18]
  ------------------
 1309|      2|            snprintf(ebuf, sizeof(ebuf),
 1310|      2|                     "%s: indefinite length not supported", errpre);
 1311|      2|            ERROR_MSG(ebuf);
  ------------------
  |  |  188|      2|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 1312|      2|            return NULL;
 1313|      2|        }
 1314|     18|        if (lengthbyte > sizeof(long)) {
  ------------------
  |  Branch (1314:13): [True: 2, False: 16]
  ------------------
 1315|      2|            snprintf(ebuf, sizeof(ebuf),
 1316|      2|                    "%s: data length %d > %lu not supported", errpre,
 1317|      2|                    lengthbyte, (unsigned long)sizeof(long));
 1318|      2|            ERROR_MSG(ebuf);
  ------------------
  |  |  188|      2|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 1319|      2|            return NULL;
 1320|      2|        }
 1321|     16|        data++;
 1322|     16|        *length = 0;            /* protect against short lengths */
 1323|    106|        while (lengthbyte--) {
  ------------------
  |  Branch (1323:16): [True: 90, False: 16]
  ------------------
 1324|     90|            *length <<= 8;
 1325|     90|            *length |= *data++;
 1326|     90|        }
 1327|     16|        if ((long) *length < 0) {
  ------------------
  |  Branch (1327:13): [True: 1, False: 15]
  ------------------
 1328|      1|            snprintf(ebuf, sizeof(ebuf),
 1329|      1|                     "%s: negative data length %ld\n", errpre,
 1330|      1|                     (long) *length);
 1331|      1|            ERROR_MSG(ebuf);
  ------------------
  |  |  188|      1|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 1332|      1|            return NULL;
 1333|      1|        }
 1334|     15|        return data;
 1335|     16|    } else {                    /* short asnlength */
 1336|      0|        *length = (long) lengthbyte;
 1337|      0|        return data + 1;
 1338|      0|    }
 1339|     20|}
asn_parse_objid:
 1437|      6|{
 1438|      6|    static const char *errpre = "parse objid";
 1439|       |    /*
 1440|       |     * ASN.1 objid ::= 0x06 asnlength subidentifier {subidentifier}*
 1441|       |     * subidentifier ::= {leadingbyte}* lastbyte
 1442|       |     * leadingbyte ::= 1 7bitvalue
 1443|       |     * lastbyte ::= 0 7bitvalue
 1444|       |     */
 1445|      6|    register u_char *bufp = data;
 1446|      6|    register oid   *oidp = objid + 1;
 1447|      6|    register u_long subidentifier;
 1448|      6|    register long   length;
 1449|      6|    u_long          asn_length;
 1450|      6|    size_t          original_length = *objidlength;
 1451|       |
 1452|      6|    if (NULL == data || NULL == datalength || NULL == type || NULL == objid) {
  ------------------
  |  Branch (1452:9): [True: 0, False: 6]
  |  Branch (1452:25): [True: 0, False: 6]
  |  Branch (1452:47): [True: 0, False: 6]
  |  Branch (1452:63): [True: 0, False: 6]
  ------------------
 1453|      0|        ERROR_MSG("parse objid: NULL pointer");
  ------------------
  |  |  188|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 1454|      0|        return NULL;
 1455|      0|    }
 1456|       |
 1457|       |    /** need at least 2 bytes to work with: type, length (which might be 0)  */
 1458|      6|    if (*datalength < 2) {
  ------------------
  |  Branch (1458:9): [True: 0, False: 6]
  ------------------
 1459|      0|        _asn_short_err(errpre, *datalength, 2);
 1460|      0|        return NULL;
 1461|      0|    }
 1462|       |
 1463|      6|    *type = *bufp++;
 1464|      6|    if (*type != ASN_OBJECT_ID) {
  ------------------
  |  |   81|      6|#define ASN_OBJECT_ID	    0x06U
  ------------------
  |  Branch (1464:9): [True: 0, False: 6]
  ------------------
 1465|      0|        _asn_type_err(errpre, *type);
 1466|      0|        return NULL;
 1467|      0|    }
 1468|      6|    bufp = asn_parse_nlength(bufp, *datalength - 1, &asn_length);
 1469|      6|    if (NULL == bufp) {
  ------------------
  |  Branch (1469:9): [True: 2, False: 4]
  ------------------
 1470|      2|        _asn_short_err(errpre, *datalength - 1, asn_length);
 1471|      2|        return NULL;
 1472|      2|    }
 1473|       |
 1474|      4|    *datalength -= (int) asn_length + (bufp - data);
 1475|       |
 1476|      4|    DEBUGDUMPSETUP("recv", data, bufp - data + asn_length);
  ------------------
  |  |   83|      4|	do {if (_DBG_IF_) {__DBGDUMPSETUP(token,buf,len);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      4|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 4]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPSETUP(token,buf,len);} }while(0)
  |  |  ------------------
  |  |  |  |  196|      0|        debugmsg("dumpx" token, "dumpx_%s:%*s", token, __DBGINDENT(), ""); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  171|      0|#define __DBGINDENT()      debug_indent_get()
  |  |  |  |  ------------------
  |  |  |  |  197|      0|        __DBGMSGHEX(("dumpx_" token,buf,len)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  169|      0|#define __DBGMSGHEX(x)     debugmsg_hex x
  |  |  |  |  ------------------
  |  |  |  |  198|      0|        if (debug_is_token_registered("dumpv" token) == SNMPERR_SUCCESS || \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (198:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  199|      0|            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|      0|            debugmsg("dumpx_" token,"\n"); \
  |  |  |  |  201|      0|        } else { \
  |  |  |  |  202|      0|            debugmsg("dumpx_" token,"  "); \
  |  |  |  |  203|      0|        } \
  |  |  |  |  204|      0|        debugmsg("dumpv" token, "dumpv_%s:%*s", token, __DBGINDENT(), "");
  |  |  |  |  ------------------
  |  |  |  |  |  |  171|      0|#define __DBGINDENT()      debug_indent_get()
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (83:60): [Folded, False: 4]
  |  |  ------------------
  ------------------
 1477|       |
 1478|       |    /*
 1479|       |     * Handle invalid object identifier encodings of the form 06 00 robustly 
 1480|       |     */
 1481|      4|    if (asn_length == 0)
  ------------------
  |  Branch (1481:9): [True: 0, False: 4]
  ------------------
 1482|      0|        objid[0] = objid[1] = 0;
 1483|       |
 1484|      4|    length = asn_length;
 1485|      4|    (*objidlength)--;           /* account for expansion of first byte */
 1486|       |
 1487|     20|    while (length > 0 && (*objidlength)-- > 0) {
  ------------------
  |  Branch (1487:12): [True: 17, False: 3]
  |  Branch (1487:26): [True: 17, False: 0]
  ------------------
 1488|     17|        subidentifier = 0;
 1489|     28|        do {                    /* shift and add in low order 7 bits */
 1490|     28|            if (subidentifier > (MAX_SUBID >> 7)) {
  ------------------
  |  |   18|     28|#define MAX_SUBID   0xFFFFFFFFUL
  ------------------
  |  Branch (1490:17): [True: 0, False: 28]
  ------------------
 1491|      0|                ERROR_MSG("subidentifier too large / overflow");
  ------------------
  |  |  188|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 1492|      0|                return NULL;
 1493|      0|            }
 1494|     28|            subidentifier =
 1495|     28|                (subidentifier << 7) + (*(u_char *) bufp & ~ASN_BIT8);
  ------------------
  |  |  100|     28|#define ASN_BIT8	    0x80U
  ------------------
 1496|     28|            length--;
 1497|     28|        } while ((*(u_char *) bufp++ & ASN_BIT8) && (length > 0));        /* last byte has high bit clear */
  ------------------
  |  |  100|     28|#define ASN_BIT8	    0x80U
  ------------------
  |  Branch (1497:18): [True: 12, False: 16]
  |  Branch (1497:53): [True: 11, False: 1]
  ------------------
 1498|       |
 1499|     17|	if (length == 0) {
  ------------------
  |  Branch (1499:6): [True: 4, False: 13]
  ------------------
 1500|      4|            u_char *last_byte = bufp - 1;
 1501|      4|            if (*last_byte & ASN_BIT8) {
  ------------------
  |  |  100|      4|#define ASN_BIT8	    0x80U
  ------------------
  |  Branch (1501:17): [True: 1, False: 3]
  ------------------
 1502|       |                /* last byte has high bit set -> wrong BER encoded OID */
 1503|      1|                ERROR_MSG("subidentifier syntax error");
  ------------------
  |  |  188|      1|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 1504|      1|                return NULL;
 1505|      1|            }
 1506|      4|        }
 1507|     16|        if (subidentifier > MAX_SUBID) {
  ------------------
  |  |   18|     16|#define MAX_SUBID   0xFFFFFFFFUL
  ------------------
  |  Branch (1507:13): [True: 0, False: 16]
  ------------------
 1508|      0|            ERROR_MSG("subidentifier too large");
  ------------------
  |  |  188|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 1509|      0|            return NULL;
 1510|      0|        }
 1511|     16|        *oidp++ = (oid) subidentifier;
 1512|     16|    }
 1513|       |
 1514|      3|    if (length || oidp < objid + 1) {
  ------------------
  |  Branch (1514:9): [True: 0, False: 3]
  |  Branch (1514:19): [True: 0, False: 3]
  ------------------
 1515|      0|        ERROR_MSG("OID length exceeds buffer size");
  ------------------
  |  |  188|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 1516|      0|        *objidlength = original_length;
 1517|      0|        return NULL;
 1518|      0|    }
 1519|       |
 1520|       |    /*
 1521|       |     * The first two subidentifiers are encoded into the first component
 1522|       |     * with the value (X * 40) + Y, where:
 1523|       |     *  X is the value of the first subidentifier.
 1524|       |     *  Y is the value of the second subidentifier.
 1525|       |     */
 1526|      3|    subidentifier = oidp - objid >= 2 ? objid[1] : 0;
  ------------------
  |  Branch (1526:21): [True: 3, False: 0]
  ------------------
 1527|      3|    if (subidentifier == 0x2B) {
  ------------------
  |  Branch (1527:9): [True: 0, False: 3]
  ------------------
 1528|      0|        objid[0] = 1;
 1529|      0|        objid[1] = 3;
 1530|      3|    } else {
 1531|      3|        if (subidentifier < 40) {
  ------------------
  |  Branch (1531:13): [True: 1, False: 2]
  ------------------
 1532|      1|            objid[0] = 0;
 1533|      1|            objid[1] = subidentifier;
 1534|      2|        } else if (subidentifier < 80) {
  ------------------
  |  Branch (1534:20): [True: 0, False: 2]
  ------------------
 1535|      0|            objid[0] = 1;
 1536|      0|            objid[1] = subidentifier - 40;
 1537|      2|        } else {
 1538|      2|            objid[0] = 2;
 1539|      2|            objid[1] = subidentifier - 80;
 1540|      2|        }
 1541|      3|    }
 1542|       |
 1543|      3|    *objidlength = (int) (oidp - objid);
 1544|       |
 1545|      3|    DEBUGMSG(("dumpv_recv", "  ObjID: "));
  ------------------
  |  |   61|      3|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  144|      3|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 3]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (61:67): [Folded, False: 3]
  |  |  ------------------
  ------------------
 1546|      3|    DEBUGMSGOID(("dumpv_recv", objid, *objidlength));
  ------------------
  |  |   67|      3|#define DEBUGMSGOID(x)     do {if (_DBG_IF_) {__DBGMSGOID(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      3|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 3]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGOID(x)     do {if (_DBG_IF_) {__DBGMSGOID(x);} }while(0)
  |  |  ------------------
  |  |  |  |  165|      0|#define __DBGMSGOID(x)     debugmsg_oid x
  |  |  ------------------
  |  |  |  Branch (67:71): [Folded, False: 3]
  |  |  ------------------
  ------------------
 1547|      3|    DEBUGMSG(("dumpv_recv", "\n"));
  ------------------
  |  |   61|      3|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  144|      3|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 3]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (61:67): [Folded, False: 3]
  |  |  ------------------
  ------------------
 1548|      3|    return bufp;
 1549|      3|}
asn1.c:_asn_short_err:
  299|     84|{
  300|     84|    char            ebuf[128];
  301|       |
  302|     84|    snprintf(ebuf, sizeof(ebuf), "%s length %lu too short: need %lu", str,
  303|     84|	    (unsigned long)wrongsize, (unsigned long)rightsize);
  304|     84|    ERROR_MSG(ebuf);
  ------------------
  |  |  188|     84|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
  305|     84|}
asn1.c:_asn_type_err:
  261|     12|{
  262|     12|    char            ebuf[128];
  263|       |
  264|     12|    snprintf(ebuf, sizeof(ebuf), "%s type %d", str, wrongtype);
  265|     12|    ebuf[ sizeof(ebuf)-1 ] = 0;
  266|     12|    ERROR_MSG(ebuf);
  ------------------
  |  |  188|     12|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
  267|     12|}
asn1.c:_asn_length_err:
  280|      5|{
  281|      5|    char            ebuf[128];
  282|       |
  283|      5|    snprintf(ebuf, sizeof(ebuf),
  284|      5|            "%s length %lu too large: exceeds %lu", str,
  285|      5|	    (unsigned long)wrongsize, (unsigned long)rightsize);
  286|      5|    ERROR_MSG(ebuf);
  ------------------
  |  |  188|      5|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
  287|      5|}

init_callbacks:
  198|     59|{
  199|       |    /*
  200|       |     * (poses a problem if you put init_callbacks() inside of
  201|       |     * init_snmp() and then want the app to register a callback before
  202|       |     * init_snmp() is called in the first place.  -- Wes 
  203|       |     */
  204|     59|    if (0 == _callback_need_init)
  ------------------
  |  Branch (204:9): [True: 58, False: 1]
  ------------------
  205|     58|        return;
  206|       |    
  207|      1|    _callback_need_init = 0;
  208|       |    
  209|      1|    memset(thecallbacks, 0, sizeof(thecallbacks)); 
  210|      1|#ifdef LOCK_PER_CALLBACK_SUBID
  211|      1|    memset(_locks, 0, sizeof(_locks));
  212|       |#else
  213|       |    _lock = 0;
  214|       |#endif
  215|       |    
  216|      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]
  |  |  ------------------
  ------------------
  217|      1|}
snmp_register_callback:
  258|    638|{
  259|    638|    return netsnmp_register_callback( major, minor, new_callback, arg,
  260|    638|                                      NETSNMP_CALLBACK_DEFAULT_PRIORITY);
  ------------------
  |  |   40|    638|#define NETSNMP_CALLBACK_DEFAULT_PRIORITY       0
  ------------------
  261|    638|}
netsnmp_register_callback:
  280|    638|{
  281|    638|    struct snmp_gen_callback *newscp = NULL, *scp = NULL;
  282|       |
  283|    638|    if (major < 0 || major >= MAX_CALLBACK_IDS ||
  ------------------
  |  |   12|  1.27k|#define MAX_CALLBACK_IDS    2
  ------------------
  |  Branch (283:9): [True: 0, False: 638]
  |  Branch (283:22): [True: 0, False: 638]
  ------------------
  284|    638|        minor < 0 || minor >= MAX_CALLBACK_SUBIDS) {
  ------------------
  |  |   13|    638|#define MAX_CALLBACK_SUBIDS 18
  ------------------
  |  Branch (284:9): [True: 0, False: 638]
  |  Branch (284:22): [True: 0, False: 638]
  ------------------
  285|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  286|      0|    }
  287|       |
  288|    638|    if (_callback_need_init)
  ------------------
  |  Branch (288:9): [True: 1, False: 637]
  ------------------
  289|      1|        init_callbacks();
  290|       |
  291|    638|    _callback_lock(major,minor, "netsnmp_register_callback", 1);
  292|       |    
  293|    638|    if ((newscp = SNMP_MALLOC_STRUCT(snmp_gen_callback)) == NULL) {
  ------------------
  |  |   69|    638|#define SNMP_MALLOC_STRUCT(s)   (struct s *) calloc(1, sizeof(struct s))
  ------------------
  |  Branch (293:9): [True: 0, False: 638]
  ------------------
  294|      0|        _callback_unlock(major,minor);
  295|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  296|    638|    } else {
  297|    638|        struct snmp_gen_callback **prevNext = &(thecallbacks[major][minor]);
  298|       |
  299|    638|        newscp->priority = priority;
  300|    638|        newscp->sc_client_arg = arg;
  301|    638|        newscp->sc_callback = new_callback;
  302|    638|        newscp->next = NULL;
  303|       |
  304|  1.16k|        for (scp = thecallbacks[major][minor]; scp != NULL;
  ------------------
  |  Branch (304:48): [True: 522, False: 638]
  ------------------
  305|    638|             scp = scp->next) {
  306|    522|            if (newscp->priority < scp->priority) {
  ------------------
  |  Branch (306:17): [True: 0, False: 522]
  ------------------
  307|      0|                newscp->next = scp;
  308|      0|                break;
  309|      0|            }
  310|    522|            prevNext = &(scp->next);
  311|    522|        }
  312|       |
  313|    638|        *prevNext = newscp;
  314|       |
  315|    638|        DEBUGMSGTL(("callback", "registered (%d,%d) at %p with priority %d\n",
  ------------------
  |  |   66|    638|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    638|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 638]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 638]
  |  |  ------------------
  ------------------
  316|    638|                    major, minor, newscp, priority));
  317|    638|        _callback_unlock(major,minor);
  318|    638|        return SNMPERR_SUCCESS;
  ------------------
  |  |  184|    638|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  319|    638|    }
  320|    638|}
snmp_call_callbacks:
  341|    406|{
  342|    406|    struct snmp_gen_callback *scp;
  343|    406|    unsigned int    count = 0;
  344|       |    
  345|    406|    if (major < 0 || major >= MAX_CALLBACK_IDS ||
  ------------------
  |  |   12|    812|#define MAX_CALLBACK_IDS    2
  ------------------
  |  Branch (345:9): [True: 0, False: 406]
  |  Branch (345:22): [True: 0, False: 406]
  ------------------
  346|    406|        minor < 0 || minor >= MAX_CALLBACK_SUBIDS) {
  ------------------
  |  |   13|    406|#define MAX_CALLBACK_SUBIDS 18
  ------------------
  |  Branch (346:9): [True: 0, False: 406]
  |  Branch (346:22): [True: 0, False: 406]
  ------------------
  347|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  348|      0|    }
  349|       |    
  350|    406|    if (_callback_need_init)
  ------------------
  |  Branch (350:9): [True: 0, False: 406]
  ------------------
  351|      0|        init_callbacks();
  352|       |
  353|    406|#ifdef LOCK_PER_CALLBACK_SUBID
  354|    406|    _callback_lock(major,minor,"snmp_call_callbacks", 1);
  355|       |#else
  356|       |    /*
  357|       |     * Notes:
  358|       |     * - this gets hit the first time a trap is sent after a new trap
  359|       |     *   destination has been added (session init cb during send trap cb)
  360|       |     */
  361|       |    _callback_lock(major,minor, NULL, 0);
  362|       |#endif
  363|       |
  364|    406|    DEBUGMSGTL(("callback", "START calling callbacks for maj=%d min=%d\n",
  ------------------
  |  |   66|    406|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    406|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 406]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 406]
  |  |  ------------------
  ------------------
  365|    406|                major, minor));
  366|       |
  367|       |    /*
  368|       |     * for each registered callback of type major and minor 
  369|       |     */
  370|  1.04k|    for (scp = thecallbacks[major][minor]; scp != NULL; scp = scp->next) {
  ------------------
  |  Branch (370:44): [True: 638, False: 406]
  ------------------
  371|       |
  372|       |        /*
  373|       |         * skip unregistered callbacks
  374|       |         */
  375|    638|        if(NULL == scp->sc_callback)
  ------------------
  |  Branch (375:12): [True: 0, False: 638]
  ------------------
  376|      0|            continue;
  377|       |
  378|    638|        DEBUGMSGTL(("callback", "calling a callback for maj=%d min=%d\n",
  ------------------
  |  |   66|    638|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    638|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 638]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 638]
  |  |  ------------------
  ------------------
  379|    638|                    major, minor));
  380|       |
  381|       |        /*
  382|       |         * call them 
  383|       |         */
  384|    638|        (*(scp->sc_callback)) (major, minor, caller_arg,
  385|    638|                               scp->sc_client_arg);
  386|    638|        count++;
  387|    638|    }
  388|       |
  389|    406|    DEBUGMSGTL(("callback",
  ------------------
  |  |   66|    406|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    406|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 406]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 406]
  |  |  ------------------
  ------------------
  390|    406|                "END calling callbacks for maj=%d min=%d (%d called)\n",
  391|    406|                major, minor, count));
  392|       |
  393|    406|    _callback_unlock(major,minor);
  394|    406|    return SNMPERR_SUCCESS;
  ------------------
  |  |  184|    406|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  395|    406|}
netsnmp_callback_clear_client_arg:
  521|    116|{
  522|    116|    struct snmp_gen_callback *scp = NULL;
  523|    116|    int rc = 0;
  524|       |
  525|    116|    if (i < 0 || i >= MAX_CALLBACK_IDS ||
  ------------------
  |  |   12|    232|#define MAX_CALLBACK_IDS    2
  ------------------
  |  Branch (525:9): [True: 0, False: 116]
  |  Branch (525:18): [True: 0, False: 116]
  ------------------
  526|    116|        j < 0 || j >= MAX_CALLBACK_SUBIDS)
  ------------------
  |  |   13|    116|#define MAX_CALLBACK_SUBIDS 18
  ------------------
  |  Branch (526:9): [True: 0, False: 116]
  |  Branch (526:18): [True: 0, False: 116]
  ------------------
  527|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  528|       |
  529|       |    /*
  530|       |     * don't init i and j before loop, since the caller specified
  531|       |     * the starting point explicitly. But *after* the i loop has
  532|       |     * finished executing once, init j to 0 for the next pass
  533|       |     * through the subids.
  534|       |     */
  535|    348|    for (; i < MAX_CALLBACK_IDS; i++,j=0) {
  ------------------
  |  |   12|    348|#define MAX_CALLBACK_IDS    2
  ------------------
  |  Branch (535:12): [True: 232, False: 116]
  ------------------
  536|  4.35k|        for (; j < MAX_CALLBACK_SUBIDS; j++) {
  ------------------
  |  |   13|  4.35k|#define MAX_CALLBACK_SUBIDS 18
  ------------------
  |  Branch (536:16): [True: 4.11k, False: 232]
  ------------------
  537|  4.11k|            scp = thecallbacks[i][j]; 
  538|  5.16k|            while (scp != NULL) {
  ------------------
  |  Branch (538:20): [True: 1.04k, False: 4.11k]
  ------------------
  539|  1.04k|                if ((NULL != scp->sc_callback) &&
  ------------------
  |  Branch (539:21): [True: 1.04k, False: 0]
  ------------------
  540|  1.04k|                    (scp->sc_client_arg != NULL) &&
  ------------------
  |  Branch (540:21): [True: 58, False: 986]
  ------------------
  541|     58|                    (scp->sc_client_arg == ptr)) {
  ------------------
  |  Branch (541:21): [True: 0, False: 58]
  ------------------
  542|      0|                    DEBUGMSGTL(("9:callback", "  clearing %p at [%d,%d]\n", ptr, i, j));
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
  543|      0|                    scp->sc_client_arg = NULL;
  544|      0|                    ++rc;
  545|      0|                }
  546|  1.04k|                scp = scp->next;
  547|  1.04k|            }
  548|  4.11k|        }
  549|    232|    }
  550|       |
  551|    116|    if (0 != rc) {
  ------------------
  |  Branch (551:9): [True: 0, False: 116]
  ------------------
  552|      0|        DEBUGMSGTL(("callback", "removed %d client args\n", rc));
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
  553|      0|    }
  554|       |
  555|    116|    return rc;
  556|    116|}
clear_callback:
  560|     58|{
  561|     58|    unsigned int i = 0, j = 0;
  562|     58|    struct snmp_gen_callback *scp = NULL;
  563|       |
  564|     58|    if (_callback_need_init)
  ------------------
  |  Branch (564:9): [True: 0, False: 58]
  ------------------
  565|      0|        init_callbacks();
  566|       |
  567|     58|    DEBUGMSGTL(("callback", "clear callback\n"));
  ------------------
  |  |   66|     58|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     58|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 58]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 58]
  |  |  ------------------
  ------------------
  568|    174|    for (i = 0; i < MAX_CALLBACK_IDS; i++) {
  ------------------
  |  |   12|    174|#define MAX_CALLBACK_IDS    2
  ------------------
  |  Branch (568:17): [True: 116, False: 58]
  ------------------
  569|  2.20k|        for (j = 0; j < MAX_CALLBACK_SUBIDS; j++) {
  ------------------
  |  |   13|  2.20k|#define MAX_CALLBACK_SUBIDS 18
  ------------------
  |  Branch (569:21): [True: 2.08k, False: 116]
  ------------------
  570|  2.08k|            _callback_lock(i,j, "clear_callback", 1);
  571|  2.08k|            scp = thecallbacks[i][j];
  572|  2.72k|            while (scp != NULL) {
  ------------------
  |  Branch (572:20): [True: 638, False: 2.08k]
  ------------------
  573|    638|                thecallbacks[i][j] = scp->next;
  574|       |                /*
  575|       |                 * if there is a client arg, check for duplicates
  576|       |                 * and then free it.
  577|       |                 */
  578|    638|                if ((NULL != scp->sc_callback) &&
  ------------------
  |  Branch (578:21): [True: 638, False: 0]
  ------------------
  579|    638|                    (scp->sc_client_arg != NULL)) {
  ------------------
  |  Branch (579:21): [True: 58, False: 580]
  ------------------
  580|     58|                    void *tmp_arg;
  581|       |                    /*
  582|       |                     * save the client arg, then set it to null so that it
  583|       |                     * won't look like a duplicate, then check for duplicates
  584|       |                     * starting at the current i,j (earlier dups should have
  585|       |                     * already been found) and free the pointer.
  586|       |                     */
  587|     58|                    tmp_arg = scp->sc_client_arg;
  588|     58|                    scp->sc_client_arg = NULL;
  589|     58|                    DEBUGMSGTL(("9:callback", "  freeing %p at [%d,%d]\n", tmp_arg, i, j));
  ------------------
  |  |   66|     58|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     58|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 58]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 58]
  |  |  ------------------
  ------------------
  590|     58|                    (void)netsnmp_callback_clear_client_arg(tmp_arg, i, j);
  591|     58|                    free(tmp_arg);
  592|     58|                }
  593|       |                SNMP_FREE(scp);
  ------------------
  |  |   62|    638|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 638, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 638]
  |  |  ------------------
  ------------------
  594|    638|                scp = thecallbacks[i][j];
  595|    638|            }
  596|  2.08k|            _callback_unlock(i,j);
  597|  2.08k|        }
  598|    116|    }
  599|     58|}
callback.c:_callback_lock:
  119|  3.13k|{
  120|  3.13k|    int lock_holded=0;
  121|  3.13k|    NETSNMP_SELECT_TIMEVAL lock_time;
  ------------------
  |  | 1777|  3.13k|#define NETSNMP_SELECT_TIMEVAL struct timeval
  ------------------
  122|       |
  123|       |#ifdef NETSNMP_PARANOID_LEVEL_HIGH
  124|       |    if (major < 0 || major >= MAX_CALLBACK_IDS ||
  125|       |        minor < 0 || minor >= MAX_CALLBACK_SUBIDS) {
  126|       |        netsnmp_assert("bad callback id");
  127|       |        return 1;
  128|       |    }
  129|       |#endif
  130|       |    
  131|  3.13k|#ifdef CALLBACK_NAME_LOGGING
  132|  3.13k|    DEBUGMSGTL(("9:callback:lock", "locked (%s,%s)\n",
  ------------------
  |  |   66|  3.13k|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|  3.13k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 3.13k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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:52): [True: 0, False: 0]
  |  |  |  |  |  Branch (164:64): [True: 0, False: 0]
  |  |  |  |  |  Branch (164:64): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 3.13k]
  |  |  ------------------
  ------------------
  133|  3.13k|                types[major], (SNMP_CALLBACK_LIBRARY == major) ?
  134|  3.13k|                SNMP_STRORNULL(lib[minor]) : "null"));
  135|  3.13k|#endif
  136|  3.13k|    while (CALLBACK_LOCK_COUNT(major,minor) >= 1 && ++lock_holded < 100) {
  ------------------
  |  |  109|  3.13k|#define CALLBACK_LOCK_COUNT(maj,min) _locks[maj][min]
  ------------------
  |  Branch (136:12): [True: 0, False: 3.13k]
  |  Branch (136:53): [True: 0, False: 0]
  ------------------
  137|      0|	lock_time.tv_sec = 0;
  138|      0|	lock_time.tv_usec = 1000;
  139|      0|	select(0, NULL, NULL, NULL, &lock_time);
  140|      0|    }
  141|       |
  142|  3.13k|    if(lock_holded >= 100) {
  ------------------
  |  Branch (142:8): [True: 0, False: 3.13k]
  ------------------
  143|      0|        if (NULL != warn)
  ------------------
  |  Branch (143:13): [True: 0, False: 0]
  ------------------
  144|      0|            snmp_log(LOG_WARNING,
  145|      0|                     "lock in _callback_lock sleeps more than 100 milliseconds in %s\n", warn);
  146|      0|        if (do_assert)
  ------------------
  |  Branch (146:13): [True: 0, False: 0]
  ------------------
  147|      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
  |  |  |  |  ------------------
  |  |  |  |  |  | 1727|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|      0|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded, False: 0]
  |  |  ------------------
  ------------------
  148|       |        
  149|      0|        return 1;
  150|      0|    }
  151|       |
  152|  3.13k|    CALLBACK_LOCK(major,minor);
  ------------------
  |  |  107|  3.13k|#define CALLBACK_LOCK(maj,min) ++_locks[maj][min]
  ------------------
  153|  3.13k|    return 0;
  154|  3.13k|}
callback.c:_callback_unlock:
  158|  3.13k|{
  159|       |#ifdef NETSNMP_PARANOID_LEVEL_HIGH
  160|       |    if (major < 0 || major >= MAX_CALLBACK_IDS ||
  161|       |        minor < 0 || minor >= MAX_CALLBACK_SUBIDS) {
  162|       |        netsnmp_assert("bad callback id");
  163|       |        return;
  164|       |    }
  165|       |#endif
  166|       |    
  167|  3.13k|    CALLBACK_UNLOCK(major,minor);
  ------------------
  |  |  108|  3.13k|#define CALLBACK_UNLOCK(maj,min) --_locks[maj][min]
  ------------------
  168|       |
  169|  3.13k|    if (CALLBACK_LOCK_COUNT(major,minor) == 0) {
  ------------------
  |  |  109|  3.13k|#define CALLBACK_LOCK_COUNT(maj,min) _locks[maj][min]
  ------------------
  |  Branch (169:9): [True: 3.13k, False: 0]
  ------------------
  170|  3.13k|        struct snmp_gen_callback *scp, **prevNext;
  171|  3.13k|        scp = thecallbacks[major][minor];
  172|  3.13k|        prevNext = &(thecallbacks[major][minor]);
  173|  4.93k|        while (scp != NULL) {
  ------------------
  |  Branch (173:16): [True: 1.79k, False: 3.13k]
  ------------------
  174|  1.79k|            if (scp->sc_callback == NULL) {
  ------------------
  |  Branch (174:17): [True: 0, False: 1.79k]
  ------------------
  175|      0|                *prevNext = scp->next;
  176|      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]
  |  |  ------------------
  ------------------
  177|      0|                scp = *prevNext;
  178|  1.79k|            } else {
  179|  1.79k|                prevNext = &(scp->next);
  180|  1.79k|                scp = scp->next;
  181|  1.79k|            }
  182|  1.79k|        }
  183|  3.13k|    }
  184|       |
  185|  3.13k|#ifdef CALLBACK_NAME_LOGGING
  186|  3.13k|    DEBUGMSGTL(("9:callback:lock", "unlocked (%s,%s)\n",
  ------------------
  |  |   66|  3.13k|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|  3.13k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 3.13k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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:52): [True: 0, False: 0]
  |  |  |  |  |  Branch (164:64): [True: 0, False: 0]
  |  |  |  |  |  Branch (164:64): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 3.13k]
  |  |  ------------------
  ------------------
  187|  3.13k|                types[major], (SNMP_CALLBACK_LIBRARY == major) ?
  188|  3.13k|                SNMP_STRORNULL(lib[minor]) : "null"));
  189|  3.13k|#endif
  190|  3.13k|}

_netsnmp_release_trustcerts:
  175|    174|{
  176|    174|    if (NULL != _trusted_certs) {
  ------------------
  |  Branch (176:9): [True: 58, False: 116]
  ------------------
  177|     58|        CONTAINER_FREE_ALL(_trusted_certs, NULL);
  178|     58|        CONTAINER_FREE(_trusted_certs);
  179|       |        _trusted_certs = NULL;
  180|     58|    }
  181|    174|}
_setup_trusted_certs:
  185|     58|{
  186|     58|    _trusted_certs = netsnmp_container_find("trusted_certs:fifo");
  187|     58|    if (NULL == _trusted_certs) {
  ------------------
  |  Branch (187:9): [True: 0, False: 58]
  ------------------
  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|     58|    _trusted_certs->container_name = strdup("trusted certificates");
  193|     58|    _trusted_certs->compare = netsnmp_str_compare;
  194|     58|}
netsnmp_certs_init:
  209|     58|{
  210|     58|    const char *trustCert_help = TRUSTCERT_CONFIG_TOKEN
  ------------------
  |  |  140|     58|#define TRUSTCERT_CONFIG_TOKEN "trustCert"
  ------------------
  211|     58|        " FINGERPRINT|FILENAME";
  212|       |
  213|     58|    register_config_handler("snmp", TRUSTCERT_CONFIG_TOKEN,
  ------------------
  |  |  140|     58|#define TRUSTCERT_CONFIG_TOKEN "trustCert"
  ------------------
  214|     58|                            _parse_trustcert, _netsnmp_release_trustcerts,
  215|     58|                            trustCert_help);
  216|     58|    _setup_containers();
  217|       |
  218|       |    /** add certificate type mapping */
  219|     58|    se_add_pair_to_slist("cert_types", strdup("pem"), NS_CERT_TYPE_PEM);
  220|     58|    se_add_pair_to_slist("cert_types", strdup("crt"), NS_CERT_TYPE_DER);
  221|     58|    se_add_pair_to_slist("cert_types", strdup("cer"), NS_CERT_TYPE_DER);
  222|     58|    se_add_pair_to_slist("cert_types", strdup("cert"), NS_CERT_TYPE_DER);
  223|     58|    se_add_pair_to_slist("cert_types", strdup("der"), NS_CERT_TYPE_DER);
  224|     58|    se_add_pair_to_slist("cert_types", strdup("key"), NS_CERT_TYPE_KEY);
  225|     58|    se_add_pair_to_slist("cert_types", strdup("private"), NS_CERT_TYPE_KEY);
  226|       |
  227|       |    /** hash algs */
  228|     58|    se_add_pair_to_slist("cert_hash_alg", strdup("sha1"), NS_HASH_SHA1);
  ------------------
  |  |   85|     58|#define NS_HASH_SHA1        2
  ------------------
  229|     58|    se_add_pair_to_slist("cert_hash_alg", strdup("md5"), NS_HASH_MD5);
  ------------------
  |  |   84|     58|#define NS_HASH_MD5         1
  ------------------
  230|     58|    se_add_pair_to_slist("cert_hash_alg", strdup("sha224"), NS_HASH_SHA224);
  ------------------
  |  |   86|     58|#define NS_HASH_SHA224      3
  ------------------
  231|     58|    se_add_pair_to_slist("cert_hash_alg", strdup("sha256"), NS_HASH_SHA256);
  ------------------
  |  |   87|     58|#define NS_HASH_SHA256      4
  ------------------
  232|     58|    se_add_pair_to_slist("cert_hash_alg", strdup("sha384"), NS_HASH_SHA384);
  ------------------
  |  |   88|     58|#define NS_HASH_SHA384      5
  ------------------
  233|     58|    se_add_pair_to_slist("cert_hash_alg", strdup("sha512"), NS_HASH_SHA512);
  ------------------
  |  |   89|     58|#define NS_HASH_SHA512      6
  ------------------
  234|       |
  235|       |    /** map types */
  236|     58|    se_add_pair_to_slist("cert_map_type", strdup("cn"),
  237|     58|                         TSNM_tlstmCertCommonName);
  ------------------
  |  |  129|     58|#define TSNM_tlstmCertCommonName                6
  ------------------
  238|     58|    se_add_pair_to_slist("cert_map_type", strdup("ip"),
  239|     58|                         TSNM_tlstmCertSANIpAddress);
  ------------------
  |  |  127|     58|#define TSNM_tlstmCertSANIpAddress              4
  ------------------
  240|     58|    se_add_pair_to_slist("cert_map_type", strdup("rfc822"),
  241|     58|                         TSNM_tlstmCertSANRFC822Name);
  ------------------
  |  |  125|     58|#define TSNM_tlstmCertSANRFC822Name             2
  ------------------
  242|     58|    se_add_pair_to_slist("cert_map_type", strdup("dns"),
  243|     58|                         TSNM_tlstmCertSANDNSName);
  ------------------
  |  |  126|     58|#define TSNM_tlstmCertSANDNSName                3
  ------------------
  244|     58|    se_add_pair_to_slist("cert_map_type", strdup("any"), TSNM_tlstmCertSANAny);
  ------------------
  |  |  128|     58|#define TSNM_tlstmCertSANAny                    5
  ------------------
  245|     58|    se_add_pair_to_slist("cert_map_type", strdup("sn"),
  246|     58|                         TSNM_tlstmCertSpecified);
  ------------------
  |  |  124|     58|#define TSNM_tlstmCertSpecified                 1
  ------------------
  247|       |
  248|     58|}
netsnmp_certs_shutdown:
  252|     58|{
  253|     58|    netsnmp_container ***c, **containers[] = {
  254|     58|        &_tlstmParams, &_tlstmAddr, &_maps, &_certs, &_keys, NULL
  255|     58|    };
  256|       |
  257|     58|    DEBUGMSGT(("cert:util:shutdown","shutdown\n"));
  ------------------
  |  |   62|     58|#define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     58|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 58]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 58]
  |  |  ------------------
  ------------------
  258|       |
  259|    348|    for (c = containers; *c; c++) {
  ------------------
  |  Branch (259:26): [True: 290, False: 58]
  ------------------
  260|    290|        if (!**c)
  ------------------
  |  Branch (260:13): [True: 174, False: 116]
  ------------------
  261|    174|            continue;
  262|    116|        CONTAINER_FREE_ALL(**c, NULL);
  263|    116|        CONTAINER_FREE(**c);
  264|       |        **c = NULL;
  265|    116|    }
  266|     58|    _netsnmp_release_trustcerts();
  267|     58|}
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: 0, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 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: 0, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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]
  |  |  ------------------
  ------------------
  306|      0|        itr = CONTAINER_ITERATOR(_certs);
  ------------------
  |  |  404|      0|#define CONTAINER_ITERATOR(x)       (x)->get_iterator(x)
  ------------------
  307|      0|        if (NULL == itr) {
  ------------------
  |  Branch (307:13): [True: 0, False: 0]
  ------------------
  308|      0|            snmp_log(LOG_ERR, "could not get iterator for certs\n");
  309|      0|            netsnmp_certs_shutdown();
  310|      0|            return;
  311|      0|        }
  312|      0|        cert = ITERATOR_FIRST(itr);
  ------------------
  |  |  546|      0|#define ITERATOR_FIRST(x)  x->first(x)
  ------------------
  313|      0|        for( ; cert; cert = ITERATOR_NEXT(itr)) {
  ------------------
  |  |  547|      0|#define ITERATOR_NEXT(x)   x->next(x)
  ------------------
  |  Branch (313:16): [True: 0, False: 0]
  ------------------
  314|      0|            netsnmp_cert_load_x509(cert);
  315|      0|        }
  316|      0|        ITERATOR_RELEASE(itr);
  ------------------
  |  |  550|      0|#define ITERATOR_RELEASE(x) do { x->release(x); x = NULL; } while(0)
  |  |  ------------------
  |  |  |  Branch (550:67): [Folded, False: 0]
  |  |  ------------------
  ------------------
  317|      0|        DEBUGMSGT(("cert:dump",
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
  318|      0|                   "-------------------- Certificates -----------------\n"));
  319|      0|        netsnmp_cert_dump_all();
  320|      0|        DEBUGMSGT(("cert:dump",
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
  321|      0|                   "------------------------ End ----------------------\n"));
  322|      0|    }
  323|      1|}
cert_util.c:_setup_containers:
  353|     58|{
  354|     58|    netsnmp_container *additional_keys;
  355|       |
  356|     58|    int rc;
  357|       |
  358|     58|    _certs = _get_cert_container("netsnmp certificates");
  359|     58|    if (NULL == _certs)
  ------------------
  |  Branch (359:9): [True: 0, False: 58]
  ------------------
  360|      0|        return;
  361|       |
  362|       |    /** additional keys: common name */
  363|     58|    additional_keys = netsnmp_container_find("certs_cn:binary_array");
  364|     58|    if (NULL == additional_keys) {
  ------------------
  |  Branch (364:9): [True: 0, False: 58]
  ------------------
  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|     58|    additional_keys->container_name = strdup("certs_cn");
  370|     58|    additional_keys->free_item = NULL;
  371|     58|    additional_keys->compare = _cert_cn_compare;
  372|     58|    CONTAINER_SET_OPTIONS(additional_keys, CONTAINER_KEY_ALLOW_DUPLICATES, rc);
  ------------------
  |  |  375|     58|#define CONTAINER_SET_OPTIONS(x,o,rc)  do {                             \
  |  |  376|     58|        if (NULL==(x)->options)                                         \
  |  |  ------------------
  |  |  |  Branch (376:13): [True: 0, False: 58]
  |  |  ------------------
  |  |  377|     58|            rc = -1;                                                    \
  |  |  378|     58|        else {                                                          \
  |  |  379|     58|            rc = (x)->options(x, 1, o);                                 \
  |  |  380|     58|            if (rc != -1 )                                              \
  |  |  ------------------
  |  |  |  Branch (380:17): [True: 58, False: 0]
  |  |  ------------------
  |  |  381|     58|                (x)->flags |= o;                                        \
  |  |  382|     58|        }                                                               \
  |  |  383|     58|    } while(0)
  |  |  ------------------
  |  |  |  Branch (383:13): [Folded, False: 58]
  |  |  ------------------
  ------------------
  373|     58|    netsnmp_container_add_index(_certs, additional_keys);
  374|       |
  375|       |    /** additional keys: subject name */
  376|     58|    additional_keys = netsnmp_container_find("certs_sn:binary_array");
  377|     58|    if (NULL == additional_keys) {
  ------------------
  |  Branch (377:9): [True: 0, False: 58]
  ------------------
  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|     58|    additional_keys->container_name = strdup("certs_sn");
  383|     58|    additional_keys->free_item = NULL;
  384|     58|    additional_keys->compare = _cert_sn_compare;
  385|     58|    additional_keys->ncompare = _cert_sn_ncompare;
  386|     58|    CONTAINER_SET_OPTIONS(additional_keys, CONTAINER_KEY_ALLOW_DUPLICATES, rc);
  ------------------
  |  |  375|     58|#define CONTAINER_SET_OPTIONS(x,o,rc)  do {                             \
  |  |  376|     58|        if (NULL==(x)->options)                                         \
  |  |  ------------------
  |  |  |  Branch (376:13): [True: 0, False: 58]
  |  |  ------------------
  |  |  377|     58|            rc = -1;                                                    \
  |  |  378|     58|        else {                                                          \
  |  |  379|     58|            rc = (x)->options(x, 1, o);                                 \
  |  |  380|     58|            if (rc != -1 )                                              \
  |  |  ------------------
  |  |  |  Branch (380:17): [True: 58, False: 0]
  |  |  ------------------
  |  |  381|     58|                (x)->flags |= o;                                        \
  |  |  382|     58|        }                                                               \
  |  |  383|     58|    } while(0)
  |  |  ------------------
  |  |  |  Branch (383:13): [Folded, False: 58]
  |  |  ------------------
  ------------------
  387|     58|    netsnmp_container_add_index(_certs, additional_keys);
  388|       |
  389|       |    /** additional keys: file name */
  390|     58|    additional_keys = netsnmp_container_find("certs_fn:binary_array");
  391|     58|    if (NULL == additional_keys) {
  ------------------
  |  Branch (391:9): [True: 0, False: 58]
  ------------------
  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|     58|    additional_keys->container_name = strdup("certs_fn");
  397|     58|    additional_keys->free_item = NULL;
  398|     58|    additional_keys->compare = _cert_fn_compare;
  399|     58|    additional_keys->ncompare = _cert_fn_ncompare;
  400|     58|    CONTAINER_SET_OPTIONS(additional_keys, CONTAINER_KEY_ALLOW_DUPLICATES, rc);
  ------------------
  |  |  375|     58|#define CONTAINER_SET_OPTIONS(x,o,rc)  do {                             \
  |  |  376|     58|        if (NULL==(x)->options)                                         \
  |  |  ------------------
  |  |  |  Branch (376:13): [True: 0, False: 58]
  |  |  ------------------
  |  |  377|     58|            rc = -1;                                                    \
  |  |  378|     58|        else {                                                          \
  |  |  379|     58|            rc = (x)->options(x, 1, o);                                 \
  |  |  380|     58|            if (rc != -1 )                                              \
  |  |  ------------------
  |  |  |  Branch (380:17): [True: 58, False: 0]
  |  |  ------------------
  |  |  381|     58|                (x)->flags |= o;                                        \
  |  |  382|     58|        }                                                               \
  |  |  383|     58|    } while(0)
  |  |  ------------------
  |  |  |  Branch (383:13): [Folded, False: 58]
  |  |  ------------------
  ------------------
  401|     58|    netsnmp_container_add_index(_certs, additional_keys);
  402|       |
  403|     58|    _keys = netsnmp_container_find("cert_keys:binary_array");
  404|     58|    if (NULL == _keys) {
  ------------------
  |  Branch (404:9): [True: 0, False: 58]
  ------------------
  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|     58|    _keys->container_name = strdup("netsnmp certificate keys");
  410|     58|    _keys->free_item = _key_free;
  411|     58|    _keys->compare = _cert_fn_compare;
  412|       |
  413|     58|    _setup_trusted_certs();
  414|     58|}
cert_util.c:_get_cert_container:
  332|     58|{
  333|     58|    netsnmp_container *c;
  334|       |
  335|     58|    int rc;
  336|       |
  337|     58|    c = netsnmp_container_find("certs:binary_array");
  338|     58|    if (NULL == c) {
  ------------------
  |  Branch (338:9): [True: 0, False: 58]
  ------------------
  339|      0|        snmp_log(LOG_ERR, "could not create container for %s\n", use);
  340|      0|        return NULL;
  341|      0|    }
  342|     58|    c->container_name = strdup(use);
  343|     58|    c->free_item = _cert_free;
  344|     58|    c->compare = _cert_compare;
  345|       |
  346|     58|    CONTAINER_SET_OPTIONS(c, CONTAINER_KEY_ALLOW_DUPLICATES, rc);
  ------------------
  |  |  375|     58|#define CONTAINER_SET_OPTIONS(x,o,rc)  do {                             \
  |  |  376|     58|        if (NULL==(x)->options)                                         \
  |  |  ------------------
  |  |  |  Branch (376:13): [True: 0, False: 58]
  |  |  ------------------
  |  |  377|     58|            rc = -1;                                                    \
  |  |  378|     58|        else {                                                          \
  |  |  379|     58|            rc = (x)->options(x, 1, o);                                 \
  |  |  380|     58|            if (rc != -1 )                                              \
  |  |  ------------------
  |  |  |  Branch (380:17): [True: 58, False: 0]
  |  |  ------------------
  |  |  381|     58|                (x)->flags |= o;                                        \
  |  |  382|     58|        }                                                               \
  |  |  383|     58|    } while(0)
  |  |  ------------------
  |  |  |  Branch (383:13): [Folded, False: 58]
  |  |  ------------------
  ------------------
  347|       |
  348|     58|    return c;
  349|     58|}
cert_util.c:_cert_indexes_load:
 1723|      1|{
 1724|      1|    const char     *confpath;
 1725|      1|    char           *confpath_copy, *dir, *st = NULL;
 1726|      1|    char            certdir[SNMP_MAXPATH];
 1727|      1|    const char     *subdirs[] = { NULL, "ca-certs", "certs", "private", NULL };
 1728|      1|    int             i = 0;
 1729|       |
 1730|       |    /*
 1731|       |     * load indexes from persistent dir
 1732|       |     */
 1733|      1|    _certindexes_load();
 1734|       |
 1735|       |    /*
 1736|       |     * duplicate path building from read_config_files_of_type() in
 1737|       |     * read_config.c. That is, use SNMPCONFPATH environment variable if
 1738|       |     * it is defined, otherwise use configuration directory.
 1739|       |     */
 1740|      1|    confpath = netsnmp_getenv("SNMPCONFPATH");
 1741|      1|    if (NULL == confpath)
  ------------------
  |  Branch (1741:9): [True: 1, False: 0]
  ------------------
 1742|      1|        confpath = get_configuration_directory();
 1743|       |
 1744|      1|    subdirs[0] = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1745|      1|                                       NETSNMP_DS_LIB_CERT_EXTRA_SUBDIR);
  ------------------
  |  |  177|      1|#define NETSNMP_DS_LIB_CERT_EXTRA_SUBDIR 26
  ------------------
 1746|      1|    confpath_copy = strdup(confpath);
 1747|      1|    if (!confpath_copy)
  ------------------
  |  Branch (1747:9): [True: 0, False: 1]
  ------------------
 1748|      0|        return;
 1749|      1|    for ( dir = strtok_r(confpath_copy, ENV_SEPARATOR, &st);
  ------------------
  |  |   67|      1|#define ENV_SEPARATOR ":"
  ------------------
 1750|      5|          dir; dir = strtok_r(NULL, ENV_SEPARATOR, &st)) {
  ------------------
  |  |   67|      4|#define ENV_SEPARATOR ":"
  ------------------
  |  Branch (1750:11): [True: 4, False: 1]
  ------------------
 1751|       |
 1752|      4|        i = (NULL == subdirs[0]) ? 1 : 0;
  ------------------
  |  Branch (1752:13): [True: 4, False: 0]
  ------------------
 1753|     16|        for ( ; subdirs[i] ; ++i ) {
  ------------------
  |  Branch (1753:17): [True: 12, False: 4]
  ------------------
 1754|       |            /** check tls subdir */
 1755|     12|            snprintf(certdir, sizeof(certdir), "%s/tls/%s", dir, subdirs[i]);
 1756|     12|            _add_certdir(certdir);
 1757|     12|        } /* for subdirs */
 1758|      4|    } /* for conf path dirs */
 1759|       |    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]
  |  |  ------------------
  ------------------
 1760|      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);
  ------------------
  |  | 2037|      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[strcspn(line, "\r\n")] = '\0';
  818|      0|        if ( cp && strncmp(line, "DIR ", 4) == 0 ) {
  ------------------
  |  Branch (818:14): [True: 0, False: 0]
  |  Branch (818:20): [True: 0, False: 0]
  ------------------
  819|      0|            pos = strrchr(line + 4, ' ');
  820|      0|            if (pos)
  ------------------
  |  Branch (820:17): [True: 0, False: 0]
  ------------------
  821|      0|                *pos = '\0';
  822|      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]
  |  |  ------------------
  ------------------
  823|      0|            (void)_certindex_add( line+4, i );  /* Skip 'DIR ' */
  824|      0|        } else {
  825|      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]
  |  |  ------------------
  ------------------
  826|      0|        }
  827|      0|        fclose( fp );
  828|      0|    }
  829|      1|    closedir( dir );
  830|      1|}
cert_util.c:_add_certdir:
 1632|     12|{
 1633|     12|    FILE           *index;
 1634|     12|    char           *file;
 1635|     12|    int             count = 0;
 1636|     12|    netsnmp_container *cert_container;
 1637|     12|    netsnmp_iterator  *it;
 1638|     12|    struct stat     statbuf;
 1639|       |
 1640|     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
  |  |  |  |  ------------------
  |  |  |  |  |  | 1727|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|     12|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded, False: 12]
  |  |  ------------------
  ------------------
 1641|       |
 1642|     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: 0, False: 12]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 12]
  |  |  ------------------
  ------------------
 1643|       |
 1644|     12|    if (stat(dirname, &statbuf) != 0) {
  ------------------
  |  Branch (1644:9): [True: 12, False: 0]
  ------------------
 1645|     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: 0, False: 12]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 12]
  |  |  ------------------
  ------------------
 1646|     12|                   dirname ));
 1647|     12|        return -1;
 1648|     12|    }
 1649|      0|#ifdef S_ISDIR
 1650|      0|    if (!S_ISDIR(statbuf.st_mode)) {
  ------------------
  |  Branch (1650:9): [True: 0, False: 0]
  ------------------
 1651|      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]
  |  |  ------------------
  ------------------
 1652|      0|        return -1;
 1653|      0|    }
 1654|      0|#endif
 1655|       |
 1656|      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]
  |  |  ------------------
  ------------------
 1657|       |
 1658|       |    /*
 1659|       |     * look for existing index
 1660|       |     */
 1661|      0|    count = _cert_read_index(dirname, &statbuf);
 1662|      0|    if (count >= 0)
  ------------------
  |  Branch (1662:9): [True: 0, False: 0]
  ------------------
 1663|      0|        return count;
 1664|       |
 1665|      0|    index = _certindex_new( dirname );
 1666|      0|    if (NULL == index) {
  ------------------
  |  Branch (1666:9): [True: 0, False: 0]
  ------------------
 1667|      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]
  |  |  ------------------
  ------------------
 1668|      0|                    "error opening index for cert directory\n"));
 1669|      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]
  |  |  ------------------
  ------------------
 1670|      0|    }
 1671|       |
 1672|       |    /*
 1673|       |     * index was missing, out of date or bad. rescan directory.
 1674|       |     */
 1675|      0|    cert_container =
 1676|      0|        netsnmp_directory_container_read_some(NULL, dirname,
 1677|      0|                                              _cert_cert_filter, NULL,
 1678|      0|                                              NETSNMP_DIR_RELATIVE_PATH |
  ------------------
  |  |   48|      0|#define NETSNMP_DIR_RELATIVE_PATH                     0x0002
  ------------------
 1679|      0|                                              NETSNMP_DIR_EMPTY_OK |
  ------------------
  |  |   51|      0|#define NETSNMP_DIR_EMPTY_OK                          0x0008
  ------------------
 1680|      0|                                              NETSNMP_DIR_ALLOW_DUPLICATES);
  ------------------
  |  |   57|      0|#define NETSNMP_DIR_ALLOW_DUPLICATES                  0x0040
  ------------------
 1681|      0|    if (NULL == cert_container) {
  ------------------
  |  Branch (1681:9): [True: 0, False: 0]
  ------------------
 1682|      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]
  |  |  ------------------
  ------------------
 1683|      0|                    "error creating container for cert files\n"));
 1684|      0|        goto err_index;
 1685|      0|    }
 1686|       |
 1687|       |    /*
 1688|       |     * iterate through the found files and add them to index
 1689|       |     */
 1690|      0|    it = CONTAINER_ITERATOR(cert_container);
  ------------------
  |  |  404|      0|#define CONTAINER_ITERATOR(x)       (x)->get_iterator(x)
  ------------------
 1691|      0|    if (NULL == it) {
  ------------------
  |  Branch (1691:9): [True: 0, False: 0]
  ------------------
 1692|      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]
  |  |  ------------------
  ------------------
 1693|      0|                    "error creating iterator for cert files\n"));
 1694|      0|        goto err_container;
 1695|      0|    }
 1696|       |
 1697|      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 (1697:37): [True: 0, False: 0]
  ------------------
 1698|      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]
  |  |  ------------------
  ------------------
 1699|      0|        if ( 0 == _add_certfile( dirname, file, index ))
  ------------------
  |  Branch (1699:14): [True: 0, False: 0]
  ------------------
 1700|      0|            count++;
 1701|      0|        else
 1702|      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]
  |  |  ------------------
  ------------------
 1703|      0|                        file));
 1704|      0|    }
 1705|       |
 1706|       |    /*
 1707|       |     * clean up and return
 1708|       |     */
 1709|      0|    ITERATOR_RELEASE(it);
  ------------------
  |  |  550|      0|#define ITERATOR_RELEASE(x) do { x->release(x); x = NULL; } while(0)
  |  |  ------------------
  |  |  |  Branch (550:67): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1710|       |
 1711|      0|  err_container:
 1712|      0|    netsnmp_directory_container_free(cert_container);
 1713|       |
 1714|      0|  err_index:
 1715|      0|    if (index)
  ------------------
  |  Branch (1715:9): [True: 0, False: 0]
  ------------------
 1716|      0|        fclose(index);
 1717|       |
 1718|      0|    return count;
 1719|      0|}

netsnmp_container_init_list:
   82|     58|{
   83|     58|    if (NULL != containers)
  ------------------
  |  Branch (83:9): [True: 0, False: 58]
  ------------------
   84|      0|        return;
   85|       |
   86|       |    /*
   87|       |     * create a binary array container to hold container
   88|       |     * factories
   89|       |     */
   90|     58|    containers = netsnmp_container_get_binary_array();
   91|     58|    containers->compare = netsnmp_compare_cstring;
   92|     58|    containers->container_name = strdup("container list");
   93|       |
   94|       |    /*
   95|       |     * register containers
   96|       |     */
   97|     58|    netsnmp_container_binary_array_init();
   98|     58|#ifndef NETSNMP_FEATURE_REMOVE_CONTAINER_LINKED_LIST
   99|     58|    netsnmp_container_ssll_init();
  100|     58|#endif /* NETSNMP_FEATURE_REMOVE_CONTAINER_LINKED_LIST */
  101|     58|#ifndef NETSNMP_FEATURE_REMOVE_CONTAINER_NULL
  102|     58|    netsnmp_container_null_init();
  103|     58|#endif /* NETSNMP_FEATURE_REMOVE_CONTAINER_NULL */
  104|       |
  105|       |    /*
  106|       |     * default aliases for some containers
  107|       |     */
  108|     58|    netsnmp_container_register("table_container",
  109|     58|                               netsnmp_container_get_factory("binary_array"));
  110|       |
  111|     58|#ifndef NETSNMP_FEATURE_REMOVE_CONTAINER_LINKED_LIST
  112|     58|    netsnmp_container_register("linked_list",
  113|     58|                               netsnmp_container_get_factory("sorted_singly_linked_list"));
  114|     58|    netsnmp_container_register("ssll_container",
  115|     58|                               netsnmp_container_get_factory("sorted_singly_linked_list"));
  116|     58|#endif /* NETSNMP_FEATURE_REMOVE_CONTAINER_LINKED_LIST */
  117|       |
  118|     58|    netsnmp_container_register_with_compare
  119|     58|        ("cstring", netsnmp_container_get_factory("binary_array"),
  120|     58|         netsnmp_compare_direct_cstring);
  121|       |
  122|     58|    netsnmp_container_register_with_compare
  123|     58|        ("string", netsnmp_container_get_factory("binary_array"),
  124|     58|         netsnmp_compare_cstring);
  125|     58|    netsnmp_container_register_with_compare
  126|     58|        ("string_binary_array", netsnmp_container_get_factory("binary_array"),
  127|     58|         netsnmp_compare_cstring);
  128|       |
  129|     58|}
netsnmp_container_free_list:
  133|     58|{
  134|     58|    DEBUGMSGTL(("container", "netsnmp_container_free_list() called\n"));
  ------------------
  |  |   66|     58|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     58|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 58]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 58]
  |  |  ------------------
  ------------------
  135|     58|    if (containers == NULL)
  ------------------
  |  Branch (135:9): [True: 0, False: 58]
  ------------------
  136|      0|	return;
  137|       |
  138|       |    /*
  139|       |     * free memory used by each factory entry
  140|       |     */
  141|     58|    CONTAINER_FOR_EACH(containers, _factory_free, NULL);
  ------------------
  |  |  406|     58|#define CONTAINER_FOR_EACH(x,f,c)   (x)->for_each(x,f,c)
  ------------------
  142|       |
  143|       |    /*
  144|       |     * free factory container
  145|       |     */
  146|     58|    CONTAINER_FREE(containers);
  147|       |    containers = NULL;
  148|     58|}
netsnmp_container_register_with_compare:
  153|    696|{
  154|    696|    container_type *ct, tmp;
  155|       |
  156|    696|    if (NULL==containers)
  ------------------
  |  Branch (156:9): [True: 0, False: 696]
  ------------------
  157|      0|        return -1;
  158|       |
  159|    696|    tmp.name = name;
  160|    696|    ct = (container_type *)CONTAINER_FIND(containers, &tmp);
  ------------------
  |  |  394|    696|#define CONTAINER_FIND(x,k)         (x)->find(x,k)
  ------------------
  161|    696|    if (NULL!=ct) {
  ------------------
  |  Branch (161:9): [True: 0, False: 696]
  ------------------
  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|    696|    else {
  167|    696|        ct = SNMP_MALLOC_TYPEDEF(container_type);
  ------------------
  |  |   73|    696|#define SNMP_MALLOC_TYPEDEF(td)  (td *) calloc(1, sizeof(td))
  ------------------
  168|    696|        if (NULL == ct)
  ------------------
  |  Branch (168:13): [True: 0, False: 696]
  ------------------
  169|      0|            return -1;
  170|    696|        ct->name = strdup(name);
  171|    696|        ct->factory = f;
  172|    696|        ct->compare = c;
  173|    696|        CONTAINER_INSERT(containers, ct);
  174|    696|    }
  175|    696|    DEBUGMSGT(("container_registry", "registered container factory %s (%s)\n",
  ------------------
  |  |   62|    696|#define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    696|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 696]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 696]
  |  |  ------------------
  ------------------
  176|    696|               ct->name, f->product));
  177|       |
  178|    696|    return 0;
  179|    696|}
netsnmp_container_register:
  183|    522|{
  184|       |    return netsnmp_container_register_with_compare(name, f, NULL);
  185|    522|}
netsnmp_container_get_factory:
  191|    348|{
  192|    348|    container_type ct, *found;
  193|       |    
  194|    348|    if (NULL==containers)
  ------------------
  |  Branch (194:9): [True: 0, False: 348]
  ------------------
  195|      0|        return NULL;
  196|       |
  197|    348|    ct.name = type;
  198|    348|    found = (container_type *)CONTAINER_FIND(containers, &ct);
  ------------------
  |  |  394|    348|#define CONTAINER_FIND(x,k)         (x)->find(x,k)
  ------------------
  199|       |
  200|    348|    return found ? found->factory : NULL;
  ------------------
  |  Branch (200:12): [True: 348, False: 0]
  ------------------
  201|    348|}
netsnmp_container_find:
  300|    348|{
  301|    348|    container_type *ct = netsnmp_container_find_ct(type);
  302|    348|    netsnmp_container *c = ct ? (netsnmp_container *)(ct->factory->produce()) : NULL;
  ------------------
  |  Branch (302:28): [True: 348, False: 0]
  ------------------
  303|       |
  304|       |    /*
  305|       |     * provide default compare and ncompare
  306|       |     */
  307|    348|    if (c) {
  ------------------
  |  Branch (307:9): [True: 348, False: 0]
  ------------------
  308|    348|        if (ct->compare)
  ------------------
  |  Branch (308:13): [True: 0, False: 348]
  ------------------
  309|      0|            c->compare = ct->compare;
  310|    348|        else if (NULL == c->compare)
  ------------------
  |  Branch (310:18): [True: 348, False: 0]
  ------------------
  311|    348|            c->compare = netsnmp_compare_netsnmp_index;
  312|       |
  313|    348|        if (NULL == c->ncompare)
  ------------------
  |  Branch (313:13): [True: 348, False: 0]
  ------------------
  314|    348|            c->ncompare = netsnmp_ncompare_netsnmp_index;
  315|    348|    }
  316|       |
  317|    348|    return c;
  318|    348|}
netsnmp_container_add_index:
  325|    174|{
  326|    174|    netsnmp_container *curr = primary;
  327|       |
  328|    174|    if((NULL == new_index) || (NULL == primary)) {
  ------------------
  |  Branch (328:8): [True: 0, False: 174]
  |  Branch (328:31): [True: 0, False: 174]
  ------------------
  329|      0|        snmp_log(LOG_ERR, "add index called with null pointer\n");
  330|      0|        return;
  331|      0|    }
  332|       |
  333|    348|    while(curr->next)
  ------------------
  |  Branch (333:11): [True: 174, False: 174]
  ------------------
  334|    174|        curr = curr->next;
  335|       |
  336|    174|    curr->next = new_index;
  337|    174|    new_index->prev = curr;
  338|    174|}
CONTAINER_INSERT_HELPER:
  341|  1.39k|{
  342|  1.39k|    while(x && x->insert_filter && x->insert_filter(x,k) == 1)
  ------------------
  |  Branch (342:11): [True: 696, False: 696]
  |  Branch (342:16): [True: 0, False: 696]
  |  Branch (342:36): [True: 0, False: 0]
  ------------------
  343|      0|        x = x->next;
  344|  1.39k|    if(x) {
  ------------------
  |  Branch (344:8): [True: 696, False: 696]
  ------------------
  345|    696|        int rc = x->insert(x,k);
  346|    696|        if(rc)
  ------------------
  |  Branch (346:12): [True: 0, False: 696]
  ------------------
  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|    696|        else {
  350|    696|            rc = CONTAINER_INSERT_HELPER(x->next, k);
  351|    696|            if(rc)
  ------------------
  |  Branch (351:16): [True: 0, False: 696]
  ------------------
  352|      0|                x->remove(x,k);
  353|    696|        }
  354|    696|        return rc;
  355|    696|    }
  356|    696|    return 0;
  357|  1.39k|}
CONTAINER_INSERT:
  360|    696|{
  361|       |    /** start at first container */
  362|    696|    while(x->prev)
  ------------------
  |  Branch (362:11): [True: 0, False: 696]
  ------------------
  363|      0|        x = x->prev;
  364|    696|    return CONTAINER_INSERT_HELPER(x, k);
  365|    696|}
CONTAINER_FREE:
  469|    232|{
  470|    232|    int  rc2, rc = 0;
  471|       |
  472|    232|    if (!x)
  ------------------
  |  Branch (472:9): [True: 0, False: 232]
  ------------------
  473|      0|        return rc;
  474|       |
  475|       |    /** start at last container */
  476|    406|    while(x->next)
  ------------------
  |  Branch (476:11): [True: 174, False: 232]
  ------------------
  477|    174|        x = x->next;
  478|    638|    while(x) {
  ------------------
  |  Branch (478:11): [True: 406, False: 232]
  ------------------
  479|    406|        netsnmp_container *tmp;
  480|    406|        char *name;
  481|    406|        tmp = x->prev;
  482|    406|        name = x->container_name;
  483|    406|        x->container_name = NULL;
  484|    406|        rc2 = x->cfree(x);
  485|    406|        if (rc2) {
  ------------------
  |  Branch (485:13): [True: 0, False: 406]
  ------------------
  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|    406|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 406, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 406]
  |  |  ------------------
  ------------------
  491|    406|        x = tmp;
  492|    406|    }
  493|    232|    return rc;
  494|    232|}
CONTAINER_CLEAR:
  503|    174|{
  504|       |    /** start at last container */
  505|    348|    while(x->next)
  ------------------
  |  Branch (505:11): [True: 174, False: 174]
  ------------------
  506|    174|        x = x->next;
  507|    348|    while(x->prev) {
  ------------------
  |  Branch (507:11): [True: 174, False: 174]
  ------------------
  508|       |        x->clear(x, NULL, c);
  509|    174|        x = x->prev;
  510|    174|    }
  511|    174|    x->clear(x, f, c);
  512|    174|#ifdef HAVE_MALLOC_TRIM
  513|    174|    malloc_trim(0);
  514|    174|#endif
  515|    174|}
CONTAINER_FREE_ALL:
  524|    174|{
  525|    174|    CONTAINER_CLEAR(x, x->free_item, c);
  526|    174|}
netsnmp_init_container:
  563|    406|{
  564|    406|    if (c == NULL)
  ------------------
  |  Branch (564:9): [True: 0, False: 406]
  ------------------
  565|      0|        return;
  566|       |
  567|    406|    c->init = init;
  568|    406|    c->cfree = cfree;
  569|    406|    c->get_size = size;
  570|    406|    c->compare = cmp;
  571|    406|    c->insert = ins;
  572|    406|    c->remove = rem;
  573|    406|    c->find = fnd;
  574|    406|    c->free_item = netsnmp_container_simple_free;
  575|    406|}
netsnmp_compare_cstring:
  643|  8.64k|{
  644|  8.64k|    const container_type *lhs = lhs_arg;
  645|  8.64k|    const container_type *rhs = rhs_arg;
  646|       |
  647|  8.64k|    return strcmp(lhs->name, rhs->name);
  648|  8.64k|}
container.c:_factory_free:
   65|    696|{
   66|    696|    container_type *data = (container_type *)dat;
   67|    696|    if (data == NULL)
  ------------------
  |  Branch (67:9): [True: 0, False: 696]
  ------------------
   68|      0|	return;
   69|       |    
   70|    696|    if (data->name != NULL) {
  ------------------
  |  Branch (70:9): [True: 696, False: 0]
  ------------------
   71|    696|        DEBUGMSGTL(("container", "  _factory_free_list() called for %s\n",
  ------------------
  |  |   66|    696|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    696|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 696]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 696]
  |  |  ------------------
  ------------------
   72|    696|                    data->name));
   73|    696|	free(NETSNMP_REMOVE_CONST(void *, data->name)); /* SNMP_FREE wasted on object about to be freed */
  ------------------
  |  |   91|    696|    (__extension__ ({ const t tmp = (e); (t)(size_t)tmp; }))
  ------------------
   74|    696|    }
   75|    696|    free(data); /* SNMP_FREE wasted on param */
   76|    696|}
container.c:netsnmp_container_get_ct:
  234|    696|{
  235|    696|    container_type ct;
  236|       |
  237|    696|    if (NULL == containers)
  ------------------
  |  Branch (237:9): [True: 0, False: 696]
  ------------------
  238|      0|        return NULL;
  239|       |    
  240|    696|    ct.name = type;
  241|    696|    return (container_type *)CONTAINER_FIND(containers, &ct);
  ------------------
  |  |  394|    696|#define CONTAINER_FIND(x,k)         (x)->find(x,k)
  ------------------
  242|    696|}
container.c:netsnmp_container_find_ct:
  246|    348|{
  247|    348|    container_type    *ct = NULL;
  248|    348|    char              *list, *entry;
  249|    348|    char              *st = NULL;
  250|       |
  251|    348|    if (NULL==type_list)
  ------------------
  |  Branch (251:9): [True: 0, False: 348]
  ------------------
  252|      0|        return NULL;
  253|       |
  254|    348|    list = strdup(type_list);
  255|    348|    if (!list)
  ------------------
  |  Branch (255:9): [True: 0, False: 348]
  ------------------
  256|      0|        return NULL;
  257|    348|    entry = strtok_r(list, ":", &st);
  258|    696|    while (entry) {
  ------------------
  |  Branch (258:12): [True: 696, False: 0]
  ------------------
  259|    696|        ct = netsnmp_container_get_ct(entry);
  260|    696|        if (NULL != ct)
  ------------------
  |  Branch (260:13): [True: 348, False: 348]
  ------------------
  261|    348|            break;
  262|    348|        entry = strtok_r(NULL, ":", &st);
  263|    348|    }
  264|       |
  265|    348|    free(list);
  266|    348|    return ct;
  267|    348|}

netsnmp_binary_array_release:
  216|    348|{
  217|    348|    binary_array_table *t = (binary_array_table*)c->container_data;
  218|    348|    SNMP_FREE(t->data);
  ------------------
  |  |   62|    348|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 58, False: 290]
  |  |  |  Branch (62:66): [Folded, False: 348]
  |  |  ------------------
  ------------------
  219|    348|    SNMP_FREE(t);
  ------------------
  |  |   62|    348|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 348, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 348]
  |  |  ------------------
  ------------------
  220|    348|    SNMP_FREE(c->container_name);
  ------------------
  |  |   62|    348|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 348]
  |  |  |  Branch (62:66): [Folded, False: 348]
  |  |  ------------------
  ------------------
  221|       |    SNMP_FREE(c);
  ------------------
  |  |   62|    348|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 348, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 348]
  |  |  ------------------
  ------------------
  222|    348|}
netsnmp_binary_array_options_set:
  232|    232|{
  233|    232|#define BA_FLAGS (CONTAINER_KEY_ALLOW_DUPLICATES|CONTAINER_KEY_UNSORTED)
  234|       |
  235|    232|    if (set) {
  ------------------
  |  Branch (235:9): [True: 232, False: 0]
  ------------------
  236|    232|        if ((flags & BA_FLAGS) == flags) {
  ------------------
  |  |  233|    232|#define BA_FLAGS (CONTAINER_KEY_ALLOW_DUPLICATES|CONTAINER_KEY_UNSORTED)
  |  |  ------------------
  |  |  |  |  370|    232|#define CONTAINER_KEY_ALLOW_DUPLICATES             0x00000001
  |  |  ------------------
  |  |               #define BA_FLAGS (CONTAINER_KEY_ALLOW_DUPLICATES|CONTAINER_KEY_UNSORTED)
  |  |  ------------------
  |  |  |  |  371|    232|#define CONTAINER_KEY_UNSORTED                     0x00000002
  |  |  ------------------
  ------------------
  |  Branch (236:13): [True: 232, False: 0]
  ------------------
  237|       |            /** if turning off unsorted, do sort */
  238|    232|            int sort = ((c->flags & CONTAINER_KEY_UNSORTED) &&
  ------------------
  |  |  371|    232|#define CONTAINER_KEY_UNSORTED                     0x00000002
  ------------------
  |  Branch (238:25): [True: 0, False: 232]
  ------------------
  239|      0|                        ! (flags & CONTAINER_KEY_UNSORTED));
  ------------------
  |  |  371|      0|#define CONTAINER_KEY_UNSORTED                     0x00000002
  ------------------
  |  Branch (239:25): [True: 0, False: 0]
  ------------------
  240|    232|            c->flags = flags;
  241|    232|            if (sort) {
  ------------------
  |  Branch (241:17): [True: 0, False: 232]
  ------------------
  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|    232|            return flags;
  247|    232|        } else {
  248|      0|            return -1; /* unsupported flag */
  249|      0|        }
  250|    232|    } else {
  251|      0|        return ((c->flags & flags) == flags);
  252|      0|    }
  253|    232|}
netsnmp_container_get_binary_array:
  817|    348|{
  818|       |    /*
  819|       |     * allocate memory
  820|       |     */
  821|    348|    netsnmp_container *c = SNMP_MALLOC_TYPEDEF(netsnmp_container);
  ------------------
  |  |   73|    348|#define SNMP_MALLOC_TYPEDEF(td)  (td *) calloc(1, sizeof(td))
  ------------------
  822|    348|    if (NULL==c) {
  ------------------
  |  Branch (822:9): [True: 0, False: 348]
  ------------------
  823|      0|        snmp_log(LOG_ERR, "couldn't allocate memory\n");
  824|      0|        return NULL;
  825|      0|    }
  826|       |
  827|    348|    c->container_data = netsnmp_binary_array_initialize();
  828|    348|    if (NULL == c->container_data) {
  ------------------
  |  Branch (828:9): [True: 0, False: 348]
  ------------------
  829|      0|        free(c);
  830|      0|        snmp_log(LOG_ERR, "couldn't allocate memory for container_data\n");
  831|      0|        return NULL;
  832|      0|    }
  833|       |
  834|       |    /*
  835|       |     * NOTE: CHANGES HERE MUST BE DUPLICATED IN duplicate AS WELL!!
  836|       |     */
  837|    348|    netsnmp_init_container(c, NULL, _ba_free, _ba_size, NULL, _ba_insert,
  838|    348|                           _ba_remove, _ba_find);
  839|    348|    c->find_next = _ba_find_next;
  840|    348|    c->get_subset = _ba_get_subset;
  841|    348|    c->get_iterator = _ba_iterator_get;
  842|    348|    c->for_each = _ba_for_each;
  843|    348|    c->clear = _ba_clear;
  844|    348|    c->options = _ba_options;
  845|    348|    c->duplicate = _ba_duplicate;
  846|    348|    c->get_at = netsnmp_binary_array_get_at;
  847|    348|    c->remove_at = netsnmp_binary_array_remove_at;
  848|    348|    c->insert_before = _ba_insert_before;
  849|       |
  850|    348|    return c;
  851|    348|}
netsnmp_container_get_binary_array_factory:
  855|     58|{
  856|     58|    static netsnmp_factory f = { "binary_array",
  857|     58|                                 netsnmp_container_get_binary_array };
  858|       |    
  859|     58|    return &f;
  860|     58|}
netsnmp_container_binary_array_init:
  864|     58|{
  865|     58|    netsnmp_container_register("binary_array",
  866|     58|                               netsnmp_container_get_binary_array_factory());
  867|     58|}
container_binary_array.c:_ba_is_sorted:
  336|    696|{
  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|    696|    return 1;
  351|    696|}
container_binary_array.c:binary_search:
  125|  2.32k|{
  126|  2.32k|    binary_array_table *t = (binary_array_table*)c->container_data;
  127|  2.32k|    size_t             len = t->count;
  128|  2.32k|    size_t             half;
  129|  2.32k|    size_t             first = 0;
  130|  2.32k|    size_t             middle = 0; /* init not needed; keeps compiler happy */
  131|  2.32k|    int                result = 0; /* init not needed; keeps compiler happy */
  132|       |
  133|  2.32k|    if (!len) {
  ------------------
  |  Branch (133:9): [True: 0, False: 2.32k]
  ------------------
  134|      0|        if (NULL != next)
  ------------------
  |  Branch (134:13): [True: 0, False: 0]
  ------------------
  135|      0|            *next = 0;
  136|      0|        return -1;
  137|      0|    }
  138|       |
  139|  2.32k|    if (c->flags & CONTAINER_KEY_UNSORTED) {
  ------------------
  |  |  371|  2.32k|#define CONTAINER_KEY_UNSORTED                     0x00000002
  ------------------
  |  Branch (139:9): [True: 0, False: 2.32k]
  ------------------
  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|  2.32k|    if (t->dirty)
  ------------------
  |  Branch (148:9): [True: 0, False: 2.32k]
  ------------------
  149|      0|        Sort_Array(c);
  150|       |
  151|  9.10k|    while (len > 0) {
  ------------------
  |  Branch (151:12): [True: 7.48k, False: 1.62k]
  ------------------
  152|  7.48k|        half = len >> 1;
  153|  7.48k|        middle = first + half;
  154|  7.48k|        if ((result = c->compare(t->data[middle], val)) < 0) {
  ------------------
  |  Branch (154:13): [True: 2.49k, False: 4.98k]
  ------------------
  155|  2.49k|            first = middle + 1;
  156|  2.49k|            len = len - half - 1;
  157|  4.98k|        } else if (result == 0) {
  ------------------
  |  Branch (157:20): [True: 696, False: 4.29k]
  ------------------
  158|    696|            first = middle;
  159|    696|            break;
  160|  4.29k|        } else {
  161|  4.29k|            len = half;
  162|  4.29k|        }
  163|  7.48k|    }
  164|       |
  165|  2.32k|    if (first >= t->count) {
  ------------------
  |  Branch (165:9): [True: 232, False: 2.08k]
  ------------------
  166|    232|        if (exact && NULL != next)
  ------------------
  |  Branch (166:13): [True: 232, False: 0]
  |  Branch (166:22): [True: 116, False: 116]
  ------------------
  167|    116|            *next = t->count;
  168|    232|        return -1;
  169|    232|    }
  170|       |
  171|  2.08k|    if (first != middle) {
  ------------------
  |  Branch (171:9): [True: 1.16k, False: 928]
  ------------------
  172|       |        /* last compare wasn't against first, so get actual result */
  173|  1.16k|        result = c->compare(t->data[first], val);
  174|  1.16k|    }
  175|       |
  176|  2.08k|    if(result == 0) {
  ------------------
  |  Branch (176:8): [True: 696, False: 1.39k]
  ------------------
  177|    696|        if (exact && NULL != next)
  ------------------
  |  Branch (177:13): [True: 696, False: 0]
  |  Branch (177:22): [True: 0, False: 696]
  ------------------
  178|      0|            *next = first+1;
  179|    696|        else if (!exact && ++first == t->count) {
  ------------------
  |  Branch (179:18): [True: 0, False: 696]
  |  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|  1.39k|    } else if(exact) {
  ------------------
  |  Branch (184:15): [True: 1.39k, False: 0]
  ------------------
  185|  1.39k|        if (NULL != next) {
  ------------------
  |  Branch (185:13): [True: 522, False: 870]
  ------------------
  186|    522|            if (result > 0)
  ------------------
  |  Branch (186:17): [True: 522, False: 0]
  ------------------
  187|    522|                *next = first;
  188|      0|            else
  189|      0|                *next = t->count;
  190|    522|        }
  191|  1.39k|        first = -1;
  192|  1.39k|    }
  193|       |
  194|  2.08k|    return first;
  195|  2.32k|}
container_binary_array.c:netsnmp_binary_array_initialize:
  199|    348|{
  200|    348|    binary_array_table *t;
  201|       |
  202|    348|    t = SNMP_MALLOC_TYPEDEF(binary_array_table);
  ------------------
  |  |   73|    348|#define SNMP_MALLOC_TYPEDEF(td)  (td *) calloc(1, sizeof(td))
  ------------------
  203|    348|    if (t == NULL)
  ------------------
  |  Branch (203:9): [True: 0, False: 348]
  ------------------
  204|      0|        return NULL;
  205|       |
  206|    348|    t->max_size = 0;
  207|    348|    t->count = 0;
  208|    348|    t->dirty = 0;
  209|    348|    t->data = NULL;
  210|       |
  211|    348|    return t;
  212|    348|}
container_binary_array.c:_ba_free:
  713|    348|{
  714|    348|    netsnmp_binary_array_release(container);
  715|    348|    return 0;
  716|    348|}
container_binary_array.c:_ba_size:
  720|      1|{
  721|      1|    return netsnmp_binary_array_count(container);
  722|      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:
  694|    696|{
  695|    696|    return netsnmp_binary_array_insert(container, data);
  696|    696|}
container_binary_array.c:netsnmp_binary_array_insert:
  533|    696|{
  534|    696|    binary_array_table *t = (binary_array_table*)c->container_data;
  535|    696|    const int duplicates_allowed = c->flags & CONTAINER_KEY_ALLOW_DUPLICATES;
  ------------------
  |  |  370|    696|#define CONTAINER_KEY_ALLOW_DUPLICATES             0x00000001
  ------------------
  536|    696|    const int sorted = !(c->flags & CONTAINER_KEY_UNSORTED);
  ------------------
  |  |  371|    696|#define CONTAINER_KEY_UNSORTED                     0x00000002
  ------------------
  537|    696|    int             i = -2;
  538|    696|    size_t          next, pos;
  539|    696|    void           *entry = NETSNMP_REMOVE_CONST(void *, const_entry);
  ------------------
  |  |   91|    696|    (__extension__ ({ const t tmp = (e); (t)(size_t)tmp; }))
  ------------------
  540|       |
  541|    696|    if (NULL == entry)
  ------------------
  |  Branch (541:9): [True: 0, False: 696]
  ------------------
  542|      0|        return -1;
  543|       |
  544|       |    /*
  545|       |     * check key if we have at least 1 item and duplicates aren't allowed
  546|       |     */
  547|    696|    if (!duplicates_allowed && t->count) {
  ------------------
  |  Branch (547:9): [True: 696, False: 0]
  |  Branch (547:32): [True: 638, False: 58]
  ------------------
  548|    638|        i = binary_search(entry, c, 1, &next);
  549|    638|        if (i >= 0) {
  ------------------
  |  Branch (549:13): [True: 0, False: 638]
  ------------------
  550|      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]
  |  |  ------------------
  ------------------
  551|      0|            return -1;
  552|      0|        }
  553|    638|    }
  554|       | 
  555|       |    /*
  556|       |     * if unsorted, just add at the end
  557|       |     */
  558|    696|    if (!sorted) {
  ------------------
  |  Branch (558:9): [True: 0, False: 696]
  ------------------
  559|      0|        pos = t->count;
  560|    696|    } else {
  561|       |        /** if we haven't searched for key yet, do it now */
  562|    696|        if (-2 == i) {
  ------------------
  |  Branch (562:13): [True: 58, False: 638]
  ------------------
  563|     58|            if (0 == t->count) {
  ------------------
  |  Branch (563:17): [True: 58, False: 0]
  ------------------
  564|     58|                next = 0;
  565|     58|                i = -1;
  566|     58|            } else {
  567|      0|                i = binary_search(entry, c, 1, &next);
  568|      0|            }
  569|     58|        }
  570|       |
  571|    696|        pos = next;
  572|       |        /* if key found, advance past any duplicates */
  573|    696|        if (duplicates_allowed && i >= 0)
  ------------------
  |  Branch (573:13): [True: 0, False: 696]
  |  Branch (573:35): [True: 0, False: 0]
  ------------------
  574|      0|            while (pos < t->count && c->compare(t->data[pos], entry) == 0)
  ------------------
  |  Branch (574:20): [True: 0, False: 0]
  |  Branch (574:38): [True: 0, False: 0]
  ------------------
  575|      0|                ++pos;
  576|    696|    }
  577|       |
  578|    696|    return netsnmp_binary_array_insert_before(c, pos, entry, !sorted);
  579|    696|}
container_binary_array.c:netsnmp_binary_array_insert_before:
  487|    696|{
  488|    696|    binary_array_table *t = (binary_array_table*)c->container_data;
  489|       |
  490|    696|    if (NULL == entry)
  ------------------
  |  Branch (490:9): [True: 0, False: 696]
  ------------------
  491|      0|        return -1;
  492|       |
  493|    696|    if (index > t->count) {
  ------------------
  |  Branch (493:9): [True: 0, False: 696]
  ------------------
  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|    696|    if (_ba_resize_check(t) < 0)
  ------------------
  |  Branch (501:9): [True: 0, False: 696]
  ------------------
  502|      0|        return -1;
  503|       |
  504|    696|    netsnmp_assert(t->count < t->max_size);
  ------------------
  |  |   47|    696|#      define netsnmp_assert(x)  do { \
  |  |   48|    696|              if ( x ) \
  |  |  ------------------
  |  |  |  Branch (48:20): [True: 696, False: 0]
  |  |  ------------------
  |  |   49|    696|                 ; \
  |  |   50|    696|              else \
  |  |   51|    696|                 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
  |  |  |  |  ------------------
  |  |  |  |  |  | 1727|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|    696|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded, False: 696]
  |  |  ------------------
  ------------------
  505|       |
  506|       |    /*
  507|       |     * shift array
  508|       |     */
  509|    696|    memmove(&t->data[index+1], &t->data[index],
  510|    696|            sizeof(void*) * (t->count - index));
  511|       |
  512|       |    /*
  513|       |     * Insert the new entry into the data array
  514|       |     */
  515|    696|    t->data[index] = NETSNMP_REMOVE_CONST(void *, entry);
  ------------------
  |  |   91|    696|    (__extension__ ({ const t tmp = (e); (t)(size_t)tmp; }))
  ------------------
  516|    696|    ++t->count;
  517|       |
  518|    696|    netsnmp_assert(index < t->count);
  ------------------
  |  |   47|    696|#      define netsnmp_assert(x)  do { \
  |  |   48|    696|              if ( x ) \
  |  |  ------------------
  |  |  |  Branch (48:20): [True: 696, False: 0]
  |  |  ------------------
  |  |   49|    696|                 ; \
  |  |   50|    696|              else \
  |  |   51|    696|                 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
  |  |  |  |  ------------------
  |  |  |  |  |  | 1727|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|    696|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded, False: 696]
  |  |  ------------------
  ------------------
  519|    696|    netsnmp_assert(t->count <= t->max_size);
  ------------------
  |  |   47|    696|#      define netsnmp_assert(x)  do { \
  |  |   48|    696|              if ( x ) \
  |  |  ------------------
  |  |  |  Branch (48:20): [True: 696, False: 0]
  |  |  ------------------
  |  |   49|    696|                 ; \
  |  |   50|    696|              else \
  |  |   51|    696|                 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
  |  |  |  |  ------------------
  |  |  |  |  |  | 1727|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|    696|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded, False: 696]
  |  |  ------------------
  ------------------
  520|       |
  521|    696|    if (dirty)
  ------------------
  |  Branch (521:9): [True: 0, False: 696]
  ------------------
  522|      0|        t->dirty = 1;
  523|       |
  524|    696|    netsnmp_assert(t->dirty || _ba_is_sorted(c));
  ------------------
  |  |   47|    696|#      define netsnmp_assert(x)  do { \
  |  |   48|  2.08k|              if ( x ) \
  |  |  ------------------
  |  |  |  Branch (48:20): [True: 0, False: 696]
  |  |  |  Branch (48:20): [True: 696, False: 0]
  |  |  ------------------
  |  |   49|    696|                 ; \
  |  |   50|    696|              else \
  |  |   51|    696|                 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
  |  |  |  |  ------------------
  |  |  |  |  |  | 1727|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|    696|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded, False: 696]
  |  |  ------------------
  ------------------
  525|       |
  526|    696|    ++c->sync;
  527|       |
  528|    696|    return 0;
  529|    696|}
container_binary_array.c:_ba_resize_check:
  458|    696|{
  459|    696|    size_t new_max;
  460|    696|    void ** new_data;
  461|    696|    if (t->max_size > t->count)
  ------------------
  |  Branch (461:9): [True: 580, False: 116]
  ------------------
  462|    580|        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|    116|    new_max = t->max_size > 0 ? 2 * t->max_size : 10;
  ------------------
  |  Branch (468:15): [True: 58, False: 58]
  ------------------
  469|    116|    new_data = (void**) realloc(t->data, new_max * sizeof(void*));
  470|    116|    if (new_data == NULL) {
  ------------------
  |  Branch (470:9): [True: 0, False: 116]
  ------------------
  471|      0|        snmp_log(LOG_ERR, "malloc failed in _ba_resize_check\n");
  472|      0|        return -1; /* error */
  473|      0|    }
  474|       |
  475|    116|    memset(new_data + t->max_size, 0x0,
  476|    116|           (new_max - t->max_size) * sizeof(void*));
  477|       |
  478|    116|    t->data = new_data;
  479|    116|    t->max_size = new_max;
  480|       |
  481|    116|    return 1; /* resized */
  482|    116|}
container_binary_array.c:_ba_find:
  682|  1.74k|{
  683|  1.74k|    return netsnmp_binary_array_get(container, data, 1);
  684|  1.74k|}
container_binary_array.c:netsnmp_binary_array_get:
  267|  1.74k|{
  268|  1.74k|    binary_array_table *t = (binary_array_table*)c->container_data;
  269|  1.74k|    int             index = 0;
  270|       |
  271|       |    /*
  272|       |     * if there is no data, return NULL;
  273|       |     */
  274|  1.74k|    if (!t->count)
  ------------------
  |  Branch (274:9): [True: 58, False: 1.68k]
  ------------------
  275|     58|        return NULL;
  276|       |
  277|       |    /*
  278|       |     * if the table is dirty, sort it.
  279|       |     */
  280|  1.68k|    if (t->dirty)
  ------------------
  |  Branch (280:9): [True: 0, False: 1.68k]
  ------------------
  281|      0|        Sort_Array(c);
  282|       |
  283|       |    /*
  284|       |     * if there is a key, search. Otherwise default is 0;
  285|       |     */
  286|  1.68k|    if (key) {
  ------------------
  |  Branch (286:9): [True: 1.68k, False: 0]
  ------------------
  287|  1.68k|        if ((index = binary_search(key, c, exact, NULL)) == -1)
  ------------------
  |  Branch (287:13): [True: 986, False: 696]
  ------------------
  288|    986|            return NULL;
  289|    696|        if (!exact &&
  ------------------
  |  Branch (289:13): [True: 0, False: 696]
  ------------------
  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|    696|    }
  308|       |
  309|    696|    return t->data[index];
  310|  1.68k|}
container_binary_array.c:_ba_for_each:
  727|     58|{
  728|     58|    netsnmp_binary_array_for_each(container, f, context, 1);
  729|     58|}
container_binary_array.c:netsnmp_binary_array_for_each:
  426|     58|{
  427|     58|    binary_array_table *t = (binary_array_table*)c->container_data;
  428|     58|    size_t             i;
  429|       |
  430|     58|    if (sort && t->dirty)
  ------------------
  |  Branch (430:9): [True: 58, False: 0]
  |  Branch (430:17): [True: 0, False: 58]
  ------------------
  431|      0|        Sort_Array(c);
  432|       |
  433|    754|    for (i = 0; i < t->count; ++i)
  ------------------
  |  Branch (433:17): [True: 696, False: 58]
  ------------------
  434|    696|        (*fe) (t->data[i], context);
  435|     58|}
container_binary_array.c:_ba_clear:
  734|    290|{
  735|    290|    netsnmp_binary_array_clear(container, f, context);
  736|    290|}
container_binary_array.c:netsnmp_binary_array_clear:
  441|    290|{
  442|    290|    binary_array_table *t = (binary_array_table*)c->container_data;
  443|       |
  444|    290|    if( NULL != fe ) {
  ------------------
  |  Branch (444:9): [True: 116, False: 174]
  ------------------
  445|    116|        size_t             i;
  446|       |
  447|    116|        for (i = 0; i < t->count; ++i)
  ------------------
  |  Branch (447:21): [True: 0, False: 116]
  ------------------
  448|      0|            (*fe) (t->data[i], context);
  449|    116|    }
  450|       |
  451|    290|    t->count = 0;
  452|    290|    t->dirty = 0;
  453|    290|    ++c->sync;
  454|    290|}
container_binary_array.c:_ba_options:
  762|    232|{
  763|    232|    return netsnmp_binary_array_options_set(c, set, flags);
  764|    232|}
container_binary_array.c:_ba_iterator_get:
 1026|      1|{
 1027|      1|    binary_array_iterator* it;
 1028|       |
 1029|      1|    if(NULL == c)
  ------------------
  |  Branch (1029:8): [True: 0, False: 1]
  ------------------
 1030|      0|        return NULL;
 1031|       |
 1032|      1|    it = SNMP_MALLOC_TYPEDEF(binary_array_iterator);
  ------------------
  |  |   73|      1|#define SNMP_MALLOC_TYPEDEF(td)  (td *) calloc(1, sizeof(td))
  ------------------
 1033|      1|    if(NULL == it)
  ------------------
  |  Branch (1033:8): [True: 0, False: 1]
  ------------------
 1034|      0|        return NULL;
 1035|       |
 1036|      1|    it->base.container = c;
 1037|       |    
 1038|      1|    it->base.first = _ba_iterator_first;
 1039|      1|    it->base.next = _ba_iterator_next;
 1040|      1|    it->base.curr = _ba_iterator_curr;
 1041|      1|    it->base.last = _ba_iterator_last;
 1042|      1|    it->base.remove = _ba_iterator_remove;
 1043|      1|    it->base.reset = _ba_iterator_reset;
 1044|      1|    it->base.release = _ba_iterator_release;
 1045|       |
 1046|      1|    (void)_ba_iterator_reset(&it->base);
 1047|       |
 1048|      1|    return &it->base;
 1049|      1|}
container_binary_array.c:_ba_iterator_first:
  932|      1|{
  933|      1|    binary_array_iterator *it = (void *)nit;
  934|       |
  935|      1|    return _ba_iterator_position(it, 0);
  936|      1|}
container_binary_array.c:_ba_iterator_position:
  895|      1|{
  896|      1|    binary_array_table *t = _ba_it2cont(it);
  897|      1|    if (NULL == t)
  ------------------
  |  Branch (897:9): [True: 0, False: 1]
  ------------------
  898|      0|        return t; /* msg already logged */
  899|       |
  900|      1|    if(it->base.container->sync != it->base.sync) {
  ------------------
  |  Branch (900:8): [True: 0, False: 1]
  ------------------
  901|      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]
  |  |  ------------------
  ------------------
  902|      0|        return NULL;
  903|      0|    }
  904|       |    
  905|      1|    if(0 == t->count) {
  ------------------
  |  Branch (905:8): [True: 1, False: 0]
  ------------------
  906|      1|        DEBUGMSGTL(("container:iterator", "empty\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]
  |  |  ------------------
  ------------------
  907|      1|        return NULL;
  908|      1|    }
  909|      0|    else if(pos >= t->count) {
  ------------------
  |  Branch (909:13): [True: 0, False: 0]
  ------------------
  910|      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]
  |  |  ------------------
  ------------------
  911|      0|        return NULL;
  912|      0|    }
  913|       |
  914|      0|    return t->data[ pos ];
  915|      1|}
container_binary_array.c:_ba_it2cont:
  876|      2|{
  877|      2|    if(NULL == it) {
  ------------------
  |  Branch (877:8): [True: 0, False: 2]
  ------------------
  878|      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
  |  |  |  |  ------------------
  |  |  |  |  |  | 1727|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|      0|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded, False: 0]
  |  |  ------------------
  ------------------
  879|      0|        return NULL;
  880|      0|    }
  881|      2|    if(NULL == it->base.container) {
  ------------------
  |  Branch (881:8): [True: 0, False: 2]
  ------------------
  882|      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
  |  |  |  |  ------------------
  |  |  |  |  |  | 1727|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|      0|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded, False: 0]
  |  |  ------------------
  ------------------
  883|      0|        return NULL;
  884|      0|    }
  885|      2|    if(NULL == it->base.container->container_data) {
  ------------------
  |  Branch (885:8): [True: 0, False: 2]
  ------------------
  886|      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
  |  |  |  |  ------------------
  |  |  |  |  |  | 1727|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|      0|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded, False: 0]
  |  |  ------------------
  ------------------
  887|      0|        return NULL;
  888|      0|    }
  889|       |
  890|      2|    return (binary_array_table*)(it->base.container->container_data);
  891|      2|}
container_binary_array.c:_ba_iterator_reset:
  994|      1|{
  995|      1|    binary_array_iterator *it = (void *)nit;
  996|      1|    binary_array_table* t = _ba_it2cont(it);
  997|      1|    if(NULL == t) {
  ------------------
  |  Branch (997:8): [True: 0, False: 1]
  ------------------
  998|      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
  |  |  |  |  ------------------
  |  |  |  |  |  | 1727|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|      0|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded, False: 0]
  |  |  ------------------
  ------------------
  999|      0|        return -1;
 1000|      0|    }
 1001|       |
 1002|      1|    if (t->dirty)
  ------------------
  |  Branch (1002:9): [True: 0, False: 1]
  ------------------
 1003|      0|        Sort_Array(it->base.container);
 1004|       |
 1005|       |    /*
 1006|       |     * save sync count, to make sure container doesn't change while
 1007|       |     * iterator is in use.
 1008|       |     */
 1009|      1|    it->base.sync = it->base.container->sync;
 1010|       |
 1011|      1|    it->pos = 0;
 1012|       |
 1013|      1|    return 0;
 1014|      1|}
container_binary_array.c:_ba_iterator_release:
 1018|      1|{
 1019|      1|    free(it);
 1020|       |
 1021|      1|    return 0;
 1022|      1|}

netsnmp_container_get_usll:
  393|     58|{
  394|       |    /*
  395|       |     * allocate memory
  396|       |     */
  397|     58|    sl_container *sl = (sl_container *)netsnmp_container_get_ssll();
  398|     58|    if (NULL==sl)
  ------------------
  |  Branch (398:9): [True: 0, False: 58]
  ------------------
  399|      0|        return NULL; /* msg already logged */
  400|       |
  401|     58|    sl->unsorted = 1;
  402|       |
  403|     58|    return (netsnmp_container*)sl;
  404|     58|}
netsnmp_container_get_singly_linked_list:
  408|     58|{
  409|     58|    sl_container *sl = (sl_container *)netsnmp_container_get_usll();
  410|     58|    if (NULL == sl)
  ------------------
  |  Branch (410:9): [True: 0, False: 58]
  ------------------
  411|      0|        return NULL; /* error already logged */
  412|       |
  413|     58|    sl->fifo = fifo;
  414|       |
  415|     58|    return (netsnmp_container *)sl;
  416|     58|}
netsnmp_container_get_fifo:
  420|     58|{
  421|     58|    return netsnmp_container_get_singly_linked_list(1);
  422|     58|}
netsnmp_container_ssll_init:
  426|     58|{
  427|     58|    static netsnmp_factory ssll = {
  428|     58|        "sorted_singly_linked_list",
  429|     58|        netsnmp_container_get_ssll
  430|     58|    };
  431|     58|    static netsnmp_factory usll = {
  432|     58|        "unsorted_singly_linked_list-lifo",
  433|     58|        netsnmp_container_get_usll
  434|     58|    };
  435|     58|    static netsnmp_factory fifo = {
  436|     58|        "unsorted_singly_linked_list-fifo",
  437|     58|        netsnmp_container_get_fifo
  438|     58|    };
  439|       |
  440|     58|    netsnmp_container_register("sorted_singly_linked_list", &ssll);
  441|     58|    netsnmp_container_register("unsorted_singly_linked_list", &usll);
  442|     58|    netsnmp_container_register("lifo", &usll);
  443|     58|    netsnmp_container_register("fifo", &fifo);
  444|     58|}
container_list_ssll.c:netsnmp_container_get_ssll:
  368|     58|{
  369|       |    /*
  370|       |     * allocate memory
  371|       |     */
  372|     58|    sl_container *sl = SNMP_MALLOC_TYPEDEF(sl_container);
  ------------------
  |  |   73|     58|#define SNMP_MALLOC_TYPEDEF(td)  (td *) calloc(1, sizeof(td))
  ------------------
  373|     58|    if (NULL==sl) {
  ------------------
  |  Branch (373:9): [True: 0, False: 58]
  ------------------
  374|      0|        snmp_log(LOG_ERR, "couldn't allocate memory\n");
  375|      0|        return NULL;
  376|      0|    }
  377|       |
  378|     58|    netsnmp_init_container((netsnmp_container *)sl, NULL, _ssll_free,
  379|     58|                           _ssll_size, NULL, _ssll_insert, _ssll_remove,
  380|     58|                           _ssll_find);
  381|     58|    sl->c.find_next = _ssll_find_next;
  382|     58|    sl->c.get_subset = NULL;
  383|     58|    sl->c.get_iterator =_ssll_iterator_get;
  384|     58|    sl->c.for_each = _ssll_for_each;
  385|     58|    sl->c.clear = _ssll_clear;
  386|     58|    sl->c.duplicate = _ssll_duplicate;
  387|       |
  388|     58|    return &sl->c;
  389|     58|}
container_list_ssll.c:_ssll_free:
  110|     58|{
  111|     58|    if(c) {
  ------------------
  |  Branch (111:8): [True: 58, False: 0]
  ------------------
  112|     58|        sl_container *sl = (sl_container *)c;
  113|     58|        sl_node *curr, *next;
  114|       |
  115|     58|        for (curr = sl->head; curr; curr = next) {
  ------------------
  |  Branch (115:31): [True: 0, False: 58]
  ------------------
  116|      0|            next = curr->next;
  117|      0|            free(curr);
  118|      0|        }
  119|     58|        free(c);
  120|     58|    }
  121|     58|    return 0;
  122|     58|}
container_list_ssll.c:_ssll_clear:
  294|     58|{
  295|     58|    sl_container *sl = (sl_container*)c;
  296|     58|    sl_node  *curr, *next;
  297|       |    
  298|     58|    if(NULL == c)
  ------------------
  |  Branch (298:8): [True: 0, False: 58]
  ------------------
  299|      0|        return;
  300|       |    
  301|     58|    for(curr = sl->head; curr; curr = next) {
  ------------------
  |  Branch (301:26): [True: 0, False: 58]
  ------------------
  302|       |
  303|      0|        next = curr->next;
  304|       |
  305|      0|        if( NULL != f ) {
  ------------------
  |  Branch (305:13): [True: 0, False: 0]
  ------------------
  306|      0|            curr->next = NULL;
  307|      0|            (*f) ((void *)curr->data, context);
  308|      0|        }
  309|       |
  310|       |        /*
  311|       |         * free our node structure, but not the data
  312|       |         */
  313|      0|        free(curr);
  314|      0|    }
  315|       |    sl->head = NULL;
  316|     58|    sl->count = 0;
  317|     58|    ++c->sync;
  318|     58|}

netsnmp_container_get_null_factory:
  173|     58|{
  174|     58|    static netsnmp_factory f = { "null",
  175|     58|                                 netsnmp_container_get_null};
  176|       |    
  177|     58|    DEBUGMSGTL(("container:null:get_null_factory","in\n"));
  ------------------
  |  |   66|     58|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     58|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 58]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 58]
  |  |  ------------------
  ------------------
  178|     58|    return &f;
  179|     58|}
netsnmp_container_null_init:
  183|     58|{
  184|     58|    netsnmp_container_register("null",
  185|     58|                               netsnmp_container_get_null_factory());
  186|     58|}

netsnmp_free_all_list_data:
   49|    174|{
   50|    174|    netsnmp_data_list *tmpptr;
   51|    174|    for (; head;) {
  ------------------
  |  Branch (51:12): [True: 0, False: 174]
  ------------------
   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|    174|}
shutdown_data_list:
  399|     58|{
  400|     58|    netsnmp_free_all_list_data(saveHead);
  401|     58|}

netsnmp_ds_set_boolean:
  201|    290|{
  202|    290|    if (storeid < 0 || storeid >= NETSNMP_DS_MAX_IDS || 
  ------------------
  |  |   38|    580|#define NETSNMP_DS_MAX_IDS 3
  ------------------
  |  Branch (202:9): [True: 0, False: 290]
  |  Branch (202:24): [True: 0, False: 290]
  ------------------
  203|    290|	which   < 0 || which   >= NETSNMP_DS_MAX_SUBIDS) {
  ------------------
  |  |   39|    290|#define NETSNMP_DS_MAX_SUBIDS 64        /* needs to be a multiple of 8 */
  ------------------
  |  Branch (203:2): [True: 0, False: 290]
  |  Branch (203:17): [True: 0, False: 290]
  ------------------
  204|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  205|      0|    }
  206|       |
  207|    290|    DEBUGMSGTL(("netsnmp_ds_set_boolean", "Setting %s:%d = %d/%s\n",
  ------------------
  |  |   66|    290|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    290|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 290]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 290]
  |  |  ------------------
  ------------------
  208|    290|                stores[storeid], which, value, ((value) ? "True" : "False")));
  209|       |
  210|    290|    if (value > 0) {
  ------------------
  |  Branch (210:9): [True: 290, False: 0]
  ------------------
  211|    290|        netsnmp_ds_booleans[storeid][which/8] |= (1 << (which % 8));
  212|    290|    } else {
  213|      0|        netsnmp_ds_booleans[storeid][which/8] &= (0xff7f >> (7 - (which % 8)));
  214|      0|    }
  215|       |
  216|    290|    return SNMPERR_SUCCESS;
  ------------------
  |  |  184|    290|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  217|    290|}
netsnmp_ds_get_boolean:
  242|  6.56k|{
  243|  6.56k|    if (storeid < 0 || storeid >= NETSNMP_DS_MAX_IDS || 
  ------------------
  |  |   38|  13.1k|#define NETSNMP_DS_MAX_IDS 3
  ------------------
  |  Branch (243:9): [True: 0, False: 6.56k]
  |  Branch (243:24): [True: 0, False: 6.56k]
  ------------------
  244|  6.56k|	which   < 0 || which   >= NETSNMP_DS_MAX_SUBIDS) {
  ------------------
  |  |   39|  6.56k|#define NETSNMP_DS_MAX_SUBIDS 64        /* needs to be a multiple of 8 */
  ------------------
  |  Branch (244:2): [True: 0, False: 6.56k]
  |  Branch (244:17): [True: 0, False: 6.56k]
  ------------------
  245|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  246|      0|    }
  247|       |
  248|  6.56k|    return (netsnmp_ds_booleans[storeid][which/8] & (1 << (which % 8))) ? 1:0;
  ------------------
  |  Branch (248:12): [True: 3.24k, False: 3.31k]
  ------------------
  249|  6.56k|}
netsnmp_ds_set_int:
  253|    116|{
  254|    116|    if (storeid < 0 || storeid >= NETSNMP_DS_MAX_IDS || 
  ------------------
  |  |   38|    232|#define NETSNMP_DS_MAX_IDS 3
  ------------------
  |  Branch (254:9): [True: 0, False: 116]
  |  Branch (254:24): [True: 0, False: 116]
  ------------------
  255|    116|	which   < 0 || which   >= NETSNMP_DS_MAX_SUBIDS) {
  ------------------
  |  |   39|    116|#define NETSNMP_DS_MAX_SUBIDS 64        /* needs to be a multiple of 8 */
  ------------------
  |  Branch (255:2): [True: 0, False: 116]
  |  Branch (255:17): [True: 0, False: 116]
  ------------------
  256|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  257|      0|    }
  258|       |
  259|    116|    DEBUGMSGTL(("netsnmp_ds_set_int", "Setting %s:%d = %d\n",
  ------------------
  |  |   66|    116|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    116|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 116]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 116]
  |  |  ------------------
  ------------------
  260|    116|                stores[storeid], which, value));
  261|       |
  262|    116|    netsnmp_ds_integers[storeid][which] = value;
  263|    116|    return SNMPERR_SUCCESS;
  ------------------
  |  |  184|    116|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  264|    116|}
netsnmp_ds_get_int:
  268|    582|{
  269|    582|    if (storeid < 0 || storeid >= NETSNMP_DS_MAX_IDS || 
  ------------------
  |  |   38|  1.16k|#define NETSNMP_DS_MAX_IDS 3
  ------------------
  |  Branch (269:9): [True: 0, False: 582]
  |  Branch (269:24): [True: 0, False: 582]
  ------------------
  270|    582|	which   < 0 || which   >= NETSNMP_DS_MAX_SUBIDS) {
  ------------------
  |  |   39|    582|#define NETSNMP_DS_MAX_SUBIDS 64        /* needs to be a multiple of 8 */
  ------------------
  |  Branch (270:2): [True: 0, False: 582]
  |  Branch (270:17): [True: 0, False: 582]
  ------------------
  271|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  272|      0|    }
  273|       |
  274|    582|    return netsnmp_ds_integers[storeid][which];
  275|    582|}
netsnmp_ds_set_string:
  279|    234|{
  280|    234|    if (storeid < 0 || storeid >= NETSNMP_DS_MAX_IDS || 
  ------------------
  |  |   38|    468|#define NETSNMP_DS_MAX_IDS 3
  ------------------
  |  Branch (280:9): [True: 0, False: 234]
  |  Branch (280:24): [True: 0, False: 234]
  ------------------
  281|    234|	which   < 0 || which   >= NETSNMP_DS_MAX_SUBIDS) {
  ------------------
  |  |   39|    234|#define NETSNMP_DS_MAX_SUBIDS 64        /* needs to be a multiple of 8 */
  ------------------
  |  Branch (281:2): [True: 0, False: 234]
  |  Branch (281:17): [True: 0, False: 234]
  ------------------
  282|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  283|      0|    }
  284|       |
  285|    234|    DEBUGMSGTL(("netsnmp_ds_set_string", "Setting %s:%d = \"%s\"\n",
  ------------------
  |  |   66|    234|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    234|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 234]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 234]
  |  |  ------------------
  ------------------
  286|    234|                stores[storeid], which, (value ? value : "(null)")));
  287|       |
  288|       |    /*
  289|       |     * is some silly person is calling us with our own pointer?
  290|       |     */
  291|    234|    if (netsnmp_ds_strings[storeid][which] == value)
  ------------------
  |  Branch (291:9): [True: 1, False: 233]
  ------------------
  292|      1|        return SNMPERR_SUCCESS;
  ------------------
  |  |  184|      1|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  293|       |
  294|    233|    snmp_res_lock(MT_LIBRARY_ID, MT_LIB_SESSION);
  ------------------
  |  |   79|    233|#define snmp_res_lock(x,y) do {} while (0)
  |  |  ------------------
  |  |  |  Branch (79:41): [Folded, False: 233]
  |  |  ------------------
  ------------------
  295|    233|    if (netsnmp_ds_strings[storeid][which] != NULL) {
  ------------------
  |  Branch (295:9): [True: 57, False: 176]
  ------------------
  296|     57|        free(netsnmp_ds_strings[storeid][which]);
  297|     57|	netsnmp_ds_strings[storeid][which] = NULL;
  298|     57|    }
  299|    233|    snmp_res_unlock(MT_LIBRARY_ID, MT_LIB_SESSION);
  ------------------
  |  |   80|    233|#define snmp_res_unlock(x,y) do {} while (0)
  |  |  ------------------
  |  |  |  Branch (80:43): [Folded, False: 233]
  |  |  ------------------
  ------------------
  300|       |
  301|    233|    if (value) {
  ------------------
  |  Branch (301:9): [True: 233, False: 0]
  ------------------
  302|    233|        netsnmp_ds_strings[storeid][which] = strdup(value);
  303|    233|    } else {
  304|      0|        netsnmp_ds_strings[storeid][which] = NULL;
  305|      0|    }
  306|       |
  307|    233|    return SNMPERR_SUCCESS;
  ------------------
  |  |  184|    233|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  308|    234|}
netsnmp_ds_get_string:
  312|  1.39k|{
  313|  1.39k|    if (storeid < 0 || storeid >= NETSNMP_DS_MAX_IDS || 
  ------------------
  |  |   38|  2.79k|#define NETSNMP_DS_MAX_IDS 3
  ------------------
  |  Branch (313:9): [True: 0, False: 1.39k]
  |  Branch (313:24): [True: 0, False: 1.39k]
  ------------------
  314|  1.39k|	which   < 0 || which   >= NETSNMP_DS_MAX_SUBIDS) {
  ------------------
  |  |   39|  1.39k|#define NETSNMP_DS_MAX_SUBIDS 64        /* needs to be a multiple of 8 */
  ------------------
  |  Branch (314:2): [True: 0, False: 1.39k]
  |  Branch (314:17): [True: 0, False: 1.39k]
  ------------------
  315|      0|        return NULL;
  316|      0|    }
  317|       |
  318|  1.39k|    return netsnmp_ds_strings[storeid][which];
  319|  1.39k|}
netsnmp_ds_register_config:
  447|  2.49k|{
  448|  2.49k|    netsnmp_ds_read_config *drsp;
  449|       |
  450|  2.49k|    if (storeid < 0 || storeid >= NETSNMP_DS_MAX_IDS    || 
  ------------------
  |  |   38|  4.98k|#define NETSNMP_DS_MAX_IDS 3
  ------------------
  |  Branch (450:9): [True: 0, False: 2.49k]
  |  Branch (450:24): [True: 0, False: 2.49k]
  ------------------
  451|  2.49k|	which   < 0 || which   >= NETSNMP_DS_MAX_SUBIDS || token == NULL) {
  ------------------
  |  |   39|  4.98k|#define NETSNMP_DS_MAX_SUBIDS 64        /* needs to be a multiple of 8 */
  ------------------
  |  Branch (451:2): [True: 0, False: 2.49k]
  |  Branch (451:17): [True: 0, False: 2.49k]
  |  Branch (451:53): [True: 0, False: 2.49k]
  ------------------
  452|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  453|      0|    }
  454|       |
  455|  2.49k|    if (netsnmp_ds_configs == NULL) {
  ------------------
  |  Branch (455:9): [True: 58, False: 2.43k]
  ------------------
  456|     58|        netsnmp_ds_configs = SNMP_MALLOC_TYPEDEF(netsnmp_ds_read_config);
  ------------------
  |  |   73|     58|#define SNMP_MALLOC_TYPEDEF(td)  (td *) calloc(1, sizeof(td))
  ------------------
  457|     58|        if (netsnmp_ds_configs == NULL)
  ------------------
  |  Branch (457:13): [True: 0, False: 58]
  ------------------
  458|      0|            return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  459|     58|        drsp = netsnmp_ds_configs;
  460|  2.43k|    } else {
  461|  98.2k|        for (drsp = netsnmp_ds_configs; drsp->next != NULL; drsp = drsp->next);
  ------------------
  |  Branch (461:41): [True: 95.8k, False: 2.43k]
  ------------------
  462|  2.43k|        drsp->next = SNMP_MALLOC_TYPEDEF(netsnmp_ds_read_config);
  ------------------
  |  |   73|  2.43k|#define SNMP_MALLOC_TYPEDEF(td)  (td *) calloc(1, sizeof(td))
  ------------------
  463|  2.43k|        if (drsp->next == NULL)
  ------------------
  |  Branch (463:13): [True: 0, False: 2.43k]
  ------------------
  464|      0|            return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  465|  2.43k|        drsp = drsp->next;
  466|  2.43k|    }
  467|       |
  468|  2.49k|    drsp->type    = type;
  469|  2.49k|    drsp->ftype   = strdup(ftype);
  470|  2.49k|    drsp->token   = strdup(token);
  471|  2.49k|    drsp->storeid = storeid;
  472|  2.49k|    drsp->which   = which;
  473|       |
  474|  2.49k|    switch (type) {
  ------------------
  |  Branch (474:13): [True: 2.49k, False: 0]
  ------------------
  475|    754|    case ASN_BOOLEAN:
  ------------------
  |  |   72|    754|#define ASN_BOOLEAN	    0x01U
  ------------------
  |  Branch (475:5): [True: 754, False: 1.74k]
  ------------------
  476|    754|        register_config_handler(ftype, token, netsnmp_ds_handle_config, NULL,
  477|    754|                                "(1|yes|true|0|no|false)");
  478|    754|        break;
  479|       |
  480|    464|    case ASN_INTEGER:
  ------------------
  |  |   75|    464|#define ASN_INTEGER	    0x02U
  ------------------
  |  Branch (480:5): [True: 464, False: 2.03k]
  ------------------
  481|    464|        register_config_handler(ftype, token, netsnmp_ds_handle_config, NULL,
  482|    464|                                "integerValue");
  483|    464|        break;
  484|       |
  485|  1.27k|    case ASN_OCTET_STR:
  ------------------
  |  |   78|  1.27k|#define ASN_OCTET_STR	    0x04U
  ------------------
  |  Branch (485:5): [True: 1.27k, False: 1.21k]
  ------------------
  486|  1.27k|        register_config_handler(ftype, token, netsnmp_ds_handle_config, NULL,
  487|  1.27k|                                "string");
  488|  1.27k|        break;
  489|       |
  490|  2.49k|    }
  491|  2.49k|    return SNMPERR_SUCCESS;
  ------------------
  |  |  184|  2.49k|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  492|  2.49k|}
netsnmp_ds_register_premib:
  497|  1.33k|{
  498|  1.33k|    netsnmp_ds_read_config *drsp;
  499|       |
  500|  1.33k|    if (storeid < 0 || storeid >= NETSNMP_DS_MAX_IDS    || 
  ------------------
  |  |   38|  2.66k|#define NETSNMP_DS_MAX_IDS 3
  ------------------
  |  Branch (500:9): [True: 0, False: 1.33k]
  |  Branch (500:24): [True: 0, False: 1.33k]
  ------------------
  501|  1.33k|	which   < 0 || which   >= NETSNMP_DS_MAX_SUBIDS || token == NULL) {
  ------------------
  |  |   39|  2.66k|#define NETSNMP_DS_MAX_SUBIDS 64        /* needs to be a multiple of 8 */
  ------------------
  |  Branch (501:2): [True: 0, False: 1.33k]
  |  Branch (501:17): [True: 0, False: 1.33k]
  |  Branch (501:53): [True: 0, False: 1.33k]
  ------------------
  502|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  503|      0|    }
  504|       |
  505|  1.33k|    if (netsnmp_ds_configs == NULL) {
  ------------------
  |  Branch (505:9): [True: 0, False: 1.33k]
  ------------------
  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|  1.33k|    } else {
  511|  26.1k|        for (drsp = netsnmp_ds_configs; drsp->next != NULL; drsp = drsp->next);
  ------------------
  |  Branch (511:41): [True: 24.8k, False: 1.33k]
  ------------------
  512|  1.33k|        drsp->next = SNMP_MALLOC_TYPEDEF(netsnmp_ds_read_config);
  ------------------
  |  |   73|  1.33k|#define SNMP_MALLOC_TYPEDEF(td)  (td *) calloc(1, sizeof(td))
  ------------------
  513|  1.33k|        if (drsp->next == NULL)
  ------------------
  |  Branch (513:13): [True: 0, False: 1.33k]
  ------------------
  514|      0|            return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  515|  1.33k|        drsp = drsp->next;
  516|  1.33k|    }
  517|       |
  518|  1.33k|    drsp->type    = type;
  519|  1.33k|    drsp->ftype   = strdup(ftype);
  520|  1.33k|    drsp->token   = strdup(token);
  521|  1.33k|    drsp->storeid = storeid;
  522|  1.33k|    drsp->which   = which;
  523|       |
  524|  1.33k|    switch (type) {
  ------------------
  |  Branch (524:13): [True: 1.33k, False: 0]
  ------------------
  525|    986|    case ASN_BOOLEAN:
  ------------------
  |  |   72|    986|#define ASN_BOOLEAN	    0x01U
  ------------------
  |  Branch (525:5): [True: 986, False: 348]
  ------------------
  526|    986|        register_prenetsnmp_mib_handler(ftype, token, netsnmp_ds_handle_config,
  527|    986|                                        NULL, "(1|yes|true|0|no|false)");
  528|    986|        break;
  529|       |
  530|    232|    case ASN_INTEGER:
  ------------------
  |  |   75|    232|#define ASN_INTEGER	    0x02U
  ------------------
  |  Branch (530:5): [True: 232, False: 1.10k]
  ------------------
  531|    232|        register_prenetsnmp_mib_handler(ftype, token, netsnmp_ds_handle_config,
  532|    232|                                        NULL, "integerValue");
  533|    232|        break;
  534|       |
  535|    116|    case ASN_OCTET_STR:
  ------------------
  |  |   78|    116|#define ASN_OCTET_STR	    0x04U
  ------------------
  |  Branch (535:5): [True: 116, False: 1.21k]
  ------------------
  536|    116|        register_prenetsnmp_mib_handler(ftype, token, netsnmp_ds_handle_config,
  537|    116|                                        NULL, "string");
  538|    116|        break;
  539|       |
  540|  1.33k|    }
  541|  1.33k|    return SNMPERR_SUCCESS;
  ------------------
  |  |  184|  1.33k|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  542|  1.33k|}
netsnmp_ds_shutdown:
  546|     58|{
  547|     58|    netsnmp_ds_read_config *drsp;
  548|     58|    int             i, j;
  549|       |
  550|     58|    snmp_res_lock(MT_LIBRARY_ID, MT_LIB_SESSION);
  ------------------
  |  |   79|     58|#define snmp_res_lock(x,y) do {} while (0)
  |  |  ------------------
  |  |  |  Branch (79:41): [Folded, False: 58]
  |  |  ------------------
  ------------------
  551|  3.88k|    for (drsp = netsnmp_ds_configs; drsp; drsp = netsnmp_ds_configs) {
  ------------------
  |  Branch (551:37): [True: 3.82k, False: 58]
  ------------------
  552|  3.82k|        netsnmp_ds_configs = drsp->next;
  553|       |
  554|  3.82k|        if (drsp->ftype && drsp->token) {
  ------------------
  |  Branch (554:13): [True: 3.82k, False: 0]
  |  Branch (554:28): [True: 3.82k, False: 0]
  ------------------
  555|  3.82k|            unregister_config_handler(drsp->ftype, drsp->token);
  556|  3.82k|        }
  557|  3.82k|	if (drsp->ftype != NULL) {
  ------------------
  |  Branch (557:6): [True: 3.82k, False: 0]
  ------------------
  558|  3.82k|	    free(drsp->ftype);
  559|  3.82k|	}
  560|  3.82k|	if (drsp->token != NULL) {
  ------------------
  |  Branch (560:6): [True: 3.82k, False: 0]
  ------------------
  561|  3.82k|	    free(drsp->token);
  562|  3.82k|	}
  563|  3.82k|        free(drsp);
  564|  3.82k|    }
  565|       |
  566|    232|    for (i = 0; i < NETSNMP_DS_MAX_IDS; i++) {
  ------------------
  |  |   38|    232|#define NETSNMP_DS_MAX_IDS 3
  ------------------
  |  Branch (566:17): [True: 174, False: 58]
  ------------------
  567|  11.3k|        for (j = 0; j < NETSNMP_DS_MAX_SUBIDS; j++) {
  ------------------
  |  |   39|  11.3k|#define NETSNMP_DS_MAX_SUBIDS 64        /* needs to be a multiple of 8 */
  ------------------
  |  Branch (567:21): [True: 11.1k, False: 174]
  ------------------
  568|  11.1k|            if (netsnmp_ds_strings[i][j] != NULL) {
  ------------------
  |  Branch (568:17): [True: 175, False: 10.9k]
  ------------------
  569|    175|                free(netsnmp_ds_strings[i][j]);
  570|    175|                netsnmp_ds_strings[i][j] = NULL;
  571|    175|            }
  572|  11.1k|        }
  573|    174|    }
  574|     58|    snmp_res_unlock(MT_LIBRARY_ID, MT_LIB_SESSION);
  ------------------
  |  |   80|     58|#define snmp_res_unlock(x,y) do {} while (0)
  |  |  ------------------
  |  |  |  Branch (80:43): [Folded, False: 58]
  |  |  ------------------
  ------------------
  575|     58|}

netsnmp_large_fd_setfd:
  122|     57|{
  123|     57|    netsnmp_assert(fd >= 0);
  ------------------
  |  |   47|     57|#      define netsnmp_assert(x)  do { \
  |  |   48|     57|              if ( x ) \
  |  |  ------------------
  |  |  |  Branch (48:20): [True: 57, False: 0]
  |  |  ------------------
  |  |   49|     57|                 ; \
  |  |   50|     57|              else \
  |  |   51|     57|                 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
  |  |  |  |  ------------------
  |  |  |  |  |  | 1727|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|     57|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded, False: 57]
  |  |  ------------------
  ------------------
  124|       |
  125|     57|    while (fd >= (int)fdset->lfs_setsize) {
  ------------------
  |  Branch (125:12): [True: 0, False: 57]
  ------------------
  126|      0|        if (!netsnmp_large_fd_set_resize(fdset, 2 * (fdset->lfs_setsize + 1)))
  ------------------
  |  Branch (126:13): [True: 0, False: 0]
  ------------------
  127|      0|            return;
  128|      0|    }
  129|       |
  130|     57|    LFD_SET(fd, fdset->lfs_setptr);
  131|     57|}
netsnmp_large_fd_is_set:
  144|     57|{
  145|     57|    netsnmp_assert(fd >= 0);
  ------------------
  |  |   47|     57|#      define netsnmp_assert(x)  do { \
  |  |   48|     57|              if ( x ) \
  |  |  ------------------
  |  |  |  Branch (48:20): [True: 57, False: 0]
  |  |  ------------------
  |  |   49|     57|                 ; \
  |  |   50|     57|              else \
  |  |   51|     57|                 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
  |  |  |  |  ------------------
  |  |  |  |  |  | 1727|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|     57|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded, False: 57]
  |  |  ------------------
  ------------------
  146|       |
  147|     57|    return ((unsigned)fd < fdset->lfs_setsize &&
  ------------------
  |  Branch (147:13): [True: 57, False: 0]
  ------------------
  148|     57|            LFD_ISSET(fd, fdset->lfs_setptr));
  ------------------
  |  Branch (148:13): [True: 57, False: 0]
  ------------------
  149|     57|}
netsnmp_large_fd_set_init:
  155|    114|{
  156|    114|    fdset->lfs_setsize = 0;
  157|    114|    fdset->lfs_setptr  = NULL;
  158|       |#if !defined(cygwin) && defined(HAVE_WINSOCK_H)
  159|       |    fdset->lfs_set.fd_count = 0;
  160|       |#endif
  161|    114|    netsnmp_large_fd_set_resize(fdset, setsize);
  162|    114|}
netsnmp_large_fd_set_resize:
  205|    342|{
  206|    342|    int             fd_set_bytes;
  207|       |
  208|    342|    if (fdset->lfs_setsize == setsize)
  ------------------
  |  Branch (208:9): [True: 114, False: 228]
  ------------------
  209|    114|        goto success;
  210|       |
  211|    228|    if (setsize > FD_SETSIZE) {
  ------------------
  |  Branch (211:9): [True: 0, False: 228]
  ------------------
  212|      0|        fd_set         *new_setptr;
  213|       |
  214|      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])
  |  |  ------------------
  ------------------
  215|      0|        if (fdset->lfs_setsize > FD_SETSIZE) {
  ------------------
  |  Branch (215:13): [True: 0, False: 0]
  ------------------
  216|      0|            new_setptr = realloc(fdset->lfs_setptr, fd_set_bytes);
  217|      0|            if (!new_setptr)
  ------------------
  |  Branch (217:17): [True: 0, False: 0]
  ------------------
  218|      0|                goto out_of_mem;
  219|      0|            fdset->lfs_setptr = new_setptr;
  220|      0|        } else {
  221|      0|            new_setptr = malloc(fd_set_bytes);
  222|      0|            if (!new_setptr)
  ------------------
  |  Branch (222:17): [True: 0, False: 0]
  ------------------
  223|      0|                goto out_of_mem;
  224|      0|            fdset->lfs_setptr = new_setptr;
  225|      0|            *fdset->lfs_setptr = fdset->lfs_set;
  226|      0|        }
  227|    228|    } else {
  228|    228|        if (fdset->lfs_setsize > FD_SETSIZE) {
  ------------------
  |  Branch (228:13): [True: 0, False: 228]
  ------------------
  229|      0|            fdset->lfs_set = *fdset->lfs_setptr;
  230|      0|            free(fdset->lfs_setptr);
  231|      0|        }
  232|    228|        fdset->lfs_setptr = &fdset->lfs_set;
  233|    228|    }
  234|       |
  235|    228|#if defined(cygwin) || !defined(HAVE_WINSOCK_H)
  236|       |    /*
  237|       |     * Unix: when enlarging, clear the file descriptors defined in the
  238|       |     * resized *fdset but that were not defined in the original *fdset.
  239|       |     */
  240|    228|    if ( fdset->lfs_setsize == 0 && setsize == FD_SETSIZE ) {
  ------------------
  |  Branch (240:10): [True: 114, False: 114]
  |  Branch (240:37): [True: 114, False: 0]
  ------------------
  241|       |        /* In this case we can use the OS's FD_ZERO */
  242|    114|        FD_ZERO(fdset->lfs_setptr);
  ------------------
  |  Branch (242:9): [Folded, False: 114]
  ------------------
  243|    114|    } else {
  244|    114|        int             i;
  245|       |
  246|    114|        for (i = fdset->lfs_setsize; i < setsize; i++)
  ------------------
  |  Branch (246:38): [True: 0, False: 114]
  ------------------
  247|      0|            LFD_CLR(i, fdset->lfs_setptr);
  248|    114|    }
  249|    228|#endif
  250|       |
  251|    228|    fdset->lfs_setsize = setsize;
  252|       |#if !defined(cygwin) && defined(HAVE_WINSOCK_H)
  253|       |    if (setsize < fdset->lfs_setptr->fd_count)
  254|       |        fdset->lfs_setptr->fd_count = setsize;
  255|       |#endif
  256|    342|success:
  257|    342|    return 1;
  258|       |
  259|      0|out_of_mem:
  260|      0|    return 0;
  261|    228|}
netsnmp_large_fd_set_cleanup:
  265|    114|{
  266|    114|    netsnmp_large_fd_set_resize(fdset, 0);
  267|    114|    fdset->lfs_setsize = 0;
  268|       |    fdset->lfs_setptr  = NULL;
  269|    114|}
netsnmp_copy_fd_set_to_large_fd_set:
  274|    114|{
  275|       |    netsnmp_large_fd_set_resize(dst, FD_SETSIZE);
  276|    114|    *dst->lfs_setptr = *src;
  277|    114|}
netsnmp_copy_large_fd_set_to_fd_set:
  282|     57|{
  283|       |    /* Report failure if *src is larger than FD_SETSIZE. */
  284|     57|    if (src->lfs_setsize > FD_SETSIZE) {
  ------------------
  |  Branch (284:9): [True: 0, False: 57]
  ------------------
  285|      0|        FD_ZERO(dst);
  ------------------
  |  Branch (285:9): [Folded, False: 0]
  ------------------
  286|      0|        return -1;
  287|      0|    }
  288|       |
  289|     57|    *dst = *src->lfs_setptr;
  290|       |
  291|     57|#if !(!defined(cygwin) && defined(HAVE_WINSOCK_H))
  292|     57|    {
  293|     57|        int             i;
  294|       |
  295|       |        /* Unix: clear any file descriptors defined in *dst but not in *src. */
  296|     57|        for (i = src->lfs_setsize; i < FD_SETSIZE; ++i)
  ------------------
  |  Branch (296:36): [True: 0, False: 57]
  ------------------
  297|     57|            FD_CLR(i, dst);
  298|     57|    }
  299|     57|#endif
  300|       |
  301|     57|    return 0;
  302|     57|}
large_fd_set.c:LFD_SET:
   97|     57|{
   98|     57|    enum { nfdbits = 8 * sizeof(p->fds_bits[0]) };
   99|     57|    NETSNMP_FD_MASK_TYPE *fds_array = p->fds_bits;
  ------------------
  |  | 1721|     57|#define NETSNMP_FD_MASK_TYPE __fd_mask
  ------------------
  100|       |
  101|     57|    fds_array[n / nfdbits] |= (1ULL << (n % nfdbits));
  102|     57|}
large_fd_set.c:LFD_ISSET:
  113|     57|{
  114|     57|    enum { nfdbits = 8 * sizeof(p->fds_bits[0]) };
  115|     57|    const NETSNMP_FD_MASK_TYPE *fds_array = p->fds_bits;
  116|       |
  117|     57|    return (fds_array[n / nfdbits] & (1ULL << (n % nfdbits))) != 0;
  118|     57|}

free_etimelist:
  298|     58|{
  299|     58|     int index = 0;
  300|     58|     Enginetime e = NULL;
  301|     58|     Enginetime nextE = NULL;
  302|       |
  303|  1.39k|     for( ; index < ETIMELIST_SIZE; ++index)
  ------------------
  |  |   21|  1.39k|#define ETIMELIST_SIZE	23
  ------------------
  |  Branch (303:13): [True: 1.33k, False: 58]
  ------------------
  304|  1.33k|     {
  305|  1.33k|           e = etimelist[index];
  306|       |
  307|  1.39k|           while(e != NULL)
  ------------------
  |  Branch (307:18): [True: 58, False: 1.33k]
  ------------------
  308|     58|           {
  309|     58|                 nextE = e->next;
  310|     58|                 SNMP_FREE(e->engineID);
  ------------------
  |  |   62|     58|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 58, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 58]
  |  |  ------------------
  ------------------
  311|     58|                 SNMP_FREE(e);
  ------------------
  |  |   62|     58|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 58, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 58]
  |  |  ------------------
  ------------------
  312|     58|                 e = nextE;
  313|     58|           }
  314|       |
  315|       |           etimelist[index] = NULL;
  316|  1.33k|     }
  317|     58|     return;
  318|     58|}
set_enginetime:
  347|     58|{
  348|     58|    int             rval = SNMPERR_SUCCESS, iindex;
  ------------------
  |  |  184|     58|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  349|     58|    Enginetime      e = NULL;
  350|       |
  351|       |
  352|       |
  353|       |    /*
  354|       |     * Sanity check.
  355|       |     */
  356|     58|    if (!engineID || (engineID_len <= 0)) {
  ------------------
  |  Branch (356:9): [True: 0, False: 58]
  |  Branch (356:22): [True: 0, False: 58]
  ------------------
  357|      0|        return rval;
  358|      0|    }
  359|       |
  360|       |
  361|       |    /*
  362|       |     * Store the given <engine_time, engineboot> tuple in the record
  363|       |     * for engineID.  Create a new record if necessary.
  364|       |     */
  365|     58|    if (!(e = search_enginetime_list(engineID, engineID_len))) {
  ------------------
  |  Branch (365:9): [True: 58, False: 0]
  ------------------
  366|     58|        if ((iindex = hash_engineID(engineID, engineID_len)) < 0) {
  ------------------
  |  Branch (366:13): [True: 0, False: 58]
  ------------------
  367|      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|	}
  ------------------
  368|      0|        }
  369|       |
  370|     58|        e = calloc(1, sizeof(*e));
  371|     58|        if (!e) {
  ------------------
  |  Branch (371:13): [True: 0, False: 58]
  ------------------
  372|      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|	}
  ------------------
  373|      0|        }
  374|       |
  375|     58|        e->engineID = calloc(1, engineID_len);
  376|     58|        if (!e->engineID) {
  ------------------
  |  Branch (376:13): [True: 0, False: 58]
  ------------------
  377|      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|	}
  ------------------
  378|      0|        }
  379|     58|        memcpy(e->engineID, engineID, engineID_len);
  380|       |
  381|     58|        e->engineID_len = engineID_len;
  382|     58|        e->next = etimelist[iindex];
  383|     58|        etimelist[iindex] = e;
  384|     58|    }
  385|     58|#ifdef LCD_TIME_SYNC_OPT
  386|     58|    if (authenticated || !e->authenticatedFlag) {
  ------------------
  |  Branch (386:9): [True: 58, False: 0]
  |  Branch (386:26): [True: 0, False: 0]
  ------------------
  387|     58|        e->authenticatedFlag = authenticated;
  388|       |#else
  389|       |    if (authenticated) {
  390|       |#endif
  391|     58|        e->engineTime = engine_time;
  392|     58|        e->engineBoot = engineboot;
  393|     58|        e->lastReceivedEngineTime = snmpv3_local_snmpEngineTime();
  394|     58|    }
  395|       |
  396|     58|    e = NULL;                   /* Indicates a successful update. */
  397|       |
  398|     58|    DEBUGMSGTL(("lcd_set_enginetime", "engineID "));
  ------------------
  |  |   66|     58|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     58|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 58]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 58]
  |  |  ------------------
  ------------------
  399|     58|    DEBUGMSGHEX(("lcd_set_enginetime", engineID, engineID_len));
  ------------------
  |  |   71|     58|#define DEBUGMSGHEX(x)     do {if (_DBG_IF_) {__DBGMSGHEX(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     58|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 58]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGHEX(x)     do {if (_DBG_IF_) {__DBGMSGHEX(x);} }while(0)
  |  |  ------------------
  |  |  |  |  169|      0|#define __DBGMSGHEX(x)     debugmsg_hex x
  |  |  ------------------
  |  |  |  Branch (71:71): [Folded, False: 58]
  |  |  ------------------
  ------------------
  400|     58|    DEBUGMSG(("lcd_set_enginetime", ": boots=%d, time=%d\n", engineboot,
  ------------------
  |  |   61|     58|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  144|     58|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 58]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (61:67): [Folded, False: 58]
  |  |  ------------------
  ------------------
  401|     58|              engine_time));
  402|       |
  403|     58|  set_enginetime_quit:
  404|     58|    SNMP_FREE(e);
  ------------------
  |  |   62|     58|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 58]
  |  |  |  Branch (62:66): [Folded, False: 58]
  |  |  ------------------
  ------------------
  405|       |
  406|     58|    return rval;
  407|       |
  408|     58|}                               /* end set_enginetime() */
search_enginetime_list:
  431|     58|{
  432|     58|    int             rval = SNMPERR_SUCCESS;
  ------------------
  |  |  184|     58|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  433|     58|    Enginetime      e = NULL;
  434|       |
  435|       |
  436|       |    /*
  437|       |     * Sanity check.
  438|       |     */
  439|     58|    if (!engineID || (engineID_len <= 0)) {
  ------------------
  |  Branch (439:9): [True: 0, False: 58]
  |  Branch (439:22): [True: 0, False: 58]
  ------------------
  440|      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|	}
  ------------------
  441|      0|    }
  442|       |
  443|       |
  444|       |    /*
  445|       |     * Find the entry for engineID if there be one.
  446|       |     */
  447|     58|    rval = hash_engineID(engineID, engineID_len);
  448|     58|    if (rval < 0) {
  ------------------
  |  Branch (448:9): [True: 0, False: 58]
  ------------------
  449|      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|	}
  ------------------
  450|      0|    }
  451|     58|    e = etimelist[rval];
  452|       |
  453|     58|    for ( /*EMPTY*/; e; e = e->next) {
  ------------------
  |  Branch (453:22): [True: 0, False: 58]
  ------------------
  454|      0|        if ((engineID_len == e->engineID_len)
  ------------------
  |  Branch (454:13): [True: 0, False: 0]
  ------------------
  455|      0|            && !memcmp(e->engineID, engineID, engineID_len)) {
  ------------------
  |  Branch (455:16): [True: 0, False: 0]
  ------------------
  456|      0|            break;
  457|      0|        }
  458|      0|    }
  459|       |
  460|       |
  461|     58|  search_enginetime_list_quit:
  462|     58|    return e;
  463|       |
  464|     58|}                               /* end search_enginetime_list() */
hash_engineID:
  489|    116|{
  490|    116|    int             rval = SNMPERR_GENERR;
  ------------------
  |  |  185|    116|#define SNMPERR_GENERR			(-1)
  ------------------
  491|    116|    size_t          buf_len = SNMP_MAXBUF;
  ------------------
  |  |   43|    116|#define SNMP_MAXBUF		(1024 * 4)
  ------------------
  492|    116|    u_int           additive = 0;
  493|    116|    u_char         *bufp, buf[SNMP_MAXBUF];
  494|    116|    void           *context = NULL;
  495|       |
  496|       |
  497|       |
  498|       |    /*
  499|       |     * Sanity check.
  500|       |     */
  501|    116|    if (!engineID || (engineID_len <= 0)) {
  ------------------
  |  Branch (501:9): [True: 0, False: 116]
  |  Branch (501:22): [True: 0, False: 116]
  ------------------
  502|      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|	}
  ------------------
  503|      0|    }
  504|       |
  505|       |
  506|       |    /*
  507|       |     * Hash engineID into a list index.
  508|       |     */
  509|    116|#ifndef NETSNMP_DISABLE_MD5
  510|    116|    rval = sc_hash(usmHMACMD5AuthProtocol,
  511|    116|                   OID_LENGTH(usmHMACMD5AuthProtocol),
  ------------------
  |  |   64|    116|    (sizeof(x) / sizeof((x)[0]) +                                       \
  |  |   65|    116|     sizeof(int[-__builtin_types_compatible_p(typeof(x), typeof(&(x)[0]))]))
  ------------------
  512|    116|                   engineID, engineID_len, buf, &buf_len);
  513|    116|    if (rval == SNMPERR_SC_NOT_CONFIGURED) {
  ------------------
  |  |  223|    116|#define SNMPERR_SC_NOT_CONFIGURED	(-39)
  ------------------
  |  Branch (513:9): [True: 0, False: 116]
  ------------------
  514|       |        /* fall back to sha1 */
  515|      0|        rval = sc_hash(usmHMACSHA1AuthProtocol,
  516|      0|                   OID_LENGTH(usmHMACSHA1AuthProtocol),
  ------------------
  |  |   64|      0|    (sizeof(x) / sizeof((x)[0]) +                                       \
  |  |   65|      0|     sizeof(int[-__builtin_types_compatible_p(typeof(x), typeof(&(x)[0]))]))
  ------------------
  517|      0|                   engineID, engineID_len, buf, &buf_len);
  518|      0|    }
  519|       |#else
  520|       |    rval = sc_hash(usmHMACSHA1AuthProtocol,
  521|       |                   OID_LENGTH(usmHMACSHA1AuthProtocol),
  522|       |                   engineID, engineID_len, buf, &buf_len);
  523|       |#endif
  524|    116|    QUITFUN(rval, hash_engineID_quit);
  ------------------
  |  |  143|    116|	if ( (e) != SNMPERR_SUCCESS) {	\
  |  |  ------------------
  |  |  |  |  184|    116|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  ------------------
  |  |  |  Branch (143:7): [True: 0, False: 116]
  |  |  ------------------
  |  |  144|      0|		rval = SNMPERR_GENERR;	\
  |  |  ------------------
  |  |  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  |  |  ------------------
  |  |  145|      0|		goto l ;		\
  |  |  146|      0|	}
  ------------------
  525|       |
  526|    580|    for (bufp = buf; (bufp - buf) < (int) buf_len; bufp += 4) {
  ------------------
  |  Branch (526:22): [True: 464, False: 116]
  ------------------
  527|    464|        additive += (u_int) * bufp;
  528|    464|    }
  529|       |
  530|    116|  hash_engineID_quit:
  531|    116|    SNMP_FREE(context);
  ------------------
  |  |   62|    116|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 116]
  |  |  |  Branch (62:66): [Folded, False: 116]
  |  |  ------------------
  ------------------
  532|    116|    memset(buf, 0, SNMP_MAXBUF);
  ------------------
  |  |   43|    116|#define SNMP_MAXBUF		(1024 * 4)
  ------------------
  533|       |
  534|    116|    return (rval < 0) ? rval : (int)(additive % ETIMELIST_SIZE);
  ------------------
  |  |   21|    116|#define ETIMELIST_SIZE	23
  ------------------
  |  Branch (534:12): [True: 0, False: 116]
  ------------------
  535|       |
  536|    116|}                               /* end hash_engineID() */

register_mib_handlers:
 2488|     58|{
 2489|     58|#ifndef NETSNMP_DISABLE_MIB_LOADING
 2490|     58|    register_prenetsnmp_mib_handler("snmp", "mibdirs",
 2491|     58|                                    handle_mibdirs_conf, NULL,
 2492|     58|                                    "[mib-dirs|+mib-dirs|-mib-dirs]");
 2493|     58|    register_prenetsnmp_mib_handler("snmp", "mibs",
 2494|     58|                                    handle_mibs_conf, NULL,
 2495|     58|                                    "[mib-tokens|+mib-tokens|-mib-tokens]");
 2496|     58|    register_config_handler("snmp", "mibfile",
 2497|     58|                            handle_mibfile_conf, NULL, "mibfile-to-read");
 2498|       |    /*
 2499|       |     * register the snmp.conf configuration handlers for default
 2500|       |     * parsing behaviour 
 2501|       |     */
 2502|       |
 2503|     58|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "showMibErrors",
  ------------------
  |  |   72|     58|#define ASN_BOOLEAN	    0x01U
  ------------------
 2504|     58|                       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_MIB_ERRORS);
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                     NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_MIB_ERRORS);
  ------------------
  |  |   59|     58|#define NETSNMP_DS_LIB_MIB_ERRORS          0
  ------------------
 2505|     58|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "commentToEOL",     /* Describes actual behaviour */
  ------------------
  |  |   72|     58|#define ASN_BOOLEAN	    0x01U
  ------------------
 2506|     58|                       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_MIB_COMMENT_TERM);
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                     NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_MIB_COMMENT_TERM);
  ------------------
  |  |   61|     58|#define NETSNMP_DS_LIB_MIB_COMMENT_TERM    2
  ------------------
 2507|     58|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "strictCommentTerm",    /* Backward compatibility */
  ------------------
  |  |   72|     58|#define ASN_BOOLEAN	    0x01U
  ------------------
 2508|     58|                       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_MIB_COMMENT_TERM);
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                     NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_MIB_COMMENT_TERM);
  ------------------
  |  |   61|     58|#define NETSNMP_DS_LIB_MIB_COMMENT_TERM    2
  ------------------
 2509|     58|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "mibAllowUnderline",
  ------------------
  |  |   72|     58|#define ASN_BOOLEAN	    0x01U
  ------------------
 2510|     58|                       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_MIB_PARSE_LABEL);
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                     NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_MIB_PARSE_LABEL);
  ------------------
  |  |   62|     58|#define NETSNMP_DS_LIB_MIB_PARSE_LABEL     3
  ------------------
 2511|     58|    netsnmp_ds_register_premib(ASN_INTEGER, "snmp", "mibWarningLevel",
  ------------------
  |  |   75|     58|#define ASN_INTEGER	    0x02U
  ------------------
 2512|     58|                       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_MIB_WARNINGS);
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                     NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_MIB_WARNINGS);
  ------------------
  |  |  114|     58|#define NETSNMP_DS_LIB_MIB_WARNINGS         0
  ------------------
 2513|     58|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "mibReplaceWithLatest",
  ------------------
  |  |   72|     58|#define ASN_BOOLEAN	    0x01U
  ------------------
 2514|     58|                       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_MIB_REPLACE);
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                     NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_MIB_REPLACE);
  ------------------
  |  |   67|     58|#define NETSNMP_DS_LIB_MIB_REPLACE         7    /* replace objects from latest module */
  ------------------
 2515|     58|#endif
 2516|       |
 2517|     58|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "printNumericEnums",
  ------------------
  |  |   72|     58|#define ASN_BOOLEAN	    0x01U
  ------------------
 2518|     58|                       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_PRINT_NUMERIC_ENUM);
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                     NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_PRINT_NUMERIC_ENUM);
  ------------------
  |  |   68|     58|#define NETSNMP_DS_LIB_PRINT_NUMERIC_ENUM  8    /* print only numeric enum values */
  ------------------
 2519|     58|    register_prenetsnmp_mib_handler("snmp", "printNumericOids",
 2520|     58|                       handle_print_numeric, NULL, "(1|yes|true|0|no|false)");
 2521|     58|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "escapeQuotes",
  ------------------
  |  |   72|     58|#define ASN_BOOLEAN	    0x01U
  ------------------
 2522|     58|                       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_ESCAPE_QUOTES);
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                     NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_ESCAPE_QUOTES);
  ------------------
  |  |   79|     58|#define NETSNMP_DS_LIB_ESCAPE_QUOTES       19   /* shell escape quote marks in oids */
  ------------------
 2523|     58|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "dontBreakdownOids",
  ------------------
  |  |   72|     58|#define ASN_BOOLEAN	    0x01U
  ------------------
 2524|     58|                       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DONT_BREAKDOWN_OIDS);
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                     NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DONT_BREAKDOWN_OIDS);
  ------------------
  |  |   70|     58|#define NETSNMP_DS_LIB_DONT_BREAKDOWN_OIDS 10   /* dont print oid indexes specially */
  ------------------
 2525|     58|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "quickPrinting",
  ------------------
  |  |   72|     58|#define ASN_BOOLEAN	    0x01U
  ------------------
 2526|     58|                       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICK_PRINT);
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                     NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICK_PRINT);
  ------------------
  |  |   73|     58|#define NETSNMP_DS_LIB_QUICK_PRINT         13   /* print very brief output for parsing */
  ------------------
 2527|     58|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "numericTimeticks",
  ------------------
  |  |   72|     58|#define ASN_BOOLEAN	    0x01U
  ------------------
 2528|     58|                       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_NUMERIC_TIMETICKS);
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                     NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_NUMERIC_TIMETICKS);
  ------------------
  |  |   78|     58|#define NETSNMP_DS_LIB_NUMERIC_TIMETICKS   18   /* print timeticks as a number */
  ------------------
 2529|     58|    netsnmp_ds_register_premib(ASN_INTEGER, "snmp", "oidOutputFormat",
  ------------------
  |  |   75|     58|#define ASN_INTEGER	    0x02U
  ------------------
 2530|     58|                       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_OID_OUTPUT_FORMAT);
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                     NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_OID_OUTPUT_FORMAT);
  ------------------
  |  |  118|     58|#define NETSNMP_DS_LIB_OID_OUTPUT_FORMAT    4
  ------------------
 2531|     58|    netsnmp_ds_register_premib(ASN_INTEGER, "snmp", "suffixPrinting",
  ------------------
  |  |   75|     58|#define ASN_INTEGER	    0x02U
  ------------------
 2532|     58|                       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_OID_OUTPUT_FORMAT);
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                     NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_OID_OUTPUT_FORMAT);
  ------------------
  |  |  118|     58|#define NETSNMP_DS_LIB_OID_OUTPUT_FORMAT    4
  ------------------
 2533|     58|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "extendedIndex",
  ------------------
  |  |   72|     58|#define ASN_BOOLEAN	    0x01U
  ------------------
 2534|     58|                       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_EXTENDED_INDEX);
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                     NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_EXTENDED_INDEX);
  ------------------
  |  |   82|     58|#define NETSNMP_DS_LIB_EXTENDED_INDEX	   22   /* print extended index format [x1][x2] */
  ------------------
 2535|     58|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "printHexText",
  ------------------
  |  |   72|     58|#define ASN_BOOLEAN	    0x01U
  ------------------
 2536|     58|                       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_PRINT_HEX_TEXT);
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                     NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_PRINT_HEX_TEXT);
  ------------------
  |  |   83|     58|#define NETSNMP_DS_LIB_PRINT_HEX_TEXT      23   /* print ASCII text along with hex strings */
  ------------------
 2537|     58|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "printValueOnly",
  ------------------
  |  |   72|     58|#define ASN_BOOLEAN	    0x01U
  ------------------
 2538|     58|                       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_PRINT_BARE_VALUE);
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                     NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_PRINT_BARE_VALUE);
  ------------------
  |  |   81|     58|#define NETSNMP_DS_LIB_PRINT_BARE_VALUE	   21   /* just print value (not OID = value) */
  ------------------
 2539|     58|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "dontPrintUnits",
  ------------------
  |  |   72|     58|#define ASN_BOOLEAN	    0x01U
  ------------------
 2540|     58|                       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DONT_PRINT_UNITS);
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                     NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DONT_PRINT_UNITS);
  ------------------
  |  |   89|     58|#define NETSNMP_DS_LIB_DONT_PRINT_UNITS    29 /* don't print UNITS suffix */
  ------------------
 2541|     58|    netsnmp_ds_register_premib(ASN_INTEGER, "snmp", "hexOutputLength",
  ------------------
  |  |   75|     58|#define ASN_INTEGER	    0x02U
  ------------------
 2542|     58|                       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_HEX_OUTPUT_LENGTH);
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                     NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_HEX_OUTPUT_LENGTH);
  ------------------
  |  |  121|     58|#define NETSNMP_DS_LIB_HEX_OUTPUT_LENGTH    6
  ------------------
 2543|     58|}
netsnmp_set_mib_directory:
 2558|    115|{
 2559|    115|    const char *newdir;
 2560|    115|    char *olddir, *tmpdir = NULL;
 2561|       |
 2562|    115|    DEBUGTRACE;
  ------------------
  |  |   63|    115|#define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
  |  |  ------------------
  |  |  |  |  144|    115|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 115]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
  |  |  ------------------
  |  |  |  |  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 (63:67): [Folded, False: 115]
  |  |  ------------------
  ------------------
 2563|    115|    if (NULL == dir) {
  ------------------
  |  Branch (2563:9): [True: 0, False: 115]
  ------------------
 2564|      0|        return;
 2565|      0|    }
 2566|       |    
 2567|    115|    olddir = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|    115|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 2568|    115|				   NETSNMP_DS_LIB_MIBDIRS);
  ------------------
  |  |  162|    115|#define NETSNMP_DS_LIB_MIBDIRS           11
  ------------------
 2569|    115|    if (olddir) {
  ------------------
  |  Branch (2569:9): [True: 58, False: 57]
  ------------------
 2570|     58|        if ((*dir == '+') || (*dir == '-')) {
  ------------------
  |  Branch (2570:13): [True: 0, False: 58]
  |  Branch (2570:30): [True: 0, False: 58]
  ------------------
 2571|       |            /** New dir starts with '+', thus we add it. */
 2572|      0|            if (*dir++ == '+') {
  ------------------
  |  Branch (2572:17): [True: 0, False: 0]
  ------------------
 2573|      0|                if (asprintf(&tmpdir, "%s%c%s", olddir, ENV_SEPARATOR_CHAR, dir) < 0)
  ------------------
  |  |   70|      0|#define ENV_SEPARATOR_CHAR ':'
  ------------------
  |  Branch (2573:21): [True: 0, False: 0]
  ------------------
 2574|      0|                    tmpdir = NULL;
 2575|      0|            } else {
 2576|      0|                if (asprintf(&tmpdir, "%s%c%s", dir, ENV_SEPARATOR_CHAR, olddir) < 0)
  ------------------
  |  |   70|      0|#define ENV_SEPARATOR_CHAR ':'
  ------------------
  |  Branch (2576:21): [True: 0, False: 0]
  ------------------
 2577|      0|                    tmpdir = NULL;
 2578|      0|            }
 2579|      0|            if (!tmpdir) {
  ------------------
  |  Branch (2579:17): [True: 0, False: 0]
  ------------------
 2580|      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]
  |  |  ------------------
  ------------------
 2581|      0|                return;
 2582|      0|            }
 2583|      0|            newdir = tmpdir;
 2584|     58|        } else {
 2585|     58|            newdir = dir;
 2586|     58|        }
 2587|     58|    } else {
 2588|       |        /** If dir starts with '+' skip '+' it. */
 2589|     57|        newdir = ((*dir == '+') ? ++dir : dir);
  ------------------
  |  Branch (2589:19): [True: 0, False: 57]
  ------------------
 2590|     57|    }
 2591|    115|    netsnmp_ds_set_string(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_MIBDIRS,
  ------------------
  |  |   48|    115|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                  netsnmp_ds_set_string(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_MIBDIRS,
  ------------------
  |  |  162|    115|#define NETSNMP_DS_LIB_MIBDIRS           11
  ------------------
 2592|    115|                          newdir);
 2593|       |
 2594|       |    /** set_string calls strdup, so if we allocated memory, free it */
 2595|    115|    if (tmpdir == newdir) {
  ------------------
  |  Branch (2595:9): [True: 0, False: 115]
  ------------------
 2596|       |        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]
  |  |  ------------------
  ------------------
 2597|      0|    }
 2598|    115|}
netsnmp_get_mib_directory:
 2615|    174|{
 2616|    174|    char *dir;
 2617|       |
 2618|    174|    DEBUGTRACE;
  ------------------
  |  |   63|    174|#define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
  |  |  ------------------
  |  |  |  |  144|    174|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 174]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
  |  |  ------------------
  |  |  |  |  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 (63:67): [Folded, False: 174]
  |  |  ------------------
  ------------------
 2619|    174|    dir = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_MIBDIRS);
  ------------------
  |  |   48|    174|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                  dir = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_MIBDIRS);
  ------------------
  |  |  162|    174|#define NETSNMP_DS_LIB_MIBDIRS           11
  ------------------
 2620|    174|    if (dir == NULL) {
  ------------------
  |  Branch (2620:9): [True: 57, False: 117]
  ------------------
 2621|     57|        DEBUGMSGTL(("get_mib_directory", "no mib directories set\n"));
  ------------------
  |  |   66|     57|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     57|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 57]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 57]
  |  |  ------------------
  ------------------
 2622|       |
 2623|       |        /** Check if the environment variable is set */
 2624|     57|        dir = netsnmp_getenv("MIBDIRS");
 2625|     57|        if (dir == NULL) {
  ------------------
  |  Branch (2625:13): [True: 57, False: 0]
  ------------------
 2626|     57|            DEBUGMSGTL(("get_mib_directory", "no mib directories set by environment\n"));
  ------------------
  |  |   66|     57|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     57|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 57]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 57]
  |  |  ------------------
  ------------------
 2627|       |            /** Not set use hard coded path */
 2628|     57|            if (confmibdir == NULL) {
  ------------------
  |  Branch (2628:17): [True: 57, False: 0]
  ------------------
 2629|     57|                DEBUGMSGTL(("get_mib_directory", "no mib directories set by config\n"));
  ------------------
  |  |   66|     57|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     57|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 57]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 57]
  |  |  ------------------
  ------------------
 2630|     57|                netsnmp_set_mib_directory(NETSNMP_DEFAULT_MIBDIRS);
  ------------------
  |  | 1669|     57|#define NETSNMP_DEFAULT_MIBDIRS "$HOME/.snmp/mibs:/usr/local/net-snmp-master/share/snmp/mibs"
  ------------------
 2631|     57|            }
 2632|      0|            else if ((*confmibdir == '+') || (*confmibdir == '-')) {
  ------------------
  |  Branch (2632:22): [True: 0, False: 0]
  |  Branch (2632:46): [True: 0, False: 0]
  ------------------
 2633|      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]
  |  |  ------------------
  ------------------
 2634|      0|                netsnmp_set_mib_directory(NETSNMP_DEFAULT_MIBDIRS);
  ------------------
  |  | 1669|      0|#define NETSNMP_DEFAULT_MIBDIRS "$HOME/.snmp/mibs:/usr/local/net-snmp-master/share/snmp/mibs"
  ------------------
 2635|      0|                netsnmp_set_mib_directory(confmibdir);
 2636|      0|            }
 2637|      0|            else {
 2638|      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]
  |  |  ------------------
  ------------------
 2639|      0|                netsnmp_set_mib_directory(confmibdir);
 2640|      0|            }
 2641|     57|        } else if ((*dir == '+') || (*dir == '-')) {
  ------------------
  |  Branch (2641:20): [True: 0, False: 0]
  |  Branch (2641:37): [True: 0, False: 0]
  ------------------
 2642|      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]
  |  |  ------------------
  ------------------
 2643|      0|            netsnmp_set_mib_directory(NETSNMP_DEFAULT_MIBDIRS);
  ------------------
  |  | 1669|      0|#define NETSNMP_DEFAULT_MIBDIRS "$HOME/.snmp/mibs:/usr/local/net-snmp-master/share/snmp/mibs"
  ------------------
 2644|      0|            netsnmp_set_mib_directory(dir);
 2645|      0|        } else {
 2646|      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]
  |  |  ------------------
  ------------------
 2647|      0|            netsnmp_set_mib_directory(dir);
 2648|      0|        }
 2649|     57|        dir = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_MIBDIRS);
  ------------------
  |  |   48|     57|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                      dir = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_MIBDIRS);
  ------------------
  |  |  162|     57|#define NETSNMP_DS_LIB_MIBDIRS           11
  ------------------
 2650|     57|    }
 2651|    174|    DEBUGMSGTL(("get_mib_directory", "mib directories set '%s'\n", dir));
  ------------------
  |  |   66|    174|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    174|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 174]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 174]
  |  |  ------------------
  ------------------
 2652|    174|    return(dir);
 2653|    174|}
netsnmp_fixup_mib_directory:
 2662|     58|{
 2663|     58|    const char *homepath = netsnmp_gethomedir();
 2664|     58|    char *mibpath = netsnmp_get_mib_directory();
 2665|     58|    char *oldmibpath = NULL;
 2666|     58|    char *ptr_home;
 2667|     58|    char *new_mibpath;
 2668|     58|    size_t new_mibpath_len;
 2669|       |
 2670|     58|    DEBUGTRACE;
  ------------------
  |  |   63|     58|#define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
  |  |  ------------------
  |  |  |  |  144|     58|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 58]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGTRACE         do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
  |  |  ------------------
  |  |  |  |  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 (63:67): [Folded, False: 58]
  |  |  ------------------
  ------------------
 2671|     58|    if (homepath && mibpath) {
  ------------------
  |  Branch (2671:9): [True: 58, False: 0]
  |  Branch (2671:21): [True: 58, False: 0]
  ------------------
 2672|     58|        DEBUGMSGTL(("fixup_mib_directory", "mib directories '%s'\n", mibpath));
  ------------------
  |  |   66|     58|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     58|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 58]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 58]
  |  |  ------------------
  ------------------
 2673|    115|        while ((ptr_home = strstr(mibpath, "$HOME"))) {
  ------------------
  |  Branch (2673:16): [True: 57, False: 58]
  ------------------
 2674|     57|            new_mibpath_len = strlen(mibpath) - strlen("$HOME") +
 2675|     57|					 strlen(homepath)+1;
 2676|     57|            new_mibpath = (char *)malloc(new_mibpath_len);
 2677|     57|            if (new_mibpath) {
  ------------------
  |  Branch (2677:17): [True: 57, False: 0]
  ------------------
 2678|     57|                *ptr_home = 0; /* null out the spot where we stop copying */
 2679|     57|                snprintf(new_mibpath, new_mibpath_len, "%s%s%s", mibpath, homepath,
 2680|     57|			ptr_home + strlen("$HOME"));
 2681|       |                /** swap in the new value and repeat */
 2682|     57|                mibpath = new_mibpath;
 2683|     57|		if (oldmibpath != NULL) {
  ------------------
  |  Branch (2683:7): [True: 0, False: 57]
  ------------------
 2684|      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]
  |  |  ------------------
  ------------------
 2685|      0|		}
 2686|     57|		oldmibpath = new_mibpath;
 2687|     57|            } else {
 2688|      0|                break;
 2689|      0|            }
 2690|     57|        }
 2691|       |
 2692|     58|        netsnmp_set_mib_directory(mibpath);
 2693|       |	
 2694|       |	/*  The above copies the mibpath for us, so...  */
 2695|       |
 2696|     58|	if (oldmibpath != NULL) {
  ------------------
  |  Branch (2696:6): [True: 57, False: 1]
  ------------------
 2697|     57|	    SNMP_FREE(oldmibpath);
  ------------------
  |  |   62|     57|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 57, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 57]
  |  |  ------------------
  ------------------
 2698|     57|	}
 2699|       |
 2700|     58|    }
 2701|       |
 2702|     58|}
netsnmp_init_mib:
 2711|     58|{
 2712|     58|    const char     *prefix;
 2713|     58|    char           *env_var, *entry;
 2714|     58|    PrefixListPtr   pp = &mib_prefixes[0];
 2715|     58|    char           *st = NULL;
 2716|       |
 2717|     58|    if (Mib)
  ------------------
  |  Branch (2717:9): [True: 0, False: 58]
  ------------------
 2718|      0|        return;
 2719|     58|    netsnmp_init_mib_internals();
 2720|       |
 2721|       |    /*
 2722|       |     * Initialise the MIB directory/ies 
 2723|       |     */
 2724|     58|    netsnmp_fixup_mib_directory();
 2725|     58|    env_var = strdup(netsnmp_get_mib_directory());
 2726|     58|    if (!env_var)
  ------------------
  |  Branch (2726:9): [True: 0, False: 58]
  ------------------
 2727|      0|        return;
 2728|       |
 2729|     58|    DEBUGMSGTL(("init_mib",
  ------------------
  |  |   66|     58|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     58|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 58]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 58]
  |  |  ------------------
  ------------------
 2730|     58|                "Seen MIBDIRS: Looking in '%s' for mib dirs ...\n",
 2731|     58|                env_var));
 2732|       |
 2733|     58|    entry = strtok_r(env_var, ENV_SEPARATOR, &st);
  ------------------
  |  |   67|     58|#define ENV_SEPARATOR ":"
  ------------------
 2734|    173|    while (entry) {
  ------------------
  |  Branch (2734:12): [True: 115, False: 58]
  ------------------
 2735|    115|        add_mibdir(entry);
 2736|    115|        entry = strtok_r(NULL, ENV_SEPARATOR, &st);
  ------------------
  |  |   67|    115|#define ENV_SEPARATOR ":"
  ------------------
 2737|    115|    }
 2738|     58|    SNMP_FREE(env_var);
  ------------------
  |  |   62|     58|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 58, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 58]
  |  |  ------------------
  ------------------
 2739|       |
 2740|     58|    env_var = netsnmp_getenv("MIBFILES");
 2741|     58|    if (env_var != NULL) {
  ------------------
  |  Branch (2741:9): [True: 0, False: 58]
  ------------------
 2742|      0|        if (*env_var == '+')
  ------------------
  |  Branch (2742:13): [True: 0, False: 0]
  ------------------
 2743|      0|            entry = strtok_r(env_var+1, ENV_SEPARATOR, &st);
  ------------------
  |  |   67|      0|#define ENV_SEPARATOR ":"
  ------------------
 2744|      0|        else
 2745|      0|            entry = strtok_r(env_var, ENV_SEPARATOR, &st);
  ------------------
  |  |   67|      0|#define ENV_SEPARATOR ":"
  ------------------
 2746|      0|        while (entry) {
  ------------------
  |  Branch (2746:16): [True: 0, False: 0]
  ------------------
 2747|      0|            add_mibfile(entry, NULL);
 2748|      0|            entry = strtok_r(NULL, ENV_SEPARATOR, &st);
  ------------------
  |  |   67|      0|#define ENV_SEPARATOR ":"
  ------------------
 2749|      0|        }
 2750|      0|    }
 2751|       |
 2752|     58|    netsnmp_init_mib_internals();
 2753|       |
 2754|       |    /*
 2755|       |     * Read in any modules or mibs requested 
 2756|       |     */
 2757|       |
 2758|     58|    env_var = netsnmp_getenv("MIBS");
 2759|     58|    if (env_var == NULL) {
  ------------------
  |  Branch (2759:9): [True: 58, False: 0]
  ------------------
 2760|     58|        if (confmibs != NULL)
  ------------------
  |  Branch (2760:13): [True: 0, False: 58]
  ------------------
 2761|      0|            env_var = strdup(confmibs);
 2762|     58|        else
 2763|     58|            env_var = strdup(NETSNMP_DEFAULT_MIBS);
  ------------------
  |  | 2017|     58|#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"
  ------------------
 2764|     58|    } else {
 2765|      0|        env_var = strdup(env_var);
 2766|      0|    }
 2767|     58|    if (env_var && ((*env_var == '+') || (*env_var == '-'))) {
  ------------------
  |  Branch (2767:9): [True: 58, False: 0]
  |  Branch (2767:21): [True: 0, False: 58]
  |  Branch (2767:42): [True: 0, False: 58]
  ------------------
 2768|      0|        int res;
 2769|       |
 2770|      0|        if (*env_var == '+')
  ------------------
  |  Branch (2770:13): [True: 0, False: 0]
  ------------------
 2771|      0|            res = asprintf(&entry, "%s%c%s", NETSNMP_DEFAULT_MIBS,
  ------------------
  |  | 2017|      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"
  ------------------
 2772|      0|                           ENV_SEPARATOR_CHAR, env_var + 1);
  ------------------
  |  |   70|      0|#define ENV_SEPARATOR_CHAR ':'
  ------------------
 2773|      0|        else
 2774|      0|            res = asprintf(&entry, "%s%c%s", env_var + 1, ENV_SEPARATOR_CHAR,
  ------------------
  |  |   70|      0|#define ENV_SEPARATOR_CHAR ':'
  ------------------
 2775|      0|                           NETSNMP_DEFAULT_MIBS);
  ------------------
  |  | 2017|      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"
  ------------------
 2776|      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]
  |  |  ------------------
  ------------------
 2777|      0|        if (res < 0) {
  ------------------
  |  Branch (2777:13): [True: 0, False: 0]
  ------------------
 2778|      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]
  |  |  ------------------
  ------------------
 2779|      0|            return;
 2780|      0|        }
 2781|      0|        env_var = entry;
 2782|      0|    }
 2783|       |
 2784|     58|    if (env_var != NULL) {
  ------------------
  |  Branch (2784:9): [True: 58, False: 0]
  ------------------
 2785|     58|        DEBUGMSGTL(("init_mib",
  ------------------
  |  |   66|     58|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     58|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 58]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 58]
  |  |  ------------------
  ------------------
 2786|     58|                    "Seen MIBS: Looking in '%s' for mib files ...\n",
 2787|     58|                    env_var));
 2788|     58|        entry = strtok_r(env_var, ENV_SEPARATOR, &st);
  ------------------
  |  |   67|     58|#define ENV_SEPARATOR ":"
  ------------------
 2789|  2.84k|        while (entry) {
  ------------------
  |  Branch (2789:16): [True: 2.78k, False: 58]
  ------------------
 2790|  2.78k|            if (strcasecmp(entry, DEBUG_ALWAYS_TOKEN) == 0) {
  ------------------
  |  |  227|  2.78k|#define DEBUG_ALWAYS_TOKEN "all"
  ------------------
  |  Branch (2790:17): [True: 0, False: 2.78k]
  ------------------
 2791|      0|                read_all_mibs();
 2792|  2.78k|            } else if (strstr(entry, "/") != NULL) {
  ------------------
  |  Branch (2792:24): [True: 0, False: 2.78k]
  ------------------
 2793|      0|                read_mib(entry);
 2794|  2.78k|            } else {
 2795|  2.78k|                netsnmp_read_module(entry);
 2796|  2.78k|            }
 2797|  2.78k|            entry = strtok_r(NULL, ENV_SEPARATOR, &st);
  ------------------
  |  |   67|  2.78k|#define ENV_SEPARATOR ":"
  ------------------
 2798|  2.78k|        }
 2799|     58|        adopt_orphans();
 2800|     58|        SNMP_FREE(env_var);
  ------------------
  |  |   62|     58|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 58, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 58]
  |  |  ------------------
  ------------------
 2801|     58|    }
 2802|       |
 2803|     58|    env_var = netsnmp_getenv("MIBFILES");
 2804|     58|    if (env_var != NULL) {
  ------------------
  |  Branch (2804:9): [True: 0, False: 58]
  ------------------
 2805|      0|        if ((*env_var == '+') || (*env_var == '-')) {
  ------------------
  |  Branch (2805:13): [True: 0, False: 0]
  |  Branch (2805:34): [True: 0, False: 0]
  ------------------
 2806|       |#ifdef NETSNMP_DEFAULT_MIBFILES
 2807|       |            int res;
 2808|       |
 2809|       |            if (*env_var++ == '+')
 2810|       |                res = asprintf(&entry, "%s%c%s", NETSNMP_DEFAULT_MIBFILES,
 2811|       |                               ENV_SEPARATOR_CHAR, env_var);
 2812|       |            else
 2813|       |                res = asprintf(&entry, "%s%c%s", env_var,
 2814|       |                               ENV_SEPARATOR_CHAR, NETSNMP_DEFAULT_MIBFILES);
 2815|       |            if (res >= 0)
 2816|       |                env_var = entry;
 2817|       |            else
 2818|       |                DEBUGMSGTL(("init_mib", "env mibfiles malloc failed"));
 2819|       |#else
 2820|      0|            env_var = strdup(env_var + 1);
 2821|      0|#endif
 2822|      0|        } else {
 2823|      0|            env_var = strdup(env_var);
 2824|      0|        }
 2825|     58|    } else {
 2826|       |#ifdef NETSNMP_DEFAULT_MIBFILES
 2827|       |        env_var = strdup(NETSNMP_DEFAULT_MIBFILES);
 2828|       |#endif
 2829|     58|    }
 2830|       |
 2831|     58|    if (env_var != NULL) {
  ------------------
  |  Branch (2831:9): [True: 0, False: 58]
  ------------------
 2832|      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]
  |  |  ------------------
  ------------------
 2833|      0|                    "Seen MIBFILES: Looking in '%s' for mib files ...\n",
 2834|      0|                    env_var));
 2835|      0|        entry = strtok_r(env_var, ENV_SEPARATOR, &st);
  ------------------
  |  |   67|      0|#define ENV_SEPARATOR ":"
  ------------------
 2836|      0|        while (entry) {
  ------------------
  |  Branch (2836:16): [True: 0, False: 0]
  ------------------
 2837|      0|            read_mib(entry);
 2838|      0|            entry = strtok_r(NULL, ENV_SEPARATOR, &st);
  ------------------
  |  |   67|      0|#define ENV_SEPARATOR ":"
  ------------------
 2839|      0|        }
 2840|      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]
  |  |  ------------------
  ------------------
 2841|      0|    }
 2842|       |
 2843|     58|    prefix = netsnmp_getenv("PREFIX");
 2844|       |
 2845|     58|    if (!prefix)
  ------------------
  |  Branch (2845:9): [True: 58, False: 0]
  ------------------
 2846|     58|        prefix = Standard_Prefix;
 2847|       |
 2848|     58|    Prefix = (char *) malloc(strlen(prefix) + 2);
 2849|     58|    if (!Prefix)
  ------------------
  |  Branch (2849:9): [True: 0, False: 58]
  ------------------
 2850|      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]
  |  |  ------------------
  ------------------
 2851|     58|    else
 2852|     58|        strcpy(Prefix, prefix);
 2853|       |
 2854|     58|    DEBUGMSGTL(("init_mib",
  ------------------
  |  |   66|     58|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     58|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 58]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 58]
  |  |  ------------------
  ------------------
 2855|     58|                "Seen PREFIX: Looking in '%s' for prefix ...\n", Prefix));
 2856|       |
 2857|       |    /*
 2858|       |     * remove trailing dot 
 2859|       |     */
 2860|     58|    if (Prefix) {
  ------------------
  |  Branch (2860:9): [True: 58, False: 0]
  ------------------
 2861|     58|        env_var = &Prefix[strlen(Prefix) - 1];
 2862|     58|        if (*env_var == '.')
  ------------------
  |  Branch (2862:13): [True: 0, False: 58]
  ------------------
 2863|      0|            *env_var = '\0';
 2864|     58|    }
 2865|       |
 2866|     58|    pp->str = Prefix;           /* fixup first mib_prefix entry */
 2867|       |    /*
 2868|       |     * now that the list of prefixes is built, save each string length. 
 2869|       |     */
 2870|    406|    while (pp->str) {
  ------------------
  |  Branch (2870:12): [True: 348, False: 58]
  ------------------
 2871|    348|        pp->len = strlen(pp->str);
 2872|    348|        pp++;
 2873|    348|    }
 2874|       |
 2875|     58|    Mib = tree_head;            /* Backwards compatibility */
 2876|     58|    tree_top = calloc(1, sizeof(struct tree));
 2877|       |    /*
 2878|       |     * XX error check ? 
 2879|       |     */
 2880|     58|    if (tree_top) {
  ------------------
  |  Branch (2880:9): [True: 58, False: 0]
  ------------------
 2881|     58|        tree_top->label = strdup("(top)");
 2882|     58|        tree_top->child_list = tree_head;
 2883|     58|    }
 2884|     58|}
shutdown_mib:
 2900|     58|{
 2901|     58|    unload_all_mibs();
 2902|     58|    if (tree_top) {
  ------------------
  |  Branch (2902:9): [True: 58, False: 0]
  ------------------
 2903|     58|        if (tree_top->label)
  ------------------
  |  Branch (2903:13): [True: 58, False: 0]
  ------------------
 2904|     58|            SNMP_FREE(tree_top->label);
  ------------------
  |  |   62|     58|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 58, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 58]
  |  |  ------------------
  ------------------
 2905|     58|        SNMP_FREE(tree_top);
  ------------------
  |  |   62|     58|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 58, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 58]
  |  |  ------------------
  ------------------
 2906|     58|    }
 2907|     58|    tree_head = NULL;
 2908|     58|    Mib = NULL;
 2909|     58|    if (Prefix != NULL && Prefix != &Standard_Prefix[0])
  ------------------
  |  Branch (2909:9): [True: 58, False: 0]
  |  Branch (2909:27): [True: 58, False: 0]
  ------------------
 2910|     58|        SNMP_FREE(Prefix);
  ------------------
  |  |   62|     58|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 58, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 58]
  |  |  ------------------
  ------------------
 2911|     58|    if (Prefix)
  ------------------
  |  Branch (2911:9): [True: 0, False: 58]
  ------------------
 2912|      0|        Prefix = NULL;
 2913|     58|    SNMP_FREE(confmibs);
  ------------------
  |  |   62|     58|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 58]
  |  |  |  Branch (62:66): [Folded, False: 58]
  |  |  ------------------
  ------------------
 2914|       |    SNMP_FREE(confmibdir);
  ------------------
  |  |   62|     58|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 58]
  |  |  |  Branch (62:66): [Folded, False: 58]
  |  |  ------------------
  ------------------
 2915|     58|}
set_function:
 2947|    174|{
 2948|    174|    subtree->printer = NULL;
 2949|    174|    switch (subtree->type) {
 2950|      0|    case TYPE_OBJID:
  ------------------
  |  |  155|      0|#define TYPE_OBJID          1
  ------------------
  |  Branch (2950:5): [True: 0, False: 174]
  ------------------
 2951|      0|        subtree->printomat = sprint_realloc_object_identifier;
 2952|      0|        break;
 2953|      0|    case TYPE_OCTETSTR:
  ------------------
  |  |  156|      0|#define TYPE_OCTETSTR       2
  ------------------
  |  Branch (2953:5): [True: 0, False: 174]
  ------------------
 2954|      0|        subtree->printomat = sprint_realloc_octet_string;
 2955|      0|        break;
 2956|      0|    case TYPE_INTEGER:
  ------------------
  |  |  157|      0|#define TYPE_INTEGER        3
  ------------------
  |  Branch (2956:5): [True: 0, False: 174]
  ------------------
 2957|      0|        subtree->printomat = sprint_realloc_integer;
 2958|      0|        break;
 2959|      0|    case TYPE_INTEGER32:
  ------------------
  |  |  170|      0|#define TYPE_INTEGER32      16
  ------------------
  |  Branch (2959:5): [True: 0, False: 174]
  ------------------
 2960|      0|        subtree->printomat = sprint_realloc_integer;
 2961|      0|        break;
 2962|      0|    case TYPE_NETADDR:
  ------------------
  |  |  158|      0|#define TYPE_NETADDR        4
  ------------------
  |  Branch (2962:5): [True: 0, False: 174]
  ------------------
 2963|      0|        subtree->printomat = sprint_realloc_networkaddress;
 2964|      0|        break;
 2965|      0|    case TYPE_IPADDR:
  ------------------
  |  |  159|      0|#define TYPE_IPADDR         5
  ------------------
  |  Branch (2965:5): [True: 0, False: 174]
  ------------------
 2966|      0|        subtree->printomat = sprint_realloc_ipaddress;
 2967|      0|        break;
 2968|      0|    case TYPE_COUNTER:
  ------------------
  |  |  160|      0|#define TYPE_COUNTER        6
  ------------------
  |  Branch (2968:5): [True: 0, False: 174]
  ------------------
 2969|      0|        subtree->printomat = sprint_realloc_counter;
 2970|      0|        break;
 2971|      0|    case TYPE_GAUGE:
  ------------------
  |  |  161|      0|#define TYPE_GAUGE          7
  ------------------
  |  Branch (2971:5): [True: 0, False: 174]
  ------------------
 2972|      0|        subtree->printomat = sprint_realloc_gauge;
 2973|      0|        break;
 2974|      0|    case TYPE_TIMETICKS:
  ------------------
  |  |  162|      0|#define TYPE_TIMETICKS      8
  ------------------
  |  Branch (2974:5): [True: 0, False: 174]
  ------------------
 2975|      0|        subtree->printomat = sprint_realloc_timeticks;
 2976|      0|        break;
 2977|      0|    case TYPE_OPAQUE:
  ------------------
  |  |  163|      0|#define TYPE_OPAQUE         9
  ------------------
  |  Branch (2977:5): [True: 0, False: 174]
  ------------------
 2978|      0|        subtree->printomat = sprint_realloc_opaque;
 2979|      0|        break;
 2980|      0|    case TYPE_NULL:
  ------------------
  |  |  164|      0|#define TYPE_NULL           10
  ------------------
  |  Branch (2980:5): [True: 0, False: 174]
  ------------------
 2981|      0|        subtree->printomat = sprint_realloc_null;
 2982|      0|        break;
 2983|      0|    case TYPE_BITSTRING:
  ------------------
  |  |  166|      0|#define TYPE_BITSTRING      12
  ------------------
  |  Branch (2983:5): [True: 0, False: 174]
  ------------------
 2984|      0|        subtree->printomat = sprint_realloc_bitstring;
 2985|      0|        break;
 2986|      0|    case TYPE_NSAPADDRESS:
  ------------------
  |  |  167|      0|#define TYPE_NSAPADDRESS    13
  ------------------
  |  Branch (2986:5): [True: 0, False: 174]
  ------------------
 2987|      0|        subtree->printomat = sprint_realloc_nsapaddress;
 2988|      0|        break;
 2989|      0|    case TYPE_COUNTER64:
  ------------------
  |  |  165|      0|#define TYPE_COUNTER64      11
  ------------------
  |  Branch (2989:5): [True: 0, False: 174]
  ------------------
 2990|      0|        subtree->printomat = sprint_realloc_counter64;
 2991|      0|        break;
 2992|      0|    case TYPE_UINTEGER:
  ------------------
  |  |  168|      0|#define TYPE_UINTEGER       14
  ------------------
  |  Branch (2992:5): [True: 0, False: 174]
  ------------------
 2993|      0|        subtree->printomat = sprint_realloc_uinteger;
 2994|      0|        break;
 2995|      0|    case TYPE_UNSIGNED32:
  ------------------
  |  |  169|      0|#define TYPE_UNSIGNED32     15
  ------------------
  |  Branch (2995:5): [True: 0, False: 174]
  ------------------
 2996|      0|        subtree->printomat = sprint_realloc_gauge;
 2997|      0|        break;
 2998|    174|    case TYPE_OTHER:
  ------------------
  |  |  154|    174|#define TYPE_OTHER          0
  ------------------
  |  Branch (2998:5): [True: 174, False: 0]
  ------------------
 2999|    174|    default:
  ------------------
  |  Branch (2999:5): [True: 0, False: 174]
  ------------------
 3000|    174|        subtree->printomat = sprint_realloc_by_type;
 3001|    174|        break;
 3002|    174|    }
 3003|    174|}

netsnmp_init_mib_internals:
  703|  2.95k|{
  704|  2.95k|    register struct tok *tp;
  705|  2.95k|    register int    b, i;
  706|  2.95k|    int             max_modc;
  707|       |
  708|  2.95k|    if (tree_head)
  ------------------
  |  Branch (708:9): [True: 2.90k, False: 58]
  ------------------
  709|  2.90k|        return;
  710|       |
  711|       |    /*
  712|       |     * Set up hash list of pre-defined tokens
  713|       |     */
  714|     58|    memset(buckets, 0, sizeof(buckets));
  715|  5.39k|    for (tp = tokens; tp->name; tp++) {
  ------------------
  |  Branch (715:23): [True: 5.33k, False: 58]
  ------------------
  716|  5.33k|        tp->hash = name_hash(tp->name);
  717|  5.33k|        b = BUCKET(tp->hash);
  ------------------
  |  |  527|  5.33k|#define BUCKET(x)       (x & (HASHSIZE-1))
  |  |  ------------------
  |  |  |  |  526|  5.33k|#define HASHSIZE        32
  |  |  ------------------
  ------------------
  718|  5.33k|        if (buckets[b])
  ------------------
  |  Branch (718:13): [True: 3.48k, False: 1.85k]
  ------------------
  719|  3.48k|            tp->next = buckets[b];      /* BUG ??? */
  720|  5.33k|        buckets[b] = tp;
  721|  5.33k|    }
  722|       |
  723|       |    /*
  724|       |     * Initialise other internal structures
  725|       |     */
  726|       |
  727|     58|    max_modc = sizeof(module_map) / sizeof(module_map[0]) - 1;
  728|  1.27k|    for (i = 0; i < max_modc; ++i)
  ------------------
  |  Branch (728:17): [True: 1.21k, False: 58]
  ------------------
  729|  1.21k|        module_map[i].next = &(module_map[i + 1]);
  730|     58|    module_map[max_modc].next = NULL;
  731|     58|    module_map_head = module_map;
  732|       |
  733|     58|    memset(nbuckets, 0, sizeof(nbuckets));
  734|     58|    memset(tbuckets, 0, sizeof(tbuckets));
  735|     58|    free(tclist);
  736|     58|    tc_alloc = TC_INCR;
  ------------------
  |  |  134|     58|#define TC_INCR 100
  ------------------
  737|     58|    tclist = calloc(tc_alloc, sizeof(struct tc));
  738|     58|    build_translation_table();
  739|     58|    init_tree_roots();          /* Set up initial roots */
  740|       |    /*
  741|       |     * Relies on 'add_mibdir' having set up the modules 
  742|       |     */
  743|     58|}
which_module:
 4125|    174|{
 4126|    174|    struct module  *mp;
 4127|       |
 4128|    174|    for (mp = module_head; mp; mp = mp->next)
  ------------------
  |  Branch (4128:28): [True: 0, False: 174]
  ------------------
 4129|      0|        if (!label_compare(mp->name, name))
  ------------------
  |  | 1240|      0|#define	label_compare	strcmp
  ------------------
  |  Branch (4129:13): [True: 0, False: 0]
  ------------------
 4130|      0|            return (mp->modid);
 4131|       |
 4132|    174|    DEBUGMSGTL(("parse-mibs", "Module %s not found\n", name));
  ------------------
  |  |   66|    174|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    174|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 174]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 174]
  |  |  ------------------
  ------------------
 4133|    174|    return (-1);
 4134|    174|}
adopt_orphans:
 4323|     58|{
 4324|     58|    struct node    *np = NULL, *onp;
 4325|     58|    struct tree    *tp;
 4326|     58|    int             i, adopted = 1;
 4327|       |
 4328|     58|    if (!orphan_nodes)
  ------------------
  |  Branch (4328:9): [True: 58, False: 0]
  ------------------
 4329|     58|        return;
 4330|      0|    init_node_hash(orphan_nodes);
 4331|      0|    orphan_nodes = NULL;
 4332|       |
 4333|      0|    while (adopted) {
  ------------------
  |  Branch (4333:12): [True: 0, False: 0]
  ------------------
 4334|      0|        adopted = 0;
 4335|      0|        for (i = 0; i < NHASHSIZE; i++)
  ------------------
  |  |  529|      0|#define NHASHSIZE    128
  ------------------
  |  Branch (4335:21): [True: 0, False: 0]
  ------------------
 4336|      0|            if (nbuckets[i]) {
  ------------------
  |  Branch (4336:17): [True: 0, False: 0]
  ------------------
 4337|      0|                for (np = nbuckets[i]; np != NULL; np = np->next) {
  ------------------
  |  Branch (4337:40): [True: 0, False: 0]
  ------------------
 4338|      0|                    tp = find_tree_node(np->parent, -1);
 4339|      0|		    if (tp) {
  ------------------
  |  Branch (4339:11): [True: 0, False: 0]
  ------------------
 4340|      0|			do_subtree(tp, &np);
 4341|      0|			adopted = 1;
 4342|       |                        /*
 4343|       |                         * if do_subtree adopted the entire bucket, stop
 4344|       |                         */
 4345|      0|                        if(NULL == nbuckets[i])
  ------------------
  |  Branch (4345:28): [True: 0, False: 0]
  ------------------
 4346|      0|                            break;
 4347|       |
 4348|       |                        /*
 4349|       |                         * do_subtree may modify nbuckets, and if np
 4350|       |                         * was adopted, np->next probably isn't an orphan
 4351|       |                         * anymore. if np is still in the bucket (do_subtree
 4352|       |                         * didn't adopt it) keep on plugging. otherwise
 4353|       |                         * start over, at the top of the bucket.
 4354|       |                         */
 4355|      0|                        for(onp = nbuckets[i]; onp; onp = onp->next)
  ------------------
  |  Branch (4355:48): [True: 0, False: 0]
  ------------------
 4356|      0|                            if(onp == np)
  ------------------
  |  Branch (4356:32): [True: 0, False: 0]
  ------------------
 4357|      0|                                break;
 4358|      0|                        if(NULL == onp) { /* not in the list */
  ------------------
  |  Branch (4358:28): [True: 0, False: 0]
  ------------------
 4359|      0|                            np = nbuckets[i]; /* start over */
 4360|      0|                        }
 4361|      0|		    }
 4362|      0|		}
 4363|      0|            }
 4364|      0|    }
 4365|       |
 4366|       |    /*
 4367|       |     * Report on outstanding orphans
 4368|       |     *    and link them back into the orphan list
 4369|       |     */
 4370|      0|    for (i = 0; i < NHASHSIZE; i++)
  ------------------
  |  |  529|      0|#define NHASHSIZE    128
  ------------------
  |  Branch (4370:17): [True: 0, False: 0]
  ------------------
 4371|      0|        if (nbuckets[i]) {
  ------------------
  |  Branch (4371:13): [True: 0, False: 0]
  ------------------
 4372|      0|            if (orphan_nodes)
  ------------------
  |  Branch (4372:17): [True: 0, False: 0]
  ------------------
 4373|      0|                onp = np->next = nbuckets[i];
 4374|      0|            else
 4375|      0|                onp = orphan_nodes = nbuckets[i];
 4376|      0|            nbuckets[i] = NULL;
 4377|      0|            while (onp) {
  ------------------
  |  Branch (4377:20): [True: 0, False: 0]
  ------------------
 4378|      0|                char            modbuf[256];
 4379|      0|                snmp_log(LOG_WARNING,
 4380|      0|                         "Cannot resolve OID in %s: %s ::= { %s %ld } at line %d in %s\n",
 4381|      0|                         module_name(onp->modid, modbuf),
 4382|      0|                         (onp->label ? onp->label : "<no label>"),
  ------------------
  |  Branch (4382:27): [True: 0, False: 0]
  ------------------
 4383|      0|                         (onp->parent ? onp->parent : "<no parent>"),
  ------------------
  |  Branch (4383:27): [True: 0, False: 0]
  ------------------
 4384|      0|                         onp->subid, onp->lineno, onp->filename);
 4385|      0|                np = onp;
 4386|      0|                onp = onp->next;
 4387|      0|            }
 4388|      0|        }
 4389|      0|}
netsnmp_read_module:
 4401|  2.78k|{
 4402|  2.78k|    int status = 0;
 4403|  2.78k|    status = read_module_internal(name);
 4404|       |
 4405|  2.78k|    if (status == MODULE_NOT_FOUND) {
  ------------------
  |  |  513|  2.78k|#define MODULE_NOT_FOUND	0
  ------------------
  |  Branch (4405:9): [True: 2.78k, False: 0]
  ------------------
 4406|  2.78k|        if (!read_module_replacements(name))
  ------------------
  |  Branch (4406:13): [True: 2.78k, False: 0]
  ------------------
 4407|  2.78k|            print_module_not_found(name);
 4408|  2.78k|    } else if (status == MODULE_SYNTAX_ERROR) {
  ------------------
  |  |  520|      0|#define MODULE_SYNTAX_ERROR     4
  ------------------
  |  Branch (4408:16): [True: 0, False: 0]
  ------------------
 4409|      0|        gMibError = 0;
 4410|      0|        gLoop = 1;
 4411|       |
 4412|      0|        strncat(gMibNames, " ", sizeof(gMibNames) - strlen(gMibNames) - 1);
 4413|      0|        strncat(gMibNames, name, sizeof(gMibNames) - strlen(gMibNames) - 1);
 4414|      0|    }
 4415|       |
 4416|  2.78k|    return tree_head;
 4417|  2.78k|}
unload_module_by_ID:
 4426|     58|{
 4427|     58|    struct tree    *tp, *next;
 4428|     58|    int             i;
 4429|       |
 4430|    232|    for (tp = tree_top; tp; tp = next) {
  ------------------
  |  Branch (4430:25): [True: 174, False: 58]
  ------------------
 4431|       |        /*
 4432|       |         * Essentially, this is equivalent to the code fragment:
 4433|       |         *      if (tp->modID == modID)
 4434|       |         *        tp->number_modules--;
 4435|       |         * but handles one tree node being part of several modules,
 4436|       |         * and possible multiple copies of the same module ID.
 4437|       |         */
 4438|    174|        int             nmod = tp->number_modules;
 4439|    174|        if (nmod > 0) {         /* in some module */
  ------------------
  |  Branch (4439:13): [True: 174, False: 0]
  ------------------
 4440|       |            /*
 4441|       |             * Remove all copies of this module ID
 4442|       |             */
 4443|    174|            int             cnt = 0, *pi1, *pi2 = tp->module_list;
 4444|    348|            for (i = 0, pi1 = pi2; i < nmod; i++, pi2++) {
  ------------------
  |  Branch (4444:36): [True: 174, False: 174]
  ------------------
 4445|    174|                if (*pi2 == modID)
  ------------------
  |  Branch (4445:21): [True: 174, False: 0]
  ------------------
 4446|    174|                    continue;
 4447|      0|                cnt++;
 4448|      0|                *pi1++ = *pi2;
 4449|      0|            }
 4450|    174|            if (nmod != cnt) {  /* in this module */
  ------------------
  |  Branch (4450:17): [True: 174, False: 0]
  ------------------
 4451|       |                /*
 4452|       |                 * if ( (nmod - cnt) > 1)
 4453|       |                 * printf("Dup modid %d,  %d times, '%s'\n", tp->modid, (nmod-cnt), tp->label); fflush(stdout); ?* XXDEBUG 
 4454|       |                 */
 4455|    174|                tp->number_modules = cnt;
 4456|    174|                switch (cnt) {
 4457|    174|                case 0:
  ------------------
  |  Branch (4457:17): [True: 174, False: 0]
  ------------------
 4458|    174|                    tp->module_list[0] = -1;    /* Mark unused, */
 4459|    174|		    NETSNMP_FALLTHROUGH;
  ------------------
  |  | 2443|    174|#    define NETSNMP_FALLTHROUGH __attribute__((__fallthrough__))
  ------------------
 4460|       |
 4461|    174|                case 1:        /* save the remaining module */
  ------------------
  |  Branch (4461:17): [True: 0, False: 174]
  ------------------
 4462|    174|                    if (&(tp->modid) != tp->module_list) {
  ------------------
  |  Branch (4462:25): [True: 0, False: 174]
  ------------------
 4463|      0|                        tp->modid = tp->module_list[0];
 4464|      0|                        free(tp->module_list);
 4465|      0|                        tp->module_list = &(tp->modid);
 4466|      0|                    }
 4467|    174|                    break;
 4468|       |
 4469|      0|                default:
  ------------------
  |  Branch (4469:17): [True: 0, False: 174]
  ------------------
 4470|      0|                    break;
 4471|    174|                }
 4472|    174|            }                   /* if tree node is in this module */
 4473|    174|        }
 4474|       |        /*
 4475|       |         * if tree node is in some module 
 4476|       |         */
 4477|    174|        next = tp->next_peer;
 4478|       |
 4479|       |
 4480|       |        /*
 4481|       |         *  OK - that's dealt with *this* node.
 4482|       |         *    Now let's look at the children.
 4483|       |         *    (Isn't recursion wonderful!)
 4484|       |         */
 4485|    174|        if (tp->child_list)
  ------------------
  |  Branch (4485:13): [True: 0, False: 174]
  ------------------
 4486|      0|            unload_module_by_ID(modID, tp->child_list);
 4487|       |
 4488|       |
 4489|    174|        if (tp->number_modules == 0) {
  ------------------
  |  Branch (4489:13): [True: 174, False: 0]
  ------------------
 4490|       |            /*
 4491|       |             * This node isn't needed any more (except perhaps
 4492|       |             * for the sake of the children) 
 4493|       |             */
 4494|    174|            if (tp->child_list == NULL) {
  ------------------
  |  Branch (4494:17): [True: 174, False: 0]
  ------------------
 4495|    174|                unlink_tree(tp);
 4496|    174|                free_tree(tp);
 4497|    174|            } else {
 4498|      0|                free_partial_tree(tp, TRUE);
  ------------------
  |  |  128|      0|#define TRUE  1
  ------------------
 4499|      0|            }
 4500|    174|        }
 4501|    174|    }
 4502|     58|}
unload_all_mibs:
 4539|     58|{
 4540|     58|    struct module  *mp;
 4541|     58|    struct module_compatability *mcp;
 4542|     58|    struct tc      *ptc;
 4543|     58|    unsigned int    i;
 4544|       |
 4545|     58|    for (mcp = module_map_head; mcp; mcp = module_map_head) {
  ------------------
  |  Branch (4545:33): [True: 58, False: 0]
  ------------------
 4546|     58|        if (mcp == module_map)
  ------------------
  |  Branch (4546:13): [True: 58, False: 0]
  ------------------
 4547|     58|            break;
 4548|      0|        module_map_head = mcp->next;
 4549|      0|        if (mcp->tag) free(NETSNMP_REMOVE_CONST(char *, mcp->tag));
  ------------------
  |  |   91|      0|    (__extension__ ({ const t tmp = (e); (t)(size_t)tmp; }))
  ------------------
  |  Branch (4549:13): [True: 0, False: 0]
  ------------------
 4550|      0|        free(NETSNMP_REMOVE_CONST(char *, mcp->old_module));
  ------------------
  |  |   91|      0|    (__extension__ ({ const t tmp = (e); (t)(size_t)tmp; }))
  ------------------
 4551|      0|        free(NETSNMP_REMOVE_CONST(char *, mcp->new_module));
  ------------------
  |  |   91|      0|    (__extension__ ({ const t tmp = (e); (t)(size_t)tmp; }))
  ------------------
 4552|      0|        free(mcp);
 4553|      0|    }
 4554|       |
 4555|     58|    for (mp = module_head; mp; mp = module_head) {
  ------------------
  |  Branch (4555:28): [True: 0, False: 58]
  ------------------
 4556|      0|        struct module_import *mi = mp->imports;
 4557|      0|        if (mi) {
  ------------------
  |  Branch (4557:13): [True: 0, False: 0]
  ------------------
 4558|      0|            for (i = 0; i < (unsigned int)mp->no_imports; ++i) {
  ------------------
  |  Branch (4558:25): [True: 0, False: 0]
  ------------------
 4559|      0|                SNMP_FREE((mi + i)->label);
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 4560|      0|            }
 4561|      0|            mp->no_imports = 0;
 4562|      0|            if (mi == root_imports)
  ------------------
  |  Branch (4562:17): [True: 0, False: 0]
  ------------------
 4563|      0|                memset(mi, 0, sizeof(*mi));
 4564|      0|            else
 4565|      0|                free(mi);
 4566|      0|        }
 4567|       |
 4568|      0|        unload_module_by_ID(mp->modid, tree_head);
 4569|      0|        module_head = mp->next;
 4570|      0|        free(mp->name);
 4571|      0|        free(mp->file);
 4572|      0|        free(mp);
 4573|      0|    }
 4574|     58|    unload_module_by_ID(-1, tree_head);
 4575|       |    /*
 4576|       |     * tree nodes are cleared 
 4577|       |     */
 4578|       |
 4579|  5.85k|    for (i = 0, ptc = tclist; i < tc_alloc; i++, ptc++) {
  ------------------
  |  Branch (4579:31): [True: 5.80k, False: 58]
  ------------------
 4580|  5.80k|        if (ptc->type == 0)
  ------------------
  |  Branch (4580:13): [True: 5.80k, False: 0]
  ------------------
 4581|  5.80k|            continue;
 4582|      0|        free_enums(&ptc->enums);
 4583|      0|        free_ranges(&ptc->ranges);
 4584|      0|        free(ptc->descriptor);
 4585|      0|        if (ptc->hint)
  ------------------
  |  Branch (4585:13): [True: 0, False: 0]
  ------------------
 4586|      0|            free(ptc->hint);
 4587|      0|        if (ptc->description)
  ------------------
  |  Branch (4587:13): [True: 0, False: 0]
  ------------------
 4588|      0|            free(ptc->description);
 4589|      0|    }
 4590|     58|    SNMP_FREE(tclist);
  ------------------
  |  |   62|     58|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 58, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 58]
  |  |  ------------------
  ------------------
 4591|     58|    tc_alloc = 0;
 4592|       |
 4593|     58|    memset(buckets, 0, sizeof(buckets));
 4594|     58|    memset(nbuckets, 0, sizeof(nbuckets));
 4595|     58|    memset(tbuckets, 0, sizeof(tbuckets));
 4596|       |
 4597|    232|    for (i = 0; i < sizeof(root_imports) / sizeof(root_imports[0]); i++) {
  ------------------
  |  Branch (4597:17): [True: 174, False: 58]
  ------------------
 4598|    174|        SNMP_FREE(root_imports[i].label);
  ------------------
  |  |   62|    174|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 174, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 174]
  |  |  ------------------
  ------------------
 4599|    174|    }
 4600|       |
 4601|     58|    max_module = 0;
 4602|     58|    current_module = 0;
 4603|     58|    module_map_head = NULL;
 4604|     58|    SNMP_FREE(last_err_module);
  ------------------
  |  |   62|     58|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 58, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 58]
  |  |  ------------------
  ------------------
 4605|       |
 4606|     58|    {
 4607|     58|        struct node *np = orphan_nodes;
 4608|       |
 4609|     58|        while (np) {
  ------------------
  |  Branch (4609:16): [True: 0, False: 58]
  ------------------
 4610|      0|            struct node *nnp = np->next;
 4611|      0|            free_node(np);
 4612|      0|            np = nnp;
 4613|      0|        }
 4614|       |        orphan_nodes = NULL;
 4615|     58|    }
 4616|     58|    erroneousMibs = 0;
 4617|     58|    first_err_module = 1;
 4618|     58|}
add_mibdir:
 5581|    115|{
 5582|    115|    const char     *oldFile = File;
 5583|    115|    int             oldLine = mibLine;
 5584|    115|    char          **filenames;
 5585|    115|    int             count = 0;
 5586|    115|    int             filename_count, i;
 5587|       |
 5588|    115|    DEBUGMSGTL(("parse-mibs", "Scanning directory %s\n", dirname));
  ------------------
  |  |   66|    115|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    115|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 115]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 115]
  |  |  ------------------
  ------------------
 5589|       |
 5590|    115|    filename_count = scan_directory(&filenames, dirname);
 5591|       |
 5592|    115|    if (filename_count >= 0) {
  ------------------
  |  Branch (5592:9): [True: 0, False: 115]
  ------------------
 5593|      0|        for (i = 0; i < filename_count; i++) {
  ------------------
  |  Branch (5593:21): [True: 0, False: 0]
  ------------------
 5594|      0|            if (add_mibfile(filenames[i], strrchr(filenames[i], '/')) == 0)
  ------------------
  |  Branch (5594:17): [True: 0, False: 0]
  ------------------
 5595|      0|                count++;
 5596|      0|	    free(filenames[i]);
 5597|      0|        }
 5598|      0|        File = oldFile;
 5599|      0|        mibLine = oldLine;
 5600|      0|        free(filenames);
 5601|      0|        return (count);
 5602|      0|    }
 5603|    115|    else
 5604|    115|        DEBUGMSGTL(("parse-mibs","cannot open MIB directory %s\n", dirname));
  ------------------
  |  |   66|    115|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    115|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 115]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 115]
  |  |  ------------------
  ------------------
 5605|       |
 5606|    115|    return (-1);
 5607|    115|}
parse.c:name_hash:
  690|  5.68k|{
  691|  5.68k|    int             hash = 0;
  692|  5.68k|    const char     *cp;
  693|       |
  694|  5.68k|    if (!name)
  ------------------
  |  Branch (694:9): [True: 0, False: 5.68k]
  ------------------
  695|      0|        return 0;
  696|  59.6k|    for (cp = name; *cp; cp++)
  ------------------
  |  Branch (696:21): [True: 53.9k, False: 5.68k]
  ------------------
  697|  53.9k|        hash += tolower((unsigned char)(*cp));
  ------------------
  |  Branch (697:17): [True: 0, False: 0]
  |  Branch (697:17): [True: 0, False: 0]
  |  Branch (697:17): [Folded, False: 53.9k]
  ------------------
  698|  5.68k|    return (hash);
  699|  5.68k|}
parse.c:build_translation_table:
 1075|     58|{
 1076|     58|    int             count;
 1077|       |
 1078|  14.9k|    for (count = 0; count < 256; count++) {
  ------------------
  |  Branch (1078:21): [True: 14.8k, False: 58]
  ------------------
 1079|  14.8k|        switch (count) {
 1080|     58|        case OBJID:
  ------------------
  |  |  167|     58|#define OBJID       (4 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|     58|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1080:9): [True: 58, False: 14.7k]
  ------------------
 1081|     58|            translation_table[count] = TYPE_OBJID;
  ------------------
  |  |  155|     58|#define TYPE_OBJID          1
  ------------------
 1082|     58|            break;
 1083|     58|        case OCTETSTR:
  ------------------
  |  |  168|     58|#define OCTETSTR    (5 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|     58|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1083:9): [True: 58, False: 14.7k]
  ------------------
 1084|     58|            translation_table[count] = TYPE_OCTETSTR;
  ------------------
  |  |  156|     58|#define TYPE_OCTETSTR       2
  ------------------
 1085|     58|            break;
 1086|     58|        case INTEGER:
  ------------------
  |  |  169|     58|#define INTEGER     (6 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|     58|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1086:9): [True: 58, False: 14.7k]
  ------------------
 1087|     58|            translation_table[count] = TYPE_INTEGER;
  ------------------
  |  |  157|     58|#define TYPE_INTEGER        3
  ------------------
 1088|     58|            break;
 1089|     58|        case NETADDR:
  ------------------
  |  |  170|     58|#define NETADDR     (7 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|     58|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1089:9): [True: 58, False: 14.7k]
  ------------------
 1090|     58|            translation_table[count] = TYPE_NETADDR;
  ------------------
  |  |  158|     58|#define TYPE_NETADDR        4
  ------------------
 1091|     58|            break;
 1092|     58|        case IPADDR:
  ------------------
  |  |  171|     58|#define IPADDR      (8 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|     58|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1092:9): [True: 58, False: 14.7k]
  ------------------
 1093|     58|            translation_table[count] = TYPE_IPADDR;
  ------------------
  |  |  159|     58|#define TYPE_IPADDR         5
  ------------------
 1094|     58|            break;
 1095|     58|        case COUNTER:
  ------------------
  |  |  172|     58|#define COUNTER     (9 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|     58|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1095:9): [True: 58, False: 14.7k]
  ------------------
 1096|     58|            translation_table[count] = TYPE_COUNTER;
  ------------------
  |  |  160|     58|#define TYPE_COUNTER        6
  ------------------
 1097|     58|            break;
 1098|     58|        case GAUGE:
  ------------------
  |  |  173|     58|#define GAUGE       (10 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|     58|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1098:9): [True: 58, False: 14.7k]
  ------------------
 1099|     58|            translation_table[count] = TYPE_GAUGE;
  ------------------
  |  |  161|     58|#define TYPE_GAUGE          7
  ------------------
 1100|     58|            break;
 1101|     58|        case TIMETICKS:
  ------------------
  |  |  174|     58|#define TIMETICKS   (11 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|     58|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1101:9): [True: 58, False: 14.7k]
  ------------------
 1102|     58|            translation_table[count] = TYPE_TIMETICKS;
  ------------------
  |  |  162|     58|#define TYPE_TIMETICKS      8
  ------------------
 1103|     58|            break;
 1104|     58|        case KW_OPAQUE:
  ------------------
  |  |  175|     58|#define KW_OPAQUE   (12 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|     58|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1104:9): [True: 58, False: 14.7k]
  ------------------
 1105|     58|            translation_table[count] = TYPE_OPAQUE;
  ------------------
  |  |  163|     58|#define TYPE_OPAQUE         9
  ------------------
 1106|     58|            break;
 1107|     58|        case NUL:
  ------------------
  |  |  176|     58|#define NUL         (13 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|     58|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1107:9): [True: 58, False: 14.7k]
  ------------------
 1108|     58|            translation_table[count] = TYPE_NULL;
  ------------------
  |  |  164|     58|#define TYPE_NULL           10
  ------------------
 1109|     58|            break;
 1110|     58|        case COUNTER64:
  ------------------
  |  |  211|     58|#define COUNTER64   (43 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|     58|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1110:9): [True: 58, False: 14.7k]
  ------------------
 1111|     58|            translation_table[count] = TYPE_COUNTER64;
  ------------------
  |  |  165|     58|#define TYPE_COUNTER64      11
  ------------------
 1112|     58|            break;
 1113|     58|        case BITSTRING:
  ------------------
  |  |  209|     58|#define BITSTRING   (41 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|     58|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1113:9): [True: 58, False: 14.7k]
  ------------------
 1114|     58|            translation_table[count] = TYPE_BITSTRING;
  ------------------
  |  |  166|     58|#define TYPE_BITSTRING      12
  ------------------
 1115|     58|            break;
 1116|     58|        case NSAPADDRESS:
  ------------------
  |  |  210|     58|#define NSAPADDRESS (42 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|     58|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1116:9): [True: 58, False: 14.7k]
  ------------------
 1117|     58|            translation_table[count] = TYPE_NSAPADDRESS;
  ------------------
  |  |  167|     58|#define TYPE_NSAPADDRESS    13
  ------------------
 1118|     58|            break;
 1119|     58|        case INTEGER32:
  ------------------
  |  |  274|     58|#define INTEGER32	(105 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|     58|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1119:9): [True: 58, False: 14.7k]
  ------------------
 1120|     58|            translation_table[count] = TYPE_INTEGER32;
  ------------------
  |  |  170|     58|#define TYPE_INTEGER32      16
  ------------------
 1121|     58|            break;
 1122|     58|        case UINTEGER32:
  ------------------
  |  |  224|     58|#define UINTEGER32 (56 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|     58|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1122:9): [True: 58, False: 14.7k]
  ------------------
 1123|     58|            translation_table[count] = TYPE_UINTEGER;
  ------------------
  |  |  168|     58|#define TYPE_UINTEGER       14
  ------------------
 1124|     58|            break;
 1125|     58|        case UNSIGNED32:
  ------------------
  |  |  273|     58|#define UNSIGNED32	(104 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|     58|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1125:9): [True: 58, False: 14.7k]
  ------------------
 1126|     58|            translation_table[count] = TYPE_UNSIGNED32;
  ------------------
  |  |  169|     58|#define TYPE_UNSIGNED32     15
  ------------------
 1127|     58|            break;
 1128|     58|        case TRAPTYPE:
  ------------------
  |  |  229|     58|#define TRAPTYPE    61
  ------------------
  |  Branch (1128:9): [True: 58, False: 14.7k]
  ------------------
 1129|     58|            translation_table[count] = TYPE_TRAPTYPE;
  ------------------
  |  |  174|     58|#define TYPE_TRAPTYPE	    20
  ------------------
 1130|     58|            break;
 1131|     58|        case NOTIFTYPE:
  ------------------
  |  |  213|     58|#define NOTIFTYPE   45
  ------------------
  |  Branch (1131:9): [True: 58, False: 14.7k]
  ------------------
 1132|     58|            translation_table[count] = TYPE_NOTIFTYPE;
  ------------------
  |  |  175|     58|#define TYPE_NOTIFTYPE      21
  ------------------
 1133|     58|            break;
 1134|     58|        case NOTIFGROUP:
  ------------------
  |  |  258|     58|#define NOTIFGROUP  88
  ------------------
  |  Branch (1134:9): [True: 58, False: 14.7k]
  ------------------
 1135|     58|            translation_table[count] = TYPE_NOTIFGROUP;
  ------------------
  |  |  177|     58|#define TYPE_NOTIFGROUP	    23
  ------------------
 1136|     58|            break;
 1137|     58|        case OBJGROUP:
  ------------------
  |  |  212|     58|#define OBJGROUP    44
  ------------------
  |  Branch (1137:9): [True: 58, False: 14.7k]
  ------------------
 1138|     58|            translation_table[count] = TYPE_OBJGROUP;
  ------------------
  |  |  176|     58|#define TYPE_OBJGROUP	    22
  ------------------
 1139|     58|            break;
 1140|     58|        case MODULEIDENTITY:
  ------------------
  |  |  220|     58|#define MODULEIDENTITY 52
  ------------------
  |  Branch (1140:9): [True: 58, False: 14.7k]
  ------------------
 1141|     58|            translation_table[count] = TYPE_MODID;
  ------------------
  |  |  178|     58|#define TYPE_MODID	    24
  ------------------
 1142|     58|            break;
 1143|     58|        case OBJIDENTITY:
  ------------------
  |  |  275|     58|#define OBJIDENTITY	106
  ------------------
  |  Branch (1143:9): [True: 58, False: 14.7k]
  ------------------
 1144|     58|            translation_table[count] = TYPE_OBJIDENTITY;
  ------------------
  |  |  181|     58|#define TYPE_OBJIDENTITY    27
  ------------------
 1145|     58|            break;
 1146|     58|        case AGENTCAP:
  ------------------
  |  |  243|     58|#define AGENTCAP    73
  ------------------
  |  Branch (1146:9): [True: 58, False: 14.7k]
  ------------------
 1147|     58|            translation_table[count] = TYPE_AGENTCAP;
  ------------------
  |  |  179|     58|#define TYPE_AGENTCAP       25
  ------------------
 1148|     58|            break;
 1149|     58|        case COMPLIANCE:
  ------------------
  |  |  215|     58|#define COMPLIANCE  47
  ------------------
  |  Branch (1149:9): [True: 58, False: 14.7k]
  ------------------
 1150|     58|            translation_table[count] = TYPE_MODCOMP;
  ------------------
  |  |  180|     58|#define TYPE_MODCOMP        26
  ------------------
 1151|     58|            break;
 1152|  13.4k|        default:
  ------------------
  |  Branch (1152:9): [True: 13.4k, False: 1.39k]
  ------------------
 1153|  13.4k|            translation_table[count] = TYPE_OTHER;
  ------------------
  |  |  154|  13.4k|#define TYPE_OTHER          0
  ------------------
 1154|  13.4k|            break;
 1155|  14.8k|        }
 1156|  14.8k|    }
 1157|     58|}
parse.c:init_tree_roots:
 1161|     58|{
 1162|     58|    struct tree    *tp, *lasttp;
 1163|     58|    int             base_modid;
 1164|     58|    int             hash;
 1165|       |
 1166|     58|    base_modid = which_module("SNMPv2-SMI");
 1167|     58|    if (base_modid == -1)
  ------------------
  |  Branch (1167:9): [True: 58, False: 0]
  ------------------
 1168|     58|        base_modid = which_module("RFC1155-SMI");
 1169|     58|    if (base_modid == -1)
  ------------------
  |  Branch (1169:9): [True: 58, False: 0]
  ------------------
 1170|     58|        base_modid = which_module("RFC1213-MIB");
 1171|       |
 1172|       |    /*
 1173|       |     * build root node 
 1174|       |     */
 1175|     58|    tp = calloc(1, sizeof(struct tree));
 1176|     58|    if (tp == NULL)
  ------------------
  |  Branch (1176:9): [True: 0, False: 58]
  ------------------
 1177|      0|        return;
 1178|     58|    tp->label = strdup("joint-iso-ccitt");
 1179|     58|    tp->modid = base_modid;
 1180|     58|    tp->number_modules = 1;
 1181|     58|    tp->module_list = &(tp->modid);
 1182|     58|    tp->subid = 2;
 1183|     58|    tp->tc_index = -1;
 1184|     58|    set_function(tp);           /* from mib.c */
 1185|     58|    hash = NBUCKET(name_hash(tp->label));
  ------------------
  |  |  530|     58|#define NBUCKET(x)   (x & (NHASHSIZE-1))
  |  |  ------------------
  |  |  |  |  529|     58|#define NHASHSIZE    128
  |  |  ------------------
  ------------------
 1186|     58|    tp->next = tbuckets[hash];
 1187|     58|    tbuckets[hash] = tp;
 1188|     58|    lasttp = tp;
 1189|     58|    root_imports[0].label = strdup(tp->label);
 1190|     58|    root_imports[0].modid = base_modid;
 1191|       |
 1192|       |    /*
 1193|       |     * build root node 
 1194|       |     */
 1195|     58|    tp = calloc(1, sizeof(struct tree));
 1196|     58|    if (tp == NULL)
  ------------------
  |  Branch (1196:9): [True: 0, False: 58]
  ------------------
 1197|      0|        return;
 1198|     58|    tp->next_peer = lasttp;
 1199|     58|    tp->label = strdup("ccitt");
 1200|     58|    tp->modid = base_modid;
 1201|     58|    tp->number_modules = 1;
 1202|     58|    tp->module_list = &(tp->modid);
 1203|     58|    tp->subid = 0;
 1204|     58|    tp->tc_index = -1;
 1205|     58|    set_function(tp);           /* from mib.c */
 1206|     58|    hash = NBUCKET(name_hash(tp->label));
  ------------------
  |  |  530|     58|#define NBUCKET(x)   (x & (NHASHSIZE-1))
  |  |  ------------------
  |  |  |  |  529|     58|#define NHASHSIZE    128
  |  |  ------------------
  ------------------
 1207|     58|    tp->next = tbuckets[hash];
 1208|     58|    tbuckets[hash] = tp;
 1209|     58|    lasttp = tp;
 1210|     58|    root_imports[1].label = strdup(tp->label);
 1211|     58|    root_imports[1].modid = base_modid;
 1212|       |
 1213|       |    /*
 1214|       |     * build root node 
 1215|       |     */
 1216|     58|    tp = calloc(1, sizeof(struct tree));
 1217|     58|    if (tp == NULL)
  ------------------
  |  Branch (1217:9): [True: 0, False: 58]
  ------------------
 1218|      0|        return;
 1219|     58|    tp->next_peer = lasttp;
 1220|     58|    tp->label = strdup("iso");
 1221|     58|    tp->modid = base_modid;
 1222|     58|    tp->number_modules = 1;
 1223|     58|    tp->module_list = &(tp->modid);
 1224|     58|    tp->subid = 1;
 1225|     58|    tp->tc_index = -1;
 1226|     58|    set_function(tp);           /* from mib.c */
 1227|     58|    hash = NBUCKET(name_hash(tp->label));
  ------------------
  |  |  530|     58|#define NBUCKET(x)   (x & (NHASHSIZE-1))
  |  |  ------------------
  |  |  |  |  529|     58|#define NHASHSIZE    128
  |  |  ------------------
  ------------------
 1228|     58|    tp->next = tbuckets[hash];
 1229|     58|    tbuckets[hash] = tp;
 1230|     58|    lasttp = tp;
 1231|     58|    root_imports[2].label = strdup(tp->label);
 1232|     58|    root_imports[2].modid = base_modid;
 1233|       |
 1234|     58|    tree_head = tp;
 1235|     58|}
parse.c:unlink_tbucket:
  833|    174|{
  834|    174|    int             hash = NBUCKET(name_hash(tp->label));
  ------------------
  |  |  530|    174|#define NBUCKET(x)   (x & (NHASHSIZE-1))
  |  |  ------------------
  |  |  |  |  529|    174|#define NHASHSIZE    128
  |  |  ------------------
  ------------------
  835|    174|    struct tree    *otp = NULL, *ntp = tbuckets[hash];
  836|       |
  837|    174|    while (ntp && ntp != tp) {
  ------------------
  |  Branch (837:12): [True: 174, False: 0]
  |  Branch (837:19): [True: 0, False: 174]
  ------------------
  838|      0|        otp = ntp;
  839|      0|        ntp = ntp->next;
  840|      0|    }
  841|    174|    if (!ntp)
  ------------------
  |  Branch (841:9): [True: 0, False: 174]
  ------------------
  842|      0|        snmp_log(LOG_EMERG, "Can't find %s in tbuckets\n", tp->label);
  843|    174|    else if (otp)
  ------------------
  |  Branch (843:14): [True: 0, False: 174]
  ------------------
  844|      0|        otp->next = ntp->next;
  845|    174|    else
  846|    174|        tbuckets[hash] = tp->next;
  847|    174|}
parse.c:read_module_internal:
 4309|  2.78k|{
 4310|  2.78k|    struct module  *mp;
 4311|       |
 4312|  2.78k|    netsnmp_init_mib_internals();
 4313|       |
 4314|  2.78k|    for (mp = module_head; mp; mp = mp->next)
  ------------------
  |  Branch (4314:28): [True: 0, False: 2.78k]
  ------------------
 4315|      0|        if (!label_compare(mp->name, name))
  ------------------
  |  | 1240|      0|#define	label_compare	strcmp
  ------------------
  |  Branch (4315:13): [True: 0, False: 0]
  ------------------
 4316|      0|            return read_from_file(mp, name);
 4317|       |
 4318|  2.78k|    return MODULE_NOT_FOUND;
  ------------------
  |  |  513|  2.78k|#define MODULE_NOT_FOUND	0
  ------------------
 4319|  2.78k|}
parse.c:print_error:
  783|  2.78k|{
  784|  2.78k|    erroneousMibs++;
  785|  2.78k|    if (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|  2.78k|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (785:9): [True: 0, False: 2.78k]
  ------------------
  786|  2.78k|                                NETSNMP_DS_LIB_MIB_ERRORS))
  ------------------
  |  |   59|  2.78k|#define NETSNMP_DS_LIB_MIB_ERRORS          0
  ------------------
  787|      0|	return;
  788|  2.78k|    DEBUGMSGTL(("parse-mibs", "\n"));
  ------------------
  |  |   66|  2.78k|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|  2.78k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 2.78k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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.78k]
  |  |  ------------------
  ------------------
  789|  2.78k|    if (type == ENDOFFILE)
  ------------------
  |  |  163|  2.78k|#define ENDOFFILE   0
  ------------------
  |  Branch (789:9): [True: 0, False: 2.78k]
  ------------------
  790|      0|        snmp_log(LOG_ERR, "%s (EOF): At line %d in %s\n", str, mibLine,
  791|      0|                 File);
  792|  2.78k|    else if (token && *token)
  ------------------
  |  Branch (792:14): [True: 2.78k, False: 0]
  |  Branch (792:23): [True: 2.78k, False: 0]
  ------------------
  793|  2.78k|        snmp_log(LOG_ERR, "%s (%s): At line %d in %s\n", str, token,
  794|  2.78k|                 mibLine, File);
  795|      0|    else
  796|      0|        snmp_log(LOG_ERR, "%s: At line %d in %s\n", str, mibLine, File);
  797|  2.78k|}
parse.c:free_indexes:
 5823|    174|{
 5824|    174|    if (spp && *spp) {
  ------------------
  |  Branch (5824:9): [True: 174, False: 0]
  |  Branch (5824:16): [True: 0, False: 174]
  ------------------
 5825|      0|        struct index_list *pp, *npp;
 5826|       |
 5827|      0|        pp = *spp;
 5828|      0|        *spp = NULL;
 5829|       |
 5830|      0|        while (pp) {
  ------------------
  |  Branch (5830:16): [True: 0, False: 0]
  ------------------
 5831|      0|            npp = pp->next;
 5832|      0|            if (pp->ilabel)
  ------------------
  |  Branch (5832:17): [True: 0, False: 0]
  ------------------
 5833|      0|                free(pp->ilabel);
 5834|      0|            free(pp);
 5835|      0|            pp = npp;
 5836|      0|        }
 5837|      0|    }
 5838|    174|}
parse.c:free_varbinds:
 5842|    174|{
 5843|    174|    if (spp && *spp) {
  ------------------
  |  Branch (5843:9): [True: 174, False: 0]
  |  Branch (5843:16): [True: 0, False: 174]
  ------------------
 5844|      0|        struct varbind_list *pp, *npp;
 5845|       |
 5846|      0|        pp = *spp;
 5847|      0|        *spp = NULL;
 5848|       |
 5849|      0|        while (pp) {
  ------------------
  |  Branch (5849:16): [True: 0, False: 0]
  ------------------
 5850|      0|            npp = pp->next;
 5851|      0|            if (pp->vblabel)
  ------------------
  |  Branch (5851:17): [True: 0, False: 0]
  ------------------
 5852|      0|                free(pp->vblabel);
 5853|      0|            free(pp);
 5854|      0|            pp = npp;
 5855|      0|        }
 5856|      0|    }
 5857|    174|}
parse.c:read_module_replacements:
 4189|  2.78k|{
 4190|  2.78k|    struct module_compatability *mcp;
 4191|       |
 4192|  64.0k|    for (mcp = module_map_head; mcp; mcp = mcp->next) {
  ------------------
  |  Branch (4192:33): [True: 61.2k, False: 2.78k]
  ------------------
 4193|  61.2k|        if (!label_compare(mcp->old_module, name)) {
  ------------------
  |  | 1240|  61.2k|#define	label_compare	strcmp
  ------------------
  |  Branch (4193:13): [True: 0, False: 61.2k]
  ------------------
 4194|      0|            if (netsnmp_ds_get_int(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|      0|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (4194:17): [True: 0, False: 0]
  ------------------
 4195|      0|				   NETSNMP_DS_LIB_MIB_WARNINGS)) {
  ------------------
  |  |  114|      0|#define NETSNMP_DS_LIB_MIB_WARNINGS         0
  ------------------
 4196|      0|                snmp_log(LOG_WARNING,
 4197|      0|                         "Loading replacement module %s for %s (%s)\n",
 4198|      0|                         mcp->new_module, name, File);
 4199|      0|	    }
 4200|      0|            (void) netsnmp_read_module(mcp->new_module);
 4201|      0|            return 1;
 4202|      0|        }
 4203|  61.2k|    }
 4204|  2.78k|    return 0;
 4205|  2.78k|}
parse.c:print_module_not_found:
  801|  2.78k|{
  802|  2.78k|    if (first_err_module) {
  ------------------
  |  Branch (802:9): [True: 58, False: 2.72k]
  ------------------
  803|     58|        snmp_log(LOG_ERR, "MIB search path: %s\n",
  804|     58|                           netsnmp_get_mib_directory());
  805|     58|        first_err_module = 0;
  806|     58|    }
  807|  2.78k|    if (!last_err_module || strcmp(cp, last_err_module))
  ------------------
  |  Branch (807:9): [True: 58, False: 2.72k]
  |  Branch (807:29): [True: 2.72k, False: 0]
  ------------------
  808|  2.78k|        print_error("Cannot find module", cp, CONTINUE);
  ------------------
  |  |  162|  2.78k|#define CONTINUE    -1
  ------------------
  809|  2.78k|    if (last_err_module)
  ------------------
  |  Branch (809:9): [True: 2.72k, False: 58]
  ------------------
  810|  2.72k|        free(last_err_module);
  811|  2.78k|    last_err_module = strdup(cp);
  812|  2.78k|}
parse.c:unlink_tree:
  851|    174|{
  852|    174|    struct tree    *otp = NULL, *ntp = tp->parent;
  853|       |
  854|    174|    if (!ntp) {                 /* this tree has no parent */
  ------------------
  |  Branch (854:9): [True: 174, False: 0]
  ------------------
  855|    174|        DEBUGMSGTL(("unlink_tree", "Tree node %s has no parent\n",
  ------------------
  |  |   66|    174|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    174|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 174]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 174]
  |  |  ------------------
  ------------------
  856|    174|                    tp->label));
  857|    174|    } else {
  858|      0|        child_index_modified(ntp, NULL);
  859|      0|        ntp = ntp->child_list;
  860|       |
  861|      0|        while (ntp && ntp != tp) {
  ------------------
  |  Branch (861:16): [True: 0, False: 0]
  |  Branch (861:23): [True: 0, False: 0]
  ------------------
  862|      0|            otp = ntp;
  863|      0|            ntp = ntp->next_peer;
  864|      0|        }
  865|      0|        if (!ntp)
  ------------------
  |  Branch (865:13): [True: 0, False: 0]
  ------------------
  866|      0|            snmp_log(LOG_EMERG, "Can't find %s in %s's children\n",
  867|      0|                     tp->label, tp->parent->label);
  868|      0|        else if (otp)
  ------------------
  |  Branch (868:18): [True: 0, False: 0]
  ------------------
  869|      0|            otp->next_peer = ntp->next_peer;
  870|      0|        else
  871|      0|            tp->parent->child_list = tp->next_peer;
  872|      0|    }
  873|       |
  874|    174|    if (tree_head == tp)
  ------------------
  |  Branch (874:9): [True: 174, False: 0]
  ------------------
  875|    174|        tree_head = tp->next_peer;
  876|    174|}
parse.c:free_tree:
  907|    174|{
  908|    174|    if (!Tree)
  ------------------
  |  Branch (908:9): [True: 0, False: 174]
  ------------------
  909|      0|        return;
  910|       |
  911|    174|    unlink_tbucket(Tree);
  912|    174|    free_partial_tree(Tree, FALSE);
  ------------------
  |  |  125|    174|#define FALSE 0
  ------------------
  913|    174|    if (Tree->module_list != &Tree->modid)
  ------------------
  |  Branch (913:9): [True: 0, False: 174]
  ------------------
  914|      0|        free(Tree->module_list);
  915|    174|    free(Tree);
  916|    174|}
parse.c:free_partial_tree:
  880|    174|{
  881|    174|    if (!tp)
  ------------------
  |  Branch (881:9): [True: 0, False: 174]
  ------------------
  882|      0|        return;
  883|       |
  884|       |    /*
  885|       |     * remove the data from this tree node 
  886|       |     */
  887|    174|    free_enums(&tp->enums);
  888|    174|    free_ranges(&tp->ranges);
  889|    174|    free_indexes(&tp->indexes);
  890|    174|    free_varbinds(&tp->varbinds);
  891|    174|    if (!keep_label)
  ------------------
  |  Branch (891:9): [True: 174, False: 0]
  ------------------
  892|    174|        SNMP_FREE(tp->label);
  ------------------
  |  |   62|    174|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 174, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 174]
  |  |  ------------------
  ------------------
  893|    174|    SNMP_FREE(tp->hint);
  ------------------
  |  |   62|    174|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 174]
  |  |  |  Branch (62:66): [Folded, False: 174]
  |  |  ------------------
  ------------------
  894|    174|    SNMP_FREE(tp->units);
  ------------------
  |  |   62|    174|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 174]
  |  |  |  Branch (62:66): [Folded, False: 174]
  |  |  ------------------
  ------------------
  895|    174|    SNMP_FREE(tp->description);
  ------------------
  |  |   62|    174|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 174]
  |  |  |  Branch (62:66): [Folded, False: 174]
  |  |  ------------------
  ------------------
  896|    174|    SNMP_FREE(tp->reference);
  ------------------
  |  |   62|    174|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 174]
  |  |  |  Branch (62:66): [Folded, False: 174]
  |  |  ------------------
  ------------------
  897|    174|    SNMP_FREE(tp->augments);
  ------------------
  |  |   62|    174|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 174]
  |  |  |  Branch (62:66): [Folded, False: 174]
  |  |  ------------------
  ------------------
  898|       |    SNMP_FREE(tp->defaultValue);
  ------------------
  |  |   62|    174|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 174]
  |  |  |  Branch (62:66): [Folded, False: 174]
  |  |  ------------------
  ------------------
  899|    174|}
parse.c:scan_directory:
 5511|    115|{
 5512|    115|    DIR            *dir, *dir2;
 5513|    115|    struct dirent  *file;
 5514|    115|    char          **filenames = NULL;
 5515|    115|    int             fname_len, i, filename_count = 0, array_size = 0;
 5516|    115|    char           *tmpstr;
 5517|       |
 5518|    115|    *result = NULL;
 5519|       |
 5520|    115|    dir = opendir(dirname);
 5521|    115|    if (!dir)
  ------------------
  |  Branch (5521:9): [True: 115, False: 0]
  ------------------
 5522|    115|        return -1;
 5523|       |
 5524|      0|    while ((file = readdir(dir))) {
  ------------------
  |  Branch (5524:12): [True: 0, False: 0]
  ------------------
 5525|       |        /*
 5526|       |         * Only parse file names that don't begin with a '.'
 5527|       |         * Also skip files ending in '~', or starting/ending
 5528|       |         * with '#' which are typically editor backup files.
 5529|       |         */
 5530|      0|        fname_len = strlen(file->d_name);
 5531|      0|        if (fname_len > 0 && file->d_name[0] != '.'
  ------------------
  |  Branch (5531:13): [True: 0, False: 0]
  |  Branch (5531:30): [True: 0, False: 0]
  ------------------
 5532|      0|            && file->d_name[0] != '#'
  ------------------
  |  Branch (5532:16): [True: 0, False: 0]
  ------------------
 5533|      0|            && file->d_name[fname_len-1] != '#'
  ------------------
  |  Branch (5533:16): [True: 0, False: 0]
  ------------------
 5534|      0|            && file->d_name[fname_len-1] != '~') {
  ------------------
  |  Branch (5534:16): [True: 0, False: 0]
  ------------------
 5535|      0|            if (asprintf(&tmpstr, "%s/%s", dirname, file->d_name) < 0)
  ------------------
  |  Branch (5535:17): [True: 0, False: 0]
  ------------------
 5536|      0|                continue;
 5537|      0|            dir2 = opendir(tmpstr);
 5538|      0|            if (dir2) {
  ------------------
  |  Branch (5538:17): [True: 0, False: 0]
  ------------------
 5539|       |                /* file is a directory, don't read it */
 5540|      0|                closedir(dir2);
 5541|      0|            } else {
 5542|      0|                if (filename_count >= array_size) {
  ------------------
  |  Branch (5542:21): [True: 0, False: 0]
  ------------------
 5543|      0|                    char **new_filenames;
 5544|       |
 5545|      0|                    array_size = (array_size + 16) * 2;
 5546|      0|                    new_filenames = realloc(filenames,
 5547|      0|                                        array_size * sizeof(filenames[0]));
 5548|      0|                    if (!new_filenames) {
  ------------------
  |  Branch (5548:25): [True: 0, False: 0]
  ------------------
 5549|      0|                        free(tmpstr);
 5550|      0|                        for (i = 0; i < filename_count; i++)
  ------------------
  |  Branch (5550:37): [True: 0, False: 0]
  ------------------
 5551|      0|                            free(filenames[i]);
 5552|      0|                        free(filenames);
 5553|      0|                        closedir(dir);
 5554|      0|                        return -1;
 5555|      0|                    }
 5556|      0|                    filenames = new_filenames;
 5557|      0|                }
 5558|      0|                filenames[filename_count++] = tmpstr;
 5559|      0|                tmpstr = NULL;
 5560|      0|            }
 5561|      0|            free(tmpstr);
 5562|      0|        }
 5563|      0|    }
 5564|      0|    closedir(dir);
 5565|       |
 5566|      0|    if (filenames)
  ------------------
  |  Branch (5566:9): [True: 0, False: 0]
  ------------------
 5567|      0|        qsort(filenames, filename_count, sizeof(filenames[0]), elemcmp);
 5568|      0|    *result = filenames;
 5569|       |
 5570|      0|    return filename_count;
 5571|      0|}
parse.c:free_ranges:
 5861|    174|{
 5862|    174|    if (spp && *spp) {
  ------------------
  |  Branch (5862:9): [True: 174, False: 0]
  |  Branch (5862:16): [True: 0, False: 174]
  ------------------
 5863|      0|        struct range_list *pp, *npp;
 5864|       |
 5865|      0|        pp = *spp;
 5866|      0|        *spp = NULL;
 5867|       |
 5868|      0|        while (pp) {
  ------------------
  |  Branch (5868:16): [True: 0, False: 0]
  ------------------
 5869|      0|            npp = pp->next;
 5870|      0|            free(pp);
 5871|      0|            pp = npp;
 5872|      0|        }
 5873|      0|    }
 5874|    174|}
parse.c:free_enums:
 5878|    174|{
 5879|    174|    if (spp && *spp) {
  ------------------
  |  Branch (5879:9): [True: 174, False: 0]
  |  Branch (5879:16): [True: 0, False: 174]
  ------------------
 5880|      0|        struct enum_list *pp, *npp;
 5881|       |
 5882|      0|        pp = *spp;
 5883|      0|        *spp = NULL;
 5884|       |
 5885|      0|        while (pp) {
  ------------------
  |  Branch (5885:16): [True: 0, False: 0]
  ------------------
 5886|      0|            npp = pp->next;
 5887|      0|            if (pp->label)
  ------------------
  |  Branch (5887:17): [True: 0, False: 0]
  ------------------
 5888|      0|                free(pp->label);
 5889|      0|            free(pp);
 5890|      0|            pp = npp;
 5891|      0|        }
 5892|      0|    }
 5893|    174|}

register_prenetsnmp_mib_handler:
  256|  2.03k|{
  257|  2.03k|    return internal_register_config_handler(type, token, parser, NULL, releaser,
  258|  2.03k|					    help, PREMIB_CONFIG);
  ------------------
  |  |   15|  2.03k|#define PREMIB_CONFIG 1
  ------------------
  259|  2.03k|}
register_config_handler:
  311|  3.65k|{
  312|  3.65k|    return internal_register_config_handler(type, token, parser, NULL, releaser,
  313|  3.65k|					    help, NORMAL_CONFIG);
  ------------------
  |  |   14|  3.65k|#define NORMAL_CONFIG 0
  ------------------
  314|  3.65k|}
register_const_config_handler:
  321|     58|{
  322|     58|    return internal_register_config_handler(type, token, NULL, parser, releaser,
  323|     58|					    help, NORMAL_CONFIG);
  ------------------
  |  |   14|     58|#define NORMAL_CONFIG 0
  ------------------
  324|     58|}
register_app_config_handler:
  330|    116|{
  331|       |    return register_config_handler(NULL, token, parser, releaser, help);
  332|    116|}
unregister_config_handler:
  356|  9.68k|{
  357|  9.68k|    struct config_files **ctmp = &config_files;
  358|  9.68k|    struct config_line  **ltmp;
  359|  9.68k|    const char           *type = type_param;
  360|       |
  361|  9.68k|    if (type == NULL || *type == '\0') {
  ------------------
  |  Branch (361:9): [True: 0, False: 9.68k]
  |  Branch (361:25): [True: 0, False: 9.68k]
  ------------------
  362|      0|        type = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|      0|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  363|      0|				     NETSNMP_DS_LIB_APPTYPE);
  ------------------
  |  |  157|      0|#define NETSNMP_DS_LIB_APPTYPE           6
  ------------------
  364|      0|    }
  365|       |
  366|       |    /*
  367|       |     * Handle multiple types (recursively)
  368|       |     */
  369|  9.68k|    if (strchr(type, ':')) {
  ------------------
  |  Branch (369:9): [True: 0, False: 9.68k]
  ------------------
  370|      0|        char                buf[STRINGMAX];
  371|      0|        char               *cptr = buf;
  372|       |
  373|      0|        strlcpy(buf, type, STRINGMAX);
  ------------------
  |  |   12|      0|#define STRINGMAX 1024
  ------------------
  374|      0|        while (cptr) {
  ------------------
  |  Branch (374:16): [True: 0, False: 0]
  ------------------
  375|      0|            char* c = cptr;
  376|      0|            cptr = strchr(cptr, ':');
  377|      0|            if(cptr) {
  ------------------
  |  Branch (377:16): [True: 0, False: 0]
  ------------------
  378|      0|                *cptr = '\0';
  379|      0|                ++cptr;
  380|      0|            }
  381|      0|            unregister_config_handler(c, token);
  382|      0|        }
  383|      0|        return;
  384|      0|    }
  385|       |    
  386|       |    /*
  387|       |     * find type in current list 
  388|       |     */
  389|  9.68k|    while (*ctmp != NULL && strcmp((*ctmp)->fileHeader, type)) {
  ------------------
  |  Branch (389:12): [True: 5.85k, False: 3.82k]
  |  Branch (389:29): [True: 0, False: 5.85k]
  ------------------
  390|      0|        ctmp = &((*ctmp)->next);
  391|      0|    }
  392|       |
  393|  9.68k|    if (*ctmp == NULL) {
  ------------------
  |  Branch (393:9): [True: 3.82k, False: 5.85k]
  ------------------
  394|       |        /*
  395|       |         * Not found, return. 
  396|       |         */
  397|  3.82k|        return;
  398|  3.82k|    }
  399|       |
  400|  5.85k|    ltmp = &((*ctmp)->start);
  401|  5.85k|    if (*ltmp == NULL) {
  ------------------
  |  Branch (401:9): [True: 0, False: 5.85k]
  ------------------
  402|       |        /*
  403|       |         * Not found, return. 
  404|       |         */
  405|      0|        return;
  406|      0|    }
  407|  5.85k|    if (strcmp((*ltmp)->config_token, token) == 0) {
  ------------------
  |  Branch (407:9): [True: 5.85k, False: 0]
  ------------------
  408|       |        /*
  409|       |         * found it at the top of the list 
  410|       |         */
  411|  5.85k|        struct config_line *ltmp2 = (*ltmp)->next;
  412|  5.85k|        if ((*ltmp)->free_func)
  ------------------
  |  Branch (412:13): [True: 406, False: 5.45k]
  ------------------
  413|    406|            (*ltmp)->free_func();
  414|  5.85k|        SNMP_FREE((*ltmp)->config_token);
  ------------------
  |  |   62|  5.85k|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 5.85k, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 5.85k]
  |  |  ------------------
  ------------------
  415|  5.85k|        SNMP_FREE((*ltmp)->help);
  ------------------
  |  |   62|  5.85k|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 5.16k, False: 696]
  |  |  |  Branch (62:66): [Folded, False: 5.85k]
  |  |  ------------------
  ------------------
  416|  5.85k|        SNMP_FREE(*ltmp);
  ------------------
  |  |   62|  5.85k|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 5.85k, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 5.85k]
  |  |  ------------------
  ------------------
  417|  5.85k|        (*ctmp)->start = ltmp2;
  418|  5.85k|        return;
  419|  5.85k|    }
  420|      0|    while ((*ltmp)->next != NULL
  ------------------
  |  Branch (420:12): [True: 0, False: 0]
  ------------------
  421|      0|           && strcmp((*ltmp)->next->config_token, token)) {
  ------------------
  |  Branch (421:15): [True: 0, False: 0]
  ------------------
  422|      0|        ltmp = &((*ltmp)->next);
  423|      0|    }
  424|      0|    if ((*ltmp)->next != NULL) {
  ------------------
  |  Branch (424:9): [True: 0, False: 0]
  ------------------
  425|      0|        struct config_line *ltmp2 = (*ltmp)->next->next;
  426|      0|        if ((*ltmp)->next->free_func)
  ------------------
  |  Branch (426:13): [True: 0, False: 0]
  ------------------
  427|      0|            (*ltmp)->next->free_func();
  428|      0|        SNMP_FREE((*ltmp)->next->config_token);
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
  429|      0|        SNMP_FREE((*ltmp)->next->help);
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
  430|       |        SNMP_FREE((*ltmp)->next);
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
  431|      0|        (*ltmp)->next = ltmp2;
  432|      0|    }
  433|      0|}
unregister_all_config_handlers:
  445|     58|{
  446|     58|    struct config_files *ctmp, *save;
  447|     58|    struct config_line *ltmp;
  448|       |
  449|       |    /*
  450|       |     * Keep using config_files until there are no more! 
  451|       |     */
  452|    174|    for (ctmp = config_files; ctmp;) {
  ------------------
  |  Branch (452:31): [True: 116, False: 58]
  ------------------
  453|  5.97k|        for (ltmp = ctmp->start; ltmp; ltmp = ctmp->start) {
  ------------------
  |  Branch (453:34): [True: 5.85k, False: 116]
  ------------------
  454|  5.85k|            unregister_config_handler(ctmp->fileHeader,
  455|  5.85k|                                      ltmp->config_token);
  456|  5.85k|        }
  457|    116|        SNMP_FREE(ctmp->fileHeader);
  ------------------
  |  |   62|    116|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 116, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 116]
  |  |  ------------------
  ------------------
  458|    116|        save = ctmp->next;
  459|       |        SNMP_FREE(ctmp);
  ------------------
  |  |   62|    116|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 116, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 116]
  |  |  ------------------
  ------------------
  460|    116|        ctmp = save;
  461|    116|        config_files = save;
  462|    116|    }
  463|     58|}
netsnmp_config_remember_free_list:
  695|     58|{
  696|     58|    struct read_config_memory *tmpmem;
  697|     58|    while (*mem) {
  ------------------
  |  Branch (697:12): [True: 0, False: 58]
  ------------------
  698|      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]
  |  |  ------------------
  ------------------
  699|      0|        tmpmem = (*mem)->next;
  700|       |        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]
  |  |  ------------------
  ------------------
  701|      0|        *mem = tmpmem;
  702|      0|    }
  703|     58|}
netsnmp_config_process_memory_list:
  708|    116|{
  709|       |
  710|    116|    struct read_config_memory *mem;
  711|       |
  712|    116|    if (!memp)
  ------------------
  |  Branch (712:9): [True: 0, False: 116]
  ------------------
  713|      0|        return;
  714|       |
  715|    116|    mem = *memp;
  716|       |
  717|    116|    while (mem) {
  ------------------
  |  Branch (717:12): [True: 0, False: 116]
  ------------------
  718|      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]
  |  |  ------------------
  ------------------
  719|      0|        snmp_config_when(mem->line, when);
  720|      0|        mem = mem->next;
  721|      0|    }
  722|       |
  723|    116|    if (clear)
  ------------------
  |  Branch (723:9): [True: 58, False: 58]
  ------------------
  724|     58|        netsnmp_config_remember_free_list(memp);
  725|    116|}
netsnmp_config_process_memories_when:
  746|    116|{
  747|    116|    netsnmp_config_process_memory_list(&memorylist, when, clear);
  748|    116|}
free_config:
 1036|     58|{
 1037|     58|    struct config_files *ctmp = config_files;
 1038|     58|    struct config_line *ltmp;
 1039|       |
 1040|    174|    for (; ctmp != NULL; ctmp = ctmp->next)
  ------------------
  |  Branch (1040:12): [True: 116, False: 58]
  ------------------
 1041|  5.97k|        for (ltmp = ctmp->start; ltmp != NULL; ltmp = ltmp->next)
  ------------------
  |  Branch (1041:34): [True: 5.85k, False: 116]
  ------------------
 1042|  5.85k|            if (ltmp->free_func)
  ------------------
  |  Branch (1042:17): [True: 406, False: 5.45k]
  ------------------
 1043|    406|                (*(ltmp->free_func)) ();
 1044|     58|}
read_configs:
 1089|     58|{
 1090|     58|    char *optional_config = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1091|     58|					       NETSNMP_DS_LIB_OPTIONALCONFIG);
  ------------------
  |  |  156|     58|#define NETSNMP_DS_LIB_OPTIONALCONFIG    5
  ------------------
 1092|       |
 1093|     58|    snmp_call_callbacks(SNMP_CALLBACK_LIBRARY,
  ------------------
  |  |   18|     58|#define SNMP_CALLBACK_LIBRARY     0
  ------------------
 1094|     58|                        SNMP_CALLBACK_PRE_READ_CONFIG, NULL);
  ------------------
  |  |   30|     58|#define SNMP_CALLBACK_PRE_READ_CONFIG	        7
  ------------------
 1095|       |
 1096|     58|    DEBUGMSGTL(("read_config", "reading normal configuration tokens\n"));
  ------------------
  |  |   66|     58|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     58|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 58]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 58]
  |  |  ------------------
  ------------------
 1097|       |
 1098|     58|    if ((NULL != optional_config) && (*optional_config == '-')) {
  ------------------
  |  Branch (1098:9): [True: 0, False: 58]
  |  Branch (1098:38): [True: 0, False: 0]
  ------------------
 1099|      0|        (void)read_configs_optional(++optional_config, NORMAL_CONFIG);
  ------------------
  |  |   14|      0|#define NORMAL_CONFIG 0
  ------------------
 1100|      0|        optional_config = NULL; /* clear, so we don't read them twice */
 1101|      0|    }
 1102|       |
 1103|     58|    (void)read_config_files(NORMAL_CONFIG);
  ------------------
  |  |   14|     58|#define NORMAL_CONFIG 0
  ------------------
 1104|       |
 1105|       |    /*
 1106|       |     * do this even when the normal above wasn't done 
 1107|       |     */
 1108|     58|    if (NULL != optional_config)
  ------------------
  |  Branch (1108:9): [True: 0, False: 58]
  ------------------
 1109|      0|        (void)read_configs_optional(optional_config, NORMAL_CONFIG);
  ------------------
  |  |   14|      0|#define NORMAL_CONFIG 0
  ------------------
 1110|       |
 1111|     58|    netsnmp_config_process_memories_when(NORMAL_CONFIG, 1);
  ------------------
  |  |   14|     58|#define NORMAL_CONFIG 0
  ------------------
 1112|       |
 1113|     58|    netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1114|     58|			   NETSNMP_DS_LIB_HAVE_READ_CONFIG, 1);
  ------------------
  |  |   87|     58|#define NETSNMP_DS_LIB_HAVE_READ_CONFIG    27   /* have the config tokens been processed */
  ------------------
 1115|     58|    snmp_call_callbacks(SNMP_CALLBACK_LIBRARY,
  ------------------
  |  |   18|     58|#define SNMP_CALLBACK_LIBRARY     0
  ------------------
 1116|     58|                        SNMP_CALLBACK_POST_READ_CONFIG, NULL);
  ------------------
  |  |   24|     58|#define SNMP_CALLBACK_POST_READ_CONFIG	        0
  ------------------
 1117|     58|}
read_premib_configs:
 1121|     58|{
 1122|     58|    char *optional_config = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1123|     58|					       NETSNMP_DS_LIB_OPTIONALCONFIG);
  ------------------
  |  |  156|     58|#define NETSNMP_DS_LIB_OPTIONALCONFIG    5
  ------------------
 1124|       |
 1125|     58|    snmp_call_callbacks(SNMP_CALLBACK_LIBRARY,
  ------------------
  |  |   18|     58|#define SNMP_CALLBACK_LIBRARY     0
  ------------------
 1126|     58|                        SNMP_CALLBACK_PRE_PREMIB_READ_CONFIG, NULL);
  ------------------
  |  |   31|     58|#define SNMP_CALLBACK_PRE_PREMIB_READ_CONFIG	8
  ------------------
 1127|       |
 1128|     58|    DEBUGMSGTL(("read_config", "reading premib configuration tokens\n"));
  ------------------
  |  |   66|     58|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     58|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 58]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 58]
  |  |  ------------------
  ------------------
 1129|       |
 1130|     58|    if ((NULL != optional_config) && (*optional_config == '-')) {
  ------------------
  |  Branch (1130:9): [True: 0, False: 58]
  |  Branch (1130:38): [True: 0, False: 0]
  ------------------
 1131|      0|        (void)read_configs_optional(++optional_config, PREMIB_CONFIG);
  ------------------
  |  |   15|      0|#define PREMIB_CONFIG 1
  ------------------
 1132|      0|        optional_config = NULL; /* clear, so we don't read them twice */
 1133|      0|    }
 1134|       |
 1135|     58|    (void)read_config_files(PREMIB_CONFIG);
  ------------------
  |  |   15|     58|#define PREMIB_CONFIG 1
  ------------------
 1136|       |
 1137|     58|    if (NULL != optional_config)
  ------------------
  |  Branch (1137:9): [True: 0, False: 58]
  ------------------
 1138|      0|        (void)read_configs_optional(optional_config, PREMIB_CONFIG);
  ------------------
  |  |   15|      0|#define PREMIB_CONFIG 1
  ------------------
 1139|       |
 1140|     58|    netsnmp_config_process_memories_when(PREMIB_CONFIG, 0);
  ------------------
  |  |   15|     58|#define PREMIB_CONFIG 1
  ------------------
 1141|       |
 1142|     58|    netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1143|     58|			   NETSNMP_DS_LIB_HAVE_READ_PREMIB_CONFIG, 1);
  ------------------
  |  |   86|     58|#define NETSNMP_DS_LIB_HAVE_READ_PREMIB_CONFIG 26       /* have the pre-mib parsing config tokens been processed */
  ------------------
 1144|     58|    snmp_call_callbacks(SNMP_CALLBACK_LIBRARY,
  ------------------
  |  |   18|     58|#define SNMP_CALLBACK_LIBRARY     0
  ------------------
 1145|     58|                        SNMP_CALLBACK_POST_PREMIB_READ_CONFIG, NULL);
  ------------------
  |  |   27|     58|#define SNMP_CALLBACK_POST_PREMIB_READ_CONFIG	3
  ------------------
 1146|     58|}
set_configuration_directory:
 1158|      1|{
 1159|      1|    netsnmp_ds_set_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1160|      1|			  NETSNMP_DS_LIB_CONFIGURATION_DIR, dir);
  ------------------
  |  |  160|      1|#define NETSNMP_DS_LIB_CONFIGURATION_DIR 9
  ------------------
 1161|      1|}
get_configuration_directory:
 1177|      1|{
 1178|      1|    char            defaultPath[SPRINT_MAX_LEN];
 1179|      1|    const char     *homepath;
 1180|       |
 1181|      1|    if (NULL == netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (1181:9): [True: 1, False: 0]
  ------------------
 1182|      1|				      NETSNMP_DS_LIB_CONFIGURATION_DIR)) {
  ------------------
  |  |  160|      1|#define NETSNMP_DS_LIB_CONFIGURATION_DIR 9
  ------------------
 1183|      1|        homepath = netsnmp_gethomedir();
 1184|      1|        snprintf(defaultPath, sizeof(defaultPath), "%s%c%s%c%s%s%s%s",
 1185|      1|                SNMPCONFPATH, ENV_SEPARATOR_CHAR,
  ------------------
  |  | 2062|      1|#define SNMPCONFPATH "/usr/local/net-snmp-master/etc/snmp"
  ------------------
                              SNMPCONFPATH, ENV_SEPARATOR_CHAR,
  ------------------
  |  |   70|      1|#define ENV_SEPARATOR_CHAR ':'
  ------------------
 1186|      1|                SNMPSHAREPATH, ENV_SEPARATOR_CHAR, SNMPLIBPATH,
  ------------------
  |  | 2061|      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,
  ------------------
  |  | 2060|      1|#define SNMPLIBPATH "/usr/local/net-snmp-master/lib/snmp"
  ------------------
 1187|      1|                ((homepath == NULL) ? "" : ENV_SEPARATOR),
  ------------------
  |  |   67|      1|#define ENV_SEPARATOR ":"
  ------------------
  |  Branch (1187:18): [True: 0, False: 1]
  ------------------
 1188|      1|                ((homepath == NULL) ? "" : homepath),
  ------------------
  |  Branch (1188:18): [True: 0, False: 1]
  ------------------
 1189|      1|                ((homepath == NULL) ? "" : "/.snmp"));
  ------------------
  |  Branch (1189:18): [True: 0, False: 1]
  ------------------
 1190|      1|        defaultPath[ sizeof(defaultPath)-1 ] = 0;
 1191|      1|        set_configuration_directory(defaultPath);
 1192|      1|    }
 1193|      1|    return (netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1194|      1|				  NETSNMP_DS_LIB_CONFIGURATION_DIR));
  ------------------
  |  |  160|      1|#define NETSNMP_DS_LIB_CONFIGURATION_DIR 9
  ------------------
 1195|      1|}
get_persistent_directory:
 1225|      1|{
 1226|      1|    if (NULL == netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (1226:9): [True: 0, False: 1]
  ------------------
 1227|      1|				      NETSNMP_DS_LIB_PERSISTENT_DIR)) {
  ------------------
  |  |  159|      1|#define NETSNMP_DS_LIB_PERSISTENT_DIR    8
  ------------------
 1228|      0|        const char *persdir = netsnmp_getenv("SNMP_PERSISTENT_DIR");
 1229|      0|        if (NULL == persdir)
  ------------------
  |  Branch (1229:13): [True: 0, False: 0]
  ------------------
 1230|      0|            persdir = NETSNMP_PERSISTENT_DIRECTORY;
  ------------------
  |  | 2032|      0|#define NETSNMP_PERSISTENT_DIRECTORY "/var/net-snmp"
  ------------------
 1231|      0|        set_persistent_directory(persdir);
 1232|      0|    }
 1233|      1|    return (netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1234|      1|				  NETSNMP_DS_LIB_PERSISTENT_DIR));
  ------------------
  |  |  159|      1|#define NETSNMP_DS_LIB_PERSISTENT_DIR    8
  ------------------
 1235|      1|}
read_config_files_of_type:
 1419|    232|{
 1420|    232|    const char     *confpath, *persfile, *envconfpath;
 1421|    232|    char           *perspath;
 1422|    232|    int             ret = SNMPERR_GENERR;
  ------------------
  |  |  185|    232|#define SNMPERR_GENERR			(-1)
  ------------------
 1423|       |
 1424|    232|    if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|    232|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (1424:9): [True: 232, False: 0]
  ------------------
 1425|    232|                               NETSNMP_DS_LIB_DONT_PERSIST_STATE)
  ------------------
  |  |   92|    232|#define NETSNMP_DS_LIB_DONT_PERSIST_STATE  32	/* don't load config and don't load/save persistent file */
  ------------------
 1426|      0|        || netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      0|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (1426:12): [True: 0, False: 0]
  ------------------
 1427|      0|                                  NETSNMP_DS_LIB_DISABLE_CONFIG_LOAD)
  ------------------
  |  |   66|      0|#define NETSNMP_DS_LIB_DISABLE_CONFIG_LOAD      NETSNMP_DS_LIB_DONT_READ_CONFIGS
  |  |  ------------------
  |  |  |  |   65|      0|#define NETSNMP_DS_LIB_DONT_READ_CONFIGS   6    /* don't read normal config files */
  |  |  ------------------
  ------------------
 1428|    232|        || (NULL == ctmp)) return ret;
  ------------------
  |  Branch (1428:12): [True: 0, False: 0]
  ------------------
 1429|       |
 1430|       |    /*
 1431|       |     * these shouldn't change
 1432|       |     */
 1433|      0|    confpath = get_configuration_directory();
 1434|      0|    persfile = netsnmp_getenv("SNMP_PERSISTENT_FILE");
 1435|      0|    envconfpath = netsnmp_getenv("SNMPCONFPATH");
 1436|       |
 1437|       |
 1438|       |        /*
 1439|       |         * read the config files. strdup() the result of
 1440|       |         * get_persistent_directory() to avoid that parsing the "persistentDir"
 1441|       |         * keyword transforms the perspath pointer into a dangling pointer.
 1442|       |         */
 1443|      0|        perspath = strdup(get_persistent_directory());
 1444|      0|        if (perspath == NULL) {
  ------------------
  |  Branch (1444:13): [True: 0, False: 0]
  ------------------
 1445|      0|            return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
 1446|      0|        }
 1447|      0|        if (envconfpath == NULL) {
  ------------------
  |  Branch (1447:13): [True: 0, False: 0]
  ------------------
 1448|       |            /*
 1449|       |             * read just the config files (no persistent stuff), since
 1450|       |             * persistent path can change via conf file. Then get the
 1451|       |             * current persistent directory, and read files there.
 1452|       |             */
 1453|      0|            if ( read_config_files_in_path(confpath, ctmp, when, perspath,
  ------------------
  |  Branch (1453:18): [True: 0, False: 0]
  ------------------
 1454|      0|                                      persfile) == SNMPERR_SUCCESS )
  ------------------
  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 1455|      0|                ret = SNMPERR_SUCCESS;
  ------------------
  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 1456|      0|            free(perspath);
 1457|      0|            perspath = strdup(get_persistent_directory());
 1458|      0|            if (perspath == NULL) {
  ------------------
  |  Branch (1458:17): [True: 0, False: 0]
  ------------------
 1459|      0|                return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
 1460|      0|            }
 1461|      0|            if ( read_config_files_in_path(perspath, ctmp, when, perspath,
  ------------------
  |  Branch (1461:18): [True: 0, False: 0]
  ------------------
 1462|      0|                                      persfile) == SNMPERR_SUCCESS )
  ------------------
  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 1463|      0|                ret = SNMPERR_SUCCESS;
  ------------------
  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 1464|      0|        }
 1465|      0|        else {
 1466|       |            /*
 1467|       |             * only read path specified by user
 1468|       |             */
 1469|      0|            if ( read_config_files_in_path(envconfpath, ctmp, when, perspath,
  ------------------
  |  Branch (1469:18): [True: 0, False: 0]
  ------------------
 1470|      0|                                      persfile) == SNMPERR_SUCCESS )
  ------------------
  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 1471|      0|                ret = SNMPERR_SUCCESS;
  ------------------
  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 1472|      0|        }
 1473|      0|        free(perspath);
 1474|      0|        return ret;
 1475|      0|}
read_config_files:
 1483|    116|read_config_files(int when) {
 1484|       |
 1485|    116|    struct config_files *ctmp = config_files;
 1486|    116|    int                  ret  = SNMPERR_GENERR;
  ------------------
  |  |  185|    116|#define SNMPERR_GENERR			(-1)
  ------------------
 1487|       |
 1488|    116|    config_errors = 0;
 1489|       |
 1490|    116|    if (when == PREMIB_CONFIG)
  ------------------
  |  |   15|    116|#define PREMIB_CONFIG 1
  ------------------
  |  Branch (1490:9): [True: 58, False: 58]
  ------------------
 1491|     58|        free_config();
 1492|       |
 1493|       |    /*
 1494|       |     * read all config file types 
 1495|       |     */
 1496|    348|    for (; ctmp != NULL; ctmp = ctmp->next) {
  ------------------
  |  Branch (1496:12): [True: 232, False: 116]
  ------------------
 1497|    232|        if ( read_config_files_of_type(when, ctmp) == SNMPERR_SUCCESS )
  ------------------
  |  |  184|    232|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  |  Branch (1497:14): [True: 0, False: 232]
  ------------------
 1498|      0|            ret = SNMPERR_SUCCESS;
  ------------------
  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 1499|    232|    }
 1500|       |
 1501|    116|    if (config_errors) {
  ------------------
  |  Branch (1501:9): [True: 0, False: 116]
  ------------------
 1502|       |        snmp_log(LOG_ERR, "net-snmp: %d error(s) in config file(s)\n",
 1503|      0|                 config_errors);
 1504|      0|    }
 1505|    116|    return ret;
 1506|    116|}
read_config_store:
 1555|    116|{
 1556|    116|#ifdef NETSNMP_PERSISTENT_DIRECTORY
 1557|    116|    char            file[512], *filep;
 1558|    116|    FILE           *fout;
 1559|    116|#ifdef NETSNMP_PERSISTENT_MASK
 1560|    116|    mode_t          oldmask;
 1561|    116|#endif
 1562|       |
 1563|    116|    if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|    116|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (1563:9): [True: 116, False: 0]
  ------------------
 1564|    116|                               NETSNMP_DS_LIB_DONT_PERSIST_STATE)
  ------------------
  |  |   92|    116|#define NETSNMP_DS_LIB_DONT_PERSIST_STATE  32	/* don't load config and don't load/save persistent file */
  ------------------
 1565|      0|     || netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      0|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (1565:9): [True: 0, False: 0]
  ------------------
 1566|    116|                               NETSNMP_DS_LIB_DISABLE_PERSISTENT_LOAD)) return;
  ------------------
  |  |   95|      0|#define NETSNMP_DS_LIB_DISABLE_PERSISTENT_LOAD  35 /* don't load persistent file */
  ------------------
 1567|       |
 1568|       |    /*
 1569|       |     * store configuration directives in the following order of preference:
 1570|       |     * 1. ENV variable SNMP_PERSISTENT_FILE
 1571|       |     * 2. configured <NETSNMP_PERSISTENT_DIRECTORY>/<type>.conf
 1572|       |     */
 1573|      0|    if ((filep = netsnmp_getenv("SNMP_PERSISTENT_FILE")) == NULL) {
  ------------------
  |  Branch (1573:9): [True: 0, False: 0]
  ------------------
 1574|      0|        snprintf(file, sizeof(file),
 1575|      0|                 "%s/%s.conf", get_persistent_directory(), type);
 1576|      0|        filep = file;
 1577|      0|    }
 1578|      0|#ifdef NETSNMP_PERSISTENT_MASK
 1579|      0|    oldmask = umask(NETSNMP_PERSISTENT_MASK);
  ------------------
  |  | 1767|      0|#define NETSNMP_PERSISTENT_MASK 077
  ------------------
 1580|      0|#endif
 1581|      0|    if (mkdirhier(filep, NETSNMP_AGENT_DIRECTORY_MODE, 1)) {
  ------------------
  |  | 2037|      0|#define NETSNMP_AGENT_DIRECTORY_MODE 0700
  ------------------
  |  Branch (1581:9): [True: 0, False: 0]
  ------------------
 1582|      0|        snmp_log(LOG_ERR,
 1583|      0|                 "Failed to create the persistent directory for %s\n",
 1584|      0|                 filep);
 1585|      0|    }
 1586|      0|    if ((fout = fopen(filep, "a")) != NULL) {
  ------------------
  |  Branch (1586:9): [True: 0, False: 0]
  ------------------
 1587|      0|        fprintf(fout, "%s", line);
 1588|      0|        if (line[strlen(line)] != '\n')
  ------------------
  |  Branch (1588:13): [True: 0, False: 0]
  ------------------
 1589|      0|            fprintf(fout, "\n");
 1590|      0|        DEBUGMSGTL(("read_config:store", "storing: %s\n", 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]
  |  |  ------------------
  ------------------
 1591|      0|        fflush(fout);
 1592|      0|#if defined(HAVE_FSYNC)
 1593|      0|        fsync(fileno(fout));
 1594|       |#elif defined(HAVE__GET_OSFHANDLE)
 1595|       |        {
 1596|       |            int fd;
 1597|       |            HANDLE h;
 1598|       |
 1599|       |            fd = fileno(fout);
 1600|       |            netsnmp_assert(fd != -1);
 1601|       |            /*
 1602|       |             * Use size_t instead of uintptr_t because not all supported
 1603|       |             * Windows compilers support uintptr_t.
 1604|       |             */
 1605|       |            h = (HANDLE)(size_t)_get_osfhandle(fd);
 1606|       |            netsnmp_assert(h != INVALID_HANDLE_VALUE);
 1607|       |            FlushFileBuffers(h);
 1608|       |        }
 1609|       |#endif
 1610|      0|        fclose(fout);
 1611|      0|    } else {
 1612|      0|        if (strcmp(NETSNMP_APPLICATION_CONFIG_TYPE, type) != 0) {
  ------------------
  |  |   22|      0|#define NETSNMP_APPLICATION_CONFIG_TYPE "snmpapp"
  ------------------
  |  Branch (1612:13): [True: 0, False: 0]
  ------------------
 1613|       |            /*
 1614|       |             * Ignore this error in client utilities, they can run with random
 1615|       |             * UID/GID and typically cannot write to /var. Error message just
 1616|       |             * confuses people.
 1617|       |             */
 1618|      0|            snmp_log(LOG_ERR, "read_config_store open failure on %s\n", filep);
 1619|      0|        }
 1620|      0|    }
 1621|      0|#ifdef NETSNMP_PERSISTENT_MASK
 1622|      0|    umask(oldmask);
 1623|      0|#endif
 1624|       |
 1625|      0|#endif
 1626|      0|}                               /* end read_config_store() */
snmp_save_persistent:
 1659|     58|{
 1660|     58|    char            file[512], fileold[SPRINT_MAX_LEN];
 1661|     58|    struct stat     statbuf;
 1662|     58|    int             j;
 1663|       |
 1664|     58|    if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (1664:9): [True: 58, False: 0]
  ------------------
 1665|     58|                               NETSNMP_DS_LIB_DONT_PERSIST_STATE)
  ------------------
  |  |   92|     58|#define NETSNMP_DS_LIB_DONT_PERSIST_STATE  32	/* don't load config and don't load/save persistent file */
  ------------------
 1666|      0|     || netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      0|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (1666:9): [True: 0, False: 0]
  ------------------
 1667|     58|                               NETSNMP_DS_LIB_DISABLE_PERSISTENT_SAVE)) return;
  ------------------
  |  |   96|      0|#define NETSNMP_DS_LIB_DISABLE_PERSISTENT_SAVE  36 /* don't save persistent file */
  ------------------
 1668|       |
 1669|      0|    DEBUGMSGTL(("snmp_save_persistent", "saving %s files...\n", type));
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 1670|      0|    snprintf(file, sizeof(file),
 1671|      0|             "%s/%s.conf", get_persistent_directory(), type);
 1672|      0|    if (stat(file, &statbuf) == 0) {
  ------------------
  |  Branch (1672:9): [True: 0, False: 0]
  ------------------
 1673|      0|        for (j = 0; j <= NETSNMP_MAX_PERSISTENT_BACKUPS; j++) {
  ------------------
  |  | 2044|      0|#define NETSNMP_MAX_PERSISTENT_BACKUPS 10
  ------------------
  |  Branch (1673:21): [True: 0, False: 0]
  ------------------
 1674|      0|            snprintf(fileold, sizeof(fileold),
 1675|      0|                     "%s/%s.%d.conf", get_persistent_directory(), type, j);
 1676|      0|            if (stat(fileold, &statbuf) != 0) {
  ------------------
  |  Branch (1676:17): [True: 0, False: 0]
  ------------------
 1677|      0|                DEBUGMSGTL(("snmp_save_persistent",
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 1678|      0|                            " saving old config file: %s -> %s.\n", file,
 1679|      0|                            fileold));
 1680|      0|                if (rename(file, fileold)) {
  ------------------
  |  Branch (1680:21): [True: 0, False: 0]
  ------------------
 1681|      0|                    snmp_log(LOG_ERR, "Cannot rename %s to %s\n", file, fileold);
 1682|       |                     /* moving it failed, try nuking it, as leaving
 1683|       |                      * it around is very bad. */
 1684|      0|                    if (unlink(file) == -1)
  ------------------
  |  Branch (1684:25): [True: 0, False: 0]
  ------------------
 1685|      0|                        snmp_log(LOG_ERR, "Cannot unlink %s\n", file);
 1686|      0|                }
 1687|      0|                break;
 1688|      0|            }
 1689|      0|        }
 1690|      0|    }
 1691|       |    /*
 1692|       |     * save a warning header to the top of the new file 
 1693|       |     */
 1694|      0|    snprintf(fileold, sizeof(fileold),
 1695|      0|            "%s%s# Please save normal configuration tokens for %s in SNMPCONFPATH/%s.conf.\n# Only \"createUser\" tokens should be placed here by %s administrators.\n%s",
 1696|      0|            "#\n# net-snmp (or ucd-snmp) persistent data file.\n#\n############################################################################\n# STOP STOP STOP STOP STOP STOP STOP STOP STOP \n",
 1697|      0|            "#\n#          **** DO NOT EDIT THIS FILE ****\n#\n# STOP STOP STOP STOP STOP STOP STOP STOP STOP \n############################################################################\n#\n# DO NOT STORE CONFIGURATION ENTRIES HERE.\n",
 1698|      0|            type, type, type,
 1699|      0|	    "# (Did I mention: do not edit this file?)\n#\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
 1700|      0|    read_config_store(type, fileold);
 1701|      0|}
snmp_clean_persistent:
 1723|     58|{
 1724|     58|    char            file[512];
 1725|     58|    struct stat     statbuf;
 1726|     58|    int             j;
 1727|       |
 1728|     58|    if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (1728:9): [True: 58, False: 0]
  ------------------
 1729|     58|                               NETSNMP_DS_LIB_DONT_PERSIST_STATE)
  ------------------
  |  |   92|     58|#define NETSNMP_DS_LIB_DONT_PERSIST_STATE  32	/* don't load config and don't load/save persistent file */
  ------------------
 1730|      0|     || netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      0|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (1730:9): [True: 0, False: 0]
  ------------------
 1731|     58|                               NETSNMP_DS_LIB_DISABLE_PERSISTENT_SAVE)) return;
  ------------------
  |  |   96|      0|#define NETSNMP_DS_LIB_DISABLE_PERSISTENT_SAVE  36 /* don't save persistent file */
  ------------------
 1732|       |
 1733|      0|    DEBUGMSGTL(("snmp_clean_persistent", "cleaning %s files...\n", type));
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 1734|      0|    snprintf(file, sizeof(file),
 1735|      0|             "%s/%s.conf", get_persistent_directory(), type);
 1736|      0|    if (stat(file, &statbuf) == 0) {
  ------------------
  |  Branch (1736:9): [True: 0, False: 0]
  ------------------
 1737|      0|        for (j = 0; j <= NETSNMP_MAX_PERSISTENT_BACKUPS; j++) {
  ------------------
  |  | 2044|      0|#define NETSNMP_MAX_PERSISTENT_BACKUPS 10
  ------------------
  |  Branch (1737:21): [True: 0, False: 0]
  ------------------
 1738|      0|            snprintf(file, sizeof(file),
 1739|      0|                     "%s/%s.%d.conf", get_persistent_directory(), type, j);
 1740|      0|            if (stat(file, &statbuf) == 0) {
  ------------------
  |  Branch (1740:17): [True: 0, False: 0]
  ------------------
 1741|      0|                DEBUGMSGTL(("snmp_clean_persistent",
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 1742|      0|                            " removing old config file: %s\n", file));
 1743|      0|                if (unlink(file) == -1)
  ------------------
  |  Branch (1743:21): [True: 0, False: 0]
  ------------------
 1744|      0|                    snmp_log(LOG_ERR, "Cannot unlink %s\n", file);
 1745|      0|            }
 1746|      0|        }
 1747|      0|    }
 1748|      0|}
skip_white_const:
 1813|    232|{
 1814|    232|    if (ptr == NULL)
  ------------------
  |  Branch (1814:9): [True: 0, False: 232]
  ------------------
 1815|      0|        return (NULL);
 1816|    348|    while (*ptr != 0 && isspace((unsigned char)*ptr))
  ------------------
  |  Branch (1816:12): [True: 232, False: 116]
  |  Branch (1816:25): [True: 116, False: 116]
  ------------------
 1817|    116|        ptr++;
 1818|    232|    if (*ptr == 0 || *ptr == '#')
  ------------------
  |  Branch (1818:9): [True: 116, False: 116]
  |  Branch (1818:22): [True: 0, False: 116]
  ------------------
 1819|    116|        return (NULL);
 1820|    116|    return (ptr);
 1821|    232|}
copy_nword_const:
 1878|    232|{
 1879|    232|    char            quote;
 1880|    232|    if (!from || !to)
  ------------------
  |  Branch (1880:9): [True: 0, False: 232]
  |  Branch (1880:18): [True: 0, False: 232]
  ------------------
 1881|      0|        return NULL;
 1882|    232|    if ((*from == '\"') || (*from == '\'')) {
  ------------------
  |  Branch (1882:9): [True: 0, False: 232]
  |  Branch (1882:28): [True: 0, False: 232]
  ------------------
 1883|      0|        quote = *(from++);
 1884|      0|        while ((*from != quote) && (*from != 0)) {
  ------------------
  |  Branch (1884:16): [True: 0, False: 0]
  |  Branch (1884:36): [True: 0, False: 0]
  ------------------
 1885|      0|            if ((*from == '\\') && (*(from + 1) != 0)) {
  ------------------
  |  Branch (1885:17): [True: 0, False: 0]
  |  Branch (1885:36): [True: 0, False: 0]
  ------------------
 1886|      0|                if (len > 0) {  /* don't copy beyond len bytes */
  ------------------
  |  Branch (1886:21): [True: 0, False: 0]
  ------------------
 1887|      0|                    *to++ = *(from + 1);
 1888|      0|                    if (--len == 0)
  ------------------
  |  Branch (1888:25): [True: 0, False: 0]
  ------------------
 1889|      0|                        *(to - 1) = '\0';       /* null protect the last spot */
 1890|      0|                }
 1891|      0|                from = from + 2;
 1892|      0|            } else {
 1893|      0|                if (len > 0) {  /* don't copy beyond len bytes */
  ------------------
  |  Branch (1893:21): [True: 0, False: 0]
  ------------------
 1894|      0|                    *to++ = *from++;
 1895|      0|                    if (--len == 0)
  ------------------
  |  Branch (1895:25): [True: 0, False: 0]
  ------------------
 1896|      0|                        *(to - 1) = '\0';       /* null protect the last spot */
 1897|      0|                } else
 1898|      0|                    from++;
 1899|      0|            }
 1900|      0|        }
 1901|      0|        if (*from == 0) {
  ------------------
  |  Branch (1901:13): [True: 0, False: 0]
  ------------------
 1902|      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]
  |  |  ------------------
  ------------------
 1903|      0|                        "no end quote found in config string\n"));
 1904|      0|        } else
 1905|      0|            from++;
 1906|    232|    } else {
 1907|  1.04k|        while (*from != 0 && !isspace((unsigned char)(*from))) {
  ------------------
  |  Branch (1907:16): [True: 928, False: 116]
  |  Branch (1907:30): [True: 812, False: 116]
  ------------------
 1908|    812|            if ((*from == '\\') && (*(from + 1) != 0)) {
  ------------------
  |  Branch (1908:17): [True: 0, False: 812]
  |  Branch (1908:36): [True: 0, False: 0]
  ------------------
 1909|      0|                if (len > 0) {  /* don't copy beyond len bytes */
  ------------------
  |  Branch (1909:21): [True: 0, False: 0]
  ------------------
 1910|      0|                    *to++ = *(from + 1);
 1911|      0|                    if (--len == 0)
  ------------------
  |  Branch (1911:25): [True: 0, False: 0]
  ------------------
 1912|      0|                        *(to - 1) = '\0';       /* null protect the last spot */
 1913|      0|                }
 1914|      0|                from = from + 2;
 1915|    812|            } else {
 1916|    812|                if (len > 0) {  /* don't copy beyond len bytes */
  ------------------
  |  Branch (1916:21): [True: 812, False: 0]
  ------------------
 1917|    812|                    *to++ = *from++;
 1918|    812|                    if (--len == 0)
  ------------------
  |  Branch (1918:25): [True: 0, False: 812]
  ------------------
 1919|      0|                        *(to - 1) = '\0';       /* null protect the last spot */
 1920|    812|                } else
 1921|      0|                    from++;
 1922|    812|            }
 1923|    812|        }
 1924|    232|    }
 1925|    232|    if (len > 0)
  ------------------
  |  Branch (1925:9): [True: 232, False: 0]
  ------------------
 1926|    232|        *to = 0;
 1927|    232|    from = skip_white_const(from);
 1928|    232|    return (from);
 1929|    232|}                               /* copy_nword */
read_config_save_octet_string:
 1970|     58|{
 1971|     58|    size_t          i;
 1972|     58|    const u_char   *cp;
 1973|       |
 1974|       |    /*
 1975|       |     * is everything easily printable
 1976|       |     */
 1977|     58|    for (i = 0, cp = str; i < len && cp &&
  ------------------
  |  Branch (1977:27): [True: 58, False: 0]
  |  Branch (1977:38): [True: 58, False: 0]
  ------------------
 1978|     58|         (isalpha(*cp) || isdigit(*cp) || *cp == ' '); cp++, i++);
  ------------------
  |  Branch (1978:11): [True: 0, False: 58]
  |  Branch (1978:27): [True: 0, False: 58]
  |  Branch (1978:43): [True: 0, False: 58]
  ------------------
 1979|       |
 1980|     58|    if (len != 0 && i == len) {
  ------------------
  |  Branch (1980:9): [True: 58, False: 0]
  |  Branch (1980:21): [True: 0, False: 58]
  ------------------
 1981|      0|        *saveto++ = '"';
 1982|      0|        memcpy(saveto, str, len);
 1983|      0|        saveto += len;
 1984|      0|        *saveto++ = '"';
 1985|      0|        *saveto = '\0';
 1986|     58|    } else {
 1987|     58|        if (str != NULL) {
  ------------------
  |  Branch (1987:13): [True: 58, False: 0]
  ------------------
 1988|     58|            sprintf(saveto, "0x");
 1989|     58|            saveto += 2;
 1990|  1.04k|            for (i = 0; i < len; i++) {
  ------------------
  |  Branch (1990:25): [True: 986, False: 58]
  ------------------
 1991|    986|                sprintf(saveto, "%02x", str[i]);
 1992|    986|                saveto = saveto + 2;
 1993|    986|            }
 1994|     58|        } else {
 1995|      0|            sprintf(saveto, "\"\"");
 1996|      0|            saveto += 2;
 1997|      0|        }
 1998|     58|    }
 1999|     58|    return saveto;
 2000|     58|}
read_config.c:internal_register_config_handler:
  153|  5.97k|{
  154|  5.97k|    struct config_files **ctmp = &config_files;
  155|  5.97k|    struct config_line  **ltmp;
  156|  5.97k|    const char           *type = type_param;
  157|       |
  158|  5.97k|    if (type == NULL || *type == '\0') {
  ------------------
  |  Branch (158:9): [True: 116, False: 5.85k]
  |  Branch (158:25): [True: 116, False: 5.74k]
  ------------------
  159|    232|        type = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|    232|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  160|    232|				     NETSNMP_DS_LIB_APPTYPE);
  ------------------
  |  |  157|    232|#define NETSNMP_DS_LIB_APPTYPE           6
  ------------------
  161|    232|    }
  162|       |
  163|       |    /*
  164|       |     * Handle multiple types (recursively)
  165|       |     */
  166|  5.97k|    if (strchr(type, ':')) {
  ------------------
  |  Branch (166:9): [True: 116, False: 5.85k]
  ------------------
  167|    116|        struct config_line *ltmp2 = NULL;
  168|    116|        char                buf[STRINGMAX];
  169|    116|        char               *cptr = buf;
  170|       |
  171|    116|        strlcpy(buf, type, STRINGMAX);
  ------------------
  |  |   12|    116|#define STRINGMAX 1024
  ------------------
  172|    348|        while (cptr) {
  ------------------
  |  Branch (172:16): [True: 232, False: 116]
  ------------------
  173|    232|            char* c = cptr;
  174|    232|            cptr = strchr(cptr, ':');
  175|    232|            if(cptr) {
  ------------------
  |  Branch (175:16): [True: 116, False: 116]
  ------------------
  176|    116|                *cptr = '\0';
  177|    116|                ++cptr;
  178|    116|            }
  179|    232|            ltmp2 = internal_register_config_handler(c, token, parser1, parser2,
  180|    232|                                                     releaser, help, when);
  181|    232|        }
  182|    116|        return ltmp2;
  183|    116|    }
  184|       |    
  185|       |    /*
  186|       |     * Find type in current list  -OR-  create a new file type.
  187|       |     */
  188|  6.84k|    while (*ctmp != NULL && strcmp((*ctmp)->fileHeader, type)) {
  ------------------
  |  Branch (188:12): [True: 6.72k, False: 116]
  |  Branch (188:29): [True: 986, False: 5.74k]
  ------------------
  189|    986|        ctmp = &((*ctmp)->next);
  190|    986|    }
  191|       |
  192|  5.85k|    if (*ctmp == NULL) {
  ------------------
  |  Branch (192:9): [True: 116, False: 5.74k]
  ------------------
  193|    116|        *ctmp = (struct config_files *)
  194|    116|            calloc(1, sizeof(struct config_files));
  195|    116|        if (!*ctmp) {
  ------------------
  |  Branch (195:13): [True: 0, False: 116]
  ------------------
  196|      0|            return NULL;
  197|      0|        }
  198|       |
  199|    116|        (*ctmp)->fileHeader = strdup(type);
  200|    116|        if (!(*ctmp)->fileHeader) {
  ------------------
  |  Branch (200:13): [True: 0, False: 116]
  ------------------
  201|      0|            free(*ctmp);
  202|      0|            *ctmp = NULL;
  203|      0|            return NULL;
  204|      0|        }
  205|    116|        DEBUGMSGTL(("9:read_config:type", "new type %s\n", type));
  ------------------
  |  |   66|    116|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    116|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 116]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 116]
  |  |  ------------------
  ------------------
  206|    116|    }
  207|       |
  208|  5.85k|    DEBUGMSGTL(("9:read_config:register_handler", "registering %s %s\n",
  ------------------
  |  |   66|  5.85k|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|  5.85k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 5.85k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 5.85k]
  |  |  ------------------
  ------------------
  209|  5.85k|                type, token));
  210|       |    /*
  211|       |     * Find parser type in current list  -OR-  create a new
  212|       |     * line parser entry.
  213|       |     */
  214|  5.85k|    ltmp = &((*ctmp)->start);
  215|       |
  216|   215k|    while (*ltmp != NULL && strcmp((*ltmp)->config_token, token)) {
  ------------------
  |  Branch (216:12): [True: 210k, False: 5.85k]
  |  Branch (216:29): [True: 210k, False: 0]
  ------------------
  217|   210k|        ltmp = &((*ltmp)->next);
  218|   210k|    }
  219|       |
  220|  5.85k|    if (*ltmp == NULL) {
  ------------------
  |  Branch (220:9): [True: 5.85k, False: 0]
  ------------------
  221|  5.85k|        *ltmp = (struct config_line *)
  222|  5.85k|            calloc(1, sizeof(struct config_line));
  223|  5.85k|        if (!*ltmp) {
  ------------------
  |  Branch (223:13): [True: 0, False: 5.85k]
  ------------------
  224|      0|            return NULL;
  225|      0|        }
  226|       |
  227|  5.85k|        (*ltmp)->config_time = when;
  228|  5.85k|        (*ltmp)->config_token = strdup(token);
  229|  5.85k|        if (!(*ltmp)->config_token) {
  ------------------
  |  Branch (229:13): [True: 0, False: 5.85k]
  ------------------
  230|      0|            free(*ltmp);
  231|      0|            *ltmp = NULL;
  232|      0|            return NULL;
  233|      0|        }
  234|       |
  235|  5.85k|        if (help != NULL)
  ------------------
  |  Branch (235:13): [True: 5.16k, False: 696]
  ------------------
  236|  5.16k|            (*ltmp)->help = strdup(help);
  237|  5.85k|    }
  238|       |
  239|       |    /*
  240|       |     * Add/Replace the parse/free functions for the given line type
  241|       |     * in the given file type.
  242|       |     */
  243|  5.85k|    (*ltmp)->parse_line1 = parser1;
  244|  5.85k|    (*ltmp)->parse_line2 = parser2;
  245|  5.85k|    (*ltmp)->free_func = releaser;
  246|       |
  247|  5.85k|    return (*ltmp);
  248|       |
  249|  5.85k|}                               /* end register_config_handler() */

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

netsnmp_sd_listen_fds:
   72|     58|int netsnmp_sd_listen_fds(int unset_environment) {
   73|       |
   74|     58|        int r, fd;
   75|     58|        const char *e;
   76|     58|        char *p = NULL;
   77|     58|        unsigned long l;
   78|       |
   79|     58|        if (!(e = getenv("LISTEN_PID"))) {
  ------------------
  |  Branch (79:13): [True: 58, False: 0]
  ------------------
   80|     58|                r = 0;
   81|     58|                goto finish;
   82|     58|        }
   83|       |
   84|     58|        errno = 0;
   85|      0|        l = strtoul(e, &p, 10);
   86|       |
   87|      0|        if (errno != 0) {
  ------------------
  |  Branch (87:13): [True: 0, False: 0]
  ------------------
   88|      0|                r = -errno;
   89|      0|                goto finish;
   90|      0|        }
   91|       |
   92|      0|        if (!p || *p || l <= 0) {
  ------------------
  |  Branch (92:13): [True: 0, False: 0]
  |  Branch (92:19): [True: 0, False: 0]
  |  Branch (92:25): [True: 0, False: 0]
  ------------------
   93|      0|                r = -EINVAL;
   94|      0|                goto finish;
   95|      0|        }
   96|       |
   97|       |        /* Is this for us? */
   98|      0|        if (getpid() != (pid_t) l) {
  ------------------
  |  Branch (98:13): [True: 0, False: 0]
  ------------------
   99|      0|                r = 0;
  100|      0|                goto finish;
  101|      0|        }
  102|       |
  103|      0|        if (!(e = getenv("LISTEN_FDS"))) {
  ------------------
  |  Branch (103:13): [True: 0, False: 0]
  ------------------
  104|      0|                r = 0;
  105|      0|                goto finish;
  106|      0|        }
  107|       |
  108|      0|        errno = 0;
  109|      0|        l = strtoul(e, &p, 10);
  110|       |
  111|      0|        if (errno != 0 || l != (int)l) {
  ------------------
  |  Branch (111:13): [True: 0, False: 0]
  |  Branch (111:27): [True: 0, False: 0]
  ------------------
  112|      0|                r = errno ? -errno : -EINVAL;
  ------------------
  |  Branch (112:21): [True: 0, False: 0]
  ------------------
  113|      0|                goto finish;
  114|      0|        }
  115|       |
  116|      0|        if (!p || *p) {
  ------------------
  |  Branch (116:13): [True: 0, False: 0]
  |  Branch (116:19): [True: 0, False: 0]
  ------------------
  117|      0|                r = -EINVAL;
  118|      0|                goto finish;
  119|      0|        }
  120|       |
  121|      0|        for (fd = SD_LISTEN_FDS_START; fd < SD_LISTEN_FDS_START + (int) l; fd ++) {
  ------------------
  |  |   70|      0|#define SD_LISTEN_FDS_START 3
  ------------------
                      for (fd = SD_LISTEN_FDS_START; fd < SD_LISTEN_FDS_START + (int) l; fd ++) {
  ------------------
  |  |   70|      0|#define SD_LISTEN_FDS_START 3
  ------------------
  |  Branch (121:40): [True: 0, False: 0]
  ------------------
  122|      0|                int flags;
  123|       |
  124|      0|                if ((flags = fcntl(fd, F_GETFD)) < 0) {
  ------------------
  |  Branch (124:21): [True: 0, False: 0]
  ------------------
  125|      0|                        r = -errno;
  126|      0|                        goto finish;
  127|      0|                }
  128|       |
  129|      0|                if (flags & FD_CLOEXEC)
  ------------------
  |  Branch (129:21): [True: 0, False: 0]
  ------------------
  130|      0|                        continue;
  131|       |
  132|      0|                if (fcntl(fd, F_SETFD, flags | FD_CLOEXEC) < 0) {
  ------------------
  |  Branch (132:21): [True: 0, False: 0]
  ------------------
  133|      0|                        r = -errno;
  134|      0|                        goto finish;
  135|      0|                }
  136|      0|        }
  137|       |
  138|      0|        r = (int) l;
  139|       |
  140|     58|finish:
  141|     58|        if (unset_environment) {
  ------------------
  |  Branch (141:13): [True: 0, False: 58]
  ------------------
  142|      0|                unsetenv("LISTEN_PID");
  143|      0|                unsetenv("LISTEN_FDS");
  144|      0|        }
  145|       |
  146|     58|        return r;
  147|      0|}
netsnmp_sd_find_inet_socket:
  356|     58|{
  357|     58|    int count, fd;
  358|       |
  359|     58|    count = netsnmp_sd_listen_fds(0);
  360|     58|    if (count <= 0) {
  ------------------
  |  Branch (360:9): [True: 58, False: 0]
  ------------------
  361|     58|        DEBUGMSGTL(("systemd:find_inet_socket", "No LISTEN_FDS found.\n"));
  ------------------
  |  |   66|     58|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     58|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 58]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 58]
  |  |  ------------------
  ------------------
  362|     58|        return -1;
  363|     58|    }
  364|      0|    DEBUGMSGTL(("systemd:find_inet_socket", "LISTEN_FDS reports %d sockets.\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]
  |  |  ------------------
  ------------------
  365|      0|            count));
  366|       |
  367|      0|    for (fd = SD_LISTEN_FDS_START; fd < SD_LISTEN_FDS_START + count; fd++) {
  ------------------
  |  |   70|      0|#define SD_LISTEN_FDS_START 3
  ------------------
                  for (fd = SD_LISTEN_FDS_START; fd < SD_LISTEN_FDS_START + count; fd++) {
  ------------------
  |  |   70|      0|#define SD_LISTEN_FDS_START 3
  ------------------
  |  Branch (367:36): [True: 0, False: 0]
  ------------------
  368|      0|        int rc = sd_is_socket_inet(fd, family, type, listening, port);
  369|      0|        if (rc < 0)
  ------------------
  |  Branch (369:13): [True: 0, False: 0]
  ------------------
  370|      0|            DEBUGMSGTL(("systemd:find_inet_socket",
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
  371|      0|                    "sd_is_socket_inet error: %d\n", rc));
  372|      0|        if (rc > 0) {
  ------------------
  |  Branch (372:13): [True: 0, False: 0]
  ------------------
  373|      0|            DEBUGMSGTL(("systemd:find_inet_socket",
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
  374|      0|                    "Found the socket in LISTEN_FDS\n"));
  375|      0|            return fd;
  376|      0|        }
  377|      0|    }
  378|      0|    DEBUGMSGTL(("systemd:find_inet_socket", "Socket not found in LISTEN_FDS\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]
  |  |  ------------------
  ------------------
  379|      0|    return -1;
  380|      0|}

init_alarm_post_config:
   63|     58|{
   64|     58|    start_alarms = 1;
   65|     58|    set_an_alarm();
   66|     58|    return SNMPERR_SUCCESS;
  ------------------
  |  |  184|     58|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
   67|     58|}
init_snmp_alarm:
   71|     58|{
   72|     58|    start_alarms = 0;
   73|     58|    snmp_register_callback(SNMP_CALLBACK_LIBRARY,
  ------------------
  |  |   18|     58|#define SNMP_CALLBACK_LIBRARY     0
  ------------------
   74|     58|                           SNMP_CALLBACK_POST_READ_CONFIG,
  ------------------
  |  |   24|     58|#define SNMP_CALLBACK_POST_READ_CONFIG	        0
  ------------------
   75|       |                           init_alarm_post_config, NULL);
   76|     58|}
snmp_alarm_unregister_all:
  156|     58|{
  157|     58|  struct snmp_alarm *sa_ptr, *sa_tmp;
  158|       |
  159|     58|  for (sa_ptr = thealarms; sa_ptr != NULL; sa_ptr = sa_tmp) {
  ------------------
  |  Branch (159:28): [True: 0, False: 58]
  ------------------
  160|      0|    sa_tmp = sa_ptr->next;
  161|      0|    free(sa_ptr);
  162|      0|  }
  163|     58|  DEBUGMSGTL(("snmp_alarm", "ALL alarms unregistered\n"));
  ------------------
  |  |   66|     58|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     58|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 58]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 58]
  |  |  ------------------
  ------------------
  164|       |  thealarms = NULL;
  165|     58|}  
sa_find_next:
  169|     58|{
  170|     58|    struct snmp_alarm *a, *lowest = NULL;
  171|       |
  172|     58|    for (a = thealarms; a != NULL; a = a->next)
  ------------------
  |  Branch (172:25): [True: 0, False: 58]
  ------------------
  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|     58|    return lowest;
  178|     58|}
netsnmp_get_next_alarm_time:
  253|     58|{
  254|     58|    struct snmp_alarm *sa_ptr;
  255|       |
  256|     58|    sa_ptr = sa_find_next();
  257|       |
  258|     58|    if (sa_ptr) {
  ------------------
  |  Branch (258:9): [True: 0, False: 58]
  ------------------
  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
  |  |  |  |  ------------------
  |  |  |  |  |  | 1727|      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
  |  |  |  |  ------------------
  |  |  |  |  |  | 1727|      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|     58|    } else {
  267|     58|        return 0;
  268|     58|    }
  269|     58|}
get_next_alarm_delay_time:
  282|     58|{
  283|     58|    struct timeval t_now, alarm_tm;
  284|     58|    int res;
  285|       |
  286|     58|    netsnmp_get_monotonic_clock(&t_now);
  287|     58|    res = netsnmp_get_next_alarm_time(&alarm_tm, &t_now);
  288|     58|    if (res)
  ------------------
  |  Branch (288:9): [True: 0, False: 58]
  ------------------
  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|     58|    return res;
  291|     58|}
set_an_alarm:
  296|     58|{
  297|     58|    struct timeval  delta;
  298|     58|    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|     58|    if (nextalarm && !netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      0|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (306:9): [True: 0, False: 58]
  |  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|     58|    } else {
  326|     58|        DEBUGMSGTL(("snmp_alarm", "no alarms found to schedule\n"));
  ------------------
  |  |   66|     58|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     58|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 58]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 58]
  |  |  ------------------
  ------------------
  327|     58|    }
  328|     58|}

netsnmp_max_send_msg_size:
  373|    116|{
  374|    116|    u_int max = netsnmp_ds_get_int(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|    116|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  375|    116|                                   NETSNMP_DS_LIB_MSG_SEND_MAX);
  ------------------
  |  |  132|    116|#define NETSNMP_DS_LIB_MSG_SEND_MAX        16 /* global max response size */
  ------------------
  376|    116|    if (0 == max)
  ------------------
  |  Branch (376:9): [True: 116, False: 0]
  ------------------
  377|    116|        max = SNMP_MAX_PACKET_LEN;
  ------------------
  |  |   49|    116|#define SNMP_MAX_PACKET_LEN (0x7fffffff)
  ------------------
  378|      0|    else if (max < SNMP_MIN_MAX_LEN)
  ------------------
  |  |   48|      0|#define SNMP_MIN_MAX_LEN    484 /* minimum maximum message size */
  ------------------
  |  Branch (378:14): [True: 0, False: 0]
  ------------------
  379|      0|        max = SNMP_MIN_MAX_LEN; /* minimum max size per SNMP specs */
  ------------------
  |  |   48|      0|#define SNMP_MIN_MAX_LEN    484 /* minimum maximum message size */
  ------------------
  380|      0|    else if (max > SNMP_MAX_PACKET_LEN)
  ------------------
  |  |   49|      0|#define SNMP_MAX_PACKET_LEN (0x7fffffff)
  ------------------
  |  Branch (380:14): [True: 0, False: 0]
  ------------------
  381|      0|        max = SNMP_MAX_PACKET_LEN;
  ------------------
  |  |   49|      0|#define SNMP_MAX_PACKET_LEN (0x7fffffff)
  ------------------
  382|       |
  383|    116|    return max;
  384|    116|}
snmp_get_next_sessid:
  477|     58|{
  478|     58|    long            retVal;
  479|     58|    snmp_res_lock(MT_LIBRARY_ID, MT_LIB_SESSIONID);
  ------------------
  |  |   79|     58|#define snmp_res_lock(x,y) do {} while (0)
  |  |  ------------------
  |  |  |  Branch (79:41): [Folded, False: 58]
  |  |  ------------------
  ------------------
  480|     58|    retVal = 1 + Sessid;        /*MTCRITICAL_RESOURCE */
  481|     58|    if (!retVal)
  ------------------
  |  Branch (481:9): [True: 0, False: 58]
  ------------------
  482|      0|        retVal = 2;
  483|     58|    Sessid = retVal;
  484|     58|    if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_16BIT_IDS))
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                  if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_16BIT_IDS))
  ------------------
  |  |   91|     58|#define NETSNMP_DS_LIB_16BIT_IDS           31   /* restrict requestIDs, etc to 16-bit values */
  ------------------
  |  Branch (484:9): [True: 0, False: 58]
  ------------------
  485|      0|        retVal &= 0x7fff;	/* mask to 15 bits */
  486|     58|    else
  487|     58|        retVal &= 0x7fffffff;	/* mask to 31 bits */
  488|       |
  489|     58|    if (!retVal) {
  ------------------
  |  Branch (489:9): [True: 0, False: 58]
  ------------------
  490|      0|        Sessid = retVal = 2;
  491|      0|    }
  492|     58|    snmp_res_unlock(MT_LIBRARY_ID, MT_LIB_SESSIONID);
  ------------------
  |  |   80|     58|#define snmp_res_unlock(x,y) do {} while (0)
  |  |  ------------------
  |  |  |  Branch (80:43): [Folded, False: 58]
  |  |  ------------------
  ------------------
  493|     58|    return retVal;
  494|     58|}
snmp_get_next_transid:
  498|    118|{
  499|    118|    long            retVal;
  500|    118|    snmp_res_lock(MT_LIBRARY_ID, MT_LIB_TRANSID);
  ------------------
  |  |   79|    118|#define snmp_res_lock(x,y) do {} while (0)
  |  |  ------------------
  |  |  |  Branch (79:41): [Folded, False: 118]
  |  |  ------------------
  ------------------
  501|    118|    retVal = 1 + Transid;       /*MTCRITICAL_RESOURCE */
  502|    118|    if (!retVal)
  ------------------
  |  Branch (502:9): [True: 0, False: 118]
  ------------------
  503|      0|        retVal = 2;
  504|    118|    Transid = retVal;
  505|    118|    if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_16BIT_IDS))
  ------------------
  |  |   48|    118|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                  if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_16BIT_IDS))
  ------------------
  |  |   91|    118|#define NETSNMP_DS_LIB_16BIT_IDS           31   /* restrict requestIDs, etc to 16-bit values */
  ------------------
  |  Branch (505:9): [True: 0, False: 118]
  ------------------
  506|      0|        retVal &= 0x7fff;	/* mask to 15 bits */
  507|    118|    else
  508|    118|        retVal &= 0x7fffffff;	/* mask to 31 bits */
  509|       |
  510|    118|    if (!retVal) {
  ------------------
  |  Branch (510:9): [True: 0, False: 118]
  ------------------
  511|      0|        Transid = retVal = 2;
  512|      0|    }
  513|    118|    snmp_res_unlock(MT_LIBRARY_ID, MT_LIB_TRANSID);
  ------------------
  |  |   80|    118|#define snmp_res_unlock(x,y) do {} while (0)
  |  |  ------------------
  |  |  |  Branch (80:43): [Folded, False: 118]
  |  |  ------------------
  ------------------
  514|    118|    return retVal;
  515|    118|}
snmp_set_detail:
  529|    212|{
  530|    212|    if (detail_string != NULL) {
  ------------------
  |  Branch (530:9): [True: 212, False: 0]
  ------------------
  531|    212|        strlcpy(snmp_detail, detail_string, sizeof(snmp_detail));
  532|    212|        snmp_detail_f = 1;
  533|    212|    }
  534|    212|}
netsnmp_random:
  652|    174|{
  653|    174|#if defined(HAVE_RANDOM)
  654|       |    /*
  655|       |     * The function random() is a more sophisticated random number generator
  656|       |     * which uses nonlinear feedback and an internal table that is 124 bytes
  657|       |     * (992 bits) long. The function returns random values that are 32 bits in
  658|       |     * length. All of the bits generated by random() are usable. The random()
  659|       |     * function is adequate for simulations and games, but should not be used
  660|       |     * for security related applications such as picking cryptographic keys or
  661|       |     * simulating one-time pads.
  662|       |     */
  663|    174|    return random();
  664|       |#elif defined(HAVE_LRAND48)
  665|       |    /*
  666|       |     * As with random(), lrand48() provides excellent random numbers for
  667|       |     * simulations and games, but should not be used for security-related
  668|       |     * applications such as picking cryptographic keys or simulating one-time
  669|       |     * pads; linear congruential algorithms are too easy to break.
  670|       |     */
  671|       |    return lrand48();
  672|       |#elif defined(HAVE_RAND)
  673|       |    /*
  674|       |     * The original UNIX random number generator, rand(), is not a very good
  675|       |     * random number generator. It uses a 32-bit seed and maintains a 32-bit
  676|       |     * internal state.
  677|       |     */
  678|       |    return rand();
  679|       |#else
  680|       |#error "Neither random(), nor lrand48() nor rand() are available"
  681|       |#endif
  682|    174|}
netsnmp_srandom:
  685|     58|{
  686|     58|#if defined(HAVE_SRANDOM)
  687|     58|    srandom(seed);
  688|       |#elif defined(HAVE_SRAND48)
  689|       |    srand48(seed);
  690|       |#elif defined(HAVE_SRAND)
  691|       |    srand(seed);
  692|       |#else
  693|       |#error "Neither srandom(), nor srand48() nor srand() are available"
  694|       |#endif
  695|     58|}
snmp_sess_init:
  788|     58|{
  789|     58|    _init_snmp();
  790|       |
  791|       |    /*
  792|       |     * initialize session to default values 
  793|       |     */
  794|       |
  795|     58|    memset(session, 0, sizeof(netsnmp_session));
  796|     58|    session->timeout = SNMP_DEFAULT_TIMEOUT;
  ------------------
  |  |   80|     58|#define SNMP_DEFAULT_TIMEOUT	    -1
  ------------------
  797|     58|    session->retries = SNMP_DEFAULT_RETRIES;
  ------------------
  |  |   79|     58|#define SNMP_DEFAULT_RETRIES	    -1
  ------------------
  798|     58|    session->version = SNMP_DEFAULT_VERSION;
  ------------------
  |  |   90|     58|#define SNMP_DEFAULT_VERSION	    -1
  ------------------
  799|     58|    session->securityModel = SNMP_DEFAULT_SECMODEL;
  ------------------
  |  |   91|     58|#define SNMP_DEFAULT_SECMODEL	    -1
  ------------------
  800|     58|    session->rcvMsgMaxSize = netsnmp_max_send_msg_size();
  801|     58|    session->sndMsgMaxSize = netsnmp_max_send_msg_size();
  802|     58|    session->flags |= SNMP_FLAGS_DONT_PROBE;
  ------------------
  |  |  155|     58|#define SNMP_FLAGS_DONT_PROBE      0x100      /* don't probe for an engineID */
  ------------------
  803|     58|}
init_snmp:
  892|     58|{
  893|     58|    if (init_snmp_init_done) {
  ------------------
  |  Branch (893:9): [True: 0, False: 58]
  ------------------
  894|      0|        return;
  895|      0|    }
  896|       |
  897|     58|    init_snmp_init_done = 1;
  898|       |
  899|       |    /*
  900|       |     * make the type available everywhere else 
  901|       |     */
  902|     58|    if (type && !netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (902:9): [True: 58, False: 0]
  |  Branch (902:17): [True: 58, False: 0]
  ------------------
  903|     58|				       NETSNMP_DS_LIB_APPTYPE)) {
  ------------------
  |  |  157|     58|#define NETSNMP_DS_LIB_APPTYPE           6
  ------------------
  904|     58|        netsnmp_ds_set_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  905|     58|			      NETSNMP_DS_LIB_APPTYPE, type);
  ------------------
  |  |  157|     58|#define NETSNMP_DS_LIB_APPTYPE           6
  ------------------
  906|     58|    }
  907|       |
  908|     58|    _init_snmp();
  909|       |
  910|       |    /*
  911|       |     * set our current locale properly to initialize isprint() type functions 
  912|       |     *
  913|       |     * Do not use setlocale on qnx, it is buggy 
  914|       |     * https://www.qnx.com/developers/docs/7.1/#com.qnx.doc.neutrino.lib_ref/topic/s/setlocale.html
  915|       |     */
  916|     58|#if defined(HAVE_SETLOCALE) && !defined(__QNX__)
  917|     58|    setlocale(LC_CTYPE, "");
  918|     58|#endif
  919|       |
  920|     58|    snmp_debug_init();    /* should be done first, to turn on debugging ASAP */
  921|     58|    netsnmp_container_init_list();
  922|     58|    init_callbacks();
  923|     58|    init_snmp_logging();
  924|     58|    snmp_init_statistics();
  925|     58|    register_mib_handlers();
  926|     58|    register_default_handlers();
  927|     58|    init_snmp_transport();
  928|     58|    init_snmpv3(type);
  929|     58|    init_snmp_alarm();
  930|     58|    init_snmp_enum(type);
  931|     58|    init_vacm();
  932|     58|#if defined(NETSNMP_USE_OPENSSL) && defined(HAVE_LIBSSL) && NETSNMP_TRANSPORT_TLSBASE_DOMAIN
  933|     58|    netsnmp_certs_init();
  934|     58|#endif
  935|       |#ifdef DNSSEC_LOCAL_VALIDATION
  936|       |    netsnmp_ds_register_config(ASN_BOOLEAN, "snmp", "dnssecWarnOnly",
  937|       |                               NETSNMP_DS_LIBRARY_ID,
  938|       |                               NETSNMP_DS_LIB_DNSSEC_WARN_ONLY);
  939|       |#endif
  940|       |
  941|     58|    read_premib_configs();
  942|     58|#ifndef NETSNMP_DISABLE_MIB_LOADING
  943|     58|    netsnmp_init_mib();
  944|     58|#endif /* NETSNMP_DISABLE_MIB_LOADING */
  945|       |
  946|     58|    read_configs();
  947|       |
  948|     58|}                               /* end init_snmp() */
snmp_store:
  974|     58|{
  975|     58|    DEBUGMSGTL(("snmp_store", "storing stuff...\n"));
  ------------------
  |  |   66|     58|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     58|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 58]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 58]
  |  |  ------------------
  ------------------
  976|     58|    snmp_save_persistent(type);
  977|     58|    snmp_call_callbacks(SNMP_CALLBACK_LIBRARY, SNMP_CALLBACK_STORE_DATA, NULL);
  ------------------
  |  |   18|     58|#define SNMP_CALLBACK_LIBRARY     0
  ------------------
                  snmp_call_callbacks(SNMP_CALLBACK_LIBRARY, SNMP_CALLBACK_STORE_DATA, NULL);
  ------------------
  |  |   25|     58|#define SNMP_CALLBACK_STORE_DATA	        1
  ------------------
  978|     58|    snmp_clean_persistent(type);
  979|     58|}
snmp_shutdown:
  992|     58|{
  993|     58|    snmp_store(type);
  994|     58|    snmp_call_callbacks(SNMP_CALLBACK_LIBRARY, SNMP_CALLBACK_SHUTDOWN, NULL);
  ------------------
  |  |   18|     58|#define SNMP_CALLBACK_LIBRARY     0
  ------------------
                  snmp_call_callbacks(SNMP_CALLBACK_LIBRARY, SNMP_CALLBACK_SHUTDOWN, NULL);
  ------------------
  |  |   26|     58|#define SNMP_CALLBACK_SHUTDOWN		        2
  ------------------
  995|     58|    shutdown_snmp_logging();
  996|     58|    snmp_alarm_unregister_all();
  997|     58|    netsnmp_query_shutdown();
  998|     58|    snmp_close_sessions();
  999|     58|#ifndef NETSNMP_DISABLE_MIB_LOADING
 1000|     58|    shutdown_mib();
 1001|     58|#endif /* NETSNMP_DISABLE_MIB_LOADING */
 1002|     58|#if defined(NETSNMP_USE_OPENSSL) && defined(HAVE_LIBSSL) && NETSNMP_TRANSPORT_TLSBASE_DOMAIN
 1003|     58|    netsnmp_certs_shutdown();
 1004|     58|#endif
 1005|     58|#if !defined(NETSNMP_FEATURE_REMOVE_FILTER_SOURCE)
 1006|     58|    netsnmp_transport_filter_cleanup();
 1007|     58|#endif
 1008|     58|    unregister_all_config_handlers();
 1009|     58|    netsnmp_container_free_list();
 1010|     58|    clear_sec_mod();
 1011|     58|    clear_snmp_enum();
 1012|     58|    netsnmp_clear_tdomain_list();
 1013|     58|    clear_callback();
 1014|     58|    netsnmp_ds_shutdown();
 1015|     58|    netsnmp_clear_default_target();
 1016|     58|    netsnmp_clear_default_domain();
 1017|     58|    shutdown_secmod();
 1018|     58|    shutdown_snmp_transport();
 1019|     58|    shutdown_data_list();
 1020|     58|    snmp_debug_shutdown();    /* should be done last */
 1021|       |
 1022|     58|    init_snmp_init_done  = 0;
 1023|     58|    _init_snmp_init_done = 0;
 1024|     58|}
snmp_session_insert:
 1030|     58|{
 1031|     58|    if (NULL == slp)
  ------------------
  |  Branch (1031:9): [True: 0, False: 58]
  ------------------
 1032|      0|        return;
 1033|       |
 1034|     58|    snmp_res_lock(MT_LIBRARY_ID, MT_LIB_SESSION);
  ------------------
  |  |   79|     58|#define snmp_res_lock(x,y) do {} while (0)
  |  |  ------------------
  |  |  |  Branch (79:41): [Folded, False: 58]
  |  |  ------------------
  ------------------
 1035|     58|    slp->next = Sessions;
 1036|     58|    Sessions = slp;
 1037|     58|    snmp_res_unlock(MT_LIBRARY_ID, MT_LIB_SESSION);
  ------------------
  |  |   80|     58|#define snmp_res_unlock(x,y) do {} while (0)
  |  |  ------------------
  |  |  |  Branch (80:43): [Folded, False: 58]
  |  |  ------------------
  ------------------
 1038|     58|}
netsnmp_sess_config_transport:
 1635|     58|{
 1636|       |    /* Optional supplemental transport configuration information and
 1637|       |       final call to actually open the transport */
 1638|     58|    if (transport_configuration) {
  ------------------
  |  Branch (1638:9): [True: 0, False: 58]
  ------------------
 1639|      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]
  |  |  ------------------
  ------------------
 1640|      0|        if (transport->f_config) {
  ------------------
  |  Branch (1640:13): [True: 0, False: 0]
  ------------------
 1641|      0|            netsnmp_iterator *iter;
 1642|      0|            netsnmp_transport_config *config_data;
 1643|      0|            int ret = 0;
 1644|       |
 1645|      0|            iter = CONTAINER_ITERATOR(transport_configuration);
  ------------------
  |  |  404|      0|#define CONTAINER_ITERATOR(x)       (x)->get_iterator(x)
  ------------------
 1646|      0|            if (NULL == iter) {
  ------------------
  |  Branch (1646:17): [True: 0, False: 0]
  ------------------
 1647|      0|                return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
 1648|      0|            }
 1649|       |
 1650|      0|            for(config_data = (netsnmp_transport_config*)ITERATOR_FIRST(iter); config_data;
  ------------------
  |  |  546|      0|#define ITERATOR_FIRST(x)  x->first(x)
  ------------------
  |  Branch (1650:80): [True: 0, False: 0]
  ------------------
 1651|      0|                config_data = (netsnmp_transport_config*)ITERATOR_NEXT(iter)) {
  ------------------
  |  |  547|      0|#define ITERATOR_NEXT(x)   x->next(x)
  ------------------
 1652|      0|                ret = transport->f_config(transport, config_data->key,
 1653|      0|                                          config_data->value);
 1654|      0|                if (ret)
  ------------------
  |  Branch (1654:21): [True: 0, False: 0]
  ------------------
 1655|      0|                    break;
 1656|      0|            }
 1657|      0|            ITERATOR_RELEASE(iter);
  ------------------
  |  |  550|      0|#define ITERATOR_RELEASE(x) do { x->release(x); x = NULL; } while(0)
  |  |  ------------------
  |  |  |  Branch (550:67): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1658|      0|            if (ret)
  ------------------
  |  Branch (1658:17): [True: 0, False: 0]
  ------------------
 1659|      0|                return SNMPERR_TRANSPORT_CONFIG_ERROR;
  ------------------
  |  |  252|      0|#define SNMPERR_TRANSPORT_CONFIG_ERROR  (-68)
  ------------------
 1660|      0|        } else {
 1661|      0|            return SNMPERR_TRANSPORT_NO_CONFIG;
  ------------------
  |  |  251|      0|#define SNMPERR_TRANSPORT_NO_CONFIG     (-67)
  ------------------
 1662|      0|        }
 1663|      0|    }
 1664|     58|    return SNMPERR_SUCCESS;
  ------------------
  |  |  184|     58|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 1665|     58|}
netsnmp_sess_config_and_open_transport:
 1697|     58|{
 1698|     58|    int rc;
 1699|       |    
 1700|     58|    DEBUGMSGTL(("snmp_sess", "opening transport: %x\n", transport->flags & NETSNMP_TRANSPORT_FLAG_OPENED));
  ------------------
  |  |   66|     58|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     58|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 58]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 58]
  |  |  ------------------
  ------------------
 1701|       |
 1702|       |    /* don't double open */
 1703|     58|    if (transport->flags & NETSNMP_TRANSPORT_FLAG_OPENED)
  ------------------
  |  |   57|     58|#define		NETSNMP_TRANSPORT_FLAG_OPENED	 0x20  /* f_open called */
  ------------------
  |  Branch (1703:9): [True: 0, False: 58]
  ------------------
 1704|      0|        return SNMPERR_SUCCESS;
  ------------------
  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 1705|       |
 1706|     58|    if ((rc = netsnmp_sess_config_transport(in_session->transport_configuration,
  ------------------
  |  Branch (1706:9): [True: 0, False: 58]
  ------------------
 1707|     58|                                            transport)) != SNMPERR_SUCCESS) {
  ------------------
  |  |  184|     58|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 1708|      0|        in_session->s_snmp_errno = rc;
 1709|      0|        in_session->s_errno = 0;
 1710|      0|        return rc;
 1711|      0|    }
 1712|       |        
 1713|     58|    if (transport->f_open)
  ------------------
  |  Branch (1713:9): [True: 0, False: 58]
  ------------------
 1714|      0|        transport = transport->f_open(transport);
 1715|       |
 1716|     58|    if (transport == NULL) {
  ------------------
  |  Branch (1716:9): [True: 0, False: 58]
  ------------------
 1717|      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]
  |  |  ------------------
  ------------------
 1718|      0|        in_session->s_snmp_errno = SNMPERR_BAD_ADDRESS;
  ------------------
  |  |  187|      0|#define SNMPERR_BAD_ADDRESS		(-3)
  ------------------
 1719|      0|        in_session->s_errno = errno;
 1720|      0|        snmp_set_detail(in_session->peername);
 1721|      0|        return SNMPERR_BAD_ADDRESS;
  ------------------
  |  |  187|      0|#define SNMPERR_BAD_ADDRESS		(-3)
  ------------------
 1722|      0|    }
 1723|       |
 1724|       |    /** if transport has a max size, make sure session is the same (or less) */
 1725|     58|    if (in_session->rcvMsgMaxSize > transport->msgMaxSize) {
  ------------------
  |  Branch (1725:9): [True: 58, False: 0]
  ------------------
 1726|     58|        DEBUGMSGTL(("snmp_sess",
  ------------------
  |  |   66|     58|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     58|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 58]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 58]
  |  |  ------------------
  ------------------
 1727|     58|                    "limiting session rcv size (%" NETSNMP_PRIz "d) to transport max (%" NETSNMP_PRIz "d)\n",
 1728|     58|                    in_session->rcvMsgMaxSize, transport->msgMaxSize));
 1729|     58|        in_session->rcvMsgMaxSize = transport->msgMaxSize;
 1730|     58|    }
 1731|       |
 1732|     58|    if (in_session->sndMsgMaxSize > transport->msgMaxSize) {
  ------------------
  |  Branch (1732:9): [True: 58, False: 0]
  ------------------
 1733|     58|        DEBUGMSGTL(("snmp_sess",
  ------------------
  |  |   66|     58|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     58|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 58]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 58]
  |  |  ------------------
  ------------------
 1734|     58|                    "limiting session snd size (%" NETSNMP_PRIz "d) to transport max (%" NETSNMP_PRIz "d)\n",
 1735|     58|                    in_session->sndMsgMaxSize, transport->msgMaxSize));
 1736|     58|        in_session->sndMsgMaxSize = transport->msgMaxSize;
 1737|     58|    }
 1738|       |
 1739|     58|    transport->flags |= NETSNMP_TRANSPORT_FLAG_OPENED;
  ------------------
  |  |   57|     58|#define		NETSNMP_TRANSPORT_FLAG_OPENED	 0x20  /* f_open called */
  ------------------
 1740|     58|    DEBUGMSGTL(("snmp_sess", "done opening transport: %x\n", transport->flags & NETSNMP_TRANSPORT_FLAG_OPENED));
  ------------------
  |  |   66|     58|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     58|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 58]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 58]
  |  |  ------------------
  ------------------
 1741|     58|    return SNMPERR_SUCCESS;
  ------------------
  |  |  184|     58|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 1742|     58|}
snmp_add:
 1858|     58|{
 1859|     58|    struct session_list *slp;
 1860|       |
 1861|     58|    slp = snmp_sess_add_ex(in_session, transport, fpre_parse, NULL,
 1862|     58|                           fpost_parse, NULL, NULL, NULL, NULL);
 1863|     58|    if (slp == NULL) {
  ------------------
  |  Branch (1863:9): [True: 0, False: 58]
  ------------------
 1864|      0|        return NULL;
 1865|      0|    }
 1866|       |
 1867|     58|    snmp_session_insert(slp);
 1868|       |
 1869|     58|    return (slp->session);
 1870|     58|}
snmp_sess_add_ex:
 1919|     58|{
 1920|     58|    struct session_list *slp;
 1921|     58|    int rc;
 1922|       |    
 1923|     58|    _init_snmp();
 1924|       |
 1925|     58|    if (transport == NULL)
  ------------------
  |  Branch (1925:9): [True: 0, False: 58]
  ------------------
 1926|      0|        return NULL;
 1927|       |
 1928|     58|    if (NULL != in_session && (in_session->rcvMsgMaxSize < SNMP_MIN_MAX_LEN ||
  ------------------
  |  |   48|    116|#define SNMP_MIN_MAX_LEN    484 /* minimum maximum message size */
  ------------------
  |  Branch (1928:9): [True: 58, False: 0]
  |  Branch (1928:32): [True: 0, False: 58]
  ------------------
 1929|     58|                               in_session->sndMsgMaxSize < SNMP_MIN_MAX_LEN)) {
  ------------------
  |  |   48|     58|#define SNMP_MIN_MAX_LEN    484 /* minimum maximum message size */
  ------------------
  |  Branch (1929:32): [True: 0, False: 58]
  ------------------
 1930|      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]
  |  |  ------------------
  ------------------
 1931|      0|                    "invalid session (msg sizes). need snmp_sess_init"));
 1932|      0|        in_session = NULL; /* force transport cleanup below */
 1933|      0|    }
 1934|       |
 1935|     58|    if (in_session == NULL) {
  ------------------
  |  Branch (1935:9): [True: 0, False: 58]
  ------------------
 1936|      0|        transport->f_close(transport);
 1937|      0|        netsnmp_transport_free(transport);
 1938|      0|        return NULL;
 1939|      0|    }
 1940|       |
 1941|       |    /* if the transport hasn't been fully opened yet, open it now */
 1942|     58|    if ((rc = netsnmp_sess_config_and_open_transport(in_session, transport))
  ------------------
  |  Branch (1942:9): [True: 0, False: 58]
  ------------------
 1943|     58|        != SNMPERR_SUCCESS) {
  ------------------
  |  |  184|     58|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 1944|      0|        return NULL;
 1945|      0|    }
 1946|       |
 1947|     58|    DEBUGMSGTL(("snmp_sess_add", "fd %" NETSNMP_FMT_SKT "\n",
  ------------------
  |  |   66|     58|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     58|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 58]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 58]
  |  |  ------------------
  ------------------
 1948|     58|                transport->sock));
 1949|       |
 1950|     58|    if ((slp = snmp_sess_copy(in_session)) == NULL) {
  ------------------
  |  Branch (1950:9): [True: 0, False: 58]
  ------------------
 1951|      0|        transport->f_close(transport);
 1952|      0|        netsnmp_transport_free(transport);
 1953|      0|        return (NULL);
 1954|      0|    }
 1955|       |
 1956|     58|    slp->transport = transport;
 1957|     58|    slp->internal->hook_pre = fpre_parse;
 1958|     58|    slp->internal->hook_parse = fparse;
 1959|     58|    slp->internal->hook_post = fpost_parse;
 1960|     58|    slp->internal->hook_build = fbuild;
 1961|     58|    slp->internal->hook_realloc_build = frbuild;
 1962|     58|    slp->internal->check_packet = fcheck;
 1963|     58|    slp->internal->hook_create_pdu = fcreate_pdu;
 1964|       |
 1965|       |    /** don't let session max exceed transport max */
 1966|     58|    if (slp->session->rcvMsgMaxSize > transport->msgMaxSize) {
  ------------------
  |  Branch (1966:9): [True: 0, False: 58]
  ------------------
 1967|      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]
  |  |  ------------------
  ------------------
 1968|      0|                    "limiting session rcv size (%" NETSNMP_PRIz "d) to transport max (%" NETSNMP_PRIz "d)\n",
 1969|      0|                    slp->session->rcvMsgMaxSize, transport->msgMaxSize));
 1970|      0|        slp->session->rcvMsgMaxSize = transport->msgMaxSize;
 1971|      0|    }
 1972|     58|    if (slp->session->sndMsgMaxSize > transport->msgMaxSize) {
  ------------------
  |  Branch (1972:9): [True: 0, False: 58]
  ------------------
 1973|      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]
  |  |  ------------------
  ------------------
 1974|      0|                    "limiting session snd size (%" NETSNMP_PRIz "d) to transport max (%" NETSNMP_PRIz "d)\n",
 1975|      0|                    slp->session->sndMsgMaxSize, transport->msgMaxSize));
 1976|      0|        slp->session->sndMsgMaxSize = transport->msgMaxSize;
 1977|      0|    }
 1978|       |
 1979|     58|    if (transport->f_setup_session &&
  ------------------
  |  Branch (1979:9): [True: 58, False: 0]
  ------------------
 1980|     58|        transport->f_setup_session(transport, slp->session) != SNMPERR_SUCCESS)
  ------------------
  |  |  184|     58|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  |  Branch (1980:9): [True: 0, False: 58]
  ------------------
 1981|      0|        goto close_session;
 1982|       |
 1983|       |    /* Anything below this point should only be done if the transport
 1984|       |       had no say in the matter */
 1985|     58|    if (slp->session->securityLevel == 0)
  ------------------
  |  Branch (1985:9): [True: 58, False: 0]
  ------------------
 1986|     58|        slp->session->securityLevel = SNMP_SEC_LEVEL_NOAUTH;
  ------------------
  |  |  299|     58|#define SNMP_SEC_LEVEL_NOAUTH		1
  ------------------
 1987|       |
 1988|     58|    if (slp->session->version == SNMP_VERSION_3) {
  ------------------
  |  |  113|     58|#define SNMP_VERSION_3     3
  ------------------
  |  Branch (1988:9): [True: 0, False: 58]
  ------------------
 1989|      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]
  |  |  ------------------
  ------------------
 1990|      0|                    "adding v3 session -- maybe engineID probe now\n"));
 1991|      0|        if (!snmpv3_engineID_probe(slp, slp->session)) {
  ------------------
  |  Branch (1991:13): [True: 0, False: 0]
  ------------------
 1992|      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]
  |  |  ------------------
  ------------------
 1993|      0|            goto close_session;
 1994|      0|        }
 1995|      0|    }
 1996|       |
 1997|     58|    slp->session->flags &= ~SNMP_FLAGS_DONT_PROBE;
  ------------------
  |  |  155|     58|#define SNMP_FLAGS_DONT_PROBE      0x100      /* don't probe for an engineID */
  ------------------
 1998|       |
 1999|     58|    return slp;
 2000|       |
 2001|      0|close_session:
 2002|      0|    snmp_sess_close(slp);
 2003|       |    return NULL;
 2004|     58|}                               /*  end snmp_sess_add_ex()  */
netsnmp_cleanup_session:
 2064|     58|{
 2065|     58|    free(s->localname);
 2066|     58|    free(s->peername);
 2067|     58|    free(s->community);
 2068|     58|    free(s->contextEngineID);
 2069|     58|    free(s->contextName);
 2070|     58|    free(s->securityEngineID);
 2071|     58|    free(s->securityName);
 2072|     58|    free(s->securityAuthProto);
 2073|     58|    free(s->securityAuthLocalKey);
 2074|     58|    free(s->securityPrivProto);
 2075|     58|    free(s->securityPrivLocalKey);
 2076|     58|    free(s->paramName);
 2077|     58|#ifndef NETSNMP_NO_TRAP_STATS
 2078|     58|    free(s->trap_stats);
 2079|     58|#endif /* NETSNMP_NO_TRAP_STATS */
 2080|     58|    usm_free_user(s->sessUser);
 2081|     58|    netsnmp_free_transport_config(s->transport_configuration);
 2082|     58|    memset(s, 0, sizeof(*s));
 2083|     58|}
snmp_sess_close:
 2137|     58|{
 2138|     58|    netsnmp_transport *transport;
 2139|     58|    struct snmp_internal_session *isp;
 2140|     58|    netsnmp_session *sesp = NULL;
 2141|     58|    struct snmp_secmod_def *sptr;
 2142|       |
 2143|     58|    if (slp == NULL) {
  ------------------
  |  Branch (2143:9): [True: 0, False: 58]
  ------------------
 2144|      0|        return 0;
 2145|      0|    }
 2146|       |
 2147|     58|    if (slp->session != NULL &&
  ------------------
  |  Branch (2147:9): [True: 58, False: 0]
  ------------------
 2148|     58|        (sptr = find_sec_mod(slp->session->securityModel)) != NULL &&
  ------------------
  |  Branch (2148:9): [True: 58, False: 0]
  ------------------
 2149|     58|        sptr->session_close != NULL) {
  ------------------
  |  Branch (2149:9): [True: 0, False: 58]
  ------------------
 2150|      0|        (*sptr->session_close) (slp->session);
 2151|      0|    }
 2152|       |
 2153|     58|    isp = slp->internal;
 2154|     58|    slp->internal = NULL;
 2155|       |
 2156|     58|    if (isp) {
  ------------------
  |  Branch (2156:9): [True: 58, False: 0]
  ------------------
 2157|     58|        netsnmp_request_list *rp, *orp;
 2158|       |
 2159|     58|        SNMP_FREE(isp->packet);
  ------------------
  |  |   62|     58|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 58]
  |  |  |  Branch (62:66): [Folded, False: 58]
  |  |  ------------------
  ------------------
 2160|       |
 2161|       |        /*
 2162|       |         * Free each element in the input request list.  
 2163|       |         */
 2164|     58|        rp = isp->requests;
 2165|     58|        while (rp) {
  ------------------
  |  Branch (2165:16): [True: 0, False: 58]
  ------------------
 2166|      0|            orp = rp;
 2167|      0|            rp = rp->next_request;
 2168|      0|            if (orp->callback) {
  ------------------
  |  Branch (2168:17): [True: 0, False: 0]
  ------------------
 2169|      0|                orp->callback(NETSNMP_CALLBACK_OP_TIMED_OUT,
  ------------------
  |  |  320|      0|#define NETSNMP_CALLBACK_OP_TIMED_OUT		2
  ------------------
 2170|      0|                              slp->session, orp->pdu->reqid,
 2171|      0|                              orp->pdu, orp->cb_data);
 2172|      0|            }
 2173|      0|            remove_request(isp, NULL, orp);
 2174|      0|            free(orp);
 2175|      0|        }
 2176|       |
 2177|     58|        free(isp);
 2178|     58|    }
 2179|       |
 2180|     58|    transport = slp->transport;
 2181|     58|    slp->transport = NULL;
 2182|       |
 2183|     58|    if (transport) {
  ------------------
  |  Branch (2183:9): [True: 58, False: 0]
  ------------------
 2184|     58|        transport->f_close(transport);
 2185|     58|        netsnmp_transport_free(transport);
 2186|     58|    }
 2187|       |
 2188|     58|    sesp = slp->session;
 2189|     58|    slp->session = NULL;
 2190|       |
 2191|       |    /*
 2192|       |     * The following is necessary to avoid memory leakage when closing AgentX 
 2193|       |     * sessions that may have multiple subsessions.  These hang off the main
 2194|       |     * session at ->subsession, and chain through ->next.  
 2195|       |     */
 2196|       |
 2197|     58|    if (sesp != NULL && sesp->subsession != NULL) {
  ------------------
  |  Branch (2197:9): [True: 58, False: 0]
  |  Branch (2197:25): [True: 0, False: 58]
  ------------------
 2198|      0|        netsnmp_session *subsession = sesp->subsession, *tmpsub;
 2199|       |
 2200|      0|        while (subsession != NULL) {
  ------------------
  |  Branch (2200:16): [True: 0, False: 0]
  ------------------
 2201|      0|            DEBUGMSGTL(("snmp_sess_close",
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 2202|      0|                        "closing session %p, subsession %p\n", sesp,
 2203|      0|                        subsession));
 2204|      0|            tmpsub = subsession->next;
 2205|      0|            snmp_free_session(subsession);
 2206|      0|            subsession = tmpsub;
 2207|      0|        }
 2208|      0|    }
 2209|       |
 2210|     58|    snmp_free_session(sesp);
 2211|     58|    free(slp);
 2212|     58|    return 1;
 2213|     58|}
snmp_close:
 2217|     58|{
 2218|     58|    struct session_list *slp = NULL, *oslp = NULL;
 2219|       |
 2220|     58|    {                           /*MTCRITICAL_RESOURCE */
 2221|     58|        snmp_res_lock(MT_LIBRARY_ID, MT_LIB_SESSION);
  ------------------
  |  |   79|     58|#define snmp_res_lock(x,y) do {} while (0)
  |  |  ------------------
  |  |  |  Branch (79:41): [Folded, False: 58]
  |  |  ------------------
  ------------------
 2222|     58|        if (Sessions && Sessions->session == session) { /* If first entry */
  ------------------
  |  Branch (2222:13): [True: 0, False: 58]
  |  Branch (2222:25): [True: 0, False: 0]
  ------------------
 2223|      0|            slp = Sessions;
 2224|      0|            Sessions = slp->next;
 2225|     58|        } else {
 2226|     58|            for (slp = Sessions; slp; slp = slp->next) {
  ------------------
  |  Branch (2226:34): [True: 0, False: 58]
  ------------------
 2227|      0|                if (slp->session == session) {
  ------------------
  |  Branch (2227:21): [True: 0, False: 0]
  ------------------
 2228|      0|                    if (oslp)   /* if we found entry that points here */
  ------------------
  |  Branch (2228:25): [True: 0, False: 0]
  ------------------
 2229|      0|                        oslp->next = slp->next; /* link around this entry */
 2230|      0|                    break;
 2231|      0|                }
 2232|      0|                oslp = slp;
 2233|      0|            }
 2234|     58|        }
 2235|     58|        snmp_res_unlock(MT_LIBRARY_ID, MT_LIB_SESSION);
  ------------------
  |  |   80|     58|#define snmp_res_unlock(x,y) do {} while (0)
  |  |  ------------------
  |  |  |  Branch (80:43): [Folded, False: 58]
  |  |  ------------------
  ------------------
 2236|     58|    }                           /*END MTCRITICAL_RESOURCE */
 2237|     58|    if (slp == NULL) {
  ------------------
  |  Branch (2237:9): [True: 58, False: 0]
  ------------------
 2238|     58|        return 0;
 2239|     58|    }
 2240|      0|    return snmp_sess_close(slp);
 2241|     58|}
snmp_close_sessions:
 2245|     58|{
 2246|     58|    struct session_list *slp;
 2247|       |
 2248|     58|    snmp_res_lock(MT_LIBRARY_ID, MT_LIB_SESSION);
  ------------------
  |  |   79|     58|#define snmp_res_lock(x,y) do {} while (0)
  |  |  ------------------
  |  |  |  Branch (79:41): [Folded, False: 58]
  |  |  ------------------
  ------------------
 2249|    116|    while (Sessions) {
  ------------------
  |  Branch (2249:12): [True: 58, False: 58]
  ------------------
 2250|     58|        slp = Sessions;
 2251|     58|        Sessions = Sessions->next;
 2252|     58|        snmp_sess_close(slp);
 2253|     58|    }
 2254|     58|    snmp_res_unlock(MT_LIBRARY_ID, MT_LIB_SESSION);
  ------------------
  |  |   80|     58|#define snmp_res_unlock(x,y) do {} while (0)
  |  |  ------------------
  |  |  |  Branch (80:43): [Folded, False: 58]
  |  |  ------------------
  ------------------
 2255|     58|    return 1;
 2256|     58|}
snmpv3_parse:
 3896|     22|{
 3897|     22|    u_char          type, msg_flags;
 3898|     22|    long            ver, msg_sec_model;
 3899|     22|    size_t          max_size_response;
 3900|     22|    u_char          tmp_buf[SNMP_MAX_MSG_SIZE];
 3901|     22|    size_t          tmp_buf_len;
 3902|     22|    u_char          pdu_buf[SNMP_MAX_MSG_SIZE];
 3903|     22|    u_char         *mallocbuf = NULL;
 3904|     22|    size_t          pdu_buf_len = SNMP_MAX_MSG_SIZE;
  ------------------
  |  |  109|     22|#define SNMP_MAX_MSG_SIZE          1472 /* ethernet MTU minus IP/UDP header */
  ------------------
 3905|     22|    u_char         *sec_params;
 3906|     22|    u_char         *msg_data;
 3907|     22|    u_char         *cp;
 3908|     22|    size_t          asn_len, msg_len;
 3909|     22|    int             ret, ret_val;
 3910|     22|    struct snmp_secmod_def *sptr;
 3911|       |
 3912|       |
 3913|     22|    msg_data = data;
 3914|     22|    msg_len = *length;
 3915|       |
 3916|       |
 3917|       |    /*
 3918|       |     * message is an ASN.1 SEQUENCE  
 3919|       |     */
 3920|     22|    DEBUGDUMPSECTION("recv", "SNMPv3 Message");
  ------------------
  |  |   81|     22|	do {if (_DBG_IF_) {__DBGDUMPSECTION(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     22|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 22]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	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: 22]
  |  |  ------------------
  ------------------
 3921|     22|    data = asn_parse_sequence(data, length, &type,
 3922|     22|                              (ASN_SEQUENCE | ASN_CONSTRUCTOR), "message");
  ------------------
  |  |   84|     22|#define ASN_SEQUENCE	    0x10U
  ------------------
                                            (ASN_SEQUENCE | ASN_CONSTRUCTOR), "message");
  ------------------
  |  |   96|     22|#define ASN_CONSTRUCTOR	    0x20U
  ------------------
 3923|     22|    if (data == NULL) {
  ------------------
  |  Branch (3923:9): [True: 0, False: 22]
  ------------------
 3924|       |        /*
 3925|       |         * error msg detail is set 
 3926|       |         */
 3927|      0|        snmp_increment_statistic(STAT_SNMPINASNPARSEERRS);
  ------------------
  |  |  637|      0|#define  STAT_SNMPINASNPARSEERRS             14
  ------------------
 3928|      0|        DEBUGINDENTLESS();
  ------------------
  |  |   75|      0|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 0]
  |  |  ------------------
  ------------------
 3929|      0|        return SNMPERR_ASN_PARSE_ERR;
  ------------------
  |  |  213|      0|#define SNMPERR_ASN_PARSE_ERR           (-29)
  ------------------
 3930|      0|    }
 3931|       |
 3932|       |    /*
 3933|       |     * parse msgVersion  
 3934|       |     */
 3935|     22|    DEBUGDUMPHEADER("recv", "SNMP Version Number");
  ------------------
  |  |   79|     22|	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     22|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 22]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  178|      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__))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  179|      0|        debugmsg("dumph_" token,x); \
  |  |  |  |  180|      0|        if (debug_is_token_registered("dumpx" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (180:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  181|      0|            debug_is_token_registered("dumpv" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (181:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  182|      0|            (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|      0|             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|      0|            debugmsg("dumph_" token,"\n"); \
  |  |  |  |  185|      0|        } else { \
  |  |  |  |  186|      0|            debugmsg("dumph_" token,"  "); \
  |  |  |  |  187|      0|        } \
  |  |  |  |  188|      0|        __DBGINDENTMORE()
  |  |  |  |  ------------------
  |  |  |  |  |  |  173|      0|#define __DBGINDENTMORE()  debug_indent_add(2)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (79:55): [Folded, False: 22]
  |  |  ------------------
  ------------------
 3936|     22|    data = asn_parse_int(data, length, &type, &ver, sizeof(ver));
 3937|     22|    DEBUGINDENTLESS();
  ------------------
  |  |   75|     22|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|     22|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 22]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 22]
  |  |  ------------------
  ------------------
 3938|     22|    if (data == NULL) {
  ------------------
  |  Branch (3938:9): [True: 0, False: 22]
  ------------------
 3939|      0|        ERROR_MSG("bad parse of version");
  ------------------
  |  |  188|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 3940|      0|        snmp_increment_statistic(STAT_SNMPINASNPARSEERRS);
  ------------------
  |  |  637|      0|#define  STAT_SNMPINASNPARSEERRS             14
  ------------------
 3941|      0|        DEBUGINDENTLESS();
  ------------------
  |  |   75|      0|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 0]
  |  |  ------------------
  ------------------
 3942|      0|        return SNMPERR_ASN_PARSE_ERR;
  ------------------
  |  |  213|      0|#define SNMPERR_ASN_PARSE_ERR           (-29)
  ------------------
 3943|      0|    }
 3944|     22|    pdu->version = ver;
 3945|       |
 3946|       |    /*
 3947|       |     * parse msgGlobalData sequence  
 3948|       |     */
 3949|     22|    cp = data;
 3950|     22|    asn_len = *length;
 3951|     22|    DEBUGDUMPSECTION("recv", "msgGlobalData");
  ------------------
  |  |   81|     22|	do {if (_DBG_IF_) {__DBGDUMPSECTION(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     22|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 22]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	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: 22]
  |  |  ------------------
  ------------------
 3952|     22|    data = asn_parse_sequence(data, &asn_len, &type,
 3953|     22|                              (ASN_SEQUENCE | ASN_CONSTRUCTOR),
  ------------------
  |  |   84|     22|#define ASN_SEQUENCE	    0x10U
  ------------------
                                            (ASN_SEQUENCE | ASN_CONSTRUCTOR),
  ------------------
  |  |   96|     22|#define ASN_CONSTRUCTOR	    0x20U
  ------------------
 3954|     22|                              "msgGlobalData");
 3955|     22|    if (data == NULL) {
  ------------------
  |  Branch (3955:9): [True: 3, False: 19]
  ------------------
 3956|       |        /*
 3957|       |         * error msg detail is set 
 3958|       |         */
 3959|      3|        snmp_increment_statistic(STAT_SNMPINASNPARSEERRS);
  ------------------
  |  |  637|      3|#define  STAT_SNMPINASNPARSEERRS             14
  ------------------
 3960|      3|        DEBUGINDENTADD(-4);
  ------------------
  |  |   73|      3|#define DEBUGINDENTADD(x)  do {if (_DBG_IF_) {__DBGINDENTADD(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      3|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 3]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTADD(x)  do {if (_DBG_IF_) {__DBGINDENTADD(x);} }while(0)
  |  |  ------------------
  |  |  |  |  172|      0|#define __DBGINDENTADD(x)  debug_indent_add(x)
  |  |  ------------------
  |  |  |  Branch (73:74): [Folded, False: 3]
  |  |  ------------------
  ------------------
 3961|      3|        return SNMPERR_ASN_PARSE_ERR;
  ------------------
  |  |  213|      3|#define SNMPERR_ASN_PARSE_ERR           (-29)
  ------------------
 3962|      3|    }
 3963|     19|    *length -= data - cp;       /* subtract off the length of the header */
 3964|       |
 3965|       |    /*
 3966|       |     * msgID 
 3967|       |     */
 3968|     19|    DEBUGDUMPHEADER("recv", "msgID");
  ------------------
  |  |   79|     19|	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     19|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 19]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  178|      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__))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  179|      0|        debugmsg("dumph_" token,x); \
  |  |  |  |  180|      0|        if (debug_is_token_registered("dumpx" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (180:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  181|      0|            debug_is_token_registered("dumpv" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (181:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  182|      0|            (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|      0|             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|      0|            debugmsg("dumph_" token,"\n"); \
  |  |  |  |  185|      0|        } else { \
  |  |  |  |  186|      0|            debugmsg("dumph_" token,"  "); \
  |  |  |  |  187|      0|        } \
  |  |  |  |  188|      0|        __DBGINDENTMORE()
  |  |  |  |  ------------------
  |  |  |  |  |  |  173|      0|#define __DBGINDENTMORE()  debug_indent_add(2)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (79:55): [Folded, False: 19]
  |  |  ------------------
  ------------------
 3969|     19|    data =
 3970|     19|        asn_parse_int(data, length, &type, &pdu->msgid,
 3971|     19|                      sizeof(pdu->msgid));
 3972|     19|    DEBUGINDENTLESS();
  ------------------
  |  |   75|     19|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|     19|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 19]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 19]
  |  |  ------------------
  ------------------
 3973|     19|    if (data == NULL || type != ASN_INTEGER) {
  ------------------
  |  |   75|     15|#define ASN_INTEGER	    0x02U
  ------------------
  |  Branch (3973:9): [True: 4, False: 15]
  |  Branch (3973:25): [True: 0, False: 15]
  ------------------
 3974|      4|        ERROR_MSG("error parsing msgID");
  ------------------
  |  |  188|      4|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 3975|      4|        DEBUGINDENTADD(-4);
  ------------------
  |  |   73|      4|#define DEBUGINDENTADD(x)  do {if (_DBG_IF_) {__DBGINDENTADD(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      4|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 4]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTADD(x)  do {if (_DBG_IF_) {__DBGINDENTADD(x);} }while(0)
  |  |  ------------------
  |  |  |  |  172|      0|#define __DBGINDENTADD(x)  debug_indent_add(x)
  |  |  ------------------
  |  |  |  Branch (73:74): [Folded, False: 4]
  |  |  ------------------
  ------------------
 3976|      4|        snmp_increment_statistic(STAT_SNMPINASNPARSEERRS);
  ------------------
  |  |  637|      4|#define  STAT_SNMPINASNPARSEERRS             14
  ------------------
 3977|      4|        return SNMPERR_ASN_PARSE_ERR;
  ------------------
  |  |  213|      4|#define SNMPERR_ASN_PARSE_ERR           (-29)
  ------------------
 3978|      4|    }
 3979|       |
 3980|       |    /*
 3981|       |     * Check the msgID we received is a legal value.  If not, then increment
 3982|       |     * snmpInASNParseErrs and return the appropriate error (see RFC 2572,
 3983|       |     * para. 7.2, section 2 -- note that a bad msgID means that the received
 3984|       |     * message is NOT a serialization of an SNMPv3Message, since the msgID
 3985|       |     * field is out of bounds).  
 3986|       |     */
 3987|       |
 3988|     15|    if (pdu->msgid < 0 || pdu->msgid > SNMP_MAX_PACKET_LEN) {
  ------------------
  |  |   49|     14|#define SNMP_MAX_PACKET_LEN (0x7fffffff)
  ------------------
  |  Branch (3988:9): [True: 1, False: 14]
  |  Branch (3988:27): [True: 0, False: 14]
  ------------------
 3989|      1|        snmp_log(LOG_ERR, "Received bad msgID (%ld %s %s).\n", pdu->msgid,
 3990|      1|                 (pdu->msgid < 0) ? "<" : ">",
  ------------------
  |  Branch (3990:18): [True: 1, False: 0]
  ------------------
 3991|      1|                 (pdu->msgid < 0) ? "0" : "2^31 - 1");
  ------------------
  |  Branch (3991:18): [True: 1, False: 0]
  ------------------
 3992|      1|        snmp_increment_statistic(STAT_SNMPINASNPARSEERRS);
  ------------------
  |  |  637|      1|#define  STAT_SNMPINASNPARSEERRS             14
  ------------------
 3993|      1|        DEBUGINDENTADD(-4);
  ------------------
  |  |   73|      1|#define DEBUGINDENTADD(x)  do {if (_DBG_IF_) {__DBGINDENTADD(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTADD(x)  do {if (_DBG_IF_) {__DBGINDENTADD(x);} }while(0)
  |  |  ------------------
  |  |  |  |  172|      0|#define __DBGINDENTADD(x)  debug_indent_add(x)
  |  |  ------------------
  |  |  |  Branch (73:74): [Folded, False: 1]
  |  |  ------------------
  ------------------
 3994|      1|        return SNMPERR_ASN_PARSE_ERR;
  ------------------
  |  |  213|      1|#define SNMPERR_ASN_PARSE_ERR           (-29)
  ------------------
 3995|      1|    }
 3996|       |
 3997|       |    /*
 3998|       |     * msgMaxSize 
 3999|       |     */
 4000|     14|    DEBUGDUMPHEADER("recv:msgMaxSize", "msgMaxSize");
  ------------------
  |  |   79|     14|	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     14|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 14]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  178|      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__))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  179|      0|        debugmsg("dumph_" token,x); \
  |  |  |  |  180|      0|        if (debug_is_token_registered("dumpx" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (180:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  181|      0|            debug_is_token_registered("dumpv" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (181:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  182|      0|            (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|      0|             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|      0|            debugmsg("dumph_" token,"\n"); \
  |  |  |  |  185|      0|        } else { \
  |  |  |  |  186|      0|            debugmsg("dumph_" token,"  "); \
  |  |  |  |  187|      0|        } \
  |  |  |  |  188|      0|        __DBGINDENTMORE()
  |  |  |  |  ------------------
  |  |  |  |  |  |  173|      0|#define __DBGINDENTMORE()  debug_indent_add(2)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (79:55): [Folded, False: 14]
  |  |  ------------------
  ------------------
 4001|     14|    data = asn_parse_int(data, length, &type, &pdu->msgMaxSize,
 4002|     14|                         sizeof(pdu->msgMaxSize));
 4003|     14|    DEBUGINDENTLESS();
  ------------------
  |  |   75|     14|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|     14|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 14]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 14]
  |  |  ------------------
  ------------------
 4004|     14|    if (data == NULL || type != ASN_INTEGER) {
  ------------------
  |  |   75|     11|#define ASN_INTEGER	    0x02U
  ------------------
  |  Branch (4004:9): [True: 3, False: 11]
  |  Branch (4004:25): [True: 0, False: 11]
  ------------------
 4005|      3|        ERROR_MSG("error parsing msgMaxSize");
  ------------------
  |  |  188|      3|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 4006|      3|        snmp_increment_statistic(STAT_SNMPINASNPARSEERRS);
  ------------------
  |  |  637|      3|#define  STAT_SNMPINASNPARSEERRS             14
  ------------------
 4007|      3|        DEBUGINDENTADD(-4);
  ------------------
  |  |   73|      3|#define DEBUGINDENTADD(x)  do {if (_DBG_IF_) {__DBGINDENTADD(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      3|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 3]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTADD(x)  do {if (_DBG_IF_) {__DBGINDENTADD(x);} }while(0)
  |  |  ------------------
  |  |  |  |  172|      0|#define __DBGINDENTADD(x)  debug_indent_add(x)
  |  |  ------------------
  |  |  |  Branch (73:74): [Folded, False: 3]
  |  |  ------------------
  ------------------
 4008|      3|        return SNMPERR_ASN_PARSE_ERR;
  ------------------
  |  |  213|      3|#define SNMPERR_ASN_PARSE_ERR           (-29)
  ------------------
 4009|      3|    }
 4010|       |
 4011|       |    /*
 4012|       |     * Check the msgMaxSize we received is a legal value.  If not, then
 4013|       |     * increment snmpInASNParseErrs and return the appropriate error (see RFC
 4014|       |     * 2572, para. 7.2, section 2 -- note that a bad msgMaxSize means that the
 4015|       |     * received message is NOT a serialization of an SNMPv3Message, since the
 4016|       |     * msgMaxSize field is out of bounds).
 4017|       |     */
 4018|       |
 4019|     11|    if (pdu->msgMaxSize < SNMP_MIN_MAX_LEN) {
  ------------------
  |  |   48|     11|#define SNMP_MIN_MAX_LEN    484 /* minimum maximum message size */
  ------------------
  |  Branch (4019:9): [True: 2, False: 9]
  ------------------
 4020|      2|        snmp_log(LOG_ERR, "Received bad msgMaxSize (%lu < 484).\n",
 4021|      2|                 pdu->msgMaxSize);
 4022|      2|        snmp_increment_statistic(STAT_SNMPINASNPARSEERRS);
  ------------------
  |  |  637|      2|#define  STAT_SNMPINASNPARSEERRS             14
  ------------------
 4023|      2|        DEBUGINDENTADD(-4);
  ------------------
  |  |   73|      2|#define DEBUGINDENTADD(x)  do {if (_DBG_IF_) {__DBGINDENTADD(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      2|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 2]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTADD(x)  do {if (_DBG_IF_) {__DBGINDENTADD(x);} }while(0)
  |  |  ------------------
  |  |  |  |  172|      0|#define __DBGINDENTADD(x)  debug_indent_add(x)
  |  |  ------------------
  |  |  |  Branch (73:74): [Folded, False: 2]
  |  |  ------------------
  ------------------
 4024|      2|        return SNMPERR_ASN_PARSE_ERR;
  ------------------
  |  |  213|      2|#define SNMPERR_ASN_PARSE_ERR           (-29)
  ------------------
 4025|      9|    } else if (pdu->msgMaxSize > SNMP_MAX_PACKET_LEN) {
  ------------------
  |  |   49|      9|#define SNMP_MAX_PACKET_LEN (0x7fffffff)
  ------------------
  |  Branch (4025:16): [True: 0, False: 9]
  ------------------
 4026|      0|        snmp_log(LOG_ERR, "Received bad msgMaxSize (%lu > 2^31 - 1).\n",
 4027|      0|                 pdu->msgMaxSize);
 4028|      0|        snmp_increment_statistic(STAT_SNMPINASNPARSEERRS);
  ------------------
  |  |  637|      0|#define  STAT_SNMPINASNPARSEERRS             14
  ------------------
 4029|      0|        DEBUGINDENTADD(-4);
  ------------------
  |  |   73|      0|#define DEBUGINDENTADD(x)  do {if (_DBG_IF_) {__DBGINDENTADD(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTADD(x)  do {if (_DBG_IF_) {__DBGINDENTADD(x);} }while(0)
  |  |  ------------------
  |  |  |  |  172|      0|#define __DBGINDENTADD(x)  debug_indent_add(x)
  |  |  ------------------
  |  |  |  Branch (73:74): [Folded, False: 0]
  |  |  ------------------
  ------------------
 4030|      0|        return SNMPERR_ASN_PARSE_ERR;
  ------------------
  |  |  213|      0|#define SNMPERR_ASN_PARSE_ERR           (-29)
  ------------------
 4031|      9|    } else {
 4032|      9|        DEBUGMSGTL(("snmpv3_parse:msgMaxSize", "msgMaxSize %lu received\n",
  ------------------
  |  |   66|      9|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      9|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 9]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 9]
  |  |  ------------------
  ------------------
 4033|      9|                    pdu->msgMaxSize));
 4034|       |        /** don't increase max msg size if we've already got one */
 4035|      9|        if (sess->sndMsgMaxSize < pdu->msgMaxSize) {
  ------------------
  |  Branch (4035:13): [True: 7, False: 2]
  ------------------
 4036|      7|            DEBUGMSGTL(("snmpv3_parse:msgMaxSize",
  ------------------
  |  |   66|      7|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      7|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 7]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 7]
  |  |  ------------------
  ------------------
 4037|      7|                        "msgMaxSize %" NETSNMP_PRIz "d greater than session max %ld; reducing\n",
 4038|      7|                        sess->sndMsgMaxSize, pdu->msgMaxSize));
 4039|      7|            pdu->msgMaxSize = sess->sndMsgMaxSize;
 4040|      7|        }
 4041|      9|    }
 4042|       |
 4043|       |    /*
 4044|       |     * msgFlags 
 4045|       |     */
 4046|      9|    tmp_buf_len = SNMP_MAX_MSG_SIZE;
  ------------------
  |  |  109|      9|#define SNMP_MAX_MSG_SIZE          1472 /* ethernet MTU minus IP/UDP header */
  ------------------
 4047|      9|    DEBUGDUMPHEADER("recv", "msgFlags");
  ------------------
  |  |   79|      9|	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      9|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 9]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  178|      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__))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  179|      0|        debugmsg("dumph_" token,x); \
  |  |  |  |  180|      0|        if (debug_is_token_registered("dumpx" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (180:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  181|      0|            debug_is_token_registered("dumpv" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (181:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  182|      0|            (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|      0|             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|      0|            debugmsg("dumph_" token,"\n"); \
  |  |  |  |  185|      0|        } else { \
  |  |  |  |  186|      0|            debugmsg("dumph_" token,"  "); \
  |  |  |  |  187|      0|        } \
  |  |  |  |  188|      0|        __DBGINDENTMORE()
  |  |  |  |  ------------------
  |  |  |  |  |  |  173|      0|#define __DBGINDENTMORE()  debug_indent_add(2)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (79:55): [Folded, False: 9]
  |  |  ------------------
  ------------------
 4048|      9|    data = asn_parse_string(data, length, &type, tmp_buf, &tmp_buf_len);
 4049|      9|    DEBUGINDENTLESS();
  ------------------
  |  |   75|      9|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|      9|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 9]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 9]
  |  |  ------------------
  ------------------
 4050|      9|    if (data == NULL || type != ASN_OCTET_STR || tmp_buf_len != 1) {
  ------------------
  |  |   78|     15|#define ASN_OCTET_STR	    0x04U
  ------------------
  |  Branch (4050:9): [True: 3, False: 6]
  |  Branch (4050:25): [True: 0, False: 6]
  |  Branch (4050:50): [True: 3, False: 3]
  ------------------
 4051|      6|        ERROR_MSG("error parsing msgFlags");
  ------------------
  |  |  188|      6|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 4052|      6|        snmp_increment_statistic(STAT_SNMPINASNPARSEERRS);
  ------------------
  |  |  637|      6|#define  STAT_SNMPINASNPARSEERRS             14
  ------------------
 4053|      6|        DEBUGINDENTADD(-4);
  ------------------
  |  |   73|      6|#define DEBUGINDENTADD(x)  do {if (_DBG_IF_) {__DBGINDENTADD(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      6|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 6]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTADD(x)  do {if (_DBG_IF_) {__DBGINDENTADD(x);} }while(0)
  |  |  ------------------
  |  |  |  |  172|      0|#define __DBGINDENTADD(x)  debug_indent_add(x)
  |  |  ------------------
  |  |  |  Branch (73:74): [Folded, False: 6]
  |  |  ------------------
  ------------------
 4054|      6|        return SNMPERR_ASN_PARSE_ERR;
  ------------------
  |  |  213|      6|#define SNMPERR_ASN_PARSE_ERR           (-29)
  ------------------
 4055|      6|    }
 4056|      3|    msg_flags = *tmp_buf;
 4057|      3|    if (msg_flags & SNMP_MSG_FLAG_RPRT_BIT)
  ------------------
  |  |  305|      3|#define SNMP_MSG_FLAG_RPRT_BIT          0x04
  ------------------
  |  Branch (4057:9): [True: 0, False: 3]
  ------------------
 4058|      0|        pdu->flags |= SNMP_MSG_FLAG_RPRT_BIT;
  ------------------
  |  |  305|      0|#define SNMP_MSG_FLAG_RPRT_BIT          0x04
  ------------------
 4059|      3|    else
 4060|      3|        pdu->flags &= (~SNMP_MSG_FLAG_RPRT_BIT);
  ------------------
  |  |  305|      3|#define SNMP_MSG_FLAG_RPRT_BIT          0x04
  ------------------
 4061|       |
 4062|       |    /*
 4063|       |     * msgSecurityModel 
 4064|       |     */
 4065|      3|    DEBUGDUMPHEADER("recv", "msgSecurityModel");
  ------------------
  |  |   79|      3|	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      3|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 3]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  178|      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__))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  179|      0|        debugmsg("dumph_" token,x); \
  |  |  |  |  180|      0|        if (debug_is_token_registered("dumpx" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (180:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  181|      0|            debug_is_token_registered("dumpv" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (181:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  182|      0|            (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|      0|             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|      0|            debugmsg("dumph_" token,"\n"); \
  |  |  |  |  185|      0|        } else { \
  |  |  |  |  186|      0|            debugmsg("dumph_" token,"  "); \
  |  |  |  |  187|      0|        } \
  |  |  |  |  188|      0|        __DBGINDENTMORE()
  |  |  |  |  ------------------
  |  |  |  |  |  |  173|      0|#define __DBGINDENTMORE()  debug_indent_add(2)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (79:55): [Folded, False: 3]
  |  |  ------------------
  ------------------
 4066|      3|    data = asn_parse_int(data, length, &type, &msg_sec_model,
 4067|      3|                         sizeof(msg_sec_model));
 4068|      3|    DEBUGINDENTADD(-4);         /* return from global data indent */
  ------------------
  |  |   73|      3|#define DEBUGINDENTADD(x)  do {if (_DBG_IF_) {__DBGINDENTADD(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      3|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 3]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTADD(x)  do {if (_DBG_IF_) {__DBGINDENTADD(x);} }while(0)
  |  |  ------------------
  |  |  |  |  172|      0|#define __DBGINDENTADD(x)  debug_indent_add(x)
  |  |  ------------------
  |  |  |  Branch (73:74): [Folded, False: 3]
  |  |  ------------------
  ------------------
 4069|      3|    if (data == NULL || type != ASN_INTEGER ||
  ------------------
  |  |   75|      6|#define ASN_INTEGER	    0x02U
  ------------------
  |  Branch (4069:9): [True: 0, False: 3]
  |  Branch (4069:25): [True: 0, False: 3]
  ------------------
 4070|      3|        msg_sec_model < 1 || msg_sec_model > 0x7fffffff) {
  ------------------
  |  Branch (4070:9): [True: 1, False: 2]
  |  Branch (4070:30): [True: 0, False: 2]
  ------------------
 4071|      1|        ERROR_MSG("error parsing msgSecurityModel");
  ------------------
  |  |  188|      1|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 4072|      1|        snmp_increment_statistic(STAT_SNMPINASNPARSEERRS);
  ------------------
  |  |  637|      1|#define  STAT_SNMPINASNPARSEERRS             14
  ------------------
 4073|      1|        DEBUGINDENTLESS();
  ------------------
  |  |   75|      1|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 1]
  |  |  ------------------
  ------------------
 4074|      1|        return SNMPERR_ASN_PARSE_ERR;
  ------------------
  |  |  213|      1|#define SNMPERR_ASN_PARSE_ERR           (-29)
  ------------------
 4075|      1|    }
 4076|      2|    sptr = find_sec_mod(msg_sec_model);
 4077|      2|    if (!sptr) {
  ------------------
  |  Branch (4077:9): [True: 0, False: 2]
  ------------------
 4078|      0|        snmp_log(LOG_WARNING, "unknown security model: %ld\n",
 4079|      0|                 msg_sec_model);
 4080|      0|        snmp_increment_statistic(STAT_SNMPUNKNOWNSECURITYMODELS);
  ------------------
  |  |  611|      0|#define   STAT_SNMPUNKNOWNSECURITYMODELS     0
  ------------------
 4081|      0|        DEBUGINDENTLESS();
  ------------------
  |  |   75|      0|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 0]
  |  |  ------------------
  ------------------
 4082|      0|        return SNMPERR_UNKNOWN_SEC_MODEL;
  ------------------
  |  |  214|      0|#define SNMPERR_UNKNOWN_SEC_MODEL 	(-30)
  ------------------
 4083|      0|    }
 4084|      2|    pdu->securityModel = msg_sec_model;
 4085|       |
 4086|      2|    if (msg_flags & SNMP_MSG_FLAG_PRIV_BIT &&
  ------------------
  |  |  304|      4|#define SNMP_MSG_FLAG_PRIV_BIT          0x02
  ------------------
  |  Branch (4086:9): [True: 0, False: 2]
  ------------------
 4087|      0|        !(msg_flags & SNMP_MSG_FLAG_AUTH_BIT)) {
  ------------------
  |  |  303|      0|#define SNMP_MSG_FLAG_AUTH_BIT          0x01
  ------------------
  |  Branch (4087:9): [True: 0, False: 0]
  ------------------
 4088|      0|        ERROR_MSG("invalid message, illegal msgFlags");
  ------------------
  |  |  188|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 4089|      0|        snmp_increment_statistic(STAT_SNMPINVALIDMSGS);
  ------------------
  |  |  612|      0|#define   STAT_SNMPINVALIDMSGS               1
  ------------------
 4090|      0|        DEBUGINDENTLESS();
  ------------------
  |  |   75|      0|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 0]
  |  |  ------------------
  ------------------
 4091|      0|        return SNMPERR_INVALID_MSG;
  ------------------
  |  |  215|      0|#define SNMPERR_INVALID_MSG             (-31)
  ------------------
 4092|      0|    }
 4093|      2|    pdu->securityLevel = ((msg_flags & SNMP_MSG_FLAG_AUTH_BIT)
  ------------------
  |  |  303|      2|#define SNMP_MSG_FLAG_AUTH_BIT          0x01
  ------------------
  |  Branch (4093:27): [True: 0, False: 2]
  ------------------
 4094|      2|                          ? ((msg_flags & SNMP_MSG_FLAG_PRIV_BIT)
  ------------------
  |  |  304|      0|#define SNMP_MSG_FLAG_PRIV_BIT          0x02
  ------------------
  |  Branch (4094:30): [True: 0, False: 0]
  ------------------
 4095|      0|                             ? SNMP_SEC_LEVEL_AUTHPRIV
  ------------------
  |  |  301|      0|#define SNMP_SEC_LEVEL_AUTHPRIV		3
  ------------------
 4096|      0|                             : SNMP_SEC_LEVEL_AUTHNOPRIV)
  ------------------
  |  |  300|      0|#define SNMP_SEC_LEVEL_AUTHNOPRIV	2
  ------------------
 4097|      2|                          : SNMP_SEC_LEVEL_NOAUTH);
  ------------------
  |  |  299|      2|#define SNMP_SEC_LEVEL_NOAUTH		1
  ------------------
 4098|       |    /*
 4099|       |     * end of msgGlobalData 
 4100|       |     */
 4101|       |
 4102|       |    /*
 4103|       |     * securtityParameters OCTET STRING begins after msgGlobalData 
 4104|       |     */
 4105|      2|    sec_params = data;
 4106|      2|    SNMP_FREE(pdu->contextEngineID);
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 4107|      2|    pdu->contextEngineID = calloc(1, SNMP_MAX_ENG_SIZE);
  ------------------
  |  |  111|      2|#define SNMP_MAX_ENG_SIZE          32
  ------------------
 4108|      2|    pdu->contextEngineIDLen = SNMP_MAX_ENG_SIZE;
  ------------------
  |  |  111|      2|#define SNMP_MAX_ENG_SIZE          32
  ------------------
 4109|       |
 4110|       |    /*
 4111|       |     * Note: there is no length limit on the msgAuthoritativeEngineID field,
 4112|       |     * although we would EXPECT it to be limited to 32 (the SnmpEngineID TC
 4113|       |     * limit).  We'll use double that here to be on the safe side.  
 4114|       |     */
 4115|       |
 4116|      2|    SNMP_FREE(pdu->securityEngineID);
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 4117|      2|    pdu->securityEngineID = calloc(1, SNMP_MAX_ENG_SIZE * 2);
  ------------------
  |  |  111|      2|#define SNMP_MAX_ENG_SIZE          32
  ------------------
 4118|      2|    pdu->securityEngineIDLen = SNMP_MAX_ENG_SIZE * 2;
  ------------------
  |  |  111|      2|#define SNMP_MAX_ENG_SIZE          32
  ------------------
 4119|      2|    SNMP_FREE(pdu->securityName);
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 4120|      2|    pdu->securityName = calloc(1, SNMP_MAX_SEC_NAME_SIZE);
  ------------------
  |  |  112|      2|#define SNMP_MAX_SEC_NAME_SIZE     256
  ------------------
 4121|      2|    pdu->securityNameLen = SNMP_MAX_SEC_NAME_SIZE;
  ------------------
  |  |  112|      2|#define SNMP_MAX_SEC_NAME_SIZE     256
  ------------------
 4122|       |
 4123|      2|    if ((pdu->securityName == NULL) ||
  ------------------
  |  Branch (4123:9): [True: 0, False: 2]
  ------------------
 4124|      2|        (pdu->securityEngineID == NULL) ||
  ------------------
  |  Branch (4124:9): [True: 0, False: 2]
  ------------------
 4125|      2|        (pdu->contextEngineID == NULL)) {
  ------------------
  |  Branch (4125:9): [True: 0, False: 2]
  ------------------
 4126|      0|        return SNMPERR_MALLOC;
  ------------------
  |  |  246|      0|#define SNMPERR_MALLOC			(-62)
  ------------------
 4127|      0|    }
 4128|       |
 4129|      2|    if (pdu_buf_len < msg_len
  ------------------
  |  Branch (4129:9): [True: 0, False: 2]
  ------------------
 4130|      0|        && pdu->securityLevel == SNMP_SEC_LEVEL_AUTHPRIV) {
  ------------------
  |  |  301|      0|#define SNMP_SEC_LEVEL_AUTHPRIV		3
  ------------------
  |  Branch (4130:12): [True: 0, False: 0]
  ------------------
 4131|       |        /*
 4132|       |         * space needed is larger than we have in the default buffer 
 4133|       |         */
 4134|      0|        mallocbuf = calloc(1, msg_len);
 4135|      0|        if (mallocbuf == NULL)
  ------------------
  |  Branch (4135:13): [True: 0, False: 0]
  ------------------
 4136|      0|            return SNMPERR_MALLOC;
  ------------------
  |  |  246|      0|#define SNMPERR_MALLOC			(-62)
  ------------------
 4137|      0|        pdu_buf_len = msg_len;
 4138|      0|        cp = mallocbuf;
 4139|      2|    } else {
 4140|      2|        memset(pdu_buf, 0, pdu_buf_len);
 4141|      2|        cp = pdu_buf;
 4142|      2|    }
 4143|       |
 4144|      2|    DEBUGDUMPSECTION("recv", "SM msgSecurityParameters");
  ------------------
  |  |   81|      2|	do {if (_DBG_IF_) {__DBGDUMPSECTION(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      2|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 2]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	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: 2]
  |  |  ------------------
  ------------------
 4145|      2|    if (sptr->decode) {
  ------------------
  |  Branch (4145:9): [True: 2, False: 0]
  ------------------
 4146|      2|        struct snmp_secmod_incoming_params parms;
 4147|      2|        parms.msgProcModel = pdu->msgParseModel;
 4148|      2|        parms.maxMsgSize = pdu->msgMaxSize;
 4149|      2|        parms.secParams = sec_params;
 4150|      2|        parms.secModel = msg_sec_model;
 4151|      2|        parms.secLevel = pdu->securityLevel;
 4152|      2|        parms.wholeMsg = msg_data;
 4153|      2|        parms.wholeMsgLen = msg_len;
 4154|      2|        parms.secEngineID = pdu->securityEngineID;
 4155|      2|        parms.secEngineIDLen = &pdu->securityEngineIDLen;
 4156|      2|        parms.secName = pdu->securityName;
 4157|      2|        parms.secNameLen = &pdu->securityNameLen;
 4158|      2|        parms.scopedPdu = &cp;
 4159|      2|        parms.scopedPduLen = &pdu_buf_len;
 4160|      2|        parms.maxSizeResponse = &max_size_response;
 4161|      2|        parms.secStateRef = &pdu->securityStateRef;
 4162|      2|        parms.sess = sess;
 4163|      2|        parms.pdu = pdu;
 4164|      2|        parms.msg_flags = msg_flags;
 4165|      2|        ret_val = (*sptr->decode) (&parms);
 4166|      2|    } else {
 4167|      0|        SNMP_FREE(mallocbuf);
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 4168|      0|        DEBUGINDENTLESS();
  ------------------
  |  |   75|      0|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 0]
  |  |  ------------------
  ------------------
 4169|      0|        snmp_log(LOG_WARNING, "security service %ld can't decode packets\n",
 4170|      0|                 msg_sec_model);
 4171|      0|        return (-1);
 4172|      0|    }
 4173|       |
 4174|      2|    if (ret_val != SNMPERR_SUCCESS) {
  ------------------
  |  |  184|      2|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  |  Branch (4174:9): [True: 2, False: 0]
  ------------------
 4175|      2|        DEBUGDUMPSECTION("recv", "ScopedPDU");
  ------------------
  |  |   81|      2|	do {if (_DBG_IF_) {__DBGDUMPSECTION(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      2|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 2]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	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: 2]
  |  |  ------------------
  ------------------
 4176|       |        /*
 4177|       |         * Parse as much as possible -- though I don't see the point? [jbpn].  
 4178|       |         */
 4179|      2|        if (cp) {
  ------------------
  |  Branch (4179:13): [True: 2, False: 0]
  ------------------
 4180|      2|            cp = snmpv3_scopedPDU_parse(pdu, cp, &pdu_buf_len);
 4181|      2|        }
 4182|      2|        if (cp) {
  ------------------
  |  Branch (4182:13): [True: 0, False: 2]
  ------------------
 4183|      0|            DEBUGPRINTPDUTYPE("recv", *cp);
  ------------------
  |  |  431|      0|    DEBUGDUMPSECTION(token, snmp_pdu_type(type))
  |  |  ------------------
  |  |  |  |   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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4184|      0|            snmp_pdu_parse(pdu, cp, &pdu_buf_len);
 4185|      0|            DEBUGINDENTADD(-8);
  ------------------
  |  |   73|      0|#define DEBUGINDENTADD(x)  do {if (_DBG_IF_) {__DBGINDENTADD(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTADD(x)  do {if (_DBG_IF_) {__DBGINDENTADD(x);} }while(0)
  |  |  ------------------
  |  |  |  |  172|      0|#define __DBGINDENTADD(x)  debug_indent_add(x)
  |  |  ------------------
  |  |  |  Branch (73:74): [Folded, False: 0]
  |  |  ------------------
  ------------------
 4186|      2|        } else {
 4187|      2|            DEBUGINDENTADD(-4);
  ------------------
  |  |   73|      2|#define DEBUGINDENTADD(x)  do {if (_DBG_IF_) {__DBGINDENTADD(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      2|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 2]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTADD(x)  do {if (_DBG_IF_) {__DBGINDENTADD(x);} }while(0)
  |  |  ------------------
  |  |  |  |  172|      0|#define __DBGINDENTADD(x)  debug_indent_add(x)
  |  |  ------------------
  |  |  |  Branch (73:74): [Folded, False: 2]
  |  |  ------------------
  ------------------
 4188|      2|        }
 4189|       |
 4190|      2|        SNMP_FREE(mallocbuf);
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 4191|      2|        return ret_val;
 4192|      2|    }
 4193|       |
 4194|       |    /*
 4195|       |     * parse plaintext ScopedPDU sequence 
 4196|       |     */
 4197|      0|    *length = pdu_buf_len;
 4198|      0|    DEBUGDUMPSECTION("recv", "ScopedPDU");
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 4199|      0|    data = snmpv3_scopedPDU_parse(pdu, cp, length);
 4200|      0|    if (data == NULL) {
  ------------------
  |  Branch (4200:9): [True: 0, False: 0]
  ------------------
 4201|      0|        snmp_log(LOG_WARNING, "security service %ld error parsing ScopedPDU\n",
 4202|      0|                 msg_sec_model);
 4203|      0|        ERROR_MSG("error parsing PDU");
  ------------------
  |  |  188|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 4204|      0|        snmp_increment_statistic(STAT_SNMPINASNPARSEERRS);
  ------------------
  |  |  637|      0|#define  STAT_SNMPINASNPARSEERRS             14
  ------------------
 4205|      0|        DEBUGINDENTADD(-4);
  ------------------
  |  |   73|      0|#define DEBUGINDENTADD(x)  do {if (_DBG_IF_) {__DBGINDENTADD(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTADD(x)  do {if (_DBG_IF_) {__DBGINDENTADD(x);} }while(0)
  |  |  ------------------
  |  |  |  |  172|      0|#define __DBGINDENTADD(x)  debug_indent_add(x)
  |  |  ------------------
  |  |  |  Branch (73:74): [Folded, False: 0]
  |  |  ------------------
  ------------------
 4206|      0|        SNMP_FREE(mallocbuf);
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 4207|      0|        return SNMPERR_ASN_PARSE_ERR;
  ------------------
  |  |  213|      0|#define SNMPERR_ASN_PARSE_ERR           (-29)
  ------------------
 4208|      0|    }
 4209|       |
 4210|       |    /*
 4211|       |     * parse the PDU.  
 4212|       |     */
 4213|      0|    if (after_header != NULL) {
  ------------------
  |  Branch (4213:9): [True: 0, False: 0]
  ------------------
 4214|      0|        *after_header = data;
 4215|      0|        tmp_buf_len = *length;
 4216|      0|    }
 4217|       |
 4218|      0|    DEBUGPRINTPDUTYPE("recv", *data);
  ------------------
  |  |  431|      0|    DEBUGDUMPSECTION(token, snmp_pdu_type(type))
  |  |  ------------------
  |  |  |  |   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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4219|      0|    ret = snmp_pdu_parse(pdu, data, length);
 4220|      0|    DEBUGINDENTADD(-8);
  ------------------
  |  |   73|      0|#define DEBUGINDENTADD(x)  do {if (_DBG_IF_) {__DBGINDENTADD(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTADD(x)  do {if (_DBG_IF_) {__DBGINDENTADD(x);} }while(0)
  |  |  ------------------
  |  |  |  |  172|      0|#define __DBGINDENTADD(x)  debug_indent_add(x)
  |  |  ------------------
  |  |  |  Branch (73:74): [Folded, False: 0]
  |  |  ------------------
  ------------------
 4221|       |
 4222|      0|    if (after_header != NULL) {
  ------------------
  |  Branch (4222:9): [True: 0, False: 0]
  ------------------
 4223|      0|        *length = tmp_buf_len;
 4224|      0|    }
 4225|       |
 4226|      0|    if (ret != SNMPERR_SUCCESS) {
  ------------------
  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  |  Branch (4226:9): [True: 0, False: 0]
  ------------------
 4227|      0|        snmp_log(LOG_WARNING, "security service %ld error parsing ScopedPDU\n",
 4228|      0|                 msg_sec_model);
 4229|      0|        ERROR_MSG("error parsing PDU");
  ------------------
  |  |  188|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 4230|      0|        snmp_increment_statistic(STAT_SNMPINASNPARSEERRS);
  ------------------
  |  |  637|      0|#define  STAT_SNMPINASNPARSEERRS             14
  ------------------
 4231|      0|        SNMP_FREE(mallocbuf);
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 4232|      0|        return SNMPERR_ASN_PARSE_ERR;
  ------------------
  |  |  213|      0|#define SNMPERR_ASN_PARSE_ERR           (-29)
  ------------------
 4233|      0|    }
 4234|       |
 4235|      0|    SNMP_FREE(mallocbuf);
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 4236|      0|    return SNMPERR_SUCCESS;
  ------------------
  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 4237|      0|}                               /* end snmpv3_parse() */
snmp_parse:
 4776|    118|{
 4777|    118|    int             rc;
 4778|       |
 4779|    118|    rc = _snmp_parse(slp, pss, pdu, data, length);
 4780|    118|    if (rc) {
  ------------------
  |  Branch (4780:9): [True: 118, False: 0]
  ------------------
 4781|    118|        if (!pss->s_snmp_errno) {
  ------------------
  |  Branch (4781:13): [True: 36, False: 82]
  ------------------
 4782|     36|            pss->s_snmp_errno = SNMPERR_BAD_PARSE;
  ------------------
  |  |  197|     36|#define SNMPERR_BAD_PARSE		(-13)
  ------------------
 4783|     36|        }
 4784|    118|        SET_SNMP_ERROR(pss->s_snmp_errno);
  ------------------
  |  |   43|    118|#define SET_SNMP_ERROR(x) snmp_errno=(x)
  ------------------
 4785|    118|    }
 4786|       |
 4787|    118|    return rc;
 4788|    118|}
snmp_pdu_parse:
 4792|     10|{
 4793|     10|    u_char          type;
 4794|     10|    u_char          msg_type;
 4795|     10|    u_char         *var_val;
 4796|     10|    size_t          len;
 4797|     10|    size_t          four;
 4798|     10|    netsnmp_variable_list *vp = NULL, *vplast = NULL;
 4799|     10|    oid             objid[MAX_OID_LEN];
 4800|     10|    u_char         *p;
 4801|       |
 4802|       |    /*
 4803|       |     * Get the PDU type 
 4804|       |     */
 4805|     10|    data = asn_parse_header(data, length, &msg_type);
 4806|     10|    if (data == NULL)
  ------------------
  |  Branch (4806:9): [True: 2, False: 8]
  ------------------
 4807|      2|        return -1;
 4808|      8|    DEBUGMSGTL(("dumpv_recv","    Command %s\n", snmp_pdu_type(msg_type)));
  ------------------
  |  |   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: 0, False: 8]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 8]
  |  |  ------------------
  ------------------
 4809|      8|    pdu->command = msg_type;
 4810|      8|    pdu->flags &= (~UCD_MSG_FLAG_RESPONSE_PDU);
  ------------------
  |  |  311|      8|#define UCD_MSG_FLAG_RESPONSE_PDU            0x100
  ------------------
 4811|       |
 4812|       |    /*
 4813|       |     * get the fields in the PDU preceding the variable-bindings sequence
 4814|       |     */
 4815|      8|    switch (pdu->command) {
 4816|      6|    case SNMP_MSG_TRAP:
  ------------------
  |  |  135|      6|#define SNMP_MSG_TRAP       (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x4) /* a4=164 */
  |  |  ------------------
  |  |  |  |   92|      6|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_MSG_TRAP       (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x4) /* a4=164 */
  |  |  ------------------
  |  |  |  |   96|      6|#define ASN_CONSTRUCTOR	    0x20U
  |  |  ------------------
  ------------------
  |  Branch (4816:5): [True: 6, False: 2]
  ------------------
 4817|       |        /*
 4818|       |         * enterprise 
 4819|       |         */
 4820|      6|        pdu->enterprise_length = MAX_OID_LEN;
  ------------------
  |  |  120|      6|#define MAX_OID_LEN	    128 /* max subid's in an oid */
  ------------------
 4821|      6|        data = asn_parse_objid(data, length, &type, objid,
 4822|      6|                               &pdu->enterprise_length);
 4823|      6|        if (data == NULL)
  ------------------
  |  Branch (4823:13): [True: 3, False: 3]
  ------------------
 4824|      3|            return -1;
 4825|      3|        SNMP_FREE(pdu->enterprise);
  ------------------
  |  |   62|      3|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 3]
  |  |  |  Branch (62:66): [Folded, False: 3]
  |  |  ------------------
  ------------------
 4826|      3|        pdu->enterprise = netsnmp_memdup(objid,
 4827|      3|                                         pdu->enterprise_length * sizeof(oid));
 4828|      3|        if (pdu->enterprise == NULL) {
  ------------------
  |  Branch (4828:13): [True: 0, False: 3]
  ------------------
 4829|      0|            return -1;
 4830|      0|        }
 4831|       |
 4832|       |        /*
 4833|       |         * agent-addr 
 4834|       |         */
 4835|      3|        four = 4;
 4836|      3|        data = asn_parse_string(data, length, &type,
 4837|      3|                                (u_char *) pdu->agent_addr, &four);
 4838|      3|        if (data == NULL)
  ------------------
  |  Branch (4838:13): [True: 3, False: 0]
  ------------------
 4839|      3|            return -1;
 4840|       |
 4841|       |        /*
 4842|       |         * generic trap 
 4843|       |         */
 4844|      0|        data = asn_parse_int(data, length, &type, (long *) &pdu->trap_type,
 4845|      0|                             sizeof(pdu->trap_type));
 4846|      0|        if (data == NULL)
  ------------------
  |  Branch (4846:13): [True: 0, False: 0]
  ------------------
 4847|      0|            return -1;
 4848|       |        /*
 4849|       |         * specific trap 
 4850|       |         */
 4851|      0|        data =
 4852|      0|            asn_parse_int(data, length, &type,
 4853|      0|                          (long *) &pdu->specific_type,
 4854|      0|                          sizeof(pdu->specific_type));
 4855|      0|        if (data == NULL)
  ------------------
  |  Branch (4855:13): [True: 0, False: 0]
  ------------------
 4856|      0|            return -1;
 4857|       |
 4858|       |        /*
 4859|       |         * timestamp  
 4860|       |         */
 4861|      0|        data = asn_parse_unsigned_int(data, length, &type, &pdu->time,
 4862|      0|                                      sizeof(pdu->time));
 4863|      0|        if (data == NULL)
  ------------------
  |  Branch (4863:13): [True: 0, False: 0]
  ------------------
 4864|      0|            return -1;
 4865|       |
 4866|      0|        break;
 4867|       |
 4868|      0|    case 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
  |  |  ------------------
  ------------------
  |  Branch (4868:5): [True: 0, False: 8]
  ------------------
 4869|      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 (4869:5): [True: 0, False: 8]
  ------------------
 4870|      0|        pdu->flags |= UCD_MSG_FLAG_RESPONSE_PDU;
  ------------------
  |  |  311|      0|#define UCD_MSG_FLAG_RESPONSE_PDU            0x100
  ------------------
 4871|      0|        NETSNMP_FALLTHROUGH;
  ------------------
  |  | 2443|      0|#    define NETSNMP_FALLTHROUGH __attribute__((__fallthrough__))
  ------------------
 4872|       |
 4873|      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 (4873:5): [True: 0, False: 8]
  ------------------
 4874|      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 (4874:5): [True: 0, False: 8]
  ------------------
 4875|      0|#ifndef NETSNMP_NOTIFY_ONLY
 4876|      0|    case SNMP_MSG_GET:
  ------------------
  |  |  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 (4876:5): [True: 0, False: 8]
  ------------------
 4877|      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 (4877:5): [True: 0, False: 8]
  ------------------
 4878|      0|    case SNMP_MSG_GETBULK:
  ------------------
  |  |  140|      0|#define SNMP_MSG_GETBULK    (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x5) /* a5=165 */
  |  |  ------------------
  |  |  |  |   92|      0|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_MSG_GETBULK    (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x5) /* a5=165 */
  |  |  ------------------
  |  |  |  |   96|      0|#define ASN_CONSTRUCTOR	    0x20U
  |  |  ------------------
  ------------------
  |  Branch (4878:5): [True: 0, False: 8]
  ------------------
 4879|      0|#endif /* ! NETSNMP_NOTIFY_ONLY */
 4880|      0|#ifndef NETSNMP_NO_WRITE_SUPPORT
 4881|      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 (4881:5): [True: 0, False: 8]
  ------------------
 4882|      0|#endif /* !NETSNMP_NO_WRITE_SUPPORT */
 4883|       |        /*
 4884|       |         * PDU is not an SNMPv1 TRAP 
 4885|       |         */
 4886|       |
 4887|       |        /*
 4888|       |         * request id 
 4889|       |         */
 4890|      0|        DEBUGDUMPHEADER("recv", "request_id");
  ------------------
  |  |   79|      0|	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  178|      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__))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  179|      0|        debugmsg("dumph_" token,x); \
  |  |  |  |  180|      0|        if (debug_is_token_registered("dumpx" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (180:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  181|      0|            debug_is_token_registered("dumpv" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (181:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  182|      0|            (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|      0|             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|      0|            debugmsg("dumph_" token,"\n"); \
  |  |  |  |  185|      0|        } else { \
  |  |  |  |  186|      0|            debugmsg("dumph_" token,"  "); \
  |  |  |  |  187|      0|        } \
  |  |  |  |  188|      0|        __DBGINDENTMORE()
  |  |  |  |  ------------------
  |  |  |  |  |  |  173|      0|#define __DBGINDENTMORE()  debug_indent_add(2)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (79:55): [Folded, False: 0]
  |  |  ------------------
  ------------------
 4891|      0|        data = asn_parse_int(data, length, &type, &pdu->reqid,
 4892|      0|                             sizeof(pdu->reqid));
 4893|      0|        DEBUGINDENTLESS();
  ------------------
  |  |   75|      0|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 0]
  |  |  ------------------
  ------------------
 4894|      0|        if (data == NULL) {
  ------------------
  |  Branch (4894:13): [True: 0, False: 0]
  ------------------
 4895|      0|            return -1;
 4896|      0|        }
 4897|       |
 4898|       |        /*
 4899|       |         * error status (getbulk non-repeaters) 
 4900|       |         */
 4901|      0|        DEBUGDUMPHEADER("recv", "error status");
  ------------------
  |  |   79|      0|	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  178|      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__))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  179|      0|        debugmsg("dumph_" token,x); \
  |  |  |  |  180|      0|        if (debug_is_token_registered("dumpx" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (180:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  181|      0|            debug_is_token_registered("dumpv" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (181:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  182|      0|            (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|      0|             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|      0|            debugmsg("dumph_" token,"\n"); \
  |  |  |  |  185|      0|        } else { \
  |  |  |  |  186|      0|            debugmsg("dumph_" token,"  "); \
  |  |  |  |  187|      0|        } \
  |  |  |  |  188|      0|        __DBGINDENTMORE()
  |  |  |  |  ------------------
  |  |  |  |  |  |  173|      0|#define __DBGINDENTMORE()  debug_indent_add(2)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (79:55): [Folded, False: 0]
  |  |  ------------------
  ------------------
 4902|      0|        data = asn_parse_int(data, length, &type, &pdu->errstat,
 4903|      0|                             sizeof(pdu->errstat));
 4904|      0|        DEBUGINDENTLESS();
  ------------------
  |  |   75|      0|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 0]
  |  |  ------------------
  ------------------
 4905|      0|        if (data == NULL) {
  ------------------
  |  Branch (4905:13): [True: 0, False: 0]
  ------------------
 4906|      0|            return -1;
 4907|      0|        }
 4908|       |
 4909|       |        /*
 4910|       |         * error index (getbulk max-repetitions) 
 4911|       |         */
 4912|      0|        DEBUGDUMPHEADER("recv", "error index");
  ------------------
  |  |   79|      0|	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  178|      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__))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  179|      0|        debugmsg("dumph_" token,x); \
  |  |  |  |  180|      0|        if (debug_is_token_registered("dumpx" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (180:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  181|      0|            debug_is_token_registered("dumpv" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (181:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  182|      0|            (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|      0|             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|      0|            debugmsg("dumph_" token,"\n"); \
  |  |  |  |  185|      0|        } else { \
  |  |  |  |  186|      0|            debugmsg("dumph_" token,"  "); \
  |  |  |  |  187|      0|        } \
  |  |  |  |  188|      0|        __DBGINDENTMORE()
  |  |  |  |  ------------------
  |  |  |  |  |  |  173|      0|#define __DBGINDENTMORE()  debug_indent_add(2)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (79:55): [Folded, False: 0]
  |  |  ------------------
  ------------------
 4913|      0|        data = asn_parse_int(data, length, &type, &pdu->errindex,
 4914|      0|                             sizeof(pdu->errindex));
 4915|      0|        DEBUGINDENTLESS();
  ------------------
  |  |   75|      0|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 0]
  |  |  ------------------
  ------------------
 4916|      0|        if (data == NULL) {
  ------------------
  |  Branch (4916:13): [True: 0, False: 0]
  ------------------
 4917|      0|            return -1;
 4918|      0|        }
 4919|      0|	break;
 4920|       |
 4921|      2|    default:
  ------------------
  |  Branch (4921:5): [True: 2, False: 6]
  ------------------
 4922|      2|        snmp_log(LOG_ERR, "Bad PDU type received: 0x%.2x\n", pdu->command);
 4923|      2|        snmp_increment_statistic(STAT_SNMPINASNPARSEERRS);
  ------------------
  |  |  637|      2|#define  STAT_SNMPINASNPARSEERRS             14
  ------------------
 4924|      2|        return -1;
 4925|      8|    }
 4926|       |
 4927|       |    /*
 4928|       |     * get header for variable-bindings sequence 
 4929|       |     */
 4930|      0|    DEBUGDUMPSECTION("recv", "VarBindList");
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 4931|      0|    data = asn_parse_sequence(data, length, &type,
 4932|      0|                              (ASN_SEQUENCE | ASN_CONSTRUCTOR),
  ------------------
  |  |   84|      0|#define ASN_SEQUENCE	    0x10U
  ------------------
                                            (ASN_SEQUENCE | ASN_CONSTRUCTOR),
  ------------------
  |  |   96|      0|#define ASN_CONSTRUCTOR	    0x20U
  ------------------
 4933|      0|                              "varbinds");
 4934|      0|    if (data == NULL)
  ------------------
  |  Branch (4934:9): [True: 0, False: 0]
  ------------------
 4935|      0|        goto fail;
 4936|       |
 4937|      0|    snmp_free_varbind(pdu->variables);
 4938|      0|    pdu->variables = NULL;
 4939|       |
 4940|       |    /*
 4941|       |     * get each varBind sequence 
 4942|       |     */
 4943|      0|    while ((int) *length > 0) {
  ------------------
  |  Branch (4943:12): [True: 0, False: 0]
  ------------------
 4944|      0|        vp = SNMP_MALLOC_TYPEDEF(netsnmp_variable_list);
  ------------------
  |  |   73|      0|#define SNMP_MALLOC_TYPEDEF(td)  (td *) calloc(1, sizeof(td))
  ------------------
 4945|      0|        if (NULL == vp)
  ------------------
  |  Branch (4945:13): [True: 0, False: 0]
  ------------------
 4946|      0|            goto fail;
 4947|       |
 4948|      0|        vp->name_length = MAX_OID_LEN;
  ------------------
  |  |  120|      0|#define MAX_OID_LEN	    128 /* max subid's in an oid */
  ------------------
 4949|      0|        DEBUGDUMPSECTION("recv", "VarBind");
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 4950|      0|        data = snmp_parse_var_op(data, objid, &vp->name_length, &vp->type,
 4951|      0|                                 &vp->val_len, &var_val, length);
 4952|      0|        if (data == NULL)
  ------------------
  |  Branch (4952:13): [True: 0, False: 0]
  ------------------
 4953|      0|            goto fail;
 4954|      0|        if (snmp_set_var_objid(vp, objid, vp->name_length))
  ------------------
  |  Branch (4954:13): [True: 0, False: 0]
  ------------------
 4955|      0|            goto fail;
 4956|       |
 4957|      0|        len = SNMP_MAX_PACKET_LEN;
  ------------------
  |  |   49|      0|#define SNMP_MAX_PACKET_LEN (0x7fffffff)
  ------------------
 4958|      0|        DEBUGDUMPHEADER("recv", "Value");
  ------------------
  |  |   79|      0|	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  178|      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__))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  179|      0|        debugmsg("dumph_" token,x); \
  |  |  |  |  180|      0|        if (debug_is_token_registered("dumpx" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (180:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  181|      0|            debug_is_token_registered("dumpv" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (181:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  182|      0|            (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|      0|             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|      0|            debugmsg("dumph_" token,"\n"); \
  |  |  |  |  185|      0|        } else { \
  |  |  |  |  186|      0|            debugmsg("dumph_" token,"  "); \
  |  |  |  |  187|      0|        } \
  |  |  |  |  188|      0|        __DBGINDENTMORE()
  |  |  |  |  ------------------
  |  |  |  |  |  |  173|      0|#define __DBGINDENTMORE()  debug_indent_add(2)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (79:55): [Folded, False: 0]
  |  |  ------------------
  ------------------
 4959|      0|        switch ((short) vp->type) {
 4960|      0|        case ASN_INTEGER:
  ------------------
  |  |   75|      0|#define ASN_INTEGER	    0x02U
  ------------------
  |  Branch (4960:9): [True: 0, False: 0]
  ------------------
 4961|      0|            vp->val.integer = (long *) vp->buf;
 4962|      0|            vp->val_len = sizeof(long);
 4963|      0|            p = asn_parse_int(var_val, &len, &vp->type,
 4964|      0|                          (long *) vp->val.integer,
 4965|      0|                          sizeof(*vp->val.integer));
 4966|      0|            if (!p)
  ------------------
  |  Branch (4966:17): [True: 0, False: 0]
  ------------------
 4967|      0|                goto fail;
 4968|      0|            break;
 4969|      0|        case ASN_COUNTER:
  ------------------
  |  |   89|      0|#define ASN_COUNTER	(ASN_APPLICATION | 1)
  |  |  ------------------
  |  |  |  |   91|      0|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (4969:9): [True: 0, False: 0]
  ------------------
 4970|      0|        case ASN_GAUGE:
  ------------------
  |  |   90|      0|#define ASN_GAUGE	(ASN_APPLICATION | 2)
  |  |  ------------------
  |  |  |  |   91|      0|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (4970:9): [True: 0, False: 0]
  ------------------
 4971|      0|        case ASN_TIMETICKS:
  ------------------
  |  |   92|      0|#define ASN_TIMETICKS   (ASN_APPLICATION | 3)
  |  |  ------------------
  |  |  |  |   91|      0|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (4971:9): [True: 0, False: 0]
  ------------------
 4972|      0|        case ASN_UINTEGER:
  ------------------
  |  |  100|      0|#define ASN_UINTEGER    (ASN_APPLICATION | 7)   /* historic - don't use */
  |  |  ------------------
  |  |  |  |   91|      0|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (4972:9): [True: 0, False: 0]
  ------------------
 4973|      0|            vp->val.integer = (long *) vp->buf;
 4974|      0|            vp->val_len = sizeof(u_long);
 4975|      0|            p = asn_parse_unsigned_int(var_val, &len, &vp->type,
 4976|      0|                                   (u_long *) vp->val.integer,
 4977|      0|                                   vp->val_len);
 4978|      0|            if (!p)
  ------------------
  |  Branch (4978:17): [True: 0, False: 0]
  ------------------
 4979|      0|                goto fail;
 4980|      0|            break;
 4981|      0|#ifdef NETSNMP_WITH_OPAQUE_SPECIAL_TYPES
 4982|      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 (4982:9): [True: 0, False: 0]
  ------------------
 4983|      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 (4983:9): [True: 0, False: 0]
  ------------------
 4984|      0|#endif                          /* NETSNMP_WITH_OPAQUE_SPECIAL_TYPES */
 4985|      0|        case ASN_COUNTER64:
  ------------------
  |  |   99|      0|#define ASN_COUNTER64   (ASN_APPLICATION | 6)
  |  |  ------------------
  |  |  |  |   91|      0|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (4985:9): [True: 0, False: 0]
  ------------------
 4986|      0|            vp->val.counter64 = (struct counter64 *) vp->buf;
 4987|      0|            vp->val_len = sizeof(struct counter64);
 4988|      0|            p = asn_parse_unsigned_int64(var_val, &len, &vp->type,
 4989|      0|                                     (struct counter64 *) vp->val.
 4990|      0|                                     counter64, vp->val_len);
 4991|      0|            if (!p)
  ------------------
  |  Branch (4991:17): [True: 0, False: 0]
  ------------------
 4992|      0|                goto fail;
 4993|      0|            break;
 4994|      0|#ifdef NETSNMP_WITH_OPAQUE_SPECIAL_TYPES
 4995|      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 (4995:9): [True: 0, False: 0]
  ------------------
 4996|      0|            vp->val.floatVal = (float *) vp->buf;
 4997|      0|            vp->val_len = sizeof(float);
 4998|      0|            p = asn_parse_float(var_val, &len, &vp->type,
 4999|      0|                            vp->val.floatVal, vp->val_len);
 5000|      0|            if (!p)
  ------------------
  |  Branch (5000:17): [True: 0, False: 0]
  ------------------
 5001|      0|                goto fail;
 5002|      0|            break;
 5003|      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 (5003:9): [True: 0, False: 0]
  ------------------
 5004|      0|            vp->val.doubleVal = (double *) vp->buf;
 5005|      0|            vp->val_len = sizeof(double);
 5006|      0|            p = asn_parse_double(var_val, &len, &vp->type,
 5007|      0|                             vp->val.doubleVal, vp->val_len);
 5008|      0|            if (!p)
  ------------------
  |  Branch (5008:17): [True: 0, False: 0]
  ------------------
 5009|      0|                goto fail;
 5010|      0|            break;
 5011|      0|        case 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 (5011:9): [True: 0, False: 0]
  ------------------
 5012|      0|            vp->val.counter64 = (struct counter64 *) vp->buf;
 5013|      0|            vp->val_len = sizeof(struct counter64);
 5014|      0|            p = asn_parse_signed_int64(var_val, &len, &vp->type,
 5015|      0|                                   (struct counter64 *) vp->val.counter64,
 5016|      0|                                   sizeof(*vp->val.counter64));
 5017|       |
 5018|      0|            if (!p)
  ------------------
  |  Branch (5018:17): [True: 0, False: 0]
  ------------------
 5019|      0|                goto fail;
 5020|      0|            break;
 5021|      0|#endif                          /* NETSNMP_WITH_OPAQUE_SPECIAL_TYPES */
 5022|      0|        case ASN_IPADDRESS:
  ------------------
  |  |   88|      0|#define ASN_IPADDRESS   (ASN_APPLICATION | 0)
  |  |  ------------------
  |  |  |  |   91|      0|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (5022:9): [True: 0, False: 0]
  ------------------
 5023|      0|            if (vp->val_len != 4)
  ------------------
  |  Branch (5023:17): [True: 0, False: 0]
  ------------------
 5024|      0|                goto fail;
 5025|      0|            NETSNMP_FALLTHROUGH;
  ------------------
  |  | 2443|      0|#    define NETSNMP_FALLTHROUGH __attribute__((__fallthrough__))
  ------------------
 5026|      0|        case ASN_OCTET_STR:
  ------------------
  |  |   78|      0|#define ASN_OCTET_STR	    0x04U
  ------------------
  |  Branch (5026:9): [True: 0, False: 0]
  ------------------
 5027|      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 (5027:9): [True: 0, False: 0]
  ------------------
 5028|      0|        case ASN_NSAP:
  ------------------
  |  |   98|      0|#define ASN_NSAP	(ASN_APPLICATION | 5)   /* historic - don't use */
  |  |  ------------------
  |  |  |  |   91|      0|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (5028:9): [True: 0, False: 0]
  ------------------
 5029|      0|            if (vp->val_len < sizeof(vp->buf)) {
  ------------------
  |  Branch (5029:17): [True: 0, False: 0]
  ------------------
 5030|      0|                vp->val.string = (u_char *) vp->buf;
 5031|      0|            } else {
 5032|      0|                vp->val.string = (u_char *) malloc(vp->val_len);
 5033|      0|            }
 5034|      0|            if (vp->val.string == NULL) {
  ------------------
  |  Branch (5034:17): [True: 0, False: 0]
  ------------------
 5035|      0|                goto fail;
 5036|      0|            }
 5037|      0|            p = asn_parse_string(var_val, &len, &vp->type, vp->val.string,
 5038|      0|                             &vp->val_len);
 5039|      0|            if (!p)
  ------------------
  |  Branch (5039:17): [True: 0, False: 0]
  ------------------
 5040|      0|                goto fail;
 5041|      0|            break;
 5042|      0|        case ASN_OBJECT_ID:
  ------------------
  |  |   81|      0|#define ASN_OBJECT_ID	    0x06U
  ------------------
  |  Branch (5042:9): [True: 0, False: 0]
  ------------------
 5043|      0|            vp->val_len = MAX_OID_LEN;
  ------------------
  |  |  120|      0|#define MAX_OID_LEN	    128 /* max subid's in an oid */
  ------------------
 5044|      0|            p = asn_parse_objid(var_val, &len, &vp->type, objid, &vp->val_len);
 5045|      0|            if (!p)
  ------------------
  |  Branch (5045:17): [True: 0, False: 0]
  ------------------
 5046|      0|                goto fail;
 5047|      0|            vp->val_len *= sizeof(oid);
 5048|      0|            vp->val.objid = netsnmp_memdup(objid, vp->val_len);
 5049|      0|            if (vp->val.objid == NULL)
  ------------------
  |  Branch (5049:17): [True: 0, False: 0]
  ------------------
 5050|      0|                goto fail;
 5051|      0|            break;
 5052|      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 (5052:9): [True: 0, False: 0]
  ------------------
 5053|      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 (5053:9): [True: 0, False: 0]
  ------------------
 5054|      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 (5054:9): [True: 0, False: 0]
  ------------------
 5055|      0|        case ASN_NULL:
  ------------------
  |  |   79|      0|#define ASN_NULL	    0x05U
  ------------------
  |  Branch (5055:9): [True: 0, False: 0]
  ------------------
 5056|      0|            break;
 5057|      0|        case ASN_BIT_STR:
  ------------------
  |  |   77|      0|#define ASN_BIT_STR	    0x03U
  ------------------
  |  Branch (5057:9): [True: 0, False: 0]
  ------------------
 5058|      0|            vp->val.bitstring = (u_char *) malloc(vp->val_len);
 5059|      0|            if (vp->val.bitstring == NULL) {
  ------------------
  |  Branch (5059:17): [True: 0, False: 0]
  ------------------
 5060|      0|                goto fail;
 5061|      0|            }
 5062|      0|            p = asn_parse_bitstring(var_val, &len, &vp->type,
 5063|      0|                                vp->val.bitstring, &vp->val_len);
 5064|      0|            if (!p)
  ------------------
  |  Branch (5064:17): [True: 0, False: 0]
  ------------------
 5065|      0|                goto fail;
 5066|      0|            break;
 5067|      0|        default:
  ------------------
  |  Branch (5067:9): [True: 0, False: 0]
  ------------------
 5068|      0|            snmp_log(LOG_ERR, "bad type returned (%x)\n", vp->type);
 5069|      0|            goto fail;
 5070|      0|            break;
 5071|      0|        }
 5072|      0|        DEBUGINDENTADD(-4);
  ------------------
  |  |   73|      0|#define DEBUGINDENTADD(x)  do {if (_DBG_IF_) {__DBGINDENTADD(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTADD(x)  do {if (_DBG_IF_) {__DBGINDENTADD(x);} }while(0)
  |  |  ------------------
  |  |  |  |  172|      0|#define __DBGINDENTADD(x)  debug_indent_add(x)
  |  |  ------------------
  |  |  |  Branch (73:74): [Folded, False: 0]
  |  |  ------------------
  ------------------
 5073|       |
 5074|      0|        if (NULL == vplast) {
  ------------------
  |  Branch (5074:13): [True: 0, False: 0]
  ------------------
 5075|      0|            pdu->variables = vp;
 5076|      0|        } else {
 5077|      0|            vplast->next_variable = vp;
 5078|      0|        }
 5079|      0|        vplast = vp;
 5080|      0|        vp = NULL;
 5081|      0|    }
 5082|      0|    return 0;
 5083|       |
 5084|      0|  fail:
 5085|      0|    {
 5086|      0|        const char *errstr = snmp_api_errstring(SNMPERR_SUCCESS);
  ------------------
  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 5087|      0|        DEBUGMSGTL(("recv", "error while parsing VarBindList:%s\n", errstr));
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 5088|      0|    }
 5089|       |    /** if we were parsing a var, remove it from the pdu and free it */
 5090|      0|    if (vp)
  ------------------
  |  Branch (5090:9): [True: 0, False: 0]
  ------------------
 5091|      0|        snmp_free_var(vp);
 5092|       |
 5093|      0|    return -1;
 5094|      0|}
snmpv3_scopedPDU_parse:
 5105|      2|{
 5106|      2|    u_char          tmp_buf[SNMP_MAX_MSG_SIZE];
 5107|      2|    size_t          tmp_buf_len;
 5108|      2|    u_char          type;
 5109|      2|    size_t          asn_len;
 5110|      2|    u_char         *data;
 5111|       |
 5112|      2|    pdu->command = 0;           /* initialize so we know if it got parsed */
 5113|      2|    asn_len = *length;
 5114|      2|    data = asn_parse_sequence(cp, &asn_len, &type,
 5115|      2|                              (ASN_SEQUENCE | ASN_CONSTRUCTOR),
  ------------------
  |  |   84|      2|#define ASN_SEQUENCE	    0x10U
  ------------------
                                            (ASN_SEQUENCE | ASN_CONSTRUCTOR),
  ------------------
  |  |   96|      2|#define ASN_CONSTRUCTOR	    0x20U
  ------------------
 5116|      2|                              "plaintext scopedPDU");
 5117|      2|    if (data == NULL) {
  ------------------
  |  Branch (5117:9): [True: 2, False: 0]
  ------------------
 5118|      2|        return NULL;
 5119|      2|    }
 5120|      0|    *length -= data - cp;
 5121|       |
 5122|       |    /*
 5123|       |     * contextEngineID from scopedPdu  
 5124|       |     */
 5125|      0|    DEBUGDUMPHEADER("recv", "contextEngineID");
  ------------------
  |  |   79|      0|	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  178|      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__))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  179|      0|        debugmsg("dumph_" token,x); \
  |  |  |  |  180|      0|        if (debug_is_token_registered("dumpx" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (180:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  181|      0|            debug_is_token_registered("dumpv" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (181:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  182|      0|            (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|      0|             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|      0|            debugmsg("dumph_" token,"\n"); \
  |  |  |  |  185|      0|        } else { \
  |  |  |  |  186|      0|            debugmsg("dumph_" token,"  "); \
  |  |  |  |  187|      0|        } \
  |  |  |  |  188|      0|        __DBGINDENTMORE()
  |  |  |  |  ------------------
  |  |  |  |  |  |  173|      0|#define __DBGINDENTMORE()  debug_indent_add(2)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (79:55): [Folded, False: 0]
  |  |  ------------------
  ------------------
 5126|      0|    data = asn_parse_string(data, length, &type, pdu->contextEngineID,
 5127|      0|                            &pdu->contextEngineIDLen);
 5128|      0|    DEBUGINDENTLESS();
  ------------------
  |  |   75|      0|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 0]
  |  |  ------------------
  ------------------
 5129|      0|    if (data == NULL) {
  ------------------
  |  Branch (5129:9): [True: 0, False: 0]
  ------------------
 5130|      0|        ERROR_MSG("error parsing contextEngineID from scopedPdu");
  ------------------
  |  |  188|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 5131|      0|        return NULL;
 5132|      0|    }
 5133|       |
 5134|       |    /*
 5135|       |     * parse contextName from scopedPdu
 5136|       |     */
 5137|      0|    tmp_buf_len = SNMP_MAX_CONTEXT_SIZE;
  ------------------
  |  |  113|      0|#define SNMP_MAX_CONTEXT_SIZE      256
  ------------------
 5138|      0|    DEBUGDUMPHEADER("recv", "contextName");
  ------------------
  |  |   79|      0|	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  178|      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__))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  179|      0|        debugmsg("dumph_" token,x); \
  |  |  |  |  180|      0|        if (debug_is_token_registered("dumpx" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (180:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  181|      0|            debug_is_token_registered("dumpv" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (181:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  182|      0|            (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|      0|             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|      0|            debugmsg("dumph_" token,"\n"); \
  |  |  |  |  185|      0|        } else { \
  |  |  |  |  186|      0|            debugmsg("dumph_" token,"  "); \
  |  |  |  |  187|      0|        } \
  |  |  |  |  188|      0|        __DBGINDENTMORE()
  |  |  |  |  ------------------
  |  |  |  |  |  |  173|      0|#define __DBGINDENTMORE()  debug_indent_add(2)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (79:55): [Folded, False: 0]
  |  |  ------------------
  ------------------
 5139|      0|    data = asn_parse_string(data, length, &type, tmp_buf, &tmp_buf_len);
 5140|      0|    DEBUGINDENTLESS();
  ------------------
  |  |   75|      0|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 0]
  |  |  ------------------
  ------------------
 5141|      0|    if (data == NULL) {
  ------------------
  |  Branch (5141:9): [True: 0, False: 0]
  ------------------
 5142|      0|        ERROR_MSG("error parsing contextName from scopedPdu");
  ------------------
  |  |  188|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 5143|      0|        return NULL;
 5144|      0|    }
 5145|       |
 5146|      0|    SNMP_FREE(pdu->contextName);
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 5147|      0|    pdu->contextName = netsnmp_memdup_nt(tmp_buf, tmp_buf_len,
 5148|      0|                                         &pdu->contextNameLen);
 5149|      0|    if (pdu->contextName == NULL) {
  ------------------
  |  Branch (5149:9): [True: 0, False: 0]
  ------------------
 5150|      0|        ERROR_MSG("error copying contextName from scopedPdu");
  ------------------
  |  |  188|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 5151|      0|        return NULL;
 5152|      0|    }
 5153|       |
 5154|       |    /*
 5155|       |     * Get the PDU type 
 5156|       |     */
 5157|      0|    asn_len = *length;
 5158|      0|    cp = asn_parse_header(data, &asn_len, &type);
 5159|      0|    if (cp == NULL)
  ------------------
  |  Branch (5159:9): [True: 0, False: 0]
  ------------------
 5160|      0|        return NULL;
 5161|       |
 5162|      0|    pdu->command = type;
 5163|       |
 5164|      0|    return data;
 5165|      0|}
snmp_free_varbind:
 5737|    118|{
 5738|    118|    netsnmp_variable_list *ptr;
 5739|    118|    while (var) {
  ------------------
  |  Branch (5739:12): [True: 0, False: 118]
  ------------------
 5740|      0|        ptr = var->next_variable;
 5741|      0|        snmp_free_var(var);
 5742|      0|        var = ptr;
 5743|      0|    }
 5744|    118|}
snmp_free_pdu:
 5751|    118|{
 5752|    118|    struct snmp_secmod_def *sptr;
 5753|       |
 5754|    118|    if (!pdu)
  ------------------
  |  Branch (5754:9): [True: 0, False: 118]
  ------------------
 5755|      0|        return;
 5756|       |
 5757|    118|    free_securityStateRef(pdu);
 5758|       |
 5759|    118|    sptr = find_sec_mod(pdu->securityModel);
 5760|    118|    if (sptr && sptr->pdu_free)
  ------------------
  |  Branch (5760:9): [True: 2, False: 116]
  |  Branch (5760:17): [True: 0, False: 2]
  ------------------
 5761|      0|        (*sptr->pdu_free)(pdu);
 5762|       |
 5763|    118|    snmp_free_varbind(pdu->variables);
 5764|    118|    free(pdu->enterprise);
 5765|    118|    free(pdu->community);
 5766|    118|    free(pdu->contextEngineID);
 5767|    118|    free(pdu->securityEngineID);
 5768|    118|    free(pdu->contextName);
 5769|    118|    free(pdu->securityName);
 5770|    118|    free(pdu->transport_data);
 5771|    118|    free(pdu);
 5772|    118|}
snmp_create_sess_pdu:
 5777|    118|{
 5778|    118|    netsnmp_pdu *pdu = calloc(1, sizeof(netsnmp_pdu));
 5779|    118|    if (pdu == NULL) {
  ------------------
  |  Branch (5779:9): [True: 0, False: 118]
  ------------------
 5780|      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]
  |  |  ------------------
  ------------------
 5781|      0|        return NULL;
 5782|      0|    }
 5783|       |
 5784|       |    /*
 5785|       |     * Save the transport-level data specific to this reception (e.g. UDP
 5786|       |     * source address).  
 5787|       |     */
 5788|       |
 5789|    118|    pdu->transport_data = opaque;
 5790|    118|    pdu->transport_data_length = olength;
 5791|    118|    pdu->tDomain = transport->domain;
 5792|    118|    pdu->tDomainLen = transport->domain_length;
 5793|    118|    return pdu;
 5794|    118|}
snmp_read:
 6334|     57|{
 6335|     57|    netsnmp_large_fd_set lfdset;
 6336|       |
 6337|       |    netsnmp_large_fd_set_init(&lfdset, FD_SETSIZE);
 6338|     57|    netsnmp_copy_fd_set_to_large_fd_set(&lfdset, fdset);
 6339|     57|    snmp_read2(&lfdset);
 6340|     57|    netsnmp_large_fd_set_cleanup(&lfdset);
 6341|     57|}
snmp_read2:
 6345|     57|{
 6346|     57|    struct session_list *slp, *next;
 6347|       |
 6348|     57|    snmp_res_lock(MT_LIBRARY_ID, MT_LIB_SESSION);
  ------------------
  |  |   79|     57|#define snmp_res_lock(x,y) do {} while (0)
  |  |  ------------------
  |  |  |  Branch (79:41): [Folded, False: 57]
  |  |  ------------------
  ------------------
 6349|    114|    for (slp = Sessions; slp; slp = next) {
  ------------------
  |  Branch (6349:26): [True: 57, False: 57]
  ------------------
 6350|     57|        next = slp->next;
 6351|     57|        if (_sess_packet_deadline_expired(slp->internal)) {
  ------------------
  |  Branch (6351:13): [True: 0, False: 57]
  ------------------
 6352|      0|            _sess_close_stream(slp);
 6353|      0|            continue;
 6354|      0|        }
 6355|     57|        snmp_sess_read2(slp, fdset);
 6356|     57|    }
 6357|     57|    snmp_res_unlock(MT_LIBRARY_ID, MT_LIB_SESSION);
  ------------------
  |  |   80|     57|#define snmp_res_unlock(x,y) do {} while (0)
  |  |  ------------------
  |  |  |  Branch (80:43): [Folded, False: 57]
  |  |  ------------------
  ------------------
 6358|     57|}
_sess_read:
 6858|     57|{
 6859|     57|    netsnmp_transport *transport;
 6860|       |
 6861|     57|    if (!slp || !fdset)
  ------------------
  |  Branch (6861:9): [True: 0, False: 57]
  |  Branch (6861:17): [True: 0, False: 57]
  ------------------
 6862|      0|        return 0;
 6863|       |
 6864|     57|    transport = slp->transport;
 6865|       |
 6866|     57|    if (!transport || !NETSNMP_LARGE_FD_ISSET(transport->sock, fdset)) {
  ------------------
  |  |   50|     57|                    netsnmp_large_fd_is_set(fd, fdset)
  ------------------
  |  Branch (6866:9): [True: 0, False: 57]
  |  Branch (6866:23): [True: 0, False: 57]
  ------------------
 6867|      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]
  |  |  ------------------
  ------------------
 6868|      0|        return 0;
 6869|      0|    }
 6870|       |
 6871|     57|    return __sess_read(slp);
 6872|     57|}
snmp_sess_read2:
 6894|     57|{
 6895|     57|    netsnmp_session *pss;
 6896|     57|    int             rc;
 6897|       |
 6898|     57|    rc = _sess_read(slp, fdset);
 6899|     57|    pss = slp->session;
 6900|     57|    if (rc && pss->s_snmp_errno) {
  ------------------
  |  Branch (6900:9): [True: 19, False: 38]
  |  Branch (6900:15): [True: 19, False: 0]
  ------------------
 6901|     19|        SET_SNMP_ERROR(pss->s_snmp_errno);
  ------------------
  |  |   43|     19|#define SET_SNMP_ERROR(x) snmp_errno=(x)
  ------------------
 6902|     19|    }
 6903|     57|    return rc;
 6904|     57|}
snmp_select_info:
 6969|     57|{
 6970|       |    return snmp_sess_select_info(NULL, numfds, fdset, timeout, block);
 6971|     57|}
snmp_sess_select_info:
 6989|     57|{
 6990|     57|    return snmp_sess_select_info_flags(slp, numfds, fdset, timeout, block,
 6991|     57|                                       NETSNMP_SELECT_NOFLAGS);
  ------------------
  |  |  198|     57|#define NETSNMP_SELECT_NOFLAGS  0x00
  ------------------
 6992|     57|}
snmp_sess_select_info_flags:
 7000|     57|{
 7001|     57|  int rc;
 7002|     57|  netsnmp_large_fd_set lfdset;
 7003|       |
 7004|     57|  netsnmp_large_fd_set_init(&lfdset, FD_SETSIZE);
 7005|     57|  netsnmp_copy_fd_set_to_large_fd_set(&lfdset, fdset);
 7006|     57|  rc = snmp_sess_select_info2_flags(slp, numfds, &lfdset, timeout,
 7007|     57|                                    block, flags);
 7008|     57|  if (netsnmp_copy_large_fd_set_to_fd_set(fdset, &lfdset) < 0) {
  ------------------
  |  Branch (7008:7): [True: 0, False: 57]
  ------------------
 7009|       |      snmp_log(LOG_ERR,
 7010|      0|	     "Use snmp_sess_select_info2() for processing"
 7011|      0|	     " large file descriptors\n");
 7012|      0|  }
 7013|     57|  netsnmp_large_fd_set_cleanup(&lfdset);
 7014|     57|  return rc;
 7015|     57|}
snmp_sess_select_info2_flags:
 7059|     57|{
 7060|     57|    struct session_list *slp, *next = NULL;
 7061|     57|    netsnmp_request_list *rp;
 7062|     57|    struct timeval  now, earliest, alarm_tm;
 7063|     57|    int             active = 0, requests = 0;
 7064|     57|    int             next_alarm = 0;
 7065|     57|    int             has_pending_data = 0;
 7066|     57|    int             packet_deadlines = 0;
 7067|       |
 7068|     57|    timerclear(&earliest);
 7069|       |
 7070|       |    /*
 7071|       |     * For each session examined, add its socket to the fdset,
 7072|       |     * and if it is the earliest timeout to expire, mark it as lowest.
 7073|       |     * If a single session is specified, do just for that session.
 7074|       |     */
 7075|       |
 7076|     57|    DEBUGMSGTL(("sess_select", "for %s session%s: ",
  ------------------
  |  |   66|     57|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     57|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 57]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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:52): [True: 0, False: 0]
  |  |  |  |  |  Branch (164:64): [True: 0, False: 0]
  |  |  |  |  |  Branch (164:64): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 57]
  |  |  ------------------
  ------------------
 7077|     57|                sessp ? "single" : "all", sessp ? "" : "s"));
 7078|       |
 7079|    114|    for (slp = sessp ? sessp : Sessions; slp; slp = next) {
  ------------------
  |  Branch (7079:16): [True: 0, False: 57]
  |  Branch (7079:42): [True: 57, False: 57]
  ------------------
 7080|     57|        next = slp->next;
 7081|       |
 7082|     57|        if (slp->transport == NULL) {
  ------------------
  |  Branch (7082:13): [True: 0, False: 57]
  ------------------
 7083|       |            /*
 7084|       |             * Close in progress -- skip this one.  
 7085|       |             */
 7086|      0|            DEBUGMSG(("sess_select", "skip "));
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 7087|      0|            continue;
 7088|      0|        }
 7089|       |
 7090|     57|        if (!NETSNMP_IS_VALID_SOCKET(slp->transport->sock)) {
  ------------------
  |  |   44|     57|#define NETSNMP_IS_VALID_SOCKET(_sock) ((_sock) != -1)
  ------------------
  |  Branch (7090:13): [True: 0, False: 57]
  ------------------
 7091|       |            /*
 7092|       |             * This session was marked for deletion.  
 7093|       |             */
 7094|      0|            DEBUGMSG(("sess_select", "delete\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]
  |  |  ------------------
  ------------------
 7095|      0|            if (sessp == NULL) {
  ------------------
  |  Branch (7095:17): [True: 0, False: 0]
  ------------------
 7096|      0|                snmp_close(slp->session);
 7097|      0|            } else {
 7098|      0|                snmp_sess_close(slp);
 7099|      0|            }
 7100|      0|            DEBUGMSGTL(("sess_select", "for %s session%s: ",
  ------------------
  |  |   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:52): [True: 0, False: 0]
  |  |  |  |  |  Branch (164:64): [True: 0, False: 0]
  |  |  |  |  |  Branch (164:64): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 7101|      0|                        sessp ? "single" : "all", sessp ? "" : "s"));
 7102|      0|            continue;
 7103|      0|        }
 7104|       |
 7105|     57|        DEBUGMSG(("sess_select", "%" NETSNMP_FMT_SKT " ",
  ------------------
  |  |   61|     57|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  144|     57|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 57]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (61:67): [Folded, False: 57]
  |  |  ------------------
  ------------------
 7106|     57|                  slp->transport->sock));
 7107|     57|        if ((slp->transport->sock + 1) > *numfds) {
  ------------------
  |  Branch (7107:13): [True: 57, False: 0]
  ------------------
 7108|     57|            *numfds = (slp->transport->sock + 1);
 7109|     57|        }
 7110|       |
 7111|     57|        NETSNMP_LARGE_FD_SET(slp->transport->sock, fdset);
  ------------------
  |  |   35|     57|                    netsnmp_large_fd_setfd(fd, fdset)
  ------------------
 7112|     57|        if (slp->transport->f_pending &&
  ------------------
  |  Branch (7112:13): [True: 0, False: 57]
  ------------------
 7113|      0|            slp->transport->f_pending(slp->transport)) {
  ------------------
  |  Branch (7113:13): [True: 0, False: 0]
  ------------------
 7114|      0|            has_pending_data = 1;
 7115|      0|        }
 7116|     57|        if (slp->internal != NULL && slp->internal->requests) {
  ------------------
  |  Branch (7116:13): [True: 57, False: 0]
  |  Branch (7116:38): [True: 0, False: 57]
  ------------------
 7117|       |            /*
 7118|       |             * Found another session with outstanding requests.  
 7119|       |             */
 7120|      0|            requests++;
 7121|      0|            for (rp = slp->internal->requests; rp; rp = rp->next_request) {
  ------------------
  |  Branch (7121:48): [True: 0, False: 0]
  ------------------
 7122|      0|                if (!timerisset(&earliest)
  ------------------
  |  Branch (7122:21): [True: 0, False: 0]
  ------------------
 7123|      0|                    || (timerisset(&rp->expireM)
  ------------------
  |  Branch (7123:25): [True: 0, False: 0]
  ------------------
 7124|      0|                        && timercmp(&rp->expireM, &earliest, <))) {
  ------------------
  |  Branch (7124:28): [True: 0, False: 0]
  |  Branch (7124:28): [True: 0, False: 0]
  ------------------
 7125|      0|                    earliest = rp->expireM;
 7126|      0|                    DEBUGMSG(("verbose:sess_select","(to in %d.%06d sec) ",
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 7127|      0|                               (int)earliest.tv_sec, (int)earliest.tv_usec));
 7128|      0|                }
 7129|      0|            }
 7130|      0|        }
 7131|     57|        if (slp->internal != NULL &&
  ------------------
  |  Branch (7131:13): [True: 57, False: 0]
  ------------------
 7132|     57|            timerisset(&slp->internal->packet_deadline)) {
  ------------------
  |  Branch (7132:13): [True: 57, False: 0]
  ------------------
 7133|      0|            packet_deadlines++;
 7134|      0|            if (!timerisset(&earliest) ||
  ------------------
  |  Branch (7134:17): [True: 0, False: 0]
  ------------------
 7135|      0|                timercmp(&slp->internal->packet_deadline, &earliest, <))
  ------------------
  |  Branch (7135:17): [True: 0, False: 0]
  |  Branch (7135:17): [True: 0, False: 0]
  ------------------
 7136|      0|                earliest = slp->internal->packet_deadline;
 7137|      0|        }
 7138|       |
 7139|     57|        active++;
 7140|     57|        if (sessp) {
  ------------------
  |  Branch (7140:13): [True: 0, False: 57]
  ------------------
 7141|       |            /*
 7142|       |             * Single session processing.  
 7143|       |             */
 7144|      0|            break;
 7145|      0|        }
 7146|     57|    }
 7147|     57|    DEBUGMSG(("sess_select", "\n"));
  ------------------
  |  |   61|     57|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  144|     57|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 57]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (61:67): [Folded, False: 57]
  |  |  ------------------
  ------------------
 7148|       |
 7149|     57|    if (has_pending_data) {
  ------------------
  |  Branch (7149:9): [True: 0, False: 57]
  ------------------
 7150|      0|        DEBUGMSGT(("sess_select",
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 7151|      0|                   "pending transport data present, setting timeout to 0\n"));
 7152|      0|        timerclear(timeout);
 7153|      0|        *block = 0;
 7154|      0|        return active;
 7155|      0|    }
 7156|       |
 7157|     57|    netsnmp_get_monotonic_clock(&now);
 7158|       |
 7159|     57|    if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|     57|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (7159:9): [True: 0, False: 57]
  ------------------
 7160|     57|                               NETSNMP_DS_LIB_ALARM_DONT_USE_SIG) &&
  ------------------
  |  |   71|     57|#define NETSNMP_DS_LIB_ALARM_DONT_USE_SIG  11   /* don't use the alarm() signal */
  ------------------
 7161|      0|        !(flags & NETSNMP_SELECT_NOALARMS)) {
  ------------------
  |  |  199|      0|#define NETSNMP_SELECT_NOALARMS 0x01
  ------------------
  |  Branch (7161:9): [True: 0, False: 0]
  ------------------
 7162|      0|        next_alarm = netsnmp_get_next_alarm_time(&alarm_tm, &now);
 7163|      0|        if (next_alarm)
  ------------------
  |  Branch (7163:13): [True: 0, False: 0]
  ------------------
 7164|      0|            DEBUGMSGT(("sess_select","next alarm at %ld.%06ld sec\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]
  |  |  ------------------
  ------------------
 7165|      0|                       (long)alarm_tm.tv_sec, (long)alarm_tm.tv_usec));
 7166|      0|    }
 7167|     57|    if (next_alarm == 0 && requests == 0 && packet_deadlines == 0) {
  ------------------
  |  Branch (7167:9): [True: 57, False: 0]
  |  Branch (7167:28): [True: 57, False: 0]
  |  Branch (7167:45): [True: 57, False: 0]
  ------------------
 7168|       |        /*
 7169|       |         * If none are active, skip arithmetic.  
 7170|       |         */
 7171|     57|        DEBUGMSGT(("sess_select","blocking:no session requests or alarms.\n"));
  ------------------
  |  |   62|     57|#define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     57|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 57]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 57]
  |  |  ------------------
  ------------------
 7172|     57|        *block = 1; /* can block - timeout value is undefined if no requests */
 7173|     57|        return active;
 7174|     57|    }
 7175|       |
 7176|      0|    if (next_alarm &&
  ------------------
  |  Branch (7176:9): [True: 0, False: 0]
  ------------------
 7177|      0|        (!timerisset(&earliest) || timercmp(&alarm_tm, &earliest, <)))
  ------------------
  |  Branch (7177:10): [True: 0, False: 0]
  |  Branch (7177:36): [True: 0, False: 0]
  |  Branch (7177:36): [True: 0, False: 0]
  ------------------
 7178|      0|        earliest = alarm_tm;
 7179|       |
 7180|      0|    NETSNMP_TIMERSUB(&earliest, &now, &earliest);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
 7181|      0|    if (earliest.tv_sec < 0) {
  ------------------
  |  Branch (7181:9): [True: 0, False: 0]
  ------------------
 7182|      0|        time_t overdue_ms = -(earliest.tv_sec * 1000 + earliest.tv_usec / 1000);
 7183|      0|        if (overdue_ms >= 10)
  ------------------
  |  Branch (7183:13): [True: 0, False: 0]
  ------------------
 7184|      0|            DEBUGMSGT(("verbose:sess_select","timer overdue by %ld ms\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]
  |  |  ------------------
  ------------------
 7185|      0|                       (long) overdue_ms));
 7186|      0|        timerclear(&earliest);
 7187|      0|    } else {
 7188|      0|        DEBUGMSGT(("verbose:sess_select","timer due in %d.%06d sec\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]
  |  |  ------------------
  ------------------
 7189|      0|                   (int)earliest.tv_sec, (int)earliest.tv_usec));
 7190|      0|    }
 7191|       |
 7192|       |    /*
 7193|       |     * if it was blocking before or our delta time is less, reset timeout 
 7194|       |     */
 7195|      0|    if ((*block || (timercmp(&earliest, timeout, <)))) {
  ------------------
  |  Branch (7195:10): [True: 0, False: 0]
  |  Branch (7195:20): [True: 0, False: 0]
  |  Branch (7195:21): [True: 0, False: 0]
  ------------------
 7196|      0|        DEBUGMSGT(("verbose:sess_select",
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 7197|      0|                   "setting timer to %d.%06d sec, clear block (was %d)\n",
 7198|      0|                   (int)earliest.tv_sec, (int)earliest.tv_usec, *block));
 7199|      0|        *timeout = earliest;
 7200|      0|        *block = 0;
 7201|      0|    }
 7202|      0|    return active;
 7203|     57|}
snmp_oid_compare:
 7391|    348|{
 7392|    348|    register int    len;
 7393|    348|    register const oid *name1 = in_name1;
 7394|    348|    register const oid *name2 = in_name2;
 7395|       |
 7396|       |    /*
 7397|       |     * len = minimum of len1 and len2 
 7398|       |     */
 7399|    348|    if (len1 < len2)
  ------------------
  |  Branch (7399:9): [True: 0, False: 348]
  ------------------
 7400|      0|        len = len1;
 7401|    348|    else
 7402|    348|        len = len2;
 7403|       |    /*
 7404|       |     * find first non-matching OID 
 7405|       |     */
 7406|  3.59k|    while (len-- > 0) {
  ------------------
  |  Branch (7406:12): [True: 3.48k, False: 116]
  ------------------
 7407|       |        /*
 7408|       |         * these must be done in separate comparisons, since
 7409|       |         * subtracting them and using that result has problems with
 7410|       |         * subids > 2^31. 
 7411|       |         */
 7412|  3.48k|        if (*(name1) != *(name2)) {
  ------------------
  |  Branch (7412:13): [True: 232, False: 3.24k]
  ------------------
 7413|    232|            if (*(name1) < *(name2))
  ------------------
  |  Branch (7413:17): [True: 116, False: 116]
  ------------------
 7414|    116|                return -1;
 7415|    116|            return 1;
 7416|    232|        }
 7417|  3.24k|        name1++;
 7418|  3.24k|        name2++;
 7419|  3.24k|    }
 7420|       |    /*
 7421|       |     * both OIDs equal up to length of shorter OID 
 7422|       |     */
 7423|    116|    if (len1 < len2)
  ------------------
  |  Branch (7423:9): [True: 0, False: 116]
  ------------------
 7424|      0|        return -1;
 7425|    116|    if (len2 < len1)
  ------------------
  |  Branch (7425:9): [True: 0, False: 116]
  ------------------
 7426|      0|        return 1;
 7427|    116|    return 0;
 7428|    116|}
netsnmp_oid_equals:
 7528|  3.20k|{
 7529|  3.20k|    register const oid *name1 = in_name1;
 7530|  3.20k|    register const oid *name2 = in_name2;
 7531|  3.20k|    register int    len = len1;
 7532|       |
 7533|       |    /*
 7534|       |     * len = minimum of len1 and len2 
 7535|       |     */
 7536|  3.20k|    if (len1 != len2)
  ------------------
  |  Branch (7536:9): [True: 2.21k, False: 991]
  ------------------
 7537|  2.21k|        return 1;
 7538|       |    /*
 7539|       |     * Handle 'null' OIDs
 7540|       |     */
 7541|    991|    if (len1 == 0)
  ------------------
  |  Branch (7541:9): [True: 0, False: 991]
  ------------------
 7542|      0|        return 0;   /* Two null OIDs are (trivially) the same */
 7543|    991|    if (!name1 || !name2)
  ------------------
  |  Branch (7543:9): [True: 0, False: 991]
  |  Branch (7543:19): [True: 0, False: 991]
  ------------------
 7544|      0|        return 1;   /* Otherwise something's wrong, so report a non-match */
 7545|       |    /*
 7546|       |     * find first non-matching OID 
 7547|       |     */
 7548|  8.28k|    while (len-- > 0) {
  ------------------
  |  Branch (7548:12): [True: 8.28k, False: 0]
  ------------------
 7549|       |        /*
 7550|       |         * these must be done in separate comparisons, since
 7551|       |         * subtracting them and using that result has problems with
 7552|       |         * subids > 2^31. 
 7553|       |         */
 7554|  8.28k|        if (*(name1++) != *(name2++))
  ------------------
  |  Branch (7554:13): [True: 991, False: 7.29k]
  ------------------
 7555|    991|            return 1;
 7556|  8.28k|    }
 7557|      0|    return 0;
 7558|    991|}
snmp_duplicate_objid:
 8395|    348|{
 8396|    348|    oid            *returnOid;
 8397|    348|    if (objToCopy != NULL && objToCopyLen != 0) {
  ------------------
  |  Branch (8397:9): [True: 348, False: 0]
  |  Branch (8397:30): [True: 348, False: 0]
  ------------------
 8398|    348|        returnOid = (oid *) malloc(objToCopyLen * sizeof(oid));
 8399|    348|        if (returnOid) {
  ------------------
  |  Branch (8399:13): [True: 348, False: 0]
  ------------------
 8400|    348|            memcpy(returnOid, objToCopy, objToCopyLen * sizeof(oid));
 8401|    348|        }
 8402|    348|    } else
 8403|      0|        returnOid = NULL;
 8404|    348|    return returnOid;
 8405|    348|}
snmp_increment_statistic:
 8415|    118|{
 8416|    118|    if (which >= 0 && which < NETSNMP_STAT_MAX_STATS) {
  ------------------
  |  |  710|    118|#define  NETSNMP_STAT_MAX_STATS              (STAT_TLSTM_STATS_END+1)
  |  |  ------------------
  |  |  |  |  706|    118|#define  STAT_TLSTM_STATS_END          STAT_TLSTM_SNMPTLSTMSESSIONINVALIDCACHES
  |  |  |  |  ------------------
  |  |  |  |  |  |  703|    118|#define  STAT_TLSTM_SNMPTLSTMSESSIONINVALIDCACHES              56
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (8416:9): [True: 118, False: 0]
  |  Branch (8416:23): [True: 118, False: 0]
  ------------------
 8417|    118|        statistics[which]++;
 8418|    118|        return statistics[which];
 8419|    118|    }
 8420|      0|    return 0;
 8421|    118|}
snmp_init_statistics:
 8443|     58|{
 8444|     58|    memset(statistics, 0, sizeof(statistics));
 8445|     58|}
snmp_api.c:_init_snmp:
  710|    174|{
  711|       |
  712|    174|    struct timeval  tv;
  713|    174|    long            tmpReqid, tmpMsgid;
  714|       |
  715|    174|    if (_init_snmp_init_done)
  ------------------
  |  Branch (715:9): [True: 116, False: 58]
  ------------------
  716|    116|        return;
  717|     58|    _init_snmp_init_done = 1;
  718|     58|    Reqid = 1;
  719|       |
  720|     58|    snmp_res_init();            /* initialize the mt locking structures */
  ------------------
  |  |   78|     58|#define snmp_res_init() do {} while (0)
  |  |  ------------------
  |  |  |  Branch (78:38): [Folded, False: 58]
  |  |  ------------------
  ------------------
  721|     58|#ifndef NETSNMP_DISABLE_MIB_LOADING
  722|     58|    netsnmp_init_mib_internals();
  723|     58|#endif /* NETSNMP_DISABLE_MIB_LOADING */
  724|     58|    netsnmp_tdomain_init();
  725|       |
  726|     58|    gettimeofday(&tv, (struct timezone *) 0);
  727|       |    /*
  728|       |     * Now = tv;
  729|       |     */
  730|       |
  731|       |    /*
  732|       |     * get pseudo-random values for request ID and message ID 
  733|       |     */
  734|     58|    netsnmp_srandom((unsigned)(tv.tv_sec ^ tv.tv_usec));
  735|     58|    tmpReqid = netsnmp_random();
  736|     58|    tmpMsgid = netsnmp_random();
  737|       |
  738|       |    /*
  739|       |     * don't allow zero value to repeat init 
  740|       |     */
  741|     58|    if (tmpReqid == 0)
  ------------------
  |  Branch (741:9): [True: 0, False: 58]
  ------------------
  742|      0|        tmpReqid = 1;
  743|     58|    if (tmpMsgid == 0)
  ------------------
  |  Branch (743:9): [True: 0, False: 58]
  ------------------
  744|      0|        tmpMsgid = 1;
  745|     58|    Reqid = tmpReqid;
  746|     58|    Msgid = tmpMsgid;
  747|       |
  748|     58|    netsnmp_register_default_domain("snmp", "udp udp6");
  749|     58|    netsnmp_register_default_domain("snmptrap", "udp udp6");
  750|       |
  751|     58|    netsnmp_register_default_target("snmp", "udp", ":161");
  752|     58|    netsnmp_register_default_target("snmp", "tcp", ":161");
  753|     58|    netsnmp_register_default_target("snmp", "udp6", ":161");
  754|     58|    netsnmp_register_default_target("snmp", "tcp6", ":161");
  755|     58|    netsnmp_register_default_target("snmp", "dtlsudp", ":10161");
  756|     58|    netsnmp_register_default_target("snmp", "tlstcp", ":10161");
  757|     58|    netsnmp_register_default_target("snmp", "ipx", "/36879");
  758|       |
  759|     58|    netsnmp_register_default_target("snmptrap", "udp", ":162");
  760|     58|    netsnmp_register_default_target("snmptrap", "tcp", ":162");
  761|     58|    netsnmp_register_default_target("snmptrap", "udp6", ":162");
  762|     58|    netsnmp_register_default_target("snmptrap", "tcp6", ":162");
  763|     58|    netsnmp_register_default_target("snmptrap", "dtlsudp", ":10162");
  764|     58|    netsnmp_register_default_target("snmptrap", "tlstcp", ":10162");
  765|     58|    netsnmp_register_default_target("snmptrap", "ipx", "/36880");
  766|       |
  767|     58|    netsnmp_ds_set_int(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  768|     58|                       NETSNMP_DS_LIB_HEX_OUTPUT_LENGTH, 16);
  ------------------
  |  |  121|     58|#define NETSNMP_DS_LIB_HEX_OUTPUT_LENGTH    6
  ------------------
  769|     58|    netsnmp_ds_set_int(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_RETRIES,
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                  netsnmp_ds_set_int(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_RETRIES,
  ------------------
  |  |  131|     58|#define NETSNMP_DS_LIB_RETRIES             15
  ------------------
  770|     58|                       DEFAULT_RETRIES);
  ------------------
  |  |  191|     58|#define DEFAULT_RETRIES	    5
  ------------------
  771|     58|    netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  772|     58|			   NETSNMP_DS_LIB_MIB_ERRORS, 1);
  ------------------
  |  |   59|     58|#define NETSNMP_DS_LIB_MIB_ERRORS          0
  ------------------
  773|       |
  774|     58|#ifdef NETSNMP_USE_REVERSE_ASNENCODING
  775|     58|    netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  776|     58|			   NETSNMP_DS_LIB_REVERSE_ENCODE,
  ------------------
  |  |   80|     58|#define NETSNMP_DS_LIB_REVERSE_ENCODE      20   /* encode packets from back to front */
  ------------------
  777|     58|			   NETSNMP_DEFAULT_ASNENCODING_DIRECTION);
  ------------------
  |  | 2027|     58|#define NETSNMP_DEFAULT_ASNENCODING_DIRECTION 1 /* 1 = reverse, 0 = forwards */
  ------------------
  778|     58|#endif
  779|     58|}
snmp_api.c:register_default_handlers:
  808|     58|{
  809|     58|    netsnmp_ds_register_config(ASN_BOOLEAN, "snmp", "dumpPacket",
  ------------------
  |  |   72|     58|#define ASN_BOOLEAN	    0x01U
  ------------------
  810|     58|		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DUMP_PACKET);
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DUMP_PACKET);
  ------------------
  |  |   63|     58|#define NETSNMP_DS_LIB_DUMP_PACKET         4
  ------------------
  811|     58|    netsnmp_ds_register_config(ASN_BOOLEAN, "snmp", "reverseEncodeBER",
  ------------------
  |  |   72|     58|#define ASN_BOOLEAN	    0x01U
  ------------------
  812|     58|		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_REVERSE_ENCODE);
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_REVERSE_ENCODE);
  ------------------
  |  |   80|     58|#define NETSNMP_DS_LIB_REVERSE_ENCODE      20   /* encode packets from back to front */
  ------------------
  813|     58|    netsnmp_ds_register_config(ASN_INTEGER, "snmp", "defaultPort",
  ------------------
  |  |   75|     58|#define ASN_INTEGER	    0x02U
  ------------------
  814|     58|		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DEFAULT_PORT);
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DEFAULT_PORT);
  ------------------
  |  |  117|     58|#define NETSNMP_DS_LIB_DEFAULT_PORT         3
  ------------------
  815|     58|#ifndef NETSNMP_FEATURE_REMOVE_RUNTIME_DISABLE_VERSION
  816|     58|    netsnmp_ds_register_config(ASN_BOOLEAN, "snmp", "disableSNMPv3",
  ------------------
  |  |   72|     58|#define ASN_BOOLEAN	    0x01U
  ------------------
  817|     58|                      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DISABLE_V3);
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                    NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DISABLE_V3);
  ------------------
  |  |  105|     58|#define NETSNMP_DS_LIB_DISABLE_V3          45 /* disable SNMPv3 */
  ------------------
  818|     58|#endif /* NETSNMP_FEATURE_REMOVE_RUNTIME_DISABLE_VERSION */
  819|     58|#if !defined(NETSNMP_DISABLE_SNMPV1) || !defined(NETSNMP_DISABLE_SNMPV2C)
  820|     58|#ifndef NETSNMP_FEATURE_REMOVE_RUNTIME_DISABLE_VERSION
  821|     58|#if !defined(NETSNMP_DISABLE_SNMPV1)
  822|     58|    netsnmp_ds_register_config(ASN_BOOLEAN, "snmp", "disableSNMPv1",
  ------------------
  |  |   72|     58|#define ASN_BOOLEAN	    0x01U
  ------------------
  823|     58|                      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DISABLE_V1);
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                    NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DISABLE_V1);
  ------------------
  |  |  103|     58|#define NETSNMP_DS_LIB_DISABLE_V1          43 /* disable SNMPv1 */
  ------------------
  824|     58|#endif
  825|     58|#if !defined(NETSNMP_DISABLE_SNMPV2C)
  826|     58|    netsnmp_ds_register_config(ASN_BOOLEAN, "snmp", "disableSNMPv2c",
  ------------------
  |  |   72|     58|#define ASN_BOOLEAN	    0x01U
  ------------------
  827|     58|                      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DISABLE_V2c);
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                    NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DISABLE_V2c);
  ------------------
  |  |  104|     58|#define NETSNMP_DS_LIB_DISABLE_V2c         44 /* disable SNMPv2c */
  ------------------
  828|     58|#endif
  829|     58|#endif /* NETSNMP_FEATURE_REMOVE_RUNTIME_DISABLE_VERSION */
  830|     58|    netsnmp_ds_register_config(ASN_OCTET_STR, "snmp", "defCommunity",
  ------------------
  |  |   78|     58|#define ASN_OCTET_STR	    0x04U
  ------------------
  831|     58|                      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_COMMUNITY);
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                    NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_COMMUNITY);
  ------------------
  |  |  158|     58|#define NETSNMP_DS_LIB_COMMUNITY         7
  ------------------
  832|     58|#endif /* !defined(NETSNMP_DISABLE_SNMPV1) || !defined(NETSNMP_DISABLE_SNMPV2C) */
  833|     58|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "noTokenWarnings",
  ------------------
  |  |   72|     58|#define ASN_BOOLEAN	    0x01U
  ------------------
  834|     58|                      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_NO_TOKEN_WARNINGS);
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                    NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_NO_TOKEN_WARNINGS);
  ------------------
  |  |   77|     58|#define NETSNMP_DS_LIB_NO_TOKEN_WARNINGS   17   /* no warn about unknown config tokens */
  ------------------
  835|     58|    netsnmp_ds_register_config(ASN_BOOLEAN, "snmp", "noRangeCheck",
  ------------------
  |  |   72|     58|#define ASN_BOOLEAN	    0x01U
  ------------------
  836|     58|		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DONT_CHECK_RANGE);
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DONT_CHECK_RANGE);
  ------------------
  |  |   76|     58|#define NETSNMP_DS_LIB_DONT_CHECK_RANGE    16   /* don't check values for ranges on send */
  ------------------
  837|     58|    netsnmp_ds_register_premib(ASN_OCTET_STR, "snmp", "persistentDir",
  ------------------
  |  |   78|     58|#define ASN_OCTET_STR	    0x04U
  ------------------
  838|     58|	              NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_PERSISTENT_DIR);
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              	              NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_PERSISTENT_DIR);
  ------------------
  |  |  159|     58|#define NETSNMP_DS_LIB_PERSISTENT_DIR    8
  ------------------
  839|     58|    netsnmp_ds_register_config(ASN_OCTET_STR, "snmp", "tempFilePattern",
  ------------------
  |  |   78|     58|#define ASN_OCTET_STR	    0x04U
  ------------------
  840|     58|	              NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_TEMP_FILE_PATTERN);
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              	              NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_TEMP_FILE_PATTERN);
  ------------------
  |  |  166|     58|#define NETSNMP_DS_LIB_TEMP_FILE_PATTERN 15
  ------------------
  841|     58|    netsnmp_ds_register_config(ASN_BOOLEAN, "snmp", "noDisplayHint",
  ------------------
  |  |   72|     58|#define ASN_BOOLEAN	    0x01U
  ------------------
  842|     58|	              NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_NO_DISPLAY_HINT);
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              	              NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_NO_DISPLAY_HINT);
  ------------------
  |  |   90|     58|#define NETSNMP_DS_LIB_NO_DISPLAY_HINT     30 /* don't apply DISPLAY-HINTs */
  ------------------
  843|     58|    netsnmp_ds_register_config(ASN_BOOLEAN, "snmp", "16bitIDs",
  ------------------
  |  |   72|     58|#define ASN_BOOLEAN	    0x01U
  ------------------
  844|     58|	              NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_16BIT_IDS);
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              	              NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_16BIT_IDS);
  ------------------
  |  |   91|     58|#define NETSNMP_DS_LIB_16BIT_IDS           31   /* restrict requestIDs, etc to 16-bit values */
  ------------------
  845|     58|    netsnmp_ds_register_premib(ASN_OCTET_STR, "snmp", "clientaddr",
  ------------------
  |  |   78|     58|#define ASN_OCTET_STR	    0x04U
  ------------------
  846|     58|                      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_CLIENT_ADDR);
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                    NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_CLIENT_ADDR);
  ------------------
  |  |  165|     58|#define NETSNMP_DS_LIB_CLIENT_ADDR       14
  ------------------
  847|     58|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "clientaddrUsesPort",
  ------------------
  |  |   72|     58|#define ASN_BOOLEAN	    0x01U
  ------------------
  848|     58|                      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_CLIENT_ADDR_USES_PORT);
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                    NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_CLIENT_ADDR_USES_PORT);
  ------------------
  |  |  102|     58|#define NETSNMP_DS_LIB_CLIENT_ADDR_USES_PORT 42 /* NETSNMP_DS_LIB_CLIENT_ADDR includes address and also port */
  ------------------
  849|     58|    netsnmp_ds_register_config(ASN_INTEGER, "snmp", "serverSendBuf",
  ------------------
  |  |   75|     58|#define ASN_INTEGER	    0x02U
  ------------------
  850|     58|		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_SERVERSENDBUF);
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_SERVERSENDBUF);
  ------------------
  |  |  122|     58|#define NETSNMP_DS_LIB_SERVERSENDBUF        7 /* send buffer (server) */
  ------------------
  851|     58|    netsnmp_ds_register_config(ASN_INTEGER, "snmp", "serverRecvBuf",
  ------------------
  |  |   75|     58|#define ASN_INTEGER	    0x02U
  ------------------
  852|     58|		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_SERVERRECVBUF);
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_SERVERRECVBUF);
  ------------------
  |  |  123|     58|#define NETSNMP_DS_LIB_SERVERRECVBUF        8 /* receive buffer (server) */
  ------------------
  853|     58|    netsnmp_ds_register_config(ASN_INTEGER, "snmp", "clientSendBuf",
  ------------------
  |  |   75|     58|#define ASN_INTEGER	    0x02U
  ------------------
  854|     58|		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_CLIENTSENDBUF);
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_CLIENTSENDBUF);
  ------------------
  |  |  124|     58|#define NETSNMP_DS_LIB_CLIENTSENDBUF        9 /* send buffer (client) */
  ------------------
  855|     58|    netsnmp_ds_register_config(ASN_INTEGER, "snmp", "clientRecvBuf",
  ------------------
  |  |   75|     58|#define ASN_INTEGER	    0x02U
  ------------------
  856|     58|		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_CLIENTRECVBUF);
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_CLIENTRECVBUF);
  ------------------
  |  |  125|     58|#define NETSNMP_DS_LIB_CLIENTRECVBUF       10 /* receive buffer (client) */
  ------------------
  857|     58|    netsnmp_ds_register_config(ASN_INTEGER, "snmp", "sendMessageMaxSize",
  ------------------
  |  |   75|     58|#define ASN_INTEGER	    0x02U
  ------------------
  858|     58|                               NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  859|     58|                               NETSNMP_DS_LIB_MSG_SEND_MAX);
  ------------------
  |  |  132|     58|#define NETSNMP_DS_LIB_MSG_SEND_MAX        16 /* global max response size */
  ------------------
  860|     58|    netsnmp_ds_register_config(ASN_BOOLEAN, "snmp", "noPersistentLoad",
  ------------------
  |  |   72|     58|#define ASN_BOOLEAN	    0x01U
  ------------------
  861|     58|		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DISABLE_PERSISTENT_LOAD);
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DISABLE_PERSISTENT_LOAD);
  ------------------
  |  |   95|     58|#define NETSNMP_DS_LIB_DISABLE_PERSISTENT_LOAD  35 /* don't load persistent file */
  ------------------
  862|     58|    netsnmp_ds_register_config(ASN_BOOLEAN, "snmp", "noPersistentSave",
  ------------------
  |  |   72|     58|#define ASN_BOOLEAN	    0x01U
  ------------------
  863|     58|		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DISABLE_PERSISTENT_SAVE);
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DISABLE_PERSISTENT_SAVE);
  ------------------
  |  |   96|     58|#define NETSNMP_DS_LIB_DISABLE_PERSISTENT_SAVE  36 /* don't save persistent file */
  ------------------
  864|     58|    netsnmp_ds_register_config(ASN_BOOLEAN, "snmp",
  ------------------
  |  |   72|     58|#define ASN_BOOLEAN	    0x01U
  ------------------
  865|     58|                               "noContextEngineIDDiscovery",
  866|     58|                               NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  867|     58|                               NETSNMP_DS_LIB_NO_DISCOVERY);
  ------------------
  |  |   98|     58|#define NETSNMP_DS_LIB_NO_DISCOVERY        38 /* don't support RFC5343 contextEngineID discovery */
  ------------------
  868|     58|    netsnmp_ds_register_config(ASN_INTEGER, "snmp", "timeout",
  ------------------
  |  |   75|     58|#define ASN_INTEGER	    0x02U
  ------------------
  869|     58|		               NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_TIMEOUT);
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              		               NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_TIMEOUT);
  ------------------
  |  |  130|     58|#define NETSNMP_DS_LIB_TIMEOUT             14
  ------------------
  870|     58|    netsnmp_ds_register_config(ASN_INTEGER, "snmp", "retries",
  ------------------
  |  |   75|     58|#define ASN_INTEGER	    0x02U
  ------------------
  871|     58|		               NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_RETRIES);
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              		               NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_RETRIES);
  ------------------
  |  |  131|     58|#define NETSNMP_DS_LIB_RETRIES             15
  ------------------
  872|     58|    netsnmp_ds_register_config(ASN_OCTET_STR, "snmp", "outputPrecision",
  ------------------
  |  |   78|     58|#define ASN_OCTET_STR	    0x04U
  ------------------
  873|     58|                               NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_OUTPUT_PRECISION);
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                             NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_OUTPUT_PRECISION);
  ------------------
  |  |  186|     58|#define NETSNMP_DS_LIB_OUTPUT_PRECISION  35
  ------------------
  874|       |
  875|       |
  876|     58|    netsnmp_register_service_handlers();
  877|     58|}
snmp_api.c:snmp_sess_copy:
 1403|     58|{
 1404|     58|    struct session_list *psl;
 1405|     58|    psl = _sess_copy(pss);
 1406|     58|    if (!psl) {
  ------------------
  |  Branch (1406:9): [True: 0, False: 58]
  ------------------
 1407|      0|        if (!pss->s_snmp_errno) {
  ------------------
  |  Branch (1407:13): [True: 0, False: 0]
  ------------------
 1408|      0|            pss->s_snmp_errno = SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
 1409|      0|        }
 1410|      0|        SET_SNMP_ERROR(pss->s_snmp_errno);
  ------------------
  |  |   43|      0|#define SET_SNMP_ERROR(x) snmp_errno=(x)
  ------------------
 1411|      0|    }
 1412|     58|    return psl;
 1413|     58|}
snmp_api.c:_sess_copy:
 1107|     58|{
 1108|     58|    struct session_list *slp;
 1109|     58|    struct snmp_internal_session *isp;
 1110|     58|    netsnmp_session *session;
 1111|     58|    struct snmp_secmod_def *sptr;
 1112|     58|    char           *cp;
 1113|     58|    u_char         *ucp;
 1114|       |
 1115|     58|    in_session->s_snmp_errno = 0;
 1116|     58|    in_session->s_errno = 0;
 1117|       |
 1118|       |    /*
 1119|       |     * Copy session structure and link into list 
 1120|       |     */
 1121|     58|    slp = calloc(1, sizeof(struct session_list));
 1122|     58|    if (slp == NULL) {
  ------------------
  |  Branch (1122:9): [True: 0, False: 58]
  ------------------
 1123|      0|        in_session->s_snmp_errno = SNMPERR_MALLOC;
  ------------------
  |  |  246|      0|#define SNMPERR_MALLOC			(-62)
  ------------------
 1124|      0|        return (NULL);
 1125|      0|    }
 1126|       |
 1127|     58|    slp->transport = NULL;
 1128|       |
 1129|     58|    isp = calloc(1, sizeof(struct snmp_internal_session));
 1130|       |
 1131|     58|    if (isp == NULL) {
  ------------------
  |  Branch (1131:9): [True: 0, False: 58]
  ------------------
 1132|      0|        snmp_sess_close(slp);
 1133|      0|        in_session->s_snmp_errno = SNMPERR_MALLOC;
  ------------------
  |  |  246|      0|#define SNMPERR_MALLOC			(-62)
  ------------------
 1134|      0|        return (NULL);
 1135|      0|    }
 1136|       |
 1137|     58|    slp->internal = isp;
 1138|     58|    slp->session = netsnmp_memdup(in_session, sizeof(netsnmp_session));
 1139|     58|    if (slp->session == NULL) {
  ------------------
  |  Branch (1139:9): [True: 0, False: 58]
  ------------------
 1140|      0|        snmp_sess_close(slp);
 1141|      0|        in_session->s_snmp_errno = SNMPERR_MALLOC;
  ------------------
  |  |  246|      0|#define SNMPERR_MALLOC			(-62)
  ------------------
 1142|      0|        return (NULL);
 1143|      0|    }
 1144|     58|    session = slp->session;
 1145|       |
 1146|       |    /*
 1147|       |     * zero out pointers so if we have to free the session we wont free mem
 1148|       |     * owned by in_session 
 1149|       |     */
 1150|     58|    session->localname = NULL;
 1151|     58|    session->peername = NULL;
 1152|     58|    session->community = NULL;
 1153|     58|    session->contextEngineID = NULL;
 1154|     58|    session->contextName = NULL;
 1155|     58|    session->securityEngineID = NULL;
 1156|     58|    session->securityName = NULL;
 1157|     58|    session->securityAuthProto = NULL;
 1158|     58|    session->securityAuthLocalKey = NULL;
 1159|     58|    session->securityPrivProto = NULL;
 1160|     58|    session->securityPrivLocalKey = NULL;
 1161|     58|    session->sessUser = NULL;
 1162|     58|    session->paramName = NULL;
 1163|     58|#ifndef NETSNMP_NO_TRAP_STATS
 1164|     58|    session->trap_stats = NULL;
 1165|     58|#endif
 1166|       |    /*
 1167|       |     * session now points to the new structure that still contains pointers to
 1168|       |     * data allocated elsewhere.  Some of this data is copied to space malloc'd
 1169|       |     * here, and the pointer replaced with the new one.
 1170|       |     */
 1171|       |
 1172|     58|    if (in_session->peername != NULL) {
  ------------------
  |  Branch (1172:9): [True: 0, False: 58]
  ------------------
 1173|      0|        session->peername =
 1174|      0|            netsnmp_strdup_and_null((u_char*)in_session->peername,
 1175|      0|                                    strlen(in_session->peername));
 1176|      0|        if (session->peername == NULL) {
  ------------------
  |  Branch (1176:13): [True: 0, False: 0]
  ------------------
 1177|      0|            snmp_sess_close(slp);
 1178|      0|            in_session->s_snmp_errno = SNMPERR_MALLOC;
  ------------------
  |  |  246|      0|#define SNMPERR_MALLOC			(-62)
  ------------------
 1179|      0|            return (NULL);
 1180|      0|        }
 1181|      0|    }
 1182|       |
 1183|       |    /*
 1184|       |     * Fill in defaults if necessary 
 1185|       |     */
 1186|     58|#if !defined(NETSNMP_DISABLE_SNMPV1) || !defined(NETSNMP_DISABLE_SNMPV2C)
 1187|     58|    if (in_session->community_len != SNMP_DEFAULT_COMMUNITY_LEN) {
  ------------------
  |  |   78|     58|#define SNMP_DEFAULT_COMMUNITY_LEN  0   /* to get a default community name */
  ------------------
  |  Branch (1187:9): [True: 0, False: 58]
  ------------------
 1188|      0|        ucp = netsnmp_memdup(in_session->community, in_session->community_len);
 1189|     58|    } else {
 1190|     58|        if ((cp = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (1190:13): [True: 0, False: 58]
  ------------------
 1191|     58|					NETSNMP_DS_LIB_COMMUNITY)) != NULL) {
  ------------------
  |  |  158|     58|#define NETSNMP_DS_LIB_COMMUNITY         7
  ------------------
 1192|      0|            session->community_len = strlen(cp);
 1193|      0|            ucp = (u_char *) strdup(cp);
 1194|     58|        } else {
 1195|       |#ifdef NETSNMP_NO_ZEROLENGTH_COMMUNITY
 1196|       |            session->community_len = strlen(DEFAULT_COMMUNITY);
 1197|       |            ucp = netsnmp_memdup(DEFAULT_COMMUNITY, session->community_len);
 1198|       |#else
 1199|     58|            ucp = (u_char *) strdup("");
 1200|     58|#endif
 1201|     58|        }
 1202|     58|    }
 1203|       |
 1204|     58|    if (ucp == NULL) {
  ------------------
  |  Branch (1204:9): [True: 0, False: 58]
  ------------------
 1205|      0|        snmp_sess_close(slp);
 1206|      0|        in_session->s_snmp_errno = SNMPERR_MALLOC;
  ------------------
  |  |  246|      0|#define SNMPERR_MALLOC			(-62)
  ------------------
 1207|      0|        return (NULL);
 1208|      0|    }
 1209|     58|    session->community = ucp;   /* replace pointer with pointer to new data */
 1210|     58|#endif
 1211|       |
 1212|     58|    if (session->securityLevel <= 0) {
  ------------------
  |  Branch (1212:9): [True: 58, False: 0]
  ------------------
 1213|     58|        session->securityLevel =
 1214|     58|            netsnmp_ds_get_int(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_SECLEVEL);
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                          netsnmp_ds_get_int(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_SECLEVEL);
  ------------------
  |  |  115|     58|#define NETSNMP_DS_LIB_SECLEVEL             1
  ------------------
 1215|     58|    }
 1216|       |
 1217|     58|    if (in_session->securityEngineIDLen > 0) {
  ------------------
  |  Branch (1217:9): [True: 0, False: 58]
  ------------------
 1218|      0|        ucp = netsnmp_memdup(in_session->securityEngineID,
 1219|      0|                             in_session->securityEngineIDLen);
 1220|      0|        if (ucp == NULL) {
  ------------------
  |  Branch (1220:13): [True: 0, False: 0]
  ------------------
 1221|      0|            snmp_sess_close(slp);
 1222|      0|            in_session->s_snmp_errno = SNMPERR_MALLOC;
  ------------------
  |  |  246|      0|#define SNMPERR_MALLOC			(-62)
  ------------------
 1223|      0|            return (NULL);
 1224|      0|        }
 1225|      0|        session->securityEngineID = ucp;
 1226|      0|        session->securityEngineIDLen = in_session->securityEngineIDLen;
 1227|      0|    }
 1228|       |
 1229|     58|    if (in_session->contextEngineIDLen > 0) {
  ------------------
  |  Branch (1229:9): [True: 0, False: 58]
  ------------------
 1230|      0|        ucp = netsnmp_memdup(in_session->contextEngineID,
 1231|      0|                             in_session->contextEngineIDLen);
 1232|      0|        if (ucp == NULL) {
  ------------------
  |  Branch (1232:13): [True: 0, False: 0]
  ------------------
 1233|      0|            snmp_sess_close(slp);
 1234|      0|            in_session->s_snmp_errno = SNMPERR_MALLOC;
  ------------------
  |  |  246|      0|#define SNMPERR_MALLOC			(-62)
  ------------------
 1235|      0|            return (NULL);
 1236|      0|        }
 1237|      0|        session->contextEngineID = ucp;
 1238|      0|        session->contextEngineIDLen = in_session->contextEngineIDLen;
 1239|     58|    } else if (in_session->securityEngineIDLen > 0) {
  ------------------
  |  Branch (1239:16): [True: 0, False: 58]
  ------------------
 1240|       |        /*
 1241|       |         * default contextEngineID to securityEngineIDLen if defined 
 1242|       |         */
 1243|      0|        ucp = netsnmp_memdup(in_session->securityEngineID,
 1244|      0|                             in_session->securityEngineIDLen);
 1245|      0|        if (ucp == NULL) {
  ------------------
  |  Branch (1245:13): [True: 0, False: 0]
  ------------------
 1246|      0|            snmp_sess_close(slp);
 1247|      0|            in_session->s_snmp_errno = SNMPERR_MALLOC;
  ------------------
  |  |  246|      0|#define SNMPERR_MALLOC			(-62)
  ------------------
 1248|      0|            return (NULL);
 1249|      0|        }
 1250|      0|        session->contextEngineID = ucp;
 1251|      0|        session->contextEngineIDLen = in_session->securityEngineIDLen;
 1252|      0|    }
 1253|       |
 1254|     58|    if (in_session->contextName) {
  ------------------
  |  Branch (1254:9): [True: 0, False: 58]
  ------------------
 1255|      0|        session->contextName = strdup(in_session->contextName);
 1256|      0|        if (session->contextName == NULL) {
  ------------------
  |  Branch (1256:13): [True: 0, False: 0]
  ------------------
 1257|      0|            snmp_sess_close(slp);
 1258|      0|            return (NULL);
 1259|      0|        }
 1260|      0|        session->contextNameLen = in_session->contextNameLen;
 1261|     58|    } else {
 1262|     58|        if ((cp = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (1262:13): [True: 0, False: 58]
  ------------------
 1263|     58|                                        NETSNMP_DS_LIB_CONTEXT)) != NULL)
  ------------------
  |  |  152|     58|#define NETSNMP_DS_LIB_CONTEXT           1
  ------------------
 1264|      0|            cp = strdup(cp);
 1265|     58|        else
 1266|     58|            cp = strdup(SNMP_DEFAULT_CONTEXT);
  ------------------
  |  |   92|     58|#define SNMP_DEFAULT_CONTEXT        ""
  ------------------
 1267|     58|        if (cp == NULL) {
  ------------------
  |  Branch (1267:13): [True: 0, False: 58]
  ------------------
 1268|      0|            snmp_sess_close(slp);
 1269|      0|            return (NULL);
 1270|      0|        }
 1271|     58|        session->contextName = cp;
 1272|     58|        session->contextNameLen = strlen(cp);
 1273|     58|    }
 1274|       |
 1275|     58|    if (in_session->securityName) {
  ------------------
  |  Branch (1275:9): [True: 0, False: 58]
  ------------------
 1276|      0|        session->securityName = strdup(in_session->securityName);
 1277|      0|        if (session->securityName == NULL) {
  ------------------
  |  Branch (1277:13): [True: 0, False: 0]
  ------------------
 1278|      0|            snmp_sess_close(slp);
 1279|      0|            return (NULL);
 1280|      0|        }
 1281|     58|    } else if ((cp = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (1281:16): [True: 0, False: 58]
  ------------------
 1282|     58|					   NETSNMP_DS_LIB_SECNAME)) != NULL) {
  ------------------
  |  |  151|     58|#define NETSNMP_DS_LIB_SECNAME           0
  ------------------
 1283|      0|        cp = strdup(cp);
 1284|      0|        if (cp == NULL) {
  ------------------
  |  Branch (1284:13): [True: 0, False: 0]
  ------------------
 1285|      0|            snmp_sess_close(slp);
 1286|      0|            return (NULL);
 1287|      0|        }
 1288|      0|        session->securityName = cp;
 1289|      0|        session->securityNameLen = strlen(cp);
 1290|      0|    }
 1291|       |
 1292|     58|    if (in_session->securityAuthLocalKey) {
  ------------------
  |  Branch (1292:9): [True: 0, False: 58]
  ------------------
 1293|      0|            session->securityAuthLocalKey =
 1294|      0|                netsnmp_memdup(in_session->securityAuthLocalKey,
 1295|      0|                               in_session->securityAuthLocalKeyLen);
 1296|      0|            session->securityAuthLocalKeyLen =
 1297|      0|                in_session->securityAuthLocalKeyLen;
 1298|      0|    }
 1299|       |
 1300|     58|    if (in_session->securityPrivLocalKey) {
  ------------------
  |  Branch (1300:9): [True: 0, False: 58]
  ------------------
 1301|      0|            session->securityPrivLocalKey =
 1302|      0|                netsnmp_memdup(in_session->securityPrivLocalKey,
 1303|      0|                               in_session->securityPrivLocalKeyLen);
 1304|      0|            session->securityPrivLocalKeyLen =
 1305|      0|                in_session->securityPrivLocalKeyLen;
 1306|      0|    }
 1307|       |
 1308|     58|    if (session->transport_configuration) {
  ------------------
  |  Branch (1308:9): [True: 0, False: 58]
  ------------------
 1309|      0|        session->transport_configuration =
 1310|      0|            CONTAINER_DUP(session->transport_configuration, NULL, 0);
 1311|      0|        if (!session->transport_configuration) {
  ------------------
  |  Branch (1311:13): [True: 0, False: 0]
  ------------------
 1312|      0|            snmp_sess_close(slp);
 1313|      0|            return NULL;
 1314|      0|        }
 1315|      0|    }
 1316|       |
 1317|     58|    if (session->retries == SNMP_DEFAULT_RETRIES) {
  ------------------
  |  |   79|     58|#define SNMP_DEFAULT_RETRIES	    -1
  ------------------
  |  Branch (1317:9): [True: 58, False: 0]
  ------------------
 1318|     58|        int retry = netsnmp_ds_get_int(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1319|     58|                                       NETSNMP_DS_LIB_RETRIES);
  ------------------
  |  |  131|     58|#define NETSNMP_DS_LIB_RETRIES             15
  ------------------
 1320|     58|        if (retry < 0)
  ------------------
  |  Branch (1320:13): [True: 0, False: 58]
  ------------------
 1321|      0|            session->retries = DEFAULT_RETRIES;
  ------------------
  |  |  191|      0|#define DEFAULT_RETRIES	    5
  ------------------
 1322|     58|        else
 1323|     58|            session->retries = retry;
 1324|     58|    }
 1325|     58|    if (session->timeout == SNMP_DEFAULT_TIMEOUT) {
  ------------------
  |  |   80|     58|#define SNMP_DEFAULT_TIMEOUT	    -1
  ------------------
  |  Branch (1325:9): [True: 58, False: 0]
  ------------------
 1326|     58|        int timeout = netsnmp_ds_get_int(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1327|     58|                                         NETSNMP_DS_LIB_TIMEOUT);
  ------------------
  |  |  130|     58|#define NETSNMP_DS_LIB_TIMEOUT             14
  ------------------
 1328|     58|        if (timeout <= 0)
  ------------------
  |  Branch (1328:13): [True: 58, False: 0]
  ------------------
 1329|     58|            session->timeout = DEFAULT_TIMEOUT;
  ------------------
  |  |  192|     58|#define DEFAULT_TIMEOUT	    (1000L * 1000L)
  ------------------
 1330|      0|        else
 1331|      0|            session->timeout = timeout * 1000L * 1000L;
 1332|     58|    }
 1333|     58|    session->sessid = snmp_get_next_sessid();
 1334|       |
 1335|     58|    snmp_call_callbacks(SNMP_CALLBACK_LIBRARY, SNMP_CALLBACK_SESSION_INIT,
  ------------------
  |  |   18|     58|#define SNMP_CALLBACK_LIBRARY     0
  ------------------
                  snmp_call_callbacks(SNMP_CALLBACK_LIBRARY, SNMP_CALLBACK_SESSION_INIT,
  ------------------
  |  |   29|     58|#define SNMP_CALLBACK_SESSION_INIT		5
  ------------------
 1336|     58|                        session);
 1337|       |
 1338|     58|    if ((sptr = find_sec_mod(session->securityModel)) != NULL) {
  ------------------
  |  Branch (1338:9): [True: 58, False: 0]
  ------------------
 1339|       |        /*
 1340|       |         * security module specific copying 
 1341|       |         */
 1342|     58|        if (sptr->session_setup) {
  ------------------
  |  Branch (1342:13): [True: 58, False: 0]
  ------------------
 1343|     58|            int ret = (*sptr->session_setup) (in_session, session);
 1344|     58|            if (ret != SNMPERR_SUCCESS) {
  ------------------
  |  |  184|     58|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  |  Branch (1344:17): [True: 0, False: 58]
  ------------------
 1345|      0|                snmp_sess_close(slp);
 1346|      0|                return NULL;
 1347|      0|            }
 1348|     58|        }
 1349|       |
 1350|       |        /*
 1351|       |         * security module specific opening
 1352|       |         */
 1353|     58|        if (sptr->session_open) {
  ------------------
  |  Branch (1353:13): [True: 0, False: 58]
  ------------------
 1354|      0|            int ret = (*sptr->session_open) (session);
 1355|      0|            if (ret != SNMPERR_SUCCESS) {
  ------------------
  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  |  Branch (1355:17): [True: 0, False: 0]
  ------------------
 1356|      0|                snmp_sess_close(slp);
 1357|      0|                return NULL;
 1358|      0|            }
 1359|      0|        }
 1360|     58|    }
 1361|       |
 1362|     58|#ifndef NETSNMP_NO_WRITE_SUPPORT
 1363|     58|    if (in_session->sessUser) {
  ------------------
  |  Branch (1363:9): [True: 0, False: 58]
  ------------------
 1364|      0|        struct usmUser *user;
 1365|       |
 1366|      0|        user = calloc(1, sizeof(struct usmUser));
 1367|      0|        if (user == NULL) {
  ------------------
  |  Branch (1367:13): [True: 0, False: 0]
  ------------------
 1368|      0|            snmp_sess_close(slp);
 1369|      0|            return NULL;
 1370|      0|        }
 1371|      0|        session->sessUser = usm_cloneFrom_user(in_session->sessUser, user);
 1372|      0|        if (session->sessUser == NULL) {
  ------------------
  |  Branch (1372:13): [True: 0, False: 0]
  ------------------
 1373|      0|            usm_free_user(user);
 1374|      0|            snmp_sess_close(slp);
 1375|      0|            return NULL;
 1376|      0|        }
 1377|      0|    }
 1378|     58|#endif /* NETSNMP_NO_WRITE_SUPPORT */
 1379|       |
 1380|     58|    if (in_session->paramName) {
  ------------------
  |  Branch (1380:9): [True: 0, False: 58]
  ------------------
 1381|      0|        session->paramName = strdup(in_session->paramName);
 1382|      0|        if (session->paramName == NULL) {
  ------------------
  |  Branch (1382:13): [True: 0, False: 0]
  ------------------
 1383|      0|            snmp_sess_close(slp);
 1384|      0|            return NULL;
 1385|      0|        }
 1386|      0|    }
 1387|     58|#ifndef NETSNMP_NO_TRAP_STATS
 1388|     58|    if (in_session->trap_stats) {
  ------------------
  |  Branch (1388:9): [True: 0, False: 58]
  ------------------
 1389|      0|        session->trap_stats = netsnmp_memdup(in_session->trap_stats,
 1390|      0|                                             sizeof(*in_session->trap_stats));
 1391|      0|        if (session->trap_stats == NULL) {
  ------------------
  |  Branch (1391:13): [True: 0, False: 0]
  ------------------
 1392|      0|            snmp_sess_close(slp);
 1393|      0|            return NULL;
 1394|      0|        }
 1395|      0|    }
 1396|     58|#endif
 1397|       |
 1398|     58|    return (slp);
 1399|     58|}
snmp_api.c:netsnmp_free_transport_config:
 2054|     58|{
 2055|     58|    if (!tc)
  ------------------
  |  Branch (2055:9): [True: 58, False: 0]
  ------------------
 2056|     58|        return;
 2057|       |
 2058|      0|    CONTAINER_CLEAR(tc, netsnmp_free_one_tr_cfg, NULL);
 2059|      0|    CONTAINER_FREE(tc);
 2060|      0|}
snmp_api.c:snmp_free_session:
 2093|     58|{
 2094|     58|    if (!s)
  ------------------
  |  Branch (2094:9): [True: 0, False: 58]
  ------------------
 2095|      0|        return;
 2096|       |
 2097|     58|    netsnmp_cleanup_session(s);
 2098|       |
 2099|       |    /*
 2100|       |     * clear session from any callbacks
 2101|       |     */
 2102|     58|    netsnmp_callback_clear_client_arg(s, 0, 0);
 2103|       |
 2104|     58|    free(s);
 2105|     58|}
snmp_api.c:free_securityStateRef:
 4241|    140|{
 4242|    140|    struct snmp_secmod_def *sptr;
 4243|       |
 4244|    140|    if (!pdu->securityStateRef)
  ------------------
  |  Branch (4244:9): [True: 140, False: 0]
  ------------------
 4245|    140|        return;
 4246|       |
 4247|      0|    sptr = find_sec_mod(pdu->securityModel);
 4248|      0|    if (sptr) {
  ------------------
  |  Branch (4248:9): [True: 0, False: 0]
  ------------------
 4249|      0|        if (sptr->pdu_free_state_ref) {
  ------------------
  |  Branch (4249:13): [True: 0, False: 0]
  ------------------
 4250|      0|            (*sptr->pdu_free_state_ref) (pdu->securityStateRef);
 4251|      0|        } else {
 4252|      0|            snmp_log(LOG_ERR,
 4253|      0|                     "Security Model %d can't free state references\n",
 4254|      0|                     pdu->securityModel);
 4255|      0|	}
 4256|      0|    } else {
 4257|      0|	snmp_log(LOG_ERR,
 4258|      0|		 "Can't find security model to free ptr: %d\n",
 4259|      0|		 pdu->securityModel);
 4260|      0|    }
 4261|       |    pdu->securityStateRef = NULL;
 4262|      0|}
snmp_api.c:_snmp_parse:
 4470|    118|{
 4471|    118|#if !defined(NETSNMP_DISABLE_SNMPV1) || !defined(NETSNMP_DISABLE_SNMPV2C)
 4472|    118|    u_char          community[COMMUNITY_MAX_LEN];
 4473|    118|    size_t          community_length = COMMUNITY_MAX_LEN;
  ------------------
  |  |   41|    118|#define COMMUNITY_MAX_LEN	256
  ------------------
 4474|    118|#endif
 4475|    118|    int             result = -1;
 4476|       |
 4477|    118|    static const oid snmpEngineIDoid[]   = { 1,3,6,1,6,3,10,2,1,1,0};
 4478|    118|    static size_t   snmpEngineIDoid_len = 11;
 4479|       |
 4480|    118|    static char     ourEngineID[SNMP_SEC_PARAM_BUF_SIZE];
 4481|    118|    static size_t   ourEngineID_len = sizeof(ourEngineID);
 4482|       |
 4483|    118|    netsnmp_pdu    *pdu2 = NULL;
 4484|       |
 4485|    118|    session->s_snmp_errno = 0;
 4486|    118|    session->s_errno = 0;
 4487|       |
 4488|       |    /*
 4489|       |     * Ensure all incoming PDUs have a unique means of identification 
 4490|       |     * (This is not restricted to AgentX handling,
 4491|       |     * though that is where the need becomes visible)   
 4492|       |     */
 4493|    118|    pdu->transid = snmp_get_next_transid();
 4494|       |
 4495|    118|    if (session->version != SNMP_DEFAULT_VERSION) {
  ------------------
  |  |   90|    118|#define SNMP_DEFAULT_VERSION	    -1
  ------------------
  |  Branch (4495:9): [True: 0, False: 118]
  ------------------
 4496|      0|        pdu->version = session->version;
 4497|    118|    } else {
 4498|    118|        pdu->version = snmp_parse_version(data, length);
 4499|    118|    }
 4500|       |
 4501|    118|    switch (pdu->version) {
 4502|      0|#if !defined(NETSNMP_DISABLE_SNMPV1) || !defined(NETSNMP_DISABLE_SNMPV2C)
 4503|      0|#ifndef NETSNMP_DISABLE_SNMPV1
 4504|     13|    case SNMP_VERSION_1:
  ------------------
  |  |  107|     13|#define SNMP_VERSION_1	   0
  ------------------
  |  Branch (4504:5): [True: 13, False: 105]
  ------------------
 4505|     13|#endif
 4506|     13|#ifndef NETSNMP_DISABLE_SNMPV2C
 4507|     14|    case SNMP_VERSION_2c:
  ------------------
  |  |  110|     14|#define SNMP_VERSION_2c    1
  ------------------
  |  Branch (4507:5): [True: 1, False: 117]
  ------------------
 4508|     14|#endif
 4509|     14|        NETSNMP_RUNTIME_PROTOCOL_CHECK_V1V2(pdu->version,unsupported_version);
  ------------------
  |  |  220|     14|#define NETSNMP_RUNTIME_PROTOCOL_CHECK_V1V2(pc_ver, pc_target) do {    \
  |  |  221|     14|        if (NETSNMP_RUNTIME_PROTOCOL_SKIP_V1(pc_ver) ||                \
  |  |  ------------------
  |  |  |  |  205|     28|    ((pc_ver) == SNMP_VERSION_1 &&                                      \
  |  |  |  |  ------------------
  |  |  |  |  |  |  107|     28|#define SNMP_VERSION_1	   0
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (205:6): [True: 13, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  206|     28|     netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,                      \
  |  |  |  |  ------------------
  |  |  |  |  |  |   48|     13|#define NETSNMP_DS_LIBRARY_ID     0
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (206:6): [True: 0, False: 13]
  |  |  |  |  ------------------
  |  |  |  |  207|     13|                            NETSNMP_DS_LIB_DISABLE_V1))
  |  |  |  |  ------------------
  |  |  |  |  |  |  103|     13|#define NETSNMP_DS_LIB_DISABLE_V1          43 /* disable SNMPv1 */
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  222|     14|            NETSNMP_RUNTIME_PROTOCOL_SKIP_V2(pc_ver)) {                \
  |  |  ------------------
  |  |  |  |  215|     14|    ((pc_ver) == SNMP_VERSION_2c &&                                     \
  |  |  |  |  ------------------
  |  |  |  |  |  |  110|     28|#define SNMP_VERSION_2c    1
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (215:6): [True: 1, False: 13]
  |  |  |  |  ------------------
  |  |  |  |  216|     14|     netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,                      \
  |  |  |  |  ------------------
  |  |  |  |  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (216:6): [True: 0, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  217|      1|                            NETSNMP_DS_LIB_DISABLE_V2c))
  |  |  |  |  ------------------
  |  |  |  |  |  |  104|      1|#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|     14|    } while(0)
  |  |  ------------------
  |  |  |  Branch (226:13): [Folded, False: 14]
  |  |  ------------------
  ------------------
 4510|     14|        DEBUGMSGTL(("snmp_api", "Parsing SNMPv%ld message...\n",
  ------------------
  |  |   66|     14|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     14|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 14]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 14]
  |  |  ------------------
  ------------------
 4511|     14|                    (1 + pdu->version)));
 4512|       |
 4513|       |        /*
 4514|       |         * authenticates message and returns length if valid 
 4515|       |         */
 4516|     14|#ifndef NETSNMP_DISABLE_SNMPV1
 4517|     14|        if (pdu->version == SNMP_VERSION_1) {
  ------------------
  |  |  107|     14|#define SNMP_VERSION_1	   0
  ------------------
  |  Branch (4517:13): [True: 13, False: 1]
  ------------------
 4518|     13|            DEBUGDUMPSECTION("recv", "SNMPv1 message\n");
  ------------------
  |  |   81|     13|	do {if (_DBG_IF_) {__DBGDUMPSECTION(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     13|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 13]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	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: 13]
  |  |  ------------------
  ------------------
 4519|     13|        } else {
 4520|      1|#endif
 4521|      1|            DEBUGDUMPSECTION("recv", "SNMPv2c message\n");
  ------------------
  |  |   81|      1|	do {if (_DBG_IF_) {__DBGDUMPSECTION(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	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: 1]
  |  |  ------------------
  ------------------
 4522|      1|#ifndef NETSNMP_DISABLE_SNMPV1
 4523|      1|        }
 4524|     14|#endif
 4525|     14|        data = snmp_comstr_parse(data, &length,
 4526|     14|                                 community, &community_length,
 4527|     14|                                 &pdu->version);
 4528|     14|        if (data == NULL)
  ------------------
  |  Branch (4528:13): [True: 4, False: 10]
  ------------------
 4529|      4|            return -1;
 4530|       |
 4531|     10|        if (pdu->version != session->version &&
  ------------------
  |  Branch (4531:13): [True: 10, False: 0]
  ------------------
 4532|     10|            session->version != SNMP_DEFAULT_VERSION) {
  ------------------
  |  |   90|     10|#define SNMP_DEFAULT_VERSION	    -1
  ------------------
  |  Branch (4532:13): [True: 0, False: 10]
  ------------------
 4533|      0|            session->s_snmp_errno = SNMPERR_BAD_VERSION;
  ------------------
  |  |  198|      0|#define SNMPERR_BAD_VERSION		(-14)
  ------------------
 4534|      0|            return -1;
 4535|      0|        }
 4536|       |
 4537|       |        /*
 4538|       |         * maybe get the community string. 
 4539|       |         */
 4540|     10|        pdu->securityLevel = SNMP_SEC_LEVEL_NOAUTH;
  ------------------
  |  |  299|     10|#define SNMP_SEC_LEVEL_NOAUTH		1
  ------------------
 4541|     10|        pdu->securityModel = 
 4542|     10|#ifndef NETSNMP_DISABLE_SNMPV1
 4543|     10|            (pdu->version == SNMP_VERSION_1) ? SNMP_SEC_MODEL_SNMPv1 : 
  ------------------
  |  |  107|     10|#define SNMP_VERSION_1	   0
  ------------------
                          (pdu->version == SNMP_VERSION_1) ? SNMP_SEC_MODEL_SNMPv1 : 
  ------------------
  |  |  293|     10|#define SNMP_SEC_MODEL_SNMPv1		1
  ------------------
  |  Branch (4543:13): [True: 10, False: 0]
  ------------------
 4544|     10|#endif
 4545|     10|                                               SNMP_SEC_MODEL_SNMPv2c;
  ------------------
  |  |  294|     10|#define SNMP_SEC_MODEL_SNMPv2c		2
  ------------------
 4546|     10|        SNMP_FREE(pdu->community);
  ------------------
  |  |   62|     10|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 10]
  |  |  |  Branch (62:66): [Folded, False: 10]
  |  |  ------------------
  ------------------
 4547|     10|        pdu->community_len = 0;
 4548|     10|        pdu->community = (u_char *) 0;
 4549|     10|        if (community_length) {
  ------------------
  |  Branch (4549:13): [True: 3, False: 7]
  ------------------
 4550|      3|            pdu->community_len = community_length;
 4551|      3|            pdu->community = netsnmp_memdup(community, community_length);
 4552|      3|            if (pdu->community == NULL) {
  ------------------
  |  Branch (4552:17): [True: 0, False: 3]
  ------------------
 4553|      0|                session->s_snmp_errno = SNMPERR_MALLOC;
  ------------------
  |  |  246|      0|#define SNMPERR_MALLOC			(-62)
  ------------------
 4554|      0|                return -1;
 4555|      0|            }
 4556|      3|        }
 4557|     10|        if (session->authenticator) {
  ------------------
  |  Branch (4557:13): [True: 0, False: 10]
  ------------------
 4558|      0|            data = session->authenticator(data, &length,
 4559|      0|                                          community, community_length);
 4560|      0|            if (data == NULL) {
  ------------------
  |  Branch (4560:17): [True: 0, False: 0]
  ------------------
 4561|      0|                session->s_snmp_errno = SNMPERR_AUTHENTICATION_FAILURE;
  ------------------
  |  |  219|      0|#define SNMPERR_AUTHENTICATION_FAILURE 	(-35)
  ------------------
 4562|      0|                return -1;
 4563|      0|            }
 4564|      0|        }
 4565|       |
 4566|     10|        DEBUGDUMPSECTION("recv", "PDU");
  ------------------
  |  |   81|     10|	do {if (_DBG_IF_) {__DBGDUMPSECTION(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     10|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 10]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	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: 10]
  |  |  ------------------
  ------------------
 4567|     10|        result = snmp_pdu_parse(pdu, data, &length);
 4568|     10|        if (result < 0) {
  ------------------
  |  Branch (4568:13): [True: 10, False: 0]
  ------------------
 4569|       |            /*
 4570|       |             * This indicates a parse error.  
 4571|       |             */
 4572|     10|            snmp_increment_statistic(STAT_SNMPINASNPARSEERRS);
  ------------------
  |  |  637|     10|#define  STAT_SNMPINASNPARSEERRS             14
  ------------------
 4573|     10|        }
 4574|     10|        DEBUGINDENTADD(-6);
  ------------------
  |  |   73|     10|#define DEBUGINDENTADD(x)  do {if (_DBG_IF_) {__DBGINDENTADD(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     10|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 10]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTADD(x)  do {if (_DBG_IF_) {__DBGINDENTADD(x);} }while(0)
  |  |  ------------------
  |  |  |  |  172|      0|#define __DBGINDENTADD(x)  debug_indent_add(x)
  |  |  ------------------
  |  |  |  Branch (73:74): [Folded, False: 10]
  |  |  ------------------
  ------------------
 4575|     10|        break;
 4576|      0|#endif /* support for community based SNMP */
 4577|       |
 4578|     22|    case SNMP_VERSION_3:
  ------------------
  |  |  113|     22|#define SNMP_VERSION_3     3
  ------------------
  |  Branch (4578:5): [True: 22, False: 96]
  ------------------
 4579|     22|        NETSNMP_RUNTIME_PROTOCOL_CHECK_V3(SNMP_VERSION_3,unsupported_version);
  ------------------
  |  |  233|     22|#define NETSNMP_RUNTIME_PROTOCOL_CHECK_V3(pc_ver, pc_target) do {      \
  |  |  234|     22|        if (NETSNMP_RUNTIME_PROTOCOL_SKIP_V3(pc_ver)) {                \
  |  |  ------------------
  |  |  |  |  229|     22|    ((pc_ver == SNMP_VERSION_3) &&                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  |  113|     22|#define SNMP_VERSION_3     3
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (229:6): [True: 22, Folded]
  |  |  |  |  ------------------
  |  |  |  |  230|     22|     netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,                     \
  |  |  |  |  ------------------
  |  |  |  |  |  |   48|     22|#define NETSNMP_DS_LIBRARY_ID     0
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (230:6): [True: 0, False: 22]
  |  |  |  |  ------------------
  |  |  |  |  231|     22|                            NETSNMP_DS_LIB_DISABLE_V3))
  |  |  |  |  ------------------
  |  |  |  |  |  |  105|     22|#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|     22|    } while(0)
  |  |  ------------------
  |  |  |  Branch (238:13): [Folded, False: 22]
  |  |  ------------------
  ------------------
 4580|     22|        result = snmpv3_parse(pdu, data, &length, NULL, session);
 4581|     22|        DEBUGMSGTL(("snmp_parse",
  ------------------
  |  |   66|     22|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     22|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 22]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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:52): [True: 0, False: 0]
  |  |  |  |  |  Branch (164:64): [True: 0, False: 0]
  |  |  |  |  |  Branch (164:64): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 22]
  |  |  ------------------
  ------------------
 4582|     22|                    "Parsed SNMPv3 message (secName:%s, secLevel:%s): %s\n",
 4583|     22|                    pdu->securityName,
 4584|     22|                    (pdu->securityLevel >= 0 && pdu->securityLevel < 4) ?
 4585|     22|                    secLevelName[pdu->securityLevel] : "ERROR: invalid",
 4586|     22|                    snmp_api_errstring(result)));
 4587|       |
 4588|     22|        if (result == SNMPERR_USM_UNKNOWNSECURITYNAME) {
  ------------------
  |  |  227|     22|#define SNMPERR_USM_UNKNOWNSECURITYNAME		(-43)
  ------------------
  |  Branch (4588:13): [True: 0, False: 22]
  ------------------
 4589|      0|            snmp_call_callbacks(SNMP_CALLBACK_APPLICATION,
  ------------------
  |  |   19|      0|#define SNMP_CALLBACK_APPLICATION 1
  ------------------
 4590|      0|                                SNMPD_CALLBACK_AUTH_FAILURE, pdu);
  ------------------
  |  |   21|      0|#define SNMPD_CALLBACK_AUTH_FAILURE             17
  ------------------
 4591|      0|        }
 4592|       |        
 4593|     22|        if (result) {
  ------------------
  |  Branch (4593:13): [True: 22, False: 0]
  ------------------
 4594|     22|            struct snmp_secmod_def *secmod =
 4595|     22|                find_sec_mod(pdu->securityModel);
 4596|     22|            if (!slp) {
  ------------------
  |  Branch (4596:17): [True: 0, False: 22]
  ------------------
 4597|      0|                session->s_snmp_errno = result;
 4598|     22|            } else {
 4599|       |                /*
 4600|       |                 * Call the security model to special handle any errors
 4601|       |                 */
 4602|       |
 4603|     22|                if (secmod && secmod->handle_report) {
  ------------------
  |  Branch (4603:21): [True: 2, False: 20]
  |  Branch (4603:31): [True: 2, False: 0]
  ------------------
 4604|      2|                    (*secmod->handle_report)(slp, slp->transport, session,
 4605|      2|                                             result, pdu);
 4606|      2|                }
 4607|     22|            }
 4608|     22|            free_securityStateRef(pdu);
 4609|     22|        }
 4610|       |
 4611|       |        /* Implement RFC5343 here for two reasons:
 4612|       |           1) From a security perspective it handles this otherwise
 4613|       |              always approved request earlier.  It bypasses the need
 4614|       |              for authorization to the snmpEngineID scalar, which is
 4615|       |              what is what RFC3415 appendix A species as ok.  Note
 4616|       |              that we haven't bypassed authentication since if there
 4617|       |              was an authentication error it would have been handled
 4618|       |              above in the if(result) part at the latest.
 4619|       |           2) From an application point of view if we let this request
 4620|       |              get all the way to the application, it'd require that
 4621|       |              all application types supporting discovery also fire up
 4622|       |              a minimal agent in order to handle just this request
 4623|       |              which seems like overkill.  Though there is no other
 4624|       |              application types that currently need discovery (NRs
 4625|       |              accept notifications from contextEngineIDs that derive
 4626|       |              from the NO not the NR).  Also a lame excuse for doing
 4627|       |              it here.
 4628|       |           3) Less important technically, but the net-snmp agent
 4629|       |              doesn't currently handle registrations of different
 4630|       |              engineIDs either and it would have been a lot more work
 4631|       |              to implement there since we'd need to support that
 4632|       |              first. :-/ Supporting multiple context engineIDs should
 4633|       |              be done anyway, so it's not a valid excuse here.
 4634|       |           4) There is a lot less to do if we trump the agent at this
 4635|       |              point; IE, the agent does a lot more unnecessary
 4636|       |              processing when the only thing that should ever be in
 4637|       |              this context by definition is the single scalar.
 4638|       |        */
 4639|       |
 4640|       |        /* special RFC5343 engineID discovery engineID check */
 4641|     22|        if (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|     22|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (4641:13): [True: 22, False: 0]
  ------------------
 4642|     22|                                    NETSNMP_DS_LIB_NO_DISCOVERY) &&
  ------------------
  |  |   98|     22|#define NETSNMP_DS_LIB_NO_DISCOVERY        38 /* don't support RFC5343 contextEngineID discovery */
  ------------------
 4643|     22|            SNMP_MSG_RESPONSE       != pdu->command &&
  ------------------
  |  |  127|     22|#define SNMP_MSG_RESPONSE   (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x2) /* a2=162 */
  |  |  ------------------
  |  |  |  |   92|     22|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_MSG_RESPONSE   (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x2) /* a2=162 */
  |  |  ------------------
  |  |  |  |   96|     22|#define ASN_CONSTRUCTOR	    0x20U
  |  |  ------------------
  ------------------
  |  Branch (4643:13): [True: 22, False: 0]
  ------------------
 4644|     22|            NULL                    != pdu->contextEngineID &&
  ------------------
  |  Branch (4644:13): [True: 2, False: 20]
  ------------------
 4645|      2|            pdu->contextEngineIDLen == 5 &&
  ------------------
  |  Branch (4645:13): [True: 0, False: 2]
  ------------------
 4646|      0|            pdu->contextEngineID[0] == 0x80 &&
  ------------------
  |  Branch (4646:13): [True: 0, False: 0]
  ------------------
 4647|      0|            pdu->contextEngineID[1] == 0x00 &&
  ------------------
  |  Branch (4647:13): [True: 0, False: 0]
  ------------------
 4648|      0|            pdu->contextEngineID[2] == 0x00 &&
  ------------------
  |  Branch (4648:13): [True: 0, False: 0]
  ------------------
 4649|      0|            pdu->contextEngineID[3] == 0x00 &&
  ------------------
  |  Branch (4649:13): [True: 0, False: 0]
  ------------------
 4650|      0|            pdu->contextEngineID[4] == 0x06) {
  ------------------
  |  Branch (4650:13): [True: 0, False: 0]
  ------------------
 4651|       |
 4652|       |            /* define a result so it doesn't get past us at this point
 4653|       |               and gets dropped by future parts of the stack */
 4654|      0|            result = SNMPERR_JUST_A_CONTEXT_PROBE;
  ------------------
  |  |  250|      0|#define SNMPERR_JUST_A_CONTEXT_PROBE    (-66)
  ------------------
 4655|       |
 4656|      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]
  |  |  ------------------
  ------------------
 4657|       |            /* ensure exactly one variable */
 4658|      0|            if (NULL != pdu->variables &&
  ------------------
  |  Branch (4658:17): [True: 0, False: 0]
  ------------------
 4659|      0|                NULL == pdu->variables->next_variable &&
  ------------------
  |  Branch (4659:17): [True: 0, False: 0]
  ------------------
 4660|       |
 4661|       |                /* if it's a GET, match it exactly */
 4662|      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 (4662:19): [True: 0, False: 0]
  ------------------
 4663|      0|                  snmp_oid_compare(snmpEngineIDoid,
  ------------------
  |  Branch (4663:19): [True: 0, False: 0]
  ------------------
 4664|      0|                                   snmpEngineIDoid_len,
 4665|      0|                                   pdu->variables->name,
 4666|      0|                                   pdu->variables->name_length) == 0)
 4667|       |                 /* if it's a GETNEXT ensure it's less than the engineID oid */
 4668|      0|                 ||
 4669|      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 (4669:19): [True: 0, False: 0]
  ------------------
 4670|      0|                  snmp_oid_compare(snmpEngineIDoid,
  ------------------
  |  Branch (4670:19): [True: 0, False: 0]
  ------------------
 4671|      0|                                   snmpEngineIDoid_len,
 4672|      0|                                   pdu->variables->name,
 4673|      0|                                   pdu->variables->name_length) > 0)
 4674|      0|                    )) {
 4675|       |
 4676|      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]
  |  |  ------------------
  ------------------
 4677|      0|                            "  One correct variable found\n"));
 4678|       |
 4679|       |                /* Note: we're explicitly not handling a GETBULK.  Deal. */
 4680|       |
 4681|       |                /* set up the response */
 4682|      0|                pdu2 = snmp_clone_pdu(pdu);
 4683|      0|                if (NULL == pdu2) {
  ------------------
  |  Branch (4683:21): [True: 0, False: 0]
  ------------------
 4684|      0|                    snmp_log(LOG_ERR, "failed to clone PDU for rfc5343 probe\n");
 4685|      0|                    if (pdu->securityStateRef)
  ------------------
  |  Branch (4685:25): [True: 0, False: 0]
  ------------------
 4686|      0|                        free_securityStateRef(pdu);
 4687|      0|                    return result;
 4688|      0|                }
 4689|       |
 4690|       |                /* free the current varbind */
 4691|      0|                snmp_free_varbind(pdu2->variables);
 4692|       |
 4693|       |                /* set the variables */
 4694|      0|                pdu2->variables = NULL;
 4695|      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
  |  |  ------------------
  ------------------
 4696|      0|                pdu2->errstat = 0;
 4697|      0|                pdu2->errindex = 0;
 4698|       |
 4699|      0|                ourEngineID_len =
 4700|      0|                    snmpv3_get_engineID((u_char*)ourEngineID, ourEngineID_len);
 4701|      0|                if (0 != ourEngineID_len) {
  ------------------
  |  Branch (4701:21): [True: 0, False: 0]
  ------------------
 4702|       |
 4703|      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]
  |  |  ------------------
  ------------------
 4704|      0|                                "  responding with our engineID\n"));
 4705|       |
 4706|      0|                    snmp_pdu_add_variable(pdu2,
 4707|      0|                                          snmpEngineIDoid, snmpEngineIDoid_len,
 4708|      0|                                          ASN_OCTET_STR,
  ------------------
  |  |   78|      0|#define ASN_OCTET_STR	    0x04U
  ------------------
 4709|      0|                                          ourEngineID, ourEngineID_len);
 4710|       |                    
 4711|       |                    /* send the response */
 4712|      0|                    if (0 == snmp_sess_send(slp, pdu2)) {
  ------------------
  |  Branch (4712:25): [True: 0, False: 0]
  ------------------
 4713|       |
 4714|      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]
  |  |  ------------------
  ------------------
 4715|      0|                                    "  sent it off!\n"));
 4716|       |
 4717|      0|                        snmp_free_pdu(pdu2);
 4718|       |                        
 4719|      0|                        snmp_log(LOG_ERR, "sending a response to the context engineID probe failed\n");
 4720|      0|                    }
 4721|      0|                } else {
 4722|      0|                    snmp_log(LOG_ERR, "failed to get our own engineID!\n");
 4723|      0|                    snmp_free_pdu(pdu2);
 4724|      0|                }
 4725|      0|            } else {
 4726|      0|                snmp_log(LOG_WARNING,
 4727|      0|                         "received an odd context engineID probe\n");
 4728|      0|            }
 4729|      0|            if (pdu->securityStateRef)
  ------------------
  |  Branch (4729:17): [True: 0, False: 0]
  ------------------
 4730|      0|                free_securityStateRef(pdu);
 4731|      0|        }
 4732|       |
 4733|     22|        break;
 4734|     78|    case SNMPERR_BAD_VERSION:
  ------------------
  |  |  198|     78|#define SNMPERR_BAD_VERSION		(-14)
  ------------------
  |  Branch (4734:5): [True: 78, False: 40]
  ------------------
 4735|     78|        ERROR_MSG("error parsing snmp message version");
  ------------------
  |  |  188|     78|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 4736|     78|        snmp_increment_statistic(STAT_SNMPINASNPARSEERRS);
  ------------------
  |  |  637|     78|#define  STAT_SNMPINASNPARSEERRS             14
  ------------------
 4737|     78|        session->s_snmp_errno = SNMPERR_BAD_VERSION;
  ------------------
  |  |  198|     78|#define SNMPERR_BAD_VERSION		(-14)
  ------------------
 4738|     78|        break;
 4739|       |
 4740|      0|        unsupported_version:  /* goto label */
 4741|      0|    case SNMP_VERSION_sec:
  ------------------
  |  |  118|      0|#define SNMP_VERSION_sec   128  /* not (will never be) supported by this code */
  ------------------
  |  Branch (4741:5): [True: 0, False: 118]
  ------------------
 4742|      0|    case SNMP_VERSION_2u:
  ------------------
  |  |  112|      0|#define SNMP_VERSION_2u    2    /* not (will never be) supported by this code */
  ------------------
  |  Branch (4742:5): [True: 0, False: 118]
  ------------------
 4743|      0|    case SNMP_VERSION_2star:
  ------------------
  |  |  120|      0|#define SNMP_VERSION_2star 130  /* not (will never be) supported by this code */
  ------------------
  |  Branch (4743:5): [True: 0, False: 118]
  ------------------
 4744|      0|    case SNMP_VERSION_2p:
  ------------------
  |  |  119|      0|#define SNMP_VERSION_2p	   129  /* no longer supported by this code (> 4.0) */
  ------------------
  |  Branch (4744:5): [True: 0, False: 118]
  ------------------
 4745|      4|    default:
  ------------------
  |  Branch (4745:5): [True: 4, False: 114]
  ------------------
 4746|      4|        ERROR_MSG("unsupported snmp message version");
  ------------------
  |  |  188|      4|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 4747|      4|        snmp_increment_statistic(STAT_SNMPINBADVERSIONS);
  ------------------
  |  |  634|      4|#define  STAT_SNMPINBADVERSIONS              11
  ------------------
 4748|       |
 4749|       |        /*
 4750|       |         * need better way to determine OS independent
 4751|       |         * INT32_MAX value, for now hardcode
 4752|       |         */
 4753|      4|        if (pdu->version < 0 || pdu->version > 2147483647) {
  ------------------
  |  Branch (4753:13): [True: 2, False: 2]
  |  Branch (4753:33): [True: 0, False: 2]
  ------------------
 4754|      2|            snmp_increment_statistic(STAT_SNMPINASNPARSEERRS);
  ------------------
  |  |  637|      2|#define  STAT_SNMPINASNPARSEERRS             14
  ------------------
 4755|      2|        }
 4756|      4|        session->s_snmp_errno = SNMPERR_BAD_VERSION;
  ------------------
  |  |  198|      4|#define SNMPERR_BAD_VERSION		(-14)
  ------------------
 4757|      4|        break;
 4758|    118|    }
 4759|       |
 4760|    114|    return result;
 4761|    118|}
snmp_api.c:snmp_parse_version:
 3872|    118|{
 3873|    118|    u_char          type;
 3874|    118|    long            version = SNMPERR_BAD_VERSION;
  ------------------
  |  |  198|    118|#define SNMPERR_BAD_VERSION		(-14)
  ------------------
 3875|       |
 3876|    118|    data = asn_parse_sequence(data, &length, &type,
 3877|    118|                              (ASN_SEQUENCE | ASN_CONSTRUCTOR), "version");
  ------------------
  |  |   84|    118|#define ASN_SEQUENCE	    0x10U
  ------------------
                                            (ASN_SEQUENCE | ASN_CONSTRUCTOR), "version");
  ------------------
  |  |   96|    118|#define ASN_CONSTRUCTOR	    0x20U
  ------------------
 3878|    118|    if (data) {
  ------------------
  |  Branch (3878:9): [True: 118, False: 0]
  ------------------
 3879|    118|        DEBUGDUMPHEADER("recv", "SNMP Version");
  ------------------
  |  |   79|    118|	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    118|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 118]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  178|      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__))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  179|      0|        debugmsg("dumph_" token,x); \
  |  |  |  |  180|      0|        if (debug_is_token_registered("dumpx" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (180:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  181|      0|            debug_is_token_registered("dumpv" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (181:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  182|      0|            (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|      0|             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|      0|            debugmsg("dumph_" token,"\n"); \
  |  |  |  |  185|      0|        } else { \
  |  |  |  |  186|      0|            debugmsg("dumph_" token,"  "); \
  |  |  |  |  187|      0|        } \
  |  |  |  |  188|      0|        __DBGINDENTMORE()
  |  |  |  |  ------------------
  |  |  |  |  |  |  173|      0|#define __DBGINDENTMORE()  debug_indent_add(2)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (79:55): [Folded, False: 118]
  |  |  ------------------
  ------------------
 3880|    118|        data =
 3881|    118|            asn_parse_int(data, &length, &type, &version, sizeof(version));
 3882|    118|        DEBUGINDENTLESS();
  ------------------
  |  |   75|    118|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|    118|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 118]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 118]
  |  |  ------------------
  ------------------
 3883|    118|        if (!data || type != ASN_INTEGER) {
  ------------------
  |  |   75|     40|#define ASN_INTEGER	    0x02U
  ------------------
  |  Branch (3883:13): [True: 78, False: 40]
  |  Branch (3883:22): [True: 0, False: 40]
  ------------------
 3884|     78|            return SNMPERR_BAD_VERSION;
  ------------------
  |  |  198|     78|#define SNMPERR_BAD_VERSION		(-14)
  ------------------
 3885|     78|        }
 3886|    118|    }
 3887|     40|    return version;
 3888|    118|}
snmp_api.c:_sess_packet_deadline_expired:
 6251|     57|{
 6252|     57|    struct timeval now;
 6253|       |
 6254|     57|    if (isp == NULL || !timerisset(&isp->packet_deadline))
  ------------------
  |  Branch (6254:9): [True: 0, False: 57]
  |  Branch (6254:24): [True: 0, False: 57]
  ------------------
 6255|     57|        return 0;
 6256|      0|    netsnmp_get_monotonic_clock(&now);
 6257|       |    return !timercmp(&now, &isp->packet_deadline, <);
  ------------------
  |  Branch (6257:13): [True: 0, False: 0]
  ------------------
 6258|     57|}
snmp_api.c:__sess_read:
 6528|     57|{
 6529|     57|    netsnmp_session *sp = slp ? slp->session : NULL;
  ------------------
  |  Branch (6529:27): [True: 57, False: 0]
  ------------------
 6530|     57|    struct snmp_internal_session *isp = slp ? slp->internal : NULL;
  ------------------
  |  Branch (6530:41): [True: 57, False: 0]
  ------------------
 6531|     57|    netsnmp_transport *transport = slp ? slp->transport : NULL;
  ------------------
  |  Branch (6531:36): [True: 57, False: 0]
  ------------------
 6532|     57|    size_t          pdulen = 0;
 6533|     57|    size_t          rxbuf_len;
 6534|     57|    size_t          stream_limit;
 6535|     57|    u_char         *rxbuf = NULL;
 6536|     57|    int             length = 0, olength = 0, rc = 0;
 6537|     57|    void           *opaque = NULL;
 6538|       |
 6539|     57|    if (NULL == slp || NULL == sp || NULL == isp || NULL == transport) {
  ------------------
  |  Branch (6539:9): [True: 0, False: 57]
  |  Branch (6539:24): [True: 0, False: 57]
  |  Branch (6539:38): [True: 0, False: 57]
  |  Branch (6539:53): [True: 0, False: 57]
  ------------------
 6540|      0|        snmp_log(LOG_ERR, "bad parameters to __sess_read\n");
 6541|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
 6542|      0|    }
 6543|       |
 6544|       |    /* to avoid subagent crash */
 6545|     57|    if (!NETSNMP_IS_VALID_SOCKET(transport->sock)) {
  ------------------
  |  |   44|     57|#define NETSNMP_IS_VALID_SOCKET(_sock) ((_sock) != -1)
  ------------------
  |  Branch (6545:9): [True: 0, False: 57]
  ------------------
 6546|      0|        snmp_log(LOG_INFO, "transport->sock is invalid\n");
 6547|      0|        return 0; 
 6548|      0|    }
 6549|       |
 6550|     57|    sp->s_snmp_errno = 0;
 6551|     57|    sp->s_errno = 0;
 6552|       |
 6553|     57|    stream_limit = sp->rcvMsgMaxSize ?
  ------------------
  |  Branch (6553:20): [True: 57, False: 0]
  ------------------
 6554|     57|        SNMP_MIN(SNMP_MAX_PACKET_LEN, sp->rcvMsgMaxSize) :
  ------------------
  |  |  111|     57|#define SNMP_MIN(a,b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (111:24): [True: 57, False: 0]
  |  |  ------------------
  ------------------
 6555|     57|        SNMP_MAX_PACKET_LEN;
  ------------------
  |  |   49|     57|#define SNMP_MAX_PACKET_LEN (0x7fffffff)
  ------------------
 6556|     57|    rxbuf_len = SNMP_MIN(SNMP_MAX_RCV_MSG_SIZE, stream_limit);
  ------------------
  |  |  111|     57|#define SNMP_MIN(a,b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (111:24): [True: 57, False: 0]
  |  |  ------------------
  ------------------
 6557|       |
 6558|     57|    if (transport->flags & NETSNMP_TRANSPORT_FLAG_LISTEN)
  ------------------
  |  |   52|     57|#define		NETSNMP_TRANSPORT_FLAG_LISTEN	 0x02
  ------------------
  |  Branch (6558:9): [True: 0, False: 57]
  ------------------
 6559|      0|        return _sess_read_accept(slp);
 6560|       |
 6561|     57|    if (!(transport->flags & NETSNMP_TRANSPORT_FLAG_STREAM)) {
  ------------------
  |  |   51|     57|#define		NETSNMP_TRANSPORT_FLAG_STREAM	 0x01
  ------------------
  |  Branch (6561:9): [True: 57, False: 0]
  ------------------
 6562|     57|        snmp_rcv_packet rcvp;
 6563|     57|        u_char *pptr;
 6564|     57|        size_t len_remaining, pdulen;
 6565|     57|        void *ocopy = NULL;
 6566|       |
 6567|     57|        memset(&rcvp, 0x0, sizeof(rcvp));
 6568|       |
 6569|       |        /** read the packet */
 6570|     57|        rc = _sess_read_dgram_packet(slp, &rcvp);
 6571|     57|        if (-1 == rc) /* protocol error */
  ------------------
  |  Branch (6571:13): [True: 0, False: 57]
  ------------------
 6572|      0|            return -1;
 6573|     57|        else if (-2 == rc) /* no packet to process */
  ------------------
  |  Branch (6573:18): [True: 0, False: 57]
  ------------------
 6574|      0|            return 0;
 6575|       |
 6576|     57|        pptr = rcvp.packet;
 6577|     57|        len_remaining = rcvp.packet_len;
 6578|     57|        rc = 0;
 6579|       |
 6580|    175|        while (len_remaining > 0) {
  ------------------
  |  Branch (6580:16): [True: 170, False: 5]
  ------------------
 6581|    170|            if (isp->check_packet) {
  ------------------
  |  Branch (6581:17): [True: 0, False: 170]
  ------------------
 6582|      0|                pdulen = isp->check_packet(pptr, len_remaining);
 6583|    170|            } else {
 6584|    170|                pdulen = asn_check_packet(pptr, len_remaining);
 6585|    170|            }
 6586|    170|            if (pdulen == 0 || pdulen > len_remaining || pdulen > SNMP_MAX_PACKET_LEN) {
  ------------------
  |  |   49|    118|#define SNMP_MAX_PACKET_LEN (0x7fffffff)
  ------------------
  |  Branch (6586:17): [True: 24, False: 146]
  |  Branch (6586:32): [True: 28, False: 118]
  |  Branch (6586:58): [True: 0, False: 118]
  ------------------
 6587|       |                /* Not a valid packet or incomplete in datagram mode */
 6588|     52|                if (pptr == rcvp.packet) {
  ------------------
  |  Branch (6588:21): [True: 38, False: 14]
  ------------------
 6589|     38|                    SNMP_FREE(rcvp.opaque);
  ------------------
  |  |   62|     38|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 38, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 38]
  |  |  ------------------
  ------------------
 6590|     38|                }
 6591|     52|                break;
 6592|     52|            }
 6593|    118|            if (pdulen < len_remaining) {
  ------------------
  |  Branch (6593:17): [True: 113, False: 5]
  ------------------
 6594|    113|                if (rcvp.olength > 0 && rcvp.opaque != NULL) {
  ------------------
  |  Branch (6594:21): [True: 113, False: 0]
  |  Branch (6594:41): [True: 113, False: 0]
  ------------------
 6595|    113|                    ocopy = malloc(rcvp.olength);
 6596|    113|                    if (ocopy != NULL) {
  ------------------
  |  Branch (6596:25): [True: 113, False: 0]
  ------------------
 6597|    113|                        memcpy(ocopy, rcvp.opaque, rcvp.olength);
 6598|    113|                    }
 6599|    113|                }
 6600|    113|            } else {
 6601|      5|                ocopy = rcvp.opaque;
 6602|      5|                rcvp.opaque = NULL;
 6603|      5|            }
 6604|    118|            rc = _sess_process_packet(slp, sp, isp, transport,
 6605|    118|                                      ocopy, ocopy ? rcvp.olength : 0,
  ------------------
  |  Branch (6605:46): [True: 118, False: 0]
  ------------------
 6606|    118|                                      pptr, pdulen);
 6607|    118|            ocopy = NULL;
 6608|    118|            pptr += pdulen;
 6609|    118|            len_remaining -= pdulen;
 6610|    118|        }
 6611|     57|        SNMP_FREE(rcvp.packet);
  ------------------
  |  |   62|     57|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 57, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 57]
  |  |  ------------------
  ------------------
 6612|     57|        SNMP_FREE(rcvp.opaque);
  ------------------
  |  |   62|     57|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 14, False: 43]
  |  |  |  Branch (62:66): [Folded, False: 57]
  |  |  ------------------
  ------------------
 6613|     57|        return rc;
 6614|     57|    }
 6615|       |
 6616|       |    /** stream transport */
 6617|       |
 6618|      0|        if (isp->packet_len >= stream_limit) {
  ------------------
  |  Branch (6618:13): [True: 0, False: 0]
  ------------------
 6619|      0|            _sess_close_stream(slp);
 6620|      0|            return -1;
 6621|      0|        }
 6622|      0|        rxbuf_len = SNMP_MIN(rxbuf_len, stream_limit - isp->packet_len);
  ------------------
  |  |  111|      0|#define SNMP_MIN(a,b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (111:24): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 6623|       |
 6624|      0|        if (isp->packet == NULL) {
  ------------------
  |  Branch (6624:13): [True: 0, False: 0]
  ------------------
 6625|       |            /*
 6626|       |             * We have no saved packet.  Allocate one.  
 6627|       |             */
 6628|      0|            if ((isp->packet = (u_char *) malloc(rxbuf_len)) == NULL) {
  ------------------
  |  Branch (6628:17): [True: 0, False: 0]
  ------------------
 6629|      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]
  |  |  ------------------
  ------------------
 6630|      0|                            "u bytes for rxbuf\n", rxbuf_len));
 6631|      0|                return 0;
 6632|      0|            } else {
 6633|      0|                rxbuf = isp->packet;
 6634|      0|                isp->packet_size = rxbuf_len;
 6635|      0|                isp->packet_len = 0;
 6636|      0|            }
 6637|      0|        } else {
 6638|       |            /*
 6639|       |             * We have saved a partial packet from last time.  Extend that, if
 6640|       |             * necessary, and receive new data after the old data.  
 6641|       |             */
 6642|      0|            u_char         *newbuf;
 6643|       |
 6644|      0|            if (isp->packet_size < isp->packet_len + rxbuf_len) {
  ------------------
  |  Branch (6644:17): [True: 0, False: 0]
  ------------------
 6645|      0|                newbuf =
 6646|      0|                    (u_char *) realloc(isp->packet,
 6647|      0|                                       isp->packet_len + rxbuf_len);
 6648|      0|                if (newbuf == NULL) {
  ------------------
  |  Branch (6648:21): [True: 0, False: 0]
  ------------------
 6649|      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]
  |  |  ------------------
  ------------------
 6650|      0|                                "can't malloc %" NETSNMP_PRIz
 6651|      0|                                "u more for rxbuf (%" NETSNMP_PRIz "u tot)\n",
 6652|      0|                                rxbuf_len, isp->packet_len + rxbuf_len));
 6653|      0|                    return 0;
 6654|      0|                } else {
 6655|      0|                    isp->packet = newbuf;
 6656|      0|                    isp->packet_size = isp->packet_len + rxbuf_len;
 6657|      0|                    rxbuf = isp->packet + isp->packet_len;
 6658|      0|                }
 6659|      0|            } else {
 6660|      0|                rxbuf = isp->packet + isp->packet_len;
 6661|      0|                rxbuf_len = isp->packet_size - isp->packet_len;
 6662|      0|            }
 6663|      0|        }
 6664|       |
 6665|      0|    length = netsnmp_transport_recv(transport, rxbuf, rxbuf_len, &opaque,
 6666|      0|                                    &olength);
 6667|       |
 6668|      0|    if (0 == length && transport->flags & NETSNMP_TRANSPORT_FLAG_EMPTY_PKT) {
  ------------------
  |  |   56|      0|#define		NETSNMP_TRANSPORT_FLAG_EMPTY_PKT 0x10
  ------------------
  |  Branch (6668:9): [True: 0, False: 0]
  |  Branch (6668:24): [True: 0, False: 0]
  ------------------
 6669|       |        /* this allows for a transport that needs to return from
 6670|       |         * packet processing that doesn't necessarily have any
 6671|       |         * consumable data in it. */
 6672|       |
 6673|       |        /* reset the flag since it's a per-message flag */
 6674|      0|        transport->flags &= (~NETSNMP_TRANSPORT_FLAG_EMPTY_PKT);
  ------------------
  |  |   56|      0|#define		NETSNMP_TRANSPORT_FLAG_EMPTY_PKT 0x10
  ------------------
 6675|       |
 6676|      0|        return 0;
 6677|      0|    }
 6678|       |
 6679|       |    /*
 6680|       |     * Remote end closed connection.  
 6681|       |     */
 6682|      0|    if (length <= 0) {
  ------------------
  |  Branch (6682:9): [True: 0, False: 0]
  ------------------
 6683|       |        /*
 6684|       |         * Alert the application if possible.  
 6685|       |         */
 6686|      0|        _sess_close_stream(slp);
 6687|      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]
  |  |  ------------------
  ------------------
 6688|      0|        return -1;
 6689|      0|    }
 6690|       |
 6691|      0|    {
 6692|      0|        u_char *pptr = isp->packet;
 6693|      0|	void *ocopy = NULL;
 6694|       |
 6695|      0|        isp->packet_len += length;
 6696|       |
 6697|      0|        while (isp->packet_len > 0) {
  ------------------
  |  Branch (6697:16): [True: 0, False: 0]
  ------------------
 6698|       |
 6699|       |            /*
 6700|       |             * Get the total data length we're expecting (and need to wait
 6701|       |             * for).
 6702|       |             */
 6703|      0|            if (isp->check_packet) {
  ------------------
  |  Branch (6703:17): [True: 0, False: 0]
  ------------------
 6704|      0|                pdulen = isp->check_packet(pptr, isp->packet_len);
 6705|      0|            } else {
 6706|      0|                pdulen = asn_check_packet(pptr, isp->packet_len);
 6707|      0|            }
 6708|       |
 6709|      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]
  |  |  ------------------
  ------------------
 6710|      0|                        "  loop packet_len %" NETSNMP_PRIz "u, PDU length %"
 6711|      0|                        NETSNMP_PRIz "u\n", isp->packet_len, pdulen));
 6712|       |
 6713|      0|            if ((int)pdulen < 0 || pdulen > SNMP_MAX_PACKET_LEN ||
  ------------------
  |  |   49|      0|#define SNMP_MAX_PACKET_LEN (0x7fffffff)
  ------------------
  |  Branch (6713:17): [True: 0, False: 0]
  |  Branch (6713:36): [True: 0, False: 0]
  ------------------
 6714|      0|                (sp->rcvMsgMaxSize && pdulen > sp->rcvMsgMaxSize)) {
  ------------------
  |  Branch (6714:18): [True: 0, False: 0]
  |  Branch (6714:39): [True: 0, False: 0]
  ------------------
 6715|       |                /*
 6716|       |                 * Illegal length, drop the connection.  
 6717|       |                 */
 6718|      0|                snmp_log(LOG_ERR, 
 6719|      0|			 "Received broken packet. Closing session.\n");
 6720|      0|                _sess_close_stream(slp);
 6721|      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]
  |  |  ------------------
  ------------------
 6722|      0|                return -1;
 6723|      0|            }
 6724|       |
 6725|      0|            if (pdulen > isp->packet_len || pdulen == 0) {
  ------------------
  |  Branch (6725:17): [True: 0, False: 0]
  |  Branch (6725:45): [True: 0, False: 0]
  ------------------
 6726|       |                /*
 6727|       |                 * We don't have a complete packet yet.  If we've already
 6728|       |                 * processed a packet, break out so we'll shift this packet
 6729|       |                 * to the start of the buffer. If we're already at the
 6730|       |                 * start, simply return and wait for more data to arrive.
 6731|       |                 */
 6732|      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]
  |  |  ------------------
  ------------------
 6733|      0|                            "pkt not complete (need %" NETSNMP_PRIz "u got %"
 6734|      0|                            NETSNMP_PRIz "u so far)\n", pdulen,
 6735|      0|                            isp->packet_len));
 6736|       |
 6737|      0|                if (pptr != isp->packet)
  ------------------
  |  Branch (6737:21): [True: 0, False: 0]
  ------------------
 6738|      0|                    break; /* opaque freed for us outside of loop. */
 6739|       |
 6740|      0|                if (!timerisset(&isp->packet_deadline))
  ------------------
  |  Branch (6740:21): [True: 0, False: 0]
  ------------------
 6741|      0|                    _sess_set_packet_deadline(isp);
 6742|      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]
  |  |  ------------------
  ------------------
 6743|      0|                return 0;
 6744|      0|            }
 6745|       |
 6746|       |            /*  We have *at least* one complete packet in the buffer now.  If
 6747|       |		we have possibly more than one packet, we must copy the opaque
 6748|       |		pointer because we may need to reuse it for a later packet.  */
 6749|       |
 6750|      0|	    if (pdulen < isp->packet_len) {
  ------------------
  |  Branch (6750:10): [True: 0, False: 0]
  ------------------
 6751|      0|		if (olength > 0 && opaque != NULL) {
  ------------------
  |  Branch (6751:7): [True: 0, False: 0]
  |  Branch (6751:22): [True: 0, False: 0]
  ------------------
 6752|      0|		    ocopy = malloc(olength);
 6753|      0|		    if (ocopy != NULL) {
  ------------------
  |  Branch (6753:11): [True: 0, False: 0]
  ------------------
 6754|      0|			memcpy(ocopy, opaque, olength);
 6755|      0|		    }
 6756|      0|		}
 6757|      0|	    } else if (pdulen == isp->packet_len) {
  ------------------
  |  Branch (6757:17): [True: 0, False: 0]
  ------------------
 6758|       |		/*  Common case -- exactly one packet.  No need to copy the
 6759|       |		    opaque pointer.  */
 6760|      0|		ocopy = opaque;
 6761|      0|		opaque = NULL;
 6762|      0|	    }
 6763|       |
 6764|      0|            if ((rc = _sess_process_packet(slp, sp, isp, transport,
  ------------------
  |  Branch (6764:17): [True: 0, False: 0]
  ------------------
 6765|      0|                                           ocopy, ocopy?olength:0, pptr,
  ------------------
  |  Branch (6765:51): [True: 0, False: 0]
  ------------------
 6766|      0|                                           pdulen))) {
 6767|       |                /*
 6768|       |                 * Something went wrong while processing this packet -- set the
 6769|       |                 * errno.  
 6770|       |                 */
 6771|      0|                if (sp->s_snmp_errno != 0) {
  ------------------
  |  Branch (6771:21): [True: 0, False: 0]
  ------------------
 6772|      0|                    SET_SNMP_ERROR(sp->s_snmp_errno);
  ------------------
  |  |   43|      0|#define SET_SNMP_ERROR(x) snmp_errno=(x)
  ------------------
 6773|      0|                }
 6774|      0|            }
 6775|      0|            timerclear(&isp->packet_deadline);
 6776|       |
 6777|       |	    /*  ocopy has been free()d by _sess_process_packet by this point,
 6778|       |		so set it to NULL.  */
 6779|       |
 6780|      0|	    ocopy = NULL;
 6781|       |
 6782|       |	    /*  Step past the packet we've just dealt with.  */
 6783|       |
 6784|      0|            pptr += pdulen;
 6785|      0|            isp->packet_len -= pdulen;
 6786|      0|        }
 6787|       |
 6788|       |	/*  If we had more than one packet, then we were working with copies
 6789|       |	    of the opaque pointer, so we still need to free() the opaque
 6790|       |	    pointer itself.  */
 6791|       |
 6792|      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]
  |  |  ------------------
  ------------------
 6793|       |
 6794|      0|        if (isp->packet_len >= stream_limit) {
  ------------------
  |  Branch (6794:13): [True: 0, False: 0]
  ------------------
 6795|       |            /*
 6796|       |             * Obviously this should never happen!  
 6797|       |             */
 6798|      0|            snmp_log(LOG_ERR,
 6799|      0|                     "too large packet_len = %" NETSNMP_PRIz
 6800|      0|                     "u, dropping connection %" NETSNMP_FMT_SKT "\n",
 6801|      0|                     isp->packet_len, transport->sock);
 6802|      0|            _sess_close_stream(slp);
 6803|      0|            return -1;
 6804|      0|        } else if (isp->packet_len == 0) {
  ------------------
  |  Branch (6804:20): [True: 0, False: 0]
  ------------------
 6805|       |            /*
 6806|       |             * This is good: it means the packet buffer contained an integral
 6807|       |             * number of PDUs, so we don't have to save any data for next
 6808|       |             * time.  We can free() the buffer now to keep the memory
 6809|       |             * footprint down.
 6810|       |             */
 6811|      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]
  |  |  ------------------
  ------------------
 6812|      0|            isp->packet_size = 0;
 6813|      0|            isp->packet_len = 0;
 6814|      0|            timerclear(&isp->packet_deadline);
 6815|      0|            return rc;
 6816|      0|        }
 6817|       |
 6818|       |        /*
 6819|       |         * If we get here, then there is a partial packet of length
 6820|       |         * isp->packet_len bytes starting at pptr left over.  Move that to the
 6821|       |         * start of the buffer, and then realloc() the buffer down to size to
 6822|       |         * reduce the memory footprint.  
 6823|       |         */
 6824|       |
 6825|      0|        memmove(isp->packet, pptr, isp->packet_len);
 6826|      0|        if (!timerisset(&isp->packet_deadline))
  ------------------
  |  Branch (6826:13): [True: 0, False: 0]
  ------------------
 6827|      0|            _sess_set_packet_deadline(isp);
 6828|      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]
  |  |  ------------------
  ------------------
 6829|      0|                    "end: memmove(%p, %p, %" NETSNMP_PRIz "u); realloc(%p, %"
 6830|      0|                    NETSNMP_PRIz "u)\n",
 6831|      0|                    isp->packet, pptr, isp->packet_len,
 6832|      0|		    isp->packet, isp->packet_len));
 6833|       |
 6834|      0|        if ((rxbuf = (u_char *)realloc(isp->packet, isp->packet_len)) == NULL) {
  ------------------
  |  Branch (6834:13): [True: 0, False: 0]
  ------------------
 6835|       |            /*
 6836|       |             * I don't see why this should ever fail, but it's not a big deal.
 6837|       |             */
 6838|      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]
  |  |  ------------------
  ------------------
 6839|      0|        } else {
 6840|      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]
  |  |  ------------------
  ------------------
 6841|      0|                        isp->packet, rxbuf));
 6842|      0|            isp->packet = rxbuf;
 6843|      0|            isp->packet_size = isp->packet_len;
 6844|      0|        }
 6845|      0|    }
 6846|       |
 6847|      0|    return rc;
 6848|      0|}
snmp_api.c:_sess_read_dgram_packet:
 6470|     57|{
 6471|     57|    netsnmp_session *sp = slp ? slp->session : NULL;
  ------------------
  |  Branch (6471:27): [True: 57, False: 0]
  ------------------
 6472|     57|    struct snmp_internal_session *isp = slp ? slp->internal : NULL;
  ------------------
  |  Branch (6472:41): [True: 57, False: 0]
  ------------------
 6473|     57|    netsnmp_transport *transport = slp ? slp->transport : NULL;
  ------------------
  |  Branch (6473:36): [True: 57, False: 0]
  ------------------
 6474|       |
 6475|     57|    if (!sp || !isp || !transport || !rcvp ) {
  ------------------
  |  Branch (6475:9): [True: 0, False: 57]
  |  Branch (6475:16): [True: 0, False: 57]
  |  Branch (6475:24): [True: 0, False: 57]
  |  Branch (6475:38): [True: 0, False: 57]
  ------------------
 6476|      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]
  |  |  ------------------
  ------------------
 6477|      0|        return -2;
 6478|      0|    }
 6479|       |
 6480|     57|    if (transport->flags & NETSNMP_TRANSPORT_FLAG_STREAM)
  ------------------
  |  |   51|     57|#define		NETSNMP_TRANSPORT_FLAG_STREAM	 0x01
  ------------------
  |  Branch (6480:9): [True: 0, False: 57]
  ------------------
 6481|      0|        return -2;
 6482|       |
 6483|     57|    if (NULL != rcvp->packet) {
  ------------------
  |  Branch (6483:9): [True: 0, False: 57]
  ------------------
 6484|      0|        snmp_log(LOG_WARNING, "overwriting existing saved packet; sess %p\n",
 6485|      0|                 sp);
 6486|      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]
  |  |  ------------------
  ------------------
 6487|      0|    }
 6488|       |
 6489|     57|    if ((rcvp->packet = (u_char *) malloc(SNMP_MAX_RCV_MSG_SIZE)) == NULL) {
  ------------------
  |  |  108|     57|#define SNMP_MAX_RCV_MSG_SIZE      65536
  ------------------
  |  Branch (6489:9): [True: 0, False: 57]
  ------------------
 6490|      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]
  |  |  ------------------
  ------------------
 6491|      0|                    SNMP_MAX_RCV_MSG_SIZE));
 6492|      0|        return -2;
 6493|      0|    }
 6494|       |
 6495|     57|    rcvp->packet_len = netsnmp_transport_recv(transport, rcvp->packet,
 6496|     57|                                              SNMP_MAX_RCV_MSG_SIZE,
  ------------------
  |  |  108|     57|#define SNMP_MAX_RCV_MSG_SIZE      65536
  ------------------
 6497|     57|                                              &rcvp->opaque, &rcvp->olength);
 6498|     57|    if (rcvp->packet_len == -1) {
  ------------------
  |  Branch (6498:9): [True: 0, False: 57]
  ------------------
 6499|      0|        sp->s_snmp_errno = SNMPERR_BAD_RECVFROM;
  ------------------
  |  |  209|      0|#define SNMPERR_BAD_RECVFROM 		(-25)
  ------------------
 6500|      0|        sp->s_errno = errno;
 6501|      0|        snmp_set_detail(strerror(errno));
 6502|      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]
  |  |  ------------------
  ------------------
 6503|      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]
  |  |  ------------------
  ------------------
 6504|      0|        return -1;
 6505|      0|    }
 6506|       |
 6507|     57|    if (0 == rcvp->packet_len &&
  ------------------
  |  Branch (6507:9): [True: 0, False: 57]
  ------------------
 6508|      0|        transport->flags & NETSNMP_TRANSPORT_FLAG_EMPTY_PKT) {
  ------------------
  |  |   56|      0|#define		NETSNMP_TRANSPORT_FLAG_EMPTY_PKT 0x10
  ------------------
  |  Branch (6508:9): [True: 0, False: 0]
  ------------------
 6509|       |        /* this allows for a transport that needs to return from
 6510|       |         * packet processing that doesn't necessarily have any
 6511|       |         * consumable data in it. */
 6512|       |
 6513|       |        /* reset the flag since it's a per-message flag */
 6514|      0|        transport->flags &= (~NETSNMP_TRANSPORT_FLAG_EMPTY_PKT);
  ------------------
  |  |   56|      0|#define		NETSNMP_TRANSPORT_FLAG_EMPTY_PKT 0x10
  ------------------
 6515|       |
 6516|       |        /** free packet */
 6517|      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]
  |  |  ------------------
  ------------------
 6518|      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]
  |  |  ------------------
  ------------------
 6519|       |
 6520|      0|        return -2;
 6521|      0|    }
 6522|       |
 6523|     57|    return 0;
 6524|     57|}
snmp_api.c:_sess_process_packet:
 6202|    118|{
 6203|    118|    netsnmp_pdu         *pdu;
 6204|    118|    int                  rc;
 6205|       |
 6206|    118|    pdu = _sess_process_packet_parse_pdu(slp, sp, isp, transport, opaque,
 6207|    118|                                         olength, packetptr, length);
 6208|    118|    if (NULL == pdu)
  ------------------
  |  Branch (6208:9): [True: 118, False: 0]
  ------------------
 6209|    118|        return -1;
 6210|       |
 6211|       |    /*
 6212|       |     * find session to process pdu. usually that will be the current session,
 6213|       |     * but with the introduction of shared transports, another session may
 6214|       |     * have the same socket.
 6215|       |     */
 6216|      0|    do {
 6217|      0|        rc = _sess_process_packet_handle_pdu(slp, sp, isp, transport, pdu);
 6218|      0|        if (-2 != rc || !(transport->flags & NETSNMP_TRANSPORT_FLAG_SHARED))
  ------------------
  |  |   58|      0|#define		NETSNMP_TRANSPORT_FLAG_SHARED	 0x40
  ------------------
  |  Branch (6218:13): [True: 0, False: 0]
  |  Branch (6218:25): [True: 0, False: 0]
  ------------------
 6219|      0|            break;
 6220|       |
 6221|       |        /** -2 means pdu not in request list. check other sessions */
 6222|      0|        do  {
 6223|      0|            slp = slp->next;
 6224|      0|        } while (slp && slp->transport->sock != transport->sock);
  ------------------
  |  Branch (6224:18): [True: 0, False: 0]
  |  Branch (6224:25): [True: 0, False: 0]
  ------------------
 6225|      0|        if (!slp)
  ------------------
  |  Branch (6225:13): [True: 0, False: 0]
  ------------------
 6226|      0|            break; /* no more sessions with same socket */
 6227|       |
 6228|      0|        sp = slp->session;
 6229|      0|        isp = slp->internal;
 6230|      0|        transport = slp->transport;
 6231|      0|    } while(slp);
  ------------------
  |  Branch (6231:13): [True: 0, False: 0]
  ------------------
 6232|       |
 6233|      0|    if (-2 == rc) { /* did not find session for pdu */
  ------------------
  |  Branch (6233:9): [True: 0, False: 0]
  ------------------
 6234|      0|        snmp_increment_statistic(STAT_SNMPUNKNOWNPDUHANDLERS);
  ------------------
  |  |  613|      0|#define   STAT_SNMPUNKNOWNPDUHANDLERS        2
  ------------------
 6235|      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]
  |  |  ------------------
  ------------------
 6236|      0|        snmp_free_pdu(pdu);
 6237|      0|    }
 6238|       |
 6239|      0|  return rc;
 6240|    118|}
snmp_api.c:_sess_process_packet_parse_pdu:
 5806|    118|{
 5807|    118|  netsnmp_pdu    *pdu;
 5808|    118|  int             ret = 0;
 5809|    118|  int             dump = 0, filter = 0;
 5810|       |
 5811|    118|  debug_indent_reset();
 5812|       |
 5813|    118|  DEBUGMSGTL(("sess_process_packet",
  ------------------
  |  |   66|    118|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    118|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 118]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 118]
  |  |  ------------------
  ------------------
 5814|    118|	      "session %p fd %" NETSNMP_FMT_SKT " pkt %p length %d\n", slp,
 5815|    118|	      transport->sock, packetptr, length));
 5816|       |
 5817|    118|  dump = netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|    118|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 5818|    118|                                NETSNMP_DS_LIB_DUMP_PACKET);
  ------------------
  |  |   63|    118|#define NETSNMP_DS_LIB_DUMP_PACKET         4
  ------------------
 5819|    118|#ifndef NETSNMP_FEATURE_REMOVE_FILTER_SOURCE
 5820|    118|  filter = netsnmp_ds_get_int(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|    118|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 5821|    118|                                  NETSNMP_DS_LIB_FILTER_TYPE);
  ------------------
  |  |  133|    118|#define NETSNMP_DS_LIB_FILTER_TYPE         17 /* 0=NONE, 1=whitelist, -1=blacklist */
  ------------------
 5822|    118|#endif
 5823|    118|  if (dump || filter) {
  ------------------
  |  Branch (5823:7): [True: 0, False: 118]
  |  Branch (5823:15): [True: 0, False: 118]
  ------------------
 5824|      0|      int filtered = 0;
 5825|      0|      char *addrtxt = netsnmp_transport_peer_string(transport, opaque, olength);
 5826|       |
 5827|      0|      if (!addrtxt) {
  ------------------
  |  Branch (5827:11): [True: 0, False: 0]
  ------------------
 5828|      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]
  |  |  ------------------
  ------------------
 5829|      0|                      "Failed to resolve peer address\n"));
 5830|      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]
  |  |  ------------------
  ------------------
 5831|      0|          return NULL;
 5832|      0|      }
 5833|       |
 5834|      0|      snmp_log(LOG_DEBUG, "\nReceived %d byte packet from %s\n",
 5835|      0|               length, addrtxt);
 5836|       |
 5837|      0|      if (dump)
  ------------------
  |  Branch (5837:11): [True: 0, False: 0]
  ------------------
 5838|      0|          xdump(packetptr, length, "");
 5839|       |
 5840|      0|#ifndef NETSNMP_FEATURE_REMOVE_FILTER_SOURCE
 5841|      0|      if (filter) {
  ------------------
  |  Branch (5841:11): [True: 0, False: 0]
  ------------------
 5842|      0|          char *sourceaddr = NULL, *c = strchr(addrtxt, '[');
 5843|      0|          const char *dropstr = NULL;
 5844|      0|          if (c) {
  ------------------
  |  Branch (5844:15): [True: 0, False: 0]
  ------------------
 5845|      0|              sourceaddr = ++c;
 5846|      0|              c = strchr(sourceaddr, ']');
 5847|      0|              if (c)
  ------------------
  |  Branch (5847:19): [True: 0, False: 0]
  ------------------
 5848|      0|                  *c = 0;
 5849|      0|              filtered = netsnmp_transport_filter_check(sourceaddr);
 5850|      0|          }
 5851|      0|          else if (!strncmp(addrtxt, "callback", 8)) {
  ------------------
  |  Branch (5851:20): [True: 0, False: 0]
  ------------------
 5852|       |              /* do not filter internal request */
 5853|      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]
  |  |  ------------------
  ------------------
 5854|      0|                          "bypass packet from %s \n",
 5855|      0|                          addrtxt));
 5856|      0|              filtered = 1;
 5857|      0|          }
 5858|      0|          if ((filter == -1) && filtered)
  ------------------
  |  Branch (5858:15): [True: 0, False: 0]
  |  Branch (5858:33): [True: 0, False: 0]
  ------------------
 5859|      0|              dropstr = "matched blacklist";
 5860|      0|          else if ((filter == 1) && !filtered)
  ------------------
  |  Branch (5860:20): [True: 0, False: 0]
  |  Branch (5860:37): [True: 0, False: 0]
  ------------------
 5861|      0|              dropstr = "didn't match whitelist";
 5862|      0|          if (dropstr) {
  ------------------
  |  Branch (5862:15): [True: 0, False: 0]
  ------------------
 5863|      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]
  |  |  ------------------
  ------------------
 5864|      0|                          "packet from %s %s\n",
 5865|      0|                          sourceaddr ? sourceaddr : "UNKNOWN", dropstr));
 5866|      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]
  |  |  ------------------
  ------------------
 5867|      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]
  |  |  ------------------
  ------------------
 5868|      0|              return NULL;
 5869|      0|          }
 5870|      0|      }
 5871|      0|#endif
 5872|       |
 5873|      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]
  |  |  ------------------
  ------------------
 5874|      0|  }
 5875|       |
 5876|       |  /*
 5877|       |   * Do transport-level filtering (e.g. IP-address based allow/deny).  
 5878|       |   */
 5879|       |
 5880|    118|  if (isp->hook_pre) {
  ------------------
  |  Branch (5880:7): [True: 0, False: 118]
  ------------------
 5881|      0|    if (isp->hook_pre(sp, transport, opaque, olength) == 0) {
  ------------------
  |  Branch (5881:9): [True: 0, False: 0]
  ------------------
 5882|      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]
  |  |  ------------------
  ------------------
 5883|      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]
  |  |  ------------------
  ------------------
 5884|      0|      return NULL;
 5885|      0|    }
 5886|      0|  }
 5887|       |
 5888|    118|  if (isp->hook_create_pdu) {
  ------------------
  |  Branch (5888:7): [True: 0, False: 118]
  ------------------
 5889|      0|    pdu = isp->hook_create_pdu(transport, opaque, olength);
 5890|    118|  } else {
 5891|    118|    pdu = snmp_create_sess_pdu(transport, opaque, olength);
 5892|    118|  }
 5893|       |
 5894|    118|  if (pdu == NULL) {
  ------------------
  |  Branch (5894:7): [True: 0, False: 118]
  ------------------
 5895|      0|    snmp_log(LOG_ERR, "pdu failed to be created\n");
 5896|      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]
  |  |  ------------------
  ------------------
 5897|      0|    return NULL;
 5898|      0|  }
 5899|       |
 5900|       |  /* if the transport was a magic tunnel, mark the PDU as having come
 5901|       |     through one. */
 5902|    118|  if (transport->flags & NETSNMP_TRANSPORT_FLAG_TUNNELED) {
  ------------------
  |  |   53|    118|#define		NETSNMP_TRANSPORT_FLAG_TUNNELED	 0x04
  ------------------
  |  Branch (5902:7): [True: 0, False: 118]
  ------------------
 5903|      0|      pdu->flags |= UCD_MSG_FLAG_TUNNELED;
  ------------------
  |  |  317|      0|#define UCD_MSG_FLAG_TUNNELED               0x4000
  ------------------
 5904|      0|  }
 5905|       |
 5906|    118|  if (isp->hook_parse) {
  ------------------
  |  Branch (5906:7): [True: 0, False: 118]
  ------------------
 5907|      0|    ret = isp->hook_parse(sp, pdu, packetptr, length);
 5908|    118|  } else {
 5909|    118|    ret = snmp_parse(slp, sp, pdu, packetptr, length);
 5910|    118|  }
 5911|       |
 5912|    118|  DEBUGMSGTL(("sess_process_packet", "received message id#%ld reqid#%ld len "
  ------------------
  |  |   66|    118|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    118|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 118]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 118]
  |  |  ------------------
  ------------------
 5913|    118|              "%u\n", pdu->msgid, pdu->reqid, length));
 5914|       |
 5915|    118|  if (ret != SNMP_ERR_NOERROR) {
  ------------------
  |  |  212|    118|#define SNMP_ERR_NOERROR                (0)     /* XXX  Used only for PDUs? */
  ------------------
  |  Branch (5915:7): [True: 118, False: 0]
  ------------------
 5916|    118|    DEBUGMSGTL(("sess_process_packet", "parse fail\n"));
  ------------------
  |  |   66|    118|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    118|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 118]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 118]
  |  |  ------------------
  ------------------
 5917|    118|  }
 5918|       |
 5919|    118|  if (isp->hook_post) {
  ------------------
  |  Branch (5919:7): [True: 0, False: 118]
  ------------------
 5920|      0|    if (isp->hook_post(sp, pdu, ret) == 0) {
  ------------------
  |  Branch (5920:9): [True: 0, False: 0]
  ------------------
 5921|      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]
  |  |  ------------------
  ------------------
 5922|      0|      ret = SNMPERR_ASN_PARSE_ERR;
  ------------------
  |  |  213|      0|#define SNMPERR_ASN_PARSE_ERR           (-29)
  ------------------
 5923|      0|    }
 5924|      0|  }
 5925|       |
 5926|    118|  if (ret != SNMP_ERR_NOERROR) {
  ------------------
  |  |  212|    118|#define SNMP_ERR_NOERROR                (0)     /* XXX  Used only for PDUs? */
  ------------------
  |  Branch (5926:7): [True: 118, False: 0]
  ------------------
 5927|    118|    snmp_free_pdu(pdu);
 5928|    118|    return NULL;
 5929|    118|  }
 5930|       |
 5931|      0|  return pdu;
 5932|    118|}

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

netsnmp_query_shutdown:
 1268|     58|netsnmp_query_shutdown(void) {
 1269|     58|    if (_def_query_session) {
  ------------------
  |  Branch (1269:9): [True: 0, False: 58]
  ------------------
 1270|      0|        snmp_close(_def_query_session);
 1271|       |        _def_query_session = NULL;
 1272|      0|    }
 1273|     58|}

debug_indent_reset:
  112|    118|{
  113|    118|    if (debugindent != 0)
  ------------------
  |  Branch (113:9): [True: 0, False: 118]
  ------------------
  114|      0|        DEBUGMSGTL(("dump_indent","indent reset from %d\n", debugindent));
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
  115|    118|    debugindent = 0;
  116|    118|}
debug_is_token_registered:
  303|     57|{
  304|     57|    int             i, rc;
  305|       |
  306|       |    /*
  307|       |     * debugging flag is on or off
  308|       |     */
  309|     57|    if (!dodebug)
  ------------------
  |  Branch (309:9): [True: 57, False: 0]
  ------------------
  310|     57|        return SNMPERR_GENERR;
  ------------------
  |  |  185|     57|#define SNMPERR_GENERR			(-1)
  ------------------
  311|       |
  312|      0|    if (debug_num_tokens == 0 || debug_print_everything) {
  ------------------
  |  Branch (312:9): [True: 0, False: 0]
  |  Branch (312:34): [True: 0, False: 0]
  ------------------
  313|       |        /*
  314|       |         * no tokens specified, print everything
  315|       |         */
  316|      0|        return SNMPERR_SUCCESS;
  ------------------
  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  317|      0|    }
  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|}
snmp_get_do_debugging:
  551|  30.6k|{
  552|  30.6k|    return dodebug;
  553|  30.6k|}
snmp_debug_shutdown:
  569|     58|{
  570|     58|    int i;
  571|       |
  572|     58|    for (i = 0; i < debug_num_tokens; i++)
  ------------------
  |  Branch (572:17): [True: 0, False: 58]
  ------------------
  573|       |       SNMP_FREE(dbg_tokens[i].token_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]
  |  |  ------------------
  ------------------
  574|     58|}
snmp_debug_init:
  722|     58|{
  723|       |#ifdef HAVE_WOLFSSL_WOLFCRYPT_LOGGING_H
  724|       |    wolfSSL_Debugging_ON();
  725|       |    wolfSSL_SetLoggingCb(snmp_log_wolfssl_msg);
  726|       |#endif
  727|       |
  728|     58|    register_prenetsnmp_mib_handler("snmp", "doDebugging",
  729|     58|                                    debug_config_turn_on_debugging, NULL,
  730|     58|                                    "(1|0)");
  731|     58|    register_prenetsnmp_mib_handler("snmp", "debugTokens",
  732|     58|                                    debug_config_register_tokens, NULL,
  733|     58|                                    "token[,token...]");
  734|     58|#ifndef NETSNMP_DISABLE_DYNAMIC_LOG_LEVEL
  735|     58|    register_prenetsnmp_mib_handler("snmp", "debugLogLevel",
  736|       |                                    debug_config_debug_log_level, NULL,
  737|     58|                                    "(emerg|alert|crit|err|warning|notice|info|debug)");
  738|     58|#endif /* NETSNMP_DISABLE_DYNAMIC_LOG_LEVEL */
  739|     58|}

init_snmp_enum:
   54|     58|{
   55|     58|    if (NULL != snmp_enum_lists)
  ------------------
  |  Branch (55:9): [True: 0, False: 58]
  ------------------
   56|      0|        return SE_OK;
  ------------------
  |  |   42|      0|#define SE_OK            0
  ------------------
   57|       |
   58|     58|    snmp_enum_lists = calloc(SE_MAX_IDS * SE_MAX_SUBIDS,
  ------------------
  |  |   21|     58|#define SE_MAX_IDS 5
  ------------------
                  snmp_enum_lists = calloc(SE_MAX_IDS * SE_MAX_SUBIDS,
  ------------------
  |  |   22|     58|#define SE_MAX_SUBIDS 32        /* needs to be a multiple of 8 */
  ------------------
   59|     58|                             sizeof(*snmp_enum_lists));
   60|     58|    if (!snmp_enum_lists)
  ------------------
  |  Branch (60:9): [True: 0, False: 58]
  ------------------
   61|      0|        return SE_NOMEM;
  ------------------
  |  |   43|      0|#define SE_NOMEM         1
  ------------------
   62|     58|    current_maj_num = SE_MAX_IDS;
  ------------------
  |  |   21|     58|#define SE_MAX_IDS 5
  ------------------
   63|     58|    current_min_num = SE_MAX_SUBIDS;
  ------------------
  |  |   22|     58|#define SE_MAX_SUBIDS 32        /* needs to be a multiple of 8 */
  ------------------
   64|       |
   65|     58|    register_const_config_handler(type, "enum", se_read_conf, NULL, NULL);
   66|     58|    return SE_OK;
  ------------------
  |  |   42|     58|#define SE_OK            0
  ------------------
   67|     58|}
se_add_pair_to_list:
  269|  1.62k|{
  270|  1.62k|    struct snmp_enum_list *lastnode = NULL, *new_node, *tmp;
  271|       |
  272|  1.62k|    if (!list) {
  ------------------
  |  Branch (272:9): [True: 0, False: 1.62k]
  ------------------
  273|      0|        free(label);
  274|      0|        return SE_DNE;
  ------------------
  |  |   45|      0|#define SE_DNE           -2
  ------------------
  275|      0|    }
  276|       |
  277|  1.62k|    tmp = *list;
  278|  4.87k|    while (tmp) {
  ------------------
  |  Branch (278:12): [True: 3.48k, False: 1.39k]
  ------------------
  279|  3.48k|        if (tmp->value == value) {
  ------------------
  |  Branch (279:13): [True: 232, False: 3.24k]
  ------------------
  280|    232|            free(label);
  281|    232|            return (SE_ALREADY_THERE);
  ------------------
  |  |   44|    232|#define SE_ALREADY_THERE 2
  ------------------
  282|    232|        }
  283|  3.24k|        lastnode = tmp;
  284|  3.24k|        tmp = tmp->next;
  285|  3.24k|    }
  286|       |
  287|  1.39k|    new_node = SNMP_MALLOC_STRUCT(snmp_enum_list);
  ------------------
  |  |   69|  1.39k|#define SNMP_MALLOC_STRUCT(s)   (struct s *) calloc(1, sizeof(struct s))
  ------------------
  288|  1.39k|    if (!new_node) {
  ------------------
  |  Branch (288:9): [True: 0, False: 1.39k]
  ------------------
  289|      0|        free(label);
  290|      0|        return (SE_NOMEM);
  ------------------
  |  |   43|      0|#define SE_NOMEM         1
  ------------------
  291|      0|    }
  292|       |
  293|  1.39k|    if (lastnode)
  ------------------
  |  Branch (293:9): [True: 1.10k, False: 290]
  ------------------
  294|  1.10k|        lastnode->next = new_node;
  295|    290|    else
  296|    290|        *list = new_node;
  297|  1.39k|    new_node->label = label;
  298|  1.39k|    new_node->value = value;
  299|  1.39k|    new_node->next = NULL;
  300|  1.39k|    return (SE_OK);
  ------------------
  |  |   42|  1.39k|#define SE_OK            0
  ------------------
  301|  1.39k|}
se_add_pair_to_slist:
  365|  1.62k|{
  366|  1.62k|    struct snmp_enum_list **list_p = se_find_slist_ptr(listname);
  367|       |
  368|  1.62k|    if (!list_p) {
  ------------------
  |  Branch (368:9): [True: 290, False: 1.33k]
  ------------------
  369|    290|        struct snmp_enum_list_str *sptr =
  370|    290|            SNMP_MALLOC_STRUCT(snmp_enum_list_str);
  ------------------
  |  |   69|    290|#define SNMP_MALLOC_STRUCT(s)   (struct s *) calloc(1, sizeof(struct s))
  ------------------
  371|    290|        if (!sptr) {
  ------------------
  |  Branch (371:13): [True: 0, False: 290]
  ------------------
  372|      0|            free(label);
  373|      0|            return SE_NOMEM;
  ------------------
  |  |   43|      0|#define SE_NOMEM         1
  ------------------
  374|      0|        }
  375|    290|        sptr->next = sliststorage;
  376|    290|        sptr->name = strdup(listname);
  377|    290|        if (!sptr->name) {
  ------------------
  |  Branch (377:13): [True: 0, False: 290]
  ------------------
  378|      0|            free(sptr);
  379|      0|            free(label);
  380|      0|            return SE_NOMEM;
  ------------------
  |  |   43|      0|#define SE_NOMEM         1
  ------------------
  381|      0|        }
  382|    290|        list_p = &sptr->list;
  383|    290|        sliststorage = sptr;
  384|    290|    }
  385|       |
  386|  1.62k|    return se_add_pair_to_list(list_p, label, value);
  387|  1.62k|}
clear_snmp_enum:
  404|     58|{
  405|     58|    struct snmp_enum_list_str *sptr = sliststorage, *next = NULL;
  406|     58|    unsigned int major, minor;
  407|       |
  408|    348|    while (sptr != NULL) {
  ------------------
  |  Branch (408:12): [True: 290, False: 58]
  ------------------
  409|    290|	next = sptr->next;
  410|    290|	free_enum_list(sptr->list);
  411|    290|	SNMP_FREE(sptr->name);
  ------------------
  |  |   62|    290|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 290, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 290]
  |  |  ------------------
  ------------------
  412|    290|	SNMP_FREE(sptr);
  ------------------
  |  |   62|    290|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 290, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 290]
  |  |  ------------------
  ------------------
  413|    290|	sptr = next;
  414|    290|    }
  415|     58|    sliststorage = NULL;
  416|       |
  417|    348|    for (major = 0; major < current_maj_num; major++) {
  ------------------
  |  Branch (417:21): [True: 290, False: 58]
  ------------------
  418|  9.57k|        for (minor = 0; minor < current_min_num; minor++) {
  ------------------
  |  Branch (418:25): [True: 9.28k, False: 290]
  ------------------
  419|  9.28k|            struct snmp_enum_list **list_ptr = se_find_list_ptr(major, minor);
  420|       |
  421|  9.28k|            if (!list_ptr || !*list_ptr)
  ------------------
  |  Branch (421:17): [True: 0, False: 9.28k]
  |  Branch (421:30): [True: 9.28k, False: 0]
  ------------------
  422|  9.28k|                continue;
  423|      0|            free_enum_list(*list_ptr);
  424|      0|        }
  425|    290|    }
  426|     58|    current_maj_num = 0;
  427|     58|    current_min_num = 0;
  428|       |    SNMP_FREE(snmp_enum_lists);
  ------------------
  |  |   62|     58|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 58, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 58]
  |  |  ------------------
  ------------------
  429|     58|}
snmp_enum.c:se_find_list_ptr:
  174|  9.28k|{
  175|  9.28k|    if (major >= current_maj_num || minor >= current_min_num)
  ------------------
  |  Branch (175:9): [True: 0, False: 9.28k]
  |  Branch (175:37): [True: 0, False: 9.28k]
  ------------------
  176|      0|        return NULL;
  177|  9.28k|    netsnmp_assert(NULL != snmp_enum_lists);
  ------------------
  |  |   47|  9.28k|#      define netsnmp_assert(x)  do { \
  |  |   48|  9.28k|              if ( x ) \
  |  |  ------------------
  |  |  |  Branch (48:20): [True: 9.28k, False: 0]
  |  |  ------------------
  |  |   49|  9.28k|                 ; \
  |  |   50|  9.28k|              else \
  |  |   51|  9.28k|                 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
  |  |  |  |  ------------------
  |  |  |  |  |  | 1727|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|  9.28k|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded, False: 9.28k]
  |  |  ------------------
  ------------------
  178|       |
  179|  9.28k|    return &snmp_enum_lists[major * current_min_num + minor];
  180|  9.28k|}
snmp_enum.c:se_find_slist_ptr:
  314|  1.62k|{
  315|  1.62k|    struct snmp_enum_list_str *sptr;
  316|  1.62k|    if (!listname)
  ------------------
  |  Branch (316:9): [True: 0, False: 1.62k]
  ------------------
  317|      0|        return NULL;
  318|       |
  319|  2.20k|    for (sptr = sliststorage; sptr != NULL; sptr = sptr->next)
  ------------------
  |  Branch (319:31): [True: 1.91k, False: 290]
  ------------------
  320|  1.91k|        if (sptr->name && strcmp(sptr->name, listname) == 0)
  ------------------
  |  Branch (320:13): [True: 1.91k, False: 0]
  |  Branch (320:27): [True: 1.33k, False: 580]
  ------------------
  321|  1.33k|            return &sptr->list;
  322|       |
  323|    290|    return NULL;
  324|  1.62k|}
snmp_enum.c:free_enum_list:
  391|    290|{
  392|    290|    struct snmp_enum_list *next;
  393|       |
  394|  1.68k|    while (list) {
  ------------------
  |  Branch (394:12): [True: 1.39k, False: 290]
  ------------------
  395|  1.39k|        next = list->next;
  396|  1.39k|        SNMP_FREE(list->label);
  ------------------
  |  |   62|  1.39k|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 1.39k, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 1.39k]
  |  |  ------------------
  ------------------
  397|       |        SNMP_FREE(list);
  ------------------
  |  |   62|  1.39k|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 1.39k, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 1.39k]
  |  |  ------------------
  ------------------
  398|  1.39k|        list = next;
  399|  1.39k|    }
  400|    290|}

init_snmp_logging:
  168|     58|{
  169|     58|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "logTimestamp", 
  ------------------
  |  |   72|     58|#define ASN_BOOLEAN	    0x01U
  ------------------
  170|     58|			 NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_LOG_TIMESTAMP);
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              			 NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_LOG_TIMESTAMP);
  ------------------
  |  |   64|     58|#define NETSNMP_DS_LIB_LOG_TIMESTAMP       5
  ------------------
  171|     58|    register_prenetsnmp_mib_handler("snmp", "logOption",
  172|     58|                                    parse_config_logOption, NULL, "string");
  173|       |
  174|     58|}
shutdown_snmp_logging:
  178|     58|{
  179|     58|   snmp_disable_log();
  180|     58|   while(NULL != logh_head)
  ------------------
  |  Branch (180:10): [True: 0, False: 58]
  ------------------
  181|      0|      netsnmp_remove_loghandler( logh_head );
  182|     58|}
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|}
snmp_disable_log:
  692|     58|{
  693|     58|    netsnmp_log_handler *logh;
  694|       |
  695|     58|    for (logh = logh_head; logh; logh = logh->next) {
  ------------------
  |  Branch (695:28): [True: 0, False: 58]
  ------------------
  696|      0|#ifndef NETSNMP_FEATURE_REMOVE_LOGGING_SYSLOG
  697|      0|        if (logh->type == NETSNMP_LOGHANDLER_SYSLOG)
  ------------------
  |  |   72|      0|#define NETSNMP_LOGHANDLER_SYSLOG	4
  ------------------
  |  Branch (697:13): [True: 0, False: 0]
  ------------------
  698|      0|            snmp_disable_syslog_entry(logh);
  699|      0|#endif /* NETSNMP_FEATURE_REMOVE_LOGGING_SYSLOG */
  700|      0|#ifndef NETSNMP_FEATURE_REMOVE_LOGGING_FILE
  701|      0|        if (logh->type == NETSNMP_LOGHANDLER_FILE)
  ------------------
  |  |   71|      0|#define NETSNMP_LOGHANDLER_FILE		3
  ------------------
  |  Branch (701:13): [True: 0, False: 0]
  ------------------
  702|      0|            snmp_disable_filelog_entry(logh);
  703|      0|#endif /* NETSNMP_FEATURE_REMOVE_LOGGING_FILE */
  704|      0|        netsnmp_disable_this_loghandler(logh);
  705|      0|    }
  706|     58|}
log_handler_stdouterr:
 1103|  2.84k|{
 1104|  2.84k|    static int      newline = 1;	 /* MTCRITICAL_RESOURCE */
 1105|  2.84k|    const char     *newline_ptr;
 1106|  2.84k|    char            sbuf[40];
 1107|       |
 1108|  2.84k|    if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|  2.84k|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (1108:9): [True: 0, False: 2.84k]
  ------------------
 1109|  2.84k|                               NETSNMP_DS_LIB_LOG_TIMESTAMP) && newline) {
  ------------------
  |  |   64|  2.84k|#define NETSNMP_DS_LIB_LOG_TIMESTAMP       5
  ------------------
  |  Branch (1109:65): [True: 0, False: 0]
  ------------------
 1110|      0|        snprintf_stamp(NULL, sbuf, sizeof(sbuf));
 1111|  2.84k|    } else {
 1112|  2.84k|        strcpy(sbuf, "");
 1113|  2.84k|    }
 1114|       |    /*
 1115|       |     * Remember whether or not the current line ends with a newline for the
 1116|       |     * next call of log_handler_stdouterr().
 1117|       |     */
 1118|  2.84k|    newline_ptr = strrchr(str, '\n');
 1119|  2.84k|    newline = newline_ptr && newline_ptr[1] == 0;
  ------------------
  |  Branch (1119:15): [True: 2.84k, False: 0]
  |  Branch (1119:30): [True: 2.84k, False: 0]
  ------------------
 1120|       |
 1121|  2.84k|    if (logh->imagic)
  ------------------
  |  Branch (1121:9): [True: 0, False: 2.84k]
  ------------------
 1122|      0|       printf(         "%s%s", sbuf, str);
 1123|  2.84k|    else
 1124|  2.84k|       fprintf(stderr, "%s%s", sbuf, str);
 1125|       |
 1126|  2.84k|    return 1;
 1127|  2.84k|}
snmp_log_string:
 1294|  2.84k|{
 1295|  2.84k|#ifndef NETSNMP_FEATURE_REMOVE_LOGGING_STDIO
 1296|  2.84k|    static int stderr_enabled = 0;
 1297|  2.84k|    static netsnmp_log_handler lh = { 1, 0, 0, 0, "stderr",
 1298|  2.84k|                                      log_handler_stdouterr, 0, NULL,  NULL,
 1299|  2.84k|                                      NULL };
 1300|  2.84k|#endif /* NETSNMP_FEATURE_REMOVE_LOGGING_STDIO */
 1301|  2.84k|    netsnmp_log_handler *logh;
 1302|       |
 1303|       |    /*
 1304|       |     * We've got to be able to log messages *somewhere*!
 1305|       |     * If you don't want stderr logging, then enable something else.
 1306|       |     */
 1307|  2.84k|    if (0 == logh_enabled) {
  ------------------
  |  Branch (1307:9): [True: 2.84k, False: 0]
  ------------------
 1308|  2.84k|#ifndef NETSNMP_FEATURE_REMOVE_LOGGING_STDIO
 1309|  2.84k|        if (!stderr_enabled) {
  ------------------
  |  Branch (1309:13): [True: 1, False: 2.84k]
  ------------------
 1310|      1|            ++stderr_enabled;
 1311|      1|            netsnmp_set_line_buffering(stderr);
 1312|      1|        }
 1313|  2.84k|        log_handler_stdouterr( &lh, priority, str );
 1314|  2.84k|#endif /* NETSNMP_FEATURE_REMOVE_LOGGING_STDIO */
 1315|       |
 1316|  2.84k|        return;
 1317|  2.84k|    }
 1318|      0|#ifndef NETSNMP_FEATURE_REMOVE_LOGGING_STDIO
 1319|      0|    else if (stderr_enabled) {
  ------------------
  |  Branch (1319:14): [True: 0, False: 0]
  ------------------
 1320|      0|        stderr_enabled = 0;
 1321|      0|        log_handler_stdouterr( &lh, LOG_INFO,
 1322|      0|                               "Log handling defined - disabling stderr\n" );
 1323|      0|    }
 1324|      0|#endif /* NETSNMP_FEATURE_REMOVE_LOGGING_STDIO */
 1325|       |        
 1326|       |
 1327|       |    /*
 1328|       |     * Start at the given priority, and work "upwards"....
 1329|       |     */
 1330|      0|    if (priority < LOG_EMERG)
  ------------------
  |  Branch (1330:9): [True: 0, False: 0]
  ------------------
 1331|      0|        priority = LOG_EMERG;
 1332|      0|    else if (priority > LOG_DEBUG)
  ------------------
  |  Branch (1332:14): [True: 0, False: 0]
  ------------------
 1333|      0|        priority = LOG_DEBUG;
 1334|      0|    logh = logh_priorities[priority];
 1335|      0|    for ( ; logh; logh = logh->next ) {
  ------------------
  |  Branch (1335:13): [True: 0, False: 0]
  ------------------
 1336|       |        /*
 1337|       |         * ... but skipping any handlers with a "maximum priority"
 1338|       |         *     that we have already exceeded. And don't forget to
 1339|       |         *     ensure this logging is turned on (see snmp_disable_stderrlog
 1340|       |         *     and its cohorts).
 1341|       |         */
 1342|      0|        if (logh->enabled && priority >= logh->pri_max)
  ------------------
  |  Branch (1342:13): [True: 0, False: 0]
  |  Branch (1342:30): [True: 0, False: 0]
  ------------------
 1343|      0|            logh->handler( logh, priority, str );
 1344|      0|    }
 1345|      0|}
snmp_vlog:
 1383|  2.84k|{
 1384|  2.84k|    char           *buffer = NULL;
 1385|  2.84k|    int             length;
 1386|       |
 1387|  2.84k|    length = vasprintf(&buffer, format, ap);
 1388|  2.84k|    if (length < 0) {
  ------------------
  |  Branch (1388:9): [True: 0, False: 2.84k]
  ------------------
 1389|      0|        snmp_log_string(LOG_ERR, "Could not format log-string\n");
 1390|      0|        return -1;
 1391|      0|    }
 1392|       |
 1393|  2.84k|    snmp_log_string(priority, buffer);
 1394|  2.84k|    free(buffer);
 1395|  2.84k|    return 0;
 1396|  2.84k|}
snmp_log:
 1407|  2.84k|{
 1408|  2.84k|    va_list         ap;
 1409|  2.84k|    int             ret;
 1410|  2.84k|    va_start(ap, format);
 1411|  2.84k|    ret = snmp_vlog(priority, format, ap);
 1412|       |    va_end(ap);
 1413|  2.84k|    return (ret);
 1414|  2.84k|}

netsnmp_init_openssl:
  118|     59|void netsnmp_init_openssl(void) {
  119|       |
  120|       |    /* avoid duplicate calls */
  121|     59|    if (have_started_already)
  ------------------
  |  Branch (121:9): [True: 58, False: 1]
  ------------------
  122|     58|        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|}

init_secmod:
   48|     58|{
   49|     58|    snmp_register_callback(SNMP_CALLBACK_LIBRARY,
  ------------------
  |  |   18|     58|#define SNMP_CALLBACK_LIBRARY     0
  ------------------
   50|     58|                           SNMP_CALLBACK_SESSION_INIT, set_default_secmod,
  ------------------
  |  |   29|     58|#define SNMP_CALLBACK_SESSION_INIT		5
  ------------------
   51|     58|                           NULL);
   52|       |
   53|     58|    netsnmp_ds_register_config(ASN_OCTET_STR, "snmp", "defSecurityModel",
  ------------------
  |  |   78|     58|#define ASN_OCTET_STR	    0x04U
  ------------------
   54|     58|			       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_SECMODEL);
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              			       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_SECMODEL);
  ------------------
  |  |  161|     58|#define NETSNMP_DS_LIB_SECMODEL          10
  ------------------
   55|       |    /*
   56|       |     * this file is generated by configure for all the stuff we're using 
   57|       |     */
   58|     58|#include "snmpsm_init.h"
  ------------------
  |  |    1|       |/* This file is automatically generated by configure.  Do not modify by hand. */
  |  |    2|     58|init_usm();
  |  |    3|     58|init_tsm();
  |  |    4|     58|init_ksm();
  ------------------
   59|     58|}
shutdown_secmod:
   63|     58|{
   64|     58|    #include "snmpsm_shutdown.h"
  ------------------
  |  |    1|       |/* This file is automatically generated by configure.  Do not modify by hand. */
  |  |    2|     58|shutdown_usm();
  |  |    3|     58|shutdown_tsm();
  |  |    4|     58|shutdown_ksm();
  ------------------
   65|     58|}
register_sec_mod:
   70|    174|{
   71|    174|    int             result = 0;
   72|    174|    struct snmp_secmod_list *sptr;
   73|    174|    char           *othername, *modname2 = NULL;
   74|       |
   75|    348|    for (sptr = registered_services; sptr; sptr = sptr->next) {
  ------------------
  |  Branch (75:38): [True: 174, False: 174]
  ------------------
   76|    174|        if (sptr->securityModel == secmod) {
  ------------------
  |  Branch (76:13): [True: 0, False: 174]
  ------------------
   77|      0|            return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
   78|      0|        }
   79|    174|    }
   80|    174|    sptr = SNMP_MALLOC_STRUCT(snmp_secmod_list);
  ------------------
  |  |   69|    174|#define SNMP_MALLOC_STRUCT(s)   (struct s *) calloc(1, sizeof(struct s))
  ------------------
   81|    174|    if (sptr == NULL)
  ------------------
  |  Branch (81:9): [True: 0, False: 174]
  ------------------
   82|      0|        return SNMPERR_MALLOC;
  ------------------
  |  |  246|      0|#define SNMPERR_MALLOC			(-62)
  ------------------
   83|    174|    sptr->secDef = newdef;
   84|    174|    sptr->securityModel = secmod;
   85|    174|    sptr->next = registered_services;
   86|    174|    registered_services = sptr;
   87|    174|    modname2 = strdup(modname);
   88|    174|    if (!modname2)
  ------------------
  |  Branch (88:9): [True: 0, False: 174]
  ------------------
   89|      0|        result = SE_NOMEM;
  ------------------
  |  |   43|      0|#define SE_NOMEM         1
  ------------------
   90|    174|    else
   91|    174|        result = se_add_pair_to_slist("snmp_secmods", modname2, secmod);
   92|    174|    if (result != SE_OK) {
  ------------------
  |  |   42|    174|#define SE_OK            0
  ------------------
  |  Branch (92:9): [True: 0, False: 174]
  ------------------
   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|    174|    return SNMPERR_SUCCESS;
  ------------------
  |  |  184|    174|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  115|    174|}
unregister_sec_mod:
  121|     58|{
  122|     58|    struct snmp_secmod_list *sptr, *lptr;
  123|       |
  124|     58|    for (sptr = registered_services, lptr = NULL; sptr;
  ------------------
  |  Branch (124:51): [True: 0, False: 58]
  ------------------
  125|     58|         lptr = sptr, sptr = sptr->next) {
  126|      0|        if (sptr->securityModel == secmod) {
  ------------------
  |  Branch (126:13): [True: 0, False: 0]
  ------------------
  127|      0|            if ( lptr )
  ------------------
  |  Branch (127:18): [True: 0, False: 0]
  ------------------
  128|      0|                lptr->next = sptr->next;
  129|      0|            else
  130|      0|                registered_services = sptr->next;
  131|      0|	    SNMP_FREE(sptr->secDef);
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
  132|      0|            SNMP_FREE(sptr);
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
  133|      0|            return SNMPERR_SUCCESS;
  ------------------
  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  134|      0|        }
  135|      0|    }
  136|       |    /*
  137|       |     * not registered 
  138|       |     */
  139|     58|    return SNMPERR_GENERR;
  ------------------
  |  |  185|     58|#define SNMPERR_GENERR			(-1)
  ------------------
  140|     58|}
clear_sec_mod:
  145|     58|{
  146|     58|    struct snmp_secmod_list *tmp = registered_services, *next = NULL;
  147|       |
  148|    232|    while (tmp != NULL) {
  ------------------
  |  Branch (148:12): [True: 174, False: 58]
  ------------------
  149|    174|	next = tmp->next;
  150|    174|	SNMP_FREE(tmp->secDef);
  ------------------
  |  |   62|    174|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 174, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 174]
  |  |  ------------------
  ------------------
  151|    174|	SNMP_FREE(tmp);
  ------------------
  |  |   62|    174|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 174, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 174]
  |  |  ------------------
  ------------------
  152|    174|	tmp = next;
  153|    174|    }
  154|       |    registered_services = NULL;
  155|     58|}
find_sec_mod:
  160|    258|{
  161|    258|    struct snmp_secmod_list *sptr;
  162|       |
  163|    910|    for (sptr = registered_services; sptr; sptr = sptr->next) {
  ------------------
  |  Branch (163:38): [True: 774, False: 136]
  ------------------
  164|    774|        if (sptr->securityModel == secmod) {
  ------------------
  |  Branch (164:13): [True: 122, False: 652]
  ------------------
  165|    122|            return sptr->secDef;
  166|    122|        }
  167|    774|    }
  168|       |    /*
  169|       |     * not registered 
  170|       |     */
  171|    136|    return NULL;
  172|    258|}
snmp_secmod.c:set_default_secmod:
  189|     58|{
  190|     58|    netsnmp_session *sess = (netsnmp_session *) serverarg;
  191|     58|    char           *cptr;
  192|     58|    int             model;
  193|       |
  194|     58|    if (!sess)
  ------------------
  |  Branch (194:9): [True: 0, False: 58]
  ------------------
  195|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  196|     58|    if (sess->securityModel == SNMP_DEFAULT_SECMODEL) {
  ------------------
  |  |   91|     58|#define SNMP_DEFAULT_SECMODEL	    -1
  ------------------
  |  Branch (196:9): [True: 58, False: 0]
  ------------------
  197|     58|        if ((cptr = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (197:13): [True: 0, False: 58]
  ------------------
  198|     58|					  NETSNMP_DS_LIB_SECMODEL)) != NULL) {
  ------------------
  |  |  161|     58|#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|     58|        } else {
  210|     58|            sess->securityModel = NETSNMP_SECMOD_DEFAULT_MODEL;
  ------------------
  |  |  177|     58|#define NETSNMP_SECMOD_DEFAULT_MODEL  USM_SEC_MODEL_NUMBER
  |  |  ------------------
  |  |  |  |   40|     58|#define USM_SEC_MODEL_NUMBER            SNMP_SEC_MODEL_USM
  |  |  |  |  ------------------
  |  |  |  |  |  |  295|     58|#define SNMP_SEC_MODEL_USM		3
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  211|     58|        }
  212|     58|    }
  213|     58|    return SNMPERR_SUCCESS;
  ------------------
  |  |  184|     58|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  214|     58|}

netsnmp_register_default_domain:
   60|    116|{
   61|    116|    struct netsnmp_lookup_domain *run = domains, *prev = NULL;
   62|    116|    int res = 0;
   63|       |
   64|    174|    while (run != NULL && strcmp(run->application, application) < 0) {
  ------------------
  |  Branch (64:12): [True: 58, False: 116]
  |  Branch (64:27): [True: 58, False: 0]
  ------------------
   65|     58|	prev = run;
   66|     58|	run = run->next;
   67|     58|    }
   68|    116|    if (run && strcmp(run->application, application) == 0) {
  ------------------
  |  Branch (68:9): [True: 0, False: 116]
  |  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|    116|    } else {
   75|    116|	run = SNMP_MALLOC_STRUCT(netsnmp_lookup_domain);
  ------------------
  |  |   69|    116|#define SNMP_MALLOC_STRUCT(s)   (struct s *) calloc(1, sizeof(struct s))
  ------------------
   76|    116|	run->application = strdup(application);
   77|    116|	run->userDomain = NULL;
   78|    116|	if (prev) {
  ------------------
  |  Branch (78:6): [True: 58, False: 58]
  ------------------
   79|     58|	    run->next = prev->next;
   80|     58|	    prev->next = run;
   81|     58|	} else {
   82|     58|	    run->next = domains;
   83|     58|	    domains = run;
   84|     58|	}
   85|    116|    }
   86|    116|    if (domain) {
  ------------------
  |  Branch (86:9): [True: 116, False: 0]
  ------------------
   87|    116|        run->domain = create_word_array(domain);
   88|    116|    } 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|    116|    return res;
   97|    116|}
netsnmp_clear_default_domain:
  101|     58|{
  102|    174|    while (domains) {
  ------------------
  |  Branch (102:12): [True: 116, False: 58]
  ------------------
  103|    116|	struct netsnmp_lookup_domain *tmp = domains;
  104|    116|	domains = domains->next;
  105|    116|	free(tmp->application);
  106|    116|        destroy_word_array(tmp->userDomain);
  107|    116|        destroy_word_array(tmp->domain);
  108|    116|	free(tmp);
  109|    116|    }
  110|     58|}
netsnmp_lookup_default_domains:
  186|     58|{
  187|     58|    const char * const * res;
  188|       |
  189|     58|    if (application == NULL)
  ------------------
  |  Branch (189:9): [True: 0, False: 58]
  ------------------
  190|      0|	res = NULL;
  191|     58|    else {
  192|     58|        struct netsnmp_lookup_domain *run = domains;
  193|       |
  194|    174|	while (run && strcmp(run->application, application) < 0)
  ------------------
  |  Branch (194:9): [True: 116, False: 58]
  |  Branch (194:16): [True: 116, False: 0]
  ------------------
  195|    116|	    run = run->next;
  196|     58|	if (run && strcmp(run->application, application) == 0)
  ------------------
  |  Branch (196:6): [True: 0, False: 58]
  |  Branch (196:13): [True: 0, False: 0]
  ------------------
  197|      0|	    if (run->userDomain)
  ------------------
  |  Branch (197:10): [True: 0, False: 0]
  ------------------
  198|      0|                res = (const char * const *)run->userDomain;
  199|      0|	    else
  200|      0|                res = (const char * const *)run->domain;
  201|     58|	else
  202|     58|	    res = NULL;
  203|     58|    }
  204|     58|    DEBUGMSGTL(("defaults",
  ------------------
  |  |   66|     58|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     58|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 58]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 58]
  |  |  ------------------
  ------------------
  205|     58|                "netsnmp_lookup_default_domain(\"%s\") ->",
  206|     58|                application ? application : "[NIL]"));
  207|     58|    if (res) {
  ------------------
  |  Branch (207:9): [True: 0, False: 58]
  ------------------
  208|      0|        const char * const * r = res;
  209|      0|        while(*r) {
  ------------------
  |  Branch (209:15): [True: 0, False: 0]
  ------------------
  210|      0|            DEBUGMSG(("defaults", " \"%s\"", *r));
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
  211|      0|            ++r;
  212|      0|        }
  213|      0|        DEBUGMSG(("defaults", "\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]
  |  |  ------------------
  ------------------
  214|      0|    } else
  215|     58|        DEBUGMSG(("defaults", " \"[NIL]\"\n"));
  ------------------
  |  |   61|     58|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  144|     58|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 58]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (61:67): [Folded, False: 58]
  |  |  ------------------
  ------------------
  216|     58|    return res;
  217|     58|}
netsnmp_register_default_target:
  248|    812|{
  249|    812|    struct netsnmp_lookup_target *run = targets, *prev = NULL;
  250|    812|    int i = 0, res = 0;
  251|  4.46k|    while (run && ((i = strcmp(run->application, application)) < 0 ||
  ------------------
  |  Branch (251:12): [True: 4.23k, False: 232]
  |  Branch (251:20): [True: 2.84k, False: 1.39k]
  ------------------
  252|  3.65k|		   (i == 0 && strcmp(run->domain, domain) < 0))) {
  ------------------
  |  Branch (252:7): [True: 1.39k, False: 0]
  |  Branch (252:17): [True: 812, False: 580]
  ------------------
  253|  3.65k|	prev = run;
  254|  3.65k|	run = run->next;
  255|  3.65k|    }
  256|    812|    if (run && i == 0 && strcmp(run->domain, domain) == 0) {
  ------------------
  |  Branch (256:9): [True: 580, False: 232]
  |  Branch (256:16): [True: 580, False: 0]
  |  Branch (256:26): [True: 0, False: 580]
  ------------------
  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|    812|    } else {
  263|    812|	run = SNMP_MALLOC_STRUCT(netsnmp_lookup_target);
  ------------------
  |  |   69|    812|#define SNMP_MALLOC_STRUCT(s)   (struct s *) calloc(1, sizeof(struct s))
  ------------------
  264|    812|	run->application = strdup(application);
  265|    812|	run->domain = strdup(domain);
  266|    812|	run->userTarget = NULL;
  267|    812|	if (prev) {
  ------------------
  |  Branch (267:6): [True: 638, False: 174]
  ------------------
  268|    638|	    run->next = prev->next;
  269|    638|	    prev->next = run;
  270|    638|	} else {
  271|    174|	    run->next = targets;
  272|    174|	    targets = run;
  273|    174|	}
  274|    812|    }
  275|    812|    if (target) {
  ------------------
  |  Branch (275:9): [True: 812, False: 0]
  ------------------
  276|    812|	run->target = strdup(target);
  277|    812|    } 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|    812|    return res;
  287|    812|}
netsnmp_clear_default_target:
  294|     58|{
  295|    870|    while (targets) {
  ------------------
  |  Branch (295:12): [True: 812, False: 58]
  ------------------
  296|    812|	struct netsnmp_lookup_target *tmp = targets;
  297|    812|	targets = targets->next;
  298|    812|	free(tmp->application);
  299|    812|	free(tmp->domain);
  300|    812|	free(tmp->userTarget);
  301|    812|	free(tmp->target);
  302|    812|	free(tmp);
  303|    812|    }
  304|     58|}
netsnmp_lookup_default_target:
  397|     58|{
  398|     58|    int i = 0;
  399|     58|    struct netsnmp_lookup_target *run = targets;
  400|     58|    const char *res;
  401|       |
  402|     58|    if (application == NULL || domain == NULL)
  ------------------
  |  Branch (402:9): [True: 0, False: 58]
  |  Branch (402:32): [True: 0, False: 58]
  ------------------
  403|      0|	res = NULL;
  404|     58|    else {
  405|    870|	while (run && ((i = strcmp(run->application, application)) < 0 ||
  ------------------
  |  Branch (405:9): [True: 812, False: 58]
  |  Branch (405:17): [True: 812, False: 0]
  ------------------
  406|      0|		       (i == 0 && strcmp(run->domain, domain) < 0)))
  ------------------
  |  Branch (406:11): [True: 0, False: 0]
  |  Branch (406:21): [True: 0, False: 0]
  ------------------
  407|    812|	    run = run->next;
  408|     58|	if (run && i == 0 && strcmp(run->domain, domain) == 0)
  ------------------
  |  Branch (408:6): [True: 0, False: 58]
  |  Branch (408:13): [True: 0, False: 0]
  |  Branch (408:23): [True: 0, False: 0]
  ------------------
  409|      0|	    if (run->userTarget != NULL)
  ------------------
  |  Branch (409:10): [True: 0, False: 0]
  ------------------
  410|      0|		res = run->userTarget;
  411|      0|	    else
  412|      0|		res = run->target;
  413|     58|	else
  414|     58|	    res = NULL;
  415|     58|    }
  416|     58|    DEBUGMSGTL(("defaults",
  ------------------
  |  |   66|     58|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     58|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 58]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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:52): [True: 0, False: 0]
  |  |  |  |  |  Branch (164:52): [True: 0, False: 0]
  |  |  |  |  |  Branch (164:64): [True: 0, False: 0]
  |  |  |  |  |  Branch (164:64): [True: 0, False: 0]
  |  |  |  |  |  Branch (164:64): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 58]
  |  |  ------------------
  ------------------
  417|     58|		"netsnmp_lookup_default_target(\"%s\", \"%s\") -> \"%s\"\n",
  418|     58|		application ? application : "[NIL]",
  419|     58|		domain ? domain : "[NIL]",
  420|     58|		res ? res : "[NIL]"));
  421|     58|    return res;
  422|     58|}
netsnmp_register_service_handlers:
  426|     58|{
  427|     58|    register_config_handler("snmp:", "defDomain",
  428|     58|			    netsnmp_register_user_domain,
  429|     58|			    netsnmp_clear_user_domain,
  430|     58|			    "application domain");
  431|     58|    register_config_handler("snmp:", "defTarget",
  432|     58|			    netsnmp_register_user_target,
  433|     58|			    netsnmp_clear_user_target,
  434|     58|			    "application domain target");
  435|     58|}
snmp_service.c:destroy_word_array:
   38|    232|{
   39|    232|    if (arr) {
  ------------------
  |  Branch (39:9): [True: 116, False: 116]
  ------------------
   40|    116|        char** run = arr;
   41|    348|        while(*run) {
  ------------------
  |  Branch (41:15): [True: 232, False: 116]
  ------------------
   42|    232|            free(*run);
   43|    232|            ++run;
   44|    232|        }
   45|    116|        free(arr);
   46|    116|    }
   47|    232|}
snmp_service.c:create_word_array:
   28|    116|{
   29|    116|    size_t tmplen = strlen(cptr);
   30|    116|    char* tmp = (char*)malloc(tmplen + 1);
   31|    116|    char** res = create_word_array_helper(cptr, 0, tmp, tmplen + 1);
   32|    116|    free(tmp);
   33|    116|    return res;
   34|    116|}
snmp_service.c:create_word_array_helper:
   11|    232|{
   12|    232|    char* item;
   13|    232|    char** res;
   14|    232|    cptr = copy_nword_const(cptr, tmp, tmplen);
   15|    232|    item = strdup(tmp);
   16|    232|    if (cptr)
  ------------------
  |  Branch (16:9): [True: 116, False: 116]
  ------------------
   17|    116|        res = create_word_array_helper(cptr, idx + 1, tmp, tmplen);
   18|    116|    else {
   19|    116|        res = (char**)malloc(sizeof(char*) * (idx + 2));
   20|       |        res[idx + 1] = NULL;
   21|    116|    }
   22|    232|    res[idx] = item;
   23|    232|    return res;
   24|    232|}
snmp_service.c:netsnmp_clear_user_domain:
  161|    232|{
  162|    232|    struct netsnmp_lookup_domain *run = domains, *prev = NULL;
  163|       |
  164|    696|    while (run) {
  ------------------
  |  Branch (164:12): [True: 464, False: 232]
  ------------------
  165|    464|	if (run->userDomain != NULL) {
  ------------------
  |  Branch (165:6): [True: 0, False: 464]
  ------------------
  166|      0|            destroy_word_array(run->userDomain);
  167|      0|	    run->userDomain = NULL;
  168|      0|	}
  169|    464|	if (run->domain == NULL) {
  ------------------
  |  Branch (169:6): [True: 0, False: 464]
  ------------------
  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|    464|	} else {
  178|    464|	    prev = run;
  179|    464|	    run = run->next;
  180|    464|	}
  181|    464|    }
  182|    232|}
snmp_service.c:netsnmp_clear_user_target:
  371|    232|{
  372|    232|    struct netsnmp_lookup_target *run = targets, *prev = NULL;
  373|       |
  374|  3.48k|    while (run) {
  ------------------
  |  Branch (374:12): [True: 3.24k, False: 232]
  ------------------
  375|  3.24k|	if (run->userTarget != NULL) {
  ------------------
  |  Branch (375:6): [True: 0, False: 3.24k]
  ------------------
  376|      0|	    free(run->userTarget);
  377|      0|	    run->userTarget = NULL;
  378|      0|	}
  379|  3.24k|	if (run->target == NULL) {
  ------------------
  |  Branch (379:6): [True: 0, False: 3.24k]
  ------------------
  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|  3.24k|	} else {
  389|  3.24k|	    prev = run;
  390|  3.24k|	    run = run->next;
  391|  3.24k|	}
  392|  3.24k|    }
  393|    232|}

init_snmp_transport:
  124|     58|{
  125|     58|    netsnmp_ds_register_config(ASN_BOOLEAN,
  ------------------
  |  |   72|     58|#define ASN_BOOLEAN	    0x01U
  ------------------
  126|     58|                               "snmp", "dontLoadHostConfig",
  127|     58|                               NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  128|     58|                               NETSNMP_DS_LIB_DONT_LOAD_HOST_FILES);
  ------------------
  |  |  100|     58|#define NETSNMP_DS_LIB_DONT_LOAD_HOST_FILES 40 /* don't read host.conf files */
  ------------------
  129|     58|#ifndef NETSNMP_FEATURE_REMOVE_FILTER_SOURCE
  130|     58|    register_app_config_handler("sourceFilterType",
  131|     58|                                netsnmp_transport_parse_filterType,
  132|       |                                NULL, "none|whitelist|blacklist");
  133|     58|    register_app_config_handler("sourceFilterAddress",
  134|     58|                                netsnmp_transport_parse_filter,
  135|     58|                                netsnmp_transport_filter_cleanup,
  136|     58|                                "host");
  137|     58|#endif /* NETSNMP_FEATURE_REMOVE_FILTER_SOURCE */
  138|     58|}
shutdown_snmp_transport:
  142|     58|{
  143|     58|#ifndef NETSNMP_FEATURE_REMOVE_FILTER_SOURCE
  144|     58|    netsnmp_transport_filter_cleanup();
  145|     58|#endif
  146|     58|}
netsnmp_transport_alloc:
  231|     58|{
  232|     58|    netsnmp_transport *transport;
  233|       |
  234|     58|    transport = SNMP_MALLOC_TYPEDEF(netsnmp_transport);
  ------------------
  |  |   73|     58|#define SNMP_MALLOC_TYPEDEF(td)  (td *) calloc(1, sizeof(td))
  ------------------
  235|     58|    if (!transport)
  ------------------
  |  Branch (235:9): [True: 0, False: 58]
  ------------------
  236|      0|        return NULL;
  237|     58|    transport->sock = NETSNMP_INVALID_SOCKET;
  ------------------
  |  |   43|     58|#define NETSNMP_INVALID_SOCKET -1
  ------------------
  238|     58|    return transport;
  239|     58|}
netsnmp_transport_free:
  243|    116|{
  244|    116|    if (NULL == t)
  ------------------
  |  Branch (244:9): [True: 58, False: 58]
  ------------------
  245|     58|        return;
  246|       |
  247|     58|#ifndef FEATURE_REMOVE_TRANSPORT_CACHE
  248|       |    /** don't free a transport that is currently shared */
  249|     58|    if (netsnmp_transport_cache_remove(t) == 1)
  ------------------
  |  Branch (249:9): [True: 0, False: 58]
  ------------------
  250|      0|        return;
  251|     58|#endif
  252|       |
  253|     58|    SNMP_FREE(t->local);
  ------------------
  |  |   62|     58|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 58, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 58]
  |  |  ------------------
  ------------------
  254|     58|    SNMP_FREE(t->remote);
  ------------------
  |  |   62|     58|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 58]
  |  |  |  Branch (62:66): [Folded, False: 58]
  |  |  ------------------
  ------------------
  255|     58|    SNMP_FREE(t->data);
  ------------------
  |  |   62|     58|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 58]
  |  |  |  Branch (62:66): [Folded, False: 58]
  |  |  ------------------
  ------------------
  256|     58|    netsnmp_transport_free(t->base_transport);
  257|       |
  258|       |    SNMP_FREE(t);
  ------------------
  |  |   62|     58|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 58, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 58]
  |  |  ------------------
  ------------------
  259|     58|}
netsnmp_transport_filter_cleanup:
  381|    232|{
  382|    232|    if (NULL == filtered)
  ------------------
  |  Branch (382:9): [True: 232, False: 0]
  ------------------
  383|    232|        return;
  384|      0|    CONTAINER_CLEAR(filtered, filtered->free_item, NULL);
  385|      0|    CONTAINER_FREE(filtered);
  386|       |    filtered = NULL;
  387|      0|}
netsnmp_transport_recv:
  450|     57|{
  451|     57|    int debugLength;
  452|       |
  453|     57|    if ((NULL == t) || (NULL == t->f_recv)) {
  ------------------
  |  Branch (453:9): [True: 0, False: 57]
  |  Branch (453:24): [True: 0, False: 57]
  ------------------
  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|     57|    length = t->f_recv(t, packet, length, opaque, olength);
  459|       |
  460|     57|    if (length <=0)
  ------------------
  |  Branch (460:9): [True: 0, False: 57]
  ------------------
  461|      0|        return length; /* don't log timeouts/socket closed */
  462|       |
  463|     57|    debugLength = (SNMPERR_SUCCESS ==
  ------------------
  |  |  184|     57|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  464|     57|                   debug_is_token_registered("transport:recv"));
  465|       |
  466|     57|    if (debugLength) {
  ------------------
  |  Branch (466:9): [True: 0, False: 57]
  ------------------
  467|      0|        char *str = netsnmp_transport_peer_string(t,
  468|      0|                                                  opaque ? *opaque : NULL,
  ------------------
  |  Branch (468:51): [True: 0, False: 0]
  ------------------
  469|      0|                                                  olength ? *olength : 0);
  ------------------
  |  Branch (469:51): [True: 0, False: 0]
  ------------------
  470|      0|        DEBUGMSGT_NC(("transport:recv","%d bytes from %s\n", length, str));
  ------------------
  |  |   85|      0|#define DEBUGMSGT_NC(x) do { __DBGMSGT_NC(x); }while(0)
  |  |  ------------------
  |  |  |  |  149|      0|#define __DBGMSGT_NC(x)  debug_combo_nc x
  |  |  ------------------
  |  |  |  Branch (85:54): [Folded, False: 0]
  |  |  ------------------
  ------------------
  471|      0|        SNMP_FREE(str);
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
  472|      0|    }
  473|       |
  474|     57|    return length;
  475|     57|}
netsnmp_tdomain_init:
  503|     58|{
  504|     58|    DEBUGMSGTL(("tdomain", "netsnmp_tdomain_init() called\n"));
  ------------------
  |  |   66|     58|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     58|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 58]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 58]
  |  |  ------------------
  ------------------
  505|       |
  506|       |/* include the configure generated list of constructor calls */
  507|     58|#include "transports/snmp_transport_inits.h"
  ------------------
  |  |    1|       |/* This file is automatically generated by configure.  Do not modify by hand. */
  |  |    2|     58|netsnmp_tlsbase_ctor();
  |  |    3|     58|netsnmp_tlstcp_ctor();
  |  |    4|     58|netsnmp_dtlsudp_ctor();
  |  |    5|     58|netsnmp_udpshared_ctor();
  |  |    6|     58|netsnmp_std_ctor();
  |  |    7|     58|netsnmp_ipx_ctor();
  |  |    8|     58|netsnmp_aal5pvc_ctor();
  |  |    9|     58|netsnmp_udpipv6_ctor();
  |  |   10|     58|netsnmp_tcpipv6_ctor();
  |  |   11|     58|netsnmp_udp_ctor();
  |  |   12|     58|netsnmp_tcp_ctor();
  |  |   13|     58|netsnmp_alias_ctor();
  |  |   14|     58|netsnmp_unix_ctor();
  ------------------
  508|       |
  509|     58|    netsnmp_tdomain_dump();
  510|       |
  511|       |
  512|     58|}
netsnmp_clear_tdomain_list:
  516|     58|{
  517|     58|    netsnmp_tdomain *list = domain_list, *next = NULL;
  518|     58|    DEBUGMSGTL(("tdomain", "clear_tdomain_list() called\n"));
  ------------------
  |  |   66|     58|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     58|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 58]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 58]
  |  |  ------------------
  ------------------
  519|       |
  520|    697|    while (list != NULL) {
  ------------------
  |  Branch (520:12): [True: 639, False: 58]
  ------------------
  521|    639|	next = list->next;
  522|    639|	SNMP_FREE(list->prefix);
  ------------------
  |  |   62|    639|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 639, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 639]
  |  |  ------------------
  ------------------
  523|       |        /* attention!! list itself is not in the heap, so we must not free it! */
  524|    639|	list = next;
  525|    639|    }
  526|       |    domain_list = NULL;
  527|     58|}
netsnmp_tdomain_register:
  554|    639|{
  555|    639|    netsnmp_tdomain **prevNext = &domain_list, *d;
  556|       |
  557|    639|    if (n != NULL) {
  ------------------
  |  Branch (557:9): [True: 639, False: 0]
  ------------------
  558|  3.84k|        for (d = domain_list; d != NULL; d = d->next) {
  ------------------
  |  Branch (558:31): [True: 3.20k, False: 639]
  ------------------
  559|  3.20k|            if (netsnmp_oid_equals(n->name, n->name_length,
  ------------------
  |  Branch (559:17): [True: 0, False: 3.20k]
  ------------------
  560|  3.20k|                                d->name, d->name_length) == 0) {
  561|       |                /*
  562|       |                 * Already registered.  
  563|       |                 */
  564|      0|                return 0;
  565|      0|            }
  566|  3.20k|            prevNext = &(d->next);
  567|  3.20k|        }
  568|    639|        n->next = NULL;
  569|    639|        *prevNext = n;
  570|    639|        return 1;
  571|    639|    } else {
  572|      0|        return 0;
  573|      0|    }
  574|    639|}
netsnmp_tdomain_transport_tspec:
  643|     58|{
  644|     58|    const char *application, *str, *default_domain, *default_target, *source;
  645|     58|    int local;
  646|     58|    netsnmp_tdomain    *match = NULL;
  647|     58|    const char         *addr = NULL;
  648|     58|    const char * const *spec = NULL;
  649|     58|    int                 any_found = 0;
  650|     58|    char buf[SNMP_MAXPATH];
  651|     58|    const char **lspec = NULL;
  652|     58|    char *tokenized_domain = NULL;
  653|       |
  654|     58|    application = tspec->application;
  655|     58|    str = tspec->target;
  656|     58|    local = tspec->flags & NETSNMP_TSPEC_LOCAL;
  ------------------
  |  |  117|     58|#define NETSNMP_TSPEC_LOCAL                     0x01 /* 1=server, 0=client */
  ------------------
  657|     58|    default_domain = tspec->default_domain;
  658|     58|    default_target = tspec->default_target;
  659|     58|    source = tspec->source;
  660|       |    /** transport_config = tspec->transport_config; not used yet */
  661|       |
  662|     58|    DEBUGMSGTL(("tdomain",
  ------------------
  |  |   66|     58|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     58|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 58]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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:52): [True: 0, False: 0]
  |  |  |  |  |  Branch (164:52): [True: 0, False: 0]
  |  |  |  |  |  Branch (164:52): [True: 0, False: 0]
  |  |  |  |  |  Branch (164:64): [True: 0, False: 0]
  |  |  |  |  |  Branch (164:64): [True: 0, False: 0]
  |  |  |  |  |  Branch (164:64): [True: 0, False: 0]
  |  |  |  |  |  Branch (164:64): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 58]
  |  |  ------------------
  ------------------
  663|     58|                "tdomain_transport_spec(\"%s\", \"%s\", %d, \"%s\", \"%s\", \"%s\")\n",
  664|     58|                application, str ? str : "[NIL]", local,
  665|     58|                default_domain ? default_domain : "[NIL]",
  666|     58|                default_target ? default_target : "[NIL]",
  667|     58|                source ? source : "[NIL]"));
  668|       |
  669|       |    /* see if we can load a host-name specific set of conf files */
  670|     58|    if (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (670:9): [True: 58, False: 0]
  ------------------
  671|     58|                                NETSNMP_DS_LIB_DONT_LOAD_HOST_FILES) &&
  ------------------
  |  |  100|     58|#define NETSNMP_DS_LIB_DONT_LOAD_HOST_FILES 40 /* don't read host.conf files */
  ------------------
  672|     58|        netsnmp_is_fqdn(str)) {
  ------------------
  |  Branch (672:9): [True: 0, False: 58]
  ------------------
  673|      0|        static int have_added_handler = 0;
  674|      0|        char *newhost;
  675|      0|        struct config_line *config_handlers;
  676|      0|        struct config_files file_names;
  677|      0|        char *prev_hostname;
  678|       |
  679|       |        /* register a "transport" specifier */
  680|      0|        if (!have_added_handler) {
  ------------------
  |  Branch (680:13): [True: 0, False: 0]
  ------------------
  681|      0|            have_added_handler = 1;
  682|      0|            netsnmp_ds_register_config(ASN_OCTET_STR,
  ------------------
  |  |   78|      0|#define ASN_OCTET_STR	    0x04U
  ------------------
  683|      0|                                       "snmp", "transport",
  684|      0|                                       NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      0|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  685|      0|                                       NETSNMP_DS_LIB_HOSTNAME);
  ------------------
  |  |  178|      0|#define NETSNMP_DS_LIB_HOSTNAME          27
  ------------------
  686|      0|        }
  687|       |
  688|       |        /* we save on specific setting that we don't allow to change
  689|       |           from one transport creation to the next; ie, we don't want
  690|       |           the "transport" specifier to be a default.  It should be a
  691|       |           single invocation use only */
  692|      0|        prev_hostname = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      0|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  693|      0|                                              NETSNMP_DS_LIB_HOSTNAME);
  ------------------
  |  |  178|      0|#define NETSNMP_DS_LIB_HOSTNAME          27
  ------------------
  694|      0|        if (prev_hostname)
  ------------------
  |  Branch (694:13): [True: 0, False: 0]
  ------------------
  695|      0|            prev_hostname = strdup(prev_hostname);
  696|       |
  697|       |        /* read in the hosts/STRING.conf files */
  698|      0|        config_handlers = read_config_get_handlers("snmp");
  699|      0|        snprintf(buf, sizeof(buf)-1, "hosts/%s", str);
  700|      0|        file_names.fileHeader = buf;
  701|      0|        file_names.start = config_handlers;
  702|      0|        file_names.next = NULL;
  703|      0|        DEBUGMSGTL(("tdomain", "checking for host specific config %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]
  |  |  ------------------
  ------------------
  704|      0|                    buf));
  705|      0|        read_config_files_of_type(EITHER_CONFIG, &file_names);
  ------------------
  |  |   16|      0|#define EITHER_CONFIG 2
  ------------------
  706|       |
  707|      0|        if (NULL !=
  ------------------
  |  Branch (707:13): [True: 0, False: 0]
  ------------------
  708|      0|            (newhost = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      0|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  709|      0|                                             NETSNMP_DS_LIB_HOSTNAME))) {
  ------------------
  |  |  178|      0|#define NETSNMP_DS_LIB_HOSTNAME          27
  ------------------
  710|      0|            strlcpy(buf, newhost, sizeof(buf));
  711|      0|            str = buf;
  712|      0|        }
  713|       |
  714|      0|        netsnmp_ds_set_string(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      0|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  715|      0|                              NETSNMP_DS_LIB_HOSTNAME,
  ------------------
  |  |  178|      0|#define NETSNMP_DS_LIB_HOSTNAME          27
  ------------------
  716|      0|                              prev_hostname);
  717|      0|        SNMP_FREE(prev_hostname);
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
  718|      0|    }
  719|       |
  720|       |    /* First try - assume that there is a domain in str (domain:target) */
  721|       |
  722|     58|    if (str != NULL) {
  ------------------
  |  Branch (722:9): [True: 58, False: 0]
  ------------------
  723|     58|        const char *cp;
  724|     58|        if ((cp = strchr(str, ':')) != NULL) {
  ------------------
  |  Branch (724:13): [True: 58, False: 0]
  ------------------
  725|     58|            char* mystring = (char*)malloc(cp + 1 - str);
  726|     58|            if (mystring == NULL)
  ------------------
  |  Branch (726:17): [True: 0, False: 58]
  ------------------
  727|      0|                return NULL;
  728|     58|            memcpy(mystring, str, cp - str);
  729|     58|            mystring[cp - str] = '\0';
  730|     58|            addr = cp + 1;
  731|       |
  732|     58|            match = find_tdomain(mystring);
  733|     58|            free(mystring);
  734|     58|        }
  735|     58|    }
  736|       |
  737|       |    /*
  738|       |     * Second try, if there is no domain in str (target), then try the
  739|       |     * default domain
  740|       |     */
  741|       |
  742|     58|    if (match == NULL) {
  ------------------
  |  Branch (742:9): [True: 58, False: 0]
  ------------------
  743|     58|        addr = str;
  744|     58|        if (addr && *addr == '/') {
  ------------------
  |  Branch (744:13): [True: 58, False: 0]
  |  Branch (744:21): [True: 0, False: 58]
  ------------------
  745|      0|            DEBUGMSGTL(("tdomain",
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
  746|      0|                        "Address starts with '/', so assume \"unix\" "
  747|      0|                        "domain\n"));
  748|      0|            match = find_tdomain("unix");
  749|     58|        } else if (default_domain) {
  ------------------
  |  Branch (749:20): [True: 0, False: 58]
  ------------------
  750|      0|            DEBUGMSGTL(("tdomain",
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
  751|      0|                        "Use user specified default domain \"%s\"\n",
  752|      0|                        default_domain));
  753|      0|            if (!strchr(default_domain, ','))
  ------------------
  |  Branch (753:17): [True: 0, False: 0]
  ------------------
  754|      0|                match = find_tdomain(default_domain);
  755|      0|            else {
  756|      0|                int commas = 0;
  757|      0|                const char *cp = default_domain;
  758|      0|                char *ptr = NULL;
  759|      0|                tokenized_domain = strdup(default_domain);
  760|      0|                if (!tokenized_domain)
  ------------------
  |  Branch (760:21): [True: 0, False: 0]
  ------------------
  761|      0|                    return NULL;
  762|       |
  763|      0|                while (*++cp) if (*cp == ',') commas++;
  ------------------
  |  Branch (763:24): [True: 0, False: 0]
  |  Branch (763:35): [True: 0, False: 0]
  ------------------
  764|      0|                lspec = calloc(commas+2, sizeof(char *));
  765|      0|                if (!lspec) {
  ------------------
  |  Branch (765:21): [True: 0, False: 0]
  ------------------
  766|      0|                    free(tokenized_domain);
  767|      0|                    return NULL;
  768|      0|                }
  769|      0|                commas = 1;
  770|      0|                lspec[0] = strtok_r(tokenized_domain, ",", &ptr);
  771|      0|                while ((lspec[commas++] = strtok_r(NULL, ",", &ptr)))
  ------------------
  |  Branch (771:24): [True: 0, False: 0]
  ------------------
  772|      0|                    ;
  773|      0|                spec = lspec;
  774|      0|            }
  775|     58|        } else {
  776|     58|            spec = netsnmp_lookup_default_domains(application);
  777|     58|            if (spec == NULL) {
  ------------------
  |  Branch (777:17): [True: 58, False: 0]
  ------------------
  778|     58|                DEBUGMSGTL(("tdomain",
  ------------------
  |  |   66|     58|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     58|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 58]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 58]
  |  |  ------------------
  ------------------
  779|     58|                            "No default domain found, assume \"udp\"\n"));
  780|     58|                match = find_tdomain("udp");
  781|     58|            } else {
  782|      0|                const char * const * r = spec;
  783|      0|                DEBUGMSGTL(("tdomain",
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
  784|      0|                            "Use application default domains"));
  785|      0|                while(*r) {
  ------------------
  |  Branch (785:23): [True: 0, False: 0]
  ------------------
  786|      0|                    DEBUGMSG(("tdomain", " \"%s\"", *r));
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
  787|      0|                    ++r;
  788|      0|                }
  789|      0|                DEBUGMSG(("tdomain", "\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]
  |  |  ------------------
  ------------------
  790|      0|            }
  791|     58|        }
  792|     58|    }
  793|       |
  794|     58|    for(;;) {
  795|     58|        if (match) {
  ------------------
  |  Branch (795:13): [True: 58, False: 0]
  ------------------
  796|     58|            netsnmp_transport *t = NULL;
  797|     58|            const char* addr2;
  798|       |
  799|     58|            any_found = 1;
  800|       |            /*
  801|       |             * Ok, we know what domain to try, lets see what default data
  802|       |             * should be used with it
  803|       |             */
  804|     58|            if (default_target != NULL)
  ------------------
  |  Branch (804:17): [True: 0, False: 58]
  ------------------
  805|      0|                addr2 = default_target;
  806|     58|            else
  807|     58|                addr2 = netsnmp_lookup_default_target(application,
  808|     58|                                                      match->prefix[0]);
  809|     58|            DEBUGMSGTL(("tdomain",
  ------------------
  |  |   66|     58|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     58|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 58]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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:52): [True: 0, False: 0]
  |  |  |  |  |  Branch (164:64): [True: 0, False: 0]
  |  |  |  |  |  Branch (164:64): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 58]
  |  |  ------------------
  ------------------
  810|     58|                        "trying domain \"%s\" address \"%s\" "
  811|     58|                        "default address \"%s\"\n",
  812|     58|                        match->prefix[0], addr ? addr : "[NIL]",
  813|     58|                        addr2 ? addr2 : "[NIL]"));
  814|     58|            if (match->f_create_from_tspec) {
  ------------------
  |  Branch (814:17): [True: 58, False: 0]
  ------------------
  815|     58|                netsnmp_tdomain_spec tspec_tmp;
  816|     58|                memcpy(&tspec_tmp, tspec, sizeof(tspec_tmp));
  817|       |                /** if we didn't have a default target but looked one up,
  818|       |                 *  copy the spec and use the found default. */
  819|     58|                if ((default_target == NULL) && (addr2 != NULL))
  ------------------
  |  Branch (819:21): [True: 58, False: 0]
  |  Branch (819:49): [True: 0, False: 58]
  ------------------
  820|      0|                    tspec_tmp.default_target = addr2;
  821|     58|                if (addr != tspec_tmp.target)
  ------------------
  |  Branch (821:21): [True: 0, False: 58]
  ------------------
  822|      0|                    tspec_tmp.target = addr;
  823|     58|                t = match->f_create_from_tspec(&tspec_tmp);
  824|     58|            }
  825|      0|            else {
  826|       |#if 0 /** remove warning until all transports implement tspec */
  827|       |                NETSNMP_LOGONCE((LOG_WARNING,
  828|       |                                 "transport domain %s uses deprecated f_create function\n",
  829|       |                                 match->prefix[0]));
  830|       |#endif
  831|      0|                if (match->f_create_from_tstring) {
  ------------------
  |  Branch (831:21): [True: 0, False: 0]
  ------------------
  832|      0|                    t = match->f_create_from_tstring(addr, local);
  833|      0|                }
  834|      0|                else
  835|      0|                    t = match->f_create_from_tstring_new(addr, local, addr2);
  836|      0|            }
  837|     58|            if (t) {
  ------------------
  |  Branch (837:17): [True: 58, False: 0]
  ------------------
  838|     58|                if (lspec) {
  ------------------
  |  Branch (838:21): [True: 0, False: 58]
  ------------------
  839|      0|                    free(tokenized_domain);
  840|      0|                    free(lspec);
  841|      0|                }
  842|     58|                return t;
  843|     58|            }
  844|     58|        }
  845|      0|        addr = str;
  846|      0|        if (spec && *spec)
  ------------------
  |  Branch (846:13): [True: 0, False: 0]
  |  Branch (846:21): [True: 0, False: 0]
  ------------------
  847|      0|            match = find_tdomain(*spec++);
  848|      0|        else
  849|      0|            break;
  850|      0|    }
  851|      0|    if (!any_found)
  ------------------
  |  Branch (851:9): [True: 0, False: 0]
  ------------------
  852|      0|        snmp_log(LOG_ERR, "No support for any checked transport domain\n");
  853|      0|    if (lspec) {
  ------------------
  |  Branch (853:9): [True: 0, False: 0]
  ------------------
  854|      0|        free(tokenized_domain);
  855|      0|        free(lspec);
  856|      0|    }
  857|       |    return NULL;
  858|     58|}
netsnmp_tdomain_transport_full:
  865|     58|{
  866|     58|    netsnmp_tdomain_spec tspec;
  867|     58|    memset(&tspec, 0x0, sizeof(tspec));
  868|     58|    tspec.application = application;
  869|     58|    tspec.target = str;
  870|     58|    if (local)
  ------------------
  |  Branch (870:9): [True: 58, False: 0]
  ------------------
  871|     58|        tspec.flags |= NETSNMP_TSPEC_LOCAL;
  ------------------
  |  |  117|     58|#define NETSNMP_TSPEC_LOCAL                     0x01 /* 1=server, 0=client */
  ------------------
  872|     58|    tspec.default_domain = default_domain;
  873|     58|    tspec.default_target = default_target;
  874|     58|    tspec.source = NULL;
  875|       |    tspec.transport_config = NULL;
  876|     58|    return netsnmp_tdomain_transport_tspec(&tspec);
  877|     58|}
netsnmp_transport_open_server:
  936|     58|{
  937|     58|    return netsnmp_tdomain_transport_full(application, str, 1, NULL, NULL);
  938|     58|}
_tc_find_transport:
 1240|     58|{
 1241|       |    /*
 1242|       |     * we shouldn't really have that many transports, so instead of
 1243|       |     * using an additional key, just iterate over the whole container.
 1244|       |     */
 1245|     58|    netsnmp_iterator  *itr;
 1246|     58|    trans_cache *tc;
 1247|       |
 1248|     58|    DEBUGMSGTL(("transport:cache:find_transport", "%p\n", t));
  ------------------
  |  |   66|     58|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     58|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 58]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 58]
  |  |  ------------------
  ------------------
 1249|       |
 1250|     58|    if (NULL == _container)
  ------------------
  |  Branch (1250:9): [True: 58, False: 0]
  ------------------
 1251|     58|        return NULL;
 1252|       |
 1253|      0|    itr = CONTAINER_ITERATOR(_container);
  ------------------
  |  |  404|      0|#define CONTAINER_ITERATOR(x)       (x)->get_iterator(x)
  ------------------
 1254|      0|    if (NULL == itr) {
  ------------------
  |  Branch (1254:9): [True: 0, False: 0]
  ------------------
 1255|      0|        snmp_log(LOG_ERR, "could not get iterator for transport cache\n");
 1256|      0|        return NULL;
 1257|      0|    }
 1258|       |
 1259|      0|    tc = ITERATOR_FIRST(itr);
  ------------------
  |  |  546|      0|#define ITERATOR_FIRST(x)  x->first(x)
  ------------------
 1260|      0|    for( ; tc; tc = ITERATOR_NEXT(itr))
  ------------------
  |  |  547|      0|#define ITERATOR_NEXT(x)   x->next(x)
  ------------------
  |  Branch (1260:12): [True: 0, False: 0]
  ------------------
 1261|      0|        if (tc->t == t)
  ------------------
  |  Branch (1261:13): [True: 0, False: 0]
  ------------------
 1262|      0|            break;
 1263|      0|    ITERATOR_RELEASE(itr);
  ------------------
  |  |  550|      0|#define ITERATOR_RELEASE(x) do { x->release(x); x = NULL; } while(0)
  |  |  ------------------
  |  |  |  Branch (550:67): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1264|       |
 1265|      0|    DEBUGMSGT(("transport:cache:find_transport","found %p\n", tc));
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 1266|       |
 1267|      0|    return tc;
 1268|      0|}
netsnmp_transport_cache_remove:
 1272|     58|{
 1273|     58|    trans_cache *tc;
 1274|       |
 1275|     58|    DEBUGMSGTL(("transport:cache:close", "%p\n", t));
  ------------------
  |  |   66|     58|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     58|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 58]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 58]
  |  |  ------------------
  ------------------
 1276|       |
 1277|     58|    if (NULL == t)
  ------------------
  |  Branch (1277:9): [True: 0, False: 58]
  ------------------
 1278|      0|        return 0;
 1279|       |
 1280|       |    /** transport in cache? */
 1281|     58|    tc = _tc_find_transport(t);
 1282|     58|    if (NULL == tc) {
  ------------------
  |  Branch (1282:9): [True: 58, False: 0]
  ------------------
 1283|     58|        DEBUGMSGTL(("transport:cache:close", "%p not found in cache\n", t));
  ------------------
  |  |   66|     58|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     58|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 58]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 58]
  |  |  ------------------
  ------------------
 1284|     58|        return 0;
 1285|     58|    }
 1286|       |
 1287|      0|    --tc->count;
 1288|       |
 1289|       |    /** still in use? */
 1290|      0|    if (tc->count > 0) {
  ------------------
  |  Branch (1290:9): [True: 0, False: 0]
  ------------------
 1291|      0|        DEBUGMSGTL(("transport:cache:close", "still %d user(s) of %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]
  |  |  ------------------
  ------------------
 1292|      0|                    tc->count, t));
 1293|      0|        return 1;
 1294|      0|    }
 1295|       |
 1296|       |    /** unbalanced get/close? */
 1297|      0|    if (tc->count < 0)
  ------------------
  |  Branch (1297:9): [True: 0, False: 0]
  ------------------
 1298|      0|        snmp_log(LOG_WARNING, "transport cache get/close mismatch\n");
 1299|       |
 1300|      0|    _tc_remove(tc);
 1301|      0|    _tc_free(tc); /* also does close */
 1302|       |
 1303|      0|    return 0;
 1304|      0|}
snmp_transport.c:netsnmp_tdomain_dump:
  532|     58|{
  533|     58|    netsnmp_tdomain *d;
  534|     58|    int i = 0;
  535|       |
  536|     58|    DEBUGMSGTL(("tdomain", "domain_list -> "));
  ------------------
  |  |   66|     58|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     58|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 58]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 58]
  |  |  ------------------
  ------------------
  537|    697|    for (d = domain_list; d != NULL; d = d->next) {
  ------------------
  |  Branch (537:27): [True: 639, False: 58]
  ------------------
  538|    639|        DEBUGMSG(("tdomain", "{ "));
  ------------------
  |  |   61|    639|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  144|    639|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 639]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (61:67): [Folded, False: 639]
  |  |  ------------------
  ------------------
  539|    639|        DEBUGMSGOID(("tdomain", d->name, d->name_length));
  ------------------
  |  |   67|    639|#define DEBUGMSGOID(x)     do {if (_DBG_IF_) {__DBGMSGOID(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    639|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 639]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGOID(x)     do {if (_DBG_IF_) {__DBGMSGOID(x);} }while(0)
  |  |  ------------------
  |  |  |  |  165|      0|#define __DBGMSGOID(x)     debugmsg_oid x
  |  |  ------------------
  |  |  |  Branch (67:71): [Folded, False: 639]
  |  |  ------------------
  ------------------
  540|    639|        DEBUGMSG(("tdomain", ", \""));
  ------------------
  |  |   61|    639|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  144|    639|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 639]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (61:67): [Folded, False: 639]
  |  |  ------------------
  ------------------
  541|  1.85k|        for (i = 0; d->prefix[i] != NULL; i++) {
  ------------------
  |  Branch (541:21): [True: 1.21k, False: 639]
  ------------------
  542|  1.21k|            DEBUGMSG(("tdomain", "%s%s", d->prefix[i],
  ------------------
  |  |   61|  1.21k|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  144|  1.21k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 1.21k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (61:56): [True: 0, False: 0]
  |  |  |  Branch (61:67): [Folded, False: 1.21k]
  |  |  ------------------
  ------------------
  543|  1.21k|		      (d->prefix[i + 1]) ? "/" : ""));
  544|  1.21k|        }
  545|    639|        DEBUGMSG(("tdomain", "\" } -> "));
  ------------------
  |  |   61|    639|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  144|    639|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 639]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (61:67): [Folded, False: 639]
  |  |  ------------------
  ------------------
  546|    639|    }
  547|     58|    DEBUGMSG(("tdomain", "[NIL]\n"));
  ------------------
  |  |   61|     58|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  144|     58|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 58]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (61:67): [Folded, False: 58]
  |  |  ------------------
  ------------------
  548|     58|}
snmp_transport.c:netsnmp_is_fqdn:
  623|     58|{
  624|     58|    if (!thename)
  ------------------
  |  Branch (624:9): [True: 0, False: 58]
  ------------------
  625|      0|        return 0;
  626|    580|    while(*thename) {
  ------------------
  |  Branch (626:11): [True: 580, False: 0]
  ------------------
  627|    580|        if (*thename != '.' && !isupper((unsigned char)*thename) &&
  ------------------
  |  Branch (627:13): [True: 406, False: 174]
  |  Branch (627:32): [True: 406, False: 0]
  ------------------
  628|    406|            !islower((unsigned char)*thename) &&
  ------------------
  |  Branch (628:13): [True: 406, False: 0]
  ------------------
  629|    406|            !isdigit((unsigned char)*thename) && *thename != '-') {
  ------------------
  |  Branch (629:13): [True: 58, False: 348]
  |  Branch (629:50): [True: 58, False: 0]
  ------------------
  630|     58|            return 0;
  631|     58|        }
  632|    522|        thename++;
  633|    522|    }
  634|      0|    return 1;
  635|     58|}
snmp_transport.c:find_tdomain:
  605|    116|{
  606|    116|    netsnmp_tdomain *d;
  607|  1.16k|    for (d = domain_list; d != NULL; d = d->next) {
  ------------------
  |  Branch (607:27): [True: 1.10k, False: 58]
  ------------------
  608|  1.10k|        int i;
  609|  3.31k|        for (i = 0; d->prefix[i] != NULL; i++)
  ------------------
  |  Branch (609:21): [True: 2.26k, False: 1.04k]
  ------------------
  610|  2.26k|            if (strcasecmp(d->prefix[i], spec) == 0) {
  ------------------
  |  Branch (610:17): [True: 58, False: 2.20k]
  ------------------
  611|     58|                DEBUGMSGTL(("tdomain",
  ------------------
  |  |   66|     58|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     58|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 58]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 58]
  |  |  ------------------
  ------------------
  612|     58|                            "Found domain \"%s\" from specifier \"%s\"\n",
  613|     58|                            d->prefix[0], spec));
  614|     58|                return d;
  615|     58|            }
  616|  1.10k|    }
  617|     58|    DEBUGMSGTL(("tdomain", "Found no domain from specifier \"%s\"\n", spec));
  ------------------
  |  |   66|     58|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     58|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 58]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 58]
  |  |  ------------------
  ------------------
  618|       |    return NULL;
  619|    116|}

init_ksm:
  218|     58|{
  219|     58|    krb5_error_code retval;
  220|     58|    struct snmp_secmod_def *def;
  221|     58|    int             i;
  222|       |
  223|     58|    netsnmp_ds_register_config(ASN_OCTET_STR, "snmp", "defKSMKeytab",
  ------------------
  |  |   78|     58|#define ASN_OCTET_STR	    0x04U
  ------------------
  224|     58|                               NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_KSM_KEYTAB);
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                             NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_KSM_KEYTAB);
  ------------------
  |  |  172|     58|#define NETSNMP_DS_LIB_KSM_KEYTAB        21
  ------------------
  225|     58|    netsnmp_ds_register_config(ASN_OCTET_STR, "snmp", "defKSMServiceName",
  ------------------
  |  |   78|     58|#define ASN_OCTET_STR	    0x04U
  ------------------
  226|     58|                               NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  227|     58|			       NETSNMP_DS_LIB_KSM_SERVICE_NAME);
  ------------------
  |  |  173|     58|#define NETSNMP_DS_LIB_KSM_SERVICE_NAME  22
  ------------------
  228|     58|    snmp_register_callback(SNMP_CALLBACK_LIBRARY,
  ------------------
  |  |   18|     58|#define SNMP_CALLBACK_LIBRARY     0
  ------------------
  229|     58|			   SNMP_CALLBACK_POST_READ_CONFIG,
  ------------------
  |  |   24|     58|#define SNMP_CALLBACK_POST_READ_CONFIG	        0
  ------------------
  230|     58|			   init_snmpksm_post_config, NULL);
  231|       |
  232|       |
  233|     58|    if (kcontext == NULL) {
  ------------------
  |  Branch (233:9): [True: 58, False: 0]
  ------------------
  234|     58|        retval = krb5_init_context(&kcontext);
  235|       |
  236|     58|        if (retval) {
  ------------------
  |  Branch (236:13): [True: 0, False: 58]
  ------------------
  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|     58|    }
  242|       |
  243|  3.77k|    for (i = 0; i < HASHSIZE; i++)
  ------------------
  |  |  129|  3.77k|#define HASHSIZE	64
  ------------------
  |  Branch (243:17): [True: 3.71k, False: 58]
  ------------------
  244|  3.71k|        ksm_hash_table[i] = NULL;
  245|       |
  246|     58|    def = SNMP_MALLOC_STRUCT(snmp_secmod_def);
  ------------------
  |  |   69|     58|#define SNMP_MALLOC_STRUCT(s)   (struct s *) calloc(1, sizeof(struct s))
  ------------------
  247|       |
  248|     58|    if (!def) {
  ------------------
  |  Branch (248:9): [True: 0, False: 58]
  ------------------
  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|     58|    def->encode_reverse = ksm_rgenerate_out_msg;
  255|     58|    def->decode = ksm_process_in_msg;
  256|     58|    def->session_open = ksm_session_init;
  257|     58|    def->pdu_free_state_ref = ksm_free_state_ref;
  258|     58|    def->pdu_free = ksm_free_pdu;
  259|     58|    def->pdu_clone = ksm_clone_pdu;
  260|       |
  261|     58|    register_sec_mod(NETSNMP_SEC_MODEL_KSM, "ksm", def);
  ------------------
  |  |   13|     58|#define NETSNMP_SEC_MODEL_KSM     2066432
  ------------------
  262|     58|}
shutdown_ksm:
  265|     58|{
  266|     58|    unregister_sec_mod(NETSNMP_SEC_MODEL_KSM);
  ------------------
  |  |   13|     58|#define NETSNMP_SEC_MODEL_KSM     2066432
  ------------------
  267|     58|    if (kcontext)
  ------------------
  |  Branch (267:9): [True: 58, False: 0]
  ------------------
  268|     58|        krb5_free_context(kcontext);
  269|       |    kcontext = NULL;
  270|     58|}
snmpksm.c:init_snmpksm_post_config:
  169|     58|{
  170|       |
  171|     58|    if (kcontext == NULL) {
  ------------------
  |  Branch (171:9): [True: 0, False: 58]
  ------------------
  172|       |	/* not reached, I'd imagine */
  173|      0|        return SNMPERR_KRB5;
  ------------------
  |  |  247|      0|#define SNMPERR_KRB5			(-63)
  ------------------
  174|      0|    }
  175|       |
  176|     58|    if (service_name == NULL) {
  ------------------
  |  Branch (176:9): [True: 1, False: 57]
  ------------------
  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|     58|    if (keytab_setup == 0) {
  ------------------
  |  Branch (188:9): [True: 1, False: 57]
  ------------------
  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: 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]
  |  |  ------------------
  ------------------
  204|      1|	}
  205|      1|	keytab_setup = 1;
  206|      1|    }
  207|       |
  208|     58|    return SNMPERR_SUCCESS;
  ------------------
  |  |  184|     58|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  209|     58|}

init_tsm:
   43|     58|{
   44|     58|    struct snmp_secmod_def *def;
   45|     58|    int ret;
   46|       |
   47|     58|    def = SNMP_MALLOC_STRUCT(snmp_secmod_def);
  ------------------
  |  |   69|     58|#define SNMP_MALLOC_STRUCT(s)   (struct s *) calloc(1, sizeof(struct s))
  ------------------
   48|       |
   49|     58|    if (!def) {
  ------------------
  |  Branch (49:9): [True: 0, False: 58]
  ------------------
   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|     58|    def->encode_reverse = tsm_rgenerate_out_msg;
   56|     58|    def->decode = tsm_process_in_msg;
   57|     58|    def->session_open = tsm_session_init;
   58|     58|    def->pdu_free_state_ref = tsm_free_state_ref;
   59|     58|    def->pdu_clone = tsm_clone_pdu;
   60|     58|    def->pdu_free = tsm_free_pdu;
   61|     58|    def->probe_engineid = snmpv3_probe_contextEngineID_rfc5343;
   62|       |
   63|     58|    DEBUGMSGTL(("tsm","registering ourselves\n"));
  ------------------
  |  |   66|     58|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     58|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 58]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 58]
  |  |  ------------------
  ------------------
   64|     58|    ret = register_sec_mod(SNMP_SEC_MODEL_TSM, "tsm", def);
  ------------------
  |  |  296|     58|#define SNMP_SEC_MODEL_TSM              4
  ------------------
   65|     58|    DEBUGMSGTL(("tsm"," returned %d\n", ret));
  ------------------
  |  |   66|     58|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     58|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 58]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 58]
  |  |  ------------------
  ------------------
   66|       |
   67|     58|    netsnmp_ds_register_config(ASN_BOOLEAN, "snmp", "tsmUseTransportPrefix",
  ------------------
  |  |   72|     58|#define ASN_BOOLEAN	    0x01U
  ------------------
   68|     58|			       NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
   69|     58|                               NETSNMP_DS_LIB_TSM_USE_PREFIX);
  ------------------
  |  |   99|     58|#define NETSNMP_DS_LIB_TSM_USE_PREFIX      39 /* TSM's simple security name mapping */
  ------------------
   70|     58|}
shutdown_tsm:
   75|     58|{
   76|     58|}

usm_free_user:
  749|    174|{
  750|    174|    if (user == NULL)
  ------------------
  |  Branch (750:9): [True: 116, False: 58]
  ------------------
  751|    116|        return NULL;
  752|       |
  753|     58|    SNMP_FREE(user->engineID);
  ------------------
  |  |   62|     58|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 58]
  |  |  |  Branch (62:66): [Folded, False: 58]
  |  |  ------------------
  ------------------
  754|     58|    SNMP_FREE(user->name);
  ------------------
  |  |   62|     58|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 58, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 58]
  |  |  ------------------
  ------------------
  755|     58|    SNMP_FREE(user->secName);
  ------------------
  |  |   62|     58|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 58, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 58]
  |  |  ------------------
  ------------------
  756|     58|    SNMP_FREE(user->cloneFrom);
  ------------------
  |  |   62|     58|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 58, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 58]
  |  |  ------------------
  ------------------
  757|     58|    SNMP_FREE(user->userPublicString);
  ------------------
  |  |   62|     58|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 58]
  |  |  |  Branch (62:66): [Folded, False: 58]
  |  |  ------------------
  ------------------
  758|     58|    SNMP_FREE(user->authProtocol);
  ------------------
  |  |   62|     58|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 58, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 58]
  |  |  ------------------
  ------------------
  759|     58|    SNMP_FREE(user->privProtocol);
  ------------------
  |  |   62|     58|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 58, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 58]
  |  |  ------------------
  ------------------
  760|       |
  761|     58|    if (user->authKey != NULL) {
  ------------------
  |  Branch (761:9): [True: 0, False: 58]
  ------------------
  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|     58|    if (user->privKey != NULL) {
  ------------------
  |  Branch (766:9): [True: 0, False: 58]
  ------------------
  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|     58|    if (user->authKeyKu != NULL) {
  ------------------
  |  Branch (771:9): [True: 0, False: 58]
  ------------------
  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|     58|    if (user->privKeyKu != NULL) {
  ------------------
  |  Branch (776:9): [True: 0, False: 58]
  ------------------
  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|     58|#ifdef NETSNMP_USE_OPENSSL
  782|     58|    if (user->usmDHUserAuthKeyChange)
  ------------------
  |  Branch (782:9): [True: 0, False: 58]
  ------------------
  783|      0|    {
  784|      0|        DH_free(user->usmDHUserAuthKeyChange);
  785|      0|        user->usmDHUserAuthKeyChange = NULL;
  786|      0|    }
  787|       |
  788|     58|    if (user->usmDHUserPrivKeyChange)
  ------------------
  |  Branch (788:9): [True: 0, False: 58]
  ------------------
  789|      0|    {
  790|      0|        DH_free(user->usmDHUserPrivKeyChange);
  791|      0|        user->usmDHUserPrivKeyChange = NULL;
  792|      0|    }
  793|     58|#endif
  794|       |
  795|       |    /*
  796|       |     * FIX  Why not put this check *first?*
  797|       |     */
  798|     58|    if (user->prev != NULL && user->prev != (struct usmUser *)-1) {   /* ack, this shouldn't happen */
  ------------------
  |  Branch (798:9): [True: 0, False: 58]
  |  Branch (798:31): [True: 0, False: 0]
  ------------------
  799|      0|        user->prev->next = user->next;
  800|      0|    }
  801|     58|    if (user->next != NULL && user->next != (struct usmUser *)-1) {
  ------------------
  |  Branch (801:9): [True: 0, False: 58]
  |  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|     58|    SNMP_ZERO(user, sizeof(*user));
  ------------------
  |  |   77|     58|#define SNMP_ZERO(s,l)	do { if (s) memset(s, 0, l); } while(0)
  |  |  ------------------
  |  |  |  Branch (77:33): [True: 58, False: 0]
  |  |  |  Branch (77:61): [Folded, False: 58]
  |  |  ------------------
  ------------------
  811|     58|    SNMP_FREE(user);
  ------------------
  |  |   62|     58|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 58, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 58]
  |  |  ------------------
  ------------------
  812|       |
  813|     58|    return NULL;                /* for convenience to returns from calling functions */
  814|       |
  815|    174|}                               /* end usm_free_user() */
usm_create_user:
 4160|     58|{
 4161|     58|    struct usmUser *newUser;
 4162|       |
 4163|       |    /*
 4164|       |     * create the new user 
 4165|       |     */
 4166|     58|    newUser = calloc(1, sizeof(struct usmUser));
 4167|     58|    if (newUser == NULL)
  ------------------
  |  Branch (4167:9): [True: 0, False: 58]
  ------------------
 4168|      0|        return NULL;
 4169|       |
 4170|       |    /*
 4171|       |     * fill the auth/priv protocols 
 4172|       |     */
 4173|     58|    if ((newUser->authProtocol =
  ------------------
  |  Branch (4173:9): [True: 0, False: 58]
  ------------------
 4174|     58|         snmp_duplicate_objid(usmNoAuthProtocol,
 4175|     58|                              OID_LENGTH(usmNoAuthProtocol))) ==
  ------------------
  |  |   64|     58|    (sizeof(x) / sizeof((x)[0]) +                                       \
  |  |   65|     58|     sizeof(int[-__builtin_types_compatible_p(typeof(x), typeof(&(x)[0]))]))
  ------------------
 4176|     58|        NULL)
 4177|      0|        return usm_free_user(newUser);
 4178|     58|    newUser->authProtocolLen = OID_LENGTH(usmNoAuthProtocol);
  ------------------
  |  |   64|     58|    (sizeof(x) / sizeof((x)[0]) +                                       \
  |  |   65|     58|     sizeof(int[-__builtin_types_compatible_p(typeof(x), typeof(&(x)[0]))]))
  ------------------
 4179|       |
 4180|     58|    if ((newUser->privProtocol =
  ------------------
  |  Branch (4180:9): [True: 0, False: 58]
  ------------------
 4181|     58|         snmp_duplicate_objid(usmNoPrivProtocol,
 4182|     58|                              OID_LENGTH(usmNoPrivProtocol))) ==
  ------------------
  |  |   64|     58|    (sizeof(x) / sizeof((x)[0]) +                                       \
  |  |   65|     58|     sizeof(int[-__builtin_types_compatible_p(typeof(x), typeof(&(x)[0]))]))
  ------------------
 4183|     58|        NULL)
 4184|      0|        return usm_free_user(newUser);
 4185|     58|    newUser->privProtocolLen = OID_LENGTH(usmNoPrivProtocol);
  ------------------
  |  |   64|     58|    (sizeof(x) / sizeof((x)[0]) +                                       \
  |  |   65|     58|     sizeof(int[-__builtin_types_compatible_p(typeof(x), typeof(&(x)[0]))]))
  ------------------
 4186|       |
 4187|       |    /*
 4188|       |     * set the storage type to nonvolatile, and the status to ACTIVE 
 4189|       |     */
 4190|     58|    newUser->userStorageType = ST_NONVOLATILE;
  ------------------
  |  |   52|     58|#define ST_NONVOLATILE	3
  ------------------
 4191|     58|    newUser->userStatus = RS_ACTIVE;
  ------------------
  |  |   35|     58|#define RS_ACTIVE	        1
  ------------------
 4192|     58|    return newUser;
 4193|       |
 4194|     58|}                               /* end usm_clone_user() */
get_default_authtype:
 5150|    116|{
 5151|    116|    if (defaultAuthType == NULL) {
  ------------------
  |  Branch (5151:9): [True: 1, False: 115]
  ------------------
 5152|      1|        defaultAuthType = SNMP_DEFAULT_AUTH_PROTO;
  ------------------
  |  |   94|      1|#define SNMP_DEFAULT_AUTH_PROTO     usmHMACMD5AuthProtocol
  ------------------
 5153|      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]))]))
  |  |  ------------------
  ------------------
 5154|      1|    }
 5155|    116|    if (len)
  ------------------
  |  Branch (5155:9): [True: 58, False: 58]
  ------------------
 5156|     58|        *len = defaultAuthTypeLen;
 5157|    116|    return defaultAuthType;
 5158|    116|}
get_default_privtype:
 5172|    116|{
 5173|    116|    if (defaultPrivType == NULL) {
  ------------------
  |  Branch (5173:9): [True: 1, False: 115]
  ------------------
 5174|      1|        defaultPrivType = SNMP_DEFAULT_PRIV_PROTO;
  ------------------
  |  |  100|      1|#define SNMP_DEFAULT_PRIV_PROTO     usmDESPrivProtocol
  ------------------
 5175|      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]))]))
  |  |  ------------------
  ------------------
 5176|      1|    }
 5177|    116|    if (len)
  ------------------
  |  Branch (5177:9): [True: 58, False: 58]
  ------------------
 5178|     58|        *len = defaultPrivTypeLen;
 5179|    116|    return defaultPrivType;
 5180|    116|}
init_usm:
 5272|     58|{
 5273|     58|    struct snmp_secmod_def *def;
 5274|     58|    char *type;
 5275|       |
 5276|     58|    DEBUGMSGTL(("init_usm", "unit_usm: %" NETSNMP_PRIo "u %" NETSNMP_PRIo "u\n",
  ------------------
  |  |   66|     58|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     58|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 58]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 58]
  |  |  ------------------
  ------------------
 5277|     58|                usmNoPrivProtocol[0], usmNoPrivProtocol[1]));
 5278|       |
 5279|     58|    sc_init();                  /* initialize scapi code */
 5280|       |
 5281|       |    /*
 5282|       |     * register ourselves as a security service
 5283|       |     */
 5284|     58|    def = SNMP_MALLOC_STRUCT(snmp_secmod_def);
  ------------------
  |  |   69|     58|#define SNMP_MALLOC_STRUCT(s)   (struct s *) calloc(1, sizeof(struct s))
  ------------------
 5285|     58|    if (def == NULL)
  ------------------
  |  Branch (5285:9): [True: 0, False: 58]
  ------------------
 5286|      0|        return;
 5287|       |    /*
 5288|       |     * XXX: def->init_sess_secmod move stuff from snmp_api.c
 5289|       |     */
 5290|     58|    def->encode_reverse = usm_secmod_rgenerate_out_msg;
 5291|     58|    def->encode_forward = usm_secmod_generate_out_msg;
 5292|     58|    def->decode = usm_secmod_process_in_msg;
 5293|     58|    def->pdu_clone = usm_clone;
 5294|     58|    def->pdu_free_state_ref = usm_free_usmStateReference;
 5295|     58|    def->session_setup = usm_session_init;
 5296|     58|    def->handle_report = usm_handle_report;
 5297|     58|    def->probe_engineid = usm_discover_engineid;
 5298|     58|    def->post_probe_engineid = usm_create_user_from_session_hook;
 5299|     58|    if (register_sec_mod(USM_SEC_MODEL_NUMBER, "usm", def) != SNMPERR_SUCCESS) {
  ------------------
  |  |   40|     58|#define USM_SEC_MODEL_NUMBER            SNMP_SEC_MODEL_USM
  |  |  ------------------
  |  |  |  |  295|     58|#define SNMP_SEC_MODEL_USM		3
  |  |  ------------------
  ------------------
                  if (register_sec_mod(USM_SEC_MODEL_NUMBER, "usm", def) != SNMPERR_SUCCESS) {
  ------------------
  |  |  184|     58|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  |  Branch (5299:9): [True: 0, False: 58]
  ------------------
 5300|      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]
  |  |  ------------------
  ------------------
 5301|      0|        snmp_log(LOG_ERR, "could not register usm sec mod\n");
 5302|      0|        return;
 5303|      0|    }
 5304|       |
 5305|     58|    snmp_register_callback(SNMP_CALLBACK_LIBRARY,
  ------------------
  |  |   18|     58|#define SNMP_CALLBACK_LIBRARY     0
  ------------------
 5306|     58|                           SNMP_CALLBACK_POST_PREMIB_READ_CONFIG,
  ------------------
  |  |   27|     58|#define SNMP_CALLBACK_POST_PREMIB_READ_CONFIG	3
  ------------------
 5307|     58|                           init_usm_post_config, NULL);
 5308|       |
 5309|     58|    snmp_register_callback(SNMP_CALLBACK_LIBRARY,
  ------------------
  |  |   18|     58|#define SNMP_CALLBACK_LIBRARY     0
  ------------------
 5310|     58|                           SNMP_CALLBACK_SHUTDOWN,
  ------------------
  |  |   26|     58|#define SNMP_CALLBACK_SHUTDOWN		        2
  ------------------
 5311|     58|                           deinit_usm_post_config, NULL);
 5312|       |
 5313|     58|    snmp_register_callback(SNMP_CALLBACK_LIBRARY,
  ------------------
  |  |   18|     58|#define SNMP_CALLBACK_LIBRARY     0
  ------------------
 5314|     58|                           SNMP_CALLBACK_SHUTDOWN,
  ------------------
  |  |   26|     58|#define SNMP_CALLBACK_SHUTDOWN		        2
  ------------------
 5315|     58|                           free_engineID, NULL);
 5316|       |
 5317|     58|    register_config_handler("snmp", "defAuthType", snmpv3_authtype_conf,
 5318|     58|                            NULL, "MD5|SHA|SHA-512|SHA-384|SHA-256|SHA-224");
 5319|     58|    register_config_handler("snmp", "defPrivType", snmpv3_privtype_conf,
 5320|     58|                            NULL,
 5321|     58|                            "DES"
 5322|     58|#ifdef HAVE_AES
 5323|     58|                            "|AES|AES-128"
 5324|     58|#ifdef NETSNMP_DRAFT_BLUMENTHAL_AES_04
 5325|     58|                            "|AES-192|AES-256"
 5326|     58|#endif /* NETSNMP_DRAFT_BLUMENTHAL_AES_04 */
 5327|       |#else
 5328|       |                            " (AES support not available)"
 5329|       |#endif
 5330|     58|                           );
 5331|       |
 5332|       |    /*
 5333|       |     * Free stuff at shutdown time
 5334|       |     */
 5335|     58|    snmp_register_callback(SNMP_CALLBACK_LIBRARY,
  ------------------
  |  |   18|     58|#define SNMP_CALLBACK_LIBRARY     0
  ------------------
 5336|     58|                           SNMP_CALLBACK_SHUTDOWN,
  ------------------
  |  |   26|     58|#define SNMP_CALLBACK_SHUTDOWN		        2
  ------------------
 5337|     58|                           free_enginetime_on_shutdown, NULL);
 5338|       |
 5339|       |
 5340|     58|    type = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_APPTYPE);
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                  type = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_APPTYPE);
  ------------------
  |  |  157|     58|#define NETSNMP_DS_LIB_APPTYPE           6
  ------------------
 5341|       |
 5342|     58|    register_config_handler(type, "userSetAuthPass", usm_set_password,
 5343|     58|                            NULL, NULL);
 5344|     58|    register_config_handler(type, "userSetPrivPass", usm_set_password,
 5345|     58|                            NULL, NULL);
 5346|     58|    register_config_handler(type, "userSetAuthKey", usm_set_password, NULL,
 5347|     58|                            NULL);
 5348|     58|    register_config_handler(type, "userSetPrivKey", usm_set_password, NULL,
 5349|     58|                            NULL);
 5350|     58|    register_config_handler(type, "userSetAuthLocalKey", usm_set_password,
 5351|     58|                            NULL, NULL);
 5352|     58|    register_config_handler(type, "userSetPrivLocalKey", usm_set_password,
 5353|     58|                            NULL, NULL);
 5354|     58|}
shutdown_usm:
 5358|     58|{
 5359|     58|    free_etimelist();
 5360|     58|    clear_user_list();
 5361|     58|}
snmpusm.c:usm_secmod_process_in_msg:
 3360|      2|{
 3361|      2|    if (!parms)
  ------------------
  |  Branch (3361:9): [True: 0, False: 2]
  ------------------
 3362|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
 3363|       |
 3364|      2|    return usm_process_in_msg(parms->msgProcModel,
 3365|      2|                              parms->maxMsgSize,
 3366|      2|                              parms->secParams,
 3367|      2|                              parms->secModel,
 3368|      2|                              parms->secLevel,
 3369|      2|                              parms->wholeMsg,
 3370|      2|                              parms->wholeMsgLen,
 3371|      2|                              parms->secEngineID,
 3372|      2|                              parms->secEngineIDLen,
 3373|      2|                              parms->secName,
 3374|      2|                              parms->secNameLen,
 3375|      2|                              parms->scopedPdu,
 3376|      2|                              parms->scopedPduLen,
 3377|      2|                              parms->maxSizeResponse,
 3378|      2|                              parms->secStateRef,
 3379|      2|                              parms->sess, parms->msg_flags);
 3380|      2|}
snmpusm.c:usm_process_in_msg:
 2958|      2|{                               /* IN     - v3 Message flags.              */
 2959|      2|    size_t          remaining = wholeMsgLen - (secParams - wholeMsg);
 2960|      2|    u_int           boots_uint;
 2961|      2|    u_int           time_uint;
 2962|      2|#ifdef HAVE_AES
 2963|      2|    u_int           net_boots, net_time;
 2964|      2|#endif
 2965|      2|#ifndef NETSNMP_DISABLE_DES
 2966|      2|    int             i;
 2967|      2|#endif
 2968|      2|    u_char          signature[USM_MAX_AUTHSIZE];
 2969|      2|    size_t          signature_length = USM_MAX_AUTHSIZE;
  ------------------
  |  |   38|      2|#define USM_MAX_AUTHSIZE                USM_HMAC384SHA512_AUTH_LEN
  |  |  ------------------
  |  |  |  |   37|      2|#define USM_HMAC384SHA512_AUTH_LEN      48      /* SHOULD */
  |  |  ------------------
  ------------------
 2970|      2|    u_char          salt[BYTESIZE(USM_MAX_SALT_LENGTH)];
 2971|      2|    size_t          salt_length = BYTESIZE(USM_MAX_SALT_LENGTH);
  ------------------
  |  |   55|      2|#define BYTESIZE(bitsize)       ((bitsize + 7) >> 3)
  ------------------
 2972|      2|    u_char          iv[BYTESIZE(USM_MAX_SALT_LENGTH)];
 2973|      2|    u_int           iv_length = BYTESIZE(USM_MAX_SALT_LENGTH);
  ------------------
  |  |   55|      2|#define BYTESIZE(bitsize)       ((bitsize + 7) >> 3)
  ------------------
 2974|      2|    u_char         *data_ptr;
 2975|      2|    u_char         *value_ptr;
 2976|      2|    u_char          type_value;
 2977|      2|    u_char         *end_of_overhead = NULL;
 2978|      2|    int             error;
 2979|      2|    int             rc = 0;
 2980|      2|    struct usmStateReference **secStateRef =
 2981|      2|        (struct usmStateReference **) secStateRf;
 2982|       |
 2983|      2|    struct usmUser *user;
 2984|       |
 2985|       |
 2986|      2|    DEBUGMSGTL(("usm", "USM processing begun...\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]
  |  |  ------------------
  ------------------
 2987|       |
 2988|      2|    netsnmp_assert(secStateRef);
  ------------------
  |  |   47|      2|#      define netsnmp_assert(x)  do { \
  |  |   48|      2|              if ( x ) \
  |  |  ------------------
  |  |  |  Branch (48:20): [True: 2, False: 0]
  |  |  ------------------
  |  |   49|      2|                 ; \
  |  |   50|      2|              else \
  |  |   51|      2|                 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
  |  |  |  |  ------------------
  |  |  |  |  |  | 1727|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|      2|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded, False: 2]
  |  |  ------------------
  ------------------
 2989|       |
 2990|      2|    usm_free_usmStateReference(*secStateRef);
 2991|      2|    *secStateRef = usm_malloc_usmStateReference();
 2992|      2|    if (*secStateRef == NULL) {
  ------------------
  |  Branch (2992:9): [True: 0, False: 2]
  ------------------
 2993|      0|        DEBUGMSGTL(("usm", "Out of memory.\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]
  |  |  ------------------
  ------------------
 2994|      0|        return SNMPERR_USM_GENERICERROR;
  ------------------
  |  |  226|      0|#define SNMPERR_USM_GENERICERROR		(-42)
  ------------------
 2995|      0|    }
 2996|       |
 2997|       |    /*
 2998|       |     * Make sure the *secParms is an OCTET STRING.
 2999|       |     * Extract the user name, engine ID, and security level.
 3000|       |     */
 3001|      2|    if ((rc = usm_parse_security_parameters(secParams, remaining,
  ------------------
  |  Branch (3001:9): [True: 2, False: 0]
  ------------------
 3002|      2|                                            secEngineID, secEngineIDLen,
 3003|      2|                                            &boots_uint, &time_uint,
 3004|      2|                                            secName, secNameLen,
 3005|      2|                                            signature, &signature_length,
 3006|      2|                                            salt, &salt_length,
 3007|      2|                                            &data_ptr)) < 0) {
 3008|      2|        DEBUGMSGTL(("usm", "Parsing failed (rc %d).\n", rc));
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 3009|      2|        if (rc == -2) {
  ------------------
  |  Branch (3009:13): [True: 0, False: 2]
  ------------------
 3010|       |            /*
 3011|       |             * This indicates a decryptionError.  
 3012|       |             */
 3013|      0|            snmp_increment_statistic(STAT_USMSTATSDECRYPTIONERRORS);
  ------------------
  |  |  625|      0|#define   STAT_USMSTATSDECRYPTIONERRORS      8
  ------------------
 3014|      0|            error = SNMPERR_USM_DECRYPTIONERROR;
  ------------------
  |  |  234|      0|#define SNMPERR_USM_DECRYPTIONERROR		(-50)
  ------------------
 3015|      2|        } else {
 3016|      2|            snmp_increment_statistic(STAT_SNMPINASNPARSEERRS);
  ------------------
  |  |  637|      2|#define  STAT_SNMPINASNPARSEERRS             14
  ------------------
 3017|      2|            error = SNMPERR_USM_PARSEERROR;
  ------------------
  |  |  231|      2|#define SNMPERR_USM_PARSEERROR			(-47)
  ------------------
 3018|      2|        }
 3019|      2|        goto err;
 3020|      2|    }
 3021|       |
 3022|       |    /*
 3023|       |     * RFC 2574 section 8.3.2
 3024|       |     * 1)  If the privParameters field is not an 8-octet OCTET STRING,
 3025|       |     * then an error indication (decryptionError) is returned to the
 3026|       |     * calling module.
 3027|       |     */
 3028|      0|    if ((secLevel == SNMP_SEC_LEVEL_AUTHPRIV) && (salt_length != 8)) {
  ------------------
  |  |  301|      0|#define SNMP_SEC_LEVEL_AUTHPRIV		3
  ------------------
  |  Branch (3028:9): [True: 0, False: 0]
  |  Branch (3028:50): [True: 0, False: 0]
  ------------------
 3029|      0|        snmp_increment_statistic(STAT_USMSTATSDECRYPTIONERRORS);
  ------------------
  |  |  625|      0|#define   STAT_USMSTATSDECRYPTIONERRORS      8
  ------------------
 3030|      0|        error = SNMPERR_USM_DECRYPTIONERROR;
  ------------------
  |  |  234|      0|#define SNMPERR_USM_DECRYPTIONERROR		(-50)
  ------------------
 3031|      0|        goto err;
 3032|      0|    }
 3033|       |
 3034|      0|    if (secLevel != SNMP_SEC_LEVEL_AUTHPRIV) {
  ------------------
  |  |  301|      0|#define SNMP_SEC_LEVEL_AUTHPRIV		3
  ------------------
  |  Branch (3034:9): [True: 0, False: 0]
  ------------------
 3035|       |        /*
 3036|       |         * pull these out now so reports can use them 
 3037|       |         */
 3038|      0|        *scopedPdu = data_ptr;
 3039|      0|        *scopedPduLen = wholeMsgLen - (data_ptr - wholeMsg);
 3040|      0|        end_of_overhead = data_ptr;
 3041|      0|    }
 3042|       |
 3043|       |    /*
 3044|       |     * Cache the name, engine ID, and security level,
 3045|       |     * * per step 2 (section 3.2)
 3046|       |     */
 3047|      0|    if (usm_set_usmStateReference_name
  ------------------
  |  Branch (3047:9): [True: 0, False: 0]
  ------------------
 3048|      0|        (*secStateRef, secName, *secNameLen) == -1) {
 3049|      0|        DEBUGMSGTL(("usm", "%s\n", "Couldn't cache name."));
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 3050|      0|        error = SNMPERR_USM_GENERICERROR;
  ------------------
  |  |  226|      0|#define SNMPERR_USM_GENERICERROR		(-42)
  ------------------
 3051|      0|        goto err;
 3052|      0|    }
 3053|       |
 3054|      0|    if (usm_set_usmStateReference_engine_id
  ------------------
  |  Branch (3054:9): [True: 0, False: 0]
  ------------------
 3055|      0|        (*secStateRef, secEngineID, *secEngineIDLen) == -1) {
 3056|      0|        DEBUGMSGTL(("usm", "%s\n", "Couldn't cache engine id."));
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 3057|      0|        error = SNMPERR_USM_GENERICERROR;
  ------------------
  |  |  226|      0|#define SNMPERR_USM_GENERICERROR		(-42)
  ------------------
 3058|      0|        goto err;
 3059|      0|    }
 3060|       |
 3061|      0|    if (usm_set_usmStateReference_sec_level(*secStateRef, secLevel) ==
  ------------------
  |  Branch (3061:9): [True: 0, False: 0]
  ------------------
 3062|      0|        -1) {
 3063|      0|        DEBUGMSGTL(("usm", "%s\n", "Couldn't cache security level."));
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 3064|      0|        error = SNMPERR_USM_GENERICERROR;
  ------------------
  |  |  226|      0|#define SNMPERR_USM_GENERICERROR		(-42)
  ------------------
 3065|      0|        goto err;
 3066|      0|    }
 3067|       |
 3068|       |    /*
 3069|       |     * Locate the engine ID record.
 3070|       |     * If it is unknown, then either create one or note this as an error.
 3071|       |     */
 3072|      0|    if ((sess && (sess->isAuthoritative == SNMP_SESS_AUTHORITATIVE ||
  ------------------
  |  |  125|      0|#define SNMP_SESS_AUTHORITATIVE    1    /* don't learn engineIDs */
  ------------------
  |  Branch (3072:10): [True: 0, False: 0]
  |  Branch (3072:19): [True: 0, False: 0]
  ------------------
 3073|      0|                  (sess->isAuthoritative == SNMP_SESS_UNKNOWNAUTH &&
  ------------------
  |  |  126|      0|#define SNMP_SESS_UNKNOWNAUTH      2    /* sometimes (like NRs) */
  ------------------
  |  Branch (3073:20): [True: 0, False: 0]
  ------------------
 3074|      0|                   (msg_flags & SNMP_MSG_FLAG_RPRT_BIT)))) ||
  ------------------
  |  |  305|      0|#define SNMP_MSG_FLAG_RPRT_BIT          0x04
  ------------------
  |  Branch (3074:20): [True: 0, False: 0]
  ------------------
 3075|      0|        (!sess && (msg_flags & SNMP_MSG_FLAG_RPRT_BIT))) {
  ------------------
  |  |  305|      0|#define SNMP_MSG_FLAG_RPRT_BIT          0x04
  ------------------
  |  Branch (3075:10): [True: 0, False: 0]
  |  Branch (3075:19): [True: 0, False: 0]
  ------------------
 3076|      0|        if (ISENGINEKNOWN(secEngineID, *secEngineIDLen) == FALSE) {
  ------------------
  |  |   82|      0|	( (get_enginetime(e, e_l,				\
  |  |  ------------------
  |  |  |  Branch (82:4): [True: 0, False: 0]
  |  |  ------------------
  |  |   83|      0|		&dummy_eboot, &dummy_etime, TRUE) == SNMPERR_SUCCESS)	\
  |  |  ------------------
  |  |  |  |  128|      0|#define TRUE  1
  |  |  ------------------
  |  |               		&dummy_eboot, &dummy_etime, TRUE) == SNMPERR_SUCCESS)	\
  |  |  ------------------
  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  ------------------
  |  |   84|      0|		? TRUE						\
  |  |  ------------------
  |  |  |  |  128|      0|#define TRUE  1
  |  |  ------------------
  |  |   85|      0|		: FALSE )
  |  |  ------------------
  |  |  |  |  125|      0|#define FALSE 0
  |  |  ------------------
  ------------------
                      if (ISENGINEKNOWN(secEngineID, *secEngineIDLen) == FALSE) {
  ------------------
  |  |  125|      0|#define FALSE 0
  ------------------
  |  Branch (3076:13): [True: 0, False: 0]
  ------------------
 3077|      0|            DEBUGMSGTL(("usm", "Unknown Engine ID.\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]
  |  |  ------------------
  ------------------
 3078|      0|            snmp_increment_statistic(STAT_USMSTATSUNKNOWNENGINEIDS);
  ------------------
  |  |  623|      0|#define   STAT_USMSTATSUNKNOWNENGINEIDS      6
  ------------------
 3079|      0|            error = SNMPERR_USM_UNKNOWNENGINEID;
  ------------------
  |  |  232|      0|#define SNMPERR_USM_UNKNOWNENGINEID		(-48)
  ------------------
 3080|      0|            goto err;
 3081|      0|        }
 3082|      0|    } else {
 3083|      0|        if (ENSURE_ENGINE_RECORD(secEngineID, *secEngineIDLen)
  ------------------
  |  |   88|      0|	( (set_enginetime(e, e_l, 0, 0, FALSE) == SNMPERR_SUCCESS)	\
  |  |  ------------------
  |  |  |  |  125|      0|#define FALSE 0
  |  |  ------------------
  |  |               	( (set_enginetime(e, e_l, 0, 0, FALSE) == SNMPERR_SUCCESS)	\
  |  |  ------------------
  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  ------------------
  |  |  |  Branch (88:4): [True: 0, False: 0]
  |  |  ------------------
  |  |   89|      0|		? SNMPERR_SUCCESS				\
  |  |  ------------------
  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  ------------------
  |  |   90|      0|		: SNMPERR_GENERR )
  |  |  ------------------
  |  |  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  |  |  ------------------
  ------------------
  |  Branch (3083:13): [True: 0, False: 0]
  ------------------
 3084|      0|            != SNMPERR_SUCCESS) {
  ------------------
  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 3085|      0|            DEBUGMSGTL(("usm", "%s\n", "Couldn't ensure engine record."));
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 3086|      0|            error = SNMPERR_USM_GENERICERROR;
  ------------------
  |  |  226|      0|#define SNMPERR_USM_GENERICERROR		(-42)
  ------------------
 3087|      0|            goto err;
 3088|      0|        }
 3089|       |
 3090|      0|    }
 3091|       |
 3092|       |
 3093|       |    /*
 3094|       |     * Locate the User record.
 3095|       |     * If the user/engine ID is unknown, report this as an error.
 3096|       |     */
 3097|      0|    if (sess && sess->sessUser)
  ------------------
  |  Branch (3097:9): [True: 0, False: 0]
  |  Branch (3097:17): [True: 0, False: 0]
  ------------------
 3098|      0|        user = sess->sessUser;
 3099|      0|    else
 3100|      0|        user = usm_get_user_from_list(secEngineID, *secEngineIDLen,
 3101|      0|                                       secName, *secNameLen, userList,
 3102|      0|                                       (((sess && sess->isAuthoritative ==
  ------------------
  |  Branch (3102:43): [True: 0, False: 0]
  |  Branch (3102:51): [True: 0, False: 0]
  ------------------
 3103|      0|                                          SNMP_SESS_AUTHORITATIVE) ||
  ------------------
  |  |  125|      0|#define SNMP_SESS_AUTHORITATIVE    1    /* don't learn engineIDs */
  ------------------
 3104|      0|                                         (!sess)) ? 0 : 1));
  ------------------
  |  Branch (3104:42): [True: 0, False: 0]
  ------------------
 3105|       |
 3106|      0|    if (user == NULL) {
  ------------------
  |  Branch (3106:9): [True: 0, False: 0]
  ------------------
 3107|      0|        DEBUGMSGTL(("usm", "Unknown User(%s)\n", secName));
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 3108|      0|        snmp_increment_statistic(STAT_USMSTATSUNKNOWNUSERNAMES);
  ------------------
  |  |  622|      0|#define   STAT_USMSTATSUNKNOWNUSERNAMES      5
  ------------------
 3109|      0|        error = SNMPERR_USM_UNKNOWNSECURITYNAME;
  ------------------
  |  |  227|      0|#define SNMPERR_USM_UNKNOWNSECURITYNAME		(-43)
  ------------------
 3110|      0|        goto err;
 3111|      0|    }
 3112|       |
 3113|       |    /* ensure the user is active */
 3114|      0|    if (user->userStatus != RS_ACTIVE) {
  ------------------
  |  |   35|      0|#define RS_ACTIVE	        1
  ------------------
  |  Branch (3114:9): [True: 0, False: 0]
  ------------------
 3115|      0|        DEBUGMSGTL(("usm", "Attempt to use an inactive user.\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]
  |  |  ------------------
  ------------------
 3116|      0|        error = SNMPERR_USM_UNKNOWNSECURITYNAME;
  ------------------
  |  |  227|      0|#define SNMPERR_USM_UNKNOWNSECURITYNAME		(-43)
  ------------------
 3117|      0|        goto err;
 3118|      0|    }
 3119|       |
 3120|       |    /*
 3121|       |     * Make sure the security level is appropriate.
 3122|       |     */
 3123|       |
 3124|      0|    rc = usm_check_secLevel(secLevel, user);
 3125|      0|    if (1 == rc) {
  ------------------
  |  Branch (3125:9): [True: 0, False: 0]
  ------------------
 3126|      0|        DEBUGMSGTL(("usm", "Unsupported Security Level (%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]
  |  |  ------------------
  ------------------
 3127|      0|                    secLevel));
 3128|      0|        snmp_increment_statistic(STAT_USMSTATSUNSUPPORTEDSECLEVELS);
  ------------------
  |  |  620|      0|#define   STAT_USMSTATSUNSUPPORTEDSECLEVELS  3
  ------------------
 3129|      0|        error = SNMPERR_USM_UNSUPPORTEDSECURITYLEVEL;
  ------------------
  |  |  228|      0|#define SNMPERR_USM_UNSUPPORTEDSECURITYLEVEL	(-44)
  ------------------
 3130|      0|        goto err;
 3131|      0|    } else if (rc != 0) {
  ------------------
  |  Branch (3131:16): [True: 0, False: 0]
  ------------------
 3132|      0|        DEBUGMSGTL(("usm", "Unknown issue.\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]
  |  |  ------------------
  ------------------
 3133|      0|        error = SNMPERR_USM_GENERICERROR;
  ------------------
  |  |  226|      0|#define SNMPERR_USM_GENERICERROR		(-42)
  ------------------
 3134|      0|        goto err;
 3135|      0|    }
 3136|       |
 3137|       |    /*
 3138|       |     * Check the authentication credentials of the message.
 3139|       |     */
 3140|      0|    if (secLevel == SNMP_SEC_LEVEL_AUTHNOPRIV
  ------------------
  |  |  300|      0|#define SNMP_SEC_LEVEL_AUTHNOPRIV	2
  ------------------
  |  Branch (3140:9): [True: 0, False: 0]
  ------------------
 3141|      0|        || secLevel == SNMP_SEC_LEVEL_AUTHPRIV) {
  ------------------
  |  |  301|      0|#define SNMP_SEC_LEVEL_AUTHPRIV		3
  ------------------
  |  Branch (3141:12): [True: 0, False: 0]
  ------------------
 3142|      0|        if (sc_check_keyed_hash(user->authProtocol, user->authProtocolLen,
  ------------------
  |  Branch (3142:13): [True: 0, False: 0]
  ------------------
 3143|      0|                                user->authKey, user->authKeyLen,
 3144|      0|                                wholeMsg, wholeMsgLen,
 3145|      0|                                signature, signature_length)
 3146|      0|            != SNMP_ERR_NOERROR) {
  ------------------
  |  |  212|      0|#define SNMP_ERR_NOERROR                (0)     /* XXX  Used only for PDUs? */
  ------------------
 3147|      0|            DEBUGMSGTL(("usm", "Verification 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]
  |  |  ------------------
  ------------------
 3148|      0|            snmp_increment_statistic(STAT_USMSTATSWRONGDIGESTS);
  ------------------
  |  |  624|      0|#define   STAT_USMSTATSWRONGDIGESTS          7
  ------------------
 3149|      0|	    snmp_log(LOG_WARNING, "Authentication failed for %s\n",
 3150|      0|				user->name);
 3151|      0|            error = SNMPERR_USM_AUTHENTICATIONFAILURE;
  ------------------
  |  |  230|      0|#define SNMPERR_USM_AUTHENTICATIONFAILURE	(-46)
  ------------------
 3152|      0|            goto err;
 3153|      0|        }
 3154|       |
 3155|      0|        DEBUGMSGTL(("usm", "Verification succeeded.\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]
  |  |  ------------------
  ------------------
 3156|      0|    }
 3157|       |
 3158|       |
 3159|       |    /*
 3160|       |     * Steps 10-11  user is already set - relocated before timeliness 
 3161|       |     * check in case it fails - still save user data for response.
 3162|       |     *
 3163|       |     * Cache the keys and protocol oids, per step 11 (s3.2).
 3164|       |     */
 3165|      0|    if (usm_set_usmStateReference_auth_protocol(*secStateRef,
  ------------------
  |  Branch (3165:9): [True: 0, False: 0]
  ------------------
 3166|      0|                                                user->authProtocol,
 3167|      0|                                                user->
 3168|      0|                                                authProtocolLen) == -1) {
 3169|      0|        DEBUGMSGTL(("usm", "%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]
  |  |  ------------------
  ------------------
 3170|      0|                    "Couldn't cache authentication protocol."));
 3171|      0|        error = SNMPERR_USM_GENERICERROR;
  ------------------
  |  |  226|      0|#define SNMPERR_USM_GENERICERROR		(-42)
  ------------------
 3172|      0|        goto err;
 3173|      0|    }
 3174|       |
 3175|      0|    if (usm_set_usmStateReference_auth_key(*secStateRef,
  ------------------
  |  Branch (3175:9): [True: 0, False: 0]
  ------------------
 3176|      0|                                           user->authKey,
 3177|      0|                                           user->authKeyLen) == -1) {
 3178|      0|        DEBUGMSGTL(("usm", "%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]
  |  |  ------------------
  ------------------
 3179|      0|                    "Couldn't cache authentication key."));
 3180|      0|        error = SNMPERR_USM_GENERICERROR;
  ------------------
  |  |  226|      0|#define SNMPERR_USM_GENERICERROR		(-42)
  ------------------
 3181|      0|        goto err;
 3182|      0|    }
 3183|       |
 3184|      0|    if (usm_set_usmStateReference_priv_protocol(*secStateRef,
  ------------------
  |  Branch (3184:9): [True: 0, False: 0]
  ------------------
 3185|      0|                                                user->privProtocol,
 3186|      0|                                                user->
 3187|      0|                                                privProtocolLen) == -1) {
 3188|      0|        DEBUGMSGTL(("usm", "%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]
  |  |  ------------------
  ------------------
 3189|      0|                    "Couldn't cache privacy protocol."));
 3190|      0|        error = SNMPERR_USM_GENERICERROR;
  ------------------
  |  |  226|      0|#define SNMPERR_USM_GENERICERROR		(-42)
  ------------------
 3191|      0|        goto err;
 3192|      0|    }
 3193|       |
 3194|      0|    if (usm_set_usmStateReference_priv_key(*secStateRef,
  ------------------
  |  Branch (3194:9): [True: 0, False: 0]
  ------------------
 3195|      0|                                           user->privKey,
 3196|      0|                                           user->privKeyLen) == -1) {
 3197|      0|        DEBUGMSGTL(("usm", "%s\n", "Couldn't cache privacy key."));
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 3198|      0|        error = SNMPERR_USM_GENERICERROR;
  ------------------
  |  |  226|      0|#define SNMPERR_USM_GENERICERROR		(-42)
  ------------------
 3199|      0|        goto err;
 3200|      0|    }
 3201|       |
 3202|       |
 3203|       |    /*
 3204|       |     * Perform the timeliness/time manager functions.
 3205|       |     */
 3206|      0|    if (secLevel == SNMP_SEC_LEVEL_AUTHNOPRIV
  ------------------
  |  |  300|      0|#define SNMP_SEC_LEVEL_AUTHNOPRIV	2
  ------------------
  |  Branch (3206:9): [True: 0, False: 0]
  ------------------
 3207|      0|        || secLevel == SNMP_SEC_LEVEL_AUTHPRIV) {
  ------------------
  |  |  301|      0|#define SNMP_SEC_LEVEL_AUTHPRIV		3
  ------------------
  |  Branch (3207:12): [True: 0, False: 0]
  ------------------
 3208|      0|        if (usm_check_and_update_timeliness(secEngineID, *secEngineIDLen,
  ------------------
  |  Branch (3208:13): [True: 0, False: 0]
  ------------------
 3209|      0|                                            boots_uint, time_uint,
 3210|      0|                                            &error) == -1) {
 3211|      0|            goto err;
 3212|      0|        }
 3213|      0|    }
 3214|      0|#ifdef							LCD_TIME_SYNC_OPT
 3215|       |    /*
 3216|       |     * Cache the unauthenticated time to use in case we don't have
 3217|       |     * anything better - this guess will be no worse than (0,0)
 3218|       |     * that we normally use.
 3219|       |     */
 3220|      0|    else {
 3221|      0|        set_enginetime(secEngineID, *secEngineIDLen,
 3222|      0|                       boots_uint, time_uint, FALSE);
  ------------------
  |  |  125|      0|#define FALSE 0
  ------------------
 3223|      0|    }
 3224|      0|#endif                          /* LCD_TIME_SYNC_OPT */
 3225|       |
 3226|       |
 3227|       |    /*
 3228|       |     * If needed, decrypt the scoped PDU.
 3229|       |     */
 3230|      0|    if (secLevel == SNMP_SEC_LEVEL_AUTHPRIV) {
  ------------------
  |  |  301|      0|#define SNMP_SEC_LEVEL_AUTHPRIV		3
  ------------------
  |  Branch (3230:9): [True: 0, False: 0]
  ------------------
 3231|      0|        int priv_type = sc_get_privtype(user->privProtocol,
 3232|      0|                                        user->privProtocolLen);
 3233|      0|        remaining = wholeMsgLen - (data_ptr - wholeMsg);
 3234|       |
 3235|      0|        if ((value_ptr = asn_parse_sequence(data_ptr, &remaining,
  ------------------
  |  Branch (3235:13): [True: 0, False: 0]
  ------------------
 3236|      0|                                            &type_value,
 3237|      0|                                            (ASN_UNIVERSAL | ASN_PRIMITIVE
  ------------------
  |  |   90|      0|#define ASN_UNIVERSAL	    0x00U
  ------------------
                                                          (ASN_UNIVERSAL | ASN_PRIMITIVE
  ------------------
  |  |   95|      0|#define ASN_PRIMITIVE	    0x00U
  ------------------
 3238|      0|                                             | ASN_OCTET_STR),
  ------------------
  |  |   78|      0|#define ASN_OCTET_STR	    0x04U
  ------------------
 3239|      0|                                            "encrypted sPDU")) == NULL) {
 3240|      0|            DEBUGMSGTL(("usm", "%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]
  |  |  ------------------
  ------------------
 3241|      0|                        "Failed while parsing encrypted sPDU."));
 3242|      0|            snmp_increment_statistic(STAT_SNMPINASNPARSEERRS);
  ------------------
  |  |  637|      0|#define  STAT_SNMPINASNPARSEERRS             14
  ------------------
 3243|      0|            usm_free_usmStateReference(*secStateRef);
 3244|      0|            *secStateRef = NULL;
 3245|      0|            error = SNMPERR_USM_PARSEERROR;
  ------------------
  |  |  231|      0|#define SNMPERR_USM_PARSEERROR			(-47)
  ------------------
 3246|      0|            goto err;
 3247|      0|        }
 3248|       |
 3249|      0|#ifndef NETSNMP_DISABLE_DES
 3250|      0|        if (USM_CREATE_USER_PRIV_DES == (priv_type & USM_PRIV_MASK_ALG)) {
  ------------------
  |  |  172|      0|#define USM_CREATE_USER_PRIV_DES            0x01
  ------------------
                      if (USM_CREATE_USER_PRIV_DES == (priv_type & USM_PRIV_MASK_ALG)) {
  ------------------
  |  |  166|      0|#define USM_PRIV_MASK_ALG                   0x0000ff
  ------------------
  |  Branch (3250:13): [True: 0, False: 0]
  ------------------
 3251|       |            /*
 3252|       |             * From RFC2574:
 3253|       |             * 
 3254|       |             * "Before decryption, the encrypted data length is verified.
 3255|       |             * If the length of the OCTET STRING to be decrypted is not
 3256|       |             * an integral multiple of 8 octets, the decryption process
 3257|       |             * is halted and an appropriate exception noted."  
 3258|       |             */
 3259|       |
 3260|      0|            if (remaining % 8 != 0) {
  ------------------
  |  Branch (3260:17): [True: 0, False: 0]
  ------------------
 3261|      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]
  |  |  ------------------
  ------------------
 3262|      0|                            "Ciphertext is %lu bytes, not an integer multiple of 8 (rem %lu)\n",
 3263|      0|                            (unsigned long)remaining, (unsigned long)remaining % 8));
 3264|      0|                snmp_increment_statistic(STAT_USMSTATSDECRYPTIONERRORS);
  ------------------
  |  |  625|      0|#define   STAT_USMSTATSDECRYPTIONERRORS      8
  ------------------
 3265|      0|                usm_free_usmStateReference(*secStateRef);
 3266|      0|                *secStateRef = NULL;
 3267|      0|                error = SNMPERR_USM_DECRYPTIONERROR;
  ------------------
  |  |  234|      0|#define SNMPERR_USM_DECRYPTIONERROR		(-50)
  ------------------
 3268|      0|                goto err;
 3269|      0|            }
 3270|       |
 3271|      0|            end_of_overhead = value_ptr;
 3272|      0|            iv_length = BYTESIZE(USM_DES_SALT_LENGTH);
  ------------------
  |  |   55|      0|#define BYTESIZE(bitsize)       ((bitsize + 7) >> 3)
  ------------------
 3273|       |
 3274|      0|            if (!user->privKey || user->privKeyLen < 2 * iv_length ||
  ------------------
  |  Branch (3274:17): [True: 0, False: 0]
  |  Branch (3274:35): [True: 0, False: 0]
  ------------------
 3275|      0|                salt_length < iv_length) {
  ------------------
  |  Branch (3275:17): [True: 0, False: 0]
  ------------------
 3276|      0|                DEBUGMSGTL(("usm", "No privacy pass phrase for %s\n", user->secName));
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 3277|      0|                snmp_increment_statistic(STAT_USMSTATSDECRYPTIONERRORS);
  ------------------
  |  |  625|      0|#define   STAT_USMSTATSDECRYPTIONERRORS      8
  ------------------
 3278|      0|                usm_free_usmStateReference(*secStateRef);
 3279|      0|                *secStateRef = NULL;
 3280|      0|                error = SNMPERR_USM_DECRYPTIONERROR;
  ------------------
  |  |  234|      0|#define SNMPERR_USM_DECRYPTIONERROR		(-50)
  ------------------
 3281|      0|                goto err;
 3282|      0|            }
 3283|       |
 3284|       |            /*
 3285|       |             * XOR the salt with the last (iv_length) bytes
 3286|       |             * of the priv_key to obtain the IV.
 3287|       |             */
 3288|      0|            for (i = 0; i < (int) iv_length; i++)
  ------------------
  |  Branch (3288:25): [True: 0, False: 0]
  ------------------
 3289|      0|                iv[i] = salt[i] ^ user->privKey[iv_length + i];
 3290|      0|        }
 3291|      0|#endif
 3292|      0|#ifdef HAVE_AES
 3293|      0|        if (USM_CREATE_USER_PRIV_AES == (priv_type & USM_PRIV_MASK_ALG)) {
  ------------------
  |  |  176|      0|#define USM_CREATE_USER_PRIV_AES            0x02
  ------------------
                      if (USM_CREATE_USER_PRIV_AES == (priv_type & USM_PRIV_MASK_ALG)) {
  ------------------
  |  |  166|      0|#define USM_PRIV_MASK_ALG                   0x0000ff
  ------------------
  |  Branch (3293:13): [True: 0, False: 0]
  ------------------
 3294|      0|            iv_length = BYTESIZE(USM_AES_SALT_LENGTH);
  ------------------
  |  |   55|      0|#define BYTESIZE(bitsize)       ((bitsize + 7) >> 3)
  ------------------
 3295|      0|            net_boots = ntohl(boots_uint);
 3296|      0|            net_time = ntohl(time_uint);
 3297|      0|            memcpy(iv, &net_boots, 4);
 3298|      0|            memcpy(iv+4, &net_time, 4);
 3299|      0|            memcpy(iv+8, salt, salt_length);
 3300|      0|        }
 3301|      0|#endif
 3302|       |
 3303|       |#ifdef NETSNMP_ENABLE_TESTING_CODE
 3304|       |        if (debug_is_token_registered("usm/dump") == SNMPERR_SUCCESS) {
 3305|       |            dump_chunk("usm/dump", "Cypher Text", value_ptr, remaining);
 3306|       |            dump_chunk("usm/dump", "salt + Encrypted form:",
 3307|       |                       salt, salt_length);
 3308|       |            dump_chunk("usm/dump", "IV + Encrypted form:", iv, iv_length);
 3309|       |        }
 3310|       |#endif
 3311|      0|        if (sc_decrypt(user->privProtocol, user->privProtocolLen,
  ------------------
  |  Branch (3311:13): [True: 0, False: 0]
  ------------------
 3312|      0|                       user->privKey, user->privKeyLen,
 3313|      0|                       iv, iv_length,
 3314|      0|                       value_ptr, remaining, *scopedPdu, scopedPduLen)
 3315|      0|            != SNMP_ERR_NOERROR) {
  ------------------
  |  |  212|      0|#define SNMP_ERR_NOERROR                (0)     /* XXX  Used only for PDUs? */
  ------------------
 3316|      0|            DEBUGMSGTL(("usm", "%s\n", "Failed decryption."));
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 3317|      0|            snmp_increment_statistic(STAT_USMSTATSDECRYPTIONERRORS);
  ------------------
  |  |  625|      0|#define   STAT_USMSTATSDECRYPTIONERRORS      8
  ------------------
 3318|      0|            error = SNMPERR_USM_DECRYPTIONERROR;
  ------------------
  |  |  234|      0|#define SNMPERR_USM_DECRYPTIONERROR		(-50)
  ------------------
 3319|      0|            goto err;
 3320|      0|        }
 3321|       |#ifdef NETSNMP_ENABLE_TESTING_CODE
 3322|       |        if (debug_is_token_registered("usm/dump") == SNMPERR_SUCCESS) {
 3323|       |            dump_chunk("usm/dump", "Decrypted chunk:",
 3324|       |                       *scopedPdu, *scopedPduLen);
 3325|       |        }
 3326|       |#endif
 3327|      0|    }
 3328|       |    /*
 3329|       |     * sPDU is plaintext.
 3330|       |     */
 3331|      0|    else {
 3332|      0|        *scopedPdu = data_ptr;
 3333|      0|        *scopedPduLen = wholeMsgLen - (data_ptr - wholeMsg);
 3334|      0|        end_of_overhead = data_ptr;
 3335|       |
 3336|      0|    }                           /* endif -- PDU decryption */
 3337|       |
 3338|       |
 3339|       |    /*
 3340|       |     * Calculate the biggest sPDU for the response (i.e., whole - ovrhd).
 3341|       |     *
 3342|       |     * FIX  Correct? 
 3343|       |     */
 3344|      0|    *maxSizeResponse = maxMsgSize - (end_of_overhead - wholeMsg);
 3345|       |
 3346|       |
 3347|      0|    DEBUGMSGTL(("usm", "USM processing completed.\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]
  |  |  ------------------
  ------------------
 3348|       |
 3349|      0|    return SNMPERR_SUCCESS;
  ------------------
  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 3350|       |
 3351|      2|err:
 3352|      2|    usm_free_usmStateReference(*secStateRef);
 3353|      2|    *secStateRef = NULL;
 3354|       |    netsnmp_assert(error != SNMPERR_SUCCESS);
  ------------------
  |  |   47|      2|#      define netsnmp_assert(x)  do { \
  |  |   48|      2|              if ( x ) \
  |  |  ------------------
  |  |  |  Branch (48:20): [True: 2, False: 0]
  |  |  ------------------
  |  |   49|      2|                 ; \
  |  |   50|      2|              else \
  |  |   51|      2|                 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
  |  |  |  |  ------------------
  |  |  |  |  |  | 1727|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|      2|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded, False: 2]
  |  |  ------------------
  ------------------
 3355|      2|    return error;
 3356|      0|}                               /* end usm_process_in_msg() */
snmpusm.c:usm_malloc_usmStateReference:
  288|      2|{
  289|      2|    struct usmStateReference *retval;
  290|       |
  291|      2|    retval = calloc(1, sizeof(struct usmStateReference));
  292|      2|    if (retval)
  ------------------
  |  Branch (292:9): [True: 2, False: 0]
  ------------------
  293|      2|        retval->refcnt = 1;
  294|       |
  295|      2|    return retval;
  296|      2|}                               /* end usm_malloc_usmStateReference() */
snmpusm.c:usm_parse_security_parameters:
 2477|      2|{
 2478|      2|    u_char         *parse_ptr = secParams;
 2479|      2|    u_char         *value_ptr;
 2480|      2|    u_char         *next_ptr;
 2481|      2|    u_char          type_value;
 2482|       |
 2483|      2|    size_t          octet_string_length = remaining;
 2484|      2|    size_t          sequence_length;
 2485|      2|    size_t          remaining_bytes;
 2486|       |
 2487|      2|    long            boots_long;
 2488|      2|    long            time_long;
 2489|       |
 2490|      2|    u_int           origNameLen;
 2491|       |
 2492|       |
 2493|       |    /*
 2494|       |     * Eat the first octet header.
 2495|       |     */
 2496|      2|    if ((value_ptr = asn_parse_sequence(parse_ptr, &octet_string_length,
  ------------------
  |  Branch (2496:9): [True: 0, False: 2]
  ------------------
 2497|      2|                                        &type_value,
 2498|      2|                                        (ASN_UNIVERSAL | ASN_PRIMITIVE |
  ------------------
  |  |   90|      2|#define ASN_UNIVERSAL	    0x00U
  ------------------
                                                      (ASN_UNIVERSAL | ASN_PRIMITIVE |
  ------------------
  |  |   95|      2|#define ASN_PRIMITIVE	    0x00U
  ------------------
 2499|      2|                                         ASN_OCTET_STR),
  ------------------
  |  |   78|      2|#define ASN_OCTET_STR	    0x04U
  ------------------
 2500|      2|                                        "usm first octet")) == NULL) {
 2501|       |        /*
 2502|       |         * RETURN parse error 
 2503|      0|         */ return -1;
 2504|      0|    }
 2505|       |
 2506|       |
 2507|       |    /*
 2508|       |     * Eat the sequence header.
 2509|       |     */
 2510|      2|    parse_ptr = value_ptr;
 2511|      2|    sequence_length = octet_string_length;
 2512|       |
 2513|      2|    if ((value_ptr = asn_parse_sequence(parse_ptr, &sequence_length,
  ------------------
  |  Branch (2513:9): [True: 1, False: 1]
  ------------------
 2514|      2|                                        &type_value,
 2515|      2|                                        (ASN_SEQUENCE | ASN_CONSTRUCTOR),
  ------------------
  |  |   84|      2|#define ASN_SEQUENCE	    0x10U
  ------------------
                                                      (ASN_SEQUENCE | ASN_CONSTRUCTOR),
  ------------------
  |  |   96|      2|#define ASN_CONSTRUCTOR	    0x20U
  ------------------
 2516|      2|                                        "usm sequence")) == NULL) {
 2517|       |        /*
 2518|       |         * RETURN parse error 
 2519|      1|         */ return -1;
 2520|      1|    }
 2521|       |
 2522|       |
 2523|       |    /*
 2524|       |     * Retrieve the engineID.
 2525|       |     */
 2526|      1|    parse_ptr = value_ptr;
 2527|      1|    remaining_bytes = sequence_length;
 2528|       |
 2529|      1|    DEBUGDUMPHEADER("recv", "msgAuthoritativeEngineID");
  ------------------
  |  |   79|      1|	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  178|      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__))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  179|      0|        debugmsg("dumph_" token,x); \
  |  |  |  |  180|      0|        if (debug_is_token_registered("dumpx" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (180:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  181|      0|            debug_is_token_registered("dumpv" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (181:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  182|      0|            (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|      0|             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|      0|            debugmsg("dumph_" token,"\n"); \
  |  |  |  |  185|      0|        } else { \
  |  |  |  |  186|      0|            debugmsg("dumph_" token,"  "); \
  |  |  |  |  187|      0|        } \
  |  |  |  |  188|      0|        __DBGINDENTMORE()
  |  |  |  |  ------------------
  |  |  |  |  |  |  173|      0|#define __DBGINDENTMORE()  debug_indent_add(2)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (79:55): [Folded, False: 1]
  |  |  ------------------
  ------------------
 2530|      1|    if ((next_ptr
  ------------------
  |  Branch (2530:9): [True: 0, False: 1]
  ------------------
 2531|      1|         = asn_parse_string(parse_ptr, &remaining_bytes, &type_value,
 2532|      1|                            secEngineID, secEngineIDLen)) == NULL) {
 2533|      0|        DEBUGINDENTLESS();
  ------------------
  |  |   75|      0|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2534|       |        /*
 2535|       |         * RETURN parse error 
 2536|      0|         */ return -1;
 2537|      0|    }
 2538|      1|    DEBUGINDENTLESS();
  ------------------
  |  |   75|      1|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 1]
  |  |  ------------------
  ------------------
 2539|       |
 2540|      1|    if (type_value !=
  ------------------
  |  Branch (2540:9): [True: 0, False: 1]
  ------------------
 2541|      1|        (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_OCTET_STR)) {
  ------------------
  |  |   90|      1|#define ASN_UNIVERSAL	    0x00U
  ------------------
                      (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_OCTET_STR)) {
  ------------------
  |  |   95|      1|#define ASN_PRIMITIVE	    0x00U
  ------------------
                      (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_OCTET_STR)) {
  ------------------
  |  |   78|      1|#define ASN_OCTET_STR	    0x04U
  ------------------
 2542|       |        /*
 2543|       |         * RETURN parse error 
 2544|      0|         */ return -1;
 2545|      0|    }
 2546|       |
 2547|       |
 2548|       |    /*
 2549|       |     * Retrieve the engine boots, notice switch in the way next_ptr and
 2550|       |     * remaining_bytes are used (to accommodate the asn code).
 2551|       |     */
 2552|      1|    DEBUGDUMPHEADER("recv", "msgAuthoritativeEngineBoots");
  ------------------
  |  |   79|      1|	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  178|      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__))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  179|      0|        debugmsg("dumph_" token,x); \
  |  |  |  |  180|      0|        if (debug_is_token_registered("dumpx" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (180:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  181|      0|            debug_is_token_registered("dumpv" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (181:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  182|      0|            (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|      0|             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|      0|            debugmsg("dumph_" token,"\n"); \
  |  |  |  |  185|      0|        } else { \
  |  |  |  |  186|      0|            debugmsg("dumph_" token,"  "); \
  |  |  |  |  187|      0|        } \
  |  |  |  |  188|      0|        __DBGINDENTMORE()
  |  |  |  |  ------------------
  |  |  |  |  |  |  173|      0|#define __DBGINDENTMORE()  debug_indent_add(2)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (79:55): [Folded, False: 1]
  |  |  ------------------
  ------------------
 2553|      1|    if ((next_ptr = asn_parse_int(next_ptr, &remaining_bytes, &type_value,
  ------------------
  |  Branch (2553:9): [True: 0, False: 1]
  ------------------
 2554|      1|                                  &boots_long, sizeof(long))) == NULL) {
 2555|      0|        DEBUGINDENTLESS();
  ------------------
  |  |   75|      0|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2556|       |        /*
 2557|       |         * RETURN parse error 
 2558|      0|         */ return -1;
 2559|      0|    }
 2560|      1|    DEBUGINDENTLESS();
  ------------------
  |  |   75|      1|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 1]
  |  |  ------------------
  ------------------
 2561|       |
 2562|      1|    if (type_value !=
  ------------------
  |  Branch (2562:9): [True: 0, False: 1]
  ------------------
 2563|      1|        (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER)) {
  ------------------
  |  |   90|      1|#define ASN_UNIVERSAL	    0x00U
  ------------------
                      (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER)) {
  ------------------
  |  |   95|      1|#define ASN_PRIMITIVE	    0x00U
  ------------------
                      (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER)) {
  ------------------
  |  |   75|      1|#define ASN_INTEGER	    0x02U
  ------------------
 2564|      0|        DEBUGINDENTLESS();
  ------------------
  |  |   75|      0|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2565|       |        /*
 2566|       |         * RETURN parse error 
 2567|      0|         */ return -1;
 2568|      0|    }
 2569|       |
 2570|      1|    *boots_uint = (u_int) boots_long;
 2571|       |
 2572|       |
 2573|       |    /*
 2574|       |     * Retrieve the time value.
 2575|       |     */
 2576|      1|    DEBUGDUMPHEADER("recv", "msgAuthoritativeEngineTime");
  ------------------
  |  |   79|      1|	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  178|      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__))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  179|      0|        debugmsg("dumph_" token,x); \
  |  |  |  |  180|      0|        if (debug_is_token_registered("dumpx" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (180:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  181|      0|            debug_is_token_registered("dumpv" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (181:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  182|      0|            (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|      0|             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|      0|            debugmsg("dumph_" token,"\n"); \
  |  |  |  |  185|      0|        } else { \
  |  |  |  |  186|      0|            debugmsg("dumph_" token,"  "); \
  |  |  |  |  187|      0|        } \
  |  |  |  |  188|      0|        __DBGINDENTMORE()
  |  |  |  |  ------------------
  |  |  |  |  |  |  173|      0|#define __DBGINDENTMORE()  debug_indent_add(2)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (79:55): [Folded, False: 1]
  |  |  ------------------
  ------------------
 2577|      1|    if ((next_ptr = asn_parse_int(next_ptr, &remaining_bytes, &type_value,
  ------------------
  |  Branch (2577:9): [True: 0, False: 1]
  ------------------
 2578|      1|                                  &time_long, sizeof(long))) == NULL) {
 2579|       |        /*
 2580|       |         * RETURN parse error 
 2581|      0|         */ return -1;
 2582|      0|    }
 2583|      1|    DEBUGINDENTLESS();
  ------------------
  |  |   75|      1|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 1]
  |  |  ------------------
  ------------------
 2584|       |
 2585|      1|    if (type_value !=
  ------------------
  |  Branch (2585:9): [True: 0, False: 1]
  ------------------
 2586|      1|        (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER)) {
  ------------------
  |  |   90|      1|#define ASN_UNIVERSAL	    0x00U
  ------------------
                      (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER)) {
  ------------------
  |  |   95|      1|#define ASN_PRIMITIVE	    0x00U
  ------------------
                      (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER)) {
  ------------------
  |  |   75|      1|#define ASN_INTEGER	    0x02U
  ------------------
 2587|       |        /*
 2588|       |         * RETURN parse error 
 2589|      0|         */ return -1;
 2590|      0|    }
 2591|       |
 2592|      1|    *time_uint = (u_int) time_long;
 2593|       |
 2594|      1|    if (boots_long < 0 || boots_long > ENGINEBOOT_MAX ||
  ------------------
  |  |  183|      2|#define ENGINEBOOT_MAX	2147483647      /* ((2^31)-1) */
  ------------------
  |  Branch (2594:9): [True: 0, False: 1]
  |  Branch (2594:27): [True: 0, False: 1]
  ------------------
 2595|      1|        time_long < 0 || time_long > ENGINETIME_MAX) {
  ------------------
  |  |  182|      1|#define ENGINETIME_MAX	2147483647      /* ((2^31)-1) */
  ------------------
  |  Branch (2595:9): [True: 0, False: 1]
  |  Branch (2595:26): [True: 0, False: 1]
  ------------------
 2596|      0|        return -1;
 2597|      0|    }
 2598|       |
 2599|       |    /*
 2600|       |     * Retrieve the secName.
 2601|       |     */
 2602|      1|    origNameLen = *secNameLen;
 2603|       |
 2604|       |
 2605|      1|    DEBUGDUMPHEADER("recv", "msgUserName");
  ------------------
  |  |   79|      1|	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  178|      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__))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  179|      0|        debugmsg("dumph_" token,x); \
  |  |  |  |  180|      0|        if (debug_is_token_registered("dumpx" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (180:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  181|      0|            debug_is_token_registered("dumpv" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (181:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  182|      0|            (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|      0|             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|      0|            debugmsg("dumph_" token,"\n"); \
  |  |  |  |  185|      0|        } else { \
  |  |  |  |  186|      0|            debugmsg("dumph_" token,"  "); \
  |  |  |  |  187|      0|        } \
  |  |  |  |  188|      0|        __DBGINDENTMORE()
  |  |  |  |  ------------------
  |  |  |  |  |  |  173|      0|#define __DBGINDENTMORE()  debug_indent_add(2)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (79:55): [Folded, False: 1]
  |  |  ------------------
  ------------------
 2606|      1|    if ((next_ptr
  ------------------
  |  Branch (2606:9): [True: 1, False: 0]
  ------------------
 2607|      1|         = asn_parse_string(next_ptr, &remaining_bytes, &type_value,
 2608|      1|                            (u_char *) secName, secNameLen)) == NULL) {
 2609|      1|        DEBUGINDENTLESS();
  ------------------
  |  |   75|      1|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|      1|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 1]
  |  |  ------------------
  ------------------
 2610|       |        /*
 2611|       |         * RETURN parse error 
 2612|      1|         */ return -1;
 2613|      1|    }
 2614|      0|    DEBUGINDENTLESS();
  ------------------
  |  |   75|      0|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2615|       |
 2616|       |    /*
 2617|       |     * FIX -- doesn't this also indicate a buffer overrun?
 2618|       |     */
 2619|      0|    if (origNameLen < *secNameLen + 1) {
  ------------------
  |  Branch (2619:9): [True: 0, False: 0]
  ------------------
 2620|       |        /*
 2621|       |         * RETURN parse error, but it's really a parameter error 
 2622|       |         */
 2623|      0|        return -1;
 2624|      0|    }
 2625|       |
 2626|      0|    if (*secNameLen > 32) {
  ------------------
  |  Branch (2626:9): [True: 0, False: 0]
  ------------------
 2627|       |        /*
 2628|       |         * This is a USM-specific limitation over and above the above
 2629|       |         * limitation (which will probably default to the length of an
 2630|       |         * SnmpAdminString, i.e. 255).  See RFC 2574, sec. 2.4.  
 2631|       |         */
 2632|      0|        return -1;
 2633|      0|    }
 2634|       |
 2635|      0|    secName[*secNameLen] = '\0';
 2636|       |
 2637|      0|    if (type_value !=
  ------------------
  |  Branch (2637:9): [True: 0, False: 0]
  ------------------
 2638|      0|        (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_OCTET_STR)) {
  ------------------
  |  |   90|      0|#define ASN_UNIVERSAL	    0x00U
  ------------------
                      (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_OCTET_STR)) {
  ------------------
  |  |   95|      0|#define ASN_PRIMITIVE	    0x00U
  ------------------
                      (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_OCTET_STR)) {
  ------------------
  |  |   78|      0|#define ASN_OCTET_STR	    0x04U
  ------------------
 2639|       |        /*
 2640|       |         * RETURN parse error 
 2641|      0|         */ return -1;
 2642|      0|    }
 2643|       |
 2644|       |
 2645|       |    /*
 2646|       |     * Retrieve the signature and blank it if there.
 2647|       |     */
 2648|      0|    DEBUGDUMPHEADER("recv", "msgAuthenticationParameters");
  ------------------
  |  |   79|      0|	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  178|      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__))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  179|      0|        debugmsg("dumph_" token,x); \
  |  |  |  |  180|      0|        if (debug_is_token_registered("dumpx" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (180:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  181|      0|            debug_is_token_registered("dumpv" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (181:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  182|      0|            (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|      0|             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|      0|            debugmsg("dumph_" token,"\n"); \
  |  |  |  |  185|      0|        } else { \
  |  |  |  |  186|      0|            debugmsg("dumph_" token,"  "); \
  |  |  |  |  187|      0|        } \
  |  |  |  |  188|      0|        __DBGINDENTMORE()
  |  |  |  |  ------------------
  |  |  |  |  |  |  173|      0|#define __DBGINDENTMORE()  debug_indent_add(2)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (79:55): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2649|      0|    if ((next_ptr
  ------------------
  |  Branch (2649:9): [True: 0, False: 0]
  ------------------
 2650|      0|         = asn_parse_string(next_ptr, &remaining_bytes, &type_value,
 2651|      0|                            signature, signature_length)) == NULL) {
 2652|      0|        DEBUGINDENTLESS();
  ------------------
  |  |   75|      0|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2653|       |        /*
 2654|       |         * RETURN parse error 
 2655|      0|         */ return -1;
 2656|      0|    }
 2657|      0|    DEBUGINDENTLESS();
  ------------------
  |  |   75|      0|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2658|       |
 2659|      0|    if (type_value !=
  ------------------
  |  Branch (2659:9): [True: 0, False: 0]
  ------------------
 2660|      0|        (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_OCTET_STR)) {
  ------------------
  |  |   90|      0|#define ASN_UNIVERSAL	    0x00U
  ------------------
                      (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_OCTET_STR)) {
  ------------------
  |  |   95|      0|#define ASN_PRIMITIVE	    0x00U
  ------------------
                      (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_OCTET_STR)) {
  ------------------
  |  |   78|      0|#define ASN_OCTET_STR	    0x04U
  ------------------
 2661|       |        /*
 2662|       |         * RETURN parse error 
 2663|      0|         */ return -1;
 2664|      0|    }
 2665|       |
 2666|      0|    if (*signature_length != 0) {       /* Blanking for authentication step later */
  ------------------
  |  Branch (2666:9): [True: 0, False: 0]
  ------------------
 2667|      0|        memset(next_ptr - (u_long) * signature_length,
 2668|      0|               0, *signature_length);
 2669|      0|    }
 2670|       |
 2671|       |
 2672|       |    /*
 2673|       |     * Retrieve the salt.
 2674|       |     *
 2675|       |     * Note that the next ptr is where the data section starts.
 2676|       |     */
 2677|      0|    DEBUGDUMPHEADER("recv", "msgPrivacyParameters");
  ------------------
  |  |   79|      0|	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  178|      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__))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  179|      0|        debugmsg("dumph_" token,x); \
  |  |  |  |  180|      0|        if (debug_is_token_registered("dumpx" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (180:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  181|      0|            debug_is_token_registered("dumpv" token) == SNMPERR_SUCCESS ||    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (181:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  182|      0|            (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|      0|             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|      0|            debugmsg("dumph_" token,"\n"); \
  |  |  |  |  185|      0|        } else { \
  |  |  |  |  186|      0|            debugmsg("dumph_" token,"  "); \
  |  |  |  |  187|      0|        } \
  |  |  |  |  188|      0|        __DBGINDENTMORE()
  |  |  |  |  ------------------
  |  |  |  |  |  |  173|      0|#define __DBGINDENTMORE()  debug_indent_add(2)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (79:55): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2678|      0|    if ((*data_ptr
  ------------------
  |  Branch (2678:9): [True: 0, False: 0]
  ------------------
 2679|      0|         = asn_parse_string(next_ptr, &remaining_bytes, &type_value,
 2680|      0|                            salt, salt_length)) == NULL) {
 2681|      0|        DEBUGINDENTLESS();
  ------------------
  |  |   75|      0|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2682|       |        /*
 2683|       |         * RETURN parse error 
 2684|      0|         */ return -2;
 2685|      0|    }
 2686|      0|    DEBUGINDENTLESS();
  ------------------
  |  |   75|      0|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2687|       |
 2688|      0|    if (type_value !=
  ------------------
  |  Branch (2688:9): [True: 0, False: 0]
  ------------------
 2689|      0|        (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_OCTET_STR)) {
  ------------------
  |  |   90|      0|#define ASN_UNIVERSAL	    0x00U
  ------------------
                      (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_OCTET_STR)) {
  ------------------
  |  |   95|      0|#define ASN_PRIMITIVE	    0x00U
  ------------------
                      (u_char) (ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_OCTET_STR)) {
  ------------------
  |  |   78|      0|#define ASN_OCTET_STR	    0x04U
  ------------------
 2690|       |        /*
 2691|       |         * RETURN parse error 
 2692|      0|         */ return -2;
 2693|      0|    }
 2694|       |
 2695|      0|    return 0;
 2696|       |
 2697|      0|}                               /* end usm_parse_security_parameters() */
snmpusm.c:usm_free_usmStateReference:
  321|      6|{
  322|      6|    struct usmStateReference *ref = old;
  323|       |
  324|      6|    if (!ref)
  ------------------
  |  Branch (324:9): [True: 4, False: 2]
  ------------------
  325|      4|        return;
  326|       |
  327|      2|    if (--ref->refcnt > 0)
  ------------------
  |  Branch (327:9): [True: 0, False: 2]
  ------------------
  328|      0|        return;
  329|       |
  330|      2|    SNMP_FREE(ref->usr_name);
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
  331|      2|    SNMP_FREE(ref->usr_engine_id);
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
  332|      2|    SNMP_FREE(ref->usr_auth_protocol);
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
  333|      2|    SNMP_FREE(ref->usr_priv_protocol);
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
  334|       |
  335|      2|    if (ref->usr_auth_key_length && ref->usr_auth_key) {
  ------------------
  |  Branch (335:9): [True: 0, False: 2]
  |  Branch (335:37): [True: 0, False: 0]
  ------------------
  336|      0|        SNMP_ZERO(ref->usr_auth_key, ref->usr_auth_key_length);
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
  337|      0|        SNMP_FREE(ref->usr_auth_key);
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
  338|      0|    }
  339|      2|    if (ref->usr_priv_key_length && ref->usr_priv_key) {
  ------------------
  |  Branch (339:9): [True: 0, False: 2]
  |  Branch (339:37): [True: 0, False: 0]
  ------------------
  340|      0|        SNMP_ZERO(ref->usr_priv_key, ref->usr_priv_key_length);
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
  341|      0|        SNMP_FREE(ref->usr_priv_key);
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
  342|      0|    }
  343|       |
  344|       |    SNMP_FREE(ref);
  ------------------
  |  |   62|      2|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 2, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 2]
  |  |  ------------------
  ------------------
  345|      2|}                               /* end usm_free_usmStateReference() */
snmpusm.c:usm_session_init:
 3466|     58|{
 3467|     58|    char *cp;
 3468|     58|    size_t i;
 3469|       |    
 3470|     58|    if (in_session->securityAuthProtoLen > 0) {
  ------------------
  |  Branch (3470:9): [True: 0, False: 58]
  ------------------
 3471|      0|        session->securityAuthProto =
 3472|      0|            snmp_duplicate_objid(in_session->securityAuthProto,
 3473|      0|                                 in_session->securityAuthProtoLen);
 3474|      0|        if (session->securityAuthProto == NULL) {
  ------------------
  |  Branch (3474:13): [True: 0, False: 0]
  ------------------
 3475|      0|            in_session->s_snmp_errno = SNMPERR_MALLOC;
  ------------------
  |  |  246|      0|#define SNMPERR_MALLOC			(-62)
  ------------------
 3476|      0|            return SNMPERR_MALLOC;
  ------------------
  |  |  246|      0|#define SNMPERR_MALLOC			(-62)
  ------------------
 3477|      0|        }
 3478|     58|    } else if (get_default_authtype(&i) != NULL) {
  ------------------
  |  Branch (3478:16): [True: 58, False: 0]
  ------------------
 3479|     58|        session->securityAuthProto =
 3480|     58|            snmp_duplicate_objid(get_default_authtype(NULL), i);
 3481|     58|        session->securityAuthProtoLen = i;
 3482|     58|    }
 3483|       |
 3484|     58|    if (in_session->securityPrivProtoLen > 0) {
  ------------------
  |  Branch (3484:9): [True: 0, False: 58]
  ------------------
 3485|      0|        session->securityPrivProto =
 3486|      0|            snmp_duplicate_objid(in_session->securityPrivProto,
 3487|      0|                                 in_session->securityPrivProtoLen);
 3488|      0|        if (session->securityPrivProto == NULL) {
  ------------------
  |  Branch (3488:13): [True: 0, False: 0]
  ------------------
 3489|      0|            in_session->s_snmp_errno = SNMPERR_MALLOC;
  ------------------
  |  |  246|      0|#define SNMPERR_MALLOC			(-62)
  ------------------
 3490|      0|            return SNMPERR_MALLOC;
  ------------------
  |  |  246|      0|#define SNMPERR_MALLOC			(-62)
  ------------------
 3491|      0|        }
 3492|     58|    } else if (get_default_privtype(&i) != NULL) {
  ------------------
  |  Branch (3492:16): [True: 58, False: 0]
  ------------------
 3493|     58|        session->securityPrivProto =
 3494|     58|            snmp_duplicate_objid(get_default_privtype(NULL), i);
 3495|     58|        session->securityPrivProtoLen = i;
 3496|     58|    }
 3497|       |
 3498|     58|    if ((in_session->securityAuthKeyLen <= 0) &&
  ------------------
  |  Branch (3498:9): [True: 58, False: 0]
  ------------------
 3499|     58|        ((cp = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (3499:9): [True: 0, False: 58]
  ------------------
 3500|     58|				     NETSNMP_DS_LIB_AUTHMASTERKEY)))) {
  ------------------
  |  |  167|     58|#define NETSNMP_DS_LIB_AUTHMASTERKEY     16
  ------------------
 3501|      0|        size_t buflen = sizeof(session->securityAuthKey);
 3502|      0|        u_char *tmpp = session->securityAuthKey;
 3503|      0|        session->securityAuthKeyLen = 0;
 3504|       |        /* it will be a hex string */
 3505|      0|        if (!snmp_hex_to_binary(&tmpp, &buflen,
  ------------------
  |  Branch (3505:13): [True: 0, False: 0]
  ------------------
 3506|      0|                                &session->securityAuthKeyLen, 0, cp)) {
 3507|      0|            snmp_set_detail("error parsing authentication master key");
 3508|      0|            return SNMP_ERR_GENERR;
  ------------------
  |  |  217|      0|#define SNMP_ERR_GENERR	                (5)
  ------------------
 3509|      0|        }
 3510|     58|    } else if ((in_session->securityAuthKeyLen <= 0) &&
  ------------------
  |  Branch (3510:16): [True: 58, False: 0]
  ------------------
 3511|     58|               ((cp = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (3511:17): [True: 0, False: 58]
  ------------------
 3512|     58|                                            NETSNMP_DS_LIB_AUTHPASSPHRASE)) ||
  ------------------
  |  |  154|     58|#define NETSNMP_DS_LIB_AUTHPASSPHRASE    3
  ------------------
 3513|     58|                (cp = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (3513:17): [True: 0, False: 58]
  ------------------
 3514|     58|                                            NETSNMP_DS_LIB_PASSPHRASE)))) {
  ------------------
  |  |  153|     58|#define NETSNMP_DS_LIB_PASSPHRASE        2
  ------------------
 3515|      0|        session->securityAuthKeyLen = USM_AUTH_KU_LEN;
  ------------------
  |  |  271|      0|#define USM_AUTH_KU_LEN     64
  ------------------
 3516|      0|        if (generate_Ku(session->securityAuthProto,
  ------------------
  |  Branch (3516:13): [True: 0, False: 0]
  ------------------
 3517|      0|                        session->securityAuthProtoLen,
 3518|      0|                        (u_char *) cp, strlen(cp),
 3519|      0|                        session->securityAuthKey,
 3520|      0|                        &session->securityAuthKeyLen) != SNMPERR_SUCCESS) {
  ------------------
  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 3521|      0|            snmp_set_detail
 3522|      0|                ("Error generating a key (Ku) from the supplied authentication pass phrase.");
 3523|      0|            return SNMP_ERR_GENERR;
  ------------------
  |  |  217|      0|#define SNMP_ERR_GENERR	                (5)
  ------------------
 3524|      0|        }
 3525|      0|    }
 3526|       |
 3527|       |    
 3528|     58|    if ((in_session->securityPrivKeyLen <= 0) &&
  ------------------
  |  Branch (3528:9): [True: 58, False: 0]
  ------------------
 3529|     58|        ((cp = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (3529:9): [True: 0, False: 58]
  ------------------
 3530|     58|				     NETSNMP_DS_LIB_PRIVMASTERKEY)))) {
  ------------------
  |  |  168|     58|#define NETSNMP_DS_LIB_PRIVMASTERKEY     17
  ------------------
 3531|      0|        size_t buflen = sizeof(session->securityPrivKey);
 3532|      0|        u_char *tmpp = session->securityPrivKey;
 3533|      0|        session->securityPrivKeyLen = 0;
 3534|       |        /* it will be a hex string */
 3535|      0|        if (!snmp_hex_to_binary(&tmpp, &buflen,
  ------------------
  |  Branch (3535:13): [True: 0, False: 0]
  ------------------
 3536|      0|                                &session->securityPrivKeyLen, 0, cp)) {
 3537|      0|            snmp_set_detail("error parsing encryption master key");
 3538|      0|            return SNMP_ERR_GENERR;
  ------------------
  |  |  217|      0|#define SNMP_ERR_GENERR	                (5)
  ------------------
 3539|      0|        }
 3540|     58|    } else if ((in_session->securityPrivKeyLen <= 0) &&
  ------------------
  |  Branch (3540:16): [True: 58, False: 0]
  ------------------
 3541|     58|               ((cp = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (3541:17): [True: 0, False: 58]
  ------------------
 3542|     58|                                            NETSNMP_DS_LIB_PRIVPASSPHRASE)) ||
  ------------------
  |  |  155|     58|#define NETSNMP_DS_LIB_PRIVPASSPHRASE    4
  ------------------
 3543|     58|                (cp = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (3543:17): [True: 0, False: 58]
  ------------------
 3544|     58|                                            NETSNMP_DS_LIB_PASSPHRASE)))) {
  ------------------
  |  |  153|     58|#define NETSNMP_DS_LIB_PASSPHRASE        2
  ------------------
 3545|      0|        session->securityPrivKeyLen = USM_PRIV_KU_LEN;
  ------------------
  |  |  272|      0|#define USM_PRIV_KU_LEN     64
  ------------------
 3546|      0|        if (generate_Ku(session->securityAuthProto,
  ------------------
  |  Branch (3546:13): [True: 0, False: 0]
  ------------------
 3547|      0|                        session->securityAuthProtoLen,
 3548|      0|                        (u_char *) cp, strlen(cp),
 3549|      0|                        session->securityPrivKey,
 3550|      0|                        &session->securityPrivKeyLen) != SNMPERR_SUCCESS) {
  ------------------
  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 3551|      0|            snmp_set_detail
 3552|      0|                ("Error generating a key (Ku) from the supplied privacy pass phrase.");
 3553|      0|            return SNMP_ERR_GENERR;
  ------------------
  |  |  217|      0|#define SNMP_ERR_GENERR	                (5)
  ------------------
 3554|      0|        }
 3555|      0|    }
 3556|       |
 3557|     58|    return SNMPERR_SUCCESS;
  ------------------
  |  |  184|     58|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 3558|     58|}
snmpusm.c:usm_handle_report:
 3386|      2|{
 3387|       |    /*
 3388|       |     * handle reportable errors 
 3389|       |     */
 3390|       |
 3391|       |    /* this will get in our way */
 3392|      2|    usm_free_usmStateReference(pdu->securityStateRef);
 3393|      2|    pdu->securityStateRef = NULL;
 3394|       |
 3395|      2|    switch (result) {
  ------------------
  |  Branch (3395:13): [True: 0, False: 2]
  ------------------
 3396|      0|    case SNMPERR_USM_AUTHENTICATIONFAILURE:
  ------------------
  |  |  230|      0|#define SNMPERR_USM_AUTHENTICATIONFAILURE	(-46)
  ------------------
  |  Branch (3396:5): [True: 0, False: 2]
  ------------------
 3397|      0|    {
 3398|      0|        int res = session->s_snmp_errno;
 3399|      0|        session->s_snmp_errno = result;
 3400|      0|        if (session->callback) {
  ------------------
  |  Branch (3400:13): [True: 0, False: 0]
  ------------------
 3401|      0|            session->callback(NETSNMP_CALLBACK_OP_RECEIVED_MESSAGE,
  ------------------
  |  |  319|      0|#define NETSNMP_CALLBACK_OP_RECEIVED_MESSAGE	1
  ------------------
 3402|      0|                              session, pdu->reqid, pdu,
 3403|      0|                              session->callback_magic);
 3404|      0|        }
 3405|      0|        session->s_snmp_errno = res;
 3406|      0|    }  
 3407|      0|    NETSNMP_FALLTHROUGH;
  ------------------
  |  | 2443|      0|#    define NETSNMP_FALLTHROUGH __attribute__((__fallthrough__))
  ------------------
 3408|      0|    case SNMPERR_USM_UNKNOWNENGINEID:
  ------------------
  |  |  232|      0|#define SNMPERR_USM_UNKNOWNENGINEID		(-48)
  ------------------
  |  Branch (3408:5): [True: 0, False: 2]
  ------------------
 3409|      0|    case SNMPERR_USM_UNKNOWNSECURITYNAME:
  ------------------
  |  |  227|      0|#define SNMPERR_USM_UNKNOWNSECURITYNAME		(-43)
  ------------------
  |  Branch (3409:5): [True: 0, False: 2]
  ------------------
 3410|      0|    case SNMPERR_USM_UNSUPPORTEDSECURITYLEVEL:
  ------------------
  |  |  228|      0|#define SNMPERR_USM_UNSUPPORTEDSECURITYLEVEL	(-44)
  ------------------
  |  Branch (3410:5): [True: 0, False: 2]
  ------------------
 3411|      0|    case SNMPERR_USM_NOTINTIMEWINDOW:
  ------------------
  |  |  233|      0|#define SNMPERR_USM_NOTINTIMEWINDOW		(-49)
  ------------------
  |  Branch (3411:5): [True: 0, False: 2]
  ------------------
 3412|      0|    case SNMPERR_USM_DECRYPTIONERROR:
  ------------------
  |  |  234|      0|#define SNMPERR_USM_DECRYPTIONERROR		(-50)
  ------------------
  |  Branch (3412:5): [True: 0, False: 2]
  ------------------
 3413|       |
 3414|      0|        if (SNMP_CMD_CONFIRMED(pdu->command) ||
  ------------------
  |  |  193|      0|#define SNMP_CMD_CONFIRMED(c) (c == SNMP_MSG_INFORM || c == SNMP_MSG_GETBULK ||\
  |  |  ------------------
  |  |  |  |  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
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define SNMP_CMD_CONFIRMED(c) (c == SNMP_MSG_INFORM || c == SNMP_MSG_GETBULK ||\
  |  |  ------------------
  |  |  |  |  140|      0|#define SNMP_MSG_GETBULK    (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x5) /* a5=165 */
  |  |  |  |  ------------------
  |  |  |  |  |  |   92|      0|#define ASN_CONTEXT	    0x80U
  |  |  |  |  ------------------
  |  |  |  |               #define SNMP_MSG_GETBULK    (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x5) /* a5=165 */
  |  |  |  |  ------------------
  |  |  |  |  |  |   96|      0|#define ASN_CONSTRUCTOR	    0x20U
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (193:32): [True: 0, False: 0]
  |  |  |  Branch (193:56): [True: 0, False: 0]
  |  |  ------------------
  |  |  194|      0|                               c == SNMP_MSG_GETNEXT || c == SNMP_MSG_GET || \
  |  |  ------------------
  |  |  |  |  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
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              c == SNMP_MSG_GETNEXT || c == SNMP_MSG_GET || \
  |  |  ------------------
  |  |  |  |  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 (194:32): [True: 0, False: 0]
  |  |  |  Branch (194:57): [True: 0, False: 0]
  |  |  ------------------
  |  |  195|      0|                               c == 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 (195:32): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 3415|      0|            (pdu->command == 0
  ------------------
  |  Branch (3415:14): [True: 0, False: 0]
  ------------------
 3416|      0|             && (pdu->flags & SNMP_MSG_FLAG_RPRT_BIT))) {
  ------------------
  |  |  305|      0|#define SNMP_MSG_FLAG_RPRT_BIT          0x04
  ------------------
  |  Branch (3416:17): [True: 0, False: 0]
  ------------------
 3417|      0|            netsnmp_pdu    *pdu2;
 3418|      0|            int             flags = pdu->flags;
 3419|       |
 3420|      0|            pdu->flags |= UCD_MSG_FLAG_FORCE_PDU_COPY;
  ------------------
  |  |  313|      0|#define UCD_MSG_FLAG_FORCE_PDU_COPY          0x400
  ------------------
 3421|      0|            pdu2 = snmp_clone_pdu(pdu);
 3422|      0|            pdu->flags = flags;
 3423|      0|            if (pdu2 == NULL)
  ------------------
  |  Branch (3423:17): [True: 0, False: 0]
  ------------------
 3424|      0|                break;
 3425|      0|            pdu2->flags = flags;
 3426|      0|            snmpv3_make_report(pdu2, result);
 3427|      0|            if (0 == snmp_sess_send(slp, pdu2)) {
  ------------------
  |  Branch (3427:17): [True: 0, False: 0]
  ------------------
 3428|      0|                snmp_free_pdu(pdu2);
 3429|       |                /*
 3430|       |                 * TODO: indicate error 
 3431|       |                 */
 3432|      0|            }
 3433|      0|        }
 3434|      0|        break;
 3435|      2|    }       
 3436|      2|}
snmpusm.c:init_usm_post_config:
 5208|     58|{
 5209|     58|    size_t          salt_integer_len = sizeof(salt_integer);
 5210|     58|    uint64_t        current_time;
 5211|       |
 5212|     58|    if (sc_random((u_char *) & salt_integer, &salt_integer_len) !=
  ------------------
  |  Branch (5212:9): [True: 0, False: 58]
  ------------------
 5213|     58|        SNMPERR_SUCCESS) {
  ------------------
  |  |  184|     58|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 5214|      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]
  |  |  ------------------
  ------------------
 5215|      0|        current_time = time(NULL);
 5216|      0|        salt_integer = current_time;
 5217|      0|    }
 5218|       |
 5219|     58|#ifdef HAVE_AES
 5220|     58|    salt_integer_len = sizeof (salt_integer64_1);
 5221|     58|    if (sc_random((u_char *) & salt_integer64_1, &salt_integer_len) !=
  ------------------
  |  Branch (5221:9): [True: 0, False: 58]
  ------------------
 5222|     58|        SNMPERR_SUCCESS) {
  ------------------
  |  |  184|     58|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 5223|      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]
  |  |  ------------------
  ------------------
 5224|      0|        current_time = time(NULL);
 5225|      0|        salt_integer64_1 = current_time;
 5226|      0|    }
 5227|     58|    salt_integer_len = sizeof (salt_integer64_1);
 5228|     58|    if (sc_random((u_char *) & salt_integer64_2, &salt_integer_len) !=
  ------------------
  |  Branch (5228:9): [True: 0, False: 58]
  ------------------
 5229|     58|        SNMPERR_SUCCESS) {
  ------------------
  |  |  184|     58|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 5230|      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]
  |  |  ------------------
  ------------------
 5231|      0|        current_time = time(NULL);
 5232|      0|        salt_integer64_2 = current_time;
 5233|      0|    }
 5234|     58|#endif
 5235|       |
 5236|       |    // Free noNameUser before it is assigned
 5237|     58|    usm_free_user(noNameUser);
 5238|       |
 5239|     58|#ifndef NETSNMP_DISABLE_MD5
 5240|     58|    noNameUser = usm_create_initial_user("", usmHMACMD5AuthProtocol,
 5241|     58|                                         OID_LENGTH(usmHMACMD5AuthProtocol),
  ------------------
  |  |   64|     58|    (sizeof(x) / sizeof((x)[0]) +                                       \
  |  |   65|     58|     sizeof(int[-__builtin_types_compatible_p(typeof(x), typeof(&(x)[0]))]))
  ------------------
 5242|     58|                                         SNMP_DEFAULT_PRIV_PROTO,
  ------------------
  |  |  100|     58|#define SNMP_DEFAULT_PRIV_PROTO     usmDESPrivProtocol
  ------------------
 5243|     58|                                         SNMP_DEFAULT_PRIV_PROTOLEN);
  ------------------
  |  |  104|     58|#define SNMP_DEFAULT_PRIV_PROTOLEN  OID_LENGTH(SNMP_DEFAULT_PRIV_PROTO)
  |  |  ------------------
  |  |  |  |   64|     58|    (sizeof(x) / sizeof((x)[0]) +                                       \
  |  |  |  |   65|     58|     sizeof(int[-__builtin_types_compatible_p(typeof(x), typeof(&(x)[0]))]))
  |  |  ------------------
  ------------------
 5244|       |#else
 5245|       |    noNameUser = usm_create_initial_user("", usmHMACSHA1AuthProtocol,
 5246|       |                                         OID_LENGTH(usmHMACSHA1AuthProtocol),
 5247|       |                                         SNMP_DEFAULT_PRIV_PROTO,
 5248|       |                                         SNMP_DEFAULT_PRIV_PROTOLEN);
 5249|       |#endif
 5250|       |
 5251|     58|    if ( noNameUser ) {
  ------------------
  |  Branch (5251:10): [True: 58, False: 0]
  ------------------
 5252|     58|        SNMP_FREE(noNameUser->engineID);
  ------------------
  |  |   62|     58|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 58, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 58]
  |  |  ------------------
  ------------------
 5253|     58|        noNameUser->engineIDLen = 0;
 5254|     58|    }
 5255|       |
 5256|     58|    return SNMPERR_SUCCESS;
  ------------------
  |  |  184|     58|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 5257|     58|}                               /* end init_usm_post_config() */
snmpusm.c:usm_create_initial_user:
 4205|     58|{
 4206|     58|    struct usmUser *newUser = usm_create_user();
 4207|     58|    if (newUser == NULL)
  ------------------
  |  Branch (4207:9): [True: 0, False: 58]
  ------------------
 4208|      0|        return NULL;
 4209|       |
 4210|     58|    if ((newUser->name = strdup(name)) == NULL)
  ------------------
  |  Branch (4210:9): [True: 0, False: 58]
  ------------------
 4211|      0|        return usm_free_user(newUser);
 4212|       |
 4213|     58|    if ((newUser->secName = strdup(name)) == NULL)
  ------------------
  |  Branch (4213:9): [True: 0, False: 58]
  ------------------
 4214|      0|        return usm_free_user(newUser);
 4215|       |
 4216|     58|    if ((newUser->engineID =
  ------------------
  |  Branch (4216:9): [True: 0, False: 58]
  ------------------
 4217|     58|         snmpv3_generate_engineID(&newUser->engineIDLen)) == NULL)
 4218|      0|        return usm_free_user(newUser);
 4219|       |
 4220|     58|    if ((newUser->cloneFrom = (oid *) malloc(sizeof(oid) * 2)) == NULL)
  ------------------
  |  Branch (4220:9): [True: 0, False: 58]
  ------------------
 4221|      0|        return usm_free_user(newUser);
 4222|     58|    newUser->cloneFrom[0] = 0;
 4223|     58|    newUser->cloneFrom[1] = 0;
 4224|     58|    newUser->cloneFromLen = 2;
 4225|       |
 4226|     58|    SNMP_FREE(newUser->privProtocol);
  ------------------
  |  |   62|     58|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 58, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 58]
  |  |  ------------------
  ------------------
 4227|     58|    if ((newUser->privProtocol = snmp_duplicate_objid(privProtocol,
  ------------------
  |  Branch (4227:9): [True: 0, False: 58]
  ------------------
 4228|     58|                                                      privProtocolLen)) ==
 4229|     58|        NULL) {
 4230|      0|        return usm_free_user(newUser);
 4231|      0|    }
 4232|     58|    newUser->privProtocolLen = privProtocolLen;
 4233|       |
 4234|     58|    SNMP_FREE(newUser->authProtocol);
  ------------------
  |  |   62|     58|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 58, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 58]
  |  |  ------------------
  ------------------
 4235|     58|    if ((newUser->authProtocol = snmp_duplicate_objid(authProtocol,
  ------------------
  |  Branch (4235:9): [True: 0, False: 58]
  ------------------
 4236|     58|                                                      authProtocolLen)) ==
 4237|     58|        NULL) {
 4238|      0|        return usm_free_user(newUser);
 4239|      0|    }
 4240|     58|    newUser->authProtocolLen = authProtocolLen;
 4241|       |
 4242|     58|    newUser->userStatus = RS_ACTIVE;
  ------------------
  |  |   35|     58|#define RS_ACTIVE	        1
  ------------------
 4243|     58|    newUser->userStorageType = ST_READONLY;
  ------------------
  |  |   54|     58|#define ST_READONLY	5
  ------------------
 4244|       |
 4245|     58|    return newUser;
 4246|     58|}
snmpusm.c:deinit_usm_post_config:
 5262|     58|{
 5263|     58|    usm_free_user(noNameUser);
 5264|     58|    noNameUser = NULL;
 5265|       |
 5266|     58|    DEBUGMSGTL(("deinit_usm_post_config", "initial user removed\n"));
  ------------------
  |  |   66|     58|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     58|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 58]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 58]
  |  |  ------------------
  ------------------
 5267|     58|    return SNMPERR_SUCCESS;
  ------------------
  |  |  184|     58|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 5268|     58|}                               /* end deinit_usm_post_config() */
snmpusm.c:free_enginetime_on_shutdown:
  274|     58|{
  275|     58|    u_char engineID[SNMP_MAX_ENG_SIZE];
  276|     58|    size_t engineID_len = sizeof(engineID);
  277|       |
  278|     58|    DEBUGMSGTL(("snmpv3", "free enginetime callback called\n"));
  ------------------
  |  |   66|     58|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     58|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 58]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 58]
  |  |  ------------------
  ------------------
  279|       |
  280|     58|    engineID_len = snmpv3_get_engineID(engineID, engineID_len);
  281|     58|    if (engineID_len > 0)
  ------------------
  |  Branch (281:9): [True: 0, False: 58]
  ------------------
  282|      0|	free_enginetime(engineID, engineID_len);
  283|     58|    return 0;
  284|     58|}
snmpusm.c:clear_user_list:
 4053|     58|{
 4054|     58|    struct usmUser *tmp = userList, *next = NULL;
 4055|       |
 4056|     58|    while (tmp != NULL) {
  ------------------
  |  Branch (4056:12): [True: 0, False: 58]
  ------------------
 4057|      0|	next = tmp->next;
 4058|      0|	usm_free_user(tmp);
 4059|      0|	tmp = next;
 4060|      0|    }
 4061|     58|    userList = NULL;
 4062|       |
 4063|     58|}

setup_engineID:
  471|     58|{
  472|     58|    int             enterpriseid = htonl(NETSNMP_ENTERPRISE_OID),
  473|     58|        netsnmpoid = htonl(NETSNMP_OID),
  474|     58|        localsetup = (eidp) ? 0 : 1;
  ------------------
  |  Branch (474:22): [True: 0, False: 58]
  ------------------
  475|       |
  476|       |    /*
  477|       |     * Use local engineID if *eidp == NULL.  
  478|       |     */
  479|     58|#ifdef HAVE_GETHOSTNAME
  480|     58|    u_char          buf[SNMP_MAXBUF_SMALL];
  481|     58|    struct hostent *hent = NULL;
  482|     58|#endif
  483|     58|    u_char         *bufp = NULL;
  484|     58|    size_t          len;
  485|     58|    int             localEngineIDType = engineIDType;
  486|     58|    int             tmpint;
  487|     58|    time_t          tmptime;
  488|       |
  489|     58|    engineIDIsSet = 1;
  490|       |
  491|     58|#ifdef HAVE_GETHOSTNAME
  492|     58|#ifdef AF_INET6
  493|       |    /*
  494|       |     * see if they selected IPV4 or IPV6 support 
  495|       |     */
  496|     58|    if ((ENGINEID_TYPE_IPV6 == localEngineIDType) ||
  ------------------
  |  |   20|     58|#define ENGINEID_TYPE_IPV6    2
  ------------------
  |  Branch (496:9): [True: 0, False: 58]
  ------------------
  497|     58|        (ENGINEID_TYPE_IPV4 == localEngineIDType)) {
  ------------------
  |  |   19|     58|#define ENGINEID_TYPE_IPV4    1
  ------------------
  |  Branch (497:9): [True: 0, False: 58]
  ------------------
  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|     58|#endif                          /* HAVE_GETHOSTNAME */
  529|       |
  530|       |    /*
  531|       |     * Determine if we have text and if so setup our localEngineIDType
  532|       |     * * appropriately.  
  533|       |     */
  534|     58|    if (NULL != text) {
  ------------------
  |  Branch (534:9): [True: 0, False: 58]
  ------------------
  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|     58|    len = 5;                    /* always have 5 leading bytes */
  541|     58|    switch (localEngineIDType) {
  542|      0|    case ENGINEID_TYPE_TEXT:
  ------------------
  |  |   22|      0|#define ENGINEID_TYPE_TEXT    4
  ------------------
  |  Branch (542:5): [True: 0, False: 58]
  ------------------
  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: 58]
  ------------------
  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: 58]
  ------------------
  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: 58]
  ------------------
  559|      0|        len += 16;              /* + 16 byte IPV6 address */
  560|      0|        break;
  561|     58|    case ENGINEID_TYPE_NETSNMP_RND:        /* Net-SNMP specific encoding */
  ------------------
  |  |   24|     58|#define ENGINEID_TYPE_NETSNMP_RND 128
  ------------------
  |  Branch (561:5): [True: 58, False: 0]
  ------------------
  562|     58|        if (engineID)           /* already setup, keep current value */
  ------------------
  |  Branch (562:13): [True: 0, False: 58]
  ------------------
  563|      0|            return engineIDLength;
  564|     58|        if (oldEngineID) {
  ------------------
  |  Branch (564:13): [True: 0, False: 58]
  ------------------
  565|      0|            len = oldEngineIDLength;
  566|     58|        } else {
  567|     58|            len += sizeof(int) + sizeof(time_t);
  568|     58|        }
  569|     58|        break;
  570|      0|    default:
  ------------------
  |  Branch (570:5): [True: 0, False: 58]
  ------------------
  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|     58|    }                           /* switch */
  578|       |
  579|       |
  580|       |    /*
  581|       |     * Allocate memory and store enterprise ID.
  582|       |     */
  583|     58|    if (len == 0) {
  ------------------
  |  Branch (583:9): [True: 0, False: 58]
  ------------------
  584|      0|        snmp_log(LOG_ERR, "%s(): len == 0\n", __func__);
  585|      0|        return -1;
  586|      0|    }
  587|     58|    bufp = calloc(1, len);
  588|     58|    if (bufp == NULL) {
  ------------------
  |  Branch (588:9): [True: 0, False: 58]
  ------------------
  589|      0|        snmp_log_perror("setup_engineID() calloc()");
  590|      0|        return -1;
  591|      0|    }
  592|     58|    if (localEngineIDType == ENGINEID_TYPE_NETSNMP_RND)
  ------------------
  |  |   24|     58|#define ENGINEID_TYPE_NETSNMP_RND 128
  ------------------
  |  Branch (592:9): [True: 58, False: 0]
  ------------------
  593|       |        /*
  594|       |         * we must use the net-snmp enterprise id here, regardless 
  595|       |         */
  596|     58|        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|     58|    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|     58|    switch (localEngineIDType) {
  609|     58|    case ENGINEID_TYPE_NETSNMP_RND:
  ------------------
  |  |   24|     58|#define ENGINEID_TYPE_NETSNMP_RND 128
  ------------------
  |  Branch (609:5): [True: 58, False: 0]
  ------------------
  610|     58|        if (oldEngineID) {
  ------------------
  |  Branch (610:13): [True: 0, False: 58]
  ------------------
  611|       |            /*
  612|       |             * keep our previous notion of the engineID 
  613|       |             */
  614|      0|            memcpy(bufp, oldEngineID, oldEngineIDLength);
  615|     58|        } 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|     58|            bufp[4] = ENGINEID_TYPE_NETSNMP_RND;
  ------------------
  |  |   24|     58|#define ENGINEID_TYPE_NETSNMP_RND 128
  ------------------
  628|     58|            tmpint = netsnmp_random();
  629|     58|            memcpy(bufp + 5, &tmpint, sizeof(tmpint));
  630|     58|            tmptime = time(NULL);
  631|     58|            memcpy(bufp + 5 + sizeof(tmpint), &tmptime, sizeof(tmptime));
  632|     58|        }
  633|     58|        break;
  634|      0|    case ENGINEID_TYPE_TEXT:
  ------------------
  |  |   22|      0|#define ENGINEID_TYPE_TEXT    4
  ------------------
  |  Branch (634:5): [True: 0, False: 58]
  ------------------
  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: 58]
  ------------------
  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: 58]
  ------------------
  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: 58]
  ------------------
  671|      0|    default:
  ------------------
  |  Branch (671:5): [True: 0, False: 58]
  ------------------
  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|     58|    }
  694|       |
  695|       |    /*
  696|       |     * Pass the string back to the calling environment, or use it for
  697|       |     * our local engineID.
  698|       |     */
  699|     58|    if (localsetup) {
  ------------------
  |  Branch (699:9): [True: 58, False: 0]
  ------------------
  700|     58|        SNMP_FREE(engineID);
  ------------------
  |  |   62|     58|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 58]
  |  |  |  Branch (62:66): [Folded, False: 58]
  |  |  ------------------
  ------------------
  701|     58|        engineID = bufp;
  702|     58|        engineIDLength = len;
  703|       |
  704|     58|    } else {
  705|      0|        *eidp = bufp;
  706|      0|    }
  707|       |
  708|       |
  709|     58|    return len;
  710|       |
  711|     58|}                               /* end setup_engineID() */
free_engineID:
  716|     58|{
  717|     58|    SNMP_FREE(engineID);
  ------------------
  |  |   62|     58|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 58, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 58]
  |  |  ------------------
  ------------------
  718|     58|    SNMP_FREE(engineIDNic);
  ------------------
  |  |   62|     58|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 58]
  |  |  |  Branch (62:66): [Folded, False: 58]
  |  |  ------------------
  ------------------
  719|       |    SNMP_FREE(oldEngineID);
  ------------------
  |  |   62|     58|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 58]
  |  |  |  Branch (62:66): [Folded, False: 58]
  |  |  ------------------
  ------------------
  720|     58|    engineIDIsSet = 0;
  721|     58|    return 0;
  722|     58|}
init_snmpv3:
  988|     58|{
  989|     58|    netsnmp_get_monotonic_clock(&snmpv3starttime);
  990|       |
  991|     58|    if (!type)
  ------------------
  |  Branch (991:9): [True: 0, False: 58]
  ------------------
  992|      0|        type = "__snmpapp__";
  993|       |
  994|       |    /*
  995|       |     * we need to be called back later 
  996|       |     */
  997|     58|    snmp_register_callback(SNMP_CALLBACK_LIBRARY,
  ------------------
  |  |   18|     58|#define SNMP_CALLBACK_LIBRARY     0
  ------------------
  998|     58|                           SNMP_CALLBACK_POST_READ_CONFIG,
  ------------------
  |  |   24|     58|#define SNMP_CALLBACK_POST_READ_CONFIG	        0
  ------------------
  999|     58|                           init_snmpv3_post_config, NULL);
 1000|       |
 1001|     58|    snmp_register_callback(SNMP_CALLBACK_LIBRARY,
  ------------------
  |  |   18|     58|#define SNMP_CALLBACK_LIBRARY     0
  ------------------
 1002|     58|                           SNMP_CALLBACK_POST_PREMIB_READ_CONFIG,
  ------------------
  |  |   27|     58|#define SNMP_CALLBACK_POST_PREMIB_READ_CONFIG	3
  ------------------
 1003|     58|                           init_snmpv3_post_premib_config, NULL);
 1004|       |    /*
 1005|       |     * we need to be called back later 
 1006|       |     */
 1007|     58|    snmp_register_callback(SNMP_CALLBACK_LIBRARY, SNMP_CALLBACK_STORE_DATA,
  ------------------
  |  |   18|     58|#define SNMP_CALLBACK_LIBRARY     0
  ------------------
                  snmp_register_callback(SNMP_CALLBACK_LIBRARY, SNMP_CALLBACK_STORE_DATA,
  ------------------
  |  |   25|     58|#define SNMP_CALLBACK_STORE_DATA	        1
  ------------------
 1008|     58|                           snmpv3_store, (void *) strdup(type));
 1009|       |
 1010|       |    /*
 1011|       |     * initialize submodules 
 1012|       |     */
 1013|       |    /*
 1014|       |     * NOTE: this must be after the callbacks are registered above,
 1015|       |     * since they need to be called before the USM callbacks. 
 1016|       |     */
 1017|     58|    init_secmod();
 1018|       |
 1019|       |    /*
 1020|       |     * register all our configuration handlers (ack, there's a lot) 
 1021|       |     */
 1022|       |
 1023|       |    /*
 1024|       |     * handle engineID setup before everything else which may depend on it 
 1025|       |     */
 1026|     58|    register_prenetsnmp_mib_handler(type, "engineID", engineID_conf, NULL,
 1027|     58|                                    "string");
 1028|     58|    register_prenetsnmp_mib_handler(type, "oldEngineID", oldengineID_conf,
 1029|     58|                                    NULL, NULL);
 1030|     58|    register_prenetsnmp_mib_handler(type, "exactEngineID", exactEngineID_conf,
 1031|     58|                                    NULL, NULL);
 1032|     58|    register_prenetsnmp_mib_handler(type, "engineIDType",
 1033|     58|                                    engineIDType_conf, NULL, "num");
 1034|     58|    register_prenetsnmp_mib_handler(type, "engineIDNic", engineIDNic_conf,
 1035|     58|                                    NULL, "string");
 1036|     58|    register_config_handler(type, "engineBoots", engineBoots_conf, NULL,
 1037|     58|                            NULL);
 1038|       |
 1039|       |    /*
 1040|       |     * default store config entries 
 1041|       |     */
 1042|     58|    netsnmp_ds_register_config(ASN_OCTET_STR, "snmp", "defSecurityName",
  ------------------
  |  |   78|     58|#define ASN_OCTET_STR	    0x04U
  ------------------
 1043|     58|			       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_SECNAME);
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              			       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_SECNAME);
  ------------------
  |  |  151|     58|#define NETSNMP_DS_LIB_SECNAME           0
  ------------------
 1044|     58|    netsnmp_ds_register_config(ASN_OCTET_STR, "snmp", "defContext", 
  ------------------
  |  |   78|     58|#define ASN_OCTET_STR	    0x04U
  ------------------
 1045|     58|			       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_CONTEXT);
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              			       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_CONTEXT);
  ------------------
  |  |  152|     58|#define NETSNMP_DS_LIB_CONTEXT           1
  ------------------
 1046|     58|    netsnmp_ds_register_config(ASN_OCTET_STR, "snmp", "defPassphrase",
  ------------------
  |  |   78|     58|#define ASN_OCTET_STR	    0x04U
  ------------------
 1047|     58|                               NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1048|     58|                               NETSNMP_DS_LIB_PASSPHRASE);
  ------------------
  |  |  153|     58|#define NETSNMP_DS_LIB_PASSPHRASE        2
  ------------------
 1049|     58|    netsnmp_ds_register_config(ASN_OCTET_STR, "snmp", "defAuthPassphrase",
  ------------------
  |  |   78|     58|#define ASN_OCTET_STR	    0x04U
  ------------------
 1050|     58|                               NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1051|     58|                               NETSNMP_DS_LIB_AUTHPASSPHRASE);
  ------------------
  |  |  154|     58|#define NETSNMP_DS_LIB_AUTHPASSPHRASE    3
  ------------------
 1052|     58|    netsnmp_ds_register_config(ASN_OCTET_STR, "snmp", "defPrivPassphrase",
  ------------------
  |  |   78|     58|#define ASN_OCTET_STR	    0x04U
  ------------------
 1053|     58|                               NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1054|     58|                               NETSNMP_DS_LIB_PRIVPASSPHRASE);
  ------------------
  |  |  155|     58|#define NETSNMP_DS_LIB_PRIVPASSPHRASE    4
  ------------------
 1055|     58|    netsnmp_ds_register_config(ASN_OCTET_STR, "snmp", "defAuthMasterKey",
  ------------------
  |  |   78|     58|#define ASN_OCTET_STR	    0x04U
  ------------------
 1056|     58|                               NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1057|     58|                               NETSNMP_DS_LIB_AUTHMASTERKEY);
  ------------------
  |  |  167|     58|#define NETSNMP_DS_LIB_AUTHMASTERKEY     16
  ------------------
 1058|     58|    netsnmp_ds_register_config(ASN_OCTET_STR, "snmp", "defPrivMasterKey",
  ------------------
  |  |   78|     58|#define ASN_OCTET_STR	    0x04U
  ------------------
 1059|     58|                               NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1060|     58|                               NETSNMP_DS_LIB_PRIVMASTERKEY);
  ------------------
  |  |  168|     58|#define NETSNMP_DS_LIB_PRIVMASTERKEY     17
  ------------------
 1061|     58|    netsnmp_ds_register_config(ASN_OCTET_STR, "snmp", "defAuthLocalizedKey",
  ------------------
  |  |   78|     58|#define ASN_OCTET_STR	    0x04U
  ------------------
 1062|     58|                               NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1063|     58|                               NETSNMP_DS_LIB_AUTHLOCALIZEDKEY);
  ------------------
  |  |  169|     58|#define NETSNMP_DS_LIB_AUTHLOCALIZEDKEY  18
  ------------------
 1064|     58|    netsnmp_ds_register_config(ASN_OCTET_STR, "snmp", "defPrivLocalizedKey",
  ------------------
  |  |   78|     58|#define ASN_OCTET_STR	    0x04U
  ------------------
 1065|     58|                               NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1066|     58|                               NETSNMP_DS_LIB_PRIVLOCALIZEDKEY);
  ------------------
  |  |  170|     58|#define NETSNMP_DS_LIB_PRIVLOCALIZEDKEY  19
  ------------------
 1067|     58|    register_config_handler("snmp", "defVersion", version_conf, NULL,
 1068|     58|                            "1|2c|3");
 1069|       |
 1070|     58|    register_config_handler("snmp", "defSecurityLevel",
 1071|       |                            snmpv3_secLevel_conf, NULL,
 1072|     58|                            "noAuthNoPriv|authNoPriv|authPriv");
 1073|     58|}
init_snmpv3_post_config:
 1083|     58|{
 1084|       |
 1085|     58|    size_t          engineIDLen;
 1086|     58|    u_char         *c_engineID;
 1087|     58|    u_long          localEngineTime;
 1088|     58|    u_long          localEngineBoots;
 1089|       |
 1090|     58|    c_engineID = snmpv3_generate_engineID(&engineIDLen);
 1091|       |
 1092|     58|    if (!c_engineID || engineIDLen == 0) {
  ------------------
  |  Branch (1092:9): [True: 0, False: 58]
  |  Branch (1092:24): [True: 0, False: 58]
  ------------------
 1093|       |        /*
 1094|       |         * Something went wrong - help! 
 1095|       |         */
 1096|      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]
  |  |  ------------------
  ------------------
 1097|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
 1098|      0|    }
 1099|       |
 1100|       |    /*
 1101|       |     * if our engineID has changed at all, the boots record must be set to 1 
 1102|       |     */
 1103|     58|    if (engineIDLen != oldEngineIDLength ||
  ------------------
  |  Branch (1103:9): [True: 58, False: 0]
  ------------------
 1104|      0|        oldEngineID == NULL || c_engineID == NULL ||
  ------------------
  |  Branch (1104:9): [True: 0, False: 0]
  |  Branch (1104:32): [True: 0, False: 0]
  ------------------
 1105|     58|        memcmp(oldEngineID, c_engineID, engineIDLen) != 0) {
  ------------------
  |  Branch (1105:9): [True: 0, False: 0]
  ------------------
 1106|     58|        engineBoots = 1;
 1107|     58|    }
 1108|       |
 1109|     58|#ifdef NETSNMP_SECMOD_USM
 1110|       |    /*
 1111|       |     * for USM set our local engineTime in the LCD timing cache 
 1112|       |     */
 1113|     58|    localEngineTime = snmpv3_local_snmpEngineTime();
 1114|     58|    localEngineBoots = snmpv3_local_snmpEngineBoots();
 1115|     58|    set_enginetime(c_engineID, engineIDLen,
 1116|     58|                   localEngineBoots,
 1117|     58|                   localEngineTime, TRUE);
  ------------------
  |  |  128|     58|#define TRUE  1
  ------------------
 1118|     58|#endif /* NETSNMP_SECMOD_USM */
 1119|       |
 1120|     58|    SNMP_FREE(c_engineID);
  ------------------
  |  |   62|     58|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 58, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 58]
  |  |  ------------------
  ------------------
 1121|     58|    return SNMPERR_SUCCESS;
  ------------------
  |  |  184|     58|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 1122|     58|}
init_snmpv3_post_premib_config:
 1127|     58|{
 1128|     58|    if (!engineIDIsSet)
  ------------------
  |  Branch (1128:9): [True: 58, False: 0]
  ------------------
 1129|     58|        setup_engineID(NULL, NULL);
 1130|       |
 1131|     58|    return SNMPERR_SUCCESS;
  ------------------
  |  |  184|     58|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 1132|     58|}
snmpv3_store:
 1142|     58|{
 1143|     58|    char            line[SNMP_MAXBUF_SMALL];
 1144|     58|    u_char          c_engineID[SNMP_MAXBUF_SMALL];
 1145|     58|    int             engineIDLen;
 1146|     58|    const char     *type = (const char *) clientarg;
 1147|       |
 1148|     58|    if (type == NULL)           /* should never happen, since the arg is ours */
  ------------------
  |  Branch (1148:9): [True: 0, False: 58]
  ------------------
 1149|      0|        type = "unknown";
 1150|       |
 1151|     58|    snprintf(line, sizeof(line), "engineBoots %ld", engineBoots);
 1152|     58|    read_config_store(type, line);
 1153|       |
 1154|     58|    engineIDLen = snmpv3_get_engineID(c_engineID, SNMP_MAXBUF_SMALL);
  ------------------
  |  |   45|     58|#define SNMP_MAXBUF_SMALL	512
  ------------------
 1155|       |
 1156|     58|    if (engineIDLen) {
  ------------------
  |  Branch (1156:9): [True: 58, False: 0]
  ------------------
 1157|       |        /*
 1158|       |         * store the engineID used for this run 
 1159|       |         */
 1160|     58|        snprintf(line, sizeof(line), "oldEngineID ");
 1161|     58|        read_config_save_octet_string(line + strlen(line), c_engineID,
 1162|     58|                                      engineIDLen);
 1163|     58|        read_config_store(type, line);
 1164|     58|    }
 1165|     58|    return SNMPERR_SUCCESS;
  ------------------
  |  |  184|     58|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 1166|     58|}                               /* snmpv3_store() */
snmpv3_local_snmpEngineBoots:
 1170|     58|{
 1171|     58|    return engineBoots;
 1172|     58|}
snmpv3_get_engineID:
 1192|    232|{
 1193|       |    /*
 1194|       |     * Sanity check.
 1195|       |     */
 1196|    232|    if (!buf || (buflen < engineIDLength)) {
  ------------------
  |  Branch (1196:9): [True: 0, False: 232]
  |  Branch (1196:17): [True: 0, False: 232]
  ------------------
 1197|      0|        return 0;
 1198|      0|    }
 1199|    232|    if (!engineID) {
  ------------------
  |  Branch (1199:9): [True: 58, False: 174]
  ------------------
 1200|     58|        return 0;
 1201|     58|    }
 1202|       |
 1203|    174|    memcpy(buf, engineID, engineIDLength);
 1204|    174|    return engineIDLength;
 1205|       |
 1206|    232|}                               /* end snmpv3_get_engineID() */
snmpv3_generate_engineID:
 1262|    116|{
 1263|    116|    u_char         *newID;
 1264|    116|    newID = (u_char *) malloc(engineIDLength);
 1265|       |
 1266|    116|    if (newID) {
  ------------------
  |  Branch (1266:9): [True: 116, False: 0]
  ------------------
 1267|    116|        *length = snmpv3_get_engineID(newID, engineIDLength);
 1268|    116|        if (*length == 0) {
  ------------------
  |  Branch (1268:13): [True: 0, False: 116]
  ------------------
 1269|      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]
  |  |  ------------------
  ------------------
 1270|      0|            newID = NULL;
 1271|      0|        }
 1272|    116|    }
 1273|    116|    return newID;
 1274|       |
 1275|    116|}                               /* end snmpv3_generate_engineID() */
snmpv3_local_snmpEngineTime:
 1289|    116|{
 1290|       |#ifdef NETSNMP_FEATURE_CHECKING
 1291|       |    netsnmp_feature_require(calculate_sectime_diff)
 1292|       |#endif /* NETSNMP_FEATURE_CHECKING */
 1293|       |
 1294|    116|    static uint32_t last_engineTime;
 1295|    116|    struct timeval  now;
 1296|    116|    uint32_t engineTime;
 1297|       |
 1298|    116|    netsnmp_get_monotonic_clock(&now);
 1299|    116|    engineTime = calculate_sectime_diff(&now, &snmpv3starttime) & 0x7fffffffL;
 1300|    116|    if (engineTime < last_engineTime)
  ------------------
  |  Branch (1300:9): [True: 0, False: 116]
  ------------------
 1301|      0|        engineBoots++;
 1302|    116|    last_engineTime = engineTime;
 1303|    116|    return engineTime;
 1304|    116|}

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

netsnmp_gethostbyname_v4:
  773|     58|{
  774|     58|#ifdef HAVE_GETADDRINFO
  775|     58|    struct addrinfo *addrs = NULL;
  776|     58|    struct addrinfo hint;
  777|     58|    int             err;
  778|       |
  779|     58|    memset(&hint, 0, sizeof hint);
  780|     58|    hint.ai_flags = 0;
  781|     58|    hint.ai_family = PF_INET;
  782|     58|    hint.ai_socktype = SOCK_DGRAM;
  783|     58|    hint.ai_protocol = 0;
  784|       |
  785|     58|    err = netsnmp_getaddrinfo(name, NULL, &hint, &addrs);
  786|     58|    if (err != 0) {
  ------------------
  |  Branch (786:9): [True: 0, False: 58]
  ------------------
  787|      0|        return -1;
  788|      0|    }
  789|       |
  790|     58|    if (addrs != NULL) {
  ------------------
  |  Branch (790:9): [True: 58, False: 0]
  ------------------
  791|     58|        memcpy(addr_out,
  792|     58|               &((struct sockaddr_in *) addrs->ai_addr)->sin_addr,
  793|     58|               sizeof(in_addr_t));
  794|     58|        freeaddrinfo(addrs);
  795|     58|    } else {
  796|      0|        DEBUGMSGTL(("get_thisaddr",
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
  797|      0|                    "Failed to resolve IPv4 hostname\n"));
  798|      0|        return -1;
  799|      0|    }
  800|     58|    return 0;
  801|       |
  802|       |#elif defined(HAVE_GETHOSTBYNAME)
  803|       |    struct hostent *hp = NULL;
  804|       |
  805|       |    hp = netsnmp_gethostbyname(name);
  806|       |    if (hp == NULL) {
  807|       |        DEBUGMSGTL(("get_thisaddr",
  808|       |                    "hostname (couldn't resolve)\n"));
  809|       |        return -1;
  810|       |    } else if (hp->h_addrtype != AF_INET) {
  811|       |        DEBUGMSGTL(("get_thisaddr",
  812|       |                    "hostname (not AF_INET!)\n"));
  813|       |        return -1;
  814|       |    } else {
  815|       |        DEBUGMSGTL(("get_thisaddr",
  816|       |                    "hostname (resolved okay)\n"));
  817|       |        memcpy(addr_out, hp->h_addr, sizeof(in_addr_t));
  818|       |    }
  819|       |    return 0;
  820|       |
  821|       |#elif defined(HAVE_GETIPNODEBYNAME)
  822|       |    struct hostent *hp = NULL;
  823|       |    int             err;
  824|       |
  825|       |    hp = getipnodebyname(peername, AF_INET, 0, &err);
  826|       |    if (hp == NULL) {
  827|       |        DEBUGMSGTL(("get_thisaddr",
  828|       |                    "hostname (couldn't resolve = %d)\n", err));
  829|       |        return -1;
  830|       |    }
  831|       |    DEBUGMSGTL(("get_thisaddr",
  832|       |                "hostname (resolved okay)\n"));
  833|       |    memcpy(addr_out, hp->h_addr, sizeof(in_addr_t));
  834|       |    return 0;
  835|       |
  836|       |#else /* HAVE_GETIPNODEBYNAME */
  837|       |    return -1;
  838|       |#endif
  839|     58|}
netsnmp_getaddrinfo:
  844|     58|{
  845|     58|#ifdef HAVE_GETADDRINFO
  846|     58|    struct addrinfo *addrs = NULL;
  847|     58|    struct addrinfo hint;
  848|     58|    int             err;
  849|       |#ifdef DNSSEC_LOCAL_VALIDATION
  850|       |    val_status_t    val_status;
  851|       |#endif
  852|       |
  853|     58|    DEBUGMSGTL(("dns:getaddrinfo", "looking up "));
  ------------------
  |  |   66|     58|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     58|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 58]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 58]
  |  |  ------------------
  ------------------
  854|     58|    if (name)
  ------------------
  |  Branch (854:9): [True: 58, False: 0]
  ------------------
  855|     58|        DEBUGMSG(("dns:getaddrinfo", "\"%s\"", name));
  ------------------
  |  |   61|     58|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  144|     58|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 58]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (61:67): [Folded, False: 58]
  |  |  ------------------
  ------------------
  856|      0|    else
  857|      0|        DEBUGMSG(("dns:getaddrinfo", "<NULL>"));
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
  858|       |
  859|     58|    if (service)
  ------------------
  |  Branch (859:9): [True: 0, False: 58]
  ------------------
  860|      0|	DEBUGMSG(("dns:getaddrinfo", ":\"%s\"", service));
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
  861|       |
  862|     58|    if (hints)
  ------------------
  |  Branch (862:9): [True: 58, False: 0]
  ------------------
  863|     58|	DEBUGMSG(("dns:getaddrinfo",
  ------------------
  |  |   61|     58|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  144|     58|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 58]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (61:56): [True: 0, False: 0]
  |  |  |  Branch (61:56): [True: 0, False: 0]
  |  |  |  Branch (61:56): [True: 0, False: 0]
  |  |  |  Branch (61:67): [Folded, False: 58]
  |  |  ------------------
  ------------------
  864|     58|                  " with hints ({.ai_flags = %#x, .ai_family = %s})",
  865|     58|                  hints->ai_flags, hints->ai_family == 0 ? "0" :
  866|     58|                  hints->ai_family == AF_INET ? "AF_INET" :
  867|     58|                  hints->ai_family == AF_INET6 ? "AF_INET6" : "?"));
  868|      0|    else
  869|      0|	DEBUGMSG(("dns:getaddrinfo", " with no hint"));
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
  870|       |
  871|     58|    DEBUGMSG(("dns:getaddrinfo", "\n"));
  ------------------
  |  |   61|     58|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  144|     58|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 58]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (61:67): [Folded, False: 58]
  |  |  ------------------
  ------------------
  872|       |
  873|     58|    if (NULL == hints) {
  ------------------
  |  Branch (873:9): [True: 0, False: 58]
  ------------------
  874|      0|        memset(&hint, 0, sizeof hint);
  875|      0|        hint.ai_flags = 0;
  876|      0|        hint.ai_family = PF_INET;
  877|      0|        hint.ai_socktype = SOCK_DGRAM;
  878|      0|        hint.ai_protocol = 0;
  879|      0|        hints = &hint;
  880|     58|    } else {
  881|     58|        memcpy(&hint, hints, sizeof hint);
  882|     58|    }
  883|       |
  884|     58|#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
  885|       |    /*
  886|       |     * Fuzz targets must not perform network I/O. Without network access,
  887|       |     * DNS queries block until they time out. Hence, only allow lookups
  888|       |     * that can be resolved without querying a DNS server.
  889|       |     */
  890|     58|    if (name && strcmp(name, "localhost") != 0)
  ------------------
  |  Branch (890:9): [True: 58, False: 0]
  |  Branch (890:17): [True: 58, False: 0]
  ------------------
  891|     58|        hint.ai_flags |= AI_NUMERICHOST;
  892|     58|#endif
  893|       |
  894|     58|#ifndef DNSSEC_LOCAL_VALIDATION
  895|     58|    err = getaddrinfo(name, NULL, &hint, &addrs);
  896|       |#else /* DNSSEC_LOCAL_VALIDATION */
  897|       |    err = val_getaddrinfo(netsnmp_validator_context(), name, NULL, &hint,
  898|       |                          &addrs, &val_status);
  899|       |    DEBUGMSGTL(("dns:sec:val", "err %d, val_status %d / %s; trusted: %d\n",
  900|       |                err, val_status, p_val_status(val_status),
  901|       |                val_istrusted(val_status)));
  902|       |    if (! val_istrusted(val_status)) {
  903|       |        int rc;
  904|       |        if ((err != 0) && VAL_GETADDRINFO_HAS_STATUS(err)) {
  905|       |            snmp_log(LOG_WARNING,
  906|       |                     "WARNING: UNTRUSTED error in DNS resolution for %s!\n",
  907|       |                     name);
  908|       |            rc = EAI_FAIL;
  909|       |        } else {
  910|       |            snmp_log(LOG_WARNING,
  911|       |                     "The authenticity of DNS response is not trusted (%s)\n",
  912|       |                     p_val_status(val_status));
  913|       |            rc = EAI_NONAME;
  914|       |        }
  915|       |        /** continue anyways if DNSSEC_WARN_ONLY is set */
  916|       |        if (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, 
  917|       |                                    NETSNMP_DS_LIB_DNSSEC_WARN_ONLY))
  918|       |            return rc;
  919|       |    }
  920|       |
  921|       |
  922|       |#endif /* DNSSEC_LOCAL_VALIDATION */
  923|     58|    *res = addrs;
  924|     58|    DEBUGIF("dns:getaddrinfo") {
  ------------------
  |  |  145|     58|#define DEBUGIF(x)         if (_DBG_IF_ && debug_is_token_registered(x) == SNMPERR_SUCCESS)
  |  |  ------------------
  |  |  |  |  144|    116|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 58]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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]
  |  |  ------------------
  ------------------
  925|      0|        if (err == 0 && addrs && addrs->ai_addr) {
  ------------------
  |  Branch (925:13): [True: 0, False: 0]
  |  Branch (925:25): [True: 0, False: 0]
  |  Branch (925:34): [True: 0, False: 0]
  ------------------
  926|      0|            const char *fam = "?";
  927|      0|            char dst[64] = "?";
  928|      0|            uint16_t port = 0;
  929|       |
  930|      0|            switch (addrs->ai_addr->sa_family) {
  ------------------
  |  Branch (930:21): [True: 0, False: 0]
  ------------------
  931|      0|            case AF_INET: {
  ------------------
  |  Branch (931:13): [True: 0, False: 0]
  ------------------
  932|      0|                struct sockaddr_in *sin = (struct sockaddr_in *)addrs->ai_addr;
  933|       |
  934|      0|                fam = "AF_INET";
  935|      0|                inet_ntop(AF_INET, &sin->sin_addr, dst, sizeof(dst));
  936|      0|                port = ntohs(sin->sin_port);
  937|      0|                break;
  938|      0|            }
  939|      0|            case AF_INET6: {
  ------------------
  |  Branch (939:13): [True: 0, False: 0]
  ------------------
  940|      0|                struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)
  941|      0|                    addrs->ai_addr;
  942|       |
  943|      0|                fam = "AF_INET6";
  944|      0|                inet_ntop(AF_INET6, &sin6->sin6_addr, dst, sizeof(dst));
  945|      0|                port = ntohs(sin6->sin6_port);
  946|      0|                break;
  947|      0|            }
  948|      0|            }
  949|      0|            DEBUGMSGTL(("dns:getaddrinfo", "answer { %s, %s:%hu }\n", fam, dst,
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
  950|      0|                        port));
  951|      0|        }
  952|      0|    }
  953|     58|    return err;
  954|       |#else
  955|       |    NETSNMP_LOGONCE((LOG_ERR, "getaddrinfo not available"));
  956|       |    return EAI_FAIL;
  957|       |#endif /* getaddrinfo */
  958|     58|}
calculate_sectime_diff:
 1210|    116|{
 1211|    116|    struct timeval  diff;
 1212|       |
 1213|    116|    NETSNMP_TIMERSUB(now, then, &diff);
  ------------------
  |  |  173|    116|#define NETSNMP_TIMERSUB(a, b, res) do {                        \
  |  |  174|    116|    (res)->tv_sec  = (a)->tv_sec  - (b)->tv_sec - 1;            \
  |  |  175|    116|    (res)->tv_usec = (a)->tv_usec - (b)->tv_usec + 1000000L;    \
  |  |  176|    116|    if ((res)->tv_usec >= 1000000L) {                           \
  |  |  ------------------
  |  |  |  Branch (176:9): [True: 116, False: 0]
  |  |  ------------------
  |  |  177|    116|        (res)->tv_usec -= 1000000L;                             \
  |  |  178|    116|        (res)->tv_sec++;                                        \
  |  |  179|    116|    }                                                           \
  |  |  180|    116|} while (0)
  |  |  ------------------
  |  |  |  Branch (180:10): [Folded, False: 116]
  |  |  ------------------
  ------------------
 1214|    116|    return (u_int)(diff.tv_sec + (diff.tv_usec >= 500000L));
 1215|    116|}
netsnmp_os_prematch:
 1417|     58|{
 1418|     58|#ifdef HAVE_SYS_UTSNAME_H
 1419|     58|  static int printOSonce = 1;
 1420|     58|  struct utsname utsbuf;
 1421|     58|  if ( 0 > uname(&utsbuf))
  ------------------
  |  Branch (1421:8): [True: 0, False: 58]
  ------------------
 1422|      0|    return -1;
 1423|       |
 1424|     58|  if (printOSonce) {
  ------------------
  |  Branch (1424:7): [True: 1, False: 57]
  ------------------
 1425|      1|    printOSonce = 0;
 1426|       |    /* show the four elements that the kernel can be sure of */
 1427|      1|  DEBUGMSGT(("daemonize","sysname '%s',\nrelease '%s',\nversion '%s',\nmachine '%s'\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: 0, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 1]
  |  |  ------------------
  ------------------
 1428|      1|      utsbuf.sysname, utsbuf.release, utsbuf.version, utsbuf.machine));
 1429|      1|  }
 1430|     58|  if (0 != strcasecmp(utsbuf.sysname, ospmname)) return -1;
  ------------------
  |  Branch (1430:7): [True: 0, False: 58]
  ------------------
 1431|       |
 1432|       |  /* Required to match only the leading characters */
 1433|     58|  return strncasecmp(utsbuf.release, ospmrelprefix, strlen(ospmrelprefix));
 1434|       |
 1435|       |#else
 1436|       |
 1437|       |  return -1;
 1438|       |
 1439|       |#endif /* HAVE_SYS_UTSNAME_H */
 1440|     58|}

netsnmp_memdup:
  278|    122|{
  279|    122|    void *to = NULL;
  280|       |
  281|    122|    if (from) {
  ------------------
  |  Branch (281:9): [True: 122, False: 0]
  ------------------
  282|    122|        to = malloc(size);
  283|    122|        if (to)
  ------------------
  |  Branch (283:13): [True: 122, False: 0]
  ------------------
  284|    122|            memcpy(to, from, size);
  285|    122|    }
  286|    122|    return to;
  287|    122|}                               /* end netsnmp_memdup() */
netsnmp_get_monotonic_clock:
  947|    289|{
  948|    289|#if defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC)
  949|    289|    struct timespec ts;
  950|    289|    int res;
  951|       |
  952|    289|    res = clock_gettime(CLOCK_MONOTONIC, &ts);
  953|    289|    if (res >= 0) {
  ------------------
  |  Branch (953:9): [True: 289, False: 0]
  ------------------
  954|    289|        tv->tv_sec = ts.tv_sec;
  955|    289|        tv->tv_usec = ts.tv_nsec / 1000;
  956|    289|    } else {
  957|      0|        gettimeofday(tv, NULL);
  958|      0|    }
  959|       |#elif defined(WIN32)
  960|       |    /*
  961|       |     * Windows: return tick count. Note: the rate at which the tick count
  962|       |     * increases is not adjusted by the time synchronization algorithm, so
  963|       |     * expect an error of <= 100 ppm for the rate at which this clock
  964|       |     * increases.
  965|       |     */
  966|       |    typedef ULONGLONG (WINAPI * pfGetTickCount64)(void);
  967|       |    static int s_initialized;
  968|       |    static pfGetTickCount64 s_pfGetTickCount64;
  969|       |    uint64_t now64;
  970|       |
  971|       |    if (!s_initialized) {
  972|       |        HMODULE hKernel32 = GetModuleHandle("kernel32");
  973|       |        s_pfGetTickCount64 =
  974|       |            (pfGetTickCount64) GetProcAddress(hKernel32, "GetTickCount64");
  975|       |        s_initialized = TRUE;
  976|       |    }
  977|       |
  978|       |    if (s_pfGetTickCount64) {
  979|       |        /* Windows Vista, Windows 2008 or any later Windows version */
  980|       |        now64 = (*s_pfGetTickCount64)();
  981|       |    } else {
  982|       |        /* Windows XP, Windows 2003 or any earlier Windows version */
  983|       |        static uint32_t s_wraps, s_last;
  984|       |        uint32_t now;
  985|       |
  986|       |        now = GetTickCount();
  987|       |        if (now < s_last)
  988|       |            s_wraps++;
  989|       |        s_last = now;
  990|       |        now64 = ((uint64_t)s_wraps << 32) | now;
  991|       |    }
  992|       |    tv->tv_sec = now64 / 1000;
  993|       |    tv->tv_usec = (now64 % 1000) * 1000;
  994|       |#else
  995|       |    /* At least FreeBSD 4 doesn't provide monotonic clock support. */
  996|       |#warning Not sure how to query a monotonically increasing clock on your system. \
  997|       |Timers will not work correctly if the system clock is adjusted by e.g. ntpd.
  998|       |    gettimeofday(tv, NULL);
  999|       |#endif
 1000|    289|}
netsnmp_getenv:
 1186|    349|{
 1187|    349|#if !defined (WIN32) && !defined (cygwin)
 1188|    349|  return (getenv(name));
 1189|       |#else
 1190|       |  char *temp = NULL;  
 1191|       |  HKEY hKey;
 1192|       |  unsigned char * key_value = NULL;
 1193|       |  DWORD key_value_size = 0;
 1194|       |  DWORD key_value_type = 0;
 1195|       |  DWORD getenv_worked = 0;
 1196|       |
 1197|       |  DEBUGMSGTL(("read_config", "netsnmp_getenv called with name: %s\n",name));
 1198|       |
 1199|       |  if (!(name))
 1200|       |    return NULL;
 1201|       |  
 1202|       |  /* Try environment variable first */ 
 1203|       |  temp = getenv(name);
 1204|       |  if (temp) {
 1205|       |    getenv_worked = 1;
 1206|       |    DEBUGMSGTL(("read_config", "netsnmp_getenv will return from ENV: %s\n",temp));
 1207|       |  }
 1208|       |  
 1209|       |  /* Next try HKCU */
 1210|       |  if (temp == NULL)
 1211|       |  {
 1212|       |    if (getenv("SNMP_IGNORE_WINDOWS_REGISTRY"))
 1213|       |      return NULL;
 1214|       |
 1215|       |    if (RegOpenKeyExA(
 1216|       |          HKEY_CURRENT_USER, 
 1217|       |          "SOFTWARE\\Net-SNMP", 
 1218|       |          0, 
 1219|       |          KEY_QUERY_VALUE, 
 1220|       |          &hKey) == ERROR_SUCCESS) {   
 1221|       |      
 1222|       |      if (RegQueryValueExA(
 1223|       |            hKey, 
 1224|       |            name, 
 1225|       |            NULL, 
 1226|       |            &key_value_type, 
 1227|       |            NULL,               /* Just get the size */
 1228|       |            &key_value_size) == ERROR_SUCCESS) {
 1229|       |
 1230|       |        SNMP_FREE(key_value);
 1231|       |
 1232|       |        /* Allocate memory needed +1 to allow RegQueryValueExA to NULL terminate the
 1233|       |         * string data in registry is missing one (which is unlikely).
 1234|       |         */
 1235|       |        key_value = malloc((sizeof(char) * key_value_size)+sizeof(char));
 1236|       |        
 1237|       |        if (RegQueryValueExA(
 1238|       |              hKey, 
 1239|       |              name, 
 1240|       |              NULL, 
 1241|       |              &key_value_type, 
 1242|       |              key_value, 
 1243|       |              &key_value_size) == ERROR_SUCCESS) {
 1244|       |        }
 1245|       |        temp = (char *) key_value;
 1246|       |      }
 1247|       |      RegCloseKey(hKey);
 1248|       |      if (temp)
 1249|       |        DEBUGMSGTL(("read_config", "netsnmp_getenv will return from HKCU: %s\n",temp));
 1250|       |    }
 1251|       |  }
 1252|       |
 1253|       |  /* Next try HKLM */
 1254|       |  if (temp == NULL)
 1255|       |  {
 1256|       |    if (RegOpenKeyExA(
 1257|       |          HKEY_LOCAL_MACHINE, 
 1258|       |          "SOFTWARE\\Net-SNMP", 
 1259|       |          0, 
 1260|       |          KEY_QUERY_VALUE, 
 1261|       |          &hKey) == ERROR_SUCCESS) {   
 1262|       |      
 1263|       |      if (RegQueryValueExA(
 1264|       |            hKey, 
 1265|       |            name, 
 1266|       |            NULL, 
 1267|       |            &key_value_type, 
 1268|       |            NULL,               /* Just get the size */
 1269|       |            &key_value_size) == ERROR_SUCCESS) {
 1270|       |
 1271|       |        SNMP_FREE(key_value);
 1272|       |
 1273|       |        /* Allocate memory needed +1 to allow RegQueryValueExA to NULL terminate the
 1274|       |         * string data in registry is missing one (which is unlikely).
 1275|       |         */
 1276|       |        key_value = malloc((sizeof(char) * key_value_size)+sizeof(char));
 1277|       |        
 1278|       |        if (RegQueryValueExA(
 1279|       |              hKey, 
 1280|       |              name, 
 1281|       |              NULL, 
 1282|       |              &key_value_type, 
 1283|       |              key_value, 
 1284|       |              &key_value_size) == ERROR_SUCCESS) {
 1285|       |        }
 1286|       |        temp = (char *) key_value;
 1287|       |
 1288|       |      }
 1289|       |      RegCloseKey(hKey);
 1290|       |      if (temp)
 1291|       |        DEBUGMSGTL(("read_config", "netsnmp_getenv will return from HKLM: %s\n",temp));
 1292|       |    }
 1293|       |  }
 1294|       |  
 1295|       |  if (temp && !getenv_worked) {
 1296|       |    setenv(name, temp, 1);
 1297|       |    SNMP_FREE(temp);
 1298|       |  }
 1299|       |
 1300|       |  DEBUGMSGTL(("read_config", "netsnmp_getenv returning: %s\n",getenv(name)));
 1301|       |
 1302|       |  return(getenv(name));
 1303|       |#endif
 1304|    349|}
netsnmp_gethomedir:
 1416|     59|const char *netsnmp_gethomedir(void) {
 1417|     59|    const char *homepath = netsnmp_getenv("HOME");
 1418|       |#ifdef _WIN32
 1419|       |    if (!homepath)
 1420|       |        homepath = netsnmp_getenv("USERPROFILE");
 1421|       |#endif
 1422|     59|    return homepath;
 1423|     59|}

netsnmp_aal5pvc_ctor:
  379|     58|{
  380|     58|    aal5pvcDomain.name = netsnmp_AAL5PVCDomain;
  381|     58|    aal5pvcDomain.name_length = OID_LENGTH(netsnmp_AAL5PVCDomain);
  ------------------
  |  |   64|     58|    (sizeof(x) / sizeof((x)[0]) +                                       \
  |  |   65|     58|     sizeof(int[-__builtin_types_compatible_p(typeof(x), typeof(&(x)[0]))]))
  ------------------
  382|     58|    aal5pvcDomain.prefix = calloc(3, sizeof(char *));
  383|     58|    if (!aal5pvcDomain.prefix) {
  ------------------
  |  Branch (383:9): [True: 0, False: 58]
  ------------------
  384|      0|        snmp_log(LOG_ERR, "calloc() failed - out of memory\n");
  385|      0|        return;
  386|      0|    }
  387|     58|    aal5pvcDomain.prefix[0] = "aal5pvc";
  388|     58|    aal5pvcDomain.prefix[1] = "pvc";
  389|       |
  390|     58|    aal5pvcDomain.f_create_from_tstring_new = netsnmp_aal5pvc_create_tstring;
  391|     58|    aal5pvcDomain.f_create_from_ostring     = netsnmp_aal5pvc_create_ostring;
  392|       |
  393|     58|    netsnmp_tdomain_register(&aal5pvcDomain);
  394|     58|}

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

netsnmp_dtlsudp_ctor:
 1733|     58|{
 1734|     58|    static const char indexname[] = "_netsnmp_addr_info";
 1735|     58|    static const char *prefixes[] = { "dtlsudp", "dtls"
 1736|     58|#ifdef NETSNMP_TRANSPORT_UDPIPV6_DOMAIN
 1737|     58|                                      , "dtlsudp6", "dtls6"
 1738|     58|#endif
 1739|     58|    };
 1740|     58|    int i, num_prefixes = sizeof(prefixes) / sizeof(char *);
 1741|     58|#ifdef NETSNMP_TRANSPORT_UDPIPV6_DOMAIN
 1742|     58|    static const char indexname6[] = "_netsnmp_addr_info6";
 1743|     58|#endif
 1744|       |
 1745|     58|    DEBUGMSGTL(("dtlsudp", "registering DTLS constructor\n"));
  ------------------
  |  |   66|     58|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     58|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 58]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 58]
  |  |  ------------------
  ------------------
 1746|       |
 1747|       |    /* config settings */
 1748|       |
 1749|     58|#ifdef NETSNMP_TRANSPORT_UDPIPV6_DOMAIN
 1750|     58|    if (!openssl_addr_index6)
  ------------------
  |  Branch (1750:9): [True: 1, False: 57]
  ------------------
 1751|      1|        openssl_addr_index6 =
 1752|      1|            SSL_get_ex_new_index(0, NETSNMP_REMOVE_CONST(void *, indexname6),
 1753|     58|                                 NULL, NULL, NULL);
 1754|     58|#endif
 1755|       |
 1756|     58|    dtlsudpDomain.name = netsnmpDTLSUDPDomain;
 1757|     58|    dtlsudpDomain.name_length = netsnmpDTLSUDPDomain_len;
 1758|     58|    dtlsudpDomain.prefix = calloc(num_prefixes + 1, sizeof(char *));
 1759|     58|    if (!dtlsudpDomain.prefix) {
  ------------------
  |  Branch (1759:9): [True: 0, False: 58]
  ------------------
 1760|      0|        snmp_log(LOG_ERR, "calloc() failed - out of memory\n");
 1761|      0|        return;
 1762|      0|    }
 1763|    290|    for (i = 0; i < num_prefixes; ++ i)
  ------------------
  |  Branch (1763:17): [True: 232, False: 58]
  ------------------
 1764|    232|        dtlsudpDomain.prefix[i] = prefixes[i];
 1765|       |
 1766|     58|    dtlsudpDomain.f_create_from_tstring_new = netsnmp_dtlsudp_create_tstring;
 1767|     58|    dtlsudpDomain.f_create_from_ostring     = netsnmp_dtlsudp_create_ostring;
 1768|       |
 1769|     58|    if (!openssl_addr_index)
  ------------------
  |  Branch (1769:9): [True: 1, False: 57]
  ------------------
 1770|      1|        openssl_addr_index =
 1771|      1|            SSL_get_ex_new_index(0, NETSNMP_REMOVE_CONST(void *, indexname),
 1772|     58|                                 NULL, NULL, NULL);
 1773|       |
 1774|     58|    netsnmp_tdomain_register(&dtlsudpDomain);
 1775|     58|}

netsnmp_parse_ep_str:
   31|     58|{
   32|     58|    char *dup, *cp, *addrstr = NULL, *iface = NULL, *portstr = NULL;
   33|     58|    unsigned port;
   34|       |
   35|     58|    if (!endpoint)
  ------------------
  |  Branch (35:9): [True: 0, False: 58]
  ------------------
   36|      0|        return 0;
   37|       |
   38|     58|    dup = strdup(endpoint);
   39|     58|    if (!dup)
  ------------------
  |  Branch (39:9): [True: 0, False: 58]
  ------------------
   40|      0|        return 0;
   41|       |
   42|     58|    cp = dup;
   43|     58|    if (netsnmp_isnumber(cp)) {
  ------------------
  |  Branch (43:9): [True: 0, False: 58]
  ------------------
   44|      0|        portstr = cp;
   45|     58|    } else {
   46|     58|        if (*cp == '[') {
  ------------------
  |  Branch (46:13): [True: 0, False: 58]
  ------------------
   47|      0|            addrstr = cp + 1;
   48|      0|            cp = strchr(cp, ']');
   49|      0|            if (cp) {
  ------------------
  |  Branch (49:17): [True: 0, False: 0]
  ------------------
   50|      0|                cp[0] = '\0';
   51|      0|                cp++;
   52|      0|            } else {
   53|      0|                goto err;
   54|      0|            }
   55|     58|        } else if (*cp != '@' && (*cp != ':' || cp[1] == ':')) {
  ------------------
  |  Branch (55:20): [True: 58, False: 0]
  |  Branch (55:35): [True: 58, False: 0]
  |  Branch (55:49): [True: 0, False: 0]
  ------------------
   56|     58|            addrstr = cp;
   57|     58|            cp = strchr(addrstr, '@');
   58|     58|            if (!cp) {
  ------------------
  |  Branch (58:17): [True: 58, False: 0]
  ------------------
   59|     58|                cp = strrchr(addrstr, ':');
   60|     58|                if (cp && strchr(dup, ':') < cp)
  ------------------
  |  Branch (60:21): [True: 58, False: 0]
  |  Branch (60:27): [True: 0, False: 58]
  ------------------
   61|      0|                    cp = NULL;
   62|     58|            }
   63|     58|        }
   64|     58|        if (cp && *cp == '@') {
  ------------------
  |  Branch (64:13): [True: 58, False: 0]
  |  Branch (64:19): [True: 0, False: 58]
  ------------------
   65|      0|            *cp = '\0';
   66|      0|            iface = cp + 1;
   67|      0|            cp = strchr(cp + 1, ':');
   68|      0|        }
   69|     58|        if (cp && *cp == ':') {
  ------------------
  |  Branch (69:13): [True: 58, False: 0]
  |  Branch (69:19): [True: 58, False: 0]
  ------------------
   70|     58|            *cp++ = '\0';
   71|     58|            portstr = cp;
   72|     58|            if (!netsnmp_isnumber(cp))
  ------------------
  |  Branch (72:17): [True: 0, False: 58]
  ------------------
   73|      0|                goto err;
   74|     58|        } else if (cp && *cp) {
  ------------------
  |  Branch (74:20): [True: 0, False: 0]
  |  Branch (74:26): [True: 0, False: 0]
  ------------------
   75|      0|            goto err;
   76|      0|        }
   77|     58|    }
   78|       |
   79|     58|    if (addrstr) {
  ------------------
  |  Branch (79:9): [True: 58, False: 0]
  ------------------
   80|     58|        ep_str->addr = strdup(addrstr);
   81|     58|        if (!ep_str->addr)
  ------------------
  |  Branch (81:13): [True: 0, False: 58]
  ------------------
   82|      0|            goto err;
   83|     58|    }
   84|     58|    if (iface)
  ------------------
  |  Branch (84:9): [True: 0, False: 58]
  ------------------
   85|      0|        strlcpy(ep_str->iface, iface, sizeof(ep_str->iface));
   86|     58|    if (portstr) {
  ------------------
  |  Branch (86:9): [True: 58, False: 0]
  ------------------
   87|     58|        port = atoi(portstr);
   88|     58|        if (port <= 0xffff)
  ------------------
  |  Branch (88:13): [True: 58, False: 0]
  ------------------
   89|     58|            strlcpy(ep_str->port, portstr, sizeof(ep_str->port));
   90|      0|        else
   91|      0|            goto err;
   92|     58|    }
   93|       |
   94|     58|    free(dup);
   95|     58|    return 1;
   96|       |
   97|      0|err:
   98|      0|    free(ep_str->addr);
   99|       |    ep_str->addr = NULL;
  100|      0|    free(dup);
  101|      0|    return 0;
  102|     58|}
netsnmp_bindtodevice:
  105|     58|{
  106|       |    /* If no interface name has been specified, report success. */
  107|     58|    if (!iface || iface[0] == '\0')
  ------------------
  |  Branch (107:9): [True: 0, False: 58]
  |  Branch (107:19): [True: 58, False: 0]
  ------------------
  108|     58|        return 0;
  109|       |
  110|      0|#ifdef HAVE_SO_BINDTODEVICE
  111|      0|    {
  112|       |        /*
  113|       |         * +1 to work around the Linux kernel bug that the passed in name is not
  114|       |         * '\0'-terminated.
  115|       |         */
  116|      0|        int ifacelen = strlen(iface) + 1;
  117|      0|        int ret;
  118|       |
  119|      0|        ret = setsockopt(sock, SOL_SOCKET, SO_BINDTODEVICE, iface, ifacelen);
  120|      0|        if (ret < 0)
  ------------------
  |  Branch (120:13): [True: 0, False: 0]
  ------------------
  121|      0|            snmp_log(LOG_ERR, "Binding socket to interface %s failed: %s\n",
  122|      0|                     iface, strerror(errno));
  123|      0|        return ret;
  124|     58|    }
  125|       |#else
  126|       |    errno = EINVAL;
  127|       |    return -1;
  128|       |#endif
  129|     58|}
netsnmp_ipbase_session_init:
  132|     58|                            struct snmp_session *sess) {
  133|     58|    union {
  134|     58|        struct sockaddr     sa;
  135|     58|        struct sockaddr_in  sin;
  136|     58|        struct sockaddr_in6 sin6;
  137|     58|    } ss;
  138|     58|    socklen_t len = sizeof(ss);
  139|       |
  140|     58|    if (!sess) {
  ------------------
  |  Branch (140:9): [True: 0, False: 58]
  ------------------
  141|      0|        DEBUGMSGTL(("netsnmp_ipbase", "session pointer is NULL\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]
  |  |  ------------------
  ------------------
  142|      0|        return SNMPERR_SUCCESS;
  ------------------
  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  143|      0|    }
  144|       |
  145|     58|    if (getsockname(transport->sock, (struct sockaddr *)&ss, &len) == -1) {
  ------------------
  |  Branch (145:9): [True: 0, False: 58]
  ------------------
  146|      0|        DEBUGMSGTL(("netsnmp_ipbase", "getsockname error %s\n", strerror(errno)));
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
  147|      0|        return SNMPERR_SUCCESS;
  ------------------
  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  148|      0|    }
  149|     58|    switch (ss.sa.sa_family) {
  150|     58|    case AF_INET:
  ------------------
  |  Branch (150:5): [True: 58, False: 0]
  ------------------
  151|     58|        sess->local_port = ntohs(ss.sin.sin_port);
  152|     58|        break;
  153|      0|    case AF_INET6:
  ------------------
  |  Branch (153:5): [True: 0, False: 58]
  ------------------
  154|      0|        sess->local_port = ntohs(ss.sin6.sin6_port);
  155|      0|        break;
  156|      0|    default:
  ------------------
  |  Branch (156:5): [True: 0, False: 58]
  ------------------
  157|      0|        DEBUGMSGTL(("netsnmp_ipbase", "unsupported address family %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]
  |  |  ------------------
  ------------------
  158|      0|                    ss.sa.sa_family));
  159|      0|        return SNMPERR_SUCCESS;
  ------------------
  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  160|     58|    }
  161|       |
  162|     58|    DEBUGMSGTL(("netsnmp_ipbase", "local port number %d\n", sess->local_port));
  ------------------
  |  |   66|     58|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     58|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 58]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 58]
  |  |  ------------------
  ------------------
  163|       |
  164|     58|    return SNMPERR_SUCCESS;
  ------------------
  |  |  184|     58|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  165|     58|}
snmpIPBaseDomain.c:netsnmp_isnumber:
   12|    116|{
   13|    116|    if (!*cp)
  ------------------
  |  Branch (13:9): [True: 0, False: 116]
  ------------------
   14|      0|        return 0;
   15|       |
   16|    116|    while (isdigit((unsigned char)*cp))
  ------------------
  |  Branch (16:12): [True: 406, False: 116]
  ------------------
   17|    406|        cp++;
   18|    116|    return *cp == '\0';
   19|    116|}

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

netsnmp_sockaddr_in3:
   87|     58|{
   88|     58|    struct sockaddr_in *addr = &ep->a.sin;
   89|     58|    struct netsnmp_ep_str ep_str;
   90|     58|    int port, ret;
   91|       |
   92|     58|    if (!ep)
  ------------------
  |  Branch (92:9): [True: 0, False: 58]
  ------------------
   93|      0|        return 0;
   94|       |
   95|     58|    DEBUGMSGTL(("netsnmp_sockaddr_in",
  ------------------
  |  |   66|     58|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     58|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 58]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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:52): [True: 0, False: 0]
  |  |  |  |  |  Branch (164:64): [True: 0, False: 0]
  |  |  |  |  |  Branch (164:64): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 58]
  |  |  ------------------
  ------------------
   96|     58|                "addr %p, inpeername \"%s\", default_target \"%s\"\n",
   97|     58|                ep, inpeername ? inpeername : "[NIL]",
   98|     58|                default_target ? default_target : "[NIL]"));
   99|       |
  100|     58|    memset(ep, 0, sizeof(*ep));
  101|     58|    addr->sin_addr.s_addr = htonl(INADDR_ANY);
  102|     58|    addr->sin_family = AF_INET;
  103|     58|    addr->sin_port = htons((u_short)SNMP_PORT);
  104|       |
  105|     58|    memset(&ep_str, 0, sizeof(ep_str));
  106|     58|    port = netsnmp_ds_get_int(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  107|     58|                              NETSNMP_DS_LIB_DEFAULT_PORT);
  ------------------
  |  |  117|     58|#define NETSNMP_DS_LIB_DEFAULT_PORT         3
  ------------------
  108|     58|    if (port != 0)
  ------------------
  |  Branch (108:9): [True: 0, False: 58]
  ------------------
  109|      0|        snprintf(ep_str.port, sizeof(ep_str.port), "%d", port);
  110|     58|    else if (default_target &&
  ------------------
  |  Branch (110:14): [True: 0, False: 58]
  ------------------
  111|      0|             !netsnmp_parse_ep_str(&ep_str, default_target))
  ------------------
  |  Branch (111:14): [True: 0, False: 0]
  ------------------
  112|      0|            snmp_log(LOG_ERR, "Invalid default target %s\n",
  113|      0|                     default_target);
  114|     58|    if (inpeername && *inpeername != '\0') {
  ------------------
  |  Branch (114:9): [True: 58, False: 0]
  |  Branch (114:23): [True: 58, False: 0]
  ------------------
  115|     58|        char *default_addr = ep_str.addr;
  116|       |
  117|     58|        ep_str.addr = NULL;
  118|     58|        if (!netsnmp_parse_ep_str(&ep_str, inpeername)) {
  ------------------
  |  Branch (118:13): [True: 0, False: 58]
  ------------------
  119|      0|            free(default_addr);
  120|      0|            return 0;
  121|      0|        }
  122|     58|        if (ep_str.addr)
  ------------------
  |  Branch (122:13): [True: 58, False: 0]
  ------------------
  123|     58|            free(default_addr);
  124|      0|        else
  125|      0|            ep_str.addr = default_addr;
  126|     58|    }
  127|       |
  128|     58|    if (ep_str.port[0])
  ------------------
  |  Branch (128:9): [True: 58, False: 0]
  ------------------
  129|     58|        addr->sin_port = htons(atoi(ep_str.port));
  130|     58|    if (ep_str.iface[0])
  ------------------
  |  Branch (130:9): [True: 0, False: 58]
  ------------------
  131|      0|        strlcpy(ep->iface, ep_str.iface, sizeof(ep->iface));
  132|     58|    if (ep_str.addr && strcmp(ep_str.addr, "255.255.255.255") == 0) {
  ------------------
  |  Branch (132:9): [True: 58, False: 0]
  |  Branch (132:24): [True: 0, False: 58]
  ------------------
  133|       |        /*
  134|       |         * The explicit broadcast address hack
  135|       |         */
  136|      0|        DEBUGMSGTL(("netsnmp_sockaddr_in", "Explicit UDP broadcast\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]
  |  |  ------------------
  ------------------
  137|      0|        addr->sin_addr.s_addr = INADDR_NONE;
  138|     58|    } else if (ep_str.addr && strcmp(ep_str.addr, "") != 0) {
  ------------------
  |  Branch (138:16): [True: 58, False: 0]
  |  Branch (138:31): [True: 58, False: 0]
  ------------------
  139|     58|        ret = netsnmp_gethostbyname_v4(ep_str.addr, &addr->sin_addr.s_addr);
  140|     58|        if (ret < 0) {
  ------------------
  |  Branch (140:13): [True: 0, False: 58]
  ------------------
  141|      0|            DEBUGMSGTL(("netsnmp_sockaddr_in",
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
  142|      0|                        "couldn't resolve hostname \"%s\"\n", ep_str.addr));
  143|      0|            free(ep_str.addr);
  144|      0|            return 0;
  145|      0|        }
  146|     58|        DEBUGMSGTL(("netsnmp_sockaddr_in",
  ------------------
  |  |   66|     58|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     58|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 58]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 58]
  |  |  ------------------
  ------------------
  147|     58|                    "hostname (resolved okay)\n"));
  148|     58|    }
  149|       |
  150|       |    /*
  151|       |     * Finished
  152|       |     */
  153|       |
  154|     58|    DEBUGMSGTL(("netsnmp_sockaddr_in", "return { AF_INET, %s:%hu }\n",
  ------------------
  |  |   66|     58|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     58|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 58]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 58]
  |  |  ------------------
  ------------------
  155|     58|                inet_ntoa(addr->sin_addr), ntohs(addr->sin_port)));
  156|     58|    free(ep_str.addr);
  157|     58|    return 1;
  158|     58|}

netsnmp_std_ctor:
  288|     58|{
  289|     58|    stdDomain.name = netsnmp_snmpSTDDomain;
  290|     58|    stdDomain.name_length = OID_LENGTH(netsnmp_snmpSTDDomain);
  ------------------
  |  |   64|     58|    (sizeof(x) / sizeof((x)[0]) +                                       \
  |  |   65|     58|     sizeof(int[-__builtin_types_compatible_p(typeof(x), typeof(&(x)[0]))]))
  ------------------
  291|     58|    stdDomain.prefix = calloc(2, sizeof(char *));
  292|     58|    if (!stdDomain.prefix) {
  ------------------
  |  Branch (292:9): [True: 0, False: 58]
  ------------------
  293|      0|        snmp_log(LOG_ERR, "calloc() failed - out of memory\n");
  294|      0|        return;
  295|      0|    }
  296|     58|    stdDomain.prefix[0] = "std";
  297|       |
  298|     58|    stdDomain.f_create_from_tstring_new = netsnmp_std_create_tstring;
  299|     58|    stdDomain.f_create_from_ostring     = netsnmp_std_create_ostring;
  300|       |
  301|     58|    netsnmp_tdomain_register(&stdDomain);
  302|     58|}

netsnmp_socketbase_close:
   49|     58|int netsnmp_socketbase_close(netsnmp_transport *t) {
   50|     58|    int rc = -1;
   51|     58|    if (NETSNMP_IS_VALID_SOCKET(t->sock)) {
  ------------------
  |  |   44|     58|#define NETSNMP_IS_VALID_SOCKET(_sock) ((_sock) != -1)
  |  |  ------------------
  |  |  |  Branch (44:40): [True: 58, False: 0]
  |  |  ------------------
  ------------------
   52|     58|#ifndef HAVE_CLOSESOCKET
   53|     58|        rc = close(t->sock);
   54|       |#else
   55|       |        rc = closesocket(t->sock);
   56|       |#endif
   57|     58|        t->sock = NETSNMP_INVALID_SOCKET;
  ------------------
  |  |   43|     58|#define NETSNMP_INVALID_SOCKET -1
  ------------------
   58|     58|    }
   59|     58|    return rc;
   60|     58|}
netsnmp_sock_buffer_set:
  227|    116|{
  228|       |#if ! defined(SO_SNDBUF) && ! defined(SO_RCVBUF)
  229|       |    DEBUGMSGTL(("socket:buffer", "Changing socket buffer is not supported\n"));
  230|       |    return -1;
  231|       |#else
  232|    116|    const char     *buftype;
  233|    116|    int            curbuf = 0;
  234|    116|    socklen_t      curbuflen = sizeof(int);
  235|       |
  236|       |#   ifndef  SO_SNDBUF
  237|       |    if (SO_SNDBUF == optname) {
  238|       |        DEBUGMSGTL(("socket:buffer",
  239|       |                    "Changing socket send buffer is not supported\n"));
  240|       |        return -1;
  241|       |    }
  242|       |#   endif                          /*SO_SNDBUF */
  243|       |#   ifndef  SO_RCVBUF
  244|       |    if (SO_RCVBUF == optname) {
  245|       |        DEBUGMSGTL(("socket:buffer",
  246|       |                    "Changing socket receive buffer is not supported\n"));
  247|       |        return -1;
  248|       |    }
  249|       |#   endif                          /*SO_RCVBUF */
  250|       |
  251|       |    /*
  252|       |     * What is the requested buffer size ?
  253|       |     */
  254|    116|    if (0 == size)
  ------------------
  |  Branch (254:9): [True: 116, False: 0]
  ------------------
  255|    116|        size = _sock_buffer_size_get(optname, local, &buftype);
  256|      0|    else {
  257|      0|        buftype = _sock_buf_type_get(optname, local);
  258|      0|        DEBUGMSGT(("verbose:socket:buffer", "Requested %s is %d\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]
  |  |  ------------------
  ------------------
  259|      0|                   buftype, size));
  260|      0|    }
  261|       |
  262|    116|    if ((getsockopt(sock, SOL_SOCKET, optname, (void *) &curbuf,
  ------------------
  |  Branch (262:9): [True: 116, False: 0]
  ------------------
  263|    116|                    &curbuflen) == 0) 
  264|    116|        && (curbuflen == sizeof(int))) {
  ------------------
  |  Branch (264:12): [True: 116, False: 0]
  ------------------
  265|       |        
  266|    116|        DEBUGMSGT(("verbose:socket:buffer", "Original %s is %d\n",
  ------------------
  |  |   62|    116|#define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    116|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 116]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 116]
  |  |  ------------------
  ------------------
  267|    116|                   buftype, curbuf));
  268|    116|        if (curbuf >= size) {
  ------------------
  |  Branch (268:13): [True: 116, False: 0]
  ------------------
  269|    116|            DEBUGMSGT(("verbose:socket:buffer",
  ------------------
  |  |   62|    116|#define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    116|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 116]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 116]
  |  |  ------------------
  ------------------
  270|    116|                      "New %s size is smaller than original!\n", buftype));
  271|    116|        }
  272|    116|    }
  273|       |
  274|       |    /*
  275|       |     * If the buffersize was not specified or it was a negative value
  276|       |     * then don't change the OS buffers at all
  277|       |     */
  278|    116|    if (size <= 0) {
  ------------------
  |  Branch (278:9): [True: 116, False: 0]
  ------------------
  279|    116|       DEBUGMSGT(("socket:buffer",
  ------------------
  |  |   62|    116|#define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    116|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 116]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 116]
  |  |  ------------------
  ------------------
  280|    116|                    "%s not valid or not specified; using OS default(%d)\n",
  281|    116|                    buftype,curbuf));
  282|    116|       return curbuf;
  283|    116|    }
  284|       |
  285|       |    /*
  286|       |     * Try to set the requested send buffer
  287|       |     */
  288|      0|    if (setsockopt(sock, SOL_SOCKET, optname, (void *) &size, sizeof(int)) == 0) {
  ------------------
  |  Branch (288:9): [True: 0, False: 0]
  ------------------
  289|       |        /*
  290|       |         * Because some platforms lie about the actual buffer that has been 
  291|       |         * set (Linux will always say it worked ...), we print some 
  292|       |         * diagnostic output for debugging
  293|       |         */
  294|      0|        DEBUGIF("socket:buffer") {
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  295|      0|            DEBUGMSGT(("socket:buffer", "Set %s to %d\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]
  |  |  ------------------
  ------------------
  296|      0|                       buftype, size));
  297|      0|            if ((getsockopt(sock, SOL_SOCKET, optname, (void *) &curbuf,
  ------------------
  |  Branch (297:17): [True: 0, False: 0]
  ------------------
  298|      0|                            &curbuflen) == 0) 
  299|      0|                    && (curbuflen == sizeof(int))) {
  ------------------
  |  Branch (299:24): [True: 0, False: 0]
  ------------------
  300|       |
  301|      0|                DEBUGMSGT(("verbose:socket:buffer",
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
  302|      0|                           "Now %s is %d\n", buftype, curbuf));
  303|      0|            }
  304|      0|        }
  305|       |        /*
  306|       |         * If the new buffer is smaller than the size we requested, we will
  307|       |         * try to increment the new buffer with 1k increments 
  308|       |         * (this will sometime allow us to reach a more optimal buffer.)
  309|       |         *   For example : On Solaris, if the max OS buffer is 100k and you
  310|       |         *   request 110k, you end up with the default 8k :-(
  311|       |         */
  312|      0|        if (curbuf < size) {
  ------------------
  |  Branch (312:13): [True: 0, False: 0]
  ------------------
  313|      0|            curbuf = _sock_buffer_maximize(sock, optname, buftype, size);
  314|      0|            if(-1 != curbuf)
  ------------------
  |  Branch (314:16): [True: 0, False: 0]
  ------------------
  315|      0|                size = curbuf;
  316|      0|        }
  317|       |
  318|      0|    } else {
  319|       |        /*
  320|       |         * Obviously changing the buffer failed, most like like because we 
  321|       |         * requested a buffer greater than the OS limit.
  322|       |         * Therefore we need to search for an optimal buffer that is close
  323|       |         * enough to the point of failure.
  324|       |         * This will allow us to reach a more optimal buffer.
  325|       |         *   For example : On Solaris, if the max OS buffer is 100k and you 
  326|       |         *   request 110k, you end up with the default 8k :-(
  327|       |         *   After this quick seach we would get 1k close to 100k (the max)
  328|       |         */
  329|      0|        DEBUGMSGTL(("socket:buffer", "couldn't set %s to %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]
  |  |  ------------------
  ------------------
  330|      0|                    buftype, size));
  331|       |
  332|      0|        curbuf = _sock_buffer_maximize(sock, optname, buftype, size);
  333|      0|        if(-1 != curbuf)
  ------------------
  |  Branch (333:12): [True: 0, False: 0]
  ------------------
  334|      0|            size = curbuf;
  335|      0|    }
  336|       |
  337|      0|    return size;
  338|    116|#endif
  339|    116|}
snmpSocketBaseDomain.c:_sock_buffer_size_get:
  166|    116|{
  167|    116|    int size;
  168|       |
  169|    116|    if (NULL != buftype)
  ------------------
  |  Branch (169:9): [True: 116, False: 0]
  ------------------
  170|    116|        *buftype = _sock_buf_type_get(optname, local);
  171|       |
  172|    116|    if (optname == SO_SNDBUF) {
  ------------------
  |  Branch (172:9): [True: 58, False: 58]
  ------------------
  173|     58|        if (local) {
  ------------------
  |  Branch (173:13): [True: 58, False: 0]
  ------------------
  174|     58|            size = netsnmp_ds_get_int(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  175|     58|                    NETSNMP_DS_LIB_SERVERSENDBUF);
  ------------------
  |  |  122|     58|#define NETSNMP_DS_LIB_SERVERSENDBUF        7 /* send buffer (server) */
  ------------------
  176|       |#ifdef NETSNMP_DEFAULT_SERVER_SEND_BUF
  177|       |            if (size <= 0)
  178|       |               size = NETSNMP_DEFAULT_SERVER_SEND_BUF;
  179|       |#endif
  180|     58|        } else {
  181|      0|            size = netsnmp_ds_get_int(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|      0|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  182|      0|                    NETSNMP_DS_LIB_CLIENTSENDBUF);
  ------------------
  |  |  124|      0|#define NETSNMP_DS_LIB_CLIENTSENDBUF        9 /* send buffer (client) */
  ------------------
  183|       |#ifdef NETSNMP_DEFAULT_CLIENT_SEND_BUF
  184|       |            if (size <= 0)
  185|       |               size = NETSNMP_DEFAULT_CLIENT_SEND_BUF;
  186|       |#endif
  187|      0|        }
  188|     58|    } else if (optname == SO_RCVBUF) {
  ------------------
  |  Branch (188:16): [True: 58, False: 0]
  ------------------
  189|     58|        if (local) {
  ------------------
  |  Branch (189:13): [True: 58, False: 0]
  ------------------
  190|     58|            size = netsnmp_ds_get_int(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  191|     58|                    NETSNMP_DS_LIB_SERVERRECVBUF);
  ------------------
  |  |  123|     58|#define NETSNMP_DS_LIB_SERVERRECVBUF        8 /* receive buffer (server) */
  ------------------
  192|       |#ifdef NETSNMP_DEFAULT_SERVER_RECV_BUF
  193|       |            if (size <= 0)
  194|       |               size = NETSNMP_DEFAULT_SERVER_RECV_BUF;
  195|       |#endif
  196|     58|        } else {
  197|      0|            size = netsnmp_ds_get_int(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|      0|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  198|      0|                    NETSNMP_DS_LIB_CLIENTRECVBUF);
  ------------------
  |  |  125|      0|#define NETSNMP_DS_LIB_CLIENTRECVBUF       10 /* receive buffer (client) */
  ------------------
  199|       |#ifdef NETSNMP_DEFAULT_CLIENT_RECV_BUF
  200|       |            if (size <= 0)
  201|       |               size = NETSNMP_DEFAULT_CLIENT_RECV_BUF;
  202|       |#endif
  203|      0|        }
  204|     58|    } else {
  205|      0|        size = 0;
  206|      0|    }
  207|       |
  208|    116|    DEBUGMSGTL(("socket:buffer", "Requested %s is %d\n",
  ------------------
  |  |   66|    116|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    116|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 116]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 116]
  |  |  ------------------
  ------------------
  209|    116|                (buftype) ? *buftype : "unknown buffer", size));
  210|       |
  211|    116|    return(size);
  212|    116|}
snmpSocketBaseDomain.c:_sock_buf_type_get:
  139|    116|{
  140|    116|    if (optname == SO_SNDBUF) {
  ------------------
  |  Branch (140:9): [True: 58, False: 58]
  ------------------
  141|     58|        if (local)
  ------------------
  |  Branch (141:13): [True: 58, False: 0]
  ------------------
  142|     58|            return "server send buffer";
  143|      0|        else
  144|      0|            return "client send buffer";
  145|     58|    } else if (optname == SO_RCVBUF) {
  ------------------
  |  Branch (145:16): [True: 58, False: 0]
  ------------------
  146|     58|        if (local)
  ------------------
  |  Branch (146:13): [True: 58, False: 0]
  ------------------
  147|     58|            return "server receive buffer";
  148|      0|        else
  149|      0|            return "client receive buffer";
  150|     58|    }
  151|       |
  152|      0|    return "unknown buffer";
  153|    116|}

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

netsnmp_tcpipv6_ctor:
  387|     58|{
  388|     58|    tcp6Domain.name = netsnmp_TCPIPv6Domain;
  389|     58|    tcp6Domain.name_length = OID_LENGTH(netsnmp_TCPIPv6Domain);
  ------------------
  |  |   64|     58|    (sizeof(x) / sizeof((x)[0]) +                                       \
  |  |   65|     58|     sizeof(int[-__builtin_types_compatible_p(typeof(x), typeof(&(x)[0]))]))
  ------------------
  390|     58|    tcp6Domain.f_create_from_tstring_new = netsnmp_tcp6_create_tstring;
  391|     58|    tcp6Domain.f_create_from_ostring     = netsnmp_tcp6_create_ostring;
  392|     58|    tcp6Domain.prefix = calloc(4, sizeof(char *));
  393|     58|    if (!tcp6Domain.prefix) {
  ------------------
  |  Branch (393:9): [True: 0, False: 58]
  ------------------
  394|      0|        snmp_log(LOG_ERR, "calloc() failed - out of memory\n");
  395|      0|        return;
  396|      0|    }
  397|     58|    tcp6Domain.prefix[0] = "tcp6";
  398|     58|    tcp6Domain.prefix[1] = "tcpv6";
  399|     58|    tcp6Domain.prefix[2] = "tcpipv6";
  400|       |
  401|     58|    netsnmp_tdomain_register(&tcp6Domain);
  402|     58|}

netsnmp_tlsbase_ctor:
 1001|     58|netsnmp_tlsbase_ctor(void) {
 1002|       |
 1003|       |    /* bootstrap ssl since we'll need it */
 1004|     58|    netsnmp_init_openssl();
 1005|       |
 1006|       |    /* the private client cert to authenticate with */
 1007|     58|    netsnmp_ds_register_config(ASN_OCTET_STR, "snmp", "extraX509SubDir",
  ------------------
  |  |   78|     58|#define ASN_OCTET_STR	    0x04U
  ------------------
 1008|     58|                               NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1009|     58|                               NETSNMP_DS_LIB_CERT_EXTRA_SUBDIR);
  ------------------
  |  |  177|     58|#define NETSNMP_DS_LIB_CERT_EXTRA_SUBDIR 26
  ------------------
 1010|       |
 1011|       |    /* Do we have a CRL list? */
 1012|     58|    netsnmp_ds_register_config(ASN_OCTET_STR, "snmp", "x509CRLFile",
  ------------------
  |  |   78|     58|#define ASN_OCTET_STR	    0x04U
  ------------------
 1013|     58|                               NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1014|     58|                               NETSNMP_DS_LIB_X509_CRL_FILE);
  ------------------
  |  |  179|     58|#define NETSNMP_DS_LIB_X509_CRL_FILE     28
  ------------------
 1015|       |
 1016|       |    /* What TLS algorithms should be use */
 1017|     58|    netsnmp_ds_register_config(ASN_OCTET_STR, "snmp", "tlsAlgorithms",
  ------------------
  |  |   78|     58|#define ASN_OCTET_STR	    0x04U
  ------------------
 1018|     58|                               NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1019|     58|                               NETSNMP_DS_LIB_TLS_ALGORITMS);
  ------------------
  |  |  180|     58|#define NETSNMP_DS_LIB_TLS_ALGORITMS     29
  ------------------
 1020|       |
 1021|       |    /* What TLS version should be used at least */
 1022|     58|    netsnmp_ds_register_config(ASN_OCTET_STR, "snmp", "tlsMinVersion",
  ------------------
  |  |   78|     58|#define ASN_OCTET_STR	    0x04U
  ------------------
 1023|     58|                               NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1024|     58|                               NETSNMP_DS_LIB_TLS_MIN_VERSION);
  ------------------
  |  |  187|     58|#define NETSNMP_DS_LIB_TLS_MIN_VERSION   36
  ------------------
 1025|       |
 1026|       |    /* What TLS version should be used at max */
 1027|     58|    netsnmp_ds_register_config(ASN_OCTET_STR, "snmp", "tlsMaxVersion",
  ------------------
  |  |   78|     58|#define ASN_OCTET_STR	    0x04U
  ------------------
 1028|     58|                               NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1029|     58|                               NETSNMP_DS_LIB_TLS_MAX_VERSION);
  ------------------
  |  |  188|     58|#define NETSNMP_DS_LIB_TLS_MAX_VERSION   37
  ------------------
 1030|       |
 1031|       |    /*
 1032|       |     * for the client
 1033|       |     */
 1034|       |
 1035|       |    /* the public client cert to authenticate with */
 1036|     58|    register_config_handler("snmp", "clientCert", _parse_client_cert, NULL,
 1037|     58|                            NULL);
 1038|       |
 1039|       |    /*
 1040|       |     * for the server
 1041|       |     */
 1042|       |
 1043|       |    /* The X509 server key to use */
 1044|     58|    register_config_handler("snmp", "serverCert", _parse_server_cert, NULL,
 1045|     58|                            NULL);
 1046|       |    /*
 1047|       |     * remove cert config ambiguity: localCert, peerCert
 1048|       |     */
 1049|     58|    netsnmp_ds_register_config(ASN_OCTET_STR, "snmp", "localCert",
  ------------------
  |  |   78|     58|#define ASN_OCTET_STR	    0x04U
  ------------------
 1050|     58|                               NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1051|     58|                               NETSNMP_DS_LIB_TLS_LOCAL_CERT);
  ------------------
  |  |  181|     58|#define NETSNMP_DS_LIB_TLS_LOCAL_CERT    30
  ------------------
 1052|     58|    netsnmp_ds_register_config(ASN_OCTET_STR, "snmp", "peerCert",
  ------------------
  |  |   78|     58|#define ASN_OCTET_STR	    0x04U
  ------------------
 1053|     58|                               NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1054|     58|                               NETSNMP_DS_LIB_TLS_PEER_CERT);
  ------------------
  |  |  182|     58|#define NETSNMP_DS_LIB_TLS_PEER_CERT     31
  ------------------
 1055|       |
 1056|       |    /*
 1057|       |     * register our boot-strapping needs
 1058|       |     */
 1059|     58|    snmp_register_callback(SNMP_CALLBACK_LIBRARY,
  ------------------
  |  |   18|     58|#define SNMP_CALLBACK_LIBRARY     0
  ------------------
 1060|     58|			   SNMP_CALLBACK_POST_PREMIB_READ_CONFIG,
  ------------------
  |  |   27|     58|#define SNMP_CALLBACK_POST_PREMIB_READ_CONFIG	3
  ------------------
 1061|     58|			   tls_bootstrap, NULL);
 1062|       |
 1063|     58|}
snmpTLSBaseDomain.c:tls_bootstrap:
  953|     58|tls_bootstrap(int majorid, int minorid, void *serverarg, void *clientarg) {
  954|     58|    char indexname[] = "_netsnmp_verify_info";
  955|       |
  956|       |    /* don't do this more than once */
  957|     58|    if (have_done_bootstrap)
  ------------------
  |  Branch (957:9): [True: 57, False: 1]
  ------------------
  958|     57|        return 0;
  959|      1|    have_done_bootstrap = 1;
  960|       |
  961|      1|    netsnmp_certs_load();
  962|       |
  963|      1|    openssl_local_index =
  964|      1|        SSL_get_ex_new_index(0, indexname, NULL, NULL, verify_info_free);
  965|       |
  966|      1|    return 0;
  967|     58|}

netsnmp_tlstcp_ctor:
 1216|     58|{
 1217|     58|    DEBUGMSGTL(("tlstcp", "registering TLS constructor\n"));
  ------------------
  |  |   66|     58|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     58|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 58]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 58]
  |  |  ------------------
  ------------------
 1218|       |
 1219|       |    /* config settings */
 1220|       |
 1221|     58|    tlstcpDomain.name = netsnmpTLSTCPDomain;
 1222|     58|    tlstcpDomain.name_length = netsnmpTLSTCPDomain_len;
 1223|     58|    tlstcpDomain.prefix = calloc(3, sizeof(char *));
 1224|     58|    if (!tlstcpDomain.prefix) {
  ------------------
  |  Branch (1224:9): [True: 0, False: 58]
  ------------------
 1225|      0|        snmp_log(LOG_ERR, "calloc() failed - out of memory\n");
 1226|      0|        return;
 1227|      0|    }
 1228|     58|    tlstcpDomain.prefix[0] = "tlstcp";
 1229|     58|    tlstcpDomain.prefix[1] = "tls";
 1230|       |
 1231|     58|    tlstcpDomain.f_create_from_tstring_new = netsnmp_tlstcp_create_tstring;
 1232|     58|    tlstcpDomain.f_create_from_ostring     = netsnmp_tlstcp_create_ostring;
 1233|       |
 1234|     58|    netsnmp_tdomain_register(&tlstcpDomain);
 1235|     58|}

_netsnmp_udp_sockopt_set:
   69|     58|{
   70|     58|#ifdef  SO_BSDCOMPAT
   71|       |    /*
   72|       |     * Patch for Linux.  Without this, UDP packets that fail get an ICMP
   73|       |     * response.  Linux turns the failed ICMP response into an error message
   74|       |     * and return value, unlike all other OS's.  
   75|       |     */
   76|     58|    if (0 == netsnmp_os_prematch("Linux","2.4"))
  ------------------
  |  Branch (76:9): [True: 0, False: 58]
  ------------------
   77|      0|    {
   78|      0|        int             one = 1;
   79|      0|        DEBUGMSGTL(("socket:option", "setting socket option SO_BSDCOMPAT\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]
  |  |  ------------------
  ------------------
   80|      0|        setsockopt(sock, SOL_SOCKET, SO_BSDCOMPAT, (void *) &one, sizeof(one));
   81|      0|    }
   82|     58|#endif                          /*SO_BSDCOMPAT */
   83|       |    /*
   84|       |     * SO_REUSEADDR will allow multiple apps to open the same port at
   85|       |     * the same time. Only the last one to open the socket will get
   86|       |     * data. Obviously, for an agent, this is a bad thing. There should
   87|       |     * only be one listener.
   88|       |     */
   89|       |#ifdef ALLOW_PORT_HIJACKING
   90|       |#ifdef  SO_REUSEADDR
   91|       |    /*
   92|       |     * Allow the same port to be specified multiple times without failing.
   93|       |     *    (useful for a listener)
   94|       |     */
   95|       |    {
   96|       |        int             one = 1;
   97|       |        DEBUGMSGTL(("socket:option", "setting socket option SO_REUSEADDR\n"));
   98|       |        setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void *) &one, sizeof(one));
   99|       |    }
  100|       |#endif                          /*SO_REUSEADDR */
  101|       |#endif
  102|       |
  103|       |    /*
  104|       |     * Try to set the send and receive buffers to a reasonably large value, so
  105|       |     * that we can send and receive big PDUs (defaults to 8192 bytes (!) on
  106|       |     * Solaris, for instance).  Don't worry too much about errors -- just
  107|       |     * plough on regardless.  
  108|       |     */
  109|     58|    netsnmp_sock_buffer_set(sock, SO_SNDBUF, local, 0);
  110|       |    netsnmp_sock_buffer_set(sock, SO_RCVBUF, local, 0);
  111|     58|}
netsnmp_udpbase_recvfrom:
  143|     57|{
  144|     57|    int r;
  145|     57|#if !defined(WIN32)
  146|     57|    struct iovec iov;
  147|     57|    char cmsg[CMSG_SPACE(cmsg_data_size)];
  148|     57|    struct cmsghdr *cm;
  149|     57|    struct msghdr msg;
  150|       |
  151|     57|    iov.iov_base = buf;
  152|     57|    iov.iov_len = len;
  153|       |
  154|     57|    memset(&msg, 0, sizeof msg);
  155|     57|    msg.msg_name = from;
  156|     57|    msg.msg_namelen = *fromlen;
  157|     57|    msg.msg_iov = &iov;
  158|     57|    msg.msg_iovlen = 1;
  159|     57|    msg.msg_control = &cmsg;
  160|     57|    msg.msg_controllen = sizeof(cmsg);
  161|       |
  162|     57|    r = recvmsg(sock, &msg, MSG_DONTWAIT);
  163|       |#else /* !defined(WIN32) */
  164|       |    WSABUF wsabuf;
  165|       |    char cmsg[WSA_CMSG_SPACE(sizeof(struct in_pktinfo))];
  166|       |    WSACMSGHDR *cm;
  167|       |    WSAMSG msg;
  168|       |    DWORD bytes_received;
  169|       |
  170|       |    wsabuf.buf = buf;
  171|       |    wsabuf.len = len;
  172|       |
  173|       |    msg.name = from;
  174|       |    msg.namelen = *fromlen;
  175|       |    msg.lpBuffers = &wsabuf;
  176|       |    msg.dwBufferCount = 1;
  177|       |    msg.Control.len = sizeof(cmsg);
  178|       |    msg.Control.buf = cmsg;
  179|       |    msg.dwFlags = 0;
  180|       |
  181|       |    if (pfWSARecvMsg) {
  182|       |        r = pfWSARecvMsg(sock, &msg, &bytes_received, NULL, NULL) == 0 ?
  183|       |            bytes_received : -1;
  184|       |        *fromlen = msg.namelen;
  185|       |    } else {
  186|       |        r = recvfrom(sock, buf, len, MSG_DONTWAIT, from, fromlen);
  187|       |    }
  188|       |#endif /* !defined(WIN32) */
  189|       |
  190|     57|    if (r == -1) {
  ------------------
  |  Branch (190:9): [True: 0, False: 57]
  ------------------
  191|      0|        return -1;
  192|      0|    }
  193|       |
  194|     57|    DEBUGMSGTL(("udpbase:recv", "got source addr: %s\n",
  ------------------
  |  |   66|     57|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     57|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 57]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 57]
  |  |  ------------------
  ------------------
  195|     57|                inet_ntoa(((struct sockaddr_in *)from)->sin_addr)));
  196|       |
  197|     57|    {
  198|       |        /* Get the local port number for use in diagnostic messages */
  199|     57|        int r2 = getsockname(sock, dstip, dstlen);
  200|     57|        netsnmp_assert(r2 == 0);
  ------------------
  |  |   47|     57|#      define netsnmp_assert(x)  do { \
  |  |   48|     57|              if ( x ) \
  |  |  ------------------
  |  |  |  Branch (48:20): [True: 57, False: 0]
  |  |  ------------------
  |  |   49|     57|                 ; \
  |  |   50|     57|              else \
  |  |   51|     57|                 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
  |  |  |  |  ------------------
  |  |  |  |  |  | 1727|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|     57|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded, False: 57]
  |  |  ------------------
  ------------------
  201|     57|    }
  202|       |
  203|     57|#if !defined(WIN32)
  204|    114|    for (cm = CMSG_FIRSTHDR(&msg); cm != NULL; cm = CMSG_NXTHDR(&msg, cm)) {
  ------------------
  |  Branch (204:15): [True: 57, False: 0]
  |  Branch (204:36): [True: 57, False: 57]
  ------------------
  205|     57|#if defined(HAVE_IP_PKTINFO)
  206|     57|        if (cm->cmsg_level == SOL_IP && cm->cmsg_type == IP_PKTINFO) {
  ------------------
  |  Branch (206:13): [True: 57, False: 0]
  |  Branch (206:41): [True: 57, False: 0]
  ------------------
  207|     57|            struct in_pktinfo* src = (struct in_pktinfo *)CMSG_DATA(cm);
  208|     57|            netsnmp_assert(dstip->sa_family == AF_INET);
  ------------------
  |  |   47|     57|#      define netsnmp_assert(x)  do { \
  |  |   48|     57|              if ( x ) \
  |  |  ------------------
  |  |  |  Branch (48:20): [True: 57, False: 0]
  |  |  ------------------
  |  |   49|     57|                 ; \
  |  |   50|     57|              else \
  |  |   51|     57|                 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
  |  |  |  |  ------------------
  |  |  |  |  |  | 1727|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|     57|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded, False: 57]
  |  |  ------------------
  ------------------
  209|     57|            ((struct sockaddr_in*)dstip)->sin_addr = src->ipi_addr;
  210|     57|            *if_index = src->ipi_ifindex;
  211|     57|            DEBUGMSGTL(("udpbase:recv",
  ------------------
  |  |   66|     57|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     57|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 57]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 57]
  |  |  ------------------
  ------------------
  212|     57|                        "got destination (local) addr %s, iface %d\n",
  213|     57|                        inet_ntoa(src->ipi_addr), *if_index));
  214|     57|        }
  215|       |#elif defined(HAVE_IP_RECVDSTADDR)
  216|       |        if (cm->cmsg_level == IPPROTO_IP && cm->cmsg_type == IP_RECVDSTADDR) {
  217|       |            struct in_addr* src = (struct in_addr *)CMSG_DATA(cm);
  218|       |            ((struct sockaddr_in*)dstip)->sin_addr = *src;
  219|       |            DEBUGMSGTL(("netsnmp_udp", "got destination (local) addr %s\n",
  220|       |                        inet_ntoa(*src)));
  221|       |        }
  222|       |#endif
  223|     57|    }
  224|       |#else /* !defined(WIN32) */
  225|       |    for (cm = WSA_CMSG_FIRSTHDR(&msg); cm; cm = WSA_CMSG_NXTHDR(&msg, cm)) {
  226|       |        if (cm->cmsg_level == IPPROTO_IP && cm->cmsg_type == IP_PKTINFO) {
  227|       |            struct in_pktinfo* src = (struct in_pktinfo *)WSA_CMSG_DATA(cm);
  228|       |            netsnmp_assert(dstip->sa_family == AF_INET);
  229|       |            ((struct sockaddr_in*)dstip)->sin_addr = src->ipi_addr;
  230|       |            *if_index = src->ipi_ifindex;
  231|       |            DEBUGMSGTL(("udpbase:recv",
  232|       |                        "got destination (local) addr %s, iface %d\n",
  233|       |                        inet_ntoa(src->ipi_addr), *if_index));
  234|       |        }
  235|       |    }
  236|       |#endif /* !defined(WIN32) */
  237|     57|    return r;
  238|     57|}
netsnmp_udpbase_recv:
  454|     57|{
  455|     57|    int             rc = -1;
  456|     57|    socklen_t       fromlen = sizeof(netsnmp_sockaddr_storage);
  457|     57|    netsnmp_indexed_addr_pair *addr_pair = NULL;
  458|     57|    struct sockaddr *from;
  459|       |
  460|     57|    if (t && NETSNMP_IS_VALID_SOCKET(t->sock)) {
  ------------------
  |  |   44|     57|#define NETSNMP_IS_VALID_SOCKET(_sock) ((_sock) != -1)
  |  |  ------------------
  |  |  |  Branch (44:40): [True: 57, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (460:9): [True: 57, False: 0]
  ------------------
  461|     57|        addr_pair = SNMP_MALLOC_TYPEDEF(netsnmp_indexed_addr_pair);
  ------------------
  |  |   73|     57|#define SNMP_MALLOC_TYPEDEF(td)  (td *) calloc(1, sizeof(td))
  ------------------
  462|     57|        if (addr_pair == NULL) {
  ------------------
  |  Branch (462:13): [True: 0, False: 57]
  ------------------
  463|      0|            *opaque = NULL;
  464|      0|            *olength = 0;
  465|      0|            return -1;
  466|      0|        } else
  467|     57|            from = &addr_pair->remote_addr.sa;
  468|       |
  469|    114|	while (rc < 0) {
  ------------------
  |  Branch (469:9): [True: 57, False: 57]
  ------------------
  470|     57|#ifdef netsnmp_udpbase_recvfrom_sendto_defined
  471|     57|            socklen_t local_addr_len = sizeof(addr_pair->local_addr);
  472|     57|            rc = netsnmp_udp_recvfrom(t->sock, buf, size, from, &fromlen,
  473|     57|                                      &addr_pair->local_addr.sa,
  474|     57|                                      &local_addr_len, &(addr_pair->if_index));
  475|       |#else
  476|       |            rc = recvfrom(t->sock, buf, size, MSG_DONTWAIT, from, &fromlen);
  477|       |#endif /* netsnmp_udpbase_recvfrom_sendto_defined */
  478|     57|	    if (rc < 0 && errno != EINTR) {
  ------------------
  |  Branch (478:10): [True: 0, False: 57]
  |  Branch (478:20): [True: 0, False: 0]
  ------------------
  479|      0|		break;
  480|      0|	    }
  481|     57|	}
  482|       |
  483|     57|        if (rc >= 0) {
  ------------------
  |  Branch (483:13): [True: 57, False: 0]
  ------------------
  484|     57|            DEBUGIF("netsnmp_udp") {
  ------------------
  |  |  145|     57|#define DEBUGIF(x)         if (_DBG_IF_ && debug_is_token_registered(x) == SNMPERR_SUCCESS)
  |  |  ------------------
  |  |  |  |  144|    114|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 57]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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]
  |  |  ------------------
  ------------------
  485|      0|                char *str = netsnmp_udp_fmtaddr(
  486|      0|                    NULL, addr_pair, sizeof(netsnmp_indexed_addr_pair));
  487|      0|                DEBUGMSGTL(("netsnmp_udp",
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
  488|      0|                            "recvfrom fd %" NETSNMP_FMT_SKT " got %d bytes (from %s)\n",
  489|      0|                            t->sock, rc, str));
  490|      0|                free(str);
  491|      0|            }
  492|     57|        } else {
  493|      0|            DEBUGMSGTL(("netsnmp_udp", "recvfrom fd %" NETSNMP_FMT_SKT " err %d (\"%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]
  |  |  ------------------
  ------------------
  494|      0|                        t->sock, errno, strerror(errno)));
  495|      0|        }
  496|     57|        *opaque = (void *)addr_pair;
  497|     57|        *olength = sizeof(netsnmp_indexed_addr_pair);
  498|     57|    }
  499|     57|    return rc;
  500|     57|}

netsnmp_udp_recvfrom:
  169|     57|{
  170|       |    /** udpipv4 just calls udpbase. should we skip directly to there? */
  171|     57|    return netsnmp_udpipv4_recvfrom(sock, buf, len, from, fromlen, dstip, dstlen,
  172|     57|                                    if_index);
  173|     57|}
netsnmp_udp_create_tspec:
  701|     58|{
  702|     58|    netsnmp_transport *t = netsnmp_udpipv4base_tspec_transport(tspec);
  703|     58|    if (NULL != t) {
  ------------------
  |  Branch (703:9): [True: 58, False: 0]
  ------------------
  704|     58|        netsnmp_udp_transport_base(t);
  705|     58|    }
  706|     58|    return t;
  707|       |
  708|     58|}
netsnmp_udp_ctor:
  724|     58|{
  725|     58|    udpDomain.name = netsnmpUDPDomain;
  726|     58|    udpDomain.name_length = netsnmpUDPDomain_len;
  727|     58|    udpDomain.prefix = calloc(2, sizeof(char *));
  728|     58|    if (!udpDomain.prefix) {
  ------------------
  |  Branch (728:9): [True: 0, False: 58]
  ------------------
  729|      0|        snmp_log(LOG_ERR, "calloc() failed - out of memory\n");
  730|      0|        return;
  731|      0|    }
  732|     58|    udpDomain.prefix[0] = "udp";
  733|       |
  734|     58|    udpDomain.f_create_from_tstring_new = netsnmp_udp_create_tstring;
  735|     58|    udpDomain.f_create_from_tspec       = netsnmp_udp_create_tspec;
  736|     58|    udpDomain.f_create_from_ostring     = netsnmp_udp_create_ostring;
  737|       |
  738|     58|    netsnmp_tdomain_register(&udpDomain);
  739|     58|}
snmpUDPDomain.c:netsnmp_udp_transport_base:
  190|     58|{
  191|     58|    if (NULL == t) {
  ------------------
  |  Branch (191:9): [True: 0, False: 58]
  ------------------
  192|      0|        return NULL;
  193|      0|    }
  194|       |
  195|       |    /*
  196|       |     * Set Domain
  197|       |     */
  198|       |
  199|     58|    t->domain = netsnmpUDPDomain;
  200|     58|    t->domain_length = netsnmpUDPDomain_len;
  201|       |
  202|       |    /*
  203|       |     * 16-bit length field, 8 byte UDP header, 20 byte IPv4 header  
  204|       |     */
  205|       |
  206|     58|    t->msgMaxSize = 0xffff - 8 - 20;
  207|     58|    t->f_recv     = netsnmp_udpbase_recv;
  208|     58|    t->f_send     = netsnmp_udpbase_send;
  209|     58|    t->f_close    = netsnmp_socketbase_close;
  210|     58|    t->f_accept   = NULL;
  211|     58|    t->f_setup_session = netsnmp_ipbase_session_init;
  212|     58|    t->f_fmtaddr  = netsnmp_udp_fmtaddr;
  213|     58|    t->f_get_taddr = netsnmp_ipv4_get_taddr;
  214|       |
  215|     58|    return t;
  216|     58|}

netsnmp_udpipv4_recvfrom:
   64|     57|{
   65|     57|    return netsnmp_udpbase_recvfrom(sock, buf, len, from, fromlen, dstip, dstlen,
   66|     57|                                    if_index);
   67|     57|}
netsnmp_udpipv4base_transport_init:
   79|     58|{
   80|     58|    netsnmp_transport *t;
   81|     58|    const struct sockaddr_in *addr = &ep->a.sin;
   82|     58|    u_char *addr_ptr;
   83|       |
   84|     58|    if (addr == NULL || addr->sin_family != AF_INET) {
  ------------------
  |  Branch (84:9): [True: 0, False: 58]
  |  Branch (84:25): [True: 0, False: 58]
  ------------------
   85|      0|        return NULL;
   86|      0|    }
   87|       |
   88|     58|    t = netsnmp_transport_alloc();
   89|     58|    if (NULL == t)
  ------------------
  |  Branch (89:9): [True: 0, False: 58]
  ------------------
   90|      0|        return NULL;
   91|       |
   92|     58|    addr_ptr = netsnmp_memdup(addr, sizeof(*addr));
   93|     58|    if (NULL == addr_ptr) {
  ------------------
  |  Branch (93:9): [True: 0, False: 58]
  ------------------
   94|      0|        free(t);
   95|      0|        return NULL;
   96|      0|    }
   97|       |
   98|     58|    if (local) {
  ------------------
  |  Branch (98:9): [True: 58, False: 0]
  ------------------
   99|       |        /** This is a server session. */
  100|     58|        t->local_length = sizeof(*addr);
  101|     58|        t->local = addr_ptr;
  102|     58|    } else {
  103|       |        /** This is a client session. */
  104|      0|        t->remote = addr_ptr;
  105|      0|        t->remote_length = sizeof(*addr);
  106|      0|    }
  107|       |
  108|     58|    DEBUGIF("netsnmp_udpbase") {
  ------------------
  |  |  145|     58|#define DEBUGIF(x)         if (_DBG_IF_ && debug_is_token_registered(x) == SNMPERR_SUCCESS)
  |  |  ------------------
  |  |  |  |  144|    116|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 58]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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]
  |  |  ------------------
  ------------------
  109|      0|        netsnmp_indexed_addr_pair addr_pair;
  110|      0|        char                      *str;
  111|      0|        memset(&addr_pair, 0, sizeof(netsnmp_indexed_addr_pair));
  112|      0|        memcpy(&(addr_pair.remote_addr), addr, sizeof(*addr));
  113|      0|        str = netsnmp_udp_fmtaddr(NULL, (void *)&addr_pair,
  114|      0|                                  sizeof(netsnmp_indexed_addr_pair));
  115|      0|        DEBUGMSGTL(("netsnmp_udpbase", "open %s %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 (164:52): [True: 0, False: 0]
  |  |  |  |  |  Branch (164:64): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
  116|      0|                    local ? "local" : "remote", str));
  117|      0|        free(str);
  118|      0|    }
  119|       |
  120|     58|    if (!local) {
  ------------------
  |  Branch (120:9): [True: 0, False: 58]
  ------------------
  121|      0|        netsnmp_indexed_addr_pair *addr_pair;
  122|       |
  123|       |        /*
  124|       |         * allocate space to save the (remote) address in the
  125|       |         * transport-specific data pointer for later use by netsnmp_udp_send.
  126|       |         */
  127|      0|        t->data = calloc(1, sizeof(netsnmp_indexed_addr_pair));
  128|      0|        if (NULL == t->data) {
  ------------------
  |  Branch (128:13): [True: 0, False: 0]
  ------------------
  129|      0|            netsnmp_transport_free(t);
  130|      0|            return NULL;
  131|      0|        }
  132|      0|        t->data_length = sizeof(netsnmp_indexed_addr_pair);
  133|       |
  134|      0|        addr_pair = (netsnmp_indexed_addr_pair *)t->data;
  135|      0|        memcpy(&addr_pair->remote_addr, addr, sizeof(*addr));
  136|      0|    }
  137|     58|    return t;
  138|     58|}
netsnmp_udpipv4base_transport_socket:
  142|     58|{
  143|     58|    int local = flags & NETSNMP_TSPEC_LOCAL;
  ------------------
  |  |  117|     58|#define NETSNMP_TSPEC_LOCAL                     0x01 /* 1=server, 0=client */
  ------------------
  144|     58|    NETSNMP_SOCKET sock;
  ------------------
  |  |   42|     58|#define NETSNMP_SOCKET         int
  ------------------
  145|       |
  146|     58|    sock = socket(PF_INET, SOCK_DGRAM, 0);
  147|     58|    DEBUGMSGTL(("UDPBase", "opened socket %" NETSNMP_FMT_SKT " as local=%d\n",
  ------------------
  |  |   66|     58|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     58|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 58]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 58]
  |  |  ------------------
  ------------------
  148|     58|                sock, local));
  149|     58|    if (!NETSNMP_IS_VALID_SOCKET(sock))
  ------------------
  |  |   44|     58|#define NETSNMP_IS_VALID_SOCKET(_sock) ((_sock) != -1)
  ------------------
  |  Branch (149:9): [True: 0, False: 58]
  ------------------
  150|      0|        return NETSNMP_INVALID_SOCKET;
  ------------------
  |  |   43|      0|#define NETSNMP_INVALID_SOCKET -1
  ------------------
  151|       |
  152|     58|    _netsnmp_udp_sockopt_set(sock, local);
  153|       |
  154|     58|    return sock;
  155|     58|}
netsnmp_udpipv4base_transport_bind:
  160|     58|{
  161|     58|    const struct sockaddr_in *addr = &ep->a.sin;
  162|     58|#if defined(HAVE_IP_PKTINFO) || defined(HAVE_IP_RECVDSTADDR) || defined(WIN32)
  163|     58|    int                sockopt = 1;
  164|     58|#endif
  165|     58|    int                rc;
  166|       |
  167|     58|    if (flags & NETSNMP_TSPEC_LOCAL) {
  ------------------
  |  |  117|     58|#define NETSNMP_TSPEC_LOCAL                     0x01 /* 1=server, 0=client */
  ------------------
  |  Branch (167:9): [True: 58, False: 0]
  ------------------
  168|       |#ifdef NETSNMP_NO_LISTEN_SUPPORT
  169|       |        return NULL;
  170|       |#endif /* NETSNMP_NO_LISTEN_SUPPORT */
  171|     58|#if defined(HAVE_IP_PKTINFO) && !defined(WIN32)
  172|     58|        if (setsockopt(t->sock, SOL_IP, IP_PKTINFO, &sockopt, sizeof sockopt) == -1) {
  ------------------
  |  Branch (172:13): [True: 0, False: 58]
  ------------------
  173|      0|            DEBUGMSGTL(("netsnmp_udpbase", "couldn't set IP_PKTINFO: %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]
  |  |  ------------------
  ------------------
  174|      0|                        strerror(errno)));
  175|      0|            return 1;
  176|      0|        }
  177|     58|        DEBUGMSGTL(("netsnmp_udpbase", "set IP_PKTINFO\n"));
  ------------------
  |  |   66|     58|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     58|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 58]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 58]
  |  |  ------------------
  ------------------
  178|       |#elif defined(HAVE_IP_RECVDSTADDR)
  179|       |        if (setsockopt(t->sock, IPPROTO_IP, IP_RECVDSTADDR, &sockopt, sizeof sockopt) == -1) {
  180|       |            DEBUGMSGTL(("netsnmp_udp", "couldn't set IP_RECVDSTADDR: %s\n",
  181|       |                        strerror(errno)));
  182|       |            return 1;
  183|       |        }
  184|       |        DEBUGMSGTL(("netsnmp_udp", "set IP_RECVDSTADDR\n"));
  185|       |#elif defined(WIN32)
  186|       |        if (setsockopt(t->sock, IPPROTO_IP, IP_PKTINFO, (void *)&sockopt,
  187|       |                       sizeof(sockopt)) == -1) {
  188|       |            DEBUGMSGTL(("netsnmp_udpbase", "couldn't set IP_PKTINFO: %d\n",
  189|       |                        WSAGetLastError()));
  190|       |        } else {
  191|       |            DEBUGMSGTL(("netsnmp_udpbase", "set IP_PKTINFO\n"));
  192|       |        }
  193|       |#endif
  194|     58|    }
  195|       |
  196|     58|    DEBUGIF("netsnmp_udpbase") {
  ------------------
  |  |  145|     58|#define DEBUGIF(x)         if (_DBG_IF_ && debug_is_token_registered(x) == SNMPERR_SUCCESS)
  |  |  ------------------
  |  |  |  |  144|    116|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 58]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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]
  |  |  ------------------
  ------------------
  197|      0|        netsnmp_indexed_addr_pair addr_pair;
  198|      0|        char *str;
  199|      0|        memset(&addr_pair, 0x0, sizeof(addr_pair));
  200|      0|        memcpy(&(addr_pair.local_addr), addr, sizeof(*addr));
  201|      0|        str = netsnmp_udp_fmtaddr(NULL, (void *)&addr_pair,
  202|      0|                                  sizeof(netsnmp_indexed_addr_pair));
  203|      0|        DEBUGMSGTL(("netsnmp_udpbase",
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
  204|      0|                    "binding socket: %" NETSNMP_FMT_SKT " to %s\n",
  205|      0|                    t->sock, str));
  206|      0|        free(str);
  207|      0|    }
  208|     58|    if (flags & NETSNMP_TSPEC_PREBOUND) {
  ------------------
  |  |  118|     58|#define NETSNMP_TSPEC_PREBOUND                  0x02 /* 1=bound by systemd, 0=needs bind in the library */
  ------------------
  |  Branch (208:9): [True: 0, False: 58]
  ------------------
  209|      0|        DEBUGMSGTL(("netsnmp_udpbase",
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
  210|      0|                    "socket %" NETSNMP_FMT_SKT " is prebound, nothing to do\n",
  211|      0|                    t->sock));
  212|      0|        return 0;
  213|      0|    }
  214|     58|    rc = netsnmp_bindtodevice(t->sock, ep->iface);
  215|     58|    if (rc != 0) {
  ------------------
  |  Branch (215:9): [True: 0, False: 58]
  ------------------
  216|      0|        DEBUGMSGTL(("netsnmp_udpbase", "failed to bind to iface %s: %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]
  |  |  ------------------
  ------------------
  217|      0|                    ep->iface, strerror(errno)));
  218|      0|        goto err;
  219|      0|    }
  220|     58|    rc = bind(t->sock, (const struct sockaddr *)addr, sizeof(*addr));
  221|     58|    if ( rc != 0 ) {
  ------------------
  |  Branch (221:10): [True: 0, False: 58]
  ------------------
  222|      0|        DEBUGMSGTL(("netsnmp_udpbase",
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
  223|      0|                    "failed to bind for clientaddr: %d %s\n",
  224|      0|                    errno, strerror(errno)));
  225|      0|        goto err;
  226|      0|    }
  227|       |
  228|     58|    return 0;
  229|       |
  230|      0|err:
  231|      0|    netsnmp_socketbase_close(t);
  232|      0|    return 1;
  233|     58|}
netsnmp_udpipv4base_transport_with_source:
  270|     58|{
  271|     58|    netsnmp_transport         *t = NULL;
  272|     58|    const struct netsnmp_ep   *bind_addr;
  273|     58|    int                        rc, flags = 0;
  274|       |
  275|     58|    t = netsnmp_udpipv4base_transport_init(ep, local);
  276|     58|    if (NULL == t)
  ------------------
  |  Branch (276:9): [True: 0, False: 58]
  ------------------
  277|      0|         return NULL;
  278|       |
  279|     58|    if (local) {
  ------------------
  |  Branch (279:9): [True: 58, False: 0]
  ------------------
  280|     58|        bind_addr = ep;
  281|     58|        flags |= NETSNMP_TSPEC_LOCAL;
  ------------------
  |  |  117|     58|#define NETSNMP_TSPEC_LOCAL                     0x01 /* 1=server, 0=client */
  ------------------
  282|       |
  283|     58|#ifndef NETSNMP_NO_SYSTEMD
  284|       |        /*
  285|       |         * Maybe the socket was already provided by systemd...
  286|       |         */
  287|     58|        t->sock = netsnmp_sd_find_inet_socket(PF_INET, SOCK_DGRAM, -1,
  288|     58|                                              ntohs(ep->a.sin.sin_port));
  289|     58|        if (t->sock >= 0)
  ------------------
  |  Branch (289:13): [True: 0, False: 58]
  ------------------
  290|      0|            flags |= NETSNMP_TSPEC_PREBOUND;
  ------------------
  |  |  118|      0|#define NETSNMP_TSPEC_PREBOUND                  0x02 /* 1=bound by systemd, 0=needs bind in the library */
  ------------------
  291|     58|#endif
  292|     58|    }
  293|      0|    else
  294|      0|        bind_addr = src_addr;
  295|       |
  296|     58|    if (!NETSNMP_IS_VALID_SOCKET(t->sock))
  ------------------
  |  |   44|     58|#define NETSNMP_IS_VALID_SOCKET(_sock) ((_sock) != -1)
  ------------------
  |  Branch (296:9): [True: 58, False: 0]
  ------------------
  297|     58|        t->sock = netsnmp_udpipv4base_transport_socket(flags);
  298|     58|    if (!NETSNMP_IS_VALID_SOCKET(t->sock)) {
  ------------------
  |  |   44|     58|#define NETSNMP_IS_VALID_SOCKET(_sock) ((_sock) != -1)
  ------------------
  |  Branch (298:9): [True: 0, False: 58]
  ------------------
  299|      0|        netsnmp_transport_free(t);
  300|      0|        return NULL;
  301|      0|    }
  302|       |
  303|       |    /*
  304|       |     * If we've been given an address to bind to, then bind to it.
  305|       |     * Otherwise the OS will use "something sensible".
  306|       |     */
  307|     58|    if (NULL == bind_addr)
  ------------------
  |  Branch (307:9): [True: 0, False: 58]
  ------------------
  308|      0|        return t;
  309|       |
  310|       |    /* for Linux VRF Traps we try to bind the iface if clientaddr is not set */
  311|     58|    if (ep && ep->iface[0]) {
  ------------------
  |  Branch (311:9): [True: 58, False: 0]
  |  Branch (311:15): [True: 0, False: 58]
  ------------------
  312|      0|        rc = netsnmp_bindtodevice(t->sock, ep->iface);
  313|      0|        if (rc)
  ------------------
  |  Branch (313:13): [True: 0, False: 0]
  ------------------
  314|      0|            DEBUGMSGTL(("netsnmp_udpbase",
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
  315|      0|                        "VRF: Could not bind socket %" NETSNMP_FMT_SKT " to %s\n",
  316|      0|                        t->sock, ep->iface));
  317|      0|        else
  318|      0|            DEBUGMSGTL(("netsnmp_udpbase",
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
  319|      0|                        "VRF: Bound socket %" NETSNMP_FMT_SKT " to %s\n",
  320|      0|                        t->sock, ep->iface));
  321|      0|    }
  322|       |
  323|     58|    rc = netsnmp_udpipv4base_transport_bind(t, bind_addr, flags);
  324|     58|    if (rc) {
  ------------------
  |  Branch (324:9): [True: 0, False: 58]
  ------------------
  325|      0|        netsnmp_transport_free(t);
  326|      0|        t = NULL;
  327|      0|    }
  328|     58|    else if (!local)
  ------------------
  |  Branch (328:14): [True: 0, False: 58]
  ------------------
  329|      0|        netsnmp_udpipv4base_transport_get_bound_addr(t);
  330|       |
  331|     58|    return t;
  332|     58|}
netsnmp_udpipv4base_tspec_transport:
  336|     58|{
  337|     58|    struct netsnmp_ep addr;
  338|     58|    int local;
  339|       |
  340|     58|    if (NULL == tspec)
  ------------------
  |  Branch (340:9): [True: 0, False: 58]
  ------------------
  341|      0|        return NULL;
  342|       |
  343|     58|    local = tspec->flags & NETSNMP_TSPEC_LOCAL;
  ------------------
  |  |  117|     58|#define NETSNMP_TSPEC_LOCAL                     0x01 /* 1=server, 0=client */
  ------------------
  344|       |
  345|       |    /** get address from target */
  346|     58|    if (!netsnmp_sockaddr_in3(&addr, tspec->target, tspec->default_target))
  ------------------
  |  Branch (346:9): [True: 0, False: 58]
  ------------------
  347|      0|        return NULL;
  348|       |
  349|     58|    if (NULL != tspec->source) {
  ------------------
  |  Branch (349:9): [True: 0, False: 58]
  ------------------
  350|      0|        struct netsnmp_ep src_addr;
  351|       |
  352|       |        /** get sockaddr from source */
  353|      0|        if (!netsnmp_sockaddr_in3(&src_addr, tspec->source, ":0"))
  ------------------
  |  Branch (353:13): [True: 0, False: 0]
  ------------------
  354|      0|            return NULL;
  355|      0|        return netsnmp_udpipv4base_transport_with_source(&addr, local,
  356|      0|                                                         &src_addr);
  357|      0|    }
  358|       |
  359|       |    /** no source and default client address ok */
  360|     58|    return netsnmp_udpipv4base_transport(&addr, local);
  361|     58|}
netsnmp_udpipv4base_transport:
  365|     58|{
  366|     58|    struct netsnmp_ep client_ep;
  367|     58|    const char *client_addr;
  368|     58|    int uses_port;
  369|       |
  370|     58|    memset(&client_ep, 0, sizeof(client_ep));
  371|     58|    client_ep.a.sin.sin_family = AF_INET;
  372|       |
  373|     58|    if (local)
  ------------------
  |  Branch (373:9): [True: 58, False: 0]
  ------------------
  374|     58|        goto out;
  375|       |
  376|      0|    client_addr = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      0|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  377|      0|                                        NETSNMP_DS_LIB_CLIENT_ADDR);
  ------------------
  |  |  165|      0|#define NETSNMP_DS_LIB_CLIENT_ADDR       14
  ------------------
  378|      0|    if (!client_addr)
  ------------------
  |  Branch (378:9): [True: 0, False: 0]
  ------------------
  379|      0|        goto out;
  380|       |
  381|      0|    if (netsnmp_sockaddr_in3(&client_ep, client_addr, ":0") < 0) {
  ------------------
  |  Branch (381:9): [True: 0, False: 0]
  ------------------
  382|      0|        snmp_log(LOG_ERR, "Parsing clientaddr %s failed\n", client_addr);
  383|      0|        goto out;
  384|      0|    }
  385|       |
  386|      0|    uses_port = netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      0|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  387|      0|                                       NETSNMP_DS_LIB_CLIENT_ADDR_USES_PORT);
  ------------------
  |  |  102|      0|#define NETSNMP_DS_LIB_CLIENT_ADDR_USES_PORT 42 /* NETSNMP_DS_LIB_CLIENT_ADDR includes address and also port */
  ------------------
  388|      0|    if (!uses_port)
  ------------------
  |  Branch (388:9): [True: 0, False: 0]
  ------------------
  389|      0|        client_ep.a.sin.sin_port = 0;
  390|       |
  391|     58|out:
  392|     58|    return netsnmp_udpipv4base_transport_with_source(ep, local, &client_ep);
  393|      0|}

netsnmp_udpipv6_ctor:
 1248|     58|{
 1249|     58|    udp6Domain.name = netsnmp_UDPIPv6Domain;
 1250|     58|    udp6Domain.name_length = OID_LENGTH(netsnmp_UDPIPv6Domain);
  ------------------
  |  |   64|     58|    (sizeof(x) / sizeof((x)[0]) +                                       \
  |  |   65|     58|     sizeof(int[-__builtin_types_compatible_p(typeof(x), typeof(&(x)[0]))]))
  ------------------
 1251|     58|    udp6Domain.f_create_from_tstring_new = netsnmp_udp6_create_tstring;
 1252|     58|    udp6Domain.f_create_from_tspec       = netsnmp_udp6_create_tspec;
 1253|     58|    udp6Domain.f_create_from_ostring     = netsnmp_udp6_create_ostring;
 1254|     58|    udp6Domain.prefix = calloc(5, sizeof(char *));
 1255|     58|    if (!udp6Domain.prefix) {
  ------------------
  |  Branch (1255:9): [True: 0, False: 58]
  ------------------
 1256|      0|        snmp_log(LOG_ERR, "calloc() failed - out of memory\n");
 1257|      0|        return;
 1258|      0|    }
 1259|     58|    udp6Domain.prefix[0] = "udp6";
 1260|     58|    udp6Domain.prefix[1] = "ipv6";
 1261|     58|    udp6Domain.prefix[2] = "udpv6";
 1262|     58|    udp6Domain.prefix[3] = "udpipv6";
 1263|       |
 1264|     58|    netsnmp_tdomain_register(&udp6Domain);
 1265|     58|}

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

netsnmp_unix_ctor:
  536|     58|{
  537|     58|    unixDomain.name = netsnmp_UnixDomain;
  538|     58|    unixDomain.name_length = OID_LENGTH(netsnmp_UnixDomain);
  ------------------
  |  |   64|     58|    (sizeof(x) / sizeof((x)[0]) +                                       \
  |  |   65|     58|     sizeof(int[-__builtin_types_compatible_p(typeof(x), typeof(&(x)[0]))]))
  ------------------
  539|     58|    unixDomain.prefix = calloc(2, sizeof(char *));
  540|     58|    if (!unixDomain.prefix) {
  ------------------
  |  Branch (540:9): [True: 0, False: 58]
  ------------------
  541|      0|        snmp_log(LOG_ERR, "calloc() failed - out of memory\n");
  542|      0|        return;
  543|      0|    }
  544|     58|    unixDomain.prefix[0] = "unix";
  545|       |
  546|     58|    unixDomain.f_create_from_tstring_new = netsnmp_unix_create_tstring;
  547|     58|    unixDomain.f_create_from_ostring     = netsnmp_unix_create_ostring;
  548|       |
  549|     58|    netsnmp_tdomain_register(&unixDomain);
  550|     58|}

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

LLVMFuzzerInitialize:
   56|      2|int LLVMFuzzerInitialize(int *argc, char ***argv) {
   57|      2|    char path[PATH_MAX];
   58|      2|    char mibdirs[PATH_MAX];
   59|      2|    char *dir;
   60|       |
   61|      2|    if (getenv("NETSNMP_DEBUGGING") != NULL) {
  ------------------
  |  Branch (61:9): [True: 0, False: 2]
  ------------------
   62|      0|        snmp_enable_stderrlog();
   63|      0|        snmp_set_do_debugging(1);
   64|      0|        debug_register_tokens("sess_process_packet");
   65|      0|    }
   66|       |
   67|      2|    strlcpy(path, (*argv)[0], sizeof(path));
   68|      2|    dir = dirname(path);
   69|      2|    snprintf(mibdirs, sizeof(mibdirs), "%s/../../mibs", dir);
   70|      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
  ------------------
   71|      2|                          mibdirs);
   72|      2|    return 0;
   73|      2|}
LLVMFuzzerTestOneInput:
   75|     59|int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
   76|     59|    netsnmp_transport *transport = NULL;
   77|     59|    netsnmp_session *session = NULL;
   78|     59|    const unsigned short pkt_len = size;
   79|     59|    const void *const pkt = data;
   80|     59|    NETSNMP_SOCKET skt = NETSNMP_INVALID_SOCKET;
  ------------------
  |  |   42|     59|#define NETSNMP_SOCKET         int
  ------------------
                  NETSNMP_SOCKET skt = NETSNMP_INVALID_SOCKET;
  ------------------
  |  |   43|     59|#define NETSNMP_INVALID_SOCKET -1
  ------------------
   81|     59|    int ret = 1;
   82|       |
   83|     59|    if (pkt_len == 0)
  ------------------
  |  Branch (83:9): [True: 1, False: 58]
  ------------------
   84|      1|        goto cleanup;
   85|       |
   86|     58|    netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
   87|     58|                           NETSNMP_DS_LIB_DONT_PERSIST_STATE, 1);
  ------------------
  |  |   92|     58|#define NETSNMP_DS_LIB_DONT_PERSIST_STATE  32	/* don't load config and don't load/save persistent file */
  ------------------
   88|     58|    netsnmp_ds_set_string(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_PERSISTENT_DIR,
  ------------------
  |  |   48|     58|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                  netsnmp_ds_set_string(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_PERSISTENT_DIR,
  ------------------
  |  |  159|     58|#define NETSNMP_DS_LIB_PERSISTENT_DIR    8
  ------------------
   89|     58|                          "/tmp");
   90|       |
   91|     58|    init_snmp("snmptrapd");
   92|       |
   93|     58|    transport = netsnmp_transport_open_server("trap_fuzzer", "127.0.0.1:7365");
   94|     58|    if (!transport) {
  ------------------
  |  Branch (94:9): [True: 0, False: 58]
  ------------------
   95|      0|        fprintf(stderr, "Error: failed to open Net-SNMP transport.\n");
   96|      0|        goto cleanup;
   97|      0|    }
   98|     58|    session = add_session(transport);
   99|     58|    if (!session) {
  ------------------
  |  Branch (99:9): [True: 0, False: 58]
  ------------------
  100|      0|        fprintf(stderr, "Error: failed to add Net-SNMP session.\n");
  101|      0|        goto cleanup;
  102|      0|    }
  103|       |
  104|     58|    skt = socket(AF_INET, SOCK_DGRAM, 0);
  105|     58|    if (!NETSNMP_IS_VALID_SOCKET(skt)) {
  ------------------
  |  |   44|     58|#define NETSNMP_IS_VALID_SOCKET(_sock) ((_sock) != -1)
  ------------------
  |  Branch (105:9): [True: 0, False: 58]
  ------------------
  106|      0|        perror("socket()");
  107|      0|        goto shutdown;
  108|      0|    }
  109|     58|    struct sockaddr_in addr = {
  110|     58|        .sin_family = AF_INET,
  111|     58|        .sin_port = htons(7365),
  112|     58|        .sin_addr = { htonl(INADDR_LOOPBACK) }
  113|     58|    };
  114|     58|    if (connect(skt, &addr, sizeof(addr)) < 0) {
  ------------------
  |  Branch (114:9): [True: 0, False: 58]
  ------------------
  115|      0|        perror("connect()");
  116|      0|        goto shutdown;
  117|      0|    }
  118|     58|    if (send(skt, pkt, pkt_len, 0) < 0) {
  ------------------
  |  Branch (118:9): [True: 1, False: 57]
  ------------------
  119|      1|        perror("send()");
  120|      1|        goto shutdown;
  121|      1|    }
  122|     57|    {
  123|     57|        fd_set readfds,writefds,exceptfds;
  124|     57|        int numfds = 0, block = 0;
  125|     57|        struct timeval timeout;
  126|       |
  127|     57|        FD_ZERO(&readfds);
  ------------------
  |  Branch (127:9): [Folded, False: 57]
  ------------------
  128|     57|        FD_ZERO(&writefds);
  ------------------
  |  Branch (128:9): [Folded, False: 57]
  ------------------
  129|     57|        FD_ZERO(&exceptfds);
  ------------------
  |  Branch (129:9): [Folded, False: 57]
  ------------------
  130|     57|        timerclear(&timeout);
  131|     57|        timeout.tv_sec = 5;
  132|     57|        snmp_select_info(&numfds, &readfds, &timeout, &block);
  133|     57|        if (select(numfds, &readfds, &writefds, &exceptfds, &timeout) > 0)
  ------------------
  |  Branch (133:13): [True: 57, False: 0]
  ------------------
  134|     57|            snmp_read(&readfds);
  135|     57|    }
  136|     57|    ret = 0;
  137|       |
  138|     58|shutdown:
  139|     58|    snmp_shutdown("snmptrapd");
  140|       |
  141|     59|cleanup:
  142|     59|    if (skt >= 0)
  ------------------
  |  Branch (142:9): [True: 58, False: 1]
  ------------------
  143|     58|        close(skt);
  144|     59|    if (session)
  ------------------
  |  Branch (144:9): [True: 58, False: 1]
  ------------------
  145|     58|        snmp_close(session);
  146|       |
  147|     59|    return ret;
  148|     58|}
snmp_parse_trap2_fuzzer.c:add_session:
   39|     58|{
   40|     58|    netsnmp_session session;
   41|       |
   42|     58|    snmp_sess_init(&session);
   43|     58|    session.peername = SNMP_DEFAULT_PEERNAME;
  ------------------
  |  |   87|     58|#define SNMP_DEFAULT_PEERNAME	    NULL
  ------------------
   44|     58|    session.version = SNMP_DEFAULT_VERSION;
  ------------------
  |  |   90|     58|#define SNMP_DEFAULT_VERSION	    -1
  ------------------
   45|     58|    session.community_len = SNMP_DEFAULT_COMMUNITY_LEN;
  ------------------
  |  |   78|     58|#define SNMP_DEFAULT_COMMUNITY_LEN  0   /* to get a default community name */
  ------------------
   46|     58|    session.retries = SNMP_DEFAULT_RETRIES;
  ------------------
  |  |   79|     58|#define SNMP_DEFAULT_RETRIES	    -1
  ------------------
   47|     58|    session.timeout = SNMP_DEFAULT_TIMEOUT;
  ------------------
  |  |   80|     58|#define SNMP_DEFAULT_TIMEOUT	    -1
  ------------------
   48|     58|    session.callback = snmp_input;
   49|     58|    session.callback_magic = t;
   50|     58|    session.authenticator = NULL;
   51|     58|    session.isAuthoritative = SNMP_SESS_UNKNOWNAUTH;
  ------------------
  |  |  126|     58|#define SNMP_SESS_UNKNOWNAUTH      2    /* sometimes (like NRs) */
  ------------------
   52|       |
   53|     58|    return snmp_add(&session, t, NULL, NULL);
   54|     58|}

