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

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

_netsnmp_release_trustcerts:
  175|    171|{
  176|    171|    if (NULL != _trusted_certs) {
  ------------------
  |  Branch (176:9): [True: 57, False: 114]
  ------------------
  177|     57|        CONTAINER_FREE_ALL(_trusted_certs, NULL);
  178|     57|        CONTAINER_FREE(_trusted_certs);
  179|       |        _trusted_certs = NULL;
  180|     57|    }
  181|    171|}
_setup_trusted_certs:
  185|     57|{
  186|     57|    _trusted_certs = netsnmp_container_find("trusted_certs:fifo");
  187|     57|    if (NULL == _trusted_certs) {
  ------------------
  |  Branch (187:9): [True: 0, False: 57]
  ------------------
  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|     57|    _trusted_certs->container_name = strdup("trusted certificates");
  193|     57|    _trusted_certs->compare = netsnmp_str_compare;
  194|     57|}
netsnmp_certs_init:
  209|     57|{
  210|     57|    const char *trustCert_help = TRUSTCERT_CONFIG_TOKEN
  ------------------
  |  |  140|     57|#define TRUSTCERT_CONFIG_TOKEN "trustCert"
  ------------------
  211|     57|        " FINGERPRINT|FILENAME";
  212|       |
  213|     57|    register_config_handler("snmp", TRUSTCERT_CONFIG_TOKEN,
  ------------------
  |  |  140|     57|#define TRUSTCERT_CONFIG_TOKEN "trustCert"
  ------------------
  214|     57|                            _parse_trustcert, _netsnmp_release_trustcerts,
  215|     57|                            trustCert_help);
  216|     57|    _setup_containers();
  217|       |
  218|       |    /** add certificate type mapping */
  219|     57|    se_add_pair_to_slist("cert_types", strdup("pem"), NS_CERT_TYPE_PEM);
  220|     57|    se_add_pair_to_slist("cert_types", strdup("crt"), NS_CERT_TYPE_DER);
  221|     57|    se_add_pair_to_slist("cert_types", strdup("cer"), NS_CERT_TYPE_DER);
  222|     57|    se_add_pair_to_slist("cert_types", strdup("cert"), NS_CERT_TYPE_DER);
  223|     57|    se_add_pair_to_slist("cert_types", strdup("der"), NS_CERT_TYPE_DER);
  224|     57|    se_add_pair_to_slist("cert_types", strdup("key"), NS_CERT_TYPE_KEY);
  225|     57|    se_add_pair_to_slist("cert_types", strdup("private"), NS_CERT_TYPE_KEY);
  226|       |
  227|       |    /** hash algs */
  228|     57|    se_add_pair_to_slist("cert_hash_alg", strdup("sha1"), NS_HASH_SHA1);
  ------------------
  |  |   82|     57|#define NS_HASH_SHA1        2
  ------------------
  229|     57|    se_add_pair_to_slist("cert_hash_alg", strdup("md5"), NS_HASH_MD5);
  ------------------
  |  |   81|     57|#define NS_HASH_MD5         1
  ------------------
  230|     57|    se_add_pair_to_slist("cert_hash_alg", strdup("sha224"), NS_HASH_SHA224);
  ------------------
  |  |   83|     57|#define NS_HASH_SHA224      3
  ------------------
  231|     57|    se_add_pair_to_slist("cert_hash_alg", strdup("sha256"), NS_HASH_SHA256);
  ------------------
  |  |   84|     57|#define NS_HASH_SHA256      4
  ------------------
  232|     57|    se_add_pair_to_slist("cert_hash_alg", strdup("sha384"), NS_HASH_SHA384);
  ------------------
  |  |   85|     57|#define NS_HASH_SHA384      5
  ------------------
  233|     57|    se_add_pair_to_slist("cert_hash_alg", strdup("sha512"), NS_HASH_SHA512);
  ------------------
  |  |   86|     57|#define NS_HASH_SHA512      6
  ------------------
  234|       |
  235|       |    /** map types */
  236|     57|    se_add_pair_to_slist("cert_map_type", strdup("cn"),
  237|     57|                         TSNM_tlstmCertCommonName);
  ------------------
  |  |  126|     57|#define TSNM_tlstmCertCommonName                6
  ------------------
  238|     57|    se_add_pair_to_slist("cert_map_type", strdup("ip"),
  239|     57|                         TSNM_tlstmCertSANIpAddress);
  ------------------
  |  |  124|     57|#define TSNM_tlstmCertSANIpAddress              4
  ------------------
  240|     57|    se_add_pair_to_slist("cert_map_type", strdup("rfc822"),
  241|     57|                         TSNM_tlstmCertSANRFC822Name);
  ------------------
  |  |  122|     57|#define TSNM_tlstmCertSANRFC822Name             2
  ------------------
  242|     57|    se_add_pair_to_slist("cert_map_type", strdup("dns"),
  243|     57|                         TSNM_tlstmCertSANDNSName);
  ------------------
  |  |  123|     57|#define TSNM_tlstmCertSANDNSName                3
  ------------------
  244|     57|    se_add_pair_to_slist("cert_map_type", strdup("any"), TSNM_tlstmCertSANAny);
  ------------------
  |  |  125|     57|#define TSNM_tlstmCertSANAny                    5
  ------------------
  245|     57|    se_add_pair_to_slist("cert_map_type", strdup("sn"),
  246|     57|                         TSNM_tlstmCertSpecified);
  ------------------
  |  |  121|     57|#define TSNM_tlstmCertSpecified                 1
  ------------------
  247|       |
  248|     57|}
netsnmp_certs_shutdown:
  252|     57|{
  253|     57|    netsnmp_container ***c, **containers[] = {
  254|     57|        &_tlstmParams, &_tlstmAddr, &_maps, &_certs, &_keys, NULL
  255|     57|    };
  256|       |
  257|     57|    DEBUGMSGT(("cert:util:shutdown","shutdown\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]
  |  |  ------------------
  ------------------
  258|       |
  259|    342|    for (c = containers; *c; c++) {
  ------------------
  |  Branch (259:26): [True: 285, False: 57]
  ------------------
  260|    285|        if (!**c)
  ------------------
  |  Branch (260:13): [True: 171, False: 114]
  ------------------
  261|    171|            continue;
  262|    114|        CONTAINER_FREE_ALL(**c, NULL);
  263|    114|        CONTAINER_FREE(**c);
  264|       |        **c = NULL;
  265|    114|    }
  266|     57|    _netsnmp_release_trustcerts();
  267|     57|}
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|     57|{
  354|     57|    netsnmp_container *additional_keys;
  355|       |
  356|     57|    int rc;
  357|       |
  358|     57|    _certs = _get_cert_container("netsnmp certificates");
  359|     57|    if (NULL == _certs)
  ------------------
  |  Branch (359:9): [True: 0, False: 57]
  ------------------
  360|      0|        return;
  361|       |
  362|       |    /** additional keys: common name */
  363|     57|    additional_keys = netsnmp_container_find("certs_cn:binary_array");
  364|     57|    if (NULL == additional_keys) {
  ------------------
  |  Branch (364:9): [True: 0, False: 57]
  ------------------
  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|     57|    additional_keys->container_name = strdup("certs_cn");
  370|     57|    additional_keys->free_item = NULL;
  371|     57|    additional_keys->compare = _cert_cn_compare;
  372|     57|    CONTAINER_SET_OPTIONS(additional_keys, CONTAINER_KEY_ALLOW_DUPLICATES, rc);
  ------------------
  |  |  375|     57|#define CONTAINER_SET_OPTIONS(x,o,rc)  do {                             \
  |  |  376|     57|        if (NULL==(x)->options)                                         \
  |  |  ------------------
  |  |  |  Branch (376:13): [True: 0, False: 57]
  |  |  ------------------
  |  |  377|     57|            rc = -1;                                                    \
  |  |  378|     57|        else {                                                          \
  |  |  379|     57|            rc = (x)->options(x, 1, o);                                 \
  |  |  380|     57|            if (rc != -1 )                                              \
  |  |  ------------------
  |  |  |  Branch (380:17): [True: 57, False: 0]
  |  |  ------------------
  |  |  381|     57|                (x)->flags |= o;                                        \
  |  |  382|     57|        }                                                               \
  |  |  383|     57|    } while(0)
  |  |  ------------------
  |  |  |  Branch (383:13): [Folded, False: 57]
  |  |  ------------------
  ------------------
  373|     57|    netsnmp_container_add_index(_certs, additional_keys);
  374|       |
  375|       |    /** additional keys: subject name */
  376|     57|    additional_keys = netsnmp_container_find("certs_sn:binary_array");
  377|     57|    if (NULL == additional_keys) {
  ------------------
  |  Branch (377:9): [True: 0, False: 57]
  ------------------
  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|     57|    additional_keys->container_name = strdup("certs_sn");
  383|     57|    additional_keys->free_item = NULL;
  384|     57|    additional_keys->compare = _cert_sn_compare;
  385|     57|    additional_keys->ncompare = _cert_sn_ncompare;
  386|     57|    CONTAINER_SET_OPTIONS(additional_keys, CONTAINER_KEY_ALLOW_DUPLICATES, rc);
  ------------------
  |  |  375|     57|#define CONTAINER_SET_OPTIONS(x,o,rc)  do {                             \
  |  |  376|     57|        if (NULL==(x)->options)                                         \
  |  |  ------------------
  |  |  |  Branch (376:13): [True: 0, False: 57]
  |  |  ------------------
  |  |  377|     57|            rc = -1;                                                    \
  |  |  378|     57|        else {                                                          \
  |  |  379|     57|            rc = (x)->options(x, 1, o);                                 \
  |  |  380|     57|            if (rc != -1 )                                              \
  |  |  ------------------
  |  |  |  Branch (380:17): [True: 57, False: 0]
  |  |  ------------------
  |  |  381|     57|                (x)->flags |= o;                                        \
  |  |  382|     57|        }                                                               \
  |  |  383|     57|    } while(0)
  |  |  ------------------
  |  |  |  Branch (383:13): [Folded, False: 57]
  |  |  ------------------
  ------------------
  387|     57|    netsnmp_container_add_index(_certs, additional_keys);
  388|       |
  389|       |    /** additional keys: file name */
  390|     57|    additional_keys = netsnmp_container_find("certs_fn:binary_array");
  391|     57|    if (NULL == additional_keys) {
  ------------------
  |  Branch (391:9): [True: 0, False: 57]
  ------------------
  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|     57|    additional_keys->container_name = strdup("certs_fn");
  397|     57|    additional_keys->free_item = NULL;
  398|     57|    additional_keys->compare = _cert_fn_compare;
  399|     57|    additional_keys->ncompare = _cert_fn_ncompare;
  400|     57|    CONTAINER_SET_OPTIONS(additional_keys, CONTAINER_KEY_ALLOW_DUPLICATES, rc);
  ------------------
  |  |  375|     57|#define CONTAINER_SET_OPTIONS(x,o,rc)  do {                             \
  |  |  376|     57|        if (NULL==(x)->options)                                         \
  |  |  ------------------
  |  |  |  Branch (376:13): [True: 0, False: 57]
  |  |  ------------------
  |  |  377|     57|            rc = -1;                                                    \
  |  |  378|     57|        else {                                                          \
  |  |  379|     57|            rc = (x)->options(x, 1, o);                                 \
  |  |  380|     57|            if (rc != -1 )                                              \
  |  |  ------------------
  |  |  |  Branch (380:17): [True: 57, False: 0]
  |  |  ------------------
  |  |  381|     57|                (x)->flags |= o;                                        \
  |  |  382|     57|        }                                                               \
  |  |  383|     57|    } while(0)
  |  |  ------------------
  |  |  |  Branch (383:13): [Folded, False: 57]
  |  |  ------------------
  ------------------
  401|     57|    netsnmp_container_add_index(_certs, additional_keys);
  402|       |
  403|     57|    _keys = netsnmp_container_find("cert_keys:binary_array");
  404|     57|    if (NULL == _keys) {
  ------------------
  |  Branch (404:9): [True: 0, False: 57]
  ------------------
  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|     57|    _keys->container_name = strdup("netsnmp certificate keys");
  410|     57|    _keys->free_item = _key_free;
  411|     57|    _keys->compare = _cert_fn_compare;
  412|       |
  413|     57|    _setup_trusted_certs();
  414|     57|}
cert_util.c:_get_cert_container:
  332|     57|{
  333|     57|    netsnmp_container *c;
  334|       |
  335|     57|    int rc;
  336|       |
  337|     57|    c = netsnmp_container_find("certs:binary_array");
  338|     57|    if (NULL == c) {
  ------------------
  |  Branch (338:9): [True: 0, False: 57]
  ------------------
  339|      0|        snmp_log(LOG_ERR, "could not create container for %s\n", use);
  340|      0|        return NULL;
  341|      0|    }
  342|     57|    c->container_name = strdup(use);
  343|     57|    c->free_item = _cert_free;
  344|     57|    c->compare = _cert_compare;
  345|       |
  346|     57|    CONTAINER_SET_OPTIONS(c, CONTAINER_KEY_ALLOW_DUPLICATES, rc);
  ------------------
  |  |  375|     57|#define CONTAINER_SET_OPTIONS(x,o,rc)  do {                             \
  |  |  376|     57|        if (NULL==(x)->options)                                         \
  |  |  ------------------
  |  |  |  Branch (376:13): [True: 0, False: 57]
  |  |  ------------------
  |  |  377|     57|            rc = -1;                                                    \
  |  |  378|     57|        else {                                                          \
  |  |  379|     57|            rc = (x)->options(x, 1, o);                                 \
  |  |  380|     57|            if (rc != -1 )                                              \
  |  |  ------------------
  |  |  |  Branch (380:17): [True: 57, False: 0]
  |  |  ------------------
  |  |  381|     57|                (x)->flags |= o;                                        \
  |  |  382|     57|        }                                                               \
  |  |  383|     57|    } while(0)
  |  |  ------------------
  |  |  |  Branch (383:13): [Folded, False: 57]
  |  |  ------------------
  ------------------
  347|       |
  348|     57|    return c;
  349|     57|}
cert_util.c:_cert_indexes_load:
 1721|      1|{
 1722|      1|    const char     *confpath;
 1723|      1|    char           *confpath_copy, *dir, *st = NULL;
 1724|      1|    char            certdir[SNMP_MAXPATH];
 1725|      1|    const char     *subdirs[] = { NULL, "ca-certs", "certs", "private", NULL };
 1726|      1|    int             i = 0;
 1727|       |
 1728|       |    /*
 1729|       |     * load indexes from persistent dir
 1730|       |     */
 1731|      1|    _certindexes_load();
 1732|       |
 1733|       |    /*
 1734|       |     * duplicate path building from read_config_files_of_type() in
 1735|       |     * read_config.c. That is, use SNMPCONFPATH environment variable if
 1736|       |     * it is defined, otherwise use configuration directory.
 1737|       |     */
 1738|      1|    confpath = netsnmp_getenv("SNMPCONFPATH");
 1739|      1|    if (NULL == confpath)
  ------------------
  |  Branch (1739:9): [True: 1, False: 0]
  ------------------
 1740|      1|        confpath = get_configuration_directory();
 1741|       |
 1742|      1|    subdirs[0] = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1743|      1|                                       NETSNMP_DS_LIB_CERT_EXTRA_SUBDIR);
  ------------------
  |  |  177|      1|#define NETSNMP_DS_LIB_CERT_EXTRA_SUBDIR 26
  ------------------
 1744|      1|    confpath_copy = strdup(confpath);
 1745|      1|    if (!confpath_copy)
  ------------------
  |  Branch (1745:9): [True: 0, False: 1]
  ------------------
 1746|      0|        return;
 1747|      1|    for ( dir = strtok_r(confpath_copy, ENV_SEPARATOR, &st);
  ------------------
  |  |   67|      1|#define ENV_SEPARATOR ":"
  ------------------
 1748|      5|          dir; dir = strtok_r(NULL, ENV_SEPARATOR, &st)) {
  ------------------
  |  |   67|      4|#define ENV_SEPARATOR ":"
  ------------------
  |  Branch (1748:11): [True: 4, False: 1]
  ------------------
 1749|       |
 1750|      4|        i = (NULL == subdirs[0]) ? 1 : 0;
  ------------------
  |  Branch (1750:13): [True: 4, False: 0]
  ------------------
 1751|     16|        for ( ; subdirs[i] ; ++i ) {
  ------------------
  |  Branch (1751:17): [True: 12, False: 4]
  ------------------
 1752|       |            /** check tls subdir */
 1753|     12|            snprintf(certdir, sizeof(certdir), "%s/tls/%s", dir, subdirs[i]);
 1754|     12|            _add_certdir(certdir);
 1755|     12|        } /* for subdirs */
 1756|      4|    } /* for conf path dirs */
 1757|       |    SNMP_FREE(confpath_copy);
  ------------------
  |  |   62|      1|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 1, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 1]
  |  |  ------------------
  ------------------
 1758|      1|}
cert_util.c:_certindexes_load:
  779|      1|{
  780|      1|    DIR *dir;
  781|      1|    struct dirent *file;
  782|      1|    FILE *fp;
  783|      1|    char filename[SNMP_MAXPATH], line[300];
  784|      1|    int  i;
  785|      1|    char *cp, *pos;
  786|       |
  787|       |    /*
  788|       |     * Open the CERT index directory, or create it (empty)
  789|       |     */
  790|      1|    snprintf(filename, sizeof(filename), "%s/cert_indexes",
  791|      1|             get_persistent_directory());
  792|      1|    dir = opendir( filename );
  793|      1|    if ( dir == NULL ) {
  ------------------
  |  Branch (793:10): [True: 1, False: 0]
  ------------------
  794|      1|        DEBUGMSGT(("cert:index:load",
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
  795|      1|                   "creating new cert_indexes directory\n"));
  796|      1|        mkdirhier( filename, NETSNMP_AGENT_DIRECTORY_MODE, 0);
  ------------------
  |  | 2005|      1|#define NETSNMP_AGENT_DIRECTORY_MODE 0700
  ------------------
  797|      1|        return;
  798|      1|    }
  799|       |
  800|       |    /*
  801|       |     * Create a list of which directory each file refers to
  802|       |     */
  803|      0|    while ((file = readdir( dir ))) {
  ------------------
  |  Branch (803:12): [True: 0, False: 0]
  ------------------
  804|      0|        if ( !isdigit(0xFF & file->d_name[0]))
  ------------------
  |  Branch (804:14): [True: 0, False: 0]
  ------------------
  805|      0|            continue;
  806|      0|        i = atoi( file->d_name );
  807|       |
  808|      0|        snprintf(filename, sizeof(filename), "%s/cert_indexes/%d",
  809|      0|                 get_persistent_directory(), i );
  810|      0|        fp = fopen( filename, "r" );
  811|      0|        if ( !fp ) {
  ------------------
  |  Branch (811:14): [True: 0, False: 0]
  ------------------
  812|      0|            DEBUGMSGT(("cert:index:load", "error opening index (%d)\n", i));
  ------------------
  |  |   62|      0|#define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  ------------------
  |  |  |  Branch (62:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
  813|      0|            continue;
  814|      0|        }
  815|      0|        cp = fgets( line, sizeof(line), fp );
  816|      0|        if ( cp ) {
  ------------------
  |  Branch (816:14): [True: 0, False: 0]
  ------------------
  817|      0|            line[strlen(line)-1] = 0;
  818|      0|            pos = strrchr(line, ' ');
  819|      0|            if (pos)
  ------------------
  |  Branch (819:17): [True: 0, False: 0]
  ------------------
  820|      0|                *pos = '\0';
  821|      0|            DEBUGMSGT(("9:cert:index:load","adding (%d) %s\n", i, line));
  ------------------
  |  |   62|      0|#define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  ------------------
  |  |  |  Branch (62:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
  822|      0|            (void)_certindex_add( line+4, i );  /* Skip 'DIR ' */
  823|      0|        } else {
  824|      0|            DEBUGMSGT(("cert:index:load", "Empty index (%d)\n", i));
  ------------------
  |  |   62|      0|#define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  ------------------
  |  |  |  Branch (62:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
  825|      0|        }
  826|      0|        fclose( fp );
  827|      0|    }
  828|      0|    closedir( dir );
  829|      0|}
cert_util.c:_add_certdir:
 1630|     12|{
 1631|     12|    FILE           *index;
 1632|     12|    char           *file;
 1633|     12|    int             count = 0;
 1634|     12|    netsnmp_container *cert_container;
 1635|     12|    netsnmp_iterator  *it;
 1636|     12|    struct stat     statbuf;
 1637|       |
 1638|     12|    netsnmp_assert(NULL != dirname);
  ------------------
  |  |   47|     12|#      define netsnmp_assert(x)  do { \
  |  |   48|     12|              if ( x ) \
  |  |  ------------------
  |  |  |  Branch (48:20): [True: 12, False: 0]
  |  |  ------------------
  |  |   49|     12|                 ; \
  |  |   50|     12|              else \
  |  |   51|     12|                 snmp_log(LOG_ERR, \
  |  |   52|      0|                          "netsnmp_assert %s failed %s:%d" NETSNMP_FUNC_FMT, \
  |  |  ------------------
  |  |  |  |   40|      0|#          define NETSNMP_FUNC_FMT " %s()\n"
  |  |  ------------------
  |  |   53|      0|                          __STRING(x),__FILE__,__LINE__, \
  |  |   54|      0|                          NETSNMP_FUNC_PARAM); \
  |  |  ------------------
  |  |  |  |   41|      0|#          define NETSNMP_FUNC_PARAM NETSNMP_FUNCTION
  |  |  |  |  ------------------
  |  |  |  |  |  | 1702|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|     12|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded, False: 12]
  |  |  ------------------
  ------------------
 1639|       |
 1640|     12|    DEBUGMSGT(("9:cert:dir:add", " config dir: %s\n", dirname ));
  ------------------
  |  |   62|     12|#define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     12|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 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]
  |  |  ------------------
  ------------------
 1641|       |
 1642|     12|    if (stat(dirname, &statbuf) != 0) {
  ------------------
  |  Branch (1642:9): [True: 12, False: 0]
  ------------------
 1643|     12|        DEBUGMSGT(("9:cert:dir:add", " dir not present: %s\n",
  ------------------
  |  |   62|     12|#define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     12|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 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]
  |  |  ------------------
  ------------------
 1644|     12|                   dirname ));
 1645|     12|        return -1;
 1646|     12|    }
 1647|      0|#ifdef S_ISDIR
 1648|      0|    if (!S_ISDIR(statbuf.st_mode)) {
  ------------------
  |  Branch (1648:9): [True: 0, False: 0]
  ------------------
 1649|      0|        DEBUGMSGT(("9:cert:dir:add", " not a dir: %s\n", dirname ));
  ------------------
  |  |   62|      0|#define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  ------------------
  |  |  |  Branch (62:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1650|      0|        return -1;
 1651|      0|    }
 1652|      0|#endif
 1653|       |
 1654|      0|    DEBUGMSGT(("cert:index:dir", "Scanning directory %s\n", dirname));
  ------------------
  |  |   62|      0|#define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  ------------------
  |  |  |  Branch (62:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1655|       |
 1656|       |    /*
 1657|       |     * look for existing index
 1658|       |     */
 1659|      0|    count = _cert_read_index(dirname, &statbuf);
 1660|      0|    if (count >= 0)
  ------------------
  |  Branch (1660:9): [True: 0, False: 0]
  ------------------
 1661|      0|        return count;
 1662|       |
 1663|      0|    index = _certindex_new( dirname );
 1664|      0|    if (NULL == index) {
  ------------------
  |  Branch (1664:9): [True: 0, False: 0]
  ------------------
 1665|      0|        DEBUGMSGT(("9:cert:index:dir",
  ------------------
  |  |   62|      0|#define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  ------------------
  |  |  |  Branch (62:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1666|      0|                    "error opening index for cert directory\n"));
 1667|      0|        DEBUGMSGTL(("cert:index", "could not open certificate index file\n"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1668|      0|    }
 1669|       |
 1670|       |    /*
 1671|       |     * index was missing, out of date or bad. rescan directory.
 1672|       |     */
 1673|      0|    cert_container =
 1674|      0|        netsnmp_directory_container_read_some(NULL, dirname,
 1675|      0|                                              _cert_cert_filter, NULL,
 1676|      0|                                              NETSNMP_DIR_RELATIVE_PATH |
  ------------------
  |  |   48|      0|#define NETSNMP_DIR_RELATIVE_PATH                     0x0002
  ------------------
 1677|      0|                                              NETSNMP_DIR_EMPTY_OK |
  ------------------
  |  |   51|      0|#define NETSNMP_DIR_EMPTY_OK                          0x0008
  ------------------
 1678|      0|                                              NETSNMP_DIR_ALLOW_DUPLICATES);
  ------------------
  |  |   57|      0|#define NETSNMP_DIR_ALLOW_DUPLICATES                  0x0040
  ------------------
 1679|      0|    if (NULL == cert_container) {
  ------------------
  |  Branch (1679:9): [True: 0, False: 0]
  ------------------
 1680|      0|        DEBUGMSGT(("cert:index:dir",
  ------------------
  |  |   62|      0|#define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  ------------------
  |  |  |  Branch (62:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1681|      0|                    "error creating container for cert files\n"));
 1682|      0|        goto err_index;
 1683|      0|    }
 1684|       |
 1685|       |    /*
 1686|       |     * iterate through the found files and add them to index
 1687|       |     */
 1688|      0|    it = CONTAINER_ITERATOR(cert_container);
  ------------------
  |  |  404|      0|#define CONTAINER_ITERATOR(x)       (x)->get_iterator(x)
  ------------------
 1689|      0|    if (NULL == it) {
  ------------------
  |  Branch (1689:9): [True: 0, False: 0]
  ------------------
 1690|      0|        DEBUGMSGT(("cert:index:dir",
  ------------------
  |  |   62|      0|#define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  ------------------
  |  |  |  Branch (62:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1691|      0|                    "error creating iterator for cert files\n"));
 1692|      0|        goto err_container;
 1693|      0|    }
 1694|       |
 1695|      0|    for (file = ITERATOR_FIRST(it); file; file = ITERATOR_NEXT(it)) {
  ------------------
  |  |  546|      0|#define ITERATOR_FIRST(x)  x->first(x)
  ------------------
                  for (file = ITERATOR_FIRST(it); file; file = ITERATOR_NEXT(it)) {
  ------------------
  |  |  547|      0|#define ITERATOR_NEXT(x)   x->next(x)
  ------------------
  |  Branch (1695:37): [True: 0, False: 0]
  ------------------
 1696|      0|        DEBUGMSGT(("cert:index:dir", "adding %s to index\n", file));
  ------------------
  |  |   62|      0|#define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  ------------------
  |  |  |  Branch (62:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1697|      0|        if ( 0 == _add_certfile( dirname, file, index ))
  ------------------
  |  Branch (1697:14): [True: 0, False: 0]
  ------------------
 1698|      0|            count++;
 1699|      0|        else
 1700|      0|            DEBUGMSGT(("cert:index:dir", "error adding %s to index\n",
  ------------------
  |  |   62|      0|#define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  ------------------
  |  |  |  Branch (62:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1701|      0|                        file));
 1702|      0|    }
 1703|       |
 1704|       |    /*
 1705|       |     * clean up and return
 1706|       |     */
 1707|      0|    ITERATOR_RELEASE(it);
  ------------------
  |  |  550|      0|#define ITERATOR_RELEASE(x) do { x->release(x); x = NULL; } while(0)
  |  |  ------------------
  |  |  |  Branch (550:67): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1708|       |
 1709|      0|  err_container:
 1710|      0|    netsnmp_directory_container_free(cert_container);
 1711|       |
 1712|      0|  err_index:
 1713|      0|    if (index)
  ------------------
  |  Branch (1713:9): [True: 0, False: 0]
  ------------------
 1714|      0|        fclose(index);
 1715|       |
 1716|      0|    return count;
 1717|      0|}

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

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

netsnmp_container_get_usll:
  386|     57|{
  387|       |    /*
  388|       |     * allocate memory
  389|       |     */
  390|     57|    sl_container *sl = (sl_container *)netsnmp_container_get_ssll();
  391|     57|    if (NULL==sl)
  ------------------
  |  Branch (391:9): [True: 0, False: 57]
  ------------------
  392|      0|        return NULL; /* msg already logged */
  393|       |
  394|     57|    sl->unsorted = 1;
  395|       |
  396|     57|    return (netsnmp_container*)sl;
  397|     57|}
netsnmp_container_get_singly_linked_list:
  401|     57|{
  402|     57|    sl_container *sl = (sl_container *)netsnmp_container_get_usll();
  403|     57|    if (NULL == sl)
  ------------------
  |  Branch (403:9): [True: 0, False: 57]
  ------------------
  404|      0|        return NULL; /* error already logged */
  405|       |
  406|     57|    sl->fifo = fifo;
  407|       |
  408|     57|    return (netsnmp_container *)sl;
  409|     57|}
netsnmp_container_get_fifo:
  413|     57|{
  414|     57|    return netsnmp_container_get_singly_linked_list(1);
  415|     57|}
netsnmp_container_ssll_init:
  419|     57|{
  420|     57|    static netsnmp_factory ssll = {
  421|     57|        "sorted_singly_linked_list",
  422|     57|        netsnmp_container_get_ssll
  423|     57|    };
  424|     57|    static netsnmp_factory usll = {
  425|     57|        "unsorted_singly_linked_list-lifo",
  426|     57|        netsnmp_container_get_usll
  427|     57|    };
  428|     57|    static netsnmp_factory fifo = {
  429|     57|        "unsorted_singly_linked_list-fifo",
  430|     57|        netsnmp_container_get_fifo
  431|     57|    };
  432|       |
  433|     57|    netsnmp_container_register("sorted_singly_linked_list", &ssll);
  434|     57|    netsnmp_container_register("unsorted_singly_linked_list", &usll);
  435|     57|    netsnmp_container_register("lifo", &usll);
  436|     57|    netsnmp_container_register("fifo", &fifo);
  437|     57|}
container_list_ssll.c:netsnmp_container_get_ssll:
  361|     57|{
  362|       |    /*
  363|       |     * allocate memory
  364|       |     */
  365|     57|    sl_container *sl = SNMP_MALLOC_TYPEDEF(sl_container);
  ------------------
  |  |   73|     57|#define SNMP_MALLOC_TYPEDEF(td)  (td *) calloc(1, sizeof(td))
  ------------------
  366|     57|    if (NULL==sl) {
  ------------------
  |  Branch (366:9): [True: 0, False: 57]
  ------------------
  367|      0|        snmp_log(LOG_ERR, "couldn't allocate memory\n");
  368|      0|        return NULL;
  369|      0|    }
  370|       |
  371|     57|    netsnmp_init_container((netsnmp_container *)sl, NULL, _ssll_free,
  372|     57|                           _ssll_size, NULL, _ssll_insert, _ssll_remove,
  373|     57|                           _ssll_find);
  374|     57|    sl->c.find_next = _ssll_find_next;
  375|     57|    sl->c.get_subset = NULL;
  376|     57|    sl->c.get_iterator =_ssll_iterator_get;
  377|     57|    sl->c.for_each = _ssll_for_each;
  378|     57|    sl->c.clear = _ssll_clear;
  379|     57|    sl->c.duplicate = _ssll_duplicate;
  380|       |
  381|     57|    return &sl->c;
  382|     57|}
container_list_ssll.c:_ssll_free:
  110|     57|{
  111|     57|    if(c) {
  ------------------
  |  Branch (111:8): [True: 57, False: 0]
  ------------------
  112|     57|        free(c);
  113|     57|    }
  114|     57|    return 0;
  115|     57|}
container_list_ssll.c:_ssll_clear:
  287|     57|{
  288|     57|    sl_container *sl = (sl_container*)c;
  289|     57|    sl_node  *curr, *next;
  290|       |    
  291|     57|    if(NULL == c)
  ------------------
  |  Branch (291:8): [True: 0, False: 57]
  ------------------
  292|      0|        return;
  293|       |    
  294|     57|    for(curr = sl->head; curr; curr = next) {
  ------------------
  |  Branch (294:26): [True: 0, False: 57]
  ------------------
  295|       |
  296|      0|        next = curr->next;
  297|       |
  298|      0|        if( NULL != f ) {
  ------------------
  |  Branch (298:13): [True: 0, False: 0]
  ------------------
  299|      0|            curr->next = NULL;
  300|      0|            (*f) ((void *)curr->data, context);
  301|      0|        }
  302|       |
  303|       |        /*
  304|       |         * free our node structure, but not the data
  305|       |         */
  306|      0|        free(curr);
  307|      0|    }
  308|       |    sl->head = NULL;
  309|     57|    sl->count = 0;
  310|     57|    ++c->sync;
  311|     57|}

netsnmp_container_get_null_factory:
  173|     57|{
  174|     57|    static netsnmp_factory f = { "null",
  175|     57|                                 netsnmp_container_get_null};
  176|       |    
  177|     57|    DEBUGMSGTL(("container:null:get_null_factory","in\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]
  |  |  ------------------
  ------------------
  178|     57|    return &f;
  179|     57|}
netsnmp_container_null_init:
  183|     57|{
  184|     57|    netsnmp_container_register("null",
  185|     57|                               netsnmp_container_get_null_factory());
  186|     57|}

netsnmp_free_all_list_data:
   49|    171|{
   50|    171|    netsnmp_data_list *tmpptr;
   51|    171|    for (; head;) {
  ------------------
  |  Branch (51:12): [True: 0, False: 171]
  ------------------
   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|    171|}
shutdown_data_list:
  395|     57|{
  396|     57|    netsnmp_free_all_list_data(saveHead);
  397|     57|}

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

netsnmp_large_fd_setfd:
  120|     56|{
  121|     56|    netsnmp_assert(fd >= 0);
  ------------------
  |  |   47|     56|#      define netsnmp_assert(x)  do { \
  |  |   48|     56|              if ( x ) \
  |  |  ------------------
  |  |  |  Branch (48:20): [True: 56, False: 0]
  |  |  ------------------
  |  |   49|     56|                 ; \
  |  |   50|     56|              else \
  |  |   51|     56|                 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
  |  |  |  |  ------------------
  |  |  |  |  |  | 1702|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|     56|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded, False: 56]
  |  |  ------------------
  ------------------
  122|       |
  123|     56|    while (fd >= (int)fdset->lfs_setsize)
  ------------------
  |  Branch (123:12): [True: 0, False: 56]
  ------------------
  124|      0|        netsnmp_large_fd_set_resize(fdset, 2 * (fdset->lfs_setsize + 1));
  125|       |
  126|     56|    LFD_SET(fd, fdset->lfs_setptr);
  127|     56|}
netsnmp_large_fd_clr:
  131|     56|{
  132|     56|    netsnmp_assert(fd >= 0);
  ------------------
  |  |   47|     56|#      define netsnmp_assert(x)  do { \
  |  |   48|     56|              if ( x ) \
  |  |  ------------------
  |  |  |  Branch (48:20): [True: 56, False: 0]
  |  |  ------------------
  |  |   49|     56|                 ; \
  |  |   50|     56|              else \
  |  |   51|     56|                 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
  |  |  |  |  ------------------
  |  |  |  |  |  | 1702|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|     56|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded, False: 56]
  |  |  ------------------
  ------------------
  133|       |
  134|     56|    if ((unsigned)fd < fdset->lfs_setsize)
  ------------------
  |  Branch (134:9): [True: 56, False: 0]
  ------------------
  135|     56|        LFD_CLR(fd, fdset->lfs_setptr);
  136|     56|}
netsnmp_large_fd_is_set:
  140|     56|{
  141|     56|    netsnmp_assert(fd >= 0);
  ------------------
  |  |   47|     56|#      define netsnmp_assert(x)  do { \
  |  |   48|     56|              if ( x ) \
  |  |  ------------------
  |  |  |  Branch (48:20): [True: 56, False: 0]
  |  |  ------------------
  |  |   49|     56|                 ; \
  |  |   50|     56|              else \
  |  |   51|     56|                 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
  |  |  |  |  ------------------
  |  |  |  |  |  | 1702|      0|#define NETSNMP_FUNCTION __func__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   55|     56|           }while(0)
  |  |  ------------------
  |  |  |  Branch (55:19): [Folded, False: 56]
  |  |  ------------------
  ------------------
  142|       |
  143|     56|    return ((unsigned)fd < fdset->lfs_setsize &&
  ------------------
  |  Branch (143:13): [True: 56, False: 0]
  ------------------
  144|     56|            LFD_ISSET(fd, fdset->lfs_setptr));
  ------------------
  |  Branch (144:13): [True: 56, False: 0]
  ------------------
  145|     56|}
netsnmp_large_fd_set_init:
  151|    112|{
  152|    112|    fdset->lfs_setsize = 0;
  153|    112|    fdset->lfs_setptr  = NULL;
  154|       |#if !defined(cygwin) && defined(HAVE_WINSOCK_H)
  155|       |    fdset->lfs_set.fd_count = 0;
  156|       |#endif
  157|    112|    netsnmp_large_fd_set_resize(fdset, setsize);
  158|    112|}
netsnmp_large_fd_set_resize:
  192|    336|{
  193|    336|    int             fd_set_bytes;
  194|       |
  195|    336|    if (fdset->lfs_setsize == setsize)
  ------------------
  |  Branch (195:9): [True: 112, False: 224]
  ------------------
  196|    112|        goto success;
  197|       |
  198|    224|    if (setsize > FD_SETSIZE) {
  ------------------
  |  Branch (198:9): [True: 0, False: 224]
  ------------------
  199|      0|        fd_set_bytes = NETSNMP_FD_SET_BYTES(setsize);
  ------------------
  |  |   99|      0|    (sizeof(fd_set) + ((setsize) > FD_SETSIZE ?                          \
  |  |  ------------------
  |  |  |  Branch (99:24): [True: 0, False: 0]
  |  |  ------------------
  |  |  100|      0|                       NETSNMP_FD_SET_ELEM_COUNT((setsize) - FD_SETSIZE) \
  |  |  ------------------
  |  |  |  |   92|      0|    (setsize + NETSNMP_BITS_PER_FD_MASK - 1) / NETSNMP_BITS_PER_FD_MASK
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|      0|#define NETSNMP_BITS_PER_FD_MASK (8 * NETSNMP_FD_MASK_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   85|      0|#define NETSNMP_FD_MASK_SIZE sizeof(((fd_set*)0)->fds_bits[0])
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |                   (setsize + NETSNMP_BITS_PER_FD_MASK - 1) / NETSNMP_BITS_PER_FD_MASK
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|      0|#define NETSNMP_BITS_PER_FD_MASK (8 * NETSNMP_FD_MASK_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   85|      0|#define NETSNMP_FD_MASK_SIZE sizeof(((fd_set*)0)->fds_bits[0])
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  101|      0|                       * NETSNMP_FD_MASK_SIZE : 0))
  |  |  ------------------
  |  |  |  |   85|      0|#define NETSNMP_FD_MASK_SIZE sizeof(((fd_set*)0)->fds_bits[0])
  |  |  ------------------
  ------------------
  200|      0|        if (fdset->lfs_setsize > FD_SETSIZE) {
  ------------------
  |  Branch (200:13): [True: 0, False: 0]
  ------------------
  201|      0|            fdset->lfs_setptr = realloc(fdset->lfs_setptr, fd_set_bytes);
  202|      0|            if (!fdset->lfs_setptr)
  ------------------
  |  Branch (202:17): [True: 0, False: 0]
  ------------------
  203|      0|                goto out_of_mem;
  204|      0|        } else {
  205|      0|            fdset->lfs_setptr = malloc(fd_set_bytes);
  206|      0|            if (!fdset->lfs_setptr)
  ------------------
  |  Branch (206:17): [True: 0, False: 0]
  ------------------
  207|      0|                goto out_of_mem;
  208|      0|            *fdset->lfs_setptr = fdset->lfs_set;
  209|      0|        }
  210|    224|    } else {
  211|    224|        if (fdset->lfs_setsize > FD_SETSIZE) {
  ------------------
  |  Branch (211:13): [True: 0, False: 224]
  ------------------
  212|      0|            fdset->lfs_set = *fdset->lfs_setptr;
  213|      0|            free(fdset->lfs_setptr);
  214|      0|        }
  215|    224|        fdset->lfs_setptr = &fdset->lfs_set;
  216|    224|    }
  217|       |
  218|    224|#if defined(cygwin) || !defined(HAVE_WINSOCK_H)
  219|       |    /*
  220|       |     * Unix: when enlarging, clear the file descriptors defined in the
  221|       |     * resized *fdset but that were not defined in the original *fdset.
  222|       |     */
  223|    224|    if ( fdset->lfs_setsize == 0 && setsize == FD_SETSIZE ) {
  ------------------
  |  Branch (223:10): [True: 112, False: 112]
  |  Branch (223:37): [True: 112, False: 0]
  ------------------
  224|       |        /* In this case we can use the OS's FD_ZERO */
  225|    112|        FD_ZERO(fdset->lfs_setptr);
  ------------------
  |  Branch (225:9): [Folded, False: 112]
  ------------------
  226|    112|    } else {
  227|    112|        int             i;
  228|       |
  229|    112|        for (i = fdset->lfs_setsize; i < setsize; i++)
  ------------------
  |  Branch (229:38): [True: 0, False: 112]
  ------------------
  230|      0|            LFD_CLR(i, fdset->lfs_setptr);
  231|    112|    }
  232|    224|#endif
  233|       |
  234|    224|    fdset->lfs_setsize = setsize;
  235|       |#if !defined(cygwin) && defined(HAVE_WINSOCK_H)
  236|       |    if (setsize < fdset->lfs_setptr->fd_count)
  237|       |        fdset->lfs_setptr->fd_count = setsize;
  238|       |#endif
  239|    336|success:
  240|    336|    return 1;
  241|       |
  242|      0|out_of_mem:
  243|      0|    fdset->lfs_setsize = 0;
  244|       |#if !defined(cygwin) && defined(HAVE_WINSOCK_H)
  245|       |    fdset->lfs_setptr->fd_count = 0;
  246|       |#endif
  247|      0|    return 0;
  248|    224|}
netsnmp_large_fd_set_cleanup:
  252|    112|{
  253|    112|    netsnmp_large_fd_set_resize(fdset, 0);
  254|    112|    fdset->lfs_setsize = 0;
  255|       |    fdset->lfs_setptr  = NULL;
  256|    112|}
netsnmp_copy_fd_set_to_large_fd_set:
  261|    112|{
  262|       |    netsnmp_large_fd_set_resize(dst, FD_SETSIZE);
  263|    112|    *dst->lfs_setptr = *src;
  264|    112|}
netsnmp_copy_large_fd_set_to_fd_set:
  269|     56|{
  270|       |    /* Report failure if *src is larger than FD_SETSIZE. */
  271|     56|    if (src->lfs_setsize > FD_SETSIZE) {
  ------------------
  |  Branch (271:9): [True: 0, False: 56]
  ------------------
  272|      0|        FD_ZERO(dst);
  ------------------
  |  Branch (272:9): [Folded, False: 0]
  ------------------
  273|      0|        return -1;
  274|      0|    }
  275|       |
  276|     56|    *dst = *src->lfs_setptr;
  277|       |
  278|     56|#if !(!defined(cygwin) && defined(HAVE_WINSOCK_H))
  279|     56|    {
  280|     56|        int             i;
  281|       |
  282|       |        /* Unix: clear any file descriptors defined in *dst but not in *src. */
  283|     56|        for (i = src->lfs_setsize; i < FD_SETSIZE; ++i)
  ------------------
  |  Branch (283:36): [True: 0, False: 56]
  ------------------
  284|     56|            FD_CLR(i, dst);
  285|     56|    }
  286|     56|#endif
  287|       |
  288|     56|    return 0;
  289|     56|}
large_fd_set.c:LFD_SET:
   95|     56|{
   96|     56|    enum { nfdbits = 8 * sizeof(p->fds_bits[0]) };
   97|     56|    NETSNMP_FD_MASK_TYPE *fds_array = p->fds_bits;
  ------------------
  |  | 1696|     56|#define NETSNMP_FD_MASK_TYPE __fd_mask
  ------------------
   98|       |
   99|     56|    fds_array[n / nfdbits] |= (1ULL << (n % nfdbits));
  100|     56|}
large_fd_set.c:LFD_CLR:
  103|     56|{
  104|     56|    enum { nfdbits = 8 * sizeof(p->fds_bits[0]) };
  105|     56|    NETSNMP_FD_MASK_TYPE *fds_array = p->fds_bits;
  ------------------
  |  | 1696|     56|#define NETSNMP_FD_MASK_TYPE __fd_mask
  ------------------
  106|       |
  107|     56|    fds_array[n / nfdbits] &= ~(1ULL << (n % nfdbits));
  108|     56|}
large_fd_set.c:LFD_ISSET:
  111|     56|{
  112|     56|    enum { nfdbits = 8 * sizeof(p->fds_bits[0]) };
  113|     56|    const NETSNMP_FD_MASK_TYPE *fds_array = p->fds_bits;
  114|       |
  115|     56|    return (fds_array[n / nfdbits] & (1ULL << (n % nfdbits))) != 0;
  116|     56|}

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

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

netsnmp_init_mib_internals:
  700|  2.90k|{
  701|  2.90k|    register struct tok *tp;
  702|  2.90k|    register int    b, i;
  703|  2.90k|    int             max_modc;
  704|       |
  705|  2.90k|    if (tree_head)
  ------------------
  |  Branch (705:9): [True: 2.85k, False: 57]
  ------------------
  706|  2.85k|        return;
  707|       |
  708|       |    /*
  709|       |     * Set up hash list of pre-defined tokens
  710|       |     */
  711|     57|    memset(buckets, 0, sizeof(buckets));
  712|  5.30k|    for (tp = tokens; tp->name; tp++) {
  ------------------
  |  Branch (712:23): [True: 5.24k, False: 57]
  ------------------
  713|  5.24k|        tp->hash = name_hash(tp->name);
  714|  5.24k|        b = BUCKET(tp->hash);
  ------------------
  |  |  527|  5.24k|#define BUCKET(x)       (x & (HASHSIZE-1))
  |  |  ------------------
  |  |  |  |  526|  5.24k|#define HASHSIZE        32
  |  |  ------------------
  ------------------
  715|  5.24k|        if (buckets[b])
  ------------------
  |  Branch (715:13): [True: 3.42k, False: 1.82k]
  ------------------
  716|  3.42k|            tp->next = buckets[b];      /* BUG ??? */
  717|  5.24k|        buckets[b] = tp;
  718|  5.24k|    }
  719|       |
  720|       |    /*
  721|       |     * Initialise other internal structures
  722|       |     */
  723|       |
  724|     57|    max_modc = sizeof(module_map) / sizeof(module_map[0]) - 1;
  725|  1.25k|    for (i = 0; i < max_modc; ++i)
  ------------------
  |  Branch (725:17): [True: 1.19k, False: 57]
  ------------------
  726|  1.19k|        module_map[i].next = &(module_map[i + 1]);
  727|     57|    module_map[max_modc].next = NULL;
  728|     57|    module_map_head = module_map;
  729|       |
  730|     57|    memset(nbuckets, 0, sizeof(nbuckets));
  731|     57|    memset(tbuckets, 0, sizeof(tbuckets));
  732|     57|    free(tclist);
  733|     57|    tc_alloc = TC_INCR;
  ------------------
  |  |  134|     57|#define TC_INCR 100
  ------------------
  734|     57|    tclist = calloc(tc_alloc, sizeof(struct tc));
  735|     57|    build_translation_table();
  736|     57|    init_tree_roots();          /* Set up initial roots */
  737|       |    /*
  738|       |     * Relies on 'add_mibdir' having set up the modules 
  739|       |     */
  740|     57|}
which_module:
 3835|    171|{
 3836|    171|    struct module  *mp;
 3837|       |
 3838|    171|    for (mp = module_head; mp; mp = mp->next)
  ------------------
  |  Branch (3838:28): [True: 0, False: 171]
  ------------------
 3839|      0|        if (!label_compare(mp->name, name))
  ------------------
  |  | 1236|      0|#define	label_compare	strcmp
  ------------------
  |  Branch (3839:13): [True: 0, False: 0]
  ------------------
 3840|      0|            return (mp->modid);
 3841|       |
 3842|    171|    DEBUGMSGTL(("parse-mibs", "Module %s not found\n", name));
  ------------------
  |  |   66|    171|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    171|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 171]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 171]
  |  |  ------------------
  ------------------
 3843|    171|    return (-1);
 3844|    171|}
adopt_orphans:
 4033|     57|{
 4034|     57|    struct node    *np = NULL, *onp;
 4035|     57|    struct tree    *tp;
 4036|     57|    int             i, adopted = 1;
 4037|       |
 4038|     57|    if (!orphan_nodes)
  ------------------
  |  Branch (4038:9): [True: 57, False: 0]
  ------------------
 4039|     57|        return;
 4040|      0|    init_node_hash(orphan_nodes);
 4041|      0|    orphan_nodes = NULL;
 4042|       |
 4043|      0|    while (adopted) {
  ------------------
  |  Branch (4043:12): [True: 0, False: 0]
  ------------------
 4044|      0|        adopted = 0;
 4045|      0|        for (i = 0; i < NHASHSIZE; i++)
  ------------------
  |  |  529|      0|#define NHASHSIZE    128
  ------------------
  |  Branch (4045:21): [True: 0, False: 0]
  ------------------
 4046|      0|            if (nbuckets[i]) {
  ------------------
  |  Branch (4046:17): [True: 0, False: 0]
  ------------------
 4047|      0|                for (np = nbuckets[i]; np != NULL; np = np->next) {
  ------------------
  |  Branch (4047:40): [True: 0, False: 0]
  ------------------
 4048|      0|                    tp = find_tree_node(np->parent, -1);
 4049|      0|		    if (tp) {
  ------------------
  |  Branch (4049:11): [True: 0, False: 0]
  ------------------
 4050|      0|			do_subtree(tp, &np);
 4051|      0|			adopted = 1;
 4052|       |                        /*
 4053|       |                         * if do_subtree adopted the entire bucket, stop
 4054|       |                         */
 4055|      0|                        if(NULL == nbuckets[i])
  ------------------
  |  Branch (4055:28): [True: 0, False: 0]
  ------------------
 4056|      0|                            break;
 4057|       |
 4058|       |                        /*
 4059|       |                         * do_subtree may modify nbuckets, and if np
 4060|       |                         * was adopted, np->next probably isn't an orphan
 4061|       |                         * anymore. if np is still in the bucket (do_subtree
 4062|       |                         * didn't adopt it) keep on plugging. otherwise
 4063|       |                         * start over, at the top of the bucket.
 4064|       |                         */
 4065|      0|                        for(onp = nbuckets[i]; onp; onp = onp->next)
  ------------------
  |  Branch (4065:48): [True: 0, False: 0]
  ------------------
 4066|      0|                            if(onp == np)
  ------------------
  |  Branch (4066:32): [True: 0, False: 0]
  ------------------
 4067|      0|                                break;
 4068|      0|                        if(NULL == onp) { /* not in the list */
  ------------------
  |  Branch (4068:28): [True: 0, False: 0]
  ------------------
 4069|      0|                            np = nbuckets[i]; /* start over */
 4070|      0|                        }
 4071|      0|		    }
 4072|      0|		}
 4073|      0|            }
 4074|      0|    }
 4075|       |
 4076|       |    /*
 4077|       |     * Report on outstanding orphans
 4078|       |     *    and link them back into the orphan list
 4079|       |     */
 4080|      0|    for (i = 0; i < NHASHSIZE; i++)
  ------------------
  |  |  529|      0|#define NHASHSIZE    128
  ------------------
  |  Branch (4080:17): [True: 0, False: 0]
  ------------------
 4081|      0|        if (nbuckets[i]) {
  ------------------
  |  Branch (4081:13): [True: 0, False: 0]
  ------------------
 4082|      0|            if (orphan_nodes)
  ------------------
  |  Branch (4082:17): [True: 0, False: 0]
  ------------------
 4083|      0|                onp = np->next = nbuckets[i];
 4084|      0|            else
 4085|      0|                onp = orphan_nodes = nbuckets[i];
 4086|      0|            nbuckets[i] = NULL;
 4087|      0|            while (onp) {
  ------------------
  |  Branch (4087:20): [True: 0, False: 0]
  ------------------
 4088|      0|                char            modbuf[256];
 4089|      0|                snmp_log(LOG_WARNING,
 4090|      0|                         "Cannot resolve OID in %s: %s ::= { %s %ld } at line %d in %s\n",
 4091|      0|                         module_name(onp->modid, modbuf),
 4092|      0|                         (onp->label ? onp->label : "<no label>"),
  ------------------
  |  Branch (4092:27): [True: 0, False: 0]
  ------------------
 4093|      0|                         (onp->parent ? onp->parent : "<no parent>"),
  ------------------
  |  Branch (4093:27): [True: 0, False: 0]
  ------------------
 4094|      0|                         onp->subid, onp->lineno, onp->filename);
 4095|      0|                np = onp;
 4096|      0|                onp = onp->next;
 4097|      0|            }
 4098|      0|        }
 4099|      0|}
netsnmp_read_module:
 4111|  2.73k|{
 4112|  2.73k|    int status = 0;
 4113|  2.73k|    status = read_module_internal(name);
 4114|       |
 4115|  2.73k|    if (status == MODULE_NOT_FOUND) {
  ------------------
  |  |  513|  2.73k|#define MODULE_NOT_FOUND	0
  ------------------
  |  Branch (4115:9): [True: 2.73k, False: 0]
  ------------------
 4116|  2.73k|        if (!read_module_replacements(name))
  ------------------
  |  Branch (4116:13): [True: 2.73k, False: 0]
  ------------------
 4117|  2.73k|            print_module_not_found(name);
 4118|  2.73k|    } else if (status == MODULE_SYNTAX_ERROR) {
  ------------------
  |  |  520|      0|#define MODULE_SYNTAX_ERROR     4
  ------------------
  |  Branch (4118:16): [True: 0, False: 0]
  ------------------
 4119|      0|        gMibError = 0;
 4120|      0|        gLoop = 1;
 4121|       |
 4122|      0|        strncat(gMibNames, " ", sizeof(gMibNames) - strlen(gMibNames) - 1);
 4123|      0|        strncat(gMibNames, name, sizeof(gMibNames) - strlen(gMibNames) - 1);
 4124|      0|    }
 4125|       |
 4126|  2.73k|    return tree_head;
 4127|  2.73k|}
unload_module_by_ID:
 4136|     57|{
 4137|     57|    struct tree    *tp, *next;
 4138|     57|    int             i;
 4139|       |
 4140|    228|    for (tp = tree_top; tp; tp = next) {
  ------------------
  |  Branch (4140:25): [True: 171, False: 57]
  ------------------
 4141|       |        /*
 4142|       |         * Essentially, this is equivalent to the code fragment:
 4143|       |         *      if (tp->modID == modID)
 4144|       |         *        tp->number_modules--;
 4145|       |         * but handles one tree node being part of several modules,
 4146|       |         * and possible multiple copies of the same module ID.
 4147|       |         */
 4148|    171|        int             nmod = tp->number_modules;
 4149|    171|        if (nmod > 0) {         /* in some module */
  ------------------
  |  Branch (4149:13): [True: 171, False: 0]
  ------------------
 4150|       |            /*
 4151|       |             * Remove all copies of this module ID
 4152|       |             */
 4153|    171|            int             cnt = 0, *pi1, *pi2 = tp->module_list;
 4154|    342|            for (i = 0, pi1 = pi2; i < nmod; i++, pi2++) {
  ------------------
  |  Branch (4154:36): [True: 171, False: 171]
  ------------------
 4155|    171|                if (*pi2 == modID)
  ------------------
  |  Branch (4155:21): [True: 171, False: 0]
  ------------------
 4156|    171|                    continue;
 4157|      0|                cnt++;
 4158|      0|                *pi1++ = *pi2;
 4159|      0|            }
 4160|    171|            if (nmod != cnt) {  /* in this module */
  ------------------
  |  Branch (4160:17): [True: 171, False: 0]
  ------------------
 4161|       |                /*
 4162|       |                 * if ( (nmod - cnt) > 1)
 4163|       |                 * printf("Dup modid %d,  %d times, '%s'\n", tp->modid, (nmod-cnt), tp->label); fflush(stdout); ?* XXDEBUG 
 4164|       |                 */
 4165|    171|                tp->number_modules = cnt;
 4166|    171|                switch (cnt) {
 4167|    171|                case 0:
  ------------------
  |  Branch (4167:17): [True: 171, False: 0]
  ------------------
 4168|    171|                    tp->module_list[0] = -1;    /* Mark unused, */
 4169|    171|		    NETSNMP_FALLTHROUGH;
  ------------------
  |  | 2411|    171|#    define NETSNMP_FALLTHROUGH __attribute__((__fallthrough__))
  ------------------
 4170|       |
 4171|    171|                case 1:        /* save the remaining module */
  ------------------
  |  Branch (4171:17): [True: 0, False: 171]
  ------------------
 4172|    171|                    if (&(tp->modid) != tp->module_list) {
  ------------------
  |  Branch (4172:25): [True: 0, False: 171]
  ------------------
 4173|      0|                        tp->modid = tp->module_list[0];
 4174|      0|                        free(tp->module_list);
 4175|      0|                        tp->module_list = &(tp->modid);
 4176|      0|                    }
 4177|    171|                    break;
 4178|       |
 4179|      0|                default:
  ------------------
  |  Branch (4179:17): [True: 0, False: 171]
  ------------------
 4180|      0|                    break;
 4181|    171|                }
 4182|    171|            }                   /* if tree node is in this module */
 4183|    171|        }
 4184|       |        /*
 4185|       |         * if tree node is in some module 
 4186|       |         */
 4187|    171|        next = tp->next_peer;
 4188|       |
 4189|       |
 4190|       |        /*
 4191|       |         *  OK - that's dealt with *this* node.
 4192|       |         *    Now let's look at the children.
 4193|       |         *    (Isn't recursion wonderful!)
 4194|       |         */
 4195|    171|        if (tp->child_list)
  ------------------
  |  Branch (4195:13): [True: 0, False: 171]
  ------------------
 4196|      0|            unload_module_by_ID(modID, tp->child_list);
 4197|       |
 4198|       |
 4199|    171|        if (tp->number_modules == 0) {
  ------------------
  |  Branch (4199:13): [True: 171, False: 0]
  ------------------
 4200|       |            /*
 4201|       |             * This node isn't needed any more (except perhaps
 4202|       |             * for the sake of the children) 
 4203|       |             */
 4204|    171|            if (tp->child_list == NULL) {
  ------------------
  |  Branch (4204:17): [True: 171, False: 0]
  ------------------
 4205|    171|                unlink_tree(tp);
 4206|    171|                free_tree(tp);
 4207|    171|            } else {
 4208|      0|                free_partial_tree(tp, TRUE);
  ------------------
  |  |  128|      0|#define TRUE  1
  ------------------
 4209|      0|            }
 4210|    171|        }
 4211|    171|    }
 4212|     57|}
unload_all_mibs:
 4249|     57|{
 4250|     57|    struct module  *mp;
 4251|     57|    struct module_compatability *mcp;
 4252|     57|    struct tc      *ptc;
 4253|     57|    unsigned int    i;
 4254|       |
 4255|     57|    for (mcp = module_map_head; mcp; mcp = module_map_head) {
  ------------------
  |  Branch (4255:33): [True: 57, False: 0]
  ------------------
 4256|     57|        if (mcp == module_map)
  ------------------
  |  Branch (4256:13): [True: 57, False: 0]
  ------------------
 4257|     57|            break;
 4258|      0|        module_map_head = mcp->next;
 4259|      0|        if (mcp->tag) free(NETSNMP_REMOVE_CONST(char *, mcp->tag));
  ------------------
  |  |   91|      0|    (__extension__ ({ const t tmp = (e); (t)(size_t)tmp; }))
  ------------------
  |  Branch (4259:13): [True: 0, False: 0]
  ------------------
 4260|      0|        free(NETSNMP_REMOVE_CONST(char *, mcp->old_module));
  ------------------
  |  |   91|      0|    (__extension__ ({ const t tmp = (e); (t)(size_t)tmp; }))
  ------------------
 4261|      0|        free(NETSNMP_REMOVE_CONST(char *, mcp->new_module));
  ------------------
  |  |   91|      0|    (__extension__ ({ const t tmp = (e); (t)(size_t)tmp; }))
  ------------------
 4262|      0|        free(mcp);
 4263|      0|    }
 4264|       |
 4265|     57|    for (mp = module_head; mp; mp = module_head) {
  ------------------
  |  Branch (4265:28): [True: 0, False: 57]
  ------------------
 4266|      0|        struct module_import *mi = mp->imports;
 4267|      0|        if (mi) {
  ------------------
  |  Branch (4267:13): [True: 0, False: 0]
  ------------------
 4268|      0|            for (i = 0; i < (unsigned int)mp->no_imports; ++i) {
  ------------------
  |  Branch (4268:25): [True: 0, False: 0]
  ------------------
 4269|      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]
  |  |  ------------------
  ------------------
 4270|      0|            }
 4271|      0|            mp->no_imports = 0;
 4272|      0|            if (mi == root_imports)
  ------------------
  |  Branch (4272:17): [True: 0, False: 0]
  ------------------
 4273|      0|                memset(mi, 0, sizeof(*mi));
 4274|      0|            else
 4275|      0|                free(mi);
 4276|      0|        }
 4277|       |
 4278|      0|        unload_module_by_ID(mp->modid, tree_head);
 4279|      0|        module_head = mp->next;
 4280|      0|        free(mp->name);
 4281|      0|        free(mp->file);
 4282|      0|        free(mp);
 4283|      0|    }
 4284|     57|    unload_module_by_ID(-1, tree_head);
 4285|       |    /*
 4286|       |     * tree nodes are cleared 
 4287|       |     */
 4288|       |
 4289|  5.75k|    for (i = 0, ptc = tclist; i < tc_alloc; i++, ptc++) {
  ------------------
  |  Branch (4289:31): [True: 5.70k, False: 57]
  ------------------
 4290|  5.70k|        if (ptc->type == 0)
  ------------------
  |  Branch (4290:13): [True: 5.70k, False: 0]
  ------------------
 4291|  5.70k|            continue;
 4292|      0|        free_enums(&ptc->enums);
 4293|      0|        free_ranges(&ptc->ranges);
 4294|      0|        free(ptc->descriptor);
 4295|      0|        if (ptc->hint)
  ------------------
  |  Branch (4295:13): [True: 0, False: 0]
  ------------------
 4296|      0|            free(ptc->hint);
 4297|      0|        if (ptc->description)
  ------------------
  |  Branch (4297:13): [True: 0, False: 0]
  ------------------
 4298|      0|            free(ptc->description);
 4299|      0|    }
 4300|     57|    SNMP_FREE(tclist);
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 4301|     57|    tc_alloc = 0;
 4302|       |
 4303|     57|    memset(buckets, 0, sizeof(buckets));
 4304|     57|    memset(nbuckets, 0, sizeof(nbuckets));
 4305|     57|    memset(tbuckets, 0, sizeof(tbuckets));
 4306|       |
 4307|    228|    for (i = 0; i < sizeof(root_imports) / sizeof(root_imports[0]); i++) {
  ------------------
  |  Branch (4307:17): [True: 171, False: 57]
  ------------------
 4308|    171|        SNMP_FREE(root_imports[i].label);
  ------------------
  |  |   62|    171|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 171, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 171]
  |  |  ------------------
  ------------------
 4309|    171|    }
 4310|       |
 4311|     57|    max_module = 0;
 4312|     57|    current_module = 0;
 4313|     57|    module_map_head = NULL;
 4314|     57|    SNMP_FREE(last_err_module);
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 4315|       |
 4316|     57|    {
 4317|     57|        struct node *np = orphan_nodes;
 4318|       |
 4319|     57|        while (np) {
  ------------------
  |  Branch (4319:16): [True: 0, False: 57]
  ------------------
 4320|      0|            struct node *nnp = np->next;
 4321|      0|            free_node(np);
 4322|      0|            np = nnp;
 4323|      0|        }
 4324|       |        orphan_nodes = NULL;
 4325|     57|    }
 4326|     57|    erroneousMibs = 0;
 4327|     57|    first_err_module = 1;
 4328|     57|}
add_mibdir:
 5124|     57|{
 5125|     57|    const char     *oldFile = File;
 5126|     57|    int             oldLine = mibLine;
 5127|     57|    char          **filenames;
 5128|     57|    int             count = 0;
 5129|     57|    int             filename_count, i;
 5130|       |
 5131|     57|    DEBUGMSGTL(("parse-mibs", "Scanning directory %s\n", dirname));
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 5132|       |
 5133|     57|    filename_count = scan_directory(&filenames, dirname);
 5134|       |
 5135|     57|    if (filename_count >= 0) {
  ------------------
  |  Branch (5135:9): [True: 0, False: 57]
  ------------------
 5136|      0|        for (i = 0; i < filename_count; i++) {
  ------------------
  |  Branch (5136:21): [True: 0, False: 0]
  ------------------
 5137|      0|            if (add_mibfile(filenames[i], strrchr(filenames[i], '/')) == 0)
  ------------------
  |  Branch (5137:17): [True: 0, False: 0]
  ------------------
 5138|      0|                count++;
 5139|      0|	    free(filenames[i]);
 5140|      0|        }
 5141|      0|        File = oldFile;
 5142|      0|        mibLine = oldLine;
 5143|      0|        free(filenames);
 5144|      0|        return (count);
 5145|      0|    }
 5146|     57|    else
 5147|     57|        DEBUGMSGTL(("parse-mibs","cannot open MIB directory %s\n", dirname));
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 5148|       |
 5149|     57|    return (-1);
 5150|     57|}
parse.c:name_hash:
  687|  5.58k|{
  688|  5.58k|    int             hash = 0;
  689|  5.58k|    const char     *cp;
  690|       |
  691|  5.58k|    if (!name)
  ------------------
  |  Branch (691:9): [True: 0, False: 5.58k]
  ------------------
  692|      0|        return 0;
  693|  58.5k|    for (cp = name; *cp; cp++)
  ------------------
  |  Branch (693:21): [True: 53.0k, False: 5.58k]
  ------------------
  694|  53.0k|        hash += tolower((unsigned char)(*cp));
  ------------------
  |  Branch (694:17): [True: 0, False: 0]
  |  Branch (694:17): [True: 0, False: 0]
  |  Branch (694:17): [Folded, False: 53.0k]
  ------------------
  695|  5.58k|    return (hash);
  696|  5.58k|}
parse.c:build_translation_table:
 1071|     57|{
 1072|     57|    int             count;
 1073|       |
 1074|  14.6k|    for (count = 0; count < 256; count++) {
  ------------------
  |  Branch (1074:21): [True: 14.5k, False: 57]
  ------------------
 1075|  14.5k|        switch (count) {
 1076|     57|        case OBJID:
  ------------------
  |  |  167|     57|#define OBJID       (4 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|     57|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1076:9): [True: 57, False: 14.5k]
  ------------------
 1077|     57|            translation_table[count] = TYPE_OBJID;
  ------------------
  |  |  155|     57|#define TYPE_OBJID          1
  ------------------
 1078|     57|            break;
 1079|     57|        case OCTETSTR:
  ------------------
  |  |  168|     57|#define OCTETSTR    (5 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|     57|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1079:9): [True: 57, False: 14.5k]
  ------------------
 1080|     57|            translation_table[count] = TYPE_OCTETSTR;
  ------------------
  |  |  156|     57|#define TYPE_OCTETSTR       2
  ------------------
 1081|     57|            break;
 1082|     57|        case INTEGER:
  ------------------
  |  |  169|     57|#define INTEGER     (6 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|     57|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1082:9): [True: 57, False: 14.5k]
  ------------------
 1083|     57|            translation_table[count] = TYPE_INTEGER;
  ------------------
  |  |  157|     57|#define TYPE_INTEGER        3
  ------------------
 1084|     57|            break;
 1085|     57|        case NETADDR:
  ------------------
  |  |  170|     57|#define NETADDR     (7 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|     57|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1085:9): [True: 57, False: 14.5k]
  ------------------
 1086|     57|            translation_table[count] = TYPE_NETADDR;
  ------------------
  |  |  158|     57|#define TYPE_NETADDR        4
  ------------------
 1087|     57|            break;
 1088|     57|        case IPADDR:
  ------------------
  |  |  171|     57|#define IPADDR      (8 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|     57|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1088:9): [True: 57, False: 14.5k]
  ------------------
 1089|     57|            translation_table[count] = TYPE_IPADDR;
  ------------------
  |  |  159|     57|#define TYPE_IPADDR         5
  ------------------
 1090|     57|            break;
 1091|     57|        case COUNTER:
  ------------------
  |  |  172|     57|#define COUNTER     (9 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|     57|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1091:9): [True: 57, False: 14.5k]
  ------------------
 1092|     57|            translation_table[count] = TYPE_COUNTER;
  ------------------
  |  |  160|     57|#define TYPE_COUNTER        6
  ------------------
 1093|     57|            break;
 1094|     57|        case GAUGE:
  ------------------
  |  |  173|     57|#define GAUGE       (10 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|     57|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1094:9): [True: 57, False: 14.5k]
  ------------------
 1095|     57|            translation_table[count] = TYPE_GAUGE;
  ------------------
  |  |  161|     57|#define TYPE_GAUGE          7
  ------------------
 1096|     57|            break;
 1097|     57|        case TIMETICKS:
  ------------------
  |  |  174|     57|#define TIMETICKS   (11 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|     57|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1097:9): [True: 57, False: 14.5k]
  ------------------
 1098|     57|            translation_table[count] = TYPE_TIMETICKS;
  ------------------
  |  |  162|     57|#define TYPE_TIMETICKS      8
  ------------------
 1099|     57|            break;
 1100|     57|        case KW_OPAQUE:
  ------------------
  |  |  175|     57|#define KW_OPAQUE   (12 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|     57|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1100:9): [True: 57, False: 14.5k]
  ------------------
 1101|     57|            translation_table[count] = TYPE_OPAQUE;
  ------------------
  |  |  163|     57|#define TYPE_OPAQUE         9
  ------------------
 1102|     57|            break;
 1103|     57|        case NUL:
  ------------------
  |  |  176|     57|#define NUL         (13 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|     57|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1103:9): [True: 57, False: 14.5k]
  ------------------
 1104|     57|            translation_table[count] = TYPE_NULL;
  ------------------
  |  |  164|     57|#define TYPE_NULL           10
  ------------------
 1105|     57|            break;
 1106|     57|        case COUNTER64:
  ------------------
  |  |  211|     57|#define COUNTER64   (43 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|     57|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1106:9): [True: 57, False: 14.5k]
  ------------------
 1107|     57|            translation_table[count] = TYPE_COUNTER64;
  ------------------
  |  |  165|     57|#define TYPE_COUNTER64      11
  ------------------
 1108|     57|            break;
 1109|     57|        case BITSTRING:
  ------------------
  |  |  209|     57|#define BITSTRING   (41 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|     57|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1109:9): [True: 57, False: 14.5k]
  ------------------
 1110|     57|            translation_table[count] = TYPE_BITSTRING;
  ------------------
  |  |  166|     57|#define TYPE_BITSTRING      12
  ------------------
 1111|     57|            break;
 1112|     57|        case NSAPADDRESS:
  ------------------
  |  |  210|     57|#define NSAPADDRESS (42 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|     57|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1112:9): [True: 57, False: 14.5k]
  ------------------
 1113|     57|            translation_table[count] = TYPE_NSAPADDRESS;
  ------------------
  |  |  167|     57|#define TYPE_NSAPADDRESS    13
  ------------------
 1114|     57|            break;
 1115|     57|        case INTEGER32:
  ------------------
  |  |  274|     57|#define INTEGER32	(105 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|     57|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1115:9): [True: 57, False: 14.5k]
  ------------------
 1116|     57|            translation_table[count] = TYPE_INTEGER32;
  ------------------
  |  |  170|     57|#define TYPE_INTEGER32      16
  ------------------
 1117|     57|            break;
 1118|     57|        case UINTEGER32:
  ------------------
  |  |  224|     57|#define UINTEGER32 (56 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|     57|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1118:9): [True: 57, False: 14.5k]
  ------------------
 1119|     57|            translation_table[count] = TYPE_UINTEGER;
  ------------------
  |  |  168|     57|#define TYPE_UINTEGER       14
  ------------------
 1120|     57|            break;
 1121|     57|        case UNSIGNED32:
  ------------------
  |  |  273|     57|#define UNSIGNED32	(104 | SYNTAX_MASK)
  |  |  ------------------
  |  |  |  |  157|     57|#define SYNTAX_MASK     0x80
  |  |  ------------------
  ------------------
  |  Branch (1121:9): [True: 57, False: 14.5k]
  ------------------
 1122|     57|            translation_table[count] = TYPE_UNSIGNED32;
  ------------------
  |  |  169|     57|#define TYPE_UNSIGNED32     15
  ------------------
 1123|     57|            break;
 1124|     57|        case TRAPTYPE:
  ------------------
  |  |  229|     57|#define TRAPTYPE    61
  ------------------
  |  Branch (1124:9): [True: 57, False: 14.5k]
  ------------------
 1125|     57|            translation_table[count] = TYPE_TRAPTYPE;
  ------------------
  |  |  174|     57|#define TYPE_TRAPTYPE	    20
  ------------------
 1126|     57|            break;
 1127|     57|        case NOTIFTYPE:
  ------------------
  |  |  213|     57|#define NOTIFTYPE   45
  ------------------
  |  Branch (1127:9): [True: 57, False: 14.5k]
  ------------------
 1128|     57|            translation_table[count] = TYPE_NOTIFTYPE;
  ------------------
  |  |  175|     57|#define TYPE_NOTIFTYPE      21
  ------------------
 1129|     57|            break;
 1130|     57|        case NOTIFGROUP:
  ------------------
  |  |  258|     57|#define NOTIFGROUP  88
  ------------------
  |  Branch (1130:9): [True: 57, False: 14.5k]
  ------------------
 1131|     57|            translation_table[count] = TYPE_NOTIFGROUP;
  ------------------
  |  |  177|     57|#define TYPE_NOTIFGROUP	    23
  ------------------
 1132|     57|            break;
 1133|     57|        case OBJGROUP:
  ------------------
  |  |  212|     57|#define OBJGROUP    44
  ------------------
  |  Branch (1133:9): [True: 57, False: 14.5k]
  ------------------
 1134|     57|            translation_table[count] = TYPE_OBJGROUP;
  ------------------
  |  |  176|     57|#define TYPE_OBJGROUP	    22
  ------------------
 1135|     57|            break;
 1136|     57|        case MODULEIDENTITY:
  ------------------
  |  |  220|     57|#define MODULEIDENTITY 52
  ------------------
  |  Branch (1136:9): [True: 57, False: 14.5k]
  ------------------
 1137|     57|            translation_table[count] = TYPE_MODID;
  ------------------
  |  |  178|     57|#define TYPE_MODID	    24
  ------------------
 1138|     57|            break;
 1139|     57|        case OBJIDENTITY:
  ------------------
  |  |  275|     57|#define OBJIDENTITY	106
  ------------------
  |  Branch (1139:9): [True: 57, False: 14.5k]
  ------------------
 1140|     57|            translation_table[count] = TYPE_OBJIDENTITY;
  ------------------
  |  |  181|     57|#define TYPE_OBJIDENTITY    27
  ------------------
 1141|     57|            break;
 1142|     57|        case AGENTCAP:
  ------------------
  |  |  243|     57|#define AGENTCAP    73
  ------------------
  |  Branch (1142:9): [True: 57, False: 14.5k]
  ------------------
 1143|     57|            translation_table[count] = TYPE_AGENTCAP;
  ------------------
  |  |  179|     57|#define TYPE_AGENTCAP       25
  ------------------
 1144|     57|            break;
 1145|     57|        case COMPLIANCE:
  ------------------
  |  |  215|     57|#define COMPLIANCE  47
  ------------------
  |  Branch (1145:9): [True: 57, False: 14.5k]
  ------------------
 1146|     57|            translation_table[count] = TYPE_MODCOMP;
  ------------------
  |  |  180|     57|#define TYPE_MODCOMP        26
  ------------------
 1147|     57|            break;
 1148|  13.2k|        default:
  ------------------
  |  Branch (1148:9): [True: 13.2k, False: 1.36k]
  ------------------
 1149|  13.2k|            translation_table[count] = TYPE_OTHER;
  ------------------
  |  |  154|  13.2k|#define TYPE_OTHER          0
  ------------------
 1150|  13.2k|            break;
 1151|  14.5k|        }
 1152|  14.5k|    }
 1153|     57|}
parse.c:init_tree_roots:
 1157|     57|{
 1158|     57|    struct tree    *tp, *lasttp;
 1159|     57|    int             base_modid;
 1160|     57|    int             hash;
 1161|       |
 1162|     57|    base_modid = which_module("SNMPv2-SMI");
 1163|     57|    if (base_modid == -1)
  ------------------
  |  Branch (1163:9): [True: 57, False: 0]
  ------------------
 1164|     57|        base_modid = which_module("RFC1155-SMI");
 1165|     57|    if (base_modid == -1)
  ------------------
  |  Branch (1165:9): [True: 57, False: 0]
  ------------------
 1166|     57|        base_modid = which_module("RFC1213-MIB");
 1167|       |
 1168|       |    /*
 1169|       |     * build root node 
 1170|       |     */
 1171|     57|    tp = calloc(1, sizeof(struct tree));
 1172|     57|    if (tp == NULL)
  ------------------
  |  Branch (1172:9): [True: 0, False: 57]
  ------------------
 1173|      0|        return;
 1174|     57|    tp->label = strdup("joint-iso-ccitt");
 1175|     57|    tp->modid = base_modid;
 1176|     57|    tp->number_modules = 1;
 1177|     57|    tp->module_list = &(tp->modid);
 1178|     57|    tp->subid = 2;
 1179|     57|    tp->tc_index = -1;
 1180|     57|    set_function(tp);           /* from mib.c */
 1181|     57|    hash = NBUCKET(name_hash(tp->label));
  ------------------
  |  |  530|     57|#define NBUCKET(x)   (x & (NHASHSIZE-1))
  |  |  ------------------
  |  |  |  |  529|     57|#define NHASHSIZE    128
  |  |  ------------------
  ------------------
 1182|     57|    tp->next = tbuckets[hash];
 1183|     57|    tbuckets[hash] = tp;
 1184|     57|    lasttp = tp;
 1185|     57|    root_imports[0].label = strdup(tp->label);
 1186|     57|    root_imports[0].modid = base_modid;
 1187|       |
 1188|       |    /*
 1189|       |     * build root node 
 1190|       |     */
 1191|     57|    tp = calloc(1, sizeof(struct tree));
 1192|     57|    if (tp == NULL)
  ------------------
  |  Branch (1192:9): [True: 0, False: 57]
  ------------------
 1193|      0|        return;
 1194|     57|    tp->next_peer = lasttp;
 1195|     57|    tp->label = strdup("ccitt");
 1196|     57|    tp->modid = base_modid;
 1197|     57|    tp->number_modules = 1;
 1198|     57|    tp->module_list = &(tp->modid);
 1199|     57|    tp->subid = 0;
 1200|     57|    tp->tc_index = -1;
 1201|     57|    set_function(tp);           /* from mib.c */
 1202|     57|    hash = NBUCKET(name_hash(tp->label));
  ------------------
  |  |  530|     57|#define NBUCKET(x)   (x & (NHASHSIZE-1))
  |  |  ------------------
  |  |  |  |  529|     57|#define NHASHSIZE    128
  |  |  ------------------
  ------------------
 1203|     57|    tp->next = tbuckets[hash];
 1204|     57|    tbuckets[hash] = tp;
 1205|     57|    lasttp = tp;
 1206|     57|    root_imports[1].label = strdup(tp->label);
 1207|     57|    root_imports[1].modid = base_modid;
 1208|       |
 1209|       |    /*
 1210|       |     * build root node 
 1211|       |     */
 1212|     57|    tp = calloc(1, sizeof(struct tree));
 1213|     57|    if (tp == NULL)
  ------------------
  |  Branch (1213:9): [True: 0, False: 57]
  ------------------
 1214|      0|        return;
 1215|     57|    tp->next_peer = lasttp;
 1216|     57|    tp->label = strdup("iso");
 1217|     57|    tp->modid = base_modid;
 1218|     57|    tp->number_modules = 1;
 1219|     57|    tp->module_list = &(tp->modid);
 1220|     57|    tp->subid = 1;
 1221|     57|    tp->tc_index = -1;
 1222|     57|    set_function(tp);           /* from mib.c */
 1223|     57|    hash = NBUCKET(name_hash(tp->label));
  ------------------
  |  |  530|     57|#define NBUCKET(x)   (x & (NHASHSIZE-1))
  |  |  ------------------
  |  |  |  |  529|     57|#define NHASHSIZE    128
  |  |  ------------------
  ------------------
 1224|     57|    tp->next = tbuckets[hash];
 1225|     57|    tbuckets[hash] = tp;
 1226|     57|    lasttp = tp;
 1227|     57|    root_imports[2].label = strdup(tp->label);
 1228|     57|    root_imports[2].modid = base_modid;
 1229|       |
 1230|     57|    tree_head = tp;
 1231|     57|}
parse.c:unlink_tbucket:
  830|    171|{
  831|    171|    int             hash = NBUCKET(name_hash(tp->label));
  ------------------
  |  |  530|    171|#define NBUCKET(x)   (x & (NHASHSIZE-1))
  |  |  ------------------
  |  |  |  |  529|    171|#define NHASHSIZE    128
  |  |  ------------------
  ------------------
  832|    171|    struct tree    *otp = NULL, *ntp = tbuckets[hash];
  833|       |
  834|    171|    while (ntp && ntp != tp) {
  ------------------
  |  Branch (834:12): [True: 171, False: 0]
  |  Branch (834:19): [True: 0, False: 171]
  ------------------
  835|      0|        otp = ntp;
  836|      0|        ntp = ntp->next;
  837|      0|    }
  838|    171|    if (!ntp)
  ------------------
  |  Branch (838:9): [True: 0, False: 171]
  ------------------
  839|      0|        snmp_log(LOG_EMERG, "Can't find %s in tbuckets\n", tp->label);
  840|    171|    else if (otp)
  ------------------
  |  Branch (840:14): [True: 0, False: 171]
  ------------------
  841|      0|        otp->next = ntp->next;
  842|    171|    else
  843|    171|        tbuckets[hash] = tp->next;
  844|    171|}
parse.c:read_module_internal:
 4019|  2.73k|{
 4020|  2.73k|    struct module  *mp;
 4021|       |
 4022|  2.73k|    netsnmp_init_mib_internals();
 4023|       |
 4024|  2.73k|    for (mp = module_head; mp; mp = mp->next)
  ------------------
  |  Branch (4024:28): [True: 0, False: 2.73k]
  ------------------
 4025|      0|        if (!label_compare(mp->name, name))
  ------------------
  |  | 1236|      0|#define	label_compare	strcmp
  ------------------
  |  Branch (4025:13): [True: 0, False: 0]
  ------------------
 4026|      0|            return read_from_file(mp, name);
 4027|       |
 4028|  2.73k|    return MODULE_NOT_FOUND;
  ------------------
  |  |  513|  2.73k|#define MODULE_NOT_FOUND	0
  ------------------
 4029|  2.73k|}
parse.c:print_error:
  780|  2.73k|{
  781|  2.73k|    erroneousMibs++;
  782|  2.73k|    if (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|  2.73k|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (782:9): [True: 0, False: 2.73k]
  ------------------
  783|  2.73k|                                NETSNMP_DS_LIB_MIB_ERRORS))
  ------------------
  |  |   59|  2.73k|#define NETSNMP_DS_LIB_MIB_ERRORS          0
  ------------------
  784|      0|	return;
  785|  2.73k|    DEBUGMSGTL(("parse-mibs", "\n"));
  ------------------
  |  |   66|  2.73k|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|  2.73k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 2.73k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%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.73k]
  |  |  ------------------
  ------------------
  786|  2.73k|    if (type == ENDOFFILE)
  ------------------
  |  |  163|  2.73k|#define ENDOFFILE   0
  ------------------
  |  Branch (786:9): [True: 0, False: 2.73k]
  ------------------
  787|      0|        snmp_log(LOG_ERR, "%s (EOF): At line %d in %s\n", str, mibLine,
  788|      0|                 File);
  789|  2.73k|    else if (token && *token)
  ------------------
  |  Branch (789:14): [True: 2.73k, False: 0]
  |  Branch (789:23): [True: 2.73k, False: 0]
  ------------------
  790|  2.73k|        snmp_log(LOG_ERR, "%s (%s): At line %d in %s\n", str, token,
  791|  2.73k|                 mibLine, File);
  792|      0|    else
  793|      0|        snmp_log(LOG_ERR, "%s: At line %d in %s\n", str, mibLine, File);
  794|  2.73k|}
parse.c:free_indexes:
 5366|    171|{
 5367|    171|    if (spp && *spp) {
  ------------------
  |  Branch (5367:9): [True: 171, False: 0]
  |  Branch (5367:16): [True: 0, False: 171]
  ------------------
 5368|      0|        struct index_list *pp, *npp;
 5369|       |
 5370|      0|        pp = *spp;
 5371|      0|        *spp = NULL;
 5372|       |
 5373|      0|        while (pp) {
  ------------------
  |  Branch (5373:16): [True: 0, False: 0]
  ------------------
 5374|      0|            npp = pp->next;
 5375|      0|            if (pp->ilabel)
  ------------------
  |  Branch (5375:17): [True: 0, False: 0]
  ------------------
 5376|      0|                free(pp->ilabel);
 5377|      0|            free(pp);
 5378|      0|            pp = npp;
 5379|      0|        }
 5380|      0|    }
 5381|    171|}
parse.c:free_varbinds:
 5385|    171|{
 5386|    171|    if (spp && *spp) {
  ------------------
  |  Branch (5386:9): [True: 171, False: 0]
  |  Branch (5386:16): [True: 0, False: 171]
  ------------------
 5387|      0|        struct varbind_list *pp, *npp;
 5388|       |
 5389|      0|        pp = *spp;
 5390|      0|        *spp = NULL;
 5391|       |
 5392|      0|        while (pp) {
  ------------------
  |  Branch (5392:16): [True: 0, False: 0]
  ------------------
 5393|      0|            npp = pp->next;
 5394|      0|            if (pp->vblabel)
  ------------------
  |  Branch (5394:17): [True: 0, False: 0]
  ------------------
 5395|      0|                free(pp->vblabel);
 5396|      0|            free(pp);
 5397|      0|            pp = npp;
 5398|      0|        }
 5399|      0|    }
 5400|    171|}
parse.c:read_module_replacements:
 3899|  2.73k|{
 3900|  2.73k|    struct module_compatability *mcp;
 3901|       |
 3902|  62.9k|    for (mcp = module_map_head; mcp; mcp = mcp->next) {
  ------------------
  |  Branch (3902:33): [True: 60.1k, False: 2.73k]
  ------------------
 3903|  60.1k|        if (!label_compare(mcp->old_module, name)) {
  ------------------
  |  | 1236|  60.1k|#define	label_compare	strcmp
  ------------------
  |  Branch (3903:13): [True: 0, False: 60.1k]
  ------------------
 3904|      0|            if (netsnmp_ds_get_int(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|      0|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (3904:17): [True: 0, False: 0]
  ------------------
 3905|      0|				   NETSNMP_DS_LIB_MIB_WARNINGS)) {
  ------------------
  |  |  114|      0|#define NETSNMP_DS_LIB_MIB_WARNINGS         0
  ------------------
 3906|      0|                snmp_log(LOG_WARNING,
 3907|      0|                         "Loading replacement module %s for %s (%s)\n",
 3908|      0|                         mcp->new_module, name, File);
 3909|      0|	    }
 3910|      0|            (void) netsnmp_read_module(mcp->new_module);
 3911|      0|            return 1;
 3912|      0|        }
 3913|  60.1k|    }
 3914|  2.73k|    return 0;
 3915|  2.73k|}
parse.c:print_module_not_found:
  798|  2.73k|{
  799|  2.73k|    if (first_err_module) {
  ------------------
  |  Branch (799:9): [True: 57, False: 2.67k]
  ------------------
  800|     57|        snmp_log(LOG_ERR, "MIB search path: %s\n",
  801|     57|                           netsnmp_get_mib_directory());
  802|     57|        first_err_module = 0;
  803|     57|    }
  804|  2.73k|    if (!last_err_module || strcmp(cp, last_err_module))
  ------------------
  |  Branch (804:9): [True: 57, False: 2.67k]
  |  Branch (804:29): [True: 2.67k, False: 0]
  ------------------
  805|  2.73k|        print_error("Cannot find module", cp, CONTINUE);
  ------------------
  |  |  162|  2.73k|#define CONTINUE    -1
  ------------------
  806|  2.73k|    if (last_err_module)
  ------------------
  |  Branch (806:9): [True: 2.67k, False: 57]
  ------------------
  807|  2.67k|        free(last_err_module);
  808|  2.73k|    last_err_module = strdup(cp);
  809|  2.73k|}
parse.c:unlink_tree:
  848|    171|{
  849|    171|    struct tree    *otp = NULL, *ntp = tp->parent;
  850|       |
  851|    171|    if (!ntp) {                 /* this tree has no parent */
  ------------------
  |  Branch (851:9): [True: 171, False: 0]
  ------------------
  852|    171|        DEBUGMSGTL(("unlink_tree", "Tree node %s has no parent\n",
  ------------------
  |  |   66|    171|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    171|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 171]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 171]
  |  |  ------------------
  ------------------
  853|    171|                    tp->label));
  854|    171|    } else {
  855|      0|        ntp = ntp->child_list;
  856|       |
  857|      0|        while (ntp && ntp != tp) {
  ------------------
  |  Branch (857:16): [True: 0, False: 0]
  |  Branch (857:23): [True: 0, False: 0]
  ------------------
  858|      0|            otp = ntp;
  859|      0|            ntp = ntp->next_peer;
  860|      0|        }
  861|      0|        if (!ntp)
  ------------------
  |  Branch (861:13): [True: 0, False: 0]
  ------------------
  862|      0|            snmp_log(LOG_EMERG, "Can't find %s in %s's children\n",
  863|      0|                     tp->label, tp->parent->label);
  864|      0|        else if (otp)
  ------------------
  |  Branch (864:18): [True: 0, False: 0]
  ------------------
  865|      0|            otp->next_peer = ntp->next_peer;
  866|      0|        else
  867|      0|            tp->parent->child_list = tp->next_peer;
  868|      0|    }
  869|       |
  870|    171|    if (tree_head == tp)
  ------------------
  |  Branch (870:9): [True: 171, False: 0]
  ------------------
  871|    171|        tree_head = tp->next_peer;
  872|    171|}
parse.c:free_tree:
  903|    171|{
  904|    171|    if (!Tree)
  ------------------
  |  Branch (904:9): [True: 0, False: 171]
  ------------------
  905|      0|        return;
  906|       |
  907|    171|    unlink_tbucket(Tree);
  908|    171|    free_partial_tree(Tree, FALSE);
  ------------------
  |  |  125|    171|#define FALSE 0
  ------------------
  909|    171|    if (Tree->module_list != &Tree->modid)
  ------------------
  |  Branch (909:9): [True: 0, False: 171]
  ------------------
  910|      0|        free(Tree->module_list);
  911|    171|    free(Tree);
  912|    171|}
parse.c:free_partial_tree:
  876|    171|{
  877|    171|    if (!tp)
  ------------------
  |  Branch (877:9): [True: 0, False: 171]
  ------------------
  878|      0|        return;
  879|       |
  880|       |    /*
  881|       |     * remove the data from this tree node 
  882|       |     */
  883|    171|    free_enums(&tp->enums);
  884|    171|    free_ranges(&tp->ranges);
  885|    171|    free_indexes(&tp->indexes);
  886|    171|    free_varbinds(&tp->varbinds);
  887|    171|    if (!keep_label)
  ------------------
  |  Branch (887:9): [True: 171, False: 0]
  ------------------
  888|    171|        SNMP_FREE(tp->label);
  ------------------
  |  |   62|    171|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 171, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 171]
  |  |  ------------------
  ------------------
  889|    171|    SNMP_FREE(tp->hint);
  ------------------
  |  |   62|    171|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 171]
  |  |  |  Branch (62:66): [Folded, False: 171]
  |  |  ------------------
  ------------------
  890|    171|    SNMP_FREE(tp->units);
  ------------------
  |  |   62|    171|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 171]
  |  |  |  Branch (62:66): [Folded, False: 171]
  |  |  ------------------
  ------------------
  891|    171|    SNMP_FREE(tp->description);
  ------------------
  |  |   62|    171|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 171]
  |  |  |  Branch (62:66): [Folded, False: 171]
  |  |  ------------------
  ------------------
  892|    171|    SNMP_FREE(tp->reference);
  ------------------
  |  |   62|    171|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 171]
  |  |  |  Branch (62:66): [Folded, False: 171]
  |  |  ------------------
  ------------------
  893|    171|    SNMP_FREE(tp->augments);
  ------------------
  |  |   62|    171|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 171]
  |  |  |  Branch (62:66): [Folded, False: 171]
  |  |  ------------------
  ------------------
  894|       |    SNMP_FREE(tp->defaultValue);
  ------------------
  |  |   62|    171|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 171]
  |  |  |  Branch (62:66): [Folded, False: 171]
  |  |  ------------------
  ------------------
  895|    171|}
parse.c:scan_directory:
 5054|     57|{
 5055|     57|    DIR            *dir, *dir2;
 5056|     57|    struct dirent  *file;
 5057|     57|    char          **filenames = NULL;
 5058|     57|    int             fname_len, i, filename_count = 0, array_size = 0;
 5059|     57|    char           *tmpstr;
 5060|       |
 5061|     57|    *result = NULL;
 5062|       |
 5063|     57|    dir = opendir(dirname);
 5064|     57|    if (!dir)
  ------------------
  |  Branch (5064:9): [True: 57, False: 0]
  ------------------
 5065|     57|        return -1;
 5066|       |
 5067|      0|    while ((file = readdir(dir))) {
  ------------------
  |  Branch (5067:12): [True: 0, False: 0]
  ------------------
 5068|       |        /*
 5069|       |         * Only parse file names that don't begin with a '.'
 5070|       |         * Also skip files ending in '~', or starting/ending
 5071|       |         * with '#' which are typically editor backup files.
 5072|       |         */
 5073|      0|        fname_len = strlen(file->d_name);
 5074|      0|        if (fname_len > 0 && file->d_name[0] != '.'
  ------------------
  |  Branch (5074:13): [True: 0, False: 0]
  |  Branch (5074:30): [True: 0, False: 0]
  ------------------
 5075|      0|            && file->d_name[0] != '#'
  ------------------
  |  Branch (5075:16): [True: 0, False: 0]
  ------------------
 5076|      0|            && file->d_name[fname_len-1] != '#'
  ------------------
  |  Branch (5076:16): [True: 0, False: 0]
  ------------------
 5077|      0|            && file->d_name[fname_len-1] != '~') {
  ------------------
  |  Branch (5077:16): [True: 0, False: 0]
  ------------------
 5078|      0|            if (asprintf(&tmpstr, "%s/%s", dirname, file->d_name) < 0)
  ------------------
  |  Branch (5078:17): [True: 0, False: 0]
  ------------------
 5079|      0|                continue;
 5080|      0|            dir2 = opendir(tmpstr);
 5081|      0|            if (dir2) {
  ------------------
  |  Branch (5081:17): [True: 0, False: 0]
  ------------------
 5082|       |                /* file is a directory, don't read it */
 5083|      0|                closedir(dir2);
 5084|      0|            } else {
 5085|      0|                if (filename_count >= array_size) {
  ------------------
  |  Branch (5085:21): [True: 0, False: 0]
  ------------------
 5086|      0|                    char **new_filenames;
 5087|       |
 5088|      0|                    array_size = (array_size + 16) * 2;
 5089|      0|                    new_filenames = realloc(filenames,
 5090|      0|                                        array_size * sizeof(filenames[0]));
 5091|      0|                    if (!new_filenames) {
  ------------------
  |  Branch (5091:25): [True: 0, False: 0]
  ------------------
 5092|      0|                        free(tmpstr);
 5093|      0|                        for (i = 0; i < filename_count; i++)
  ------------------
  |  Branch (5093:37): [True: 0, False: 0]
  ------------------
 5094|      0|                            free(filenames[i]);
 5095|      0|                        free(filenames);
 5096|      0|                        closedir(dir);
 5097|      0|                        return -1;
 5098|      0|                    }
 5099|      0|                    filenames = new_filenames;
 5100|      0|                }
 5101|      0|                filenames[filename_count++] = tmpstr;
 5102|      0|                tmpstr = NULL;
 5103|      0|            }
 5104|      0|            free(tmpstr);
 5105|      0|        }
 5106|      0|    }
 5107|      0|    closedir(dir);
 5108|       |
 5109|      0|    if (filenames)
  ------------------
  |  Branch (5109:9): [True: 0, False: 0]
  ------------------
 5110|      0|        qsort(filenames, filename_count, sizeof(filenames[0]), elemcmp);
 5111|      0|    *result = filenames;
 5112|       |
 5113|      0|    return filename_count;
 5114|      0|}
parse.c:free_ranges:
 5404|    171|{
 5405|    171|    if (spp && *spp) {
  ------------------
  |  Branch (5405:9): [True: 171, False: 0]
  |  Branch (5405:16): [True: 0, False: 171]
  ------------------
 5406|      0|        struct range_list *pp, *npp;
 5407|       |
 5408|      0|        pp = *spp;
 5409|      0|        *spp = NULL;
 5410|       |
 5411|      0|        while (pp) {
  ------------------
  |  Branch (5411:16): [True: 0, False: 0]
  ------------------
 5412|      0|            npp = pp->next;
 5413|      0|            free(pp);
 5414|      0|            pp = npp;
 5415|      0|        }
 5416|      0|    }
 5417|    171|}
parse.c:free_enums:
 5421|    171|{
 5422|    171|    if (spp && *spp) {
  ------------------
  |  Branch (5422:9): [True: 171, False: 0]
  |  Branch (5422:16): [True: 0, False: 171]
  ------------------
 5423|      0|        struct enum_list *pp, *npp;
 5424|       |
 5425|      0|        pp = *spp;
 5426|      0|        *spp = NULL;
 5427|       |
 5428|      0|        while (pp) {
  ------------------
  |  Branch (5428:16): [True: 0, False: 0]
  ------------------
 5429|      0|            npp = pp->next;
 5430|      0|            if (pp->label)
  ------------------
  |  Branch (5430:17): [True: 0, False: 0]
  ------------------
 5431|      0|                free(pp->label);
 5432|      0|            free(pp);
 5433|      0|            pp = npp;
 5434|      0|        }
 5435|      0|    }
 5436|    171|}

register_prenetsnmp_mib_handler:
  256|  1.99k|{
  257|  1.99k|    return internal_register_config_handler(type, token, parser, NULL, releaser,
  258|  1.99k|					    help, PREMIB_CONFIG);
  ------------------
  |  |   15|  1.99k|#define PREMIB_CONFIG 1
  ------------------
  259|  1.99k|}
register_config_handler:
  311|  3.59k|{
  312|  3.59k|    return internal_register_config_handler(type, token, parser, NULL, releaser,
  313|  3.59k|					    help, NORMAL_CONFIG);
  ------------------
  |  |   14|  3.59k|#define NORMAL_CONFIG 0
  ------------------
  314|  3.59k|}
register_const_config_handler:
  321|     57|{
  322|     57|    return internal_register_config_handler(type, token, NULL, parser, releaser,
  323|     57|					    help, NORMAL_CONFIG);
  ------------------
  |  |   14|     57|#define NORMAL_CONFIG 0
  ------------------
  324|     57|}
register_app_config_handler:
  330|    114|{
  331|       |    return register_config_handler(NULL, token, parser, releaser, help);
  332|    114|}
unregister_config_handler:
  356|  9.51k|{
  357|  9.51k|    struct config_files **ctmp = &config_files;
  358|  9.51k|    struct config_line  **ltmp;
  359|  9.51k|    const char           *type = type_param;
  360|       |
  361|  9.51k|    if (type == NULL || *type == '\0') {
  ------------------
  |  Branch (361:9): [True: 0, False: 9.51k]
  |  Branch (361:25): [True: 0, False: 9.51k]
  ------------------
  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.51k|    if (strchr(type, ':')) {
  ------------------
  |  Branch (369:9): [True: 0, False: 9.51k]
  ------------------
  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.51k|    while (*ctmp != NULL && strcmp((*ctmp)->fileHeader, type)) {
  ------------------
  |  Branch (389:12): [True: 5.75k, False: 3.76k]
  |  Branch (389:29): [True: 0, False: 5.75k]
  ------------------
  390|      0|        ctmp = &((*ctmp)->next);
  391|      0|    }
  392|       |
  393|  9.51k|    if (*ctmp == NULL) {
  ------------------
  |  Branch (393:9): [True: 3.76k, False: 5.75k]
  ------------------
  394|       |        /*
  395|       |         * Not found, return. 
  396|       |         */
  397|  3.76k|        return;
  398|  3.76k|    }
  399|       |
  400|  5.75k|    ltmp = &((*ctmp)->start);
  401|  5.75k|    if (*ltmp == NULL) {
  ------------------
  |  Branch (401:9): [True: 0, False: 5.75k]
  ------------------
  402|       |        /*
  403|       |         * Not found, return. 
  404|       |         */
  405|      0|        return;
  406|      0|    }
  407|  5.75k|    if (strcmp((*ltmp)->config_token, token) == 0) {
  ------------------
  |  Branch (407:9): [True: 5.75k, False: 0]
  ------------------
  408|       |        /*
  409|       |         * found it at the top of the list 
  410|       |         */
  411|  5.75k|        struct config_line *ltmp2 = (*ltmp)->next;
  412|  5.75k|        if ((*ltmp)->free_func)
  ------------------
  |  Branch (412:13): [True: 399, False: 5.35k]
  ------------------
  413|    399|            (*ltmp)->free_func();
  414|  5.75k|        SNMP_FREE((*ltmp)->config_token);
  ------------------
  |  |   62|  5.75k|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 5.75k, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 5.75k]
  |  |  ------------------
  ------------------
  415|  5.75k|        SNMP_FREE((*ltmp)->help);
  ------------------
  |  |   62|  5.75k|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 5.07k, False: 684]
  |  |  |  Branch (62:66): [Folded, False: 5.75k]
  |  |  ------------------
  ------------------
  416|  5.75k|        SNMP_FREE(*ltmp);
  ------------------
  |  |   62|  5.75k|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 5.75k, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 5.75k]
  |  |  ------------------
  ------------------
  417|  5.75k|        (*ctmp)->start = ltmp2;
  418|  5.75k|        return;
  419|  5.75k|    }
  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|     57|{
  446|     57|    struct config_files *ctmp, *save;
  447|     57|    struct config_line *ltmp;
  448|       |
  449|       |    /*
  450|       |     * Keep using config_files until there are no more! 
  451|       |     */
  452|    171|    for (ctmp = config_files; ctmp;) {
  ------------------
  |  Branch (452:31): [True: 114, False: 57]
  ------------------
  453|  5.87k|        for (ltmp = ctmp->start; ltmp; ltmp = ctmp->start) {
  ------------------
  |  Branch (453:34): [True: 5.75k, False: 114]
  ------------------
  454|  5.75k|            unregister_config_handler(ctmp->fileHeader,
  455|  5.75k|                                      ltmp->config_token);
  456|  5.75k|        }
  457|    114|        SNMP_FREE(ctmp->fileHeader);
  ------------------
  |  |   62|    114|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 114, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 114]
  |  |  ------------------
  ------------------
  458|    114|        save = ctmp->next;
  459|       |        SNMP_FREE(ctmp);
  ------------------
  |  |   62|    114|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 114, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 114]
  |  |  ------------------
  ------------------
  460|    114|        ctmp = save;
  461|    114|        config_files = save;
  462|    114|    }
  463|     57|}
netsnmp_config_remember_free_list:
  691|     57|{
  692|     57|    struct read_config_memory *tmpmem;
  693|     57|    while (*mem) {
  ------------------
  |  Branch (693:12): [True: 0, False: 57]
  ------------------
  694|      0|        SNMP_FREE((*mem)->line);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 0]
  |  |  ------------------
  ------------------
  695|      0|        tmpmem = (*mem)->next;
  696|       |        SNMP_FREE(*mem);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 0]
  |  |  ------------------
  ------------------
  697|      0|        *mem = tmpmem;
  698|      0|    }
  699|     57|}
netsnmp_config_process_memory_list:
  704|    114|{
  705|       |
  706|    114|    struct read_config_memory *mem;
  707|       |
  708|    114|    if (!memp)
  ------------------
  |  Branch (708:9): [True: 0, False: 114]
  ------------------
  709|      0|        return;
  710|       |
  711|    114|    mem = *memp;
  712|       |
  713|    114|    while (mem) {
  ------------------
  |  Branch (713:12): [True: 0, False: 114]
  ------------------
  714|      0|        DEBUGMSGTL(("read_config:mem", "processing memory: %s\n", mem->line));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
  715|      0|        snmp_config_when(mem->line, when);
  716|      0|        mem = mem->next;
  717|      0|    }
  718|       |
  719|    114|    if (clear)
  ------------------
  |  Branch (719:9): [True: 57, False: 57]
  ------------------
  720|     57|        netsnmp_config_remember_free_list(memp);
  721|    114|}
netsnmp_config_process_memories_when:
  742|    114|{
  743|    114|    netsnmp_config_process_memory_list(&memorylist, when, clear);
  744|    114|}
free_config:
 1029|     57|{
 1030|     57|    struct config_files *ctmp = config_files;
 1031|     57|    struct config_line *ltmp;
 1032|       |
 1033|    171|    for (; ctmp != NULL; ctmp = ctmp->next)
  ------------------
  |  Branch (1033:12): [True: 114, False: 57]
  ------------------
 1034|  5.87k|        for (ltmp = ctmp->start; ltmp != NULL; ltmp = ltmp->next)
  ------------------
  |  Branch (1034:34): [True: 5.75k, False: 114]
  ------------------
 1035|  5.75k|            if (ltmp->free_func)
  ------------------
  |  Branch (1035:17): [True: 399, False: 5.35k]
  ------------------
 1036|    399|                (*(ltmp->free_func)) ();
 1037|     57|}
read_configs:
 1082|     57|{
 1083|     57|    char *optional_config = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|     57|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1084|     57|					       NETSNMP_DS_LIB_OPTIONALCONFIG);
  ------------------
  |  |  156|     57|#define NETSNMP_DS_LIB_OPTIONALCONFIG    5
  ------------------
 1085|       |
 1086|     57|    snmp_call_callbacks(SNMP_CALLBACK_LIBRARY,
  ------------------
  |  |   18|     57|#define SNMP_CALLBACK_LIBRARY     0
  ------------------
 1087|     57|                        SNMP_CALLBACK_PRE_READ_CONFIG, NULL);
  ------------------
  |  |   30|     57|#define SNMP_CALLBACK_PRE_READ_CONFIG	        7
  ------------------
 1088|       |
 1089|     57|    DEBUGMSGTL(("read_config", "reading normal configuration tokens\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]
  |  |  ------------------
  ------------------
 1090|       |
 1091|     57|    if ((NULL != optional_config) && (*optional_config == '-')) {
  ------------------
  |  Branch (1091:9): [True: 0, False: 57]
  |  Branch (1091:38): [True: 0, False: 0]
  ------------------
 1092|      0|        (void)read_configs_optional(++optional_config, NORMAL_CONFIG);
  ------------------
  |  |   14|      0|#define NORMAL_CONFIG 0
  ------------------
 1093|      0|        optional_config = NULL; /* clear, so we don't read them twice */
 1094|      0|    }
 1095|       |
 1096|     57|    (void)read_config_files(NORMAL_CONFIG);
  ------------------
  |  |   14|     57|#define NORMAL_CONFIG 0
  ------------------
 1097|       |
 1098|       |    /*
 1099|       |     * do this even when the normal above wasn't done 
 1100|       |     */
 1101|     57|    if (NULL != optional_config)
  ------------------
  |  Branch (1101:9): [True: 0, False: 57]
  ------------------
 1102|      0|        (void)read_configs_optional(optional_config, NORMAL_CONFIG);
  ------------------
  |  |   14|      0|#define NORMAL_CONFIG 0
  ------------------
 1103|       |
 1104|     57|    netsnmp_config_process_memories_when(NORMAL_CONFIG, 1);
  ------------------
  |  |   14|     57|#define NORMAL_CONFIG 0
  ------------------
 1105|       |
 1106|     57|    netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|     57|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1107|     57|			   NETSNMP_DS_LIB_HAVE_READ_CONFIG, 1);
  ------------------
  |  |   87|     57|#define NETSNMP_DS_LIB_HAVE_READ_CONFIG    27   /* have the config tokens been processed */
  ------------------
 1108|     57|    snmp_call_callbacks(SNMP_CALLBACK_LIBRARY,
  ------------------
  |  |   18|     57|#define SNMP_CALLBACK_LIBRARY     0
  ------------------
 1109|     57|                        SNMP_CALLBACK_POST_READ_CONFIG, NULL);
  ------------------
  |  |   24|     57|#define SNMP_CALLBACK_POST_READ_CONFIG	        0
  ------------------
 1110|     57|}
read_premib_configs:
 1114|     57|{
 1115|     57|    char *optional_config = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|     57|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1116|     57|					       NETSNMP_DS_LIB_OPTIONALCONFIG);
  ------------------
  |  |  156|     57|#define NETSNMP_DS_LIB_OPTIONALCONFIG    5
  ------------------
 1117|       |
 1118|     57|    snmp_call_callbacks(SNMP_CALLBACK_LIBRARY,
  ------------------
  |  |   18|     57|#define SNMP_CALLBACK_LIBRARY     0
  ------------------
 1119|     57|                        SNMP_CALLBACK_PRE_PREMIB_READ_CONFIG, NULL);
  ------------------
  |  |   31|     57|#define SNMP_CALLBACK_PRE_PREMIB_READ_CONFIG	8
  ------------------
 1120|       |
 1121|     57|    DEBUGMSGTL(("read_config", "reading premib configuration tokens\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]
  |  |  ------------------
  ------------------
 1122|       |
 1123|     57|    if ((NULL != optional_config) && (*optional_config == '-')) {
  ------------------
  |  Branch (1123:9): [True: 0, False: 57]
  |  Branch (1123:38): [True: 0, False: 0]
  ------------------
 1124|      0|        (void)read_configs_optional(++optional_config, PREMIB_CONFIG);
  ------------------
  |  |   15|      0|#define PREMIB_CONFIG 1
  ------------------
 1125|      0|        optional_config = NULL; /* clear, so we don't read them twice */
 1126|      0|    }
 1127|       |
 1128|     57|    (void)read_config_files(PREMIB_CONFIG);
  ------------------
  |  |   15|     57|#define PREMIB_CONFIG 1
  ------------------
 1129|       |
 1130|     57|    if (NULL != optional_config)
  ------------------
  |  Branch (1130:9): [True: 0, False: 57]
  ------------------
 1131|      0|        (void)read_configs_optional(optional_config, PREMIB_CONFIG);
  ------------------
  |  |   15|      0|#define PREMIB_CONFIG 1
  ------------------
 1132|       |
 1133|     57|    netsnmp_config_process_memories_when(PREMIB_CONFIG, 0);
  ------------------
  |  |   15|     57|#define PREMIB_CONFIG 1
  ------------------
 1134|       |
 1135|     57|    netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|     57|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1136|     57|			   NETSNMP_DS_LIB_HAVE_READ_PREMIB_CONFIG, 1);
  ------------------
  |  |   86|     57|#define NETSNMP_DS_LIB_HAVE_READ_PREMIB_CONFIG 26       /* have the pre-mib parsing config tokens been processed */
  ------------------
 1137|     57|    snmp_call_callbacks(SNMP_CALLBACK_LIBRARY,
  ------------------
  |  |   18|     57|#define SNMP_CALLBACK_LIBRARY     0
  ------------------
 1138|     57|                        SNMP_CALLBACK_POST_PREMIB_READ_CONFIG, NULL);
  ------------------
  |  |   27|     57|#define SNMP_CALLBACK_POST_PREMIB_READ_CONFIG	3
  ------------------
 1139|     57|}
set_configuration_directory:
 1151|      1|{
 1152|      1|    netsnmp_ds_set_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1153|      1|			  NETSNMP_DS_LIB_CONFIGURATION_DIR, dir);
  ------------------
  |  |  160|      1|#define NETSNMP_DS_LIB_CONFIGURATION_DIR 9
  ------------------
 1154|      1|}
get_configuration_directory:
 1170|      1|{
 1171|      1|    char            defaultPath[SPRINT_MAX_LEN];
 1172|      1|    const char     *homepath;
 1173|       |
 1174|      1|    if (NULL == netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (1174:9): [True: 1, False: 0]
  ------------------
 1175|      1|				      NETSNMP_DS_LIB_CONFIGURATION_DIR)) {
  ------------------
  |  |  160|      1|#define NETSNMP_DS_LIB_CONFIGURATION_DIR 9
  ------------------
 1176|      1|        homepath = netsnmp_gethomedir();
 1177|      1|        snprintf(defaultPath, sizeof(defaultPath), "%s%c%s%c%s%s%s%s",
 1178|      1|                SNMPCONFPATH, ENV_SEPARATOR_CHAR,
  ------------------
  |  | 2030|      1|#define SNMPCONFPATH "/usr/local/net-snmp-master/etc/snmp"
  ------------------
                              SNMPCONFPATH, ENV_SEPARATOR_CHAR,
  ------------------
  |  |   70|      1|#define ENV_SEPARATOR_CHAR ':'
  ------------------
 1179|      1|                SNMPSHAREPATH, ENV_SEPARATOR_CHAR, SNMPLIBPATH,
  ------------------
  |  | 2029|      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,
  ------------------
  |  | 2028|      1|#define SNMPLIBPATH "/usr/local/net-snmp-master/lib/snmp"
  ------------------
 1180|      1|                ((homepath == NULL) ? "" : ENV_SEPARATOR),
  ------------------
  |  |   67|      1|#define ENV_SEPARATOR ":"
  ------------------
  |  Branch (1180:18): [True: 0, False: 1]
  ------------------
 1181|      1|                ((homepath == NULL) ? "" : homepath),
  ------------------
  |  Branch (1181:18): [True: 0, False: 1]
  ------------------
 1182|      1|                ((homepath == NULL) ? "" : "/.snmp"));
  ------------------
  |  Branch (1182:18): [True: 0, False: 1]
  ------------------
 1183|      1|        defaultPath[ sizeof(defaultPath)-1 ] = 0;
 1184|      1|        set_configuration_directory(defaultPath);
 1185|      1|    }
 1186|      1|    return (netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1187|      1|				  NETSNMP_DS_LIB_CONFIGURATION_DIR));
  ------------------
  |  |  160|      1|#define NETSNMP_DS_LIB_CONFIGURATION_DIR 9
  ------------------
 1188|      1|}
get_persistent_directory:
 1218|      1|{
 1219|      1|    if (NULL == netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (1219:9): [True: 0, False: 1]
  ------------------
 1220|      1|				      NETSNMP_DS_LIB_PERSISTENT_DIR)) {
  ------------------
  |  |  159|      1|#define NETSNMP_DS_LIB_PERSISTENT_DIR    8
  ------------------
 1221|      0|        const char *persdir = netsnmp_getenv("SNMP_PERSISTENT_DIR");
 1222|      0|        if (NULL == persdir)
  ------------------
  |  Branch (1222:13): [True: 0, False: 0]
  ------------------
 1223|      0|            persdir = NETSNMP_PERSISTENT_DIRECTORY;
  ------------------
  |  | 2000|      0|#define NETSNMP_PERSISTENT_DIRECTORY "/var/net-snmp"
  ------------------
 1224|      0|        set_persistent_directory(persdir);
 1225|      0|    }
 1226|      1|    return (netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|      1|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1227|      1|				  NETSNMP_DS_LIB_PERSISTENT_DIR));
  ------------------
  |  |  159|      1|#define NETSNMP_DS_LIB_PERSISTENT_DIR    8
  ------------------
 1228|      1|}
read_config_files_of_type:
 1412|    228|{
 1413|    228|    const char     *confpath, *persfile, *envconfpath;
 1414|    228|    char           *perspath;
 1415|    228|    int             ret = SNMPERR_GENERR;
  ------------------
  |  |  185|    228|#define SNMPERR_GENERR			(-1)
  ------------------
 1416|       |
 1417|    228|    if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|    228|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (1417:9): [True: 228, False: 0]
  ------------------
 1418|    228|                               NETSNMP_DS_LIB_DONT_PERSIST_STATE)
  ------------------
  |  |   92|    228|#define NETSNMP_DS_LIB_DONT_PERSIST_STATE  32	/* don't load config and don't load/save persistent file */
  ------------------
 1419|      0|        || netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      0|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (1419:12): [True: 0, False: 0]
  ------------------
 1420|      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 */
  |  |  ------------------
  ------------------
 1421|    228|        || (NULL == ctmp)) return ret;
  ------------------
  |  Branch (1421:12): [True: 0, False: 0]
  ------------------
 1422|       |
 1423|       |    /*
 1424|       |     * these shouldn't change
 1425|       |     */
 1426|      0|    confpath = get_configuration_directory();
 1427|      0|    persfile = netsnmp_getenv("SNMP_PERSISTENT_FILE");
 1428|      0|    envconfpath = netsnmp_getenv("SNMPCONFPATH");
 1429|       |
 1430|       |
 1431|       |        /*
 1432|       |         * read the config files. strdup() the result of
 1433|       |         * get_persistent_directory() to avoid that parsing the "persistentDir"
 1434|       |         * keyword transforms the perspath pointer into a dangling pointer.
 1435|       |         */
 1436|      0|        perspath = strdup(get_persistent_directory());
 1437|      0|        if (perspath == NULL) {
  ------------------
  |  Branch (1437:13): [True: 0, False: 0]
  ------------------
 1438|      0|            return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
 1439|      0|        }
 1440|      0|        if (envconfpath == NULL) {
  ------------------
  |  Branch (1440:13): [True: 0, False: 0]
  ------------------
 1441|       |            /*
 1442|       |             * read just the config files (no persistent stuff), since
 1443|       |             * persistent path can change via conf file. Then get the
 1444|       |             * current persistent directory, and read files there.
 1445|       |             */
 1446|      0|            if ( read_config_files_in_path(confpath, ctmp, when, perspath,
  ------------------
  |  Branch (1446:18): [True: 0, False: 0]
  ------------------
 1447|      0|                                      persfile) == SNMPERR_SUCCESS )
  ------------------
  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 1448|      0|                ret = SNMPERR_SUCCESS;
  ------------------
  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 1449|      0|            free(perspath);
 1450|      0|            perspath = strdup(get_persistent_directory());
 1451|      0|            if (perspath == NULL) {
  ------------------
  |  Branch (1451:17): [True: 0, False: 0]
  ------------------
 1452|      0|                return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
 1453|      0|            }
 1454|      0|            if ( read_config_files_in_path(perspath, ctmp, when, perspath,
  ------------------
  |  Branch (1454:18): [True: 0, False: 0]
  ------------------
 1455|      0|                                      persfile) == SNMPERR_SUCCESS )
  ------------------
  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 1456|      0|                ret = SNMPERR_SUCCESS;
  ------------------
  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 1457|      0|        }
 1458|      0|        else {
 1459|       |            /*
 1460|       |             * only read path specified by user
 1461|       |             */
 1462|      0|            if ( read_config_files_in_path(envconfpath, ctmp, when, perspath,
  ------------------
  |  Branch (1462:18): [True: 0, False: 0]
  ------------------
 1463|      0|                                      persfile) == SNMPERR_SUCCESS )
  ------------------
  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 1464|      0|                ret = SNMPERR_SUCCESS;
  ------------------
  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 1465|      0|        }
 1466|      0|        free(perspath);
 1467|      0|        return ret;
 1468|      0|}
read_config_files:
 1476|    114|read_config_files(int when) {
 1477|       |
 1478|    114|    struct config_files *ctmp = config_files;
 1479|    114|    int                  ret  = SNMPERR_GENERR;
  ------------------
  |  |  185|    114|#define SNMPERR_GENERR			(-1)
  ------------------
 1480|       |
 1481|    114|    config_errors = 0;
 1482|       |
 1483|    114|    if (when == PREMIB_CONFIG)
  ------------------
  |  |   15|    114|#define PREMIB_CONFIG 1
  ------------------
  |  Branch (1483:9): [True: 57, False: 57]
  ------------------
 1484|     57|        free_config();
 1485|       |
 1486|       |    /*
 1487|       |     * read all config file types 
 1488|       |     */
 1489|    342|    for (; ctmp != NULL; ctmp = ctmp->next) {
  ------------------
  |  Branch (1489:12): [True: 228, False: 114]
  ------------------
 1490|    228|        if ( read_config_files_of_type(when, ctmp) == SNMPERR_SUCCESS )
  ------------------
  |  |  184|    228|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  |  Branch (1490:14): [True: 0, False: 228]
  ------------------
 1491|      0|            ret = SNMPERR_SUCCESS;
  ------------------
  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 1492|    228|    }
 1493|       |
 1494|    114|    if (config_errors) {
  ------------------
  |  Branch (1494:9): [True: 0, False: 114]
  ------------------
 1495|       |        snmp_log(LOG_ERR, "net-snmp: %d error(s) in config file(s)\n",
 1496|      0|                 config_errors);
 1497|      0|    }
 1498|    114|    return ret;
 1499|    114|}
read_config_store:
 1548|    114|{
 1549|    114|#ifdef NETSNMP_PERSISTENT_DIRECTORY
 1550|    114|    char            file[512], *filep;
 1551|    114|    FILE           *fout;
 1552|    114|#ifdef NETSNMP_PERSISTENT_MASK
 1553|    114|    mode_t          oldmask;
 1554|    114|#endif
 1555|       |
 1556|    114|    if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|    114|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (1556:9): [True: 114, False: 0]
  ------------------
 1557|    114|                               NETSNMP_DS_LIB_DONT_PERSIST_STATE)
  ------------------
  |  |   92|    114|#define NETSNMP_DS_LIB_DONT_PERSIST_STATE  32	/* don't load config and don't load/save persistent file */
  ------------------
 1558|      0|     || netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      0|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (1558:9): [True: 0, False: 0]
  ------------------
 1559|    114|                               NETSNMP_DS_LIB_DISABLE_PERSISTENT_LOAD)) return;
  ------------------
  |  |   95|      0|#define NETSNMP_DS_LIB_DISABLE_PERSISTENT_LOAD  35 /* don't load persistent file */
  ------------------
 1560|       |
 1561|       |    /*
 1562|       |     * store configuration directives in the following order of preference:
 1563|       |     * 1. ENV variable SNMP_PERSISTENT_FILE
 1564|       |     * 2. configured <NETSNMP_PERSISTENT_DIRECTORY>/<type>.conf
 1565|       |     */
 1566|      0|    if ((filep = netsnmp_getenv("SNMP_PERSISTENT_FILE")) == NULL) {
  ------------------
  |  Branch (1566:9): [True: 0, False: 0]
  ------------------
 1567|      0|        snprintf(file, sizeof(file),
 1568|      0|                 "%s/%s.conf", get_persistent_directory(), type);
 1569|      0|        filep = file;
 1570|      0|    }
 1571|      0|#ifdef NETSNMP_PERSISTENT_MASK
 1572|      0|    oldmask = umask(NETSNMP_PERSISTENT_MASK);
  ------------------
  |  | 1742|      0|#define NETSNMP_PERSISTENT_MASK 077
  ------------------
 1573|      0|#endif
 1574|      0|    if (mkdirhier(filep, NETSNMP_AGENT_DIRECTORY_MODE, 1)) {
  ------------------
  |  | 2005|      0|#define NETSNMP_AGENT_DIRECTORY_MODE 0700
  ------------------
  |  Branch (1574:9): [True: 0, False: 0]
  ------------------
 1575|      0|        snmp_log(LOG_ERR,
 1576|      0|                 "Failed to create the persistent directory for %s\n",
 1577|      0|                 file);
 1578|      0|    }
 1579|      0|    if ((fout = fopen(filep, "a")) != NULL) {
  ------------------
  |  Branch (1579:9): [True: 0, False: 0]
  ------------------
 1580|      0|        fprintf(fout, "%s", line);
 1581|      0|        if (line[strlen(line)] != '\n')
  ------------------
  |  Branch (1581:13): [True: 0, False: 0]
  ------------------
 1582|      0|            fprintf(fout, "\n");
 1583|      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]
  |  |  ------------------
  ------------------
 1584|      0|        fflush(fout);
 1585|      0|#if defined(HAVE_FSYNC)
 1586|      0|        fsync(fileno(fout));
 1587|       |#elif defined(HAVE__GET_OSFHANDLE)
 1588|       |        {
 1589|       |            int fd;
 1590|       |            HANDLE h;
 1591|       |
 1592|       |            fd = fileno(fout);
 1593|       |            netsnmp_assert(fd != -1);
 1594|       |            /*
 1595|       |             * Use size_t instead of uintptr_t because not all supported
 1596|       |             * Windows compilers support uintptr_t.
 1597|       |             */
 1598|       |            h = (HANDLE)(size_t)_get_osfhandle(fd);
 1599|       |            netsnmp_assert(h != INVALID_HANDLE_VALUE);
 1600|       |            FlushFileBuffers(h);
 1601|       |        }
 1602|       |#endif
 1603|      0|        fclose(fout);
 1604|      0|    } else {
 1605|      0|        if (strcmp(NETSNMP_APPLICATION_CONFIG_TYPE, type) != 0) {
  ------------------
  |  |   22|      0|#define NETSNMP_APPLICATION_CONFIG_TYPE "snmpapp"
  ------------------
  |  Branch (1605:13): [True: 0, False: 0]
  ------------------
 1606|       |            /*
 1607|       |             * Ignore this error in client utilities, they can run with random
 1608|       |             * UID/GID and typically cannot write to /var. Error message just
 1609|       |             * confuses people.
 1610|       |             */
 1611|      0|            snmp_log(LOG_ERR, "read_config_store open failure on %s\n", filep);
 1612|      0|        }
 1613|      0|    }
 1614|      0|#ifdef NETSNMP_PERSISTENT_MASK
 1615|      0|    umask(oldmask);
 1616|      0|#endif
 1617|       |
 1618|      0|#endif
 1619|      0|}                               /* end read_config_store() */
snmp_save_persistent:
 1652|     57|{
 1653|     57|    char            file[512], fileold[SPRINT_MAX_LEN];
 1654|     57|    struct stat     statbuf;
 1655|     57|    int             j;
 1656|       |
 1657|     57|    if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|     57|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (1657:9): [True: 57, False: 0]
  ------------------
 1658|     57|                               NETSNMP_DS_LIB_DONT_PERSIST_STATE)
  ------------------
  |  |   92|     57|#define NETSNMP_DS_LIB_DONT_PERSIST_STATE  32	/* don't load config and don't load/save persistent file */
  ------------------
 1659|      0|     || netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      0|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (1659:9): [True: 0, False: 0]
  ------------------
 1660|     57|                               NETSNMP_DS_LIB_DISABLE_PERSISTENT_SAVE)) return;
  ------------------
  |  |   96|      0|#define NETSNMP_DS_LIB_DISABLE_PERSISTENT_SAVE  36 /* don't save persistent file */
  ------------------
 1661|       |
 1662|      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]
  |  |  ------------------
  ------------------
 1663|      0|    snprintf(file, sizeof(file),
 1664|      0|             "%s/%s.conf", get_persistent_directory(), type);
 1665|      0|    if (stat(file, &statbuf) == 0) {
  ------------------
  |  Branch (1665:9): [True: 0, False: 0]
  ------------------
 1666|      0|        for (j = 0; j <= NETSNMP_MAX_PERSISTENT_BACKUPS; j++) {
  ------------------
  |  | 2012|      0|#define NETSNMP_MAX_PERSISTENT_BACKUPS 10
  ------------------
  |  Branch (1666:21): [True: 0, False: 0]
  ------------------
 1667|      0|            snprintf(fileold, sizeof(fileold),
 1668|      0|                     "%s/%s.%d.conf", get_persistent_directory(), type, j);
 1669|      0|            if (stat(fileold, &statbuf) != 0) {
  ------------------
  |  Branch (1669:17): [True: 0, False: 0]
  ------------------
 1670|      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]
  |  |  ------------------
  ------------------
 1671|      0|                            " saving old config file: %s -> %s.\n", file,
 1672|      0|                            fileold));
 1673|      0|                if (rename(file, fileold)) {
  ------------------
  |  Branch (1673:21): [True: 0, False: 0]
  ------------------
 1674|      0|                    snmp_log(LOG_ERR, "Cannot rename %s to %s\n", file, fileold);
 1675|       |                     /* moving it failed, try nuking it, as leaving
 1676|       |                      * it around is very bad. */
 1677|      0|                    if (unlink(file) == -1)
  ------------------
  |  Branch (1677:25): [True: 0, False: 0]
  ------------------
 1678|      0|                        snmp_log(LOG_ERR, "Cannot unlink %s\n", file);
 1679|      0|                }
 1680|      0|                break;
 1681|      0|            }
 1682|      0|        }
 1683|      0|    }
 1684|       |    /*
 1685|       |     * save a warning header to the top of the new file 
 1686|       |     */
 1687|      0|    snprintf(fileold, sizeof(fileold),
 1688|      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",
 1689|      0|            "#\n# net-snmp (or ucd-snmp) persistent data file.\n#\n############################################################################\n# STOP STOP STOP STOP STOP STOP STOP STOP STOP \n",
 1690|      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",
 1691|      0|            type, type, type,
 1692|      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");
 1693|      0|    read_config_store(type, fileold);
 1694|      0|}
snmp_clean_persistent:
 1716|     57|{
 1717|     57|    char            file[512];
 1718|     57|    struct stat     statbuf;
 1719|     57|    int             j;
 1720|       |
 1721|     57|    if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|     57|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (1721:9): [True: 57, False: 0]
  ------------------
 1722|     57|                               NETSNMP_DS_LIB_DONT_PERSIST_STATE)
  ------------------
  |  |   92|     57|#define NETSNMP_DS_LIB_DONT_PERSIST_STATE  32	/* don't load config and don't load/save persistent file */
  ------------------
 1723|      0|     || netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      0|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (1723:9): [True: 0, False: 0]
  ------------------
 1724|     57|                               NETSNMP_DS_LIB_DISABLE_PERSISTENT_SAVE)) return;
  ------------------
  |  |   96|      0|#define NETSNMP_DS_LIB_DISABLE_PERSISTENT_SAVE  36 /* don't save persistent file */
  ------------------
 1725|       |
 1726|      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]
  |  |  ------------------
  ------------------
 1727|      0|    snprintf(file, sizeof(file),
 1728|      0|             "%s/%s.conf", get_persistent_directory(), type);
 1729|      0|    if (stat(file, &statbuf) == 0) {
  ------------------
  |  Branch (1729:9): [True: 0, False: 0]
  ------------------
 1730|      0|        for (j = 0; j <= NETSNMP_MAX_PERSISTENT_BACKUPS; j++) {
  ------------------
  |  | 2012|      0|#define NETSNMP_MAX_PERSISTENT_BACKUPS 10
  ------------------
  |  Branch (1730:21): [True: 0, False: 0]
  ------------------
 1731|      0|            snprintf(file, sizeof(file),
 1732|      0|                     "%s/%s.%d.conf", get_persistent_directory(), type, j);
 1733|      0|            if (stat(file, &statbuf) == 0) {
  ------------------
  |  Branch (1733:17): [True: 0, False: 0]
  ------------------
 1734|      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]
  |  |  ------------------
  ------------------
 1735|      0|                            " removing old config file: %s\n", file));
 1736|      0|                if (unlink(file) == -1)
  ------------------
  |  Branch (1736:21): [True: 0, False: 0]
  ------------------
 1737|      0|                    snmp_log(LOG_ERR, "Cannot unlink %s\n", file);
 1738|      0|            }
 1739|      0|        }
 1740|      0|    }
 1741|      0|}
skip_white_const:
 1806|    228|{
 1807|    228|    if (ptr == NULL)
  ------------------
  |  Branch (1807:9): [True: 0, False: 228]
  ------------------
 1808|      0|        return (NULL);
 1809|    342|    while (*ptr != 0 && isspace((unsigned char)*ptr))
  ------------------
  |  Branch (1809:12): [True: 228, False: 114]
  |  Branch (1809:25): [True: 114, False: 114]
  ------------------
 1810|    114|        ptr++;
 1811|    228|    if (*ptr == 0 || *ptr == '#')
  ------------------
  |  Branch (1811:9): [True: 114, False: 114]
  |  Branch (1811:22): [True: 0, False: 114]
  ------------------
 1812|    114|        return (NULL);
 1813|    114|    return (ptr);
 1814|    228|}
copy_nword_const:
 1871|    228|{
 1872|    228|    char            quote;
 1873|    228|    if (!from || !to)
  ------------------
  |  Branch (1873:9): [True: 0, False: 228]
  |  Branch (1873:18): [True: 0, False: 228]
  ------------------
 1874|      0|        return NULL;
 1875|    228|    if ((*from == '\"') || (*from == '\'')) {
  ------------------
  |  Branch (1875:9): [True: 0, False: 228]
  |  Branch (1875:28): [True: 0, False: 228]
  ------------------
 1876|      0|        quote = *(from++);
 1877|      0|        while ((*from != quote) && (*from != 0)) {
  ------------------
  |  Branch (1877:16): [True: 0, False: 0]
  |  Branch (1877:36): [True: 0, False: 0]
  ------------------
 1878|      0|            if ((*from == '\\') && (*(from + 1) != 0)) {
  ------------------
  |  Branch (1878:17): [True: 0, False: 0]
  |  Branch (1878:36): [True: 0, False: 0]
  ------------------
 1879|      0|                if (len > 0) {  /* don't copy beyond len bytes */
  ------------------
  |  Branch (1879:21): [True: 0, False: 0]
  ------------------
 1880|      0|                    *to++ = *(from + 1);
 1881|      0|                    if (--len == 0)
  ------------------
  |  Branch (1881:25): [True: 0, False: 0]
  ------------------
 1882|      0|                        *(to - 1) = '\0';       /* null protect the last spot */
 1883|      0|                }
 1884|      0|                from = from + 2;
 1885|      0|            } else {
 1886|      0|                if (len > 0) {  /* don't copy beyond len bytes */
  ------------------
  |  Branch (1886:21): [True: 0, False: 0]
  ------------------
 1887|      0|                    *to++ = *from++;
 1888|      0|                    if (--len == 0)
  ------------------
  |  Branch (1888:25): [True: 0, False: 0]
  ------------------
 1889|      0|                        *(to - 1) = '\0';       /* null protect the last spot */
 1890|      0|                } else
 1891|      0|                    from++;
 1892|      0|            }
 1893|      0|        }
 1894|      0|        if (*from == 0) {
  ------------------
  |  Branch (1894:13): [True: 0, False: 0]
  ------------------
 1895|      0|            DEBUGMSGTL(("read_config_copy_word",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1896|      0|                        "no end quote found in config string\n"));
 1897|      0|        } else
 1898|      0|            from++;
 1899|    228|    } else {
 1900|  1.02k|        while (*from != 0 && !isspace((unsigned char)(*from))) {
  ------------------
  |  Branch (1900:16): [True: 912, False: 114]
  |  Branch (1900:30): [True: 798, False: 114]
  ------------------
 1901|    798|            if ((*from == '\\') && (*(from + 1) != 0)) {
  ------------------
  |  Branch (1901:17): [True: 0, False: 798]
  |  Branch (1901:36): [True: 0, False: 0]
  ------------------
 1902|      0|                if (len > 0) {  /* don't copy beyond len bytes */
  ------------------
  |  Branch (1902:21): [True: 0, False: 0]
  ------------------
 1903|      0|                    *to++ = *(from + 1);
 1904|      0|                    if (--len == 0)
  ------------------
  |  Branch (1904:25): [True: 0, False: 0]
  ------------------
 1905|      0|                        *(to - 1) = '\0';       /* null protect the last spot */
 1906|      0|                }
 1907|      0|                from = from + 2;
 1908|    798|            } else {
 1909|    798|                if (len > 0) {  /* don't copy beyond len bytes */
  ------------------
  |  Branch (1909:21): [True: 798, False: 0]
  ------------------
 1910|    798|                    *to++ = *from++;
 1911|    798|                    if (--len == 0)
  ------------------
  |  Branch (1911:25): [True: 0, False: 798]
  ------------------
 1912|      0|                        *(to - 1) = '\0';       /* null protect the last spot */
 1913|    798|                } else
 1914|      0|                    from++;
 1915|    798|            }
 1916|    798|        }
 1917|    228|    }
 1918|    228|    if (len > 0)
  ------------------
  |  Branch (1918:9): [True: 228, False: 0]
  ------------------
 1919|    228|        *to = 0;
 1920|    228|    from = skip_white_const(from);
 1921|    228|    return (from);
 1922|    228|}                               /* copy_nword */
read_config_save_octet_string:
 1963|     57|{
 1964|     57|    size_t          i;
 1965|     57|    const u_char   *cp;
 1966|       |
 1967|       |    /*
 1968|       |     * is everything easily printable
 1969|       |     */
 1970|     57|    for (i = 0, cp = str; i < len && cp &&
  ------------------
  |  Branch (1970:27): [True: 57, False: 0]
  |  Branch (1970:38): [True: 57, False: 0]
  ------------------
 1971|     57|         (isalpha(*cp) || isdigit(*cp) || *cp == ' '); cp++, i++);
  ------------------
  |  Branch (1971:11): [True: 0, False: 57]
  |  Branch (1971:27): [True: 0, False: 57]
  |  Branch (1971:43): [True: 0, False: 57]
  ------------------
 1972|       |
 1973|     57|    if (len != 0 && i == len) {
  ------------------
  |  Branch (1973:9): [True: 57, False: 0]
  |  Branch (1973:21): [True: 0, False: 57]
  ------------------
 1974|      0|        *saveto++ = '"';
 1975|      0|        memcpy(saveto, str, len);
 1976|      0|        saveto += len;
 1977|      0|        *saveto++ = '"';
 1978|      0|        *saveto = '\0';
 1979|     57|    } else {
 1980|     57|        if (str != NULL) {
  ------------------
  |  Branch (1980:13): [True: 57, False: 0]
  ------------------
 1981|     57|            sprintf(saveto, "0x");
 1982|     57|            saveto += 2;
 1983|  1.02k|            for (i = 0; i < len; i++) {
  ------------------
  |  Branch (1983:25): [True: 969, False: 57]
  ------------------
 1984|    969|                sprintf(saveto, "%02x", str[i]);
 1985|    969|                saveto = saveto + 2;
 1986|    969|            }
 1987|     57|        } else {
 1988|      0|            sprintf(saveto, "\"\"");
 1989|      0|            saveto += 2;
 1990|      0|        }
 1991|     57|    }
 1992|     57|    return saveto;
 1993|     57|}
read_config.c:internal_register_config_handler:
  153|  5.87k|{
  154|  5.87k|    struct config_files **ctmp = &config_files;
  155|  5.87k|    struct config_line  **ltmp;
  156|  5.87k|    const char           *type = type_param;
  157|       |
  158|  5.87k|    if (type == NULL || *type == '\0') {
  ------------------
  |  Branch (158:9): [True: 114, False: 5.75k]
  |  Branch (158:25): [True: 114, False: 5.64k]
  ------------------
  159|    228|        type = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|    228|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  160|    228|				     NETSNMP_DS_LIB_APPTYPE);
  ------------------
  |  |  157|    228|#define NETSNMP_DS_LIB_APPTYPE           6
  ------------------
  161|    228|    }
  162|       |
  163|       |    /*
  164|       |     * Handle multiple types (recursively)
  165|       |     */
  166|  5.87k|    if (strchr(type, ':')) {
  ------------------
  |  Branch (166:9): [True: 114, False: 5.75k]
  ------------------
  167|    114|        struct config_line *ltmp2 = NULL;
  168|    114|        char                buf[STRINGMAX];
  169|    114|        char               *cptr = buf;
  170|       |
  171|    114|        strlcpy(buf, type, STRINGMAX);
  ------------------
  |  |   12|    114|#define STRINGMAX 1024
  ------------------
  172|    342|        while (cptr) {
  ------------------
  |  Branch (172:16): [True: 228, False: 114]
  ------------------
  173|    228|            char* c = cptr;
  174|    228|            cptr = strchr(cptr, ':');
  175|    228|            if(cptr) {
  ------------------
  |  Branch (175:16): [True: 114, False: 114]
  ------------------
  176|    114|                *cptr = '\0';
  177|    114|                ++cptr;
  178|    114|            }
  179|    228|            ltmp2 = internal_register_config_handler(c, token, parser1, parser2,
  180|    228|                                                     releaser, help, when);
  181|    228|        }
  182|    114|        return ltmp2;
  183|    114|    }
  184|       |    
  185|       |    /*
  186|       |     * Find type in current list  -OR-  create a new file type.
  187|       |     */
  188|  6.72k|    while (*ctmp != NULL && strcmp((*ctmp)->fileHeader, type)) {
  ------------------
  |  Branch (188:12): [True: 6.61k, False: 114]
  |  Branch (188:29): [True: 969, False: 5.64k]
  ------------------
  189|    969|        ctmp = &((*ctmp)->next);
  190|    969|    }
  191|       |
  192|  5.75k|    if (*ctmp == NULL) {
  ------------------
  |  Branch (192:9): [True: 114, False: 5.64k]
  ------------------
  193|    114|        *ctmp = (struct config_files *)
  194|    114|            calloc(1, sizeof(struct config_files));
  195|    114|        if (!*ctmp) {
  ------------------
  |  Branch (195:13): [True: 0, False: 114]
  ------------------
  196|      0|            return NULL;
  197|      0|        }
  198|       |
  199|    114|        (*ctmp)->fileHeader = strdup(type);
  200|    114|        if (!(*ctmp)->fileHeader) {
  ------------------
  |  Branch (200:13): [True: 0, False: 114]
  ------------------
  201|      0|            free(*ctmp);
  202|      0|            *ctmp = NULL;
  203|      0|            return NULL;
  204|      0|        }
  205|    114|        DEBUGMSGTL(("9:read_config:type", "new type %s\n", type));
  ------------------
  |  |   66|    114|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    114|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 114]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 114]
  |  |  ------------------
  ------------------
  206|    114|    }
  207|       |
  208|  5.75k|    DEBUGMSGTL(("9:read_config:register_handler", "registering %s %s\n",
  ------------------
  |  |   66|  5.75k|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|  5.75k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 5.75k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%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.75k]
  |  |  ------------------
  ------------------
  209|  5.75k|                type, token));
  210|       |    /*
  211|       |     * Find parser type in current list  -OR-  create a new
  212|       |     * line parser entry.
  213|       |     */
  214|  5.75k|    ltmp = &((*ctmp)->start);
  215|       |
  216|   212k|    while (*ltmp != NULL && strcmp((*ltmp)->config_token, token)) {
  ------------------
  |  Branch (216:12): [True: 206k, False: 5.75k]
  |  Branch (216:29): [True: 206k, False: 0]
  ------------------
  217|   206k|        ltmp = &((*ltmp)->next);
  218|   206k|    }
  219|       |
  220|  5.75k|    if (*ltmp == NULL) {
  ------------------
  |  Branch (220:9): [True: 5.75k, False: 0]
  ------------------
  221|  5.75k|        *ltmp = (struct config_line *)
  222|  5.75k|            calloc(1, sizeof(struct config_line));
  223|  5.75k|        if (!*ltmp) {
  ------------------
  |  Branch (223:13): [True: 0, False: 5.75k]
  ------------------
  224|      0|            return NULL;
  225|      0|        }
  226|       |
  227|  5.75k|        (*ltmp)->config_time = when;
  228|  5.75k|        (*ltmp)->config_token = strdup(token);
  229|  5.75k|        if (!(*ltmp)->config_token) {
  ------------------
  |  Branch (229:13): [True: 0, False: 5.75k]
  ------------------
  230|      0|            free(*ltmp);
  231|      0|            *ltmp = NULL;
  232|      0|            return NULL;
  233|      0|        }
  234|       |
  235|  5.75k|        if (help != NULL)
  ------------------
  |  Branch (235:13): [True: 5.07k, False: 684]
  ------------------
  236|  5.07k|            (*ltmp)->help = strdup(help);
  237|  5.75k|    }
  238|       |
  239|       |    /*
  240|       |     * Add/Replace the parse/free functions for the given line type
  241|       |     * in the given file type.
  242|       |     */
  243|  5.75k|    (*ltmp)->parse_line1 = parser1;
  244|  5.75k|    (*ltmp)->parse_line2 = parser2;
  245|  5.75k|    (*ltmp)->free_func = releaser;
  246|       |
  247|  5.75k|    return (*ltmp);
  248|       |
  249|  5.75k|}                               /* end register_config_handler() */

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

netsnmp_sd_listen_fds:
   72|     57|int netsnmp_sd_listen_fds(int unset_environment) {
   73|       |
   74|     57|        int r, fd;
   75|     57|        const char *e;
   76|     57|        char *p = NULL;
   77|     57|        unsigned long l;
   78|       |
   79|     57|        if (!(e = getenv("LISTEN_PID"))) {
  ------------------
  |  Branch (79:13): [True: 57, False: 0]
  ------------------
   80|     57|                r = 0;
   81|     57|                goto finish;
   82|     57|        }
   83|       |
   84|     57|        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|     57|finish:
  141|     57|        if (unset_environment) {
  ------------------
  |  Branch (141:13): [True: 0, False: 57]
  ------------------
  142|      0|                unsetenv("LISTEN_PID");
  143|      0|                unsetenv("LISTEN_FDS");
  144|      0|        }
  145|       |
  146|     57|        return r;
  147|      0|}
netsnmp_sd_find_inet_socket:
  356|     57|{
  357|     57|    int count, fd;
  358|       |
  359|     57|    count = netsnmp_sd_listen_fds(0);
  360|     57|    if (count <= 0) {
  ------------------
  |  Branch (360:9): [True: 57, False: 0]
  ------------------
  361|     57|        DEBUGMSGTL(("systemd:find_inet_socket", "No LISTEN_FDS found.\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]
  |  |  ------------------
  ------------------
  362|     57|        return -1;
  363|     57|    }
  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|     57|{
   64|     57|    start_alarms = 1;
   65|     57|    set_an_alarm();
   66|     57|    return SNMPERR_SUCCESS;
  ------------------
  |  |  184|     57|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
   67|     57|}
init_snmp_alarm:
   71|     57|{
   72|     57|    start_alarms = 0;
   73|     57|    snmp_register_callback(SNMP_CALLBACK_LIBRARY,
  ------------------
  |  |   18|     57|#define SNMP_CALLBACK_LIBRARY     0
  ------------------
   74|     57|                           SNMP_CALLBACK_POST_READ_CONFIG,
  ------------------
  |  |   24|     57|#define SNMP_CALLBACK_POST_READ_CONFIG	        0
  ------------------
   75|       |                           init_alarm_post_config, NULL);
   76|     57|}
snmp_alarm_unregister_all:
  156|     57|{
  157|     57|  struct snmp_alarm *sa_ptr, *sa_tmp;
  158|       |
  159|     57|  for (sa_ptr = thealarms; sa_ptr != NULL; sa_ptr = sa_tmp) {
  ------------------
  |  Branch (159:28): [True: 0, False: 57]
  ------------------
  160|      0|    sa_tmp = sa_ptr->next;
  161|      0|    free(sa_ptr);
  162|      0|  }
  163|     57|  DEBUGMSGTL(("snmp_alarm", "ALL alarms unregistered\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]
  |  |  ------------------
  ------------------
  164|       |  thealarms = NULL;
  165|     57|}  
sa_find_next:
  169|     57|{
  170|     57|    struct snmp_alarm *a, *lowest = NULL;
  171|       |
  172|     57|    for (a = thealarms; a != NULL; a = a->next)
  ------------------
  |  Branch (172:25): [True: 0, False: 57]
  ------------------
  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|     57|    return lowest;
  178|     57|}
netsnmp_get_next_alarm_time:
  253|     57|{
  254|     57|    struct snmp_alarm *sa_ptr;
  255|       |
  256|     57|    sa_ptr = sa_find_next();
  257|       |
  258|     57|    if (sa_ptr) {
  ------------------
  |  Branch (258:9): [True: 0, False: 57]
  ------------------
  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
  |  |  |  |  ------------------
  |  |  |  |  |  | 1702|      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
  |  |  |  |  ------------------
  |  |  |  |  |  | 1702|      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|     57|    } else {
  267|     57|        return 0;
  268|     57|    }
  269|     57|}
get_next_alarm_delay_time:
  282|     57|{
  283|     57|    struct timeval t_now, alarm_tm;
  284|     57|    int res;
  285|       |
  286|     57|    netsnmp_get_monotonic_clock(&t_now);
  287|     57|    res = netsnmp_get_next_alarm_time(&alarm_tm, &t_now);
  288|     57|    if (res)
  ------------------
  |  Branch (288:9): [True: 0, False: 57]
  ------------------
  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|     57|    return res;
  291|     57|}
set_an_alarm:
  296|     57|{
  297|     57|    struct timeval  delta;
  298|     57|    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|     57|    if (nextalarm && !netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      0|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (306:9): [True: 0, False: 57]
  |  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|     57|    } else {
  326|     57|        DEBUGMSGTL(("snmp_alarm", "no alarms found to schedule\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]
  |  |  ------------------
  ------------------
  327|     57|    }
  328|     57|}

netsnmp_max_send_msg_size:
  382|    114|{
  383|    114|    u_int max = netsnmp_ds_get_int(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|    114|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  384|    114|                                   NETSNMP_DS_LIB_MSG_SEND_MAX);
  ------------------
  |  |  132|    114|#define NETSNMP_DS_LIB_MSG_SEND_MAX        16 /* global max response size */
  ------------------
  385|    114|    if (0 == max)
  ------------------
  |  Branch (385:9): [True: 114, False: 0]
  ------------------
  386|    114|        max = SNMP_MAX_PACKET_LEN;
  ------------------
  |  |   49|    114|#define SNMP_MAX_PACKET_LEN (0x7fffffff)
  ------------------
  387|      0|    else if (max < SNMP_MIN_MAX_LEN)
  ------------------
  |  |   48|      0|#define SNMP_MIN_MAX_LEN    484 /* minimum maximum message size */
  ------------------
  |  Branch (387:14): [True: 0, False: 0]
  ------------------
  388|      0|        max = SNMP_MIN_MAX_LEN; /* minimum max size per SNMP specs */
  ------------------
  |  |   48|      0|#define SNMP_MIN_MAX_LEN    484 /* minimum maximum message size */
  ------------------
  389|      0|    else if (max > SNMP_MAX_PACKET_LEN)
  ------------------
  |  |   49|      0|#define SNMP_MAX_PACKET_LEN (0x7fffffff)
  ------------------
  |  Branch (389:14): [True: 0, False: 0]
  ------------------
  390|      0|        max = SNMP_MAX_PACKET_LEN;
  ------------------
  |  |   49|      0|#define SNMP_MAX_PACKET_LEN (0x7fffffff)
  ------------------
  391|       |
  392|    114|    return max;
  393|    114|}
snmp_get_next_sessid:
  486|     57|{
  487|     57|    long            retVal;
  488|     57|    snmp_res_lock(MT_LIBRARY_ID, MT_LIB_SESSIONID);
  ------------------
  |  |   79|     57|#define snmp_res_lock(x,y) do {} while (0)
  |  |  ------------------
  |  |  |  Branch (79:41): [Folded, False: 57]
  |  |  ------------------
  ------------------
  489|     57|    retVal = 1 + Sessid;        /*MTCRITICAL_RESOURCE */
  490|     57|    if (!retVal)
  ------------------
  |  Branch (490:9): [True: 0, False: 57]
  ------------------
  491|      0|        retVal = 2;
  492|     57|    Sessid = retVal;
  493|     57|    if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_16BIT_IDS))
  ------------------
  |  |   48|     57|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                  if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_16BIT_IDS))
  ------------------
  |  |   91|     57|#define NETSNMP_DS_LIB_16BIT_IDS           31   /* restrict requestIDs, etc to 16-bit values */
  ------------------
  |  Branch (493:9): [True: 0, False: 57]
  ------------------
  494|      0|        retVal &= 0x7fff;	/* mask to 15 bits */
  495|     57|    else
  496|     57|        retVal &= 0x7fffffff;	/* mask to 31 bits */
  497|       |
  498|     57|    if (!retVal) {
  ------------------
  |  Branch (498:9): [True: 0, False: 57]
  ------------------
  499|      0|        Sessid = retVal = 2;
  500|      0|    }
  501|     57|    snmp_res_unlock(MT_LIBRARY_ID, MT_LIB_SESSIONID);
  ------------------
  |  |   80|     57|#define snmp_res_unlock(x,y) do {} while (0)
  |  |  ------------------
  |  |  |  Branch (80:43): [Folded, False: 57]
  |  |  ------------------
  ------------------
  502|     57|    return retVal;
  503|     57|}
snmp_get_next_transid:
  507|     25|{
  508|     25|    long            retVal;
  509|     25|    snmp_res_lock(MT_LIBRARY_ID, MT_LIB_TRANSID);
  ------------------
  |  |   79|     25|#define snmp_res_lock(x,y) do {} while (0)
  |  |  ------------------
  |  |  |  Branch (79:41): [Folded, False: 25]
  |  |  ------------------
  ------------------
  510|     25|    retVal = 1 + Transid;       /*MTCRITICAL_RESOURCE */
  511|     25|    if (!retVal)
  ------------------
  |  Branch (511:9): [True: 0, False: 25]
  ------------------
  512|      0|        retVal = 2;
  513|     25|    Transid = retVal;
  514|     25|    if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_16BIT_IDS))
  ------------------
  |  |   48|     25|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                  if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_16BIT_IDS))
  ------------------
  |  |   91|     25|#define NETSNMP_DS_LIB_16BIT_IDS           31   /* restrict requestIDs, etc to 16-bit values */
  ------------------
  |  Branch (514:9): [True: 0, False: 25]
  ------------------
  515|      0|        retVal &= 0x7fff;	/* mask to 15 bits */
  516|     25|    else
  517|     25|        retVal &= 0x7fffffff;	/* mask to 31 bits */
  518|       |
  519|     25|    if (!retVal) {
  ------------------
  |  Branch (519:9): [True: 0, False: 25]
  ------------------
  520|      0|        Transid = retVal = 2;
  521|      0|    }
  522|     25|    snmp_res_unlock(MT_LIBRARY_ID, MT_LIB_TRANSID);
  ------------------
  |  |   80|     25|#define snmp_res_unlock(x,y) do {} while (0)
  |  |  ------------------
  |  |  |  Branch (80:43): [Folded, False: 25]
  |  |  ------------------
  ------------------
  523|     25|    return retVal;
  524|     25|}
snmp_set_detail:
  538|     39|{
  539|     39|    if (detail_string != NULL) {
  ------------------
  |  Branch (539:9): [True: 39, False: 0]
  ------------------
  540|     39|        strlcpy(snmp_detail, detail_string, sizeof(snmp_detail));
  541|     39|        snmp_detail_f = 1;
  542|     39|    }
  543|     39|}
snmp_api_errstring:
  553|      3|{
  554|      3|    const char     *msg = "";
  555|      3|    static char     msg_buf[SPRINT_MAX_LEN];
  556|       |
  557|      3|    if (snmp_errnumber >= SNMPERR_MAX && snmp_errnumber <= SNMPERR_GENERR) {
  ------------------
  |  |  255|      6|#define SNMPERR_MAX			(-69)
  ------------------
                  if (snmp_errnumber >= SNMPERR_MAX && snmp_errnumber <= SNMPERR_GENERR) {
  ------------------
  |  |  185|      3|#define SNMPERR_GENERR			(-1)
  ------------------
  |  Branch (557:9): [True: 3, False: 0]
  |  Branch (557:42): [True: 0, False: 3]
  ------------------
  558|      0|        msg = api_errors[-snmp_errnumber];
  559|      3|    } else if (snmp_errnumber != SNMPERR_SUCCESS) {
  ------------------
  |  |  184|      3|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  |  Branch (559:16): [True: 0, False: 3]
  ------------------
  560|      0|        msg = NULL;
  561|      0|    }
  562|      3|    if (!msg) {
  ------------------
  |  Branch (562:9): [True: 0, False: 3]
  ------------------
  563|      0|	snprintf(msg_buf, sizeof(msg_buf), "Unknown error: %d", snmp_errnumber);
  564|      0|        msg_buf[sizeof(msg_buf)-1] = '\0';
  565|      3|    } else if (snmp_detail_f) {
  ------------------
  |  Branch (565:16): [True: 3, False: 0]
  ------------------
  566|      3|        snprintf(msg_buf, sizeof(msg_buf), "%s (%s)", msg, snmp_detail);
  567|      3|        msg_buf[sizeof(msg_buf)-1] = '\0';
  568|      3|        snmp_detail_f = 0;
  569|      3|    } else {
  570|      0|        strlcpy(msg_buf, msg, sizeof(msg_buf));
  571|      0|    }
  572|       |
  573|      3|    return (msg_buf);
  574|      3|}
netsnmp_random:
  661|    171|{
  662|    171|#if defined(HAVE_RANDOM)
  663|       |    /*
  664|       |     * The function random() is a more sophisticated random number generator
  665|       |     * which uses nonlinear feedback and an internal table that is 124 bytes
  666|       |     * (992 bits) long. The function returns random values that are 32 bits in
  667|       |     * length. All of the bits generated by random() are usable. The random()
  668|       |     * function is adequate for simulations and games, but should not be used
  669|       |     * for security related applications such as picking cryptographic keys or
  670|       |     * simulating one-time pads.
  671|       |     */
  672|    171|    return random();
  673|       |#elif defined(HAVE_LRAND48)
  674|       |    /*
  675|       |     * As with random(), lrand48() provides excellent random numbers for
  676|       |     * simulations and games, but should not be used for security-related
  677|       |     * applications such as picking cryptographic keys or simulating one-time
  678|       |     * pads; linear congruential algorithms are too easy to break.
  679|       |     */
  680|       |    return lrand48();
  681|       |#elif defined(HAVE_RAND)
  682|       |    /*
  683|       |     * The original UNIX random number generator, rand(), is not a very good
  684|       |     * random number generator. It uses a 32-bit seed and maintains a 32-bit
  685|       |     * internal state.
  686|       |     */
  687|       |    return rand();
  688|       |#else
  689|       |#error "Neither random(), nor lrand48() nor rand() are available"
  690|       |#endif
  691|    171|}
netsnmp_srandom:
  694|     57|{
  695|     57|#if defined(HAVE_SRANDOM)
  696|     57|    srandom(seed);
  697|       |#elif defined(HAVE_SRAND48)
  698|       |    srand48(seed);
  699|       |#elif defined(HAVE_SRAND)
  700|       |    srand(seed);
  701|       |#else
  702|       |#error "Neither srandom(), nor srand48() nor srand() are available"
  703|       |#endif
  704|     57|}
snmp_sess_init:
  797|     57|{
  798|     57|    _init_snmp();
  799|       |
  800|       |    /*
  801|       |     * initialize session to default values 
  802|       |     */
  803|       |
  804|     57|    memset(session, 0, sizeof(netsnmp_session));
  805|     57|    session->timeout = SNMP_DEFAULT_TIMEOUT;
  ------------------
  |  |   80|     57|#define SNMP_DEFAULT_TIMEOUT	    -1
  ------------------
  806|     57|    session->retries = SNMP_DEFAULT_RETRIES;
  ------------------
  |  |   79|     57|#define SNMP_DEFAULT_RETRIES	    -1
  ------------------
  807|     57|    session->version = SNMP_DEFAULT_VERSION;
  ------------------
  |  |   90|     57|#define SNMP_DEFAULT_VERSION	    -1
  ------------------
  808|     57|    session->securityModel = SNMP_DEFAULT_SECMODEL;
  ------------------
  |  |   91|     57|#define SNMP_DEFAULT_SECMODEL	    -1
  ------------------
  809|     57|    session->rcvMsgMaxSize = netsnmp_max_send_msg_size();
  810|     57|    session->sndMsgMaxSize = netsnmp_max_send_msg_size();
  811|     57|    session->flags |= SNMP_FLAGS_DONT_PROBE;
  ------------------
  |  |  155|     57|#define SNMP_FLAGS_DONT_PROBE      0x100      /* don't probe for an engineID */
  ------------------
  812|     57|}
init_snmp:
  901|     57|{
  902|     57|    if (init_snmp_init_done) {
  ------------------
  |  Branch (902:9): [True: 0, False: 57]
  ------------------
  903|      0|        return;
  904|      0|    }
  905|       |
  906|     57|    init_snmp_init_done = 1;
  907|       |
  908|       |    /*
  909|       |     * make the type available everywhere else 
  910|       |     */
  911|     57|    if (type && !netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|     57|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (911:9): [True: 57, False: 0]
  |  Branch (911:17): [True: 57, False: 0]
  ------------------
  912|     57|				       NETSNMP_DS_LIB_APPTYPE)) {
  ------------------
  |  |  157|     57|#define NETSNMP_DS_LIB_APPTYPE           6
  ------------------
  913|     57|        netsnmp_ds_set_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|     57|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  914|     57|			      NETSNMP_DS_LIB_APPTYPE, type);
  ------------------
  |  |  157|     57|#define NETSNMP_DS_LIB_APPTYPE           6
  ------------------
  915|     57|    }
  916|       |
  917|     57|    _init_snmp();
  918|       |
  919|       |    /*
  920|       |     * set our current locale properly to initialize isprint() type functions 
  921|       |     *
  922|       |     * Do not use setlocale on qnx, it is buggy 
  923|       |     * https://www.qnx.com/developers/docs/7.1/#com.qnx.doc.neutrino.lib_ref/topic/s/setlocale.html
  924|       |     */
  925|     57|#if defined(HAVE_SETLOCALE) && !defined(__QNX__)
  926|     57|    setlocale(LC_CTYPE, "");
  927|     57|#endif
  928|       |
  929|     57|    snmp_debug_init();    /* should be done first, to turn on debugging ASAP */
  930|     57|    netsnmp_container_init_list();
  931|     57|    init_callbacks();
  932|     57|    init_snmp_logging();
  933|     57|    snmp_init_statistics();
  934|     57|    register_mib_handlers();
  935|     57|    register_default_handlers();
  936|     57|    init_snmp_transport();
  937|     57|    init_snmpv3(type);
  938|     57|    init_snmp_alarm();
  939|     57|    init_snmp_enum(type);
  940|     57|    init_vacm();
  941|     57|#if defined(NETSNMP_USE_OPENSSL) && defined(HAVE_LIBSSL) && NETSNMP_TRANSPORT_TLSBASE_DOMAIN
  942|     57|    netsnmp_certs_init();
  943|     57|#endif
  944|       |#ifdef DNSSEC_LOCAL_VALIDATION
  945|       |    netsnmp_ds_register_config(ASN_BOOLEAN, "snmp", "dnssecWarnOnly",
  946|       |                               NETSNMP_DS_LIBRARY_ID,
  947|       |                               NETSNMP_DS_LIB_DNSSEC_WARN_ONLY);
  948|       |#endif
  949|       |
  950|     57|    read_premib_configs();
  951|     57|#ifndef NETSNMP_DISABLE_MIB_LOADING
  952|     57|    netsnmp_init_mib();
  953|     57|#endif /* NETSNMP_DISABLE_MIB_LOADING */
  954|       |
  955|     57|    read_configs();
  956|       |
  957|     57|}                               /* end init_snmp() */
snmp_store:
  983|     57|{
  984|     57|    DEBUGMSGTL(("snmp_store", "storing stuff...\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]
  |  |  ------------------
  ------------------
  985|     57|    snmp_save_persistent(type);
  986|     57|    snmp_call_callbacks(SNMP_CALLBACK_LIBRARY, SNMP_CALLBACK_STORE_DATA, NULL);
  ------------------
  |  |   18|     57|#define SNMP_CALLBACK_LIBRARY     0
  ------------------
                  snmp_call_callbacks(SNMP_CALLBACK_LIBRARY, SNMP_CALLBACK_STORE_DATA, NULL);
  ------------------
  |  |   25|     57|#define SNMP_CALLBACK_STORE_DATA	        1
  ------------------
  987|     57|    snmp_clean_persistent(type);
  988|     57|}
snmp_shutdown:
 1001|     57|{
 1002|     57|    snmp_store(type);
 1003|     57|    snmp_call_callbacks(SNMP_CALLBACK_LIBRARY, SNMP_CALLBACK_SHUTDOWN, NULL);
  ------------------
  |  |   18|     57|#define SNMP_CALLBACK_LIBRARY     0
  ------------------
                  snmp_call_callbacks(SNMP_CALLBACK_LIBRARY, SNMP_CALLBACK_SHUTDOWN, NULL);
  ------------------
  |  |   26|     57|#define SNMP_CALLBACK_SHUTDOWN		        2
  ------------------
 1004|     57|    shutdown_snmp_logging();
 1005|     57|    snmp_alarm_unregister_all();
 1006|     57|    netsnmp_query_shutdown();
 1007|     57|    snmp_close_sessions();
 1008|     57|#ifndef NETSNMP_DISABLE_MIB_LOADING
 1009|     57|    shutdown_mib();
 1010|     57|#endif /* NETSNMP_DISABLE_MIB_LOADING */
 1011|     57|#if defined(NETSNMP_USE_OPENSSL) && defined(HAVE_LIBSSL) && NETSNMP_TRANSPORT_TLSBASE_DOMAIN
 1012|     57|    netsnmp_certs_shutdown();
 1013|     57|#endif
 1014|     57|#if !defined(NETSNMP_FEATURE_REMOVE_FILTER_SOURCE)
 1015|     57|    netsnmp_transport_filter_cleanup();
 1016|     57|#endif
 1017|     57|    unregister_all_config_handlers();
 1018|     57|    netsnmp_container_free_list();
 1019|     57|    clear_sec_mod();
 1020|     57|    clear_snmp_enum();
 1021|     57|    netsnmp_clear_tdomain_list();
 1022|     57|    clear_callback();
 1023|     57|    netsnmp_ds_shutdown();
 1024|     57|    netsnmp_clear_default_target();
 1025|     57|    netsnmp_clear_default_domain();
 1026|     57|    shutdown_secmod();
 1027|     57|    shutdown_snmp_transport();
 1028|     57|    shutdown_data_list();
 1029|     57|    snmp_debug_shutdown();    /* should be done last */
 1030|       |
 1031|     57|    init_snmp_init_done  = 0;
 1032|     57|    _init_snmp_init_done = 0;
 1033|     57|}
snmp_session_insert:
 1039|     57|{
 1040|     57|    if (NULL == slp)
  ------------------
  |  Branch (1040:9): [True: 0, False: 57]
  ------------------
 1041|      0|        return;
 1042|       |
 1043|     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]
  |  |  ------------------
  ------------------
 1044|     57|    slp->next = Sessions;
 1045|     57|    Sessions = slp;
 1046|     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]
  |  |  ------------------
  ------------------
 1047|     57|}
netsnmp_sess_config_transport:
 1627|     57|{
 1628|       |    /* Optional supplemental transport configuration information and
 1629|       |       final call to actually open the transport */
 1630|     57|    if (transport_configuration) {
  ------------------
  |  Branch (1630:9): [True: 0, False: 57]
  ------------------
 1631|      0|        DEBUGMSGTL(("snmp_sess", "configuring transport\n"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1632|      0|        if (transport->f_config) {
  ------------------
  |  Branch (1632:13): [True: 0, False: 0]
  ------------------
 1633|      0|            netsnmp_iterator *iter;
 1634|      0|            netsnmp_transport_config *config_data;
 1635|      0|            int ret = 0;
 1636|       |
 1637|      0|            iter = CONTAINER_ITERATOR(transport_configuration);
  ------------------
  |  |  404|      0|#define CONTAINER_ITERATOR(x)       (x)->get_iterator(x)
  ------------------
 1638|      0|            if (NULL == iter) {
  ------------------
  |  Branch (1638:17): [True: 0, False: 0]
  ------------------
 1639|      0|                return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
 1640|      0|            }
 1641|       |
 1642|      0|            for(config_data = (netsnmp_transport_config*)ITERATOR_FIRST(iter); config_data;
  ------------------
  |  |  546|      0|#define ITERATOR_FIRST(x)  x->first(x)
  ------------------
  |  Branch (1642:80): [True: 0, False: 0]
  ------------------
 1643|      0|                config_data = (netsnmp_transport_config*)ITERATOR_NEXT(iter)) {
  ------------------
  |  |  547|      0|#define ITERATOR_NEXT(x)   x->next(x)
  ------------------
 1644|      0|                ret = transport->f_config(transport, config_data->key,
 1645|      0|                                          config_data->value);
 1646|      0|                if (ret)
  ------------------
  |  Branch (1646:21): [True: 0, False: 0]
  ------------------
 1647|      0|                    break;
 1648|      0|            }
 1649|      0|            ITERATOR_RELEASE(iter);
  ------------------
  |  |  550|      0|#define ITERATOR_RELEASE(x) do { x->release(x); x = NULL; } while(0)
  |  |  ------------------
  |  |  |  Branch (550:67): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1650|      0|            if (ret)
  ------------------
  |  Branch (1650:17): [True: 0, False: 0]
  ------------------
 1651|      0|                return SNMPERR_TRANSPORT_CONFIG_ERROR;
  ------------------
  |  |  252|      0|#define SNMPERR_TRANSPORT_CONFIG_ERROR  (-68)
  ------------------
 1652|      0|        } else {
 1653|      0|            return SNMPERR_TRANSPORT_NO_CONFIG;
  ------------------
  |  |  251|      0|#define SNMPERR_TRANSPORT_NO_CONFIG     (-67)
  ------------------
 1654|      0|        }
 1655|      0|    }
 1656|     57|    return SNMPERR_SUCCESS;
  ------------------
  |  |  184|     57|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 1657|     57|}
netsnmp_sess_config_and_open_transport:
 1689|     57|{
 1690|     57|    int rc;
 1691|       |    
 1692|     57|    DEBUGMSGTL(("snmp_sess", "opening transport: %x\n", transport->flags & NETSNMP_TRANSPORT_FLAG_OPENED));
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 1693|       |
 1694|       |    /* don't double open */
 1695|     57|    if (transport->flags & NETSNMP_TRANSPORT_FLAG_OPENED)
  ------------------
  |  |   57|     57|#define		NETSNMP_TRANSPORT_FLAG_OPENED	 0x20  /* f_open called */
  ------------------
  |  Branch (1695:9): [True: 0, False: 57]
  ------------------
 1696|      0|        return SNMPERR_SUCCESS;
  ------------------
  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 1697|       |
 1698|     57|    if ((rc = netsnmp_sess_config_transport(in_session->transport_configuration,
  ------------------
  |  Branch (1698:9): [True: 0, False: 57]
  ------------------
 1699|     57|                                            transport)) != SNMPERR_SUCCESS) {
  ------------------
  |  |  184|     57|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 1700|      0|        in_session->s_snmp_errno = rc;
 1701|      0|        in_session->s_errno = 0;
 1702|      0|        return rc;
 1703|      0|    }
 1704|       |        
 1705|     57|    if (transport->f_open)
  ------------------
  |  Branch (1705:9): [True: 0, False: 57]
  ------------------
 1706|      0|        transport = transport->f_open(transport);
 1707|       |
 1708|     57|    if (transport == NULL) {
  ------------------
  |  Branch (1708:9): [True: 0, False: 57]
  ------------------
 1709|      0|        DEBUGMSGTL(("snmp_sess", "couldn't open transport connection\n"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1710|      0|        in_session->s_snmp_errno = SNMPERR_BAD_ADDRESS;
  ------------------
  |  |  187|      0|#define SNMPERR_BAD_ADDRESS		(-3)
  ------------------
 1711|      0|        in_session->s_errno = errno;
 1712|      0|        snmp_set_detail(in_session->peername);
 1713|      0|        return SNMPERR_BAD_ADDRESS;
  ------------------
  |  |  187|      0|#define SNMPERR_BAD_ADDRESS		(-3)
  ------------------
 1714|      0|    }
 1715|       |
 1716|       |    /** if transport has a max size, make sure session is the same (or less) */
 1717|     57|    if (in_session->rcvMsgMaxSize > transport->msgMaxSize) {
  ------------------
  |  Branch (1717:9): [True: 57, False: 0]
  ------------------
 1718|     57|        DEBUGMSGTL(("snmp_sess",
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 1719|     57|                    "limiting session rcv size (%" NETSNMP_PRIz "d) to transport max (%" NETSNMP_PRIz "d)\n",
 1720|     57|                    in_session->rcvMsgMaxSize, transport->msgMaxSize));
 1721|     57|        in_session->rcvMsgMaxSize = transport->msgMaxSize;
 1722|     57|    }
 1723|       |
 1724|     57|    if (in_session->sndMsgMaxSize > transport->msgMaxSize) {
  ------------------
  |  Branch (1724:9): [True: 57, False: 0]
  ------------------
 1725|     57|        DEBUGMSGTL(("snmp_sess",
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 1726|     57|                    "limiting session snd size (%" NETSNMP_PRIz "d) to transport max (%" NETSNMP_PRIz "d)\n",
 1727|     57|                    in_session->sndMsgMaxSize, transport->msgMaxSize));
 1728|     57|        in_session->sndMsgMaxSize = transport->msgMaxSize;
 1729|     57|    }
 1730|       |
 1731|     57|    transport->flags |= NETSNMP_TRANSPORT_FLAG_OPENED;
  ------------------
  |  |   57|     57|#define		NETSNMP_TRANSPORT_FLAG_OPENED	 0x20  /* f_open called */
  ------------------
 1732|     57|    DEBUGMSGTL(("snmp_sess", "done opening transport: %x\n", transport->flags & NETSNMP_TRANSPORT_FLAG_OPENED));
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 1733|     57|    return SNMPERR_SUCCESS;
  ------------------
  |  |  184|     57|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 1734|     57|}
snmp_add:
 1848|     57|{
 1849|     57|    struct session_list *slp;
 1850|       |
 1851|     57|    slp = snmp_sess_add_ex(in_session, transport, fpre_parse, NULL,
 1852|     57|                           fpost_parse, NULL, NULL, NULL, NULL);
 1853|     57|    if (slp == NULL) {
  ------------------
  |  Branch (1853:9): [True: 0, False: 57]
  ------------------
 1854|      0|        return NULL;
 1855|      0|    }
 1856|       |
 1857|     57|    snmp_session_insert(slp);
 1858|       |
 1859|     57|    return (slp->session);
 1860|     57|}
snmp_sess_add_ex:
 1909|     57|{
 1910|     57|    struct session_list *slp;
 1911|     57|    int rc;
 1912|       |    
 1913|     57|    _init_snmp();
 1914|       |
 1915|     57|    if (transport == NULL)
  ------------------
  |  Branch (1915:9): [True: 0, False: 57]
  ------------------
 1916|      0|        return NULL;
 1917|       |
 1918|     57|    if (NULL != in_session && (in_session->rcvMsgMaxSize < SNMP_MIN_MAX_LEN ||
  ------------------
  |  |   48|    114|#define SNMP_MIN_MAX_LEN    484 /* minimum maximum message size */
  ------------------
  |  Branch (1918:9): [True: 57, False: 0]
  |  Branch (1918:32): [True: 0, False: 57]
  ------------------
 1919|     57|                               in_session->sndMsgMaxSize < SNMP_MIN_MAX_LEN)) {
  ------------------
  |  |   48|     57|#define SNMP_MIN_MAX_LEN    484 /* minimum maximum message size */
  ------------------
  |  Branch (1919:32): [True: 0, False: 57]
  ------------------
 1920|      0|        DEBUGMSGTL(("snmp_sess_add",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1921|      0|                    "invalid session (msg sizes). need snmp_sess_init"));
 1922|      0|        in_session = NULL; /* force transport cleanup below */
 1923|      0|    }
 1924|       |
 1925|     57|    if (in_session == NULL) {
  ------------------
  |  Branch (1925:9): [True: 0, False: 57]
  ------------------
 1926|      0|        transport->f_close(transport);
 1927|      0|        netsnmp_transport_free(transport);
 1928|      0|        return NULL;
 1929|      0|    }
 1930|       |
 1931|       |    /* if the transport hasn't been fully opened yet, open it now */
 1932|     57|    if ((rc = netsnmp_sess_config_and_open_transport(in_session, transport))
  ------------------
  |  Branch (1932:9): [True: 0, False: 57]
  ------------------
 1933|     57|        != SNMPERR_SUCCESS) {
  ------------------
  |  |  184|     57|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 1934|      0|        return NULL;
 1935|      0|    }
 1936|       |
 1937|     57|    DEBUGMSGTL(("snmp_sess_add", "fd %d\n", transport->sock));
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 1938|       |
 1939|     57|    if ((slp = snmp_sess_copy(in_session)) == NULL) {
  ------------------
  |  Branch (1939:9): [True: 0, False: 57]
  ------------------
 1940|      0|        transport->f_close(transport);
 1941|      0|        netsnmp_transport_free(transport);
 1942|      0|        return (NULL);
 1943|      0|    }
 1944|       |
 1945|     57|    slp->transport = transport;
 1946|     57|    slp->internal->hook_pre = fpre_parse;
 1947|     57|    slp->internal->hook_parse = fparse;
 1948|     57|    slp->internal->hook_post = fpost_parse;
 1949|     57|    slp->internal->hook_build = fbuild;
 1950|     57|    slp->internal->hook_realloc_build = frbuild;
 1951|     57|    slp->internal->check_packet = fcheck;
 1952|     57|    slp->internal->hook_create_pdu = fcreate_pdu;
 1953|       |
 1954|       |    /** don't let session max exceed transport max */
 1955|     57|    if (slp->session->rcvMsgMaxSize > transport->msgMaxSize) {
  ------------------
  |  Branch (1955:9): [True: 0, False: 57]
  ------------------
 1956|      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]
  |  |  ------------------
  ------------------
 1957|      0|                    "limiting session rcv size (%" NETSNMP_PRIz "d) to transport max (%" NETSNMP_PRIz "d)\n",
 1958|      0|                    slp->session->rcvMsgMaxSize, transport->msgMaxSize));
 1959|      0|        slp->session->rcvMsgMaxSize = transport->msgMaxSize;
 1960|      0|    }
 1961|     57|    if (slp->session->sndMsgMaxSize > transport->msgMaxSize) {
  ------------------
  |  Branch (1961:9): [True: 0, False: 57]
  ------------------
 1962|      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]
  |  |  ------------------
  ------------------
 1963|      0|                    "limiting session snd size (%" NETSNMP_PRIz "d) to transport max (%" NETSNMP_PRIz "d)\n",
 1964|      0|                    slp->session->sndMsgMaxSize, transport->msgMaxSize));
 1965|      0|        slp->session->sndMsgMaxSize = transport->msgMaxSize;
 1966|      0|    }
 1967|       |
 1968|     57|    if (transport->f_setup_session &&
  ------------------
  |  Branch (1968:9): [True: 57, False: 0]
  ------------------
 1969|     57|        transport->f_setup_session(transport, slp->session) != SNMPERR_SUCCESS)
  ------------------
  |  |  184|     57|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  |  Branch (1969:9): [True: 0, False: 57]
  ------------------
 1970|      0|        goto close_session;
 1971|       |
 1972|       |    /* Anything below this point should only be done if the transport
 1973|       |       had no say in the matter */
 1974|     57|    if (slp->session->securityLevel == 0)
  ------------------
  |  Branch (1974:9): [True: 57, False: 0]
  ------------------
 1975|     57|        slp->session->securityLevel = SNMP_SEC_LEVEL_NOAUTH;
  ------------------
  |  |  299|     57|#define SNMP_SEC_LEVEL_NOAUTH		1
  ------------------
 1976|       |
 1977|     57|    if (slp->session->version == SNMP_VERSION_3) {
  ------------------
  |  |  113|     57|#define SNMP_VERSION_3     3
  ------------------
  |  Branch (1977:9): [True: 0, False: 57]
  ------------------
 1978|      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]
  |  |  ------------------
  ------------------
 1979|      0|                    "adding v3 session -- maybe engineID probe now\n"));
 1980|      0|        if (!snmpv3_engineID_probe(slp, slp->session)) {
  ------------------
  |  Branch (1980:13): [True: 0, False: 0]
  ------------------
 1981|      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]
  |  |  ------------------
  ------------------
 1982|      0|            goto close_session;
 1983|      0|        }
 1984|      0|    }
 1985|       |
 1986|     57|    slp->session->flags &= ~SNMP_FLAGS_DONT_PROBE;
  ------------------
  |  |  155|     57|#define SNMP_FLAGS_DONT_PROBE      0x100      /* don't probe for an engineID */
  ------------------
 1987|       |
 1988|     57|    return slp;
 1989|       |
 1990|      0|close_session:
 1991|      0|    snmp_sess_close(slp);
 1992|       |    return NULL;
 1993|     57|}                               /*  end snmp_sess_add_ex()  */
netsnmp_cleanup_session:
 2053|     57|{
 2054|     57|    free(s->localname);
 2055|     57|    free(s->peername);
 2056|     57|    free(s->community);
 2057|     57|    free(s->contextEngineID);
 2058|     57|    free(s->contextName);
 2059|     57|    free(s->securityEngineID);
 2060|     57|    free(s->securityName);
 2061|     57|    free(s->securityAuthProto);
 2062|     57|    free(s->securityAuthLocalKey);
 2063|     57|    free(s->securityPrivProto);
 2064|     57|    free(s->securityPrivLocalKey);
 2065|     57|    free(s->paramName);
 2066|     57|#ifndef NETSNMP_NO_TRAP_STATS
 2067|     57|    free(s->trap_stats);
 2068|     57|#endif /* NETSNMP_NO_TRAP_STATS */
 2069|     57|    usm_free_user(s->sessUser);
 2070|     57|    netsnmp_free_transport_config(s->transport_configuration);
 2071|     57|    memset(s, 0, sizeof(*s));
 2072|     57|}
snmp_sess_close:
 2103|     57|{
 2104|     57|    netsnmp_transport *transport;
 2105|     57|    struct snmp_internal_session *isp;
 2106|     57|    netsnmp_session *sesp = NULL;
 2107|     57|    struct snmp_secmod_def *sptr;
 2108|       |
 2109|     57|    if (slp == NULL) {
  ------------------
  |  Branch (2109:9): [True: 0, False: 57]
  ------------------
 2110|      0|        return 0;
 2111|      0|    }
 2112|       |
 2113|     57|    if (slp->session != NULL &&
  ------------------
  |  Branch (2113:9): [True: 57, False: 0]
  ------------------
 2114|     57|        (sptr = find_sec_mod(slp->session->securityModel)) != NULL &&
  ------------------
  |  Branch (2114:9): [True: 57, False: 0]
  ------------------
 2115|     57|        sptr->session_close != NULL) {
  ------------------
  |  Branch (2115:9): [True: 0, False: 57]
  ------------------
 2116|      0|        (*sptr->session_close) (slp->session);
 2117|      0|    }
 2118|       |
 2119|     57|    isp = slp->internal;
 2120|     57|    slp->internal = NULL;
 2121|       |
 2122|     57|    if (isp) {
  ------------------
  |  Branch (2122:9): [True: 57, False: 0]
  ------------------
 2123|     57|        netsnmp_request_list *rp, *orp;
 2124|       |
 2125|     57|        SNMP_FREE(isp->packet);
  ------------------
  |  |   62|     57|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 57]
  |  |  |  Branch (62:66): [Folded, False: 57]
  |  |  ------------------
  ------------------
 2126|       |
 2127|       |        /*
 2128|       |         * Free each element in the input request list.  
 2129|       |         */
 2130|     57|        rp = isp->requests;
 2131|     57|        while (rp) {
  ------------------
  |  Branch (2131:16): [True: 0, False: 57]
  ------------------
 2132|      0|            orp = rp;
 2133|      0|            rp = rp->next_request;
 2134|      0|            if (orp->callback) {
  ------------------
  |  Branch (2134:17): [True: 0, False: 0]
  ------------------
 2135|      0|                orp->callback(NETSNMP_CALLBACK_OP_TIMED_OUT,
  ------------------
  |  |  320|      0|#define NETSNMP_CALLBACK_OP_TIMED_OUT		2
  ------------------
 2136|      0|                              slp->session, orp->pdu->reqid,
 2137|      0|                              orp->pdu, orp->cb_data);
 2138|      0|            }
 2139|      0|            remove_request(isp, NULL, orp);
 2140|      0|            free(orp);
 2141|      0|        }
 2142|       |
 2143|     57|        free(isp);
 2144|     57|    }
 2145|       |
 2146|     57|    transport = slp->transport;
 2147|     57|    slp->transport = NULL;
 2148|       |
 2149|     57|    if (transport) {
  ------------------
  |  Branch (2149:9): [True: 57, False: 0]
  ------------------
 2150|     57|        transport->f_close(transport);
 2151|     57|        netsnmp_transport_free(transport);
 2152|     57|    }
 2153|       |
 2154|     57|    sesp = slp->session;
 2155|     57|    slp->session = NULL;
 2156|       |
 2157|       |    /*
 2158|       |     * The following is necessary to avoid memory leakage when closing AgentX 
 2159|       |     * sessions that may have multiple subsessions.  These hang off the main
 2160|       |     * session at ->subsession, and chain through ->next.  
 2161|       |     */
 2162|       |
 2163|     57|    if (sesp != NULL && sesp->subsession != NULL) {
  ------------------
  |  Branch (2163:9): [True: 57, False: 0]
  |  Branch (2163:25): [True: 0, False: 57]
  ------------------
 2164|      0|        netsnmp_session *subsession = sesp->subsession, *tmpsub;
 2165|       |
 2166|      0|        while (subsession != NULL) {
  ------------------
  |  Branch (2166:16): [True: 0, False: 0]
  ------------------
 2167|      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]
  |  |  ------------------
  ------------------
 2168|      0|                        "closing session %p, subsession %p\n", sesp,
 2169|      0|                        subsession));
 2170|      0|            tmpsub = subsession->next;
 2171|      0|            snmp_free_session(subsession);
 2172|      0|            subsession = tmpsub;
 2173|      0|        }
 2174|      0|    }
 2175|       |
 2176|     57|    snmp_free_session(sesp);
 2177|     57|    free(slp);
 2178|     57|    return 1;
 2179|     57|}
snmp_close:
 2183|     57|{
 2184|     57|    struct session_list *slp = NULL, *oslp = NULL;
 2185|       |
 2186|     57|    {                           /*MTCRITICAL_RESOURCE */
 2187|     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]
  |  |  ------------------
  ------------------
 2188|     57|        if (Sessions && Sessions->session == session) { /* If first entry */
  ------------------
  |  Branch (2188:13): [True: 0, False: 57]
  |  Branch (2188:25): [True: 0, False: 0]
  ------------------
 2189|      0|            slp = Sessions;
 2190|      0|            Sessions = slp->next;
 2191|     57|        } else {
 2192|     57|            for (slp = Sessions; slp; slp = slp->next) {
  ------------------
  |  Branch (2192:34): [True: 0, False: 57]
  ------------------
 2193|      0|                if (slp->session == session) {
  ------------------
  |  Branch (2193:21): [True: 0, False: 0]
  ------------------
 2194|      0|                    if (oslp)   /* if we found entry that points here */
  ------------------
  |  Branch (2194:25): [True: 0, False: 0]
  ------------------
 2195|      0|                        oslp->next = slp->next; /* link around this entry */
 2196|      0|                    break;
 2197|      0|                }
 2198|      0|                oslp = slp;
 2199|      0|            }
 2200|     57|        }
 2201|     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]
  |  |  ------------------
  ------------------
 2202|     57|    }                           /*END MTCRITICAL_RESOURCE */
 2203|     57|    if (slp == NULL) {
  ------------------
  |  Branch (2203:9): [True: 57, False: 0]
  ------------------
 2204|     57|        return 0;
 2205|     57|    }
 2206|      0|    return snmp_sess_close(slp);
 2207|     57|}
snmp_close_sessions:
 2211|     57|{
 2212|     57|    struct session_list *slp;
 2213|       |
 2214|     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]
  |  |  ------------------
  ------------------
 2215|    114|    while (Sessions) {
  ------------------
  |  Branch (2215:12): [True: 57, False: 57]
  ------------------
 2216|     57|        slp = Sessions;
 2217|     57|        Sessions = Sessions->next;
 2218|     57|        snmp_sess_close(slp);
 2219|     57|    }
 2220|     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]
  |  |  ------------------
  ------------------
 2221|     57|    return 1;
 2222|     57|}
snmpv3_parse:
 3851|     12|{
 3852|     12|    u_char          type, msg_flags;
 3853|     12|    long            ver, msg_sec_model;
 3854|     12|    size_t          max_size_response;
 3855|     12|    u_char          tmp_buf[SNMP_MAX_MSG_SIZE];
 3856|     12|    size_t          tmp_buf_len;
 3857|     12|    u_char          pdu_buf[SNMP_MAX_MSG_SIZE];
 3858|     12|    u_char         *mallocbuf = NULL;
 3859|     12|    size_t          pdu_buf_len = SNMP_MAX_MSG_SIZE;
  ------------------
  |  |  109|     12|#define SNMP_MAX_MSG_SIZE          1472 /* ethernet MTU minus IP/UDP header */
  ------------------
 3860|     12|    u_char         *sec_params;
 3861|     12|    u_char         *msg_data;
 3862|     12|    u_char         *cp;
 3863|     12|    size_t          asn_len, msg_len;
 3864|     12|    int             ret, ret_val;
 3865|     12|    struct snmp_secmod_def *sptr;
 3866|       |
 3867|       |
 3868|     12|    msg_data = data;
 3869|     12|    msg_len = *length;
 3870|       |
 3871|       |
 3872|       |    /*
 3873|       |     * message is an ASN.1 SEQUENCE  
 3874|       |     */
 3875|     12|    DEBUGDUMPSECTION("recv", "SNMPv3 Message");
  ------------------
  |  |   81|     12|	do {if (_DBG_IF_) {__DBGDUMPSECTION(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     12|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 12]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	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: 12]
  |  |  ------------------
  ------------------
 3876|     12|    data = asn_parse_sequence(data, length, &type,
 3877|     12|                              (ASN_SEQUENCE | ASN_CONSTRUCTOR), "message");
  ------------------
  |  |   84|     12|#define ASN_SEQUENCE	    0x10U
  ------------------
                                            (ASN_SEQUENCE | ASN_CONSTRUCTOR), "message");
  ------------------
  |  |   96|     12|#define ASN_CONSTRUCTOR	    0x20U
  ------------------
 3878|     12|    if (data == NULL) {
  ------------------
  |  Branch (3878:9): [True: 0, False: 12]
  ------------------
 3879|       |        /*
 3880|       |         * error msg detail is set 
 3881|       |         */
 3882|      0|        snmp_increment_statistic(STAT_SNMPINASNPARSEERRS);
  ------------------
  |  |  637|      0|#define  STAT_SNMPINASNPARSEERRS             14
  ------------------
 3883|      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]
  |  |  ------------------
  ------------------
 3884|      0|        return SNMPERR_ASN_PARSE_ERR;
  ------------------
  |  |  213|      0|#define SNMPERR_ASN_PARSE_ERR           (-29)
  ------------------
 3885|      0|    }
 3886|       |
 3887|       |    /*
 3888|       |     * parse msgVersion  
 3889|       |     */
 3890|     12|    DEBUGDUMPHEADER("recv", "SNMP Version Number");
  ------------------
  |  |   79|     12|	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     12|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 12]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	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: 12]
  |  |  ------------------
  ------------------
 3891|     12|    data = asn_parse_int(data, length, &type, &ver, sizeof(ver));
 3892|     12|    DEBUGINDENTLESS();
  ------------------
  |  |   75|     12|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|     12|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 12]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 12]
  |  |  ------------------
  ------------------
 3893|     12|    if (data == NULL) {
  ------------------
  |  Branch (3893:9): [True: 0, False: 12]
  ------------------
 3894|      0|        ERROR_MSG("bad parse of version");
  ------------------
  |  |  188|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 3895|      0|        snmp_increment_statistic(STAT_SNMPINASNPARSEERRS);
  ------------------
  |  |  637|      0|#define  STAT_SNMPINASNPARSEERRS             14
  ------------------
 3896|      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]
  |  |  ------------------
  ------------------
 3897|      0|        return SNMPERR_ASN_PARSE_ERR;
  ------------------
  |  |  213|      0|#define SNMPERR_ASN_PARSE_ERR           (-29)
  ------------------
 3898|      0|    }
 3899|     12|    pdu->version = ver;
 3900|       |
 3901|       |    /*
 3902|       |     * parse msgGlobalData sequence  
 3903|       |     */
 3904|     12|    cp = data;
 3905|     12|    asn_len = *length;
 3906|     12|    DEBUGDUMPSECTION("recv", "msgGlobalData");
  ------------------
  |  |   81|     12|	do {if (_DBG_IF_) {__DBGDUMPSECTION(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     12|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 12]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	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: 12]
  |  |  ------------------
  ------------------
 3907|     12|    data = asn_parse_sequence(data, &asn_len, &type,
 3908|     12|                              (ASN_SEQUENCE | ASN_CONSTRUCTOR),
  ------------------
  |  |   84|     12|#define ASN_SEQUENCE	    0x10U
  ------------------
                                            (ASN_SEQUENCE | ASN_CONSTRUCTOR),
  ------------------
  |  |   96|     12|#define ASN_CONSTRUCTOR	    0x20U
  ------------------
 3909|     12|                              "msgGlobalData");
 3910|     12|    if (data == NULL) {
  ------------------
  |  Branch (3910:9): [True: 0, False: 12]
  ------------------
 3911|       |        /*
 3912|       |         * error msg detail is set 
 3913|       |         */
 3914|      0|        snmp_increment_statistic(STAT_SNMPINASNPARSEERRS);
  ------------------
  |  |  637|      0|#define  STAT_SNMPINASNPARSEERRS             14
  ------------------
 3915|      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]
  |  |  ------------------
  ------------------
 3916|      0|        return SNMPERR_ASN_PARSE_ERR;
  ------------------
  |  |  213|      0|#define SNMPERR_ASN_PARSE_ERR           (-29)
  ------------------
 3917|      0|    }
 3918|     12|    *length -= data - cp;       /* subtract off the length of the header */
 3919|       |
 3920|       |    /*
 3921|       |     * msgID 
 3922|       |     */
 3923|     12|    DEBUGDUMPHEADER("recv", "msgID");
  ------------------
  |  |   79|     12|	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     12|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 12]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	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: 12]
  |  |  ------------------
  ------------------
 3924|     12|    data =
 3925|     12|        asn_parse_int(data, length, &type, &pdu->msgid,
 3926|     12|                      sizeof(pdu->msgid));
 3927|     12|    DEBUGINDENTLESS();
  ------------------
  |  |   75|     12|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|     12|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 12]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 12]
  |  |  ------------------
  ------------------
 3928|     12|    if (data == NULL || type != ASN_INTEGER) {
  ------------------
  |  |   75|     12|#define ASN_INTEGER	    0x02U
  ------------------
  |  Branch (3928:9): [True: 0, False: 12]
  |  Branch (3928:25): [True: 0, False: 12]
  ------------------
 3929|      0|        ERROR_MSG("error parsing msgID");
  ------------------
  |  |  188|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 3930|      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]
  |  |  ------------------
  ------------------
 3931|      0|        snmp_increment_statistic(STAT_SNMPINASNPARSEERRS);
  ------------------
  |  |  637|      0|#define  STAT_SNMPINASNPARSEERRS             14
  ------------------
 3932|      0|        return SNMPERR_ASN_PARSE_ERR;
  ------------------
  |  |  213|      0|#define SNMPERR_ASN_PARSE_ERR           (-29)
  ------------------
 3933|      0|    }
 3934|       |
 3935|       |    /*
 3936|       |     * Check the msgID we received is a legal value.  If not, then increment
 3937|       |     * snmpInASNParseErrs and return the appropriate error (see RFC 2572,
 3938|       |     * para. 7.2, section 2 -- note that a bad msgID means that the received
 3939|       |     * message is NOT a serialization of an SNMPv3Message, since the msgID
 3940|       |     * field is out of bounds).  
 3941|       |     */
 3942|       |
 3943|     12|    if (pdu->msgid < 0 || pdu->msgid > SNMP_MAX_PACKET_LEN) {
  ------------------
  |  |   49|     12|#define SNMP_MAX_PACKET_LEN (0x7fffffff)
  ------------------
  |  Branch (3943:9): [True: 0, False: 12]
  |  Branch (3943:27): [True: 0, False: 12]
  ------------------
 3944|      0|        snmp_log(LOG_ERR, "Received bad msgID (%ld %s %s).\n", pdu->msgid,
 3945|      0|                 (pdu->msgid < 0) ? "<" : ">",
  ------------------
  |  Branch (3945:18): [True: 0, False: 0]
  ------------------
 3946|      0|                 (pdu->msgid < 0) ? "0" : "2^31 - 1");
  ------------------
  |  Branch (3946:18): [True: 0, False: 0]
  ------------------
 3947|      0|        snmp_increment_statistic(STAT_SNMPINASNPARSEERRS);
  ------------------
  |  |  637|      0|#define  STAT_SNMPINASNPARSEERRS             14
  ------------------
 3948|      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]
  |  |  ------------------
  ------------------
 3949|      0|        return SNMPERR_ASN_PARSE_ERR;
  ------------------
  |  |  213|      0|#define SNMPERR_ASN_PARSE_ERR           (-29)
  ------------------
 3950|      0|    }
 3951|       |
 3952|       |    /*
 3953|       |     * msgMaxSize 
 3954|       |     */
 3955|     12|    DEBUGDUMPHEADER("recv:msgMaxSize", "msgMaxSize");
  ------------------
  |  |   79|     12|	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     12|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 12]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	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: 12]
  |  |  ------------------
  ------------------
 3956|     12|    data = asn_parse_int(data, length, &type, &pdu->msgMaxSize,
 3957|     12|                         sizeof(pdu->msgMaxSize));
 3958|     12|    DEBUGINDENTLESS();
  ------------------
  |  |   75|     12|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|     12|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 12]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 12]
  |  |  ------------------
  ------------------
 3959|     12|    if (data == NULL || type != ASN_INTEGER) {
  ------------------
  |  |   75|     12|#define ASN_INTEGER	    0x02U
  ------------------
  |  Branch (3959:9): [True: 0, False: 12]
  |  Branch (3959:25): [True: 0, False: 12]
  ------------------
 3960|      0|        ERROR_MSG("error parsing msgMaxSize");
  ------------------
  |  |  188|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 3961|      0|        snmp_increment_statistic(STAT_SNMPINASNPARSEERRS);
  ------------------
  |  |  637|      0|#define  STAT_SNMPINASNPARSEERRS             14
  ------------------
 3962|      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]
  |  |  ------------------
  ------------------
 3963|      0|        return SNMPERR_ASN_PARSE_ERR;
  ------------------
  |  |  213|      0|#define SNMPERR_ASN_PARSE_ERR           (-29)
  ------------------
 3964|      0|    }
 3965|       |
 3966|       |    /*
 3967|       |     * Check the msgMaxSize we received is a legal value.  If not, then
 3968|       |     * increment snmpInASNParseErrs and return the appropriate error (see RFC
 3969|       |     * 2572, para. 7.2, section 2 -- note that a bad msgMaxSize means that the
 3970|       |     * received message is NOT a serialization of an SNMPv3Message, since the
 3971|       |     * msgMaxSize field is out of bounds).
 3972|       |     */
 3973|       |
 3974|     12|    if (pdu->msgMaxSize < SNMP_MIN_MAX_LEN) {
  ------------------
  |  |   48|     12|#define SNMP_MIN_MAX_LEN    484 /* minimum maximum message size */
  ------------------
  |  Branch (3974:9): [True: 2, False: 10]
  ------------------
 3975|      2|        snmp_log(LOG_ERR, "Received bad msgMaxSize (%lu < 484).\n",
 3976|      2|                 pdu->msgMaxSize);
 3977|      2|        snmp_increment_statistic(STAT_SNMPINASNPARSEERRS);
  ------------------
  |  |  637|      2|#define  STAT_SNMPINASNPARSEERRS             14
  ------------------
 3978|      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]
  |  |  ------------------
  ------------------
 3979|      2|        return SNMPERR_ASN_PARSE_ERR;
  ------------------
  |  |  213|      2|#define SNMPERR_ASN_PARSE_ERR           (-29)
  ------------------
 3980|     10|    } else if (pdu->msgMaxSize > SNMP_MAX_PACKET_LEN) {
  ------------------
  |  |   49|     10|#define SNMP_MAX_PACKET_LEN (0x7fffffff)
  ------------------
  |  Branch (3980:16): [True: 0, False: 10]
  ------------------
 3981|      0|        snmp_log(LOG_ERR, "Received bad msgMaxSize (%lu > 2^31 - 1).\n",
 3982|      0|                 pdu->msgMaxSize);
 3983|      0|        snmp_increment_statistic(STAT_SNMPINASNPARSEERRS);
  ------------------
  |  |  637|      0|#define  STAT_SNMPINASNPARSEERRS             14
  ------------------
 3984|      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]
  |  |  ------------------
  ------------------
 3985|      0|        return SNMPERR_ASN_PARSE_ERR;
  ------------------
  |  |  213|      0|#define SNMPERR_ASN_PARSE_ERR           (-29)
  ------------------
 3986|     10|    } else {
 3987|     10|        DEBUGMSGTL(("snmpv3_parse:msgMaxSize", "msgMaxSize %lu received\n",
  ------------------
  |  |   66|     10|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     10|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 10]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 10]
  |  |  ------------------
  ------------------
 3988|     10|                    pdu->msgMaxSize));
 3989|       |        /** don't increase max msg size if we've already got one */
 3990|     10|        if (sess->sndMsgMaxSize < pdu->msgMaxSize) {
  ------------------
  |  Branch (3990:13): [True: 10, False: 0]
  ------------------
 3991|     10|            DEBUGMSGTL(("snmpv3_parse:msgMaxSize",
  ------------------
  |  |   66|     10|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     10|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 10]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 10]
  |  |  ------------------
  ------------------
 3992|     10|                        "msgMaxSize %" NETSNMP_PRIz "d greater than session max %ld; reducing\n",
 3993|     10|                        sess->sndMsgMaxSize, pdu->msgMaxSize));
 3994|     10|            pdu->msgMaxSize = sess->sndMsgMaxSize;
 3995|     10|        }
 3996|     10|    }
 3997|       |
 3998|       |    /*
 3999|       |     * msgFlags 
 4000|       |     */
 4001|     10|    tmp_buf_len = SNMP_MAX_MSG_SIZE;
  ------------------
  |  |  109|     10|#define SNMP_MAX_MSG_SIZE          1472 /* ethernet MTU minus IP/UDP header */
  ------------------
 4002|     10|    DEBUGDUMPHEADER("recv", "msgFlags");
  ------------------
  |  |   79|     10|	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     10|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 10]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	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: 10]
  |  |  ------------------
  ------------------
 4003|     10|    data = asn_parse_string(data, length, &type, tmp_buf, &tmp_buf_len);
 4004|     10|    DEBUGINDENTLESS();
  ------------------
  |  |   75|     10|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|     10|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 10]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 10]
  |  |  ------------------
  ------------------
 4005|     10|    if (data == NULL || type != ASN_OCTET_STR || tmp_buf_len != 1) {
  ------------------
  |  |   78|     19|#define ASN_OCTET_STR	    0x04U
  ------------------
  |  Branch (4005:9): [True: 1, False: 9]
  |  Branch (4005:25): [True: 0, False: 9]
  |  Branch (4005:50): [True: 0, False: 9]
  ------------------
 4006|      1|        ERROR_MSG("error parsing msgFlags");
  ------------------
  |  |  188|      1|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 4007|      1|        snmp_increment_statistic(STAT_SNMPINASNPARSEERRS);
  ------------------
  |  |  637|      1|#define  STAT_SNMPINASNPARSEERRS             14
  ------------------
 4008|      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]
  |  |  ------------------
  ------------------
 4009|      1|        return SNMPERR_ASN_PARSE_ERR;
  ------------------
  |  |  213|      1|#define SNMPERR_ASN_PARSE_ERR           (-29)
  ------------------
 4010|      1|    }
 4011|      9|    msg_flags = *tmp_buf;
 4012|      9|    if (msg_flags & SNMP_MSG_FLAG_RPRT_BIT)
  ------------------
  |  |  305|      9|#define SNMP_MSG_FLAG_RPRT_BIT          0x04
  ------------------
  |  Branch (4012:9): [True: 1, False: 8]
  ------------------
 4013|      1|        pdu->flags |= SNMP_MSG_FLAG_RPRT_BIT;
  ------------------
  |  |  305|      1|#define SNMP_MSG_FLAG_RPRT_BIT          0x04
  ------------------
 4014|      8|    else
 4015|      8|        pdu->flags &= (~SNMP_MSG_FLAG_RPRT_BIT);
  ------------------
  |  |  305|      8|#define SNMP_MSG_FLAG_RPRT_BIT          0x04
  ------------------
 4016|       |
 4017|       |    /*
 4018|       |     * msgSecurityModel 
 4019|       |     */
 4020|      9|    DEBUGDUMPHEADER("recv", "msgSecurityModel");
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 4021|      9|    data = asn_parse_int(data, length, &type, &msg_sec_model,
 4022|      9|                         sizeof(msg_sec_model));
 4023|      9|    DEBUGINDENTADD(-4);         /* return from global data indent */
  ------------------
  |  |   73|      9|#define DEBUGINDENTADD(x)  do {if (_DBG_IF_) {__DBGINDENTADD(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      9|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 9]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 9]
  |  |  ------------------
  ------------------
 4024|      9|    if (data == NULL || type != ASN_INTEGER ||
  ------------------
  |  |   75|     18|#define ASN_INTEGER	    0x02U
  ------------------
  |  Branch (4024:9): [True: 0, False: 9]
  |  Branch (4024:25): [True: 0, False: 9]
  ------------------
 4025|      9|        msg_sec_model < 1 || msg_sec_model > 0x7fffffff) {
  ------------------
  |  Branch (4025:9): [True: 0, False: 9]
  |  Branch (4025:30): [True: 0, False: 9]
  ------------------
 4026|      0|        ERROR_MSG("error parsing msgSecurityModel");
  ------------------
  |  |  188|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 4027|      0|        snmp_increment_statistic(STAT_SNMPINASNPARSEERRS);
  ------------------
  |  |  637|      0|#define  STAT_SNMPINASNPARSEERRS             14
  ------------------
 4028|      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]
  |  |  ------------------
  ------------------
 4029|      0|        return SNMPERR_ASN_PARSE_ERR;
  ------------------
  |  |  213|      0|#define SNMPERR_ASN_PARSE_ERR           (-29)
  ------------------
 4030|      0|    }
 4031|      9|    sptr = find_sec_mod(msg_sec_model);
 4032|      9|    if (!sptr) {
  ------------------
  |  Branch (4032:9): [True: 0, False: 9]
  ------------------
 4033|      0|        snmp_log(LOG_WARNING, "unknown security model: %ld\n",
 4034|      0|                 msg_sec_model);
 4035|      0|        snmp_increment_statistic(STAT_SNMPUNKNOWNSECURITYMODELS);
  ------------------
  |  |  611|      0|#define   STAT_SNMPUNKNOWNSECURITYMODELS     0
  ------------------
 4036|      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]
  |  |  ------------------
  ------------------
 4037|      0|        return SNMPERR_UNKNOWN_SEC_MODEL;
  ------------------
  |  |  214|      0|#define SNMPERR_UNKNOWN_SEC_MODEL 	(-30)
  ------------------
 4038|      0|    }
 4039|      9|    pdu->securityModel = msg_sec_model;
 4040|       |
 4041|      9|    if (msg_flags & SNMP_MSG_FLAG_PRIV_BIT &&
  ------------------
  |  |  304|     18|#define SNMP_MSG_FLAG_PRIV_BIT          0x02
  ------------------
  |  Branch (4041:9): [True: 0, False: 9]
  ------------------
 4042|      0|        !(msg_flags & SNMP_MSG_FLAG_AUTH_BIT)) {
  ------------------
  |  |  303|      0|#define SNMP_MSG_FLAG_AUTH_BIT          0x01
  ------------------
  |  Branch (4042:9): [True: 0, False: 0]
  ------------------
 4043|      0|        ERROR_MSG("invalid message, illegal msgFlags");
  ------------------
  |  |  188|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 4044|      0|        snmp_increment_statistic(STAT_SNMPINVALIDMSGS);
  ------------------
  |  |  612|      0|#define   STAT_SNMPINVALIDMSGS               1
  ------------------
 4045|      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]
  |  |  ------------------
  ------------------
 4046|      0|        return SNMPERR_INVALID_MSG;
  ------------------
  |  |  215|      0|#define SNMPERR_INVALID_MSG             (-31)
  ------------------
 4047|      0|    }
 4048|      9|    pdu->securityLevel = ((msg_flags & SNMP_MSG_FLAG_AUTH_BIT)
  ------------------
  |  |  303|      9|#define SNMP_MSG_FLAG_AUTH_BIT          0x01
  ------------------
  |  Branch (4048:27): [True: 9, False: 0]
  ------------------
 4049|      9|                          ? ((msg_flags & SNMP_MSG_FLAG_PRIV_BIT)
  ------------------
  |  |  304|      9|#define SNMP_MSG_FLAG_PRIV_BIT          0x02
  ------------------
  |  Branch (4049:30): [True: 0, False: 9]
  ------------------
 4050|      9|                             ? SNMP_SEC_LEVEL_AUTHPRIV
  ------------------
  |  |  301|      0|#define SNMP_SEC_LEVEL_AUTHPRIV		3
  ------------------
 4051|      9|                             : SNMP_SEC_LEVEL_AUTHNOPRIV)
  ------------------
  |  |  300|      9|#define SNMP_SEC_LEVEL_AUTHNOPRIV	2
  ------------------
 4052|      9|                          : SNMP_SEC_LEVEL_NOAUTH);
  ------------------
  |  |  299|      0|#define SNMP_SEC_LEVEL_NOAUTH		1
  ------------------
 4053|       |    /*
 4054|       |     * end of msgGlobalData 
 4055|       |     */
 4056|       |
 4057|       |    /*
 4058|       |     * securtityParameters OCTET STRING begins after msgGlobalData 
 4059|       |     */
 4060|      9|    sec_params = data;
 4061|      9|    pdu->contextEngineID = calloc(1, SNMP_MAX_ENG_SIZE);
  ------------------
  |  |  111|      9|#define SNMP_MAX_ENG_SIZE          32
  ------------------
 4062|      9|    pdu->contextEngineIDLen = SNMP_MAX_ENG_SIZE;
  ------------------
  |  |  111|      9|#define SNMP_MAX_ENG_SIZE          32
  ------------------
 4063|       |
 4064|       |    /*
 4065|       |     * Note: there is no length limit on the msgAuthoritativeEngineID field,
 4066|       |     * although we would EXPECT it to be limited to 32 (the SnmpEngineID TC
 4067|       |     * limit).  We'll use double that here to be on the safe side.  
 4068|       |     */
 4069|       |
 4070|      9|    pdu->securityEngineID = calloc(1, SNMP_MAX_ENG_SIZE * 2);
  ------------------
  |  |  111|      9|#define SNMP_MAX_ENG_SIZE          32
  ------------------
 4071|      9|    pdu->securityEngineIDLen = SNMP_MAX_ENG_SIZE * 2;
  ------------------
  |  |  111|      9|#define SNMP_MAX_ENG_SIZE          32
  ------------------
 4072|      9|    pdu->securityName = calloc(1, SNMP_MAX_SEC_NAME_SIZE);
  ------------------
  |  |  112|      9|#define SNMP_MAX_SEC_NAME_SIZE     256
  ------------------
 4073|      9|    pdu->securityNameLen = SNMP_MAX_SEC_NAME_SIZE;
  ------------------
  |  |  112|      9|#define SNMP_MAX_SEC_NAME_SIZE     256
  ------------------
 4074|       |
 4075|      9|    if ((pdu->securityName == NULL) ||
  ------------------
  |  Branch (4075:9): [True: 0, False: 9]
  ------------------
 4076|      9|        (pdu->securityEngineID == NULL) ||
  ------------------
  |  Branch (4076:9): [True: 0, False: 9]
  ------------------
 4077|      9|        (pdu->contextEngineID == NULL)) {
  ------------------
  |  Branch (4077:9): [True: 0, False: 9]
  ------------------
 4078|      0|        return SNMPERR_MALLOC;
  ------------------
  |  |  246|      0|#define SNMPERR_MALLOC			(-62)
  ------------------
 4079|      0|    }
 4080|       |
 4081|      9|    if (pdu_buf_len < msg_len
  ------------------
  |  Branch (4081:9): [True: 0, False: 9]
  ------------------
 4082|      0|        && pdu->securityLevel == SNMP_SEC_LEVEL_AUTHPRIV) {
  ------------------
  |  |  301|      0|#define SNMP_SEC_LEVEL_AUTHPRIV		3
  ------------------
  |  Branch (4082:12): [True: 0, False: 0]
  ------------------
 4083|       |        /*
 4084|       |         * space needed is larger than we have in the default buffer 
 4085|       |         */
 4086|      0|        mallocbuf = calloc(1, msg_len);
 4087|      0|        pdu_buf_len = msg_len;
 4088|      0|        cp = mallocbuf;
 4089|      9|    } else {
 4090|      9|        memset(pdu_buf, 0, pdu_buf_len);
 4091|      9|        cp = pdu_buf;
 4092|      9|    }
 4093|       |
 4094|      9|    DEBUGDUMPSECTION("recv", "SM msgSecurityParameters");
  ------------------
  |  |   81|      9|	do {if (_DBG_IF_) {__DBGDUMPSECTION(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      9|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 9]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	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: 9]
  |  |  ------------------
  ------------------
 4095|      9|    if (sptr->decode) {
  ------------------
  |  Branch (4095:9): [True: 9, False: 0]
  ------------------
 4096|      9|        struct snmp_secmod_incoming_params parms;
 4097|      9|        parms.msgProcModel = pdu->msgParseModel;
 4098|      9|        parms.maxMsgSize = pdu->msgMaxSize;
 4099|      9|        parms.secParams = sec_params;
 4100|      9|        parms.secModel = msg_sec_model;
 4101|      9|        parms.secLevel = pdu->securityLevel;
 4102|      9|        parms.wholeMsg = msg_data;
 4103|      9|        parms.wholeMsgLen = msg_len;
 4104|      9|        parms.secEngineID = pdu->securityEngineID;
 4105|      9|        parms.secEngineIDLen = &pdu->securityEngineIDLen;
 4106|      9|        parms.secName = pdu->securityName;
 4107|      9|        parms.secNameLen = &pdu->securityNameLen;
 4108|      9|        parms.scopedPdu = &cp;
 4109|      9|        parms.scopedPduLen = &pdu_buf_len;
 4110|      9|        parms.maxSizeResponse = &max_size_response;
 4111|      9|        parms.secStateRef = &pdu->securityStateRef;
 4112|      9|        parms.sess = sess;
 4113|      9|        parms.pdu = pdu;
 4114|      9|        parms.msg_flags = msg_flags;
 4115|      9|        ret_val = (*sptr->decode) (&parms);
 4116|      9|    } else {
 4117|      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]
  |  |  ------------------
  ------------------
 4118|      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]
  |  |  ------------------
  ------------------
 4119|      0|        snmp_log(LOG_WARNING, "security service %ld can't decode packets\n",
 4120|      0|                 msg_sec_model);
 4121|      0|        return (-1);
 4122|      0|    }
 4123|       |
 4124|      9|    if (ret_val != SNMPERR_SUCCESS) {
  ------------------
  |  |  184|      9|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  |  Branch (4124:9): [True: 9, False: 0]
  ------------------
 4125|      9|        DEBUGDUMPSECTION("recv", "ScopedPDU");
  ------------------
  |  |   81|      9|	do {if (_DBG_IF_) {__DBGDUMPSECTION(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      9|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 9]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	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: 9]
  |  |  ------------------
  ------------------
 4126|       |        /*
 4127|       |         * Parse as much as possible -- though I don't see the point? [jbpn].  
 4128|       |         */
 4129|      9|        if (cp) {
  ------------------
  |  Branch (4129:13): [True: 9, False: 0]
  ------------------
 4130|      9|            cp = snmpv3_scopedPDU_parse(pdu, cp, &pdu_buf_len);
 4131|      9|        }
 4132|      9|        if (cp) {
  ------------------
  |  Branch (4132:13): [True: 0, False: 9]
  ------------------
 4133|      0|            DEBUGPRINTPDUTYPE("recv", *cp);
  ------------------
  |  |  440|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4134|      0|            snmp_pdu_parse(pdu, cp, &pdu_buf_len);
 4135|      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]
  |  |  ------------------
  ------------------
 4136|      9|        } else {
 4137|      9|            DEBUGINDENTADD(-4);
  ------------------
  |  |   73|      9|#define DEBUGINDENTADD(x)  do {if (_DBG_IF_) {__DBGINDENTADD(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      9|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 9]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 9]
  |  |  ------------------
  ------------------
 4138|      9|        }
 4139|       |
 4140|      9|        SNMP_FREE(mallocbuf);
  ------------------
  |  |   62|      9|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 9]
  |  |  |  Branch (62:66): [Folded, False: 9]
  |  |  ------------------
  ------------------
 4141|      9|        return ret_val;
 4142|      9|    }
 4143|       |
 4144|       |    /*
 4145|       |     * parse plaintext ScopedPDU sequence 
 4146|       |     */
 4147|      0|    *length = pdu_buf_len;
 4148|      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]
  |  |  ------------------
  ------------------
 4149|      0|    data = snmpv3_scopedPDU_parse(pdu, cp, length);
 4150|      0|    if (data == NULL) {
  ------------------
  |  Branch (4150:9): [True: 0, False: 0]
  ------------------
 4151|      0|        snmp_log(LOG_WARNING, "security service %ld error parsing ScopedPDU\n",
 4152|      0|                 msg_sec_model);
 4153|      0|        ERROR_MSG("error parsing PDU");
  ------------------
  |  |  188|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 4154|      0|        snmp_increment_statistic(STAT_SNMPINASNPARSEERRS);
  ------------------
  |  |  637|      0|#define  STAT_SNMPINASNPARSEERRS             14
  ------------------
 4155|      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]
  |  |  ------------------
  ------------------
 4156|      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]
  |  |  ------------------
  ------------------
 4157|      0|        return SNMPERR_ASN_PARSE_ERR;
  ------------------
  |  |  213|      0|#define SNMPERR_ASN_PARSE_ERR           (-29)
  ------------------
 4158|      0|    }
 4159|       |
 4160|       |    /*
 4161|       |     * parse the PDU.  
 4162|       |     */
 4163|      0|    if (after_header != NULL) {
  ------------------
  |  Branch (4163:9): [True: 0, False: 0]
  ------------------
 4164|      0|        *after_header = data;
 4165|      0|        tmp_buf_len = *length;
 4166|      0|    }
 4167|       |
 4168|      0|    DEBUGPRINTPDUTYPE("recv", *data);
  ------------------
  |  |  440|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4169|      0|    ret = snmp_pdu_parse(pdu, data, length);
 4170|      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]
  |  |  ------------------
  ------------------
 4171|       |
 4172|      0|    if (after_header != NULL) {
  ------------------
  |  Branch (4172:9): [True: 0, False: 0]
  ------------------
 4173|      0|        *length = tmp_buf_len;
 4174|      0|    }
 4175|       |
 4176|      0|    if (ret != SNMPERR_SUCCESS) {
  ------------------
  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  |  Branch (4176:9): [True: 0, False: 0]
  ------------------
 4177|      0|        snmp_log(LOG_WARNING, "security service %ld error parsing ScopedPDU\n",
 4178|      0|                 msg_sec_model);
 4179|      0|        ERROR_MSG("error parsing PDU");
  ------------------
  |  |  188|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 4180|      0|        snmp_increment_statistic(STAT_SNMPINASNPARSEERRS);
  ------------------
  |  |  637|      0|#define  STAT_SNMPINASNPARSEERRS             14
  ------------------
 4181|      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]
  |  |  ------------------
  ------------------
 4182|      0|        return SNMPERR_ASN_PARSE_ERR;
  ------------------
  |  |  213|      0|#define SNMPERR_ASN_PARSE_ERR           (-29)
  ------------------
 4183|      0|    }
 4184|       |
 4185|      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]
  |  |  ------------------
  ------------------
 4186|      0|    return SNMPERR_SUCCESS;
  ------------------
  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 4187|      0|}                               /* end snmpv3_parse() */
snmp_parse:
 4713|     25|{
 4714|     25|    int             rc;
 4715|       |
 4716|     25|    rc = _snmp_parse(slp, pss, pdu, data, length);
 4717|     25|    if (rc) {
  ------------------
  |  Branch (4717:9): [True: 25, False: 0]
  ------------------
 4718|     25|        if (!pss->s_snmp_errno) {
  ------------------
  |  Branch (4718:13): [True: 19, False: 6]
  ------------------
 4719|     19|            pss->s_snmp_errno = SNMPERR_BAD_PARSE;
  ------------------
  |  |  197|     19|#define SNMPERR_BAD_PARSE		(-13)
  ------------------
 4720|     19|        }
 4721|     25|        SET_SNMP_ERROR(pss->s_snmp_errno);
  ------------------
  |  |   43|     25|#define SET_SNMP_ERROR(x) snmp_errno=(x)
  ------------------
 4722|     25|    }
 4723|       |
 4724|     25|    return rc;
 4725|     25|}
snmp_pdu_parse:
 4729|      6|{
 4730|      6|    u_char          type;
 4731|      6|    u_char          msg_type;
 4732|      6|    u_char         *var_val;
 4733|      6|    size_t          len;
 4734|      6|    size_t          four;
 4735|      6|    netsnmp_variable_list *vp = NULL, *vplast = NULL;
 4736|      6|    oid             objid[MAX_OID_LEN];
 4737|      6|    u_char         *p;
 4738|       |
 4739|       |    /*
 4740|       |     * Get the PDU type 
 4741|       |     */
 4742|      6|    data = asn_parse_header(data, length, &msg_type);
 4743|      6|    if (data == NULL)
  ------------------
  |  Branch (4743:9): [True: 2, False: 4]
  ------------------
 4744|      2|        return -1;
 4745|      4|    DEBUGMSGTL(("dumpv_recv","    Command %s\n", snmp_pdu_type(msg_type)));
  ------------------
  |  |   66|      4|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      4|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 4]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 4]
  |  |  ------------------
  ------------------
 4746|      4|    pdu->command = msg_type;
 4747|      4|    pdu->flags &= (~UCD_MSG_FLAG_RESPONSE_PDU);
  ------------------
  |  |  311|      4|#define UCD_MSG_FLAG_RESPONSE_PDU            0x100
  ------------------
 4748|       |
 4749|       |    /*
 4750|       |     * get the fields in the PDU preceding the variable-bindings sequence
 4751|       |     */
 4752|      4|    switch (pdu->command) {
 4753|      4|    case SNMP_MSG_TRAP:
  ------------------
  |  |  135|      4|#define SNMP_MSG_TRAP       (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x4) /* a4=164 */
  |  |  ------------------
  |  |  |  |   92|      4|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_MSG_TRAP       (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x4) /* a4=164 */
  |  |  ------------------
  |  |  |  |   96|      4|#define ASN_CONSTRUCTOR	    0x20U
  |  |  ------------------
  ------------------
  |  Branch (4753:5): [True: 4, False: 0]
  ------------------
 4754|       |        /*
 4755|       |         * enterprise 
 4756|       |         */
 4757|      4|        pdu->enterprise_length = MAX_OID_LEN;
  ------------------
  |  |  106|      4|#define MAX_OID_LEN	    128 /* max subid's in an oid */
  ------------------
 4758|      4|        data = asn_parse_objid(data, length, &type, objid,
 4759|      4|                               &pdu->enterprise_length);
 4760|      4|        if (data == NULL)
  ------------------
  |  Branch (4760:13): [True: 0, False: 4]
  ------------------
 4761|      0|            return -1;
 4762|      4|        pdu->enterprise = netsnmp_memdup(objid,
 4763|      4|                                         pdu->enterprise_length * sizeof(oid));
 4764|      4|        if (pdu->enterprise == NULL) {
  ------------------
  |  Branch (4764:13): [True: 0, False: 4]
  ------------------
 4765|      0|            return -1;
 4766|      0|        }
 4767|       |
 4768|       |        /*
 4769|       |         * agent-addr 
 4770|       |         */
 4771|      4|        four = 4;
 4772|      4|        data = asn_parse_string(data, length, &type,
 4773|      4|                                (u_char *) pdu->agent_addr, &four);
 4774|      4|        if (data == NULL)
  ------------------
  |  Branch (4774:13): [True: 0, False: 4]
  ------------------
 4775|      0|            return -1;
 4776|       |
 4777|       |        /*
 4778|       |         * generic trap 
 4779|       |         */
 4780|      4|        data = asn_parse_int(data, length, &type, (long *) &pdu->trap_type,
 4781|      4|                             sizeof(pdu->trap_type));
 4782|      4|        if (data == NULL)
  ------------------
  |  Branch (4782:13): [True: 0, False: 4]
  ------------------
 4783|      0|            return -1;
 4784|       |        /*
 4785|       |         * specific trap 
 4786|       |         */
 4787|      4|        data =
 4788|      4|            asn_parse_int(data, length, &type,
 4789|      4|                          (long *) &pdu->specific_type,
 4790|      4|                          sizeof(pdu->specific_type));
 4791|      4|        if (data == NULL)
  ------------------
  |  Branch (4791:13): [True: 0, False: 4]
  ------------------
 4792|      0|            return -1;
 4793|       |
 4794|       |        /*
 4795|       |         * timestamp  
 4796|       |         */
 4797|      4|        data = asn_parse_unsigned_int(data, length, &type, &pdu->time,
 4798|      4|                                      sizeof(pdu->time));
 4799|      4|        if (data == NULL)
  ------------------
  |  Branch (4799:13): [True: 1, False: 3]
  ------------------
 4800|      1|            return -1;
 4801|       |
 4802|      3|        break;
 4803|       |
 4804|      3|    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 (4804:5): [True: 0, False: 4]
  ------------------
 4805|      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 (4805:5): [True: 0, False: 4]
  ------------------
 4806|      0|        pdu->flags |= UCD_MSG_FLAG_RESPONSE_PDU;
  ------------------
  |  |  311|      0|#define UCD_MSG_FLAG_RESPONSE_PDU            0x100
  ------------------
 4807|      0|        NETSNMP_FALLTHROUGH;
  ------------------
  |  | 2411|      0|#    define NETSNMP_FALLTHROUGH __attribute__((__fallthrough__))
  ------------------
 4808|       |
 4809|      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 (4809:5): [True: 0, False: 4]
  ------------------
 4810|      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 (4810:5): [True: 0, False: 4]
  ------------------
 4811|      0|#ifndef NETSNMP_NOTIFY_ONLY
 4812|      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 (4812:5): [True: 0, False: 4]
  ------------------
 4813|      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 (4813:5): [True: 0, False: 4]
  ------------------
 4814|      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 (4814:5): [True: 0, False: 4]
  ------------------
 4815|      0|#endif /* ! NETSNMP_NOTIFY_ONLY */
 4816|      0|#ifndef NETSNMP_NO_WRITE_SUPPORT
 4817|      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 (4817:5): [True: 0, False: 4]
  ------------------
 4818|      0|#endif /* !NETSNMP_NO_WRITE_SUPPORT */
 4819|       |        /*
 4820|       |         * PDU is not an SNMPv1 TRAP 
 4821|       |         */
 4822|       |
 4823|       |        /*
 4824|       |         * request id 
 4825|       |         */
 4826|      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]
  |  |  ------------------
  ------------------
 4827|      0|        data = asn_parse_int(data, length, &type, &pdu->reqid,
 4828|      0|                             sizeof(pdu->reqid));
 4829|      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]
  |  |  ------------------
  ------------------
 4830|      0|        if (data == NULL) {
  ------------------
  |  Branch (4830:13): [True: 0, False: 0]
  ------------------
 4831|      0|            return -1;
 4832|      0|        }
 4833|       |
 4834|       |        /*
 4835|       |         * error status (getbulk non-repeaters) 
 4836|       |         */
 4837|      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]
  |  |  ------------------
  ------------------
 4838|      0|        data = asn_parse_int(data, length, &type, &pdu->errstat,
 4839|      0|                             sizeof(pdu->errstat));
 4840|      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]
  |  |  ------------------
  ------------------
 4841|      0|        if (data == NULL) {
  ------------------
  |  Branch (4841:13): [True: 0, False: 0]
  ------------------
 4842|      0|            return -1;
 4843|      0|        }
 4844|       |
 4845|       |        /*
 4846|       |         * error index (getbulk max-repetitions) 
 4847|       |         */
 4848|      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]
  |  |  ------------------
  ------------------
 4849|      0|        data = asn_parse_int(data, length, &type, &pdu->errindex,
 4850|      0|                             sizeof(pdu->errindex));
 4851|      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]
  |  |  ------------------
  ------------------
 4852|      0|        if (data == NULL) {
  ------------------
  |  Branch (4852:13): [True: 0, False: 0]
  ------------------
 4853|      0|            return -1;
 4854|      0|        }
 4855|      0|	break;
 4856|       |
 4857|      0|    default:
  ------------------
  |  Branch (4857:5): [True: 0, False: 4]
  ------------------
 4858|      0|        snmp_log(LOG_ERR, "Bad PDU type received: 0x%.2x\n", pdu->command);
 4859|      0|        snmp_increment_statistic(STAT_SNMPINASNPARSEERRS);
  ------------------
  |  |  637|      0|#define  STAT_SNMPINASNPARSEERRS             14
  ------------------
 4860|      0|        return -1;
 4861|      4|    }
 4862|       |
 4863|       |    /*
 4864|       |     * get header for variable-bindings sequence 
 4865|       |     */
 4866|      3|    DEBUGDUMPSECTION("recv", "VarBindList");
  ------------------
  |  |   81|      3|	do {if (_DBG_IF_) {__DBGDUMPSECTION(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      3|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 3]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	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: 3]
  |  |  ------------------
  ------------------
 4867|      3|    data = asn_parse_sequence(data, length, &type,
 4868|      3|                              (ASN_SEQUENCE | ASN_CONSTRUCTOR),
  ------------------
  |  |   84|      3|#define ASN_SEQUENCE	    0x10U
  ------------------
                                            (ASN_SEQUENCE | ASN_CONSTRUCTOR),
  ------------------
  |  |   96|      3|#define ASN_CONSTRUCTOR	    0x20U
  ------------------
 4869|      3|                              "varbinds");
 4870|      3|    if (data == NULL)
  ------------------
  |  Branch (4870:9): [True: 3, False: 0]
  ------------------
 4871|      3|        goto fail;
 4872|       |
 4873|       |    /*
 4874|       |     * get each varBind sequence 
 4875|       |     */
 4876|      0|    while ((int) *length > 0) {
  ------------------
  |  Branch (4876:12): [True: 0, False: 0]
  ------------------
 4877|      0|        vp = SNMP_MALLOC_TYPEDEF(netsnmp_variable_list);
  ------------------
  |  |   73|      0|#define SNMP_MALLOC_TYPEDEF(td)  (td *) calloc(1, sizeof(td))
  ------------------
 4878|      0|        if (NULL == vp)
  ------------------
  |  Branch (4878:13): [True: 0, False: 0]
  ------------------
 4879|      0|            goto fail;
 4880|       |
 4881|      0|        vp->name_length = MAX_OID_LEN;
  ------------------
  |  |  106|      0|#define MAX_OID_LEN	    128 /* max subid's in an oid */
  ------------------
 4882|      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]
  |  |  ------------------
  ------------------
 4883|      0|        data = snmp_parse_var_op(data, objid, &vp->name_length, &vp->type,
 4884|      0|                                 &vp->val_len, &var_val, length);
 4885|      0|        if (data == NULL)
  ------------------
  |  Branch (4885:13): [True: 0, False: 0]
  ------------------
 4886|      0|            goto fail;
 4887|      0|        if (snmp_set_var_objid(vp, objid, vp->name_length))
  ------------------
  |  Branch (4887:13): [True: 0, False: 0]
  ------------------
 4888|      0|            goto fail;
 4889|       |
 4890|      0|        len = SNMP_MAX_PACKET_LEN;
  ------------------
  |  |   49|      0|#define SNMP_MAX_PACKET_LEN (0x7fffffff)
  ------------------
 4891|      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]
  |  |  ------------------
  ------------------
 4892|      0|        switch ((short) vp->type) {
 4893|      0|        case ASN_INTEGER:
  ------------------
  |  |   75|      0|#define ASN_INTEGER	    0x02U
  ------------------
  |  Branch (4893:9): [True: 0, False: 0]
  ------------------
 4894|      0|            vp->val.integer = (long *) vp->buf;
 4895|      0|            vp->val_len = sizeof(long);
 4896|      0|            p = asn_parse_int(var_val, &len, &vp->type,
 4897|      0|                          (long *) vp->val.integer,
 4898|      0|                          sizeof(*vp->val.integer));
 4899|      0|            if (!p)
  ------------------
  |  Branch (4899:17): [True: 0, False: 0]
  ------------------
 4900|      0|                goto fail;
 4901|      0|            break;
 4902|      0|        case ASN_COUNTER:
  ------------------
  |  |   89|      0|#define ASN_COUNTER	(ASN_APPLICATION | 1)
  |  |  ------------------
  |  |  |  |   91|      0|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (4902:9): [True: 0, False: 0]
  ------------------
 4903|      0|        case ASN_GAUGE:
  ------------------
  |  |   90|      0|#define ASN_GAUGE	(ASN_APPLICATION | 2)
  |  |  ------------------
  |  |  |  |   91|      0|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (4903:9): [True: 0, False: 0]
  ------------------
 4904|      0|        case ASN_TIMETICKS:
  ------------------
  |  |   92|      0|#define ASN_TIMETICKS   (ASN_APPLICATION | 3)
  |  |  ------------------
  |  |  |  |   91|      0|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (4904:9): [True: 0, False: 0]
  ------------------
 4905|      0|        case ASN_UINTEGER:
  ------------------
  |  |  100|      0|#define ASN_UINTEGER    (ASN_APPLICATION | 7)   /* historic - don't use */
  |  |  ------------------
  |  |  |  |   91|      0|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (4905:9): [True: 0, False: 0]
  ------------------
 4906|      0|            vp->val.integer = (long *) vp->buf;
 4907|      0|            vp->val_len = sizeof(u_long);
 4908|      0|            p = asn_parse_unsigned_int(var_val, &len, &vp->type,
 4909|      0|                                   (u_long *) vp->val.integer,
 4910|      0|                                   vp->val_len);
 4911|      0|            if (!p)
  ------------------
  |  Branch (4911:17): [True: 0, False: 0]
  ------------------
 4912|      0|                goto fail;
 4913|      0|            break;
 4914|      0|#ifdef NETSNMP_WITH_OPAQUE_SPECIAL_TYPES
 4915|      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 (4915:9): [True: 0, False: 0]
  ------------------
 4916|      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 (4916:9): [True: 0, False: 0]
  ------------------
 4917|      0|#endif                          /* NETSNMP_WITH_OPAQUE_SPECIAL_TYPES */
 4918|      0|        case ASN_COUNTER64:
  ------------------
  |  |   99|      0|#define ASN_COUNTER64   (ASN_APPLICATION | 6)
  |  |  ------------------
  |  |  |  |   91|      0|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (4918:9): [True: 0, False: 0]
  ------------------
 4919|      0|            vp->val.counter64 = (struct counter64 *) vp->buf;
 4920|      0|            vp->val_len = sizeof(struct counter64);
 4921|      0|            p = asn_parse_unsigned_int64(var_val, &len, &vp->type,
 4922|      0|                                     (struct counter64 *) vp->val.
 4923|      0|                                     counter64, vp->val_len);
 4924|      0|            if (!p)
  ------------------
  |  Branch (4924:17): [True: 0, False: 0]
  ------------------
 4925|      0|                goto fail;
 4926|      0|            break;
 4927|      0|#ifdef NETSNMP_WITH_OPAQUE_SPECIAL_TYPES
 4928|      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 (4928:9): [True: 0, False: 0]
  ------------------
 4929|      0|            vp->val.floatVal = (float *) vp->buf;
 4930|      0|            vp->val_len = sizeof(float);
 4931|      0|            p = asn_parse_float(var_val, &len, &vp->type,
 4932|      0|                            vp->val.floatVal, vp->val_len);
 4933|      0|            if (!p)
  ------------------
  |  Branch (4933:17): [True: 0, False: 0]
  ------------------
 4934|      0|                goto fail;
 4935|      0|            break;
 4936|      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 (4936:9): [True: 0, False: 0]
  ------------------
 4937|      0|            vp->val.doubleVal = (double *) vp->buf;
 4938|      0|            vp->val_len = sizeof(double);
 4939|      0|            p = asn_parse_double(var_val, &len, &vp->type,
 4940|      0|                             vp->val.doubleVal, vp->val_len);
 4941|      0|            if (!p)
  ------------------
  |  Branch (4941:17): [True: 0, False: 0]
  ------------------
 4942|      0|                goto fail;
 4943|      0|            break;
 4944|      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 (4944:9): [True: 0, False: 0]
  ------------------
 4945|      0|            vp->val.counter64 = (struct counter64 *) vp->buf;
 4946|      0|            vp->val_len = sizeof(struct counter64);
 4947|      0|            p = asn_parse_signed_int64(var_val, &len, &vp->type,
 4948|      0|                                   (struct counter64 *) vp->val.counter64,
 4949|      0|                                   sizeof(*vp->val.counter64));
 4950|       |
 4951|      0|            if (!p)
  ------------------
  |  Branch (4951:17): [True: 0, False: 0]
  ------------------
 4952|      0|                goto fail;
 4953|      0|            break;
 4954|      0|#endif                          /* NETSNMP_WITH_OPAQUE_SPECIAL_TYPES */
 4955|      0|        case ASN_IPADDRESS:
  ------------------
  |  |   88|      0|#define ASN_IPADDRESS   (ASN_APPLICATION | 0)
  |  |  ------------------
  |  |  |  |   91|      0|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (4955:9): [True: 0, False: 0]
  ------------------
 4956|      0|            if (vp->val_len != 4)
  ------------------
  |  Branch (4956:17): [True: 0, False: 0]
  ------------------
 4957|      0|                goto fail;
 4958|      0|            NETSNMP_FALLTHROUGH;
  ------------------
  |  | 2411|      0|#    define NETSNMP_FALLTHROUGH __attribute__((__fallthrough__))
  ------------------
 4959|      0|        case ASN_OCTET_STR:
  ------------------
  |  |   78|      0|#define ASN_OCTET_STR	    0x04U
  ------------------
  |  Branch (4959:9): [True: 0, False: 0]
  ------------------
 4960|      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 (4960:9): [True: 0, False: 0]
  ------------------
 4961|      0|        case ASN_NSAP:
  ------------------
  |  |   98|      0|#define ASN_NSAP	(ASN_APPLICATION | 5)   /* historic - don't use */
  |  |  ------------------
  |  |  |  |   91|      0|#define ASN_APPLICATION     0x40U
  |  |  ------------------
  ------------------
  |  Branch (4961:9): [True: 0, False: 0]
  ------------------
 4962|      0|            if (vp->val_len < sizeof(vp->buf)) {
  ------------------
  |  Branch (4962:17): [True: 0, False: 0]
  ------------------
 4963|      0|                vp->val.string = (u_char *) vp->buf;
 4964|      0|            } else {
 4965|      0|                vp->val.string = (u_char *) malloc(vp->val_len);
 4966|      0|            }
 4967|      0|            if (vp->val.string == NULL) {
  ------------------
  |  Branch (4967:17): [True: 0, False: 0]
  ------------------
 4968|      0|                goto fail;
 4969|      0|            }
 4970|      0|            p = asn_parse_string(var_val, &len, &vp->type, vp->val.string,
 4971|      0|                             &vp->val_len);
 4972|      0|            if (!p)
  ------------------
  |  Branch (4972:17): [True: 0, False: 0]
  ------------------
 4973|      0|                goto fail;
 4974|      0|            break;
 4975|      0|        case ASN_OBJECT_ID:
  ------------------
  |  |   81|      0|#define ASN_OBJECT_ID	    0x06U
  ------------------
  |  Branch (4975:9): [True: 0, False: 0]
  ------------------
 4976|      0|            vp->val_len = MAX_OID_LEN;
  ------------------
  |  |  106|      0|#define MAX_OID_LEN	    128 /* max subid's in an oid */
  ------------------
 4977|      0|            p = asn_parse_objid(var_val, &len, &vp->type, objid, &vp->val_len);
 4978|      0|            if (!p)
  ------------------
  |  Branch (4978:17): [True: 0, False: 0]
  ------------------
 4979|      0|                goto fail;
 4980|      0|            vp->val_len *= sizeof(oid);
 4981|      0|            vp->val.objid = netsnmp_memdup(objid, vp->val_len);
 4982|      0|            if (vp->val.objid == NULL)
  ------------------
  |  Branch (4982:17): [True: 0, False: 0]
  ------------------
 4983|      0|                goto fail;
 4984|      0|            break;
 4985|      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 (4985:9): [True: 0, False: 0]
  ------------------
 4986|      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 (4986:9): [True: 0, False: 0]
  ------------------
 4987|      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 (4987:9): [True: 0, False: 0]
  ------------------
 4988|      0|        case ASN_NULL:
  ------------------
  |  |   79|      0|#define ASN_NULL	    0x05U
  ------------------
  |  Branch (4988:9): [True: 0, False: 0]
  ------------------
 4989|      0|            break;
 4990|      0|        case ASN_BIT_STR:
  ------------------
  |  |   77|      0|#define ASN_BIT_STR	    0x03U
  ------------------
  |  Branch (4990:9): [True: 0, False: 0]
  ------------------
 4991|      0|            vp->val.bitstring = (u_char *) malloc(vp->val_len);
 4992|      0|            if (vp->val.bitstring == NULL) {
  ------------------
  |  Branch (4992:17): [True: 0, False: 0]
  ------------------
 4993|      0|                goto fail;
 4994|      0|            }
 4995|      0|            p = asn_parse_bitstring(var_val, &len, &vp->type,
 4996|      0|                                vp->val.bitstring, &vp->val_len);
 4997|      0|            if (!p)
  ------------------
  |  Branch (4997:17): [True: 0, False: 0]
  ------------------
 4998|      0|                goto fail;
 4999|      0|            break;
 5000|      0|        default:
  ------------------
  |  Branch (5000:9): [True: 0, False: 0]
  ------------------
 5001|      0|            snmp_log(LOG_ERR, "bad type returned (%x)\n", vp->type);
 5002|      0|            goto fail;
 5003|      0|            break;
 5004|      0|        }
 5005|      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]
  |  |  ------------------
  ------------------
 5006|       |
 5007|      0|        if (NULL == vplast) {
  ------------------
  |  Branch (5007:13): [True: 0, False: 0]
  ------------------
 5008|      0|            pdu->variables = vp;
 5009|      0|        } else {
 5010|      0|            vplast->next_variable = vp;
 5011|      0|        }
 5012|      0|        vplast = vp;
 5013|      0|        vp = NULL;
 5014|      0|    }
 5015|      0|    return 0;
 5016|       |
 5017|      3|  fail:
 5018|      3|    {
 5019|      3|        const char *errstr = snmp_api_errstring(SNMPERR_SUCCESS);
  ------------------
  |  |  184|      3|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 5020|      3|        DEBUGMSGTL(("recv", "error while parsing VarBindList:%s\n", errstr));
  ------------------
  |  |   66|      3|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      3|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 3]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 3]
  |  |  ------------------
  ------------------
 5021|      3|    }
 5022|       |    /** if we were parsing a var, remove it from the pdu and free it */
 5023|      3|    if (vp)
  ------------------
  |  Branch (5023:9): [True: 0, False: 3]
  ------------------
 5024|      0|        snmp_free_var(vp);
 5025|       |
 5026|      3|    return -1;
 5027|      0|}
snmpv3_scopedPDU_parse:
 5038|      9|{
 5039|      9|    u_char          tmp_buf[SNMP_MAX_MSG_SIZE];
 5040|      9|    size_t          tmp_buf_len;
 5041|      9|    u_char          type;
 5042|      9|    size_t          asn_len;
 5043|      9|    u_char         *data;
 5044|       |
 5045|      9|    pdu->command = 0;           /* initialize so we know if it got parsed */
 5046|      9|    asn_len = *length;
 5047|      9|    data = asn_parse_sequence(cp, &asn_len, &type,
 5048|      9|                              (ASN_SEQUENCE | ASN_CONSTRUCTOR),
  ------------------
  |  |   84|      9|#define ASN_SEQUENCE	    0x10U
  ------------------
                                            (ASN_SEQUENCE | ASN_CONSTRUCTOR),
  ------------------
  |  |   96|      9|#define ASN_CONSTRUCTOR	    0x20U
  ------------------
 5049|      9|                              "plaintext scopedPDU");
 5050|      9|    if (data == NULL) {
  ------------------
  |  Branch (5050:9): [True: 9, False: 0]
  ------------------
 5051|      9|        return NULL;
 5052|      9|    }
 5053|      0|    *length -= data - cp;
 5054|       |
 5055|       |    /*
 5056|       |     * contextEngineID from scopedPdu  
 5057|       |     */
 5058|      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]
  |  |  ------------------
  ------------------
 5059|      0|    data = asn_parse_string(data, length, &type, pdu->contextEngineID,
 5060|      0|                            &pdu->contextEngineIDLen);
 5061|      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]
  |  |  ------------------
  ------------------
 5062|      0|    if (data == NULL) {
  ------------------
  |  Branch (5062:9): [True: 0, False: 0]
  ------------------
 5063|      0|        ERROR_MSG("error parsing contextEngineID from scopedPdu");
  ------------------
  |  |  188|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 5064|      0|        return NULL;
 5065|      0|    }
 5066|       |
 5067|       |    /*
 5068|       |     * parse contextName from scopedPdu
 5069|       |     */
 5070|      0|    tmp_buf_len = SNMP_MAX_CONTEXT_SIZE;
  ------------------
  |  |  113|      0|#define SNMP_MAX_CONTEXT_SIZE      256
  ------------------
 5071|      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]
  |  |  ------------------
  ------------------
 5072|      0|    data = asn_parse_string(data, length, &type, tmp_buf, &tmp_buf_len);
 5073|      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]
  |  |  ------------------
  ------------------
 5074|      0|    if (data == NULL) {
  ------------------
  |  Branch (5074:9): [True: 0, False: 0]
  ------------------
 5075|      0|        ERROR_MSG("error parsing contextName from scopedPdu");
  ------------------
  |  |  188|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 5076|      0|        return NULL;
 5077|      0|    }
 5078|       |
 5079|      0|    if (tmp_buf_len) {
  ------------------
  |  Branch (5079:9): [True: 0, False: 0]
  ------------------
 5080|      0|        pdu->contextName = netsnmp_memdup(tmp_buf, tmp_buf_len);
 5081|      0|        pdu->contextNameLen = tmp_buf_len;
 5082|      0|    } else {
 5083|      0|        pdu->contextName = strdup("");
 5084|      0|        pdu->contextNameLen = 0;
 5085|      0|    }
 5086|      0|    if (pdu->contextName == NULL) {
  ------------------
  |  Branch (5086:9): [True: 0, False: 0]
  ------------------
 5087|      0|        ERROR_MSG("error copying contextName from scopedPdu");
  ------------------
  |  |  188|      0|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 5088|      0|        return NULL;
 5089|      0|    }
 5090|       |
 5091|       |    /*
 5092|       |     * Get the PDU type 
 5093|       |     */
 5094|      0|    asn_len = *length;
 5095|      0|    cp = asn_parse_header(data, &asn_len, &type);
 5096|      0|    if (cp == NULL)
  ------------------
  |  Branch (5096:9): [True: 0, False: 0]
  ------------------
 5097|      0|        return NULL;
 5098|       |
 5099|      0|    pdu->command = type;
 5100|       |
 5101|      0|    return data;
 5102|      0|}
snmp_free_varbind:
 5674|     25|{
 5675|     25|    netsnmp_variable_list *ptr;
 5676|     25|    while (var) {
  ------------------
  |  Branch (5676:12): [True: 0, False: 25]
  ------------------
 5677|      0|        ptr = var->next_variable;
 5678|      0|        snmp_free_var(var);
 5679|      0|        var = ptr;
 5680|      0|    }
 5681|     25|}
snmp_free_pdu:
 5688|     25|{
 5689|     25|    struct snmp_secmod_def *sptr;
 5690|       |
 5691|     25|    if (!pdu)
  ------------------
  |  Branch (5691:9): [True: 0, False: 25]
  ------------------
 5692|      0|        return;
 5693|       |
 5694|     25|    free_securityStateRef(pdu);
 5695|       |
 5696|     25|    sptr = find_sec_mod(pdu->securityModel);
 5697|     25|    if (sptr && sptr->pdu_free)
  ------------------
  |  Branch (5697:9): [True: 9, False: 16]
  |  Branch (5697:17): [True: 0, False: 9]
  ------------------
 5698|      0|        (*sptr->pdu_free)(pdu);
 5699|       |
 5700|     25|    snmp_free_varbind(pdu->variables);
 5701|     25|    free(pdu->enterprise);
 5702|     25|    free(pdu->community);
 5703|     25|    free(pdu->contextEngineID);
 5704|     25|    free(pdu->securityEngineID);
 5705|     25|    free(pdu->contextName);
 5706|     25|    free(pdu->securityName);
 5707|     25|    free(pdu->transport_data);
 5708|     25|    free(pdu);
 5709|     25|}
snmp_create_sess_pdu:
 5714|     25|{
 5715|     25|    netsnmp_pdu *pdu = calloc(1, sizeof(netsnmp_pdu));
 5716|     25|    if (pdu == NULL) {
  ------------------
  |  Branch (5716:9): [True: 0, False: 25]
  ------------------
 5717|      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]
  |  |  ------------------
  ------------------
 5718|      0|        return NULL;
 5719|      0|    }
 5720|       |
 5721|       |    /*
 5722|       |     * Save the transport-level data specific to this reception (e.g. UDP
 5723|       |     * source address).  
 5724|       |     */
 5725|       |
 5726|     25|    pdu->transport_data = opaque;
 5727|     25|    pdu->transport_data_length = olength;
 5728|     25|    pdu->tDomain = transport->domain;
 5729|     25|    pdu->tDomainLen = transport->domain_length;
 5730|     25|    return pdu;
 5731|     25|}
snmp_read:
 6120|     56|{
 6121|     56|    netsnmp_large_fd_set lfdset;
 6122|       |
 6123|       |    netsnmp_large_fd_set_init(&lfdset, FD_SETSIZE);
 6124|     56|    netsnmp_copy_fd_set_to_large_fd_set(&lfdset, fdset);
 6125|     56|    snmp_read2(&lfdset);
 6126|     56|    netsnmp_large_fd_set_cleanup(&lfdset);
 6127|     56|}
snmp_read2:
 6131|     56|{
 6132|     56|    struct session_list *slp, *next;
 6133|       |
 6134|     56|    snmp_res_lock(MT_LIBRARY_ID, MT_LIB_SESSION);
  ------------------
  |  |   79|     56|#define snmp_res_lock(x,y) do {} while (0)
  |  |  ------------------
  |  |  |  Branch (79:41): [Folded, False: 56]
  |  |  ------------------
  ------------------
 6135|    112|    for (slp = Sessions; slp; slp = next) {
  ------------------
  |  Branch (6135:26): [True: 56, False: 56]
  ------------------
 6136|     56|        next = slp->next;
 6137|     56|        snmp_sess_read2(slp, fdset);
 6138|     56|    }
 6139|     56|    snmp_res_unlock(MT_LIBRARY_ID, MT_LIB_SESSION);
  ------------------
  |  |   80|     56|#define snmp_res_unlock(x,y) do {} while (0)
  |  |  ------------------
  |  |  |  Branch (80:43): [Folded, False: 56]
  |  |  ------------------
  ------------------
 6140|     56|}
_sess_read:
 6299|     56|{
 6300|     56|    netsnmp_session *sp = slp ? slp->session : NULL;
  ------------------
  |  Branch (6300:27): [True: 56, False: 0]
  ------------------
 6301|     56|    struct snmp_internal_session *isp = slp ? slp->internal : NULL;
  ------------------
  |  Branch (6301:41): [True: 56, False: 0]
  ------------------
 6302|     56|    netsnmp_transport *transport = slp ? slp->transport : NULL;
  ------------------
  |  Branch (6302:36): [True: 56, False: 0]
  ------------------
 6303|     56|    size_t          pdulen = 0, rxbuf_len = SNMP_MAX_RCV_MSG_SIZE;
  ------------------
  |  |  108|     56|#define SNMP_MAX_RCV_MSG_SIZE      65536
  ------------------
 6304|     56|    u_char         *rxbuf = NULL;
 6305|     56|    int             length = 0, olength = 0, rc = 0;
 6306|     56|    void           *opaque = NULL;
 6307|       |
 6308|     56|    if (NULL == slp || NULL == sp || NULL == isp || NULL == transport) {
  ------------------
  |  Branch (6308:9): [True: 0, False: 56]
  |  Branch (6308:24): [True: 0, False: 56]
  |  Branch (6308:38): [True: 0, False: 56]
  |  Branch (6308:53): [True: 0, False: 56]
  ------------------
 6309|      0|        snmp_log(LOG_ERR, "bad parameters to _sess_read\n");
 6310|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
 6311|      0|    }
 6312|       |
 6313|       |    /* to avoid subagent crash */ 
 6314|     56|    if (transport->sock < 0) { 
  ------------------
  |  Branch (6314:9): [True: 0, False: 56]
  ------------------
 6315|      0|        snmp_log (LOG_INFO, "transport->sock got negative fd value %d\n",
 6316|      0|                  transport->sock);
 6317|      0|        return 0; 
 6318|      0|    }
 6319|       |
 6320|     56|    if (!fdset || !(NETSNMP_LARGE_FD_ISSET(transport->sock, fdset))) {
  ------------------
  |  |   50|     56|                    netsnmp_large_fd_is_set(fd, fdset)
  ------------------
  |  Branch (6320:9): [True: 0, False: 56]
  |  Branch (6320:19): [True: 0, False: 56]
  ------------------
 6321|      0|        DEBUGMSGTL(("sess_read", "not reading %d (fdset %p set %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 (164:52): [True: 0, False: 0]
  |  |  |  |  |  Branch (164:64): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 6322|      0|                    transport->sock, fdset,
 6323|      0|                    fdset ? NETSNMP_LARGE_FD_ISSET(transport->sock, fdset)
 6324|      0|		    : -9));
 6325|      0|        return 0;
 6326|      0|    }
 6327|       |
 6328|     56|    sp->s_snmp_errno = 0;
 6329|     56|    sp->s_errno = 0;
 6330|       |
 6331|     56|    if (transport->flags & NETSNMP_TRANSPORT_FLAG_LISTEN)
  ------------------
  |  |   52|     56|#define		NETSNMP_TRANSPORT_FLAG_LISTEN	 0x02
  ------------------
  |  Branch (6331:9): [True: 0, False: 56]
  ------------------
 6332|      0|        return _sess_read_accept(slp);
 6333|       |
 6334|     56|    if (!(transport->flags & NETSNMP_TRANSPORT_FLAG_STREAM)) {
  ------------------
  |  |   51|     56|#define		NETSNMP_TRANSPORT_FLAG_STREAM	 0x01
  ------------------
  |  Branch (6334:9): [True: 56, False: 0]
  ------------------
 6335|     56|        snmp_rcv_packet rcvp;
 6336|     56|        u_char *pptr;
 6337|     56|        size_t len_remaining, pdulen;
 6338|     56|        void *ocopy = NULL;
 6339|       |
 6340|     56|        memset(&rcvp, 0x0, sizeof(rcvp));
 6341|       |
 6342|       |        /** read the packet */
 6343|     56|        rc = _sess_read_dgram_packet(slp, fdset, &rcvp);
 6344|     56|        if (-1 == rc) /* protocol error */
  ------------------
  |  Branch (6344:13): [True: 0, False: 56]
  ------------------
 6345|      0|            return -1;
 6346|     56|        else if (-2 == rc) /* no packet to process */
  ------------------
  |  Branch (6346:18): [True: 0, False: 56]
  ------------------
 6347|      0|            return 0;
 6348|       |
 6349|     56|        pptr = rcvp.packet;
 6350|     56|        len_remaining = rcvp.packet_len;
 6351|     56|        rc = 0;
 6352|       |
 6353|     81|        while (len_remaining > 0) {
  ------------------
  |  Branch (6353:16): [True: 73, False: 8]
  ------------------
 6354|     73|            if (isp->check_packet) {
  ------------------
  |  Branch (6354:17): [True: 0, False: 73]
  ------------------
 6355|      0|                pdulen = isp->check_packet(pptr, len_remaining);
 6356|     73|            } else {
 6357|     73|                pdulen = asn_check_packet(pptr, len_remaining);
 6358|     73|            }
 6359|     73|            if (pdulen == 0 || pdulen > len_remaining || pdulen > SNMP_MAX_PACKET_LEN) {
  ------------------
  |  |   49|     25|#define SNMP_MAX_PACKET_LEN (0x7fffffff)
  ------------------
  |  Branch (6359:17): [True: 19, False: 54]
  |  Branch (6359:32): [True: 29, False: 25]
  |  Branch (6359:58): [True: 0, False: 25]
  ------------------
 6360|       |                /* Not a valid packet or incomplete in datagram mode */
 6361|     48|                if (pptr == rcvp.packet) {
  ------------------
  |  Branch (6361:21): [True: 36, False: 12]
  ------------------
 6362|     36|                    SNMP_FREE(rcvp.opaque);
  ------------------
  |  |   62|     36|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 36, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 36]
  |  |  ------------------
  ------------------
 6363|     36|                }
 6364|     48|                break;
 6365|     48|            }
 6366|     25|            if (pdulen < len_remaining) {
  ------------------
  |  Branch (6366:17): [True: 17, False: 8]
  ------------------
 6367|     17|                if (rcvp.olength > 0 && rcvp.opaque != NULL) {
  ------------------
  |  Branch (6367:21): [True: 17, False: 0]
  |  Branch (6367:41): [True: 17, False: 0]
  ------------------
 6368|     17|                    ocopy = malloc(rcvp.olength);
 6369|     17|                    if (ocopy != NULL) {
  ------------------
  |  Branch (6369:25): [True: 17, False: 0]
  ------------------
 6370|     17|                        memcpy(ocopy, rcvp.opaque, rcvp.olength);
 6371|     17|                    }
 6372|     17|                }
 6373|     17|            } else {
 6374|      8|                ocopy = rcvp.opaque;
 6375|      8|                rcvp.opaque = NULL;
 6376|      8|            }
 6377|     25|            rc = _sess_process_packet(slp, sp, isp, transport,
 6378|     25|                                      ocopy, ocopy ? rcvp.olength : 0,
  ------------------
  |  Branch (6378:46): [True: 25, False: 0]
  ------------------
 6379|     25|                                      pptr, pdulen);
 6380|     25|            ocopy = NULL;
 6381|     25|            pptr += pdulen;
 6382|     25|            len_remaining -= pdulen;
 6383|     25|        }
 6384|     56|        SNMP_FREE(rcvp.packet);
  ------------------
  |  |   62|     56|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 56, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 56]
  |  |  ------------------
  ------------------
 6385|     56|        SNMP_FREE(rcvp.opaque);
  ------------------
  |  |   62|     56|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 12, False: 44]
  |  |  |  Branch (62:66): [Folded, False: 56]
  |  |  ------------------
  ------------------
 6386|     56|        return rc;
 6387|     56|    }
 6388|       |
 6389|       |    /** stream transport */
 6390|       |
 6391|      0|        if (isp->packet == NULL) {
  ------------------
  |  Branch (6391:13): [True: 0, False: 0]
  ------------------
 6392|       |            /*
 6393|       |             * We have no saved packet.  Allocate one.  
 6394|       |             */
 6395|      0|            if ((isp->packet = (u_char *) malloc(rxbuf_len)) == NULL) {
  ------------------
  |  Branch (6395:17): [True: 0, False: 0]
  ------------------
 6396|      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]
  |  |  ------------------
  ------------------
 6397|      0|                            "u bytes for rxbuf\n", rxbuf_len));
 6398|      0|                return 0;
 6399|      0|            } else {
 6400|      0|                rxbuf = isp->packet;
 6401|      0|                isp->packet_size = rxbuf_len;
 6402|      0|                isp->packet_len = 0;
 6403|      0|            }
 6404|      0|        } else {
 6405|       |            /*
 6406|       |             * We have saved a partial packet from last time.  Extend that, if
 6407|       |             * necessary, and receive new data after the old data.  
 6408|       |             */
 6409|      0|            u_char         *newbuf;
 6410|       |
 6411|      0|            if (isp->packet_size < isp->packet_len + rxbuf_len) {
  ------------------
  |  Branch (6411:17): [True: 0, False: 0]
  ------------------
 6412|      0|                newbuf =
 6413|      0|                    (u_char *) realloc(isp->packet,
 6414|      0|                                       isp->packet_len + rxbuf_len);
 6415|      0|                if (newbuf == NULL) {
  ------------------
  |  Branch (6415:21): [True: 0, False: 0]
  ------------------
 6416|      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]
  |  |  ------------------
  ------------------
 6417|      0|                                "can't malloc %" NETSNMP_PRIz
 6418|      0|                                "u more for rxbuf (%" NETSNMP_PRIz "u tot)\n",
 6419|      0|                                rxbuf_len, isp->packet_len + rxbuf_len));
 6420|      0|                    return 0;
 6421|      0|                } else {
 6422|      0|                    isp->packet = newbuf;
 6423|      0|                    isp->packet_size = isp->packet_len + rxbuf_len;
 6424|      0|                    rxbuf = isp->packet + isp->packet_len;
 6425|      0|                }
 6426|      0|            } else {
 6427|      0|                rxbuf = isp->packet + isp->packet_len;
 6428|      0|                rxbuf_len = isp->packet_size - isp->packet_len;
 6429|      0|            }
 6430|      0|        }
 6431|       |
 6432|      0|    length = netsnmp_transport_recv(transport, rxbuf, rxbuf_len, &opaque,
 6433|      0|                                    &olength);
 6434|       |
 6435|      0|    if (0 == length && transport->flags & NETSNMP_TRANSPORT_FLAG_EMPTY_PKT) {
  ------------------
  |  |   56|      0|#define		NETSNMP_TRANSPORT_FLAG_EMPTY_PKT 0x10
  ------------------
  |  Branch (6435:9): [True: 0, False: 0]
  |  Branch (6435:24): [True: 0, False: 0]
  ------------------
 6436|       |        /* this allows for a transport that needs to return from
 6437|       |         * packet processing that doesn't necessarily have any
 6438|       |         * consumable data in it. */
 6439|       |
 6440|       |        /* reset the flag since it's a per-message flag */
 6441|      0|        transport->flags &= (~NETSNMP_TRANSPORT_FLAG_EMPTY_PKT);
  ------------------
  |  |   56|      0|#define		NETSNMP_TRANSPORT_FLAG_EMPTY_PKT 0x10
  ------------------
 6442|       |
 6443|      0|        return 0;
 6444|      0|    }
 6445|       |
 6446|       |    /*
 6447|       |     * Remote end closed connection.  
 6448|       |     */
 6449|      0|    if (length <= 0) {
  ------------------
  |  Branch (6449:9): [True: 0, False: 0]
  ------------------
 6450|       |        /*
 6451|       |         * Alert the application if possible.  
 6452|       |         */
 6453|      0|        if (sp->callback != NULL) {
  ------------------
  |  Branch (6453:13): [True: 0, False: 0]
  ------------------
 6454|      0|            DEBUGMSGTL(("sess_read", "perform callback with op=DISCONNECT\n"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 6455|      0|            (void) sp->callback(NETSNMP_CALLBACK_OP_DISCONNECT, sp, 0,
  ------------------
  |  |  323|      0|#define NETSNMP_CALLBACK_OP_DISCONNECT		5
  ------------------
 6456|      0|                                NULL, sp->callback_magic);
 6457|      0|        }
 6458|       |        /*
 6459|       |         * Close socket and mark session for deletion.  
 6460|       |         */
 6461|      0|        DEBUGMSGTL(("sess_read", "fd %d closed\n", transport->sock));
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 6462|      0|        transport->f_close(transport);
 6463|      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]
  |  |  ------------------
  ------------------
 6464|      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]
  |  |  ------------------
  ------------------
 6465|      0|        return -1;
 6466|      0|    }
 6467|       |
 6468|      0|    {
 6469|      0|        u_char *pptr = isp->packet;
 6470|      0|	void *ocopy = NULL;
 6471|       |
 6472|      0|        isp->packet_len += length;
 6473|       |
 6474|      0|        while (isp->packet_len > 0) {
  ------------------
  |  Branch (6474:16): [True: 0, False: 0]
  ------------------
 6475|       |
 6476|       |            /*
 6477|       |             * Get the total data length we're expecting (and need to wait
 6478|       |             * for).
 6479|       |             */
 6480|      0|            if (isp->check_packet) {
  ------------------
  |  Branch (6480:17): [True: 0, False: 0]
  ------------------
 6481|      0|                pdulen = isp->check_packet(pptr, isp->packet_len);
 6482|      0|            } else {
 6483|      0|                pdulen = asn_check_packet(pptr, isp->packet_len);
 6484|      0|            }
 6485|       |
 6486|      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]
  |  |  ------------------
  ------------------
 6487|      0|                        "  loop packet_len %" NETSNMP_PRIz "u, PDU length %"
 6488|      0|                        NETSNMP_PRIz "u\n", isp->packet_len, pdulen));
 6489|       |
 6490|      0|            if (pdulen > SNMP_MAX_PACKET_LEN) {
  ------------------
  |  |   49|      0|#define SNMP_MAX_PACKET_LEN (0x7fffffff)
  ------------------
  |  Branch (6490:17): [True: 0, False: 0]
  ------------------
 6491|       |                /*
 6492|       |                 * Illegal length, drop the connection.  
 6493|       |                 */
 6494|      0|                snmp_log(LOG_ERR, 
 6495|      0|			 "Received broken packet. Closing session.\n");
 6496|      0|		if (sp->callback != NULL) {
  ------------------
  |  Branch (6496:7): [True: 0, False: 0]
  ------------------
 6497|      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]
  |  |  ------------------
  ------------------
 6498|      0|			      "perform callback with op=DISCONNECT\n"));
 6499|      0|		  (void)sp->callback(NETSNMP_CALLBACK_OP_DISCONNECT,
  ------------------
  |  |  323|      0|#define NETSNMP_CALLBACK_OP_DISCONNECT		5
  ------------------
 6500|      0|				     sp, 0, NULL, sp->callback_magic);
 6501|      0|		}
 6502|      0|		DEBUGMSGTL(("sess_read", "fd %d closed\n", transport->sock));
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 6503|      0|                transport->f_close(transport);
 6504|      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]
  |  |  ------------------
  ------------------
 6505|       |                /** XXX-rks: why no SNMP_FREE(isp->packet); ?? */
 6506|      0|                return -1;
 6507|      0|            }
 6508|       |
 6509|      0|            if (pdulen > isp->packet_len || pdulen == 0) {
  ------------------
  |  Branch (6509:17): [True: 0, False: 0]
  |  Branch (6509:45): [True: 0, False: 0]
  ------------------
 6510|       |                /*
 6511|       |                 * We don't have a complete packet yet.  If we've already
 6512|       |                 * processed a packet, break out so we'll shift this packet
 6513|       |                 * to the start of the buffer. If we're already at the
 6514|       |                 * start, simply return and wait for more data to arrive.
 6515|       |                 */
 6516|      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]
  |  |  ------------------
  ------------------
 6517|      0|                            "pkt not complete (need %" NETSNMP_PRIz "u got %"
 6518|      0|                            NETSNMP_PRIz "u so far)\n", pdulen,
 6519|      0|                            isp->packet_len));
 6520|       |
 6521|      0|                if (pptr != isp->packet)
  ------------------
  |  Branch (6521:21): [True: 0, False: 0]
  ------------------
 6522|      0|                    break; /* opaque freed for us outside of loop. */
 6523|       |
 6524|      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]
  |  |  ------------------
  ------------------
 6525|      0|                return 0;
 6526|      0|            }
 6527|       |
 6528|       |            /*  We have *at least* one complete packet in the buffer now.  If
 6529|       |		we have possibly more than one packet, we must copy the opaque
 6530|       |		pointer because we may need to reuse it for a later packet.  */
 6531|       |
 6532|      0|	    if (pdulen < isp->packet_len) {
  ------------------
  |  Branch (6532:10): [True: 0, False: 0]
  ------------------
 6533|      0|		if (olength > 0 && opaque != NULL) {
  ------------------
  |  Branch (6533:7): [True: 0, False: 0]
  |  Branch (6533:22): [True: 0, False: 0]
  ------------------
 6534|      0|		    ocopy = malloc(olength);
 6535|      0|		    if (ocopy != NULL) {
  ------------------
  |  Branch (6535:11): [True: 0, False: 0]
  ------------------
 6536|      0|			memcpy(ocopy, opaque, olength);
 6537|      0|		    }
 6538|      0|		}
 6539|      0|	    } else if (pdulen == isp->packet_len) {
  ------------------
  |  Branch (6539:17): [True: 0, False: 0]
  ------------------
 6540|       |		/*  Common case -- exactly one packet.  No need to copy the
 6541|       |		    opaque pointer.  */
 6542|      0|		ocopy = opaque;
 6543|      0|		opaque = NULL;
 6544|      0|	    }
 6545|       |
 6546|      0|            if ((rc = _sess_process_packet(slp, sp, isp, transport,
  ------------------
  |  Branch (6546:17): [True: 0, False: 0]
  ------------------
 6547|      0|                                           ocopy, ocopy?olength:0, pptr,
  ------------------
  |  Branch (6547:51): [True: 0, False: 0]
  ------------------
 6548|      0|                                           pdulen))) {
 6549|       |                /*
 6550|       |                 * Something went wrong while processing this packet -- set the
 6551|       |                 * errno.  
 6552|       |                 */
 6553|      0|                if (sp->s_snmp_errno != 0) {
  ------------------
  |  Branch (6553:21): [True: 0, False: 0]
  ------------------
 6554|      0|                    SET_SNMP_ERROR(sp->s_snmp_errno);
  ------------------
  |  |   43|      0|#define SET_SNMP_ERROR(x) snmp_errno=(x)
  ------------------
 6555|      0|                }
 6556|      0|            }
 6557|       |
 6558|       |	    /*  ocopy has been free()d by _sess_process_packet by this point,
 6559|       |		so set it to NULL.  */
 6560|       |
 6561|      0|	    ocopy = NULL;
 6562|       |
 6563|       |	    /*  Step past the packet we've just dealt with.  */
 6564|       |
 6565|      0|            pptr += pdulen;
 6566|      0|            isp->packet_len -= pdulen;
 6567|      0|        }
 6568|       |
 6569|       |	/*  If we had more than one packet, then we were working with copies
 6570|       |	    of the opaque pointer, so we still need to free() the opaque
 6571|       |	    pointer itself.  */
 6572|       |
 6573|      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]
  |  |  ------------------
  ------------------
 6574|       |
 6575|      0|        if (isp->packet_len >= SNMP_MAX_PACKET_LEN) {
  ------------------
  |  |   49|      0|#define SNMP_MAX_PACKET_LEN (0x7fffffff)
  ------------------
  |  Branch (6575:13): [True: 0, False: 0]
  ------------------
 6576|       |            /*
 6577|       |             * Obviously this should never happen!  
 6578|       |             */
 6579|      0|            snmp_log(LOG_ERR,
 6580|      0|                     "too large packet_len = %" NETSNMP_PRIz
 6581|      0|                     "u, dropping connection %d\n",
 6582|      0|                     isp->packet_len, transport->sock);
 6583|      0|            transport->f_close(transport);
 6584|       |            /** XXX-rks: why no SNMP_FREE(isp->packet); ?? */
 6585|      0|            return -1;
 6586|      0|        } else if (isp->packet_len == 0) {
  ------------------
  |  Branch (6586:20): [True: 0, False: 0]
  ------------------
 6587|       |            /*
 6588|       |             * This is good: it means the packet buffer contained an integral
 6589|       |             * number of PDUs, so we don't have to save any data for next
 6590|       |             * time.  We can free() the buffer now to keep the memory
 6591|       |             * footprint down.
 6592|       |             */
 6593|      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]
  |  |  ------------------
  ------------------
 6594|      0|            isp->packet_size = 0;
 6595|      0|            isp->packet_len = 0;
 6596|      0|            return rc;
 6597|      0|        }
 6598|       |
 6599|       |        /*
 6600|       |         * If we get here, then there is a partial packet of length
 6601|       |         * isp->packet_len bytes starting at pptr left over.  Move that to the
 6602|       |         * start of the buffer, and then realloc() the buffer down to size to
 6603|       |         * reduce the memory footprint.  
 6604|       |         */
 6605|       |
 6606|      0|        memmove(isp->packet, pptr, isp->packet_len);
 6607|      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]
  |  |  ------------------
  ------------------
 6608|      0|                    "end: memmove(%p, %p, %" NETSNMP_PRIz "u); realloc(%p, %"
 6609|      0|                    NETSNMP_PRIz "u)\n",
 6610|      0|                    isp->packet, pptr, isp->packet_len,
 6611|      0|		    isp->packet, isp->packet_len));
 6612|       |
 6613|      0|        if ((rxbuf = (u_char *)realloc(isp->packet, isp->packet_len)) == NULL) {
  ------------------
  |  Branch (6613:13): [True: 0, False: 0]
  ------------------
 6614|       |            /*
 6615|       |             * I don't see why this should ever fail, but it's not a big deal.
 6616|       |             */
 6617|      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]
  |  |  ------------------
  ------------------
 6618|      0|        } else {
 6619|      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]
  |  |  ------------------
  ------------------
 6620|      0|                        isp->packet, rxbuf));
 6621|      0|            isp->packet = rxbuf;
 6622|      0|            isp->packet_size = isp->packet_len;
 6623|      0|        }
 6624|      0|    }
 6625|       |
 6626|      0|    return rc;
 6627|      0|}
snmp_sess_read2:
 6649|     56|{
 6650|     56|    netsnmp_session *pss;
 6651|     56|    int             rc;
 6652|       |
 6653|     56|    rc = _sess_read(slp, fdset);
 6654|     56|    pss = slp->session;
 6655|     56|    if (rc && pss->s_snmp_errno) {
  ------------------
  |  Branch (6655:9): [True: 20, False: 36]
  |  Branch (6655:15): [True: 20, False: 0]
  ------------------
 6656|     20|        SET_SNMP_ERROR(pss->s_snmp_errno);
  ------------------
  |  |   43|     20|#define SET_SNMP_ERROR(x) snmp_errno=(x)
  ------------------
 6657|     20|    }
 6658|     56|    return rc;
 6659|     56|}
snmp_select_info:
 6689|     56|{
 6690|       |    return snmp_sess_select_info(NULL, numfds, fdset, timeout, block);
 6691|     56|}
snmp_sess_select_info:
 6709|     56|{
 6710|     56|    return snmp_sess_select_info_flags(slp, numfds, fdset, timeout, block,
 6711|     56|                                       NETSNMP_SELECT_NOFLAGS);
  ------------------
  |  |  192|     56|#define NETSNMP_SELECT_NOFLAGS  0x00
  ------------------
 6712|     56|}
snmp_sess_select_info_flags:
 6720|     56|{
 6721|     56|  int rc;
 6722|     56|  netsnmp_large_fd_set lfdset;
 6723|       |
 6724|     56|  netsnmp_large_fd_set_init(&lfdset, FD_SETSIZE);
 6725|     56|  netsnmp_copy_fd_set_to_large_fd_set(&lfdset, fdset);
 6726|     56|  rc = snmp_sess_select_info2_flags(slp, numfds, &lfdset, timeout,
 6727|     56|                                    block, flags);
 6728|     56|  if (netsnmp_copy_large_fd_set_to_fd_set(fdset, &lfdset) < 0) {
  ------------------
  |  Branch (6728:7): [True: 0, False: 56]
  ------------------
 6729|       |      snmp_log(LOG_ERR,
 6730|      0|	     "Use snmp_sess_select_info2() for processing"
 6731|      0|	     " large file descriptors\n");
 6732|      0|  }
 6733|     56|  netsnmp_large_fd_set_cleanup(&lfdset);
 6734|     56|  return rc;
 6735|     56|}
snmp_sess_select_info2_flags:
 6779|     56|{
 6780|     56|    struct session_list *slp, *next = NULL;
 6781|     56|    netsnmp_request_list *rp;
 6782|     56|    struct timeval  now, earliest, alarm_tm;
 6783|     56|    int             active = 0, requests = 0;
 6784|     56|    int             next_alarm = 0;
 6785|       |
 6786|     56|    timerclear(&earliest);
 6787|       |
 6788|       |    /*
 6789|       |     * For each session examined, add its socket to the fdset,
 6790|       |     * and if it is the earliest timeout to expire, mark it as lowest.
 6791|       |     * If a single session is specified, do just for that session.
 6792|       |     */
 6793|       |
 6794|     56|    DEBUGMSGTL(("sess_select", "for %s session%s: ",
  ------------------
  |  |   66|     56|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     56|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 56]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#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: 56]
  |  |  ------------------
  ------------------
 6795|     56|                sessp ? "single" : "all", sessp ? "" : "s"));
 6796|       |
 6797|    112|    for (slp = sessp ? sessp : Sessions; slp; slp = next) {
  ------------------
  |  Branch (6797:16): [True: 0, False: 56]
  |  Branch (6797:42): [True: 56, False: 56]
  ------------------
 6798|     56|        next = slp->next;
 6799|       |
 6800|     56|        if (slp->transport == NULL) {
  ------------------
  |  Branch (6800:13): [True: 0, False: 56]
  ------------------
 6801|       |            /*
 6802|       |             * Close in progress -- skip this one.  
 6803|       |             */
 6804|      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]
  |  |  ------------------
  ------------------
 6805|      0|            continue;
 6806|      0|        }
 6807|       |
 6808|     56|        if (slp->transport->sock == -1) {
  ------------------
  |  Branch (6808:13): [True: 0, False: 56]
  ------------------
 6809|       |            /*
 6810|       |             * This session was marked for deletion.  
 6811|       |             */
 6812|      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]
  |  |  ------------------
  ------------------
 6813|      0|            if (sessp == NULL) {
  ------------------
  |  Branch (6813:17): [True: 0, False: 0]
  ------------------
 6814|      0|                snmp_close(slp->session);
 6815|      0|            } else {
 6816|      0|                snmp_sess_close(slp);
 6817|      0|            }
 6818|      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]
  |  |  ------------------
  ------------------
 6819|      0|                        sessp ? "single" : "all", sessp ? "" : "s"));
 6820|      0|            continue;
 6821|      0|        }
 6822|       |
 6823|     56|        DEBUGMSG(("sess_select", "%d ", slp->transport->sock));
  ------------------
  |  |   61|     56|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  144|     56|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 56]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (61:67): [Folded, False: 56]
  |  |  ------------------
  ------------------
 6824|     56|        if ((slp->transport->sock + 1) > *numfds) {
  ------------------
  |  Branch (6824:13): [True: 56, False: 0]
  ------------------
 6825|     56|            *numfds = (slp->transport->sock + 1);
 6826|     56|        }
 6827|       |
 6828|     56|        NETSNMP_LARGE_FD_SET(slp->transport->sock, fdset);
  ------------------
  |  |   35|     56|                    netsnmp_large_fd_setfd(fd, fdset)
  ------------------
 6829|     56|        if (slp->internal != NULL && slp->internal->requests) {
  ------------------
  |  Branch (6829:13): [True: 56, False: 0]
  |  Branch (6829:38): [True: 0, False: 56]
  ------------------
 6830|       |            /*
 6831|       |             * Found another session with outstanding requests.  
 6832|       |             */
 6833|      0|            requests++;
 6834|      0|            for (rp = slp->internal->requests; rp; rp = rp->next_request) {
  ------------------
  |  Branch (6834:48): [True: 0, False: 0]
  ------------------
 6835|      0|                if (!timerisset(&earliest)
  ------------------
  |  Branch (6835:21): [True: 0, False: 0]
  ------------------
 6836|      0|                    || (timerisset(&rp->expireM)
  ------------------
  |  Branch (6836:25): [True: 0, False: 0]
  ------------------
 6837|      0|                        && timercmp(&rp->expireM, &earliest, <))) {
  ------------------
  |  Branch (6837:28): [True: 0, False: 0]
  |  Branch (6837:28): [True: 0, False: 0]
  ------------------
 6838|      0|                    earliest = rp->expireM;
 6839|      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]
  |  |  ------------------
  ------------------
 6840|      0|                               (int)earliest.tv_sec, (int)earliest.tv_usec));
 6841|      0|                }
 6842|      0|            }
 6843|      0|        }
 6844|       |
 6845|     56|        active++;
 6846|     56|        if (sessp) {
  ------------------
  |  Branch (6846:13): [True: 0, False: 56]
  ------------------
 6847|       |            /*
 6848|       |             * Single session processing.  
 6849|       |             */
 6850|      0|            break;
 6851|      0|        }
 6852|     56|    }
 6853|     56|    DEBUGMSG(("sess_select", "\n"));
  ------------------
  |  |   61|     56|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  144|     56|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 56]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (61:67): [Folded, False: 56]
  |  |  ------------------
  ------------------
 6854|       |
 6855|     56|    netsnmp_get_monotonic_clock(&now);
 6856|       |
 6857|     56|    if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|     56|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (6857:9): [True: 0, False: 56]
  ------------------
 6858|     56|                               NETSNMP_DS_LIB_ALARM_DONT_USE_SIG) &&
  ------------------
  |  |   71|     56|#define NETSNMP_DS_LIB_ALARM_DONT_USE_SIG  11   /* don't use the alarm() signal */
  ------------------
 6859|      0|        !(flags & NETSNMP_SELECT_NOALARMS)) {
  ------------------
  |  |  193|      0|#define NETSNMP_SELECT_NOALARMS 0x01
  ------------------
  |  Branch (6859:9): [True: 0, False: 0]
  ------------------
 6860|      0|        next_alarm = netsnmp_get_next_alarm_time(&alarm_tm, &now);
 6861|      0|        if (next_alarm)
  ------------------
  |  Branch (6861:13): [True: 0, False: 0]
  ------------------
 6862|      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]
  |  |  ------------------
  ------------------
 6863|      0|                       (long)alarm_tm.tv_sec, (long)alarm_tm.tv_usec));
 6864|      0|    }
 6865|     56|    if (next_alarm == 0 && requests == 0) {
  ------------------
  |  Branch (6865:9): [True: 56, False: 0]
  |  Branch (6865:28): [True: 56, False: 0]
  ------------------
 6866|       |        /*
 6867|       |         * If none are active, skip arithmetic.  
 6868|       |         */
 6869|     56|        DEBUGMSGT(("sess_select","blocking:no session requests or alarms.\n"));
  ------------------
  |  |   62|     56|#define DEBUGMSGT(x)       do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     56|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 56]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #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: 56]
  |  |  ------------------
  ------------------
 6870|     56|        *block = 1; /* can block - timeout value is undefined if no requests */
 6871|     56|        return active;
 6872|     56|    }
 6873|       |
 6874|      0|    if (next_alarm &&
  ------------------
  |  Branch (6874:9): [True: 0, False: 0]
  ------------------
 6875|      0|        (!timerisset(&earliest) || timercmp(&alarm_tm, &earliest, <)))
  ------------------
  |  Branch (6875:10): [True: 0, False: 0]
  |  Branch (6875:36): [True: 0, False: 0]
  |  Branch (6875:36): [True: 0, False: 0]
  ------------------
 6876|      0|        earliest = alarm_tm;
 6877|       |
 6878|      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]
  |  |  ------------------
  ------------------
 6879|      0|    if (earliest.tv_sec < 0) {
  ------------------
  |  Branch (6879:9): [True: 0, False: 0]
  ------------------
 6880|      0|        time_t overdue_ms = -(earliest.tv_sec * 1000 + earliest.tv_usec / 1000);
 6881|      0|        if (overdue_ms >= 10)
  ------------------
  |  Branch (6881:13): [True: 0, False: 0]
  ------------------
 6882|      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]
  |  |  ------------------
  ------------------
 6883|      0|                       (long) overdue_ms));
 6884|      0|        timerclear(&earliest);
 6885|      0|    } else {
 6886|      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]
  |  |  ------------------
  ------------------
 6887|      0|                   (int)earliest.tv_sec, (int)earliest.tv_usec));
 6888|      0|    }
 6889|       |
 6890|       |    /*
 6891|       |     * if it was blocking before or our delta time is less, reset timeout 
 6892|       |     */
 6893|      0|    if ((*block || (timercmp(&earliest, timeout, <)))) {
  ------------------
  |  Branch (6893:10): [True: 0, False: 0]
  |  Branch (6893:20): [True: 0, False: 0]
  |  Branch (6893:21): [True: 0, False: 0]
  ------------------
 6894|      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]
  |  |  ------------------
  ------------------
 6895|      0|                   "setting timer to %d.%06d sec, clear block (was %d)\n",
 6896|      0|                   (int)earliest.tv_sec, (int)earliest.tv_usec, *block));
 6897|      0|        *timeout = earliest;
 6898|      0|        *block = 0;
 6899|      0|    }
 6900|      0|    return active;
 6901|     56|}
snmp_oid_compare:
 7175|    342|{
 7176|    342|    register int    len;
 7177|    342|    register const oid *name1 = in_name1;
 7178|    342|    register const oid *name2 = in_name2;
 7179|       |
 7180|       |    /*
 7181|       |     * len = minimum of len1 and len2 
 7182|       |     */
 7183|    342|    if (len1 < len2)
  ------------------
  |  Branch (7183:9): [True: 0, False: 342]
  ------------------
 7184|      0|        len = len1;
 7185|    342|    else
 7186|    342|        len = len2;
 7187|       |    /*
 7188|       |     * find first non-matching OID 
 7189|       |     */
 7190|  3.53k|    while (len-- > 0) {
  ------------------
  |  Branch (7190:12): [True: 3.42k, False: 114]
  ------------------
 7191|       |        /*
 7192|       |         * these must be done in separate comparisons, since
 7193|       |         * subtracting them and using that result has problems with
 7194|       |         * subids > 2^31. 
 7195|       |         */
 7196|  3.42k|        if (*(name1) != *(name2)) {
  ------------------
  |  Branch (7196:13): [True: 228, False: 3.19k]
  ------------------
 7197|    228|            if (*(name1) < *(name2))
  ------------------
  |  Branch (7197:17): [True: 114, False: 114]
  ------------------
 7198|    114|                return -1;
 7199|    114|            return 1;
 7200|    228|        }
 7201|  3.19k|        name1++;
 7202|  3.19k|        name2++;
 7203|  3.19k|    }
 7204|       |    /*
 7205|       |     * both OIDs equal up to length of shorter OID 
 7206|       |     */
 7207|    114|    if (len1 < len2)
  ------------------
  |  Branch (7207:9): [True: 0, False: 114]
  ------------------
 7208|      0|        return -1;
 7209|    114|    if (len2 < len1)
  ------------------
  |  Branch (7209:9): [True: 0, False: 114]
  ------------------
 7210|      0|        return 1;
 7211|    114|    return 0;
 7212|    114|}
netsnmp_oid_equals:
 7312|  3.14k|{
 7313|  3.14k|    register const oid *name1 = in_name1;
 7314|  3.14k|    register const oid *name2 = in_name2;
 7315|  3.14k|    register int    len = len1;
 7316|       |
 7317|       |    /*
 7318|       |     * len = minimum of len1 and len2 
 7319|       |     */
 7320|  3.14k|    if (len1 != len2)
  ------------------
  |  Branch (7320:9): [True: 2.17k, False: 974]
  ------------------
 7321|  2.17k|        return 1;
 7322|       |    /*
 7323|       |     * Handle 'null' OIDs
 7324|       |     */
 7325|    974|    if (len1 == 0)
  ------------------
  |  Branch (7325:9): [True: 0, False: 974]
  ------------------
 7326|      0|        return 0;   /* Two null OIDs are (trivially) the same */
 7327|    974|    if (!name1 || !name2)
  ------------------
  |  Branch (7327:9): [True: 0, False: 974]
  |  Branch (7327:19): [True: 0, False: 974]
  ------------------
 7328|      0|        return 1;   /* Otherwise something's wrong, so report a non-match */
 7329|       |    /*
 7330|       |     * find first non-matching OID 
 7331|       |     */
 7332|  8.13k|    while (len-- > 0) {
  ------------------
  |  Branch (7332:12): [True: 8.13k, False: 0]
  ------------------
 7333|       |        /*
 7334|       |         * these must be done in separate comparisons, since
 7335|       |         * subtracting them and using that result has problems with
 7336|       |         * subids > 2^31. 
 7337|       |         */
 7338|  8.13k|        if (*(name1++) != *(name2++))
  ------------------
  |  Branch (7338:13): [True: 974, False: 7.16k]
  ------------------
 7339|    974|            return 1;
 7340|  8.13k|    }
 7341|      0|    return 0;
 7342|    974|}
snmp_duplicate_objid:
 8138|    342|{
 8139|    342|    oid            *returnOid;
 8140|    342|    if (objToCopy != NULL && objToCopyLen != 0) {
  ------------------
  |  Branch (8140:9): [True: 342, False: 0]
  |  Branch (8140:30): [True: 342, False: 0]
  ------------------
 8141|    342|        returnOid = (oid *) malloc(objToCopyLen * sizeof(oid));
 8142|    342|        if (returnOid) {
  ------------------
  |  Branch (8142:13): [True: 342, False: 0]
  ------------------
 8143|    342|            memcpy(returnOid, objToCopy, objToCopyLen * sizeof(oid));
 8144|    342|        }
 8145|    342|    } else
 8146|      0|        returnOid = NULL;
 8147|    342|    return returnOid;
 8148|    342|}
snmp_increment_statistic:
 8158|     25|{
 8159|     25|    if (which >= 0 && which < NETSNMP_STAT_MAX_STATS) {
  ------------------
  |  |  710|     25|#define  NETSNMP_STAT_MAX_STATS              (STAT_TLSTM_STATS_END+1)
  |  |  ------------------
  |  |  |  |  706|     25|#define  STAT_TLSTM_STATS_END          STAT_TLSTM_SNMPTLSTMSESSIONINVALIDCACHES
  |  |  |  |  ------------------
  |  |  |  |  |  |  703|     25|#define  STAT_TLSTM_SNMPTLSTMSESSIONINVALIDCACHES              56
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (8159:9): [True: 25, False: 0]
  |  Branch (8159:23): [True: 25, False: 0]
  ------------------
 8160|     25|        statistics[which]++;
 8161|     25|        return statistics[which];
 8162|     25|    }
 8163|      0|    return 0;
 8164|     25|}
snmp_init_statistics:
 8186|     57|{
 8187|     57|    memset(statistics, 0, sizeof(statistics));
 8188|     57|}
snmp_api.c:_init_snmp:
  719|    171|{
  720|       |
  721|    171|    struct timeval  tv;
  722|    171|    long            tmpReqid, tmpMsgid;
  723|       |
  724|    171|    if (_init_snmp_init_done)
  ------------------
  |  Branch (724:9): [True: 114, False: 57]
  ------------------
  725|    114|        return;
  726|     57|    _init_snmp_init_done = 1;
  727|     57|    Reqid = 1;
  728|       |
  729|     57|    snmp_res_init();            /* initialize the mt locking structures */
  ------------------
  |  |   78|     57|#define snmp_res_init() do {} while (0)
  |  |  ------------------
  |  |  |  Branch (78:38): [Folded, False: 57]
  |  |  ------------------
  ------------------
  730|     57|#ifndef NETSNMP_DISABLE_MIB_LOADING
  731|     57|    netsnmp_init_mib_internals();
  732|     57|#endif /* NETSNMP_DISABLE_MIB_LOADING */
  733|     57|    netsnmp_tdomain_init();
  734|       |
  735|     57|    gettimeofday(&tv, (struct timezone *) 0);
  736|       |    /*
  737|       |     * Now = tv;
  738|       |     */
  739|       |
  740|       |    /*
  741|       |     * get pseudo-random values for request ID and message ID 
  742|       |     */
  743|     57|    netsnmp_srandom((unsigned)(tv.tv_sec ^ tv.tv_usec));
  744|     57|    tmpReqid = netsnmp_random();
  745|     57|    tmpMsgid = netsnmp_random();
  746|       |
  747|       |    /*
  748|       |     * don't allow zero value to repeat init 
  749|       |     */
  750|     57|    if (tmpReqid == 0)
  ------------------
  |  Branch (750:9): [True: 0, False: 57]
  ------------------
  751|      0|        tmpReqid = 1;
  752|     57|    if (tmpMsgid == 0)
  ------------------
  |  Branch (752:9): [True: 0, False: 57]
  ------------------
  753|      0|        tmpMsgid = 1;
  754|     57|    Reqid = tmpReqid;
  755|     57|    Msgid = tmpMsgid;
  756|       |
  757|     57|    netsnmp_register_default_domain("snmp", "udp udp6");
  758|     57|    netsnmp_register_default_domain("snmptrap", "udp udp6");
  759|       |
  760|     57|    netsnmp_register_default_target("snmp", "udp", ":161");
  761|     57|    netsnmp_register_default_target("snmp", "tcp", ":161");
  762|     57|    netsnmp_register_default_target("snmp", "udp6", ":161");
  763|     57|    netsnmp_register_default_target("snmp", "tcp6", ":161");
  764|     57|    netsnmp_register_default_target("snmp", "dtlsudp", ":10161");
  765|     57|    netsnmp_register_default_target("snmp", "tlstcp", ":10161");
  766|     57|    netsnmp_register_default_target("snmp", "ipx", "/36879");
  767|       |
  768|     57|    netsnmp_register_default_target("snmptrap", "udp", ":162");
  769|     57|    netsnmp_register_default_target("snmptrap", "tcp", ":162");
  770|     57|    netsnmp_register_default_target("snmptrap", "udp6", ":162");
  771|     57|    netsnmp_register_default_target("snmptrap", "tcp6", ":162");
  772|     57|    netsnmp_register_default_target("snmptrap", "dtlsudp", ":10162");
  773|     57|    netsnmp_register_default_target("snmptrap", "tlstcp", ":10162");
  774|     57|    netsnmp_register_default_target("snmptrap", "ipx", "/36880");
  775|       |
  776|     57|    netsnmp_ds_set_int(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|     57|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  777|     57|                       NETSNMP_DS_LIB_HEX_OUTPUT_LENGTH, 16);
  ------------------
  |  |  121|     57|#define NETSNMP_DS_LIB_HEX_OUTPUT_LENGTH    6
  ------------------
  778|     57|    netsnmp_ds_set_int(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_RETRIES,
  ------------------
  |  |   48|     57|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                  netsnmp_ds_set_int(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_RETRIES,
  ------------------
  |  |  131|     57|#define NETSNMP_DS_LIB_RETRIES             15
  ------------------
  779|     57|                       DEFAULT_RETRIES);
  ------------------
  |  |  184|     57|#define DEFAULT_RETRIES	    5
  ------------------
  780|     57|    netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|     57|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  781|     57|			   NETSNMP_DS_LIB_MIB_ERRORS, 1);
  ------------------
  |  |   59|     57|#define NETSNMP_DS_LIB_MIB_ERRORS          0
  ------------------
  782|       |
  783|     57|#ifdef NETSNMP_USE_REVERSE_ASNENCODING
  784|     57|    netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|     57|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  785|     57|			   NETSNMP_DS_LIB_REVERSE_ENCODE,
  ------------------
  |  |   80|     57|#define NETSNMP_DS_LIB_REVERSE_ENCODE      20   /* encode packets from back to front */
  ------------------
  786|     57|			   NETSNMP_DEFAULT_ASNENCODING_DIRECTION);
  ------------------
  |  | 1995|     57|#define NETSNMP_DEFAULT_ASNENCODING_DIRECTION 1 /* 1 = reverse, 0 = forwards */
  ------------------
  787|     57|#endif
  788|     57|}
snmp_api.c:register_default_handlers:
  817|     57|{
  818|     57|    netsnmp_ds_register_config(ASN_BOOLEAN, "snmp", "dumpPacket",
  ------------------
  |  |   72|     57|#define ASN_BOOLEAN	    0x01U
  ------------------
  819|     57|		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DUMP_PACKET);
  ------------------
  |  |   48|     57|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DUMP_PACKET);
  ------------------
  |  |   63|     57|#define NETSNMP_DS_LIB_DUMP_PACKET         4
  ------------------
  820|     57|    netsnmp_ds_register_config(ASN_BOOLEAN, "snmp", "reverseEncodeBER",
  ------------------
  |  |   72|     57|#define ASN_BOOLEAN	    0x01U
  ------------------
  821|     57|		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_REVERSE_ENCODE);
  ------------------
  |  |   48|     57|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_REVERSE_ENCODE);
  ------------------
  |  |   80|     57|#define NETSNMP_DS_LIB_REVERSE_ENCODE      20   /* encode packets from back to front */
  ------------------
  822|     57|    netsnmp_ds_register_config(ASN_INTEGER, "snmp", "defaultPort",
  ------------------
  |  |   75|     57|#define ASN_INTEGER	    0x02U
  ------------------
  823|     57|		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DEFAULT_PORT);
  ------------------
  |  |   48|     57|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DEFAULT_PORT);
  ------------------
  |  |  117|     57|#define NETSNMP_DS_LIB_DEFAULT_PORT         3
  ------------------
  824|     57|#ifndef NETSNMP_FEATURE_REMOVE_RUNTIME_DISABLE_VERSION
  825|     57|    netsnmp_ds_register_config(ASN_BOOLEAN, "snmp", "disableSNMPv3",
  ------------------
  |  |   72|     57|#define ASN_BOOLEAN	    0x01U
  ------------------
  826|     57|                      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DISABLE_V3);
  ------------------
  |  |   48|     57|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                    NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DISABLE_V3);
  ------------------
  |  |  105|     57|#define NETSNMP_DS_LIB_DISABLE_V3          45 /* disable SNMPv3 */
  ------------------
  827|     57|#endif /* NETSNMP_FEATURE_REMOVE_RUNTIME_DISABLE_VERSION */
  828|     57|#if !defined(NETSNMP_DISABLE_SNMPV1) || !defined(NETSNMP_DISABLE_SNMPV2C)
  829|     57|#ifndef NETSNMP_FEATURE_REMOVE_RUNTIME_DISABLE_VERSION
  830|     57|#if !defined(NETSNMP_DISABLE_SNMPV1)
  831|     57|    netsnmp_ds_register_config(ASN_BOOLEAN, "snmp", "disableSNMPv1",
  ------------------
  |  |   72|     57|#define ASN_BOOLEAN	    0x01U
  ------------------
  832|     57|                      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DISABLE_V1);
  ------------------
  |  |   48|     57|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                    NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DISABLE_V1);
  ------------------
  |  |  103|     57|#define NETSNMP_DS_LIB_DISABLE_V1          43 /* disable SNMPv1 */
  ------------------
  833|     57|#endif
  834|     57|#if !defined(NETSNMP_DISABLE_SNMPV2C)
  835|     57|    netsnmp_ds_register_config(ASN_BOOLEAN, "snmp", "disableSNMPv2c",
  ------------------
  |  |   72|     57|#define ASN_BOOLEAN	    0x01U
  ------------------
  836|     57|                      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DISABLE_V2c);
  ------------------
  |  |   48|     57|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                    NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DISABLE_V2c);
  ------------------
  |  |  104|     57|#define NETSNMP_DS_LIB_DISABLE_V2c         44 /* disable SNMPv2c */
  ------------------
  837|     57|#endif
  838|     57|#endif /* NETSNMP_FEATURE_REMOVE_RUNTIME_DISABLE_VERSION */
  839|     57|    netsnmp_ds_register_config(ASN_OCTET_STR, "snmp", "defCommunity",
  ------------------
  |  |   78|     57|#define ASN_OCTET_STR	    0x04U
  ------------------
  840|     57|                      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_COMMUNITY);
  ------------------
  |  |   48|     57|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                    NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_COMMUNITY);
  ------------------
  |  |  158|     57|#define NETSNMP_DS_LIB_COMMUNITY         7
  ------------------
  841|     57|#endif /* !defined(NETSNMP_DISABLE_SNMPV1) || !defined(NETSNMP_DISABLE_SNMPV2C) */
  842|     57|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "noTokenWarnings",
  ------------------
  |  |   72|     57|#define ASN_BOOLEAN	    0x01U
  ------------------
  843|     57|                      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_NO_TOKEN_WARNINGS);
  ------------------
  |  |   48|     57|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                    NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_NO_TOKEN_WARNINGS);
  ------------------
  |  |   77|     57|#define NETSNMP_DS_LIB_NO_TOKEN_WARNINGS   17   /* no warn about unknown config tokens */
  ------------------
  844|     57|    netsnmp_ds_register_config(ASN_BOOLEAN, "snmp", "noRangeCheck",
  ------------------
  |  |   72|     57|#define ASN_BOOLEAN	    0x01U
  ------------------
  845|     57|		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DONT_CHECK_RANGE);
  ------------------
  |  |   48|     57|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DONT_CHECK_RANGE);
  ------------------
  |  |   76|     57|#define NETSNMP_DS_LIB_DONT_CHECK_RANGE    16   /* don't check values for ranges on send */
  ------------------
  846|     57|    netsnmp_ds_register_premib(ASN_OCTET_STR, "snmp", "persistentDir",
  ------------------
  |  |   78|     57|#define ASN_OCTET_STR	    0x04U
  ------------------
  847|     57|	              NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_PERSISTENT_DIR);
  ------------------
  |  |   48|     57|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              	              NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_PERSISTENT_DIR);
  ------------------
  |  |  159|     57|#define NETSNMP_DS_LIB_PERSISTENT_DIR    8
  ------------------
  848|     57|    netsnmp_ds_register_config(ASN_OCTET_STR, "snmp", "tempFilePattern",
  ------------------
  |  |   78|     57|#define ASN_OCTET_STR	    0x04U
  ------------------
  849|     57|	              NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_TEMP_FILE_PATTERN);
  ------------------
  |  |   48|     57|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              	              NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_TEMP_FILE_PATTERN);
  ------------------
  |  |  166|     57|#define NETSNMP_DS_LIB_TEMP_FILE_PATTERN 15
  ------------------
  850|     57|    netsnmp_ds_register_config(ASN_BOOLEAN, "snmp", "noDisplayHint",
  ------------------
  |  |   72|     57|#define ASN_BOOLEAN	    0x01U
  ------------------
  851|     57|	              NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_NO_DISPLAY_HINT);
  ------------------
  |  |   48|     57|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              	              NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_NO_DISPLAY_HINT);
  ------------------
  |  |   90|     57|#define NETSNMP_DS_LIB_NO_DISPLAY_HINT     30 /* don't apply DISPLAY-HINTs */
  ------------------
  852|     57|    netsnmp_ds_register_config(ASN_BOOLEAN, "snmp", "16bitIDs",
  ------------------
  |  |   72|     57|#define ASN_BOOLEAN	    0x01U
  ------------------
  853|     57|	              NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_16BIT_IDS);
  ------------------
  |  |   48|     57|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              	              NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_16BIT_IDS);
  ------------------
  |  |   91|     57|#define NETSNMP_DS_LIB_16BIT_IDS           31   /* restrict requestIDs, etc to 16-bit values */
  ------------------
  854|     57|    netsnmp_ds_register_premib(ASN_OCTET_STR, "snmp", "clientaddr",
  ------------------
  |  |   78|     57|#define ASN_OCTET_STR	    0x04U
  ------------------
  855|     57|                      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_CLIENT_ADDR);
  ------------------
  |  |   48|     57|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                    NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_CLIENT_ADDR);
  ------------------
  |  |  165|     57|#define NETSNMP_DS_LIB_CLIENT_ADDR       14
  ------------------
  856|     57|    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "clientaddrUsesPort",
  ------------------
  |  |   72|     57|#define ASN_BOOLEAN	    0x01U
  ------------------
  857|     57|                      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_CLIENT_ADDR_USES_PORT);
  ------------------
  |  |   48|     57|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                    NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_CLIENT_ADDR_USES_PORT);
  ------------------
  |  |  102|     57|#define NETSNMP_DS_LIB_CLIENT_ADDR_USES_PORT 42 /* NETSNMP_DS_LIB_CLIENT_ADDR includes address and also port */
  ------------------
  858|     57|    netsnmp_ds_register_config(ASN_INTEGER, "snmp", "serverSendBuf",
  ------------------
  |  |   75|     57|#define ASN_INTEGER	    0x02U
  ------------------
  859|     57|		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_SERVERSENDBUF);
  ------------------
  |  |   48|     57|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_SERVERSENDBUF);
  ------------------
  |  |  122|     57|#define NETSNMP_DS_LIB_SERVERSENDBUF        7 /* send buffer (server) */
  ------------------
  860|     57|    netsnmp_ds_register_config(ASN_INTEGER, "snmp", "serverRecvBuf",
  ------------------
  |  |   75|     57|#define ASN_INTEGER	    0x02U
  ------------------
  861|     57|		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_SERVERRECVBUF);
  ------------------
  |  |   48|     57|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_SERVERRECVBUF);
  ------------------
  |  |  123|     57|#define NETSNMP_DS_LIB_SERVERRECVBUF        8 /* receive buffer (server) */
  ------------------
  862|     57|    netsnmp_ds_register_config(ASN_INTEGER, "snmp", "clientSendBuf",
  ------------------
  |  |   75|     57|#define ASN_INTEGER	    0x02U
  ------------------
  863|     57|		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_CLIENTSENDBUF);
  ------------------
  |  |   48|     57|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_CLIENTSENDBUF);
  ------------------
  |  |  124|     57|#define NETSNMP_DS_LIB_CLIENTSENDBUF        9 /* send buffer (client) */
  ------------------
  864|     57|    netsnmp_ds_register_config(ASN_INTEGER, "snmp", "clientRecvBuf",
  ------------------
  |  |   75|     57|#define ASN_INTEGER	    0x02U
  ------------------
  865|     57|		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_CLIENTRECVBUF);
  ------------------
  |  |   48|     57|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_CLIENTRECVBUF);
  ------------------
  |  |  125|     57|#define NETSNMP_DS_LIB_CLIENTRECVBUF       10 /* receive buffer (client) */
  ------------------
  866|     57|    netsnmp_ds_register_config(ASN_INTEGER, "snmp", "sendMessageMaxSize",
  ------------------
  |  |   75|     57|#define ASN_INTEGER	    0x02U
  ------------------
  867|     57|                               NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|     57|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  868|     57|                               NETSNMP_DS_LIB_MSG_SEND_MAX);
  ------------------
  |  |  132|     57|#define NETSNMP_DS_LIB_MSG_SEND_MAX        16 /* global max response size */
  ------------------
  869|     57|    netsnmp_ds_register_config(ASN_BOOLEAN, "snmp", "noPersistentLoad",
  ------------------
  |  |   72|     57|#define ASN_BOOLEAN	    0x01U
  ------------------
  870|     57|		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DISABLE_PERSISTENT_LOAD);
  ------------------
  |  |   48|     57|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DISABLE_PERSISTENT_LOAD);
  ------------------
  |  |   95|     57|#define NETSNMP_DS_LIB_DISABLE_PERSISTENT_LOAD  35 /* don't load persistent file */
  ------------------
  871|     57|    netsnmp_ds_register_config(ASN_BOOLEAN, "snmp", "noPersistentSave",
  ------------------
  |  |   72|     57|#define ASN_BOOLEAN	    0x01U
  ------------------
  872|     57|		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DISABLE_PERSISTENT_SAVE);
  ------------------
  |  |   48|     57|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DISABLE_PERSISTENT_SAVE);
  ------------------
  |  |   96|     57|#define NETSNMP_DS_LIB_DISABLE_PERSISTENT_SAVE  36 /* don't save persistent file */
  ------------------
  873|     57|    netsnmp_ds_register_config(ASN_BOOLEAN, "snmp",
  ------------------
  |  |   72|     57|#define ASN_BOOLEAN	    0x01U
  ------------------
  874|     57|                               "noContextEngineIDDiscovery",
  875|     57|                               NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|     57|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  876|     57|                               NETSNMP_DS_LIB_NO_DISCOVERY);
  ------------------
  |  |   98|     57|#define NETSNMP_DS_LIB_NO_DISCOVERY        38 /* don't support RFC5343 contextEngineID discovery */
  ------------------
  877|     57|    netsnmp_ds_register_config(ASN_INTEGER, "snmp", "timeout",
  ------------------
  |  |   75|     57|#define ASN_INTEGER	    0x02U
  ------------------
  878|     57|		               NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_TIMEOUT);
  ------------------
  |  |   48|     57|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              		               NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_TIMEOUT);
  ------------------
  |  |  130|     57|#define NETSNMP_DS_LIB_TIMEOUT             14
  ------------------
  879|     57|    netsnmp_ds_register_config(ASN_INTEGER, "snmp", "retries",
  ------------------
  |  |   75|     57|#define ASN_INTEGER	    0x02U
  ------------------
  880|     57|		               NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_RETRIES);
  ------------------
  |  |   48|     57|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
              		               NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_RETRIES);
  ------------------
  |  |  131|     57|#define NETSNMP_DS_LIB_RETRIES             15
  ------------------
  881|     57|    netsnmp_ds_register_config(ASN_OCTET_STR, "snmp", "outputPrecision",
  ------------------
  |  |   78|     57|#define ASN_OCTET_STR	    0x04U
  ------------------
  882|     57|                               NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_OUTPUT_PRECISION);
  ------------------
  |  |   48|     57|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                                             NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_OUTPUT_PRECISION);
  ------------------
  |  |  186|     57|#define NETSNMP_DS_LIB_OUTPUT_PRECISION  35
  ------------------
  883|       |
  884|       |
  885|     57|    netsnmp_register_service_handlers();
  886|     57|}
snmp_api.c:snmp_sess_copy:
 1407|     57|{
 1408|     57|    struct session_list *psl;
 1409|     57|    psl = _sess_copy(pss);
 1410|     57|    if (!psl) {
  ------------------
  |  Branch (1410:9): [True: 0, False: 57]
  ------------------
 1411|      0|        if (!pss->s_snmp_errno) {
  ------------------
  |  Branch (1411:13): [True: 0, False: 0]
  ------------------
 1412|      0|            pss->s_snmp_errno = SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
 1413|      0|        }
 1414|      0|        SET_SNMP_ERROR(pss->s_snmp_errno);
  ------------------
  |  |   43|      0|#define SET_SNMP_ERROR(x) snmp_errno=(x)
  ------------------
 1415|      0|    }
 1416|     57|    return psl;
 1417|     57|}
snmp_api.c:_sess_copy:
 1116|     57|{
 1117|     57|    struct session_list *slp;
 1118|     57|    struct snmp_internal_session *isp;
 1119|     57|    netsnmp_session *session;
 1120|     57|    struct snmp_secmod_def *sptr;
 1121|     57|    char           *cp;
 1122|     57|    u_char         *ucp;
 1123|       |
 1124|     57|    in_session->s_snmp_errno = 0;
 1125|     57|    in_session->s_errno = 0;
 1126|       |
 1127|       |    /*
 1128|       |     * Copy session structure and link into list 
 1129|       |     */
 1130|     57|    slp = calloc(1, sizeof(struct session_list));
 1131|     57|    if (slp == NULL) {
  ------------------
  |  Branch (1131:9): [True: 0, False: 57]
  ------------------
 1132|      0|        in_session->s_snmp_errno = SNMPERR_MALLOC;
  ------------------
  |  |  246|      0|#define SNMPERR_MALLOC			(-62)
  ------------------
 1133|      0|        return (NULL);
 1134|      0|    }
 1135|       |
 1136|     57|    slp->transport = NULL;
 1137|       |
 1138|     57|    isp = calloc(1, sizeof(struct snmp_internal_session));
 1139|       |
 1140|     57|    if (isp == NULL) {
  ------------------
  |  Branch (1140:9): [True: 0, False: 57]
  ------------------
 1141|      0|        snmp_sess_close(slp);
 1142|      0|        in_session->s_snmp_errno = SNMPERR_MALLOC;
  ------------------
  |  |  246|      0|#define SNMPERR_MALLOC			(-62)
  ------------------
 1143|      0|        return (NULL);
 1144|      0|    }
 1145|       |
 1146|     57|    slp->internal = isp;
 1147|     57|    slp->session = netsnmp_memdup(in_session, sizeof(netsnmp_session));
 1148|     57|    if (slp->session == NULL) {
  ------------------
  |  Branch (1148:9): [True: 0, False: 57]
  ------------------
 1149|      0|        snmp_sess_close(slp);
 1150|      0|        in_session->s_snmp_errno = SNMPERR_MALLOC;
  ------------------
  |  |  246|      0|#define SNMPERR_MALLOC			(-62)
  ------------------
 1151|      0|        return (NULL);
 1152|      0|    }
 1153|     57|    session = slp->session;
 1154|       |
 1155|       |    /*
 1156|       |     * zero out pointers so if we have to free the session we wont free mem
 1157|       |     * owned by in_session 
 1158|       |     */
 1159|     57|    session->localname = NULL;
 1160|     57|    session->peername = NULL;
 1161|     57|    session->community = NULL;
 1162|     57|    session->contextEngineID = NULL;
 1163|     57|    session->contextName = NULL;
 1164|     57|    session->securityEngineID = NULL;
 1165|     57|    session->securityName = NULL;
 1166|     57|    session->securityAuthProto = NULL;
 1167|     57|    session->securityAuthLocalKey = NULL;
 1168|     57|    session->securityPrivProto = NULL;
 1169|     57|    session->securityPrivLocalKey = NULL;
 1170|     57|    session->sessUser = NULL;
 1171|     57|    session->paramName = NULL;
 1172|     57|#ifndef NETSNMP_NO_TRAP_STATS
 1173|     57|    session->trap_stats = NULL;
 1174|     57|#endif
 1175|       |    /*
 1176|       |     * session now points to the new structure that still contains pointers to
 1177|       |     * data allocated elsewhere.  Some of this data is copied to space malloc'd
 1178|       |     * here, and the pointer replaced with the new one.
 1179|       |     */
 1180|       |
 1181|     57|    if (in_session->peername != NULL) {
  ------------------
  |  Branch (1181:9): [True: 0, False: 57]
  ------------------
 1182|      0|        session->peername =
 1183|      0|            netsnmp_strdup_and_null((u_char*)in_session->peername,
 1184|      0|                                    strlen(in_session->peername));
 1185|      0|        if (session->peername == NULL) {
  ------------------
  |  Branch (1185:13): [True: 0, False: 0]
  ------------------
 1186|      0|            snmp_sess_close(slp);
 1187|      0|            in_session->s_snmp_errno = SNMPERR_MALLOC;
  ------------------
  |  |  246|      0|#define SNMPERR_MALLOC			(-62)
  ------------------
 1188|      0|            return (NULL);
 1189|      0|        }
 1190|      0|    }
 1191|       |
 1192|       |    /*
 1193|       |     * Fill in defaults if necessary 
 1194|       |     */
 1195|     57|#if !defined(NETSNMP_DISABLE_SNMPV1) || !defined(NETSNMP_DISABLE_SNMPV2C)
 1196|     57|    if (in_session->community_len != SNMP_DEFAULT_COMMUNITY_LEN) {
  ------------------
  |  |   78|     57|#define SNMP_DEFAULT_COMMUNITY_LEN  0   /* to get a default community name */
  ------------------
  |  Branch (1196:9): [True: 0, False: 57]
  ------------------
 1197|      0|        ucp = netsnmp_memdup(in_session->community, in_session->community_len);
 1198|     57|    } else {
 1199|     57|        if ((cp = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|     57|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (1199:13): [True: 0, False: 57]
  ------------------
 1200|     57|					NETSNMP_DS_LIB_COMMUNITY)) != NULL) {
  ------------------
  |  |  158|     57|#define NETSNMP_DS_LIB_COMMUNITY         7
  ------------------
 1201|      0|            session->community_len = strlen(cp);
 1202|      0|            ucp = (u_char *) strdup(cp);
 1203|     57|        } else {
 1204|       |#ifdef NETSNMP_NO_ZEROLENGTH_COMMUNITY
 1205|       |            session->community_len = strlen(DEFAULT_COMMUNITY);
 1206|       |            ucp = netsnmp_memdup(DEFAULT_COMMUNITY, session->community_len);
 1207|       |#else
 1208|     57|            ucp = (u_char *) strdup("");
 1209|     57|#endif
 1210|     57|        }
 1211|     57|    }
 1212|       |
 1213|     57|    if (ucp == NULL) {
  ------------------
  |  Branch (1213:9): [True: 0, False: 57]
  ------------------
 1214|      0|        snmp_sess_close(slp);
 1215|      0|        in_session->s_snmp_errno = SNMPERR_MALLOC;
  ------------------
  |  |  246|      0|#define SNMPERR_MALLOC			(-62)
  ------------------
 1216|      0|        return (NULL);
 1217|      0|    }
 1218|     57|    session->community = ucp;   /* replace pointer with pointer to new data */
 1219|     57|#endif
 1220|       |
 1221|     57|    if (session->securityLevel <= 0) {
  ------------------
  |  Branch (1221:9): [True: 57, False: 0]
  ------------------
 1222|     57|        session->securityLevel =
 1223|     57|            netsnmp_ds_get_int(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_SECLEVEL);
  ------------------
  |  |   48|     57|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
                          netsnmp_ds_get_int(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_SECLEVEL);
  ------------------
  |  |  115|     57|#define NETSNMP_DS_LIB_SECLEVEL             1
  ------------------
 1224|     57|    }
 1225|       |
 1226|     57|    if (in_session->securityEngineIDLen > 0) {
  ------------------
  |  Branch (1226:9): [True: 0, False: 57]
  ------------------
 1227|      0|        ucp = netsnmp_memdup(in_session->securityEngineID,
 1228|      0|                             in_session->securityEngineIDLen);
 1229|      0|        if (ucp == NULL) {
  ------------------
  |  Branch (1229:13): [True: 0, False: 0]
  ------------------
 1230|      0|            snmp_sess_close(slp);
 1231|      0|            in_session->s_snmp_errno = SNMPERR_MALLOC;
  ------------------
  |  |  246|      0|#define SNMPERR_MALLOC			(-62)
  ------------------
 1232|      0|            return (NULL);
 1233|      0|        }
 1234|      0|        session->securityEngineID = ucp;
 1235|      0|        session->securityEngineIDLen = in_session->securityEngineIDLen;
 1236|      0|    }
 1237|       |
 1238|     57|    if (in_session->contextEngineIDLen > 0) {
  ------------------
  |  Branch (1238:9): [True: 0, False: 57]
  ------------------
 1239|      0|        ucp = netsnmp_memdup(in_session->contextEngineID,
 1240|      0|                             in_session->contextEngineIDLen);
 1241|      0|        if (ucp == NULL) {
  ------------------
  |  Branch (1241:13): [True: 0, False: 0]
  ------------------
 1242|      0|            snmp_sess_close(slp);
 1243|      0|            in_session->s_snmp_errno = SNMPERR_MALLOC;
  ------------------
  |  |  246|      0|#define SNMPERR_MALLOC			(-62)
  ------------------
 1244|      0|            return (NULL);
 1245|      0|        }
 1246|      0|        session->contextEngineID = ucp;
 1247|      0|        session->contextEngineIDLen = in_session->contextEngineIDLen;
 1248|     57|    } else if (in_session->securityEngineIDLen > 0) {
  ------------------
  |  Branch (1248:16): [True: 0, False: 57]
  ------------------
 1249|       |        /*
 1250|       |         * default contextEngineID to securityEngineIDLen if defined 
 1251|       |         */
 1252|      0|        ucp = netsnmp_memdup(in_session->securityEngineID,
 1253|      0|                             in_session->securityEngineIDLen);
 1254|      0|        if (ucp == NULL) {
  ------------------
  |  Branch (1254:13): [True: 0, False: 0]
  ------------------
 1255|      0|            snmp_sess_close(slp);
 1256|      0|            in_session->s_snmp_errno = SNMPERR_MALLOC;
  ------------------
  |  |  246|      0|#define SNMPERR_MALLOC			(-62)
  ------------------
 1257|      0|            return (NULL);
 1258|      0|        }
 1259|      0|        session->contextEngineID = ucp;
 1260|      0|        session->contextEngineIDLen = in_session->securityEngineIDLen;
 1261|      0|    }
 1262|       |
 1263|     57|    if (in_session->contextName) {
  ------------------
  |  Branch (1263:9): [True: 0, False: 57]
  ------------------
 1264|      0|        session->contextName = strdup(in_session->contextName);
 1265|      0|        if (session->contextName == NULL) {
  ------------------
  |  Branch (1265:13): [True: 0, False: 0]
  ------------------
 1266|      0|            snmp_sess_close(slp);
 1267|      0|            return (NULL);
 1268|      0|        }
 1269|      0|        session->contextNameLen = in_session->contextNameLen;
 1270|     57|    } else {
 1271|     57|        if ((cp = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|     57|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (1271:13): [True: 0, False: 57]
  ------------------
 1272|     57|                                        NETSNMP_DS_LIB_CONTEXT)) != NULL)
  ------------------
  |  |  152|     57|#define NETSNMP_DS_LIB_CONTEXT           1
  ------------------
 1273|      0|            cp = strdup(cp);
 1274|     57|        else
 1275|     57|            cp = strdup(SNMP_DEFAULT_CONTEXT);
  ------------------
  |  |   92|     57|#define SNMP_DEFAULT_CONTEXT        ""
  ------------------
 1276|     57|        if (cp == NULL) {
  ------------------
  |  Branch (1276:13): [True: 0, False: 57]
  ------------------
 1277|      0|            snmp_sess_close(slp);
 1278|      0|            return (NULL);
 1279|      0|        }
 1280|     57|        session->contextName = cp;
 1281|     57|        session->contextNameLen = strlen(cp);
 1282|     57|    }
 1283|       |
 1284|     57|    if (in_session->securityName) {
  ------------------
  |  Branch (1284:9): [True: 0, False: 57]
  ------------------
 1285|      0|        session->securityName = strdup(in_session->securityName);
 1286|      0|        if (session->securityName == NULL) {
  ------------------
  |  Branch (1286:13): [True: 0, False: 0]
  ------------------
 1287|      0|            snmp_sess_close(slp);
 1288|      0|            return (NULL);
 1289|      0|        }
 1290|     57|    } else if ((cp = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
  ------------------
  |  |   48|     57|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (1290:16): [True: 0, False: 57]
  ------------------
 1291|     57|					   NETSNMP_DS_LIB_SECNAME)) != NULL) {
  ------------------
  |  |  151|     57|#define NETSNMP_DS_LIB_SECNAME           0
  ------------------
 1292|      0|        cp = strdup(cp);
 1293|      0|        if (cp == NULL) {
  ------------------
  |  Branch (1293:13): [True: 0, False: 0]
  ------------------
 1294|      0|            snmp_sess_close(slp);
 1295|      0|            return (NULL);
 1296|      0|        }
 1297|      0|        session->securityName = cp;
 1298|      0|        session->securityNameLen = strlen(cp);
 1299|      0|    }
 1300|       |
 1301|     57|    if (in_session->securityAuthLocalKey) {
  ------------------
  |  Branch (1301:9): [True: 0, False: 57]
  ------------------
 1302|      0|            session->securityAuthLocalKey =
 1303|      0|                netsnmp_memdup(in_session->securityAuthLocalKey,
 1304|      0|                               in_session->securityAuthLocalKeyLen);
 1305|      0|            session->securityAuthLocalKeyLen =
 1306|      0|                in_session->securityAuthLocalKeyLen;
 1307|      0|    }
 1308|       |
 1309|     57|    if (in_session->securityPrivLocalKey) {
  ------------------
  |  Branch (1309:9): [True: 0, False: 57]
  ------------------
 1310|      0|            session->securityPrivLocalKey =
 1311|      0|                netsnmp_memdup(in_session->securityPrivLocalKey,
 1312|      0|                               in_session->securityPrivLocalKeyLen);
 1313|      0|            session->securityPrivLocalKeyLen =
 1314|      0|                in_session->securityPrivLocalKeyLen;
 1315|      0|    }
 1316|       |
 1317|     57|    if (session->transport_configuration) {
  ------------------
  |  Branch (1317:9): [True: 0, False: 57]
  ------------------
 1318|      0|        session->transport_configuration =
 1319|      0|            CONTAINER_DUP(session->transport_configuration, NULL, 0);
 1320|      0|        if (!session->transport_configuration) {
  ------------------
  |  Branch (1320:13): [True: 0, False: 0]
  ------------------
 1321|      0|            snmp_sess_close(slp);
 1322|      0|            return NULL;
 1323|      0|        }
 1324|      0|    }
 1325|       |
 1326|     57|    if (session->retries == SNMP_DEFAULT_RETRIES) {
  ------------------
  |  |   79|     57|#define SNMP_DEFAULT_RETRIES	    -1
  ------------------
  |  Branch (1326:9): [True: 57, False: 0]
  ------------------
 1327|     57|        int retry = netsnmp_ds_get_int(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|     57|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1328|     57|                                       NETSNMP_DS_LIB_RETRIES);
  ------------------
  |  |  131|     57|#define NETSNMP_DS_LIB_RETRIES             15
  ------------------
 1329|     57|        if (retry < 0)
  ------------------
  |  Branch (1329:13): [True: 0, False: 57]
  ------------------
 1330|      0|            session->retries = DEFAULT_RETRIES;
  ------------------
  |  |  184|      0|#define DEFAULT_RETRIES	    5
  ------------------
 1331|     57|        else
 1332|     57|            session->retries = retry;
 1333|     57|    }
 1334|     57|    if (session->timeout == SNMP_DEFAULT_TIMEOUT) {
  ------------------
  |  |   80|     57|#define SNMP_DEFAULT_TIMEOUT	    -1
  ------------------
  |  Branch (1334:9): [True: 57, False: 0]
  ------------------
 1335|     57|        int timeout = netsnmp_ds_get_int(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|     57|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 1336|     57|                                         NETSNMP_DS_LIB_TIMEOUT);
  ------------------
  |  |  130|     57|#define NETSNMP_DS_LIB_TIMEOUT             14
  ------------------
 1337|     57|        if (timeout <= 0)
  ------------------
  |  Branch (1337:13): [True: 57, False: 0]
  ------------------
 1338|     57|            session->timeout = DEFAULT_TIMEOUT;
  ------------------
  |  |  185|     57|#define DEFAULT_TIMEOUT	    (1000L * 1000L)
  ------------------
 1339|      0|        else
 1340|      0|            session->timeout = timeout * 1000L * 1000L;
 1341|     57|    }
 1342|     57|    session->sessid = snmp_get_next_sessid();
 1343|       |
 1344|     57|    snmp_call_callbacks(SNMP_CALLBACK_LIBRARY, SNMP_CALLBACK_SESSION_INIT,
  ------------------
  |  |   18|     57|#define SNMP_CALLBACK_LIBRARY     0
  ------------------
                  snmp_call_callbacks(SNMP_CALLBACK_LIBRARY, SNMP_CALLBACK_SESSION_INIT,
  ------------------
  |  |   29|     57|#define SNMP_CALLBACK_SESSION_INIT		5
  ------------------
 1345|     57|                        session);
 1346|       |
 1347|     57|    if ((sptr = find_sec_mod(session->securityModel)) != NULL) {
  ------------------
  |  Branch (1347:9): [True: 57, False: 0]
  ------------------
 1348|       |        /*
 1349|       |         * security module specific copying 
 1350|       |         */
 1351|     57|        if (sptr->session_setup) {
  ------------------
  |  Branch (1351:13): [True: 57, False: 0]
  ------------------
 1352|     57|            int ret = (*sptr->session_setup) (in_session, session);
 1353|     57|            if (ret != SNMPERR_SUCCESS) {
  ------------------
  |  |  184|     57|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  |  Branch (1353:17): [True: 0, False: 57]
  ------------------
 1354|      0|                snmp_sess_close(slp);
 1355|      0|                return NULL;
 1356|      0|            }
 1357|     57|        }
 1358|       |
 1359|       |        /*
 1360|       |         * security module specific opening
 1361|       |         */
 1362|     57|        if (sptr->session_open) {
  ------------------
  |  Branch (1362:13): [True: 0, False: 57]
  ------------------
 1363|      0|            int ret = (*sptr->session_open) (session);
 1364|      0|            if (ret != SNMPERR_SUCCESS) {
  ------------------
  |  |  184|      0|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  |  Branch (1364:17): [True: 0, False: 0]
  ------------------
 1365|      0|                snmp_sess_close(slp);
 1366|      0|                return NULL;
 1367|      0|            }
 1368|      0|        }
 1369|     57|    }
 1370|       |
 1371|     57|#ifndef NETSNMP_NO_WRITE_SUPPORT
 1372|     57|    if (in_session->sessUser) {
  ------------------
  |  Branch (1372:9): [True: 0, False: 57]
  ------------------
 1373|      0|        struct usmUser *user;
 1374|       |
 1375|      0|        user = calloc(1, sizeof(struct usmUser));
 1376|      0|        if (user == NULL) {
  ------------------
  |  Branch (1376:13): [True: 0, False: 0]
  ------------------
 1377|      0|            snmp_sess_close(slp);
 1378|      0|            return NULL;
 1379|      0|        }
 1380|      0|        session->sessUser = usm_cloneFrom_user(in_session->sessUser, user);
 1381|      0|    }
 1382|     57|#endif /* NETSNMP_NO_WRITE_SUPPORT */
 1383|       |
 1384|     57|    if (in_session->paramName) {
  ------------------
  |  Branch (1384:9): [True: 0, False: 57]
  ------------------
 1385|      0|        session->paramName = strdup(in_session->paramName);
 1386|      0|        if (session->paramName == NULL) {
  ------------------
  |  Branch (1386:13): [True: 0, False: 0]
  ------------------
 1387|      0|            snmp_sess_close(slp);
 1388|      0|            return NULL;
 1389|      0|        }
 1390|      0|    }
 1391|     57|#ifndef NETSNMP_NO_TRAP_STATS
 1392|     57|    if (in_session->trap_stats) {
  ------------------
  |  Branch (1392:9): [True: 0, False: 57]
  ------------------
 1393|      0|        session->trap_stats = netsnmp_memdup(in_session->trap_stats,
 1394|      0|                                             sizeof(*in_session->trap_stats));
 1395|      0|        if (session->trap_stats == NULL) {
  ------------------
  |  Branch (1395:13): [True: 0, False: 0]
  ------------------
 1396|      0|            snmp_sess_close(slp);
 1397|      0|            return NULL;
 1398|      0|        }
 1399|      0|    }
 1400|     57|#endif
 1401|       |
 1402|     57|    return (slp);
 1403|     57|}
snmp_api.c:netsnmp_free_transport_config:
 2043|     57|{
 2044|     57|    if (!tc)
  ------------------
  |  Branch (2044:9): [True: 57, False: 0]
  ------------------
 2045|     57|        return;
 2046|       |
 2047|      0|    CONTAINER_CLEAR(tc, netsnmp_free_one_tr_cfg, NULL);
 2048|      0|    CONTAINER_FREE(tc);
 2049|      0|}
snmp_api.c:snmp_free_session:
 2082|     57|{
 2083|     57|    if (!s)
  ------------------
  |  Branch (2083:9): [True: 0, False: 57]
  ------------------
 2084|      0|        return;
 2085|       |
 2086|     57|    netsnmp_cleanup_session(s);
 2087|       |
 2088|       |    /*
 2089|       |     * clear session from any callbacks
 2090|       |     */
 2091|     57|    netsnmp_callback_clear_client_arg(s, 0, 0);
 2092|       |
 2093|     57|    free(s);
 2094|     57|}
snmp_api.c:free_securityStateRef:
 4191|     37|{
 4192|     37|    struct snmp_secmod_def *sptr;
 4193|       |
 4194|     37|    if (!pdu->securityStateRef)
  ------------------
  |  Branch (4194:9): [True: 37, False: 0]
  ------------------
 4195|     37|        return;
 4196|       |
 4197|      0|    sptr = find_sec_mod(pdu->securityModel);
 4198|      0|    if (sptr) {
  ------------------
  |  Branch (4198:9): [True: 0, False: 0]
  ------------------
 4199|      0|        if (sptr->pdu_free_state_ref) {
  ------------------
  |  Branch (4199:13): [True: 0, False: 0]
  ------------------
 4200|      0|            (*sptr->pdu_free_state_ref) (pdu->securityStateRef);
 4201|      0|        } else {
 4202|      0|            snmp_log(LOG_ERR,
 4203|      0|                     "Security Model %d can't free state references\n",
 4204|      0|                     pdu->securityModel);
 4205|      0|	}
 4206|      0|    } else {
 4207|      0|	snmp_log(LOG_ERR,
 4208|      0|		 "Can't find security model to free ptr: %d\n",
 4209|      0|		 pdu->securityModel);
 4210|      0|    }
 4211|       |    pdu->securityStateRef = NULL;
 4212|      0|}
snmp_api.c:_snmp_parse:
 4417|     25|{
 4418|     25|#if !defined(NETSNMP_DISABLE_SNMPV1) || !defined(NETSNMP_DISABLE_SNMPV2C)
 4419|     25|    u_char          community[COMMUNITY_MAX_LEN];
 4420|     25|    size_t          community_length = COMMUNITY_MAX_LEN;
  ------------------
  |  |   41|     25|#define COMMUNITY_MAX_LEN	256
  ------------------
 4421|     25|#endif
 4422|     25|    int             result = -1;
 4423|       |
 4424|     25|    static const oid snmpEngineIDoid[]   = { 1,3,6,1,6,3,10,2,1,1,0};
 4425|     25|    static size_t   snmpEngineIDoid_len = 11;
 4426|       |
 4427|     25|    static char     ourEngineID[SNMP_SEC_PARAM_BUF_SIZE];
 4428|     25|    static size_t   ourEngineID_len = sizeof(ourEngineID);
 4429|       |
 4430|     25|    netsnmp_pdu    *pdu2 = NULL;
 4431|       |
 4432|     25|    session->s_snmp_errno = 0;
 4433|     25|    session->s_errno = 0;
 4434|       |
 4435|       |    /*
 4436|       |     * Ensure all incoming PDUs have a unique means of identification 
 4437|       |     * (This is not restricted to AgentX handling,
 4438|       |     * though that is where the need becomes visible)   
 4439|       |     */
 4440|     25|    pdu->transid = snmp_get_next_transid();
 4441|       |
 4442|     25|    if (session->version != SNMP_DEFAULT_VERSION) {
  ------------------
  |  |   90|     25|#define SNMP_DEFAULT_VERSION	    -1
  ------------------
  |  Branch (4442:9): [True: 0, False: 25]
  ------------------
 4443|      0|        pdu->version = session->version;
 4444|     25|    } else {
 4445|     25|        pdu->version = snmp_parse_version(data, length);
 4446|     25|    }
 4447|       |
 4448|     25|    switch (pdu->version) {
 4449|      0|#if !defined(NETSNMP_DISABLE_SNMPV1) || !defined(NETSNMP_DISABLE_SNMPV2C)
 4450|      0|#ifndef NETSNMP_DISABLE_SNMPV1
 4451|      7|    case SNMP_VERSION_1:
  ------------------
  |  |  107|      7|#define SNMP_VERSION_1	   0
  ------------------
  |  Branch (4451:5): [True: 7, False: 18]
  ------------------
 4452|      7|#endif
 4453|      7|#ifndef NETSNMP_DISABLE_SNMPV2C
 4454|      7|    case SNMP_VERSION_2c:
  ------------------
  |  |  110|      7|#define SNMP_VERSION_2c    1
  ------------------
  |  Branch (4454:5): [True: 0, False: 25]
  ------------------
 4455|      7|#endif
 4456|      7|        NETSNMP_RUNTIME_PROTOCOL_CHECK_V1V2(pdu->version,unsupported_version);
  ------------------
  |  |  220|      7|#define NETSNMP_RUNTIME_PROTOCOL_CHECK_V1V2(pc_ver, pc_target) do {    \
  |  |  221|      7|        if (NETSNMP_RUNTIME_PROTOCOL_SKIP_V1(pc_ver) ||                \
  |  |  ------------------
  |  |  |  |  205|     14|    ((pc_ver) == SNMP_VERSION_1 &&                                      \
  |  |  |  |  ------------------
  |  |  |  |  |  |  107|     14|#define SNMP_VERSION_1	   0
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (205:6): [True: 7, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  206|     14|     netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,                      \
  |  |  |  |  ------------------
  |  |  |  |  |  |   48|      7|#define NETSNMP_DS_LIBRARY_ID     0
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (206:6): [True: 0, False: 7]
  |  |  |  |  ------------------
  |  |  |  |  207|      7|                            NETSNMP_DS_LIB_DISABLE_V1))
  |  |  |  |  ------------------
  |  |  |  |  |  |  103|      7|#define NETSNMP_DS_LIB_DISABLE_V1          43 /* disable SNMPv1 */
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  222|      7|            NETSNMP_RUNTIME_PROTOCOL_SKIP_V2(pc_ver)) {                \
  |  |  ------------------
  |  |  |  |  215|      7|    ((pc_ver) == SNMP_VERSION_2c &&                                     \
  |  |  |  |  ------------------
  |  |  |  |  |  |  110|     14|#define SNMP_VERSION_2c    1
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (215:6): [True: 0, False: 7]
  |  |  |  |  ------------------
  |  |  |  |  216|      7|     netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,                      \
  |  |  |  |  ------------------
  |  |  |  |  |  |   48|      0|#define NETSNMP_DS_LIBRARY_ID     0
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (216:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  217|      0|                            NETSNMP_DS_LIB_DISABLE_V2c))
  |  |  |  |  ------------------
  |  |  |  |  |  |  104|      0|#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|      7|    } while(0)
  |  |  ------------------
  |  |  |  Branch (226:13): [Folded, False: 7]
  |  |  ------------------
  ------------------
 4457|      7|        DEBUGMSGTL(("snmp_api", "Parsing SNMPv%ld message...\n",
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 4458|      7|                    (1 + pdu->version)));
 4459|       |
 4460|       |        /*
 4461|       |         * authenticates message and returns length if valid 
 4462|       |         */
 4463|      7|#ifndef NETSNMP_DISABLE_SNMPV1
 4464|      7|        if (pdu->version == SNMP_VERSION_1) {
  ------------------
  |  |  107|      7|#define SNMP_VERSION_1	   0
  ------------------
  |  Branch (4464:13): [True: 7, False: 0]
  ------------------
 4465|      7|            DEBUGDUMPSECTION("recv", "SNMPv1 message\n");
  ------------------
  |  |   81|      7|	do {if (_DBG_IF_) {__DBGDUMPSECTION(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      7|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 7]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	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: 7]
  |  |  ------------------
  ------------------
 4466|      7|        } else {
 4467|      0|#endif
 4468|      0|            DEBUGDUMPSECTION("recv", "SNMPv2c message\n");
  ------------------
  |  |   81|      0|	do {if (_DBG_IF_) {__DBGDUMPSECTION(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	do {if (_DBG_IF_) {__DBGDUMPSECTION(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  191|      0|        __DBGPRINTINDENT("dumph_" token); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  175|      0|#define __DBGPRINTINDENT(token) __DBGMSGTL((token, "%*s", __DBGINDENT(), ""))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  192|      0|        debugmsg("dumph_" token,"%s\n",x);\
  |  |  |  |  193|      0|        __DBGINDENTMORE()
  |  |  |  |  ------------------
  |  |  |  |  |  |  173|      0|#define __DBGINDENTMORE()  debug_indent_add(2)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (81:56): [Folded, False: 0]
  |  |  ------------------
  ------------------
 4469|      0|#ifndef NETSNMP_DISABLE_SNMPV1
 4470|      0|        }
 4471|      7|#endif
 4472|      7|        data = snmp_comstr_parse(data, &length,
 4473|      7|                                 community, &community_length,
 4474|      7|                                 &pdu->version);
 4475|      7|        if (data == NULL)
  ------------------
  |  Branch (4475:13): [True: 1, False: 6]
  ------------------
 4476|      1|            return -1;
 4477|       |
 4478|      6|        if (pdu->version != session->version &&
  ------------------
  |  Branch (4478:13): [True: 6, False: 0]
  ------------------
 4479|      6|            session->version != SNMP_DEFAULT_VERSION) {
  ------------------
  |  |   90|      6|#define SNMP_DEFAULT_VERSION	    -1
  ------------------
  |  Branch (4479:13): [True: 0, False: 6]
  ------------------
 4480|      0|            session->s_snmp_errno = SNMPERR_BAD_VERSION;
  ------------------
  |  |  198|      0|#define SNMPERR_BAD_VERSION		(-14)
  ------------------
 4481|      0|            return -1;
 4482|      0|        }
 4483|       |
 4484|       |        /*
 4485|       |         * maybe get the community string. 
 4486|       |         */
 4487|      6|        pdu->securityLevel = SNMP_SEC_LEVEL_NOAUTH;
  ------------------
  |  |  299|      6|#define SNMP_SEC_LEVEL_NOAUTH		1
  ------------------
 4488|      6|        pdu->securityModel = 
 4489|      6|#ifndef NETSNMP_DISABLE_SNMPV1
 4490|      6|            (pdu->version == SNMP_VERSION_1) ? SNMP_SEC_MODEL_SNMPv1 : 
  ------------------
  |  |  107|      6|#define SNMP_VERSION_1	   0
  ------------------
                          (pdu->version == SNMP_VERSION_1) ? SNMP_SEC_MODEL_SNMPv1 : 
  ------------------
  |  |  293|      6|#define SNMP_SEC_MODEL_SNMPv1		1
  ------------------
  |  Branch (4490:13): [True: 6, False: 0]
  ------------------
 4491|      6|#endif
 4492|      6|                                               SNMP_SEC_MODEL_SNMPv2c;
  ------------------
  |  |  294|      6|#define SNMP_SEC_MODEL_SNMPv2c		2
  ------------------
 4493|      6|        SNMP_FREE(pdu->community);
  ------------------
  |  |   62|      6|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 6]
  |  |  |  Branch (62:66): [Folded, False: 6]
  |  |  ------------------
  ------------------
 4494|      6|        pdu->community_len = 0;
 4495|      6|        pdu->community = (u_char *) 0;
 4496|      6|        if (community_length) {
  ------------------
  |  Branch (4496:13): [True: 0, False: 6]
  ------------------
 4497|      0|            pdu->community_len = community_length;
 4498|      0|            pdu->community = netsnmp_memdup(community, community_length);
 4499|      0|            if (pdu->community == NULL) {
  ------------------
  |  Branch (4499:17): [True: 0, False: 0]
  ------------------
 4500|      0|                session->s_snmp_errno = SNMPERR_MALLOC;
  ------------------
  |  |  246|      0|#define SNMPERR_MALLOC			(-62)
  ------------------
 4501|      0|                return -1;
 4502|      0|            }
 4503|      0|        }
 4504|      6|        if (session->authenticator) {
  ------------------
  |  Branch (4504:13): [True: 0, False: 6]
  ------------------
 4505|      0|            data = session->authenticator(data, &length,
 4506|      0|                                          community, community_length);
 4507|      0|            if (data == NULL) {
  ------------------
  |  Branch (4507:17): [True: 0, False: 0]
  ------------------
 4508|      0|                session->s_snmp_errno = SNMPERR_AUTHENTICATION_FAILURE;
  ------------------
  |  |  219|      0|#define SNMPERR_AUTHENTICATION_FAILURE 	(-35)
  ------------------
 4509|      0|                return -1;
 4510|      0|            }
 4511|      0|        }
 4512|       |
 4513|      6|        DEBUGDUMPSECTION("recv", "PDU");
  ------------------
  |  |   81|      6|	do {if (_DBG_IF_) {__DBGDUMPSECTION(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      6|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 6]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	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: 6]
  |  |  ------------------
  ------------------
 4514|      6|        result = snmp_pdu_parse(pdu, data, &length);
 4515|      6|        if (result < 0) {
  ------------------
  |  Branch (4515:13): [True: 6, False: 0]
  ------------------
 4516|       |            /*
 4517|       |             * This indicates a parse error.  
 4518|       |             */
 4519|      6|            snmp_increment_statistic(STAT_SNMPINASNPARSEERRS);
  ------------------
  |  |  637|      6|#define  STAT_SNMPINASNPARSEERRS             14
  ------------------
 4520|      6|        }
 4521|      6|        DEBUGINDENTADD(-6);
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 4522|      6|        break;
 4523|      0|#endif /* support for community based SNMP */
 4524|       |
 4525|     12|    case SNMP_VERSION_3:
  ------------------
  |  |  113|     12|#define SNMP_VERSION_3     3
  ------------------
  |  Branch (4525:5): [True: 12, False: 13]
  ------------------
 4526|     12|        NETSNMP_RUNTIME_PROTOCOL_CHECK_V3(SNMP_VERSION_3,unsupported_version);
  ------------------
  |  |  233|     12|#define NETSNMP_RUNTIME_PROTOCOL_CHECK_V3(pc_ver, pc_target) do {      \
  |  |  234|     12|        if (NETSNMP_RUNTIME_PROTOCOL_SKIP_V3(pc_ver)) {                \
  |  |  ------------------
  |  |  |  |  229|     12|    ((pc_ver == SNMP_VERSION_3) &&                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  |  113|     12|#define SNMP_VERSION_3     3
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (229:6): [True: 12, Folded]
  |  |  |  |  ------------------
  |  |  |  |  230|     12|     netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,                     \
  |  |  |  |  ------------------
  |  |  |  |  |  |   48|     12|#define NETSNMP_DS_LIBRARY_ID     0
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (230:6): [True: 0, False: 12]
  |  |  |  |  ------------------
  |  |  |  |  231|     12|                            NETSNMP_DS_LIB_DISABLE_V3))
  |  |  |  |  ------------------
  |  |  |  |  |  |  105|     12|#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|     12|    } while(0)
  |  |  ------------------
  |  |  |  Branch (238:13): [Folded, False: 12]
  |  |  ------------------
  ------------------
 4527|     12|        result = snmpv3_parse(pdu, data, &length, NULL, session);
 4528|     12|        DEBUGMSGTL(("snmp_parse",
  ------------------
  |  |   66|     12|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     12|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 12]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 12]
  |  |  ------------------
  ------------------
 4529|     12|                    "Parsed SNMPv3 message (secName:%s, secLevel:%s): %s\n",
 4530|     12|                    pdu->securityName, secLevelName[pdu->securityLevel],
 4531|     12|                    snmp_api_errstring(result)));
 4532|       |
 4533|     12|        if (result == SNMPERR_USM_UNKNOWNSECURITYNAME) {
  ------------------
  |  |  227|     12|#define SNMPERR_USM_UNKNOWNSECURITYNAME		(-43)
  ------------------
  |  Branch (4533:13): [True: 0, False: 12]
  ------------------
 4534|      0|            snmp_call_callbacks(SNMP_CALLBACK_APPLICATION,
  ------------------
  |  |   19|      0|#define SNMP_CALLBACK_APPLICATION 1
  ------------------
 4535|      0|                                SNMPD_CALLBACK_AUTH_FAILURE, pdu);
  ------------------
  |  |   21|      0|#define SNMPD_CALLBACK_AUTH_FAILURE             17
  ------------------
 4536|      0|        }
 4537|       |        
 4538|     12|        if (result) {
  ------------------
  |  Branch (4538:13): [True: 12, False: 0]
  ------------------
 4539|     12|            struct snmp_secmod_def *secmod =
 4540|     12|                find_sec_mod(pdu->securityModel);
 4541|     12|            if (!slp) {
  ------------------
  |  Branch (4541:17): [True: 0, False: 12]
  ------------------
 4542|      0|                session->s_snmp_errno = result;
 4543|     12|            } else {
 4544|       |                /*
 4545|       |                 * Call the security model to special handle any errors
 4546|       |                 */
 4547|       |
 4548|     12|                if (secmod && secmod->handle_report) {
  ------------------
  |  Branch (4548:21): [True: 9, False: 3]
  |  Branch (4548:31): [True: 9, False: 0]
  ------------------
 4549|      9|                    (*secmod->handle_report)(slp, slp->transport, session,
 4550|      9|                                             result, pdu);
 4551|      9|                }
 4552|     12|            }
 4553|     12|            free_securityStateRef(pdu);
 4554|     12|        }
 4555|       |
 4556|       |        /* Implement RFC5343 here for two reasons:
 4557|       |           1) From a security perspective it handles this otherwise
 4558|       |              always approved request earlier.  It bypasses the need
 4559|       |              for authorization to the snmpEngineID scalar, which is
 4560|       |              what is what RFC3415 appendix A species as ok.  Note
 4561|       |              that we haven't bypassed authentication since if there
 4562|       |              was an authentication error it would have been handled
 4563|       |              above in the if(result) part at the latest.
 4564|       |           2) From an application point of view if we let this request
 4565|       |              get all the way to the application, it'd require that
 4566|       |              all application types supporting discovery also fire up
 4567|       |              a minimal agent in order to handle just this request
 4568|       |              which seems like overkill.  Though there is no other
 4569|       |              application types that currently need discovery (NRs
 4570|       |              accept notifications from contextEngineIDs that derive
 4571|       |              from the NO not the NR).  Also a lame excuse for doing
 4572|       |              it here.
 4573|       |           3) Less important technically, but the net-snmp agent
 4574|       |              doesn't currently handle registrations of different
 4575|       |              engineIDs either and it would have been a lot more work
 4576|       |              to implement there since we'd need to support that
 4577|       |              first. :-/ Supporting multiple context engineIDs should
 4578|       |              be done anyway, so it's not a valid excuse here.
 4579|       |           4) There is a lot less to do if we trump the agent at this
 4580|       |              point; IE, the agent does a lot more unnecessary
 4581|       |              processing when the only thing that should ever be in
 4582|       |              this context by definition is the single scalar.
 4583|       |        */
 4584|       |
 4585|       |        /* special RFC5343 engineID discovery engineID check */
 4586|     12|        if (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|     12|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (4586:13): [True: 12, False: 0]
  ------------------
 4587|     12|                                    NETSNMP_DS_LIB_NO_DISCOVERY) &&
  ------------------
  |  |   98|     12|#define NETSNMP_DS_LIB_NO_DISCOVERY        38 /* don't support RFC5343 contextEngineID discovery */
  ------------------
 4588|     12|            SNMP_MSG_RESPONSE       != pdu->command &&
  ------------------
  |  |  127|     12|#define SNMP_MSG_RESPONSE   (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x2) /* a2=162 */
  |  |  ------------------
  |  |  |  |   92|     12|#define ASN_CONTEXT	    0x80U
  |  |  ------------------
  |  |               #define SNMP_MSG_RESPONSE   (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x2) /* a2=162 */
  |  |  ------------------
  |  |  |  |   96|     12|#define ASN_CONSTRUCTOR	    0x20U
  |  |  ------------------
  ------------------
  |  Branch (4588:13): [True: 12, False: 0]
  ------------------
 4589|     12|            NULL                    != pdu->contextEngineID &&
  ------------------
  |  Branch (4589:13): [True: 9, False: 3]
  ------------------
 4590|      9|            pdu->contextEngineIDLen == 5 &&
  ------------------
  |  Branch (4590:13): [True: 0, False: 9]
  ------------------
 4591|      0|            pdu->contextEngineID[0] == 0x80 &&
  ------------------
  |  Branch (4591:13): [True: 0, False: 0]
  ------------------
 4592|      0|            pdu->contextEngineID[1] == 0x00 &&
  ------------------
  |  Branch (4592:13): [True: 0, False: 0]
  ------------------
 4593|      0|            pdu->contextEngineID[2] == 0x00 &&
  ------------------
  |  Branch (4593:13): [True: 0, False: 0]
  ------------------
 4594|      0|            pdu->contextEngineID[3] == 0x00 &&
  ------------------
  |  Branch (4594:13): [True: 0, False: 0]
  ------------------
 4595|      0|            pdu->contextEngineID[4] == 0x06) {
  ------------------
  |  Branch (4595:13): [True: 0, False: 0]
  ------------------
 4596|       |
 4597|       |            /* define a result so it doesn't get past us at this point
 4598|       |               and gets dropped by future parts of the stack */
 4599|      0|            result = SNMPERR_JUST_A_CONTEXT_PROBE;
  ------------------
  |  |  250|      0|#define SNMPERR_JUST_A_CONTEXT_PROBE    (-66)
  ------------------
 4600|       |
 4601|      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]
  |  |  ------------------
  ------------------
 4602|       |            /* ensure exactly one variable */
 4603|      0|            if (NULL != pdu->variables &&
  ------------------
  |  Branch (4603:17): [True: 0, False: 0]
  ------------------
 4604|      0|                NULL == pdu->variables->next_variable &&
  ------------------
  |  Branch (4604:17): [True: 0, False: 0]
  ------------------
 4605|       |
 4606|       |                /* if it's a GET, match it exactly */
 4607|      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 (4607:19): [True: 0, False: 0]
  ------------------
 4608|      0|                  snmp_oid_compare(snmpEngineIDoid,
  ------------------
  |  Branch (4608:19): [True: 0, False: 0]
  ------------------
 4609|      0|                                   snmpEngineIDoid_len,
 4610|      0|                                   pdu->variables->name,
 4611|      0|                                   pdu->variables->name_length) == 0)
 4612|       |                 /* if it's a GETNEXT ensure it's less than the engineID oid */
 4613|      0|                 ||
 4614|      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 (4614:19): [True: 0, False: 0]
  ------------------
 4615|      0|                  snmp_oid_compare(snmpEngineIDoid,
  ------------------
  |  Branch (4615:19): [True: 0, False: 0]
  ------------------
 4616|      0|                                   snmpEngineIDoid_len,
 4617|      0|                                   pdu->variables->name,
 4618|      0|                                   pdu->variables->name_length) > 0)
 4619|      0|                    )) {
 4620|       |
 4621|      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]
  |  |  ------------------
  ------------------
 4622|      0|                            "  One correct variable found\n"));
 4623|       |
 4624|       |                /* Note: we're explicitly not handling a GETBULK.  Deal. */
 4625|       |
 4626|       |                /* set up the response */
 4627|      0|                pdu2 = snmp_clone_pdu(pdu);
 4628|       |
 4629|       |                /* free the current varbind */
 4630|      0|                snmp_free_varbind(pdu2->variables);
 4631|       |
 4632|       |                /* set the variables */
 4633|      0|                pdu2->variables = NULL;
 4634|      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
  |  |  ------------------
  ------------------
 4635|      0|                pdu2->errstat = 0;
 4636|      0|                pdu2->errindex = 0;
 4637|       |
 4638|      0|                ourEngineID_len =
 4639|      0|                    snmpv3_get_engineID((u_char*)ourEngineID, ourEngineID_len);
 4640|      0|                if (0 != ourEngineID_len) {
  ------------------
  |  Branch (4640:21): [True: 0, False: 0]
  ------------------
 4641|       |
 4642|      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]
  |  |  ------------------
  ------------------
 4643|      0|                                "  responding with our engineID\n"));
 4644|       |
 4645|      0|                    snmp_pdu_add_variable(pdu2,
 4646|      0|                                          snmpEngineIDoid, snmpEngineIDoid_len,
 4647|      0|                                          ASN_OCTET_STR,
  ------------------
  |  |   78|      0|#define ASN_OCTET_STR	    0x04U
  ------------------
 4648|      0|                                          ourEngineID, ourEngineID_len);
 4649|       |                    
 4650|       |                    /* send the response */
 4651|      0|                    if (0 == snmp_sess_send(slp, pdu2)) {
  ------------------
  |  Branch (4651:25): [True: 0, False: 0]
  ------------------
 4652|       |
 4653|      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]
  |  |  ------------------
  ------------------
 4654|      0|                                    "  sent it off!\n"));
 4655|       |
 4656|      0|                        snmp_free_pdu(pdu2);
 4657|       |                        
 4658|      0|                        snmp_log(LOG_ERR, "sending a response to the context engineID probe failed\n");
 4659|      0|                    }
 4660|      0|                } else {
 4661|      0|                    snmp_log(LOG_ERR, "failed to get our own engineID!\n");
 4662|      0|                    snmp_free_pdu(pdu2);
 4663|      0|                }
 4664|      0|            } else {
 4665|      0|                snmp_log(LOG_WARNING,
 4666|      0|                         "received an odd context engineID probe\n");
 4667|      0|            }
 4668|      0|        }
 4669|       |
 4670|     12|        break;
 4671|      4|    case SNMPERR_BAD_VERSION:
  ------------------
  |  |  198|      4|#define SNMPERR_BAD_VERSION		(-14)
  ------------------
  |  Branch (4671:5): [True: 4, False: 21]
  ------------------
 4672|      4|        ERROR_MSG("error parsing snmp message version");
  ------------------
  |  |  188|      4|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 4673|      4|        snmp_increment_statistic(STAT_SNMPINASNPARSEERRS);
  ------------------
  |  |  637|      4|#define  STAT_SNMPINASNPARSEERRS             14
  ------------------
 4674|      4|        session->s_snmp_errno = SNMPERR_BAD_VERSION;
  ------------------
  |  |  198|      4|#define SNMPERR_BAD_VERSION		(-14)
  ------------------
 4675|      4|        break;
 4676|       |
 4677|      0|        unsupported_version:  /* goto label */
 4678|      0|    case SNMP_VERSION_sec:
  ------------------
  |  |  118|      0|#define SNMP_VERSION_sec   128  /* not (will never be) supported by this code */
  ------------------
  |  Branch (4678:5): [True: 0, False: 25]
  ------------------
 4679|      0|    case SNMP_VERSION_2u:
  ------------------
  |  |  112|      0|#define SNMP_VERSION_2u    2    /* not (will never be) supported by this code */
  ------------------
  |  Branch (4679:5): [True: 0, False: 25]
  ------------------
 4680|      0|    case SNMP_VERSION_2star:
  ------------------
  |  |  120|      0|#define SNMP_VERSION_2star 130  /* not (will never be) supported by this code */
  ------------------
  |  Branch (4680:5): [True: 0, False: 25]
  ------------------
 4681|      0|    case SNMP_VERSION_2p:
  ------------------
  |  |  119|      0|#define SNMP_VERSION_2p	   129  /* no longer supported by this code (> 4.0) */
  ------------------
  |  Branch (4681:5): [True: 0, False: 25]
  ------------------
 4682|      2|    default:
  ------------------
  |  Branch (4682:5): [True: 2, False: 23]
  ------------------
 4683|      2|        ERROR_MSG("unsupported snmp message version");
  ------------------
  |  |  188|      2|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
 4684|      2|        snmp_increment_statistic(STAT_SNMPINBADVERSIONS);
  ------------------
  |  |  634|      2|#define  STAT_SNMPINBADVERSIONS              11
  ------------------
 4685|       |
 4686|       |        /*
 4687|       |         * need better way to determine OS independent
 4688|       |         * INT32_MAX value, for now hardcode
 4689|       |         */
 4690|      2|        if (pdu->version < 0 || pdu->version > 2147483647) {
  ------------------
  |  Branch (4690:13): [True: 1, False: 1]
  |  Branch (4690:33): [True: 0, False: 1]
  ------------------
 4691|      1|            snmp_increment_statistic(STAT_SNMPINASNPARSEERRS);
  ------------------
  |  |  637|      1|#define  STAT_SNMPINASNPARSEERRS             14
  ------------------
 4692|      1|        }
 4693|      2|        session->s_snmp_errno = SNMPERR_BAD_VERSION;
  ------------------
  |  |  198|      2|#define SNMPERR_BAD_VERSION		(-14)
  ------------------
 4694|      2|        break;
 4695|     25|    }
 4696|       |
 4697|     24|    return result;
 4698|     25|}
snmp_api.c:snmp_parse_version:
 3827|     25|{
 3828|     25|    u_char          type;
 3829|     25|    long            version = SNMPERR_BAD_VERSION;
  ------------------
  |  |  198|     25|#define SNMPERR_BAD_VERSION		(-14)
  ------------------
 3830|       |
 3831|     25|    data = asn_parse_sequence(data, &length, &type,
 3832|     25|                              (ASN_SEQUENCE | ASN_CONSTRUCTOR), "version");
  ------------------
  |  |   84|     25|#define ASN_SEQUENCE	    0x10U
  ------------------
                                            (ASN_SEQUENCE | ASN_CONSTRUCTOR), "version");
  ------------------
  |  |   96|     25|#define ASN_CONSTRUCTOR	    0x20U
  ------------------
 3833|     25|    if (data) {
  ------------------
  |  Branch (3833:9): [True: 25, False: 0]
  ------------------
 3834|     25|        DEBUGDUMPHEADER("recv", "SNMP Version");
  ------------------
  |  |   79|     25|	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     25|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 25]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	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: 25]
  |  |  ------------------
  ------------------
 3835|     25|        data =
 3836|     25|            asn_parse_int(data, &length, &type, &version, sizeof(version));
 3837|     25|        DEBUGINDENTLESS();
  ------------------
  |  |   75|     25|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|     25|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 25]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 25]
  |  |  ------------------
  ------------------
 3838|     25|        if (!data || type != ASN_INTEGER) {
  ------------------
  |  |   75|     21|#define ASN_INTEGER	    0x02U
  ------------------
  |  Branch (3838:13): [True: 4, False: 21]
  |  Branch (3838:22): [True: 0, False: 21]
  ------------------
 3839|      4|            return SNMPERR_BAD_VERSION;
  ------------------
  |  |  198|      4|#define SNMPERR_BAD_VERSION		(-14)
  ------------------
 3840|      4|        }
 3841|     25|    }
 3842|     21|    return version;
 3843|     25|}
snmp_api.c:_sess_read_dgram_packet:
 6232|     56|{
 6233|     56|    netsnmp_session *sp = slp ? slp->session : NULL;
  ------------------
  |  Branch (6233:27): [True: 56, False: 0]
  ------------------
 6234|     56|    struct snmp_internal_session *isp = slp ? slp->internal : NULL;
  ------------------
  |  Branch (6234:41): [True: 56, False: 0]
  ------------------
 6235|     56|    netsnmp_transport *transport = slp ? slp->transport : NULL;
  ------------------
  |  Branch (6235:36): [True: 56, False: 0]
  ------------------
 6236|       |
 6237|     56|    if (!sp || !isp || !transport || !rcvp ) {
  ------------------
  |  Branch (6237:9): [True: 0, False: 56]
  |  Branch (6237:16): [True: 0, False: 56]
  |  Branch (6237:24): [True: 0, False: 56]
  |  Branch (6237:38): [True: 0, False: 56]
  ------------------
 6238|      0|        DEBUGMSGTL(("sess_read_packet", "missing arguments\n"));
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 6239|      0|        return -2;
 6240|      0|    }
 6241|       |
 6242|     56|    if (transport->flags & NETSNMP_TRANSPORT_FLAG_STREAM)
  ------------------
  |  |   51|     56|#define		NETSNMP_TRANSPORT_FLAG_STREAM	 0x01
  ------------------
  |  Branch (6242:9): [True: 0, False: 56]
  ------------------
 6243|      0|        return -2;
 6244|       |
 6245|     56|    if (NULL != rcvp->packet) {
  ------------------
  |  Branch (6245:9): [True: 0, False: 56]
  ------------------
 6246|      0|        snmp_log(LOG_WARNING, "overwriting existing saved packet; sess %p\n",
 6247|      0|                 sp);
 6248|      0|        SNMP_FREE(rcvp->packet);
  ------------------
  |  |   62|      0|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 0]
  |  |  ------------------
  ------------------
 6249|      0|    }
 6250|       |
 6251|     56|    if ((rcvp->packet = (u_char *) malloc(SNMP_MAX_RCV_MSG_SIZE)) == NULL) {
  ------------------
  |  |  108|     56|#define SNMP_MAX_RCV_MSG_SIZE      65536
  ------------------
  |  Branch (6251:9): [True: 0, False: 56]
  ------------------
 6252|      0|        DEBUGMSGTL(("sess_read_packet", "can't malloc %u bytes for packet\n",
  ------------------
  |  |   66|      0|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      0|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 0]
  |  |  ------------------
  ------------------
 6253|      0|                    SNMP_MAX_RCV_MSG_SIZE));
 6254|      0|        return -2;
 6255|      0|    }
 6256|       |
 6257|     56|    rcvp->packet_len = netsnmp_transport_recv(transport, rcvp->packet,
 6258|     56|                                              SNMP_MAX_RCV_MSG_SIZE,
  ------------------
  |  |  108|     56|#define SNMP_MAX_RCV_MSG_SIZE      65536
  ------------------
 6259|     56|                                              &rcvp->opaque, &rcvp->olength);
 6260|     56|    if (rcvp->packet_len == -1) {
  ------------------
  |  Branch (6260:9): [True: 0, False: 56]
  ------------------
 6261|      0|        sp->s_snmp_errno = SNMPERR_BAD_RECVFROM;
  ------------------
  |  |  209|      0|#define SNMPERR_BAD_RECVFROM 		(-25)
  ------------------
 6262|      0|        sp->s_errno = errno;
 6263|      0|        snmp_set_detail(strerror(errno));
 6264|      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]
  |  |  ------------------
  ------------------
 6265|      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]
  |  |  ------------------
  ------------------
 6266|      0|        return -1;
 6267|      0|    }
 6268|       |
 6269|       |    /** clear so any other sess sharing this socket won't try reading again */
 6270|     56|    NETSNMP_LARGE_FD_CLR(transport->sock, fdset);
  ------------------
  |  |   43|     56|                    netsnmp_large_fd_clr(fd, fdset)
  ------------------
 6271|       |
 6272|     56|    if (0 == rcvp->packet_len &&
  ------------------
  |  Branch (6272:9): [True: 0, False: 56]
  ------------------
 6273|      0|        transport->flags & NETSNMP_TRANSPORT_FLAG_EMPTY_PKT) {
  ------------------
  |  |   56|      0|#define		NETSNMP_TRANSPORT_FLAG_EMPTY_PKT 0x10
  ------------------
  |  Branch (6273:9): [True: 0, False: 0]
  ------------------
 6274|       |        /* this allows for a transport that needs to return from
 6275|       |         * packet processing that doesn't necessarily have any
 6276|       |         * consumable data in it. */
 6277|       |
 6278|       |        /* reset the flag since it's a per-message flag */
 6279|      0|        transport->flags &= (~NETSNMP_TRANSPORT_FLAG_EMPTY_PKT);
  ------------------
  |  |   56|      0|#define		NETSNMP_TRANSPORT_FLAG_EMPTY_PKT 0x10
  ------------------
 6280|       |
 6281|       |        /** free packet */
 6282|      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]
  |  |  ------------------
  ------------------
 6283|      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]
  |  |  ------------------
  ------------------
 6284|       |
 6285|      0|        return -2;
 6286|      0|    }
 6287|       |
 6288|     56|    return 0;
 6289|     56|}
snmp_api.c:_sess_process_packet:
 6071|     25|{
 6072|     25|    netsnmp_pdu         *pdu;
 6073|     25|    int                  rc;
 6074|       |
 6075|     25|    pdu = _sess_process_packet_parse_pdu(slp, sp, isp, transport, opaque,
 6076|     25|                                         olength, packetptr, length);
 6077|     25|    if (NULL == pdu)
  ------------------
  |  Branch (6077:9): [True: 25, False: 0]
  ------------------
 6078|     25|        return -1;
 6079|       |
 6080|       |    /*
 6081|       |     * find session to process pdu. usually that will be the current session,
 6082|       |     * but with the introduction of shared transports, another session may
 6083|       |     * have the same socket.
 6084|       |     */
 6085|      0|    do {
 6086|      0|        rc = _sess_process_packet_handle_pdu(slp, sp, isp, transport, pdu);
 6087|      0|        if (-2 != rc || !(transport->flags & NETSNMP_TRANSPORT_FLAG_SHARED))
  ------------------
  |  |   58|      0|#define		NETSNMP_TRANSPORT_FLAG_SHARED	 0x40
  ------------------
  |  Branch (6087:13): [True: 0, False: 0]
  |  Branch (6087:25): [True: 0, False: 0]
  ------------------
 6088|      0|            break;
 6089|       |
 6090|       |        /** -2 means pdu not in request list. check other sessions */
 6091|      0|        do  {
 6092|      0|            slp = slp->next;
 6093|      0|        } while (slp && slp->transport->sock != transport->sock);
  ------------------
  |  Branch (6093:18): [True: 0, False: 0]
  |  Branch (6093:25): [True: 0, False: 0]
  ------------------
 6094|      0|        if (!slp)
  ------------------
  |  Branch (6094:13): [True: 0, False: 0]
  ------------------
 6095|      0|            break; /* no more sessions with same socket */
 6096|       |
 6097|      0|        sp = slp->session;
 6098|      0|        isp = slp->internal;
 6099|      0|        transport = slp->transport;
 6100|      0|    } while(slp);
  ------------------
  |  Branch (6100:13): [True: 0, False: 0]
  ------------------
 6101|       |
 6102|      0|    if (-2 == rc) { /* did not find session for pdu */
  ------------------
  |  Branch (6102:9): [True: 0, False: 0]
  ------------------
 6103|      0|        snmp_increment_statistic(STAT_SNMPUNKNOWNPDUHANDLERS);
  ------------------
  |  |  613|      0|#define   STAT_SNMPUNKNOWNPDUHANDLERS        2
  ------------------
 6104|      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]
  |  |  ------------------
  ------------------
 6105|      0|        snmp_free_pdu(pdu);
 6106|      0|    }
 6107|       |
 6108|      0|  return rc;
 6109|     25|}
snmp_api.c:_sess_process_packet_parse_pdu:
 5743|     25|{
 5744|     25|  netsnmp_pdu    *pdu;
 5745|     25|  int             ret = 0;
 5746|     25|  int             dump = 0, filter = 0;
 5747|       |
 5748|     25|  debug_indent_reset();
 5749|       |
 5750|     25|  DEBUGMSGTL(("sess_process_packet",
  ------------------
  |  |   66|     25|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     25|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 25]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 25]
  |  |  ------------------
  ------------------
 5751|     25|	      "session %p fd %d pkt %p length %d\n", slp,
 5752|     25|	      transport->sock, packetptr, length));
 5753|       |
 5754|     25|  dump = netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|     25|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 5755|     25|                                NETSNMP_DS_LIB_DUMP_PACKET);
  ------------------
  |  |   63|     25|#define NETSNMP_DS_LIB_DUMP_PACKET         4
  ------------------
 5756|     25|#ifndef NETSNMP_FEATURE_REMOVE_FILTER_SOURCE
 5757|     25|  filter = netsnmp_ds_get_int(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|     25|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
 5758|     25|                                  NETSNMP_DS_LIB_FILTER_TYPE);
  ------------------
  |  |  133|     25|#define NETSNMP_DS_LIB_FILTER_TYPE         17 /* 0=NONE, 1=whitelist, -1=blacklist */
  ------------------
 5759|     25|#endif
 5760|     25|  if (dump || filter) {
  ------------------
  |  Branch (5760:7): [True: 0, False: 25]
  |  Branch (5760:15): [True: 0, False: 25]
  ------------------
 5761|      0|      int filtered = 0;
 5762|      0|      char *addrtxt = netsnmp_transport_peer_string(transport, opaque, olength);
 5763|       |
 5764|      0|      if (!addrtxt) {
  ------------------
  |  Branch (5764:11): [True: 0, False: 0]
  ------------------
 5765|      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]
  |  |  ------------------
  ------------------
 5766|      0|                      "Failed to resolve peer address\n"));
 5767|      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]
  |  |  ------------------
  ------------------
 5768|      0|          return NULL;
 5769|      0|      }
 5770|       |
 5771|      0|      snmp_log(LOG_DEBUG, "\nReceived %d byte packet from %s\n",
 5772|      0|               length, addrtxt);
 5773|       |
 5774|      0|      if (dump)
  ------------------
  |  Branch (5774:11): [True: 0, False: 0]
  ------------------
 5775|      0|          xdump(packetptr, length, "");
 5776|       |
 5777|      0|#ifndef NETSNMP_FEATURE_REMOVE_FILTER_SOURCE
 5778|      0|      if (filter) {
  ------------------
  |  Branch (5778:11): [True: 0, False: 0]
  ------------------
 5779|      0|          char *sourceaddr = NULL, *c = strchr(addrtxt, '[');
 5780|      0|          const char *dropstr = NULL;
 5781|      0|          if (c) {
  ------------------
  |  Branch (5781:15): [True: 0, False: 0]
  ------------------
 5782|      0|              sourceaddr = ++c;
 5783|      0|              c = strchr(sourceaddr, ']');
 5784|      0|              if (c)
  ------------------
  |  Branch (5784:19): [True: 0, False: 0]
  ------------------
 5785|      0|                  *c = 0;
 5786|      0|              filtered = netsnmp_transport_filter_check(sourceaddr);
 5787|      0|          }
 5788|      0|          else if (!strncmp(addrtxt, "callback", 8)) {
  ------------------
  |  Branch (5788:20): [True: 0, False: 0]
  ------------------
 5789|       |              /* do not filter internal request */
 5790|      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]
  |  |  ------------------
  ------------------
 5791|      0|                          "bypass packet from %s \n",
 5792|      0|                          addrtxt));
 5793|      0|              filtered = 1;
 5794|      0|          }
 5795|      0|          if ((filter == -1) && filtered)
  ------------------
  |  Branch (5795:15): [True: 0, False: 0]
  |  Branch (5795:33): [True: 0, False: 0]
  ------------------
 5796|      0|              dropstr = "matched blacklist";
 5797|      0|          else if ((filter == 1) && !filtered)
  ------------------
  |  Branch (5797:20): [True: 0, False: 0]
  |  Branch (5797:37): [True: 0, False: 0]
  ------------------
 5798|      0|              dropstr = "didn't match whitelist";
 5799|      0|          if (dropstr) {
  ------------------
  |  Branch (5799:15): [True: 0, False: 0]
  ------------------
 5800|      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]
  |  |  ------------------
  ------------------
 5801|      0|                          "packet from %s %s\n",
 5802|      0|                          sourceaddr ? sourceaddr : "UNKNOWN", dropstr));
 5803|      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]
  |  |  ------------------
  ------------------
 5804|      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]
  |  |  ------------------
  ------------------
 5805|      0|              return NULL;
 5806|      0|          }
 5807|      0|      }
 5808|      0|#endif
 5809|       |
 5810|      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]
  |  |  ------------------
  ------------------
 5811|      0|  }
 5812|       |
 5813|       |  /*
 5814|       |   * Do transport-level filtering (e.g. IP-address based allow/deny).  
 5815|       |   */
 5816|       |
 5817|     25|  if (isp->hook_pre) {
  ------------------
  |  Branch (5817:7): [True: 0, False: 25]
  ------------------
 5818|      0|    if (isp->hook_pre(sp, transport, opaque, olength) == 0) {
  ------------------
  |  Branch (5818:9): [True: 0, False: 0]
  ------------------
 5819|      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]
  |  |  ------------------
  ------------------
 5820|      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]
  |  |  ------------------
  ------------------
 5821|      0|      return NULL;
 5822|      0|    }
 5823|      0|  }
 5824|       |
 5825|     25|  if (isp->hook_create_pdu) {
  ------------------
  |  Branch (5825:7): [True: 0, False: 25]
  ------------------
 5826|      0|    pdu = isp->hook_create_pdu(transport, opaque, olength);
 5827|     25|  } else {
 5828|     25|    pdu = snmp_create_sess_pdu(transport, opaque, olength);
 5829|     25|  }
 5830|       |
 5831|     25|  if (pdu == NULL) {
  ------------------
  |  Branch (5831:7): [True: 0, False: 25]
  ------------------
 5832|      0|    snmp_log(LOG_ERR, "pdu failed to be created\n");
 5833|      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]
  |  |  ------------------
  ------------------
 5834|      0|    return NULL;
 5835|      0|  }
 5836|       |
 5837|       |  /* if the transport was a magic tunnel, mark the PDU as having come
 5838|       |     through one. */
 5839|     25|  if (transport->flags & NETSNMP_TRANSPORT_FLAG_TUNNELED) {
  ------------------
  |  |   53|     25|#define		NETSNMP_TRANSPORT_FLAG_TUNNELED	 0x04
  ------------------
  |  Branch (5839:7): [True: 0, False: 25]
  ------------------
 5840|      0|      pdu->flags |= UCD_MSG_FLAG_TUNNELED;
  ------------------
  |  |  317|      0|#define UCD_MSG_FLAG_TUNNELED               0x4000
  ------------------
 5841|      0|  }
 5842|       |
 5843|     25|  if (isp->hook_parse) {
  ------------------
  |  Branch (5843:7): [True: 0, False: 25]
  ------------------
 5844|      0|    ret = isp->hook_parse(sp, pdu, packetptr, length);
 5845|     25|  } else {
 5846|     25|    ret = snmp_parse(slp, sp, pdu, packetptr, length);
 5847|     25|  }
 5848|       |
 5849|     25|  DEBUGMSGTL(("sess_process_packet", "received message id#%ld reqid#%ld len "
  ------------------
  |  |   66|     25|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     25|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 25]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 25]
  |  |  ------------------
  ------------------
 5850|     25|              "%u\n", pdu->msgid, pdu->reqid, length));
 5851|       |
 5852|     25|  if (ret != SNMP_ERR_NOERROR) {
  ------------------
  |  |  212|     25|#define SNMP_ERR_NOERROR                (0)     /* XXX  Used only for PDUs? */
  ------------------
  |  Branch (5852:7): [True: 25, False: 0]
  ------------------
 5853|     25|    DEBUGMSGTL(("sess_process_packet", "parse fail\n"));
  ------------------
  |  |   66|     25|#define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|     25|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 25]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGTL(x)      do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
  |  |  ------------------
  |  |  |  |  164|      0|#define __DBGMSGTL(x)    __DBGTRACE, debugmsgtoken x, debugmsg x
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define __DBGTRACE       __DBGMSGT(("trace","%s(): %s, %d:\n",\
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  147|      0|#define __DBGMSGT(x)     debugmsgtoken x,  debugmsg x
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  155|      0|				NETSNMP_FUNCTION,__FILE__,__LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (66:70): [Folded, False: 25]
  |  |  ------------------
  ------------------
 5854|     25|  }
 5855|       |
 5856|     25|  if (isp->hook_post) {
  ------------------
  |  Branch (5856:7): [True: 0, False: 25]
  ------------------
 5857|      0|    if (isp->hook_post(sp, pdu, ret) == 0) {
  ------------------
  |  Branch (5857:9): [True: 0, False: 0]
  ------------------
 5858|      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]
  |  |  ------------------
  ------------------
 5859|      0|      ret = SNMPERR_ASN_PARSE_ERR;
  ------------------
  |  |  213|      0|#define SNMPERR_ASN_PARSE_ERR           (-29)
  ------------------
 5860|      0|    }
 5861|      0|  }
 5862|       |
 5863|     25|  if (ret != SNMP_ERR_NOERROR) {
  ------------------
  |  |  212|     25|#define SNMP_ERR_NOERROR                (0)     /* XXX  Used only for PDUs? */
  ------------------
  |  Branch (5863:7): [True: 25, False: 0]
  ------------------
 5864|     25|    snmp_free_pdu(pdu);
 5865|     25|    return NULL;
 5866|     25|  }
 5867|       |
 5868|      0|  return pdu;
 5869|     25|}

snmp_comstr_parse:
  109|      7|{
  110|      7|    u_char          type;
  111|      7|    long            ver;
  112|      7|    size_t          origlen = *slen;
  113|       |
  114|       |    /*
  115|       |     * Message is an ASN.1 SEQUENCE.
  116|       |     */
  117|      7|    data = asn_parse_sequence(data, length, &type,
  118|      7|                              (ASN_SEQUENCE | ASN_CONSTRUCTOR),
  ------------------
  |  |   84|      7|#define ASN_SEQUENCE	    0x10U
  ------------------
                                            (ASN_SEQUENCE | ASN_CONSTRUCTOR),
  ------------------
  |  |   96|      7|#define ASN_CONSTRUCTOR	    0x20U
  ------------------
  119|      7|                              "auth message");
  120|      7|    if (data == NULL) {
  ------------------
  |  Branch (120:9): [True: 0, False: 7]
  ------------------
  121|      0|        return NULL;
  122|      0|    }
  123|       |
  124|       |    /*
  125|       |     * First field is the version.
  126|       |     */
  127|      7|    DEBUGDUMPHEADER("recv", "SNMP version");
  ------------------
  |  |   79|      7|	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      7|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 7]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	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: 7]
  |  |  ------------------
  ------------------
  128|      7|    data = asn_parse_int(data, length, &type, &ver, sizeof(ver));
  129|      7|    DEBUGINDENTLESS();
  ------------------
  |  |   75|      7|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|      7|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 7]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 7]
  |  |  ------------------
  ------------------
  130|      7|    *version = ver;
  131|      7|    if (data == NULL) {
  ------------------
  |  Branch (131:9): [True: 0, False: 7]
  ------------------
  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|      7|    DEBUGDUMPHEADER("recv", "community string");
  ------------------
  |  |   79|      7|	do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|      7|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 7]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               	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: 7]
  |  |  ------------------
  ------------------
  140|      7|    data = asn_parse_string(data, length, &type, psid, slen);
  141|      7|    DEBUGINDENTLESS();
  ------------------
  |  |   75|      7|#define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  144|      7|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 7]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGINDENTLESS()  do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
  |  |  ------------------
  |  |  |  |  174|      0|#define __DBGINDENTLESS()  debug_indent_add(-2)
  |  |  ------------------
  |  |  |  Branch (75:74): [Folded, False: 7]
  |  |  ------------------
  ------------------
  142|      7|    if (data == NULL) {
  ------------------
  |  Branch (142:9): [True: 1, False: 6]
  ------------------
  143|      1|        ERROR_MSG("bad parse of community");
  ------------------
  |  |  188|      1|#define ERROR_MSG(string)	snmp_set_detail(string)
  ------------------
  144|      1|        return NULL;
  145|      1|    }
  146|      6|    psid[SNMP_MIN(*slen, origlen - 1)] = '\0';
  ------------------
  |  |  111|      6|#define SNMP_MIN(a,b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (111:24): [True: 0, False: 6]
  |  |  ------------------
  ------------------
  147|      6|    return (u_char *) data;
  148|       |
  149|      7|}                               /* end snmp_comstr_parse() */

netsnmp_query_shutdown:
 1253|     57|netsnmp_query_shutdown(void) {
 1254|     57|    if (_def_query_session) {
  ------------------
  |  Branch (1254:9): [True: 0, False: 57]
  ------------------
 1255|      0|        snmp_close(_def_query_session);
 1256|       |        _def_query_session = NULL;
 1257|      0|    }
 1258|     57|}

debug_indent_reset:
  112|     25|{
  113|     25|    if (debugindent != 0)
  ------------------
  |  Branch (113:9): [True: 0, False: 25]
  ------------------
  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|     25|    debugindent = 0;
  116|     25|}
debug_is_token_registered:
  303|     56|{
  304|     56|    int             i, rc;
  305|       |
  306|       |    /*
  307|       |     * debugging flag is on or off
  308|       |     */
  309|     56|    if (!dodebug)
  ------------------
  |  Branch (309:9): [True: 56, False: 0]
  ------------------
  310|     56|        return SNMPERR_GENERR;
  ------------------
  |  |  185|     56|#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|  29.2k|{
  552|  29.2k|    return dodebug;
  553|  29.2k|}
snmp_debug_shutdown:
  569|     57|{
  570|     57|    int i;
  571|       |
  572|     57|    for (i = 0; i < debug_num_tokens; i++)
  ------------------
  |  Branch (572:17): [True: 0, False: 57]
  ------------------
  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|     57|}
snmp_debug_init:
  722|     57|{
  723|       |#ifdef HAVE_WOLFSSL_WOLFCRYPT_LOGGING_H
  724|       |    wolfSSL_Debugging_ON();
  725|       |    wolfSSL_SetLoggingCb(snmp_log_wolfssl_msg);
  726|       |#endif
  727|       |
  728|     57|    register_prenetsnmp_mib_handler("snmp", "doDebugging",
  729|     57|                                    debug_config_turn_on_debugging, NULL,
  730|     57|                                    "(1|0)");
  731|     57|    register_prenetsnmp_mib_handler("snmp", "debugTokens",
  732|     57|                                    debug_config_register_tokens, NULL,
  733|     57|                                    "token[,token...]");
  734|     57|#ifndef NETSNMP_DISABLE_DYNAMIC_LOG_LEVEL
  735|     57|    register_prenetsnmp_mib_handler("snmp", "debugLogLevel",
  736|       |                                    debug_config_debug_log_level, NULL,
  737|     57|                                    "(emerg|alert|crit|err|warning|notice|info|debug)");
  738|     57|#endif /* NETSNMP_DISABLE_DYNAMIC_LOG_LEVEL */
  739|     57|}

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

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

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

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

init_snmp_transport:
  124|     57|{
  125|     57|    netsnmp_ds_register_config(ASN_BOOLEAN,
  ------------------
  |  |   72|     57|#define ASN_BOOLEAN	    0x01U
  ------------------
  126|     57|                               "snmp", "dontLoadHostConfig",
  127|     57|                               NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|     57|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  128|     57|                               NETSNMP_DS_LIB_DONT_LOAD_HOST_FILES);
  ------------------
  |  |  100|     57|#define NETSNMP_DS_LIB_DONT_LOAD_HOST_FILES 40 /* don't read host.conf files */
  ------------------
  129|     57|#ifndef NETSNMP_FEATURE_REMOVE_FILTER_SOURCE
  130|     57|    register_app_config_handler("sourceFilterType",
  131|     57|                                netsnmp_transport_parse_filterType,
  132|       |                                NULL, "none|whitelist|blacklist");
  133|     57|    register_app_config_handler("sourceFilterAddress",
  134|     57|                                netsnmp_transport_parse_filter,
  135|     57|                                netsnmp_transport_filter_cleanup,
  136|     57|                                "host");
  137|     57|#endif /* NETSNMP_FEATURE_REMOVE_FILTER_SOURCE */
  138|     57|}
shutdown_snmp_transport:
  142|     57|{
  143|     57|#ifndef NETSNMP_FEATURE_REMOVE_FILTER_SOURCE
  144|     57|    netsnmp_transport_filter_cleanup();
  145|     57|#endif
  146|     57|}
netsnmp_transport_free:
  232|    114|{
  233|    114|    if (NULL == t)
  ------------------
  |  Branch (233:9): [True: 57, False: 57]
  ------------------
  234|     57|        return;
  235|       |
  236|     57|#ifndef FEATURE_REMOVE_TRANSPORT_CACHE
  237|       |    /** don't free a transport that is currently shared */
  238|     57|    if (netsnmp_transport_cache_remove(t) == 1)
  ------------------
  |  Branch (238:9): [True: 0, False: 57]
  ------------------
  239|      0|        return;
  240|     57|#endif
  241|       |
  242|     57|    SNMP_FREE(t->local);
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
  243|     57|    SNMP_FREE(t->remote);
  ------------------
  |  |   62|     57|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 57]
  |  |  |  Branch (62:66): [Folded, False: 57]
  |  |  ------------------
  ------------------
  244|     57|    SNMP_FREE(t->data);
  ------------------
  |  |   62|     57|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 0, False: 57]
  |  |  |  Branch (62:66): [Folded, False: 57]
  |  |  ------------------
  ------------------
  245|     57|    netsnmp_transport_free(t->base_transport);
  246|       |
  247|       |    SNMP_FREE(t);
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
  248|     57|}
netsnmp_transport_filter_cleanup:
  370|    228|{
  371|    228|    if (NULL == filtered)
  ------------------
  |  Branch (371:9): [True: 228, False: 0]
  ------------------
  372|    228|        return;
  373|      0|    CONTAINER_CLEAR(filtered, filtered->free_item, NULL);
  374|      0|    CONTAINER_FREE(filtered);
  375|       |    filtered = NULL;
  376|      0|}
netsnmp_transport_recv:
  439|     56|{
  440|     56|    int debugLength;
  441|       |
  442|     56|    if ((NULL == t) || (NULL == t->f_recv)) {
  ------------------
  |  Branch (442:9): [True: 0, False: 56]
  |  Branch (442:24): [True: 0, False: 56]
  ------------------
  443|      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]
  |  |  ------------------
  ------------------
  444|      0|        return SNMPERR_GENERR;
  ------------------
  |  |  185|      0|#define SNMPERR_GENERR			(-1)
  ------------------
  445|      0|    }
  446|       |
  447|     56|    length = t->f_recv(t, packet, length, opaque, olength);
  448|       |
  449|     56|    if (length <=0)
  ------------------
  |  Branch (449:9): [True: 0, False: 56]
  ------------------
  450|      0|        return length; /* don't log timeouts/socket closed */
  451|       |
  452|     56|    debugLength = (SNMPERR_SUCCESS ==
  ------------------
  |  |  184|     56|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  453|     56|                   debug_is_token_registered("transport:recv"));
  454|       |
  455|     56|    if (debugLength) {
  ------------------
  |  Branch (455:9): [True: 0, False: 56]
  ------------------
  456|      0|        char *str = netsnmp_transport_peer_string(t,
  457|      0|                                                  opaque ? *opaque : NULL,
  ------------------
  |  Branch (457:51): [True: 0, False: 0]
  ------------------
  458|      0|                                                  olength ? *olength : 0);
  ------------------
  |  Branch (458:51): [True: 0, False: 0]
  ------------------
  459|      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]
  |  |  ------------------
  ------------------
  460|      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]
  |  |  ------------------
  ------------------
  461|      0|    }
  462|       |
  463|     56|    return length;
  464|     56|}
netsnmp_tdomain_init:
  492|     57|{
  493|     57|    DEBUGMSGTL(("tdomain", "netsnmp_tdomain_init() called\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]
  |  |  ------------------
  ------------------
  494|       |
  495|       |/* include the configure generated list of constructor calls */
  496|     57|#include "transports/snmp_transport_inits.h"
  ------------------
  |  |    1|       |/* This file is automatically generated by configure.  Do not modify by hand. */
  |  |    2|     57|netsnmp_tlsbase_ctor();
  |  |    3|     57|netsnmp_tlstcp_ctor();
  |  |    4|     57|netsnmp_dtlsudp_ctor();
  |  |    5|     57|netsnmp_udpshared_ctor();
  |  |    6|     57|netsnmp_std_ctor();
  |  |    7|     57|netsnmp_ipx_ctor();
  |  |    8|     57|netsnmp_aal5pvc_ctor();
  |  |    9|     57|netsnmp_udpipv6_ctor();
  |  |   10|     57|netsnmp_tcpipv6_ctor();
  |  |   11|     57|netsnmp_udp_ctor();
  |  |   12|     57|netsnmp_tcp_ctor();
  |  |   13|     57|netsnmp_alias_ctor();
  |  |   14|     57|netsnmp_unix_ctor();
  ------------------
  497|       |
  498|     57|    netsnmp_tdomain_dump();
  499|       |
  500|       |
  501|     57|}
netsnmp_clear_tdomain_list:
  505|     57|{
  506|     57|    netsnmp_tdomain *list = domain_list, *next = NULL;
  507|     57|    DEBUGMSGTL(("tdomain", "clear_tdomain_list() called\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]
  |  |  ------------------
  ------------------
  508|       |
  509|    685|    while (list != NULL) {
  ------------------
  |  Branch (509:12): [True: 628, False: 57]
  ------------------
  510|    628|	next = list->next;
  511|    628|	SNMP_FREE(list->prefix);
  ------------------
  |  |   62|    628|#define SNMP_FREE(s)    do { if (s) { free(s); s=NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (62:34): [True: 628, False: 0]
  |  |  |  Branch (62:66): [Folded, False: 628]
  |  |  ------------------
  ------------------
  512|       |        /* attention!! list itself is not in the heap, so we must not free it! */
  513|    628|	list = next;
  514|    628|    }
  515|       |    domain_list = NULL;
  516|     57|}
netsnmp_tdomain_register:
  543|    628|{
  544|    628|    netsnmp_tdomain **prevNext = &domain_list, *d;
  545|       |
  546|    628|    if (n != NULL) {
  ------------------
  |  Branch (546:9): [True: 628, False: 0]
  ------------------
  547|  3.77k|        for (d = domain_list; d != NULL; d = d->next) {
  ------------------
  |  Branch (547:31): [True: 3.14k, False: 628]
  ------------------
  548|  3.14k|            if (netsnmp_oid_equals(n->name, n->name_length,
  ------------------
  |  Branch (548:17): [True: 0, False: 3.14k]
  ------------------
  549|  3.14k|                                d->name, d->name_length) == 0) {
  550|       |                /*
  551|       |                 * Already registered.  
  552|       |                 */
  553|      0|                return 0;
  554|      0|            }
  555|  3.14k|            prevNext = &(d->next);
  556|  3.14k|        }
  557|    628|        n->next = NULL;
  558|    628|        *prevNext = n;
  559|    628|        return 1;
  560|    628|    } else {
  561|      0|        return 0;
  562|      0|    }
  563|    628|}
netsnmp_tdomain_transport_tspec:
  632|     57|{
  633|     57|    const char *application, *str, *default_domain, *default_target, *source;
  634|     57|    int local;
  635|     57|    netsnmp_tdomain    *match = NULL;
  636|     57|    const char         *addr = NULL;
  637|     57|    const char * const *spec = NULL;
  638|     57|    int                 any_found = 0;
  639|     57|    char buf[SNMP_MAXPATH];
  640|     57|    const char **lspec = NULL;
  641|     57|    char *tokenized_domain = NULL;
  642|       |
  643|     57|    application = tspec->application;
  644|     57|    str = tspec->target;
  645|     57|    local = tspec->flags & NETSNMP_TSPEC_LOCAL;
  ------------------
  |  |  117|     57|#define NETSNMP_TSPEC_LOCAL                     0x01 /* 1=server, 0=client */
  ------------------
  646|     57|    default_domain = tspec->default_domain;
  647|     57|    default_target = tspec->default_target;
  648|     57|    source = tspec->source;
  649|       |    /** transport_config = tspec->transport_config; not used yet */
  650|       |
  651|     57|    DEBUGMSGTL(("tdomain",
  ------------------
  |  |   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: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: 57]
  |  |  ------------------
  ------------------
  652|     57|                "tdomain_transport_spec(\"%s\", \"%s\", %d, \"%s\", \"%s\", \"%s\")\n",
  653|     57|                application, str ? str : "[NIL]", local,
  654|     57|                default_domain ? default_domain : "[NIL]",
  655|     57|                default_target ? default_target : "[NIL]",
  656|     57|                source ? source : "[NIL]"));
  657|       |
  658|       |    /* see if we can load a host-name specific set of conf files */
  659|     57|    if (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|     57|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  |  Branch (659:9): [True: 57, False: 0]
  ------------------
  660|     57|                                NETSNMP_DS_LIB_DONT_LOAD_HOST_FILES) &&
  ------------------
  |  |  100|     57|#define NETSNMP_DS_LIB_DONT_LOAD_HOST_FILES 40 /* don't read host.conf files */
  ------------------
  661|     57|        netsnmp_is_fqdn(str)) {
  ------------------
  |  Branch (661:9): [True: 0, False: 57]
  ------------------
  662|      0|        static int have_added_handler = 0;
  663|      0|        char *newhost;
  664|      0|        struct config_line *config_handlers;
  665|      0|        struct config_files file_names;
  666|      0|        char *prev_hostname;
  667|       |
  668|       |        /* register a "transport" specifier */
  669|      0|        if (!have_added_handler) {
  ------------------
  |  Branch (669:13): [True: 0, False: 0]
  ------------------
  670|      0|            have_added_handler = 1;
  671|      0|            netsnmp_ds_register_config(ASN_OCTET_STR,
  ------------------
  |  |   78|      0|#define ASN_OCTET_STR	    0x04U
  ------------------
  672|      0|                                       "snmp", "transport",
  673|      0|                                       NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      0|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  674|      0|                                       NETSNMP_DS_LIB_HOSTNAME);
  ------------------
  |  |  178|      0|#define NETSNMP_DS_LIB_HOSTNAME          27
  ------------------
  675|      0|        }
  676|       |
  677|       |        /* we save on specific setting that we don't allow to change
  678|       |           from one transport creation to the next; ie, we don't want
  679|       |           the "transport" specifier to be a default.  It should be a
  680|       |           single invocation use only */
  681|      0|        prev_hostname = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      0|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  682|      0|                                              NETSNMP_DS_LIB_HOSTNAME);
  ------------------
  |  |  178|      0|#define NETSNMP_DS_LIB_HOSTNAME          27
  ------------------
  683|      0|        if (prev_hostname)
  ------------------
  |  Branch (683:13): [True: 0, False: 0]
  ------------------
  684|      0|            prev_hostname = strdup(prev_hostname);
  685|       |
  686|       |        /* read in the hosts/STRING.conf files */
  687|      0|        config_handlers = read_config_get_handlers("snmp");
  688|      0|        snprintf(buf, sizeof(buf)-1, "hosts/%s", str);
  689|      0|        file_names.fileHeader = buf;
  690|      0|        file_names.start = config_handlers;
  691|      0|        file_names.next = NULL;
  692|      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]
  |  |  ------------------
  ------------------
  693|      0|                    buf));
  694|      0|        read_config_files_of_type(EITHER_CONFIG, &file_names);
  ------------------
  |  |   16|      0|#define EITHER_CONFIG 2
  ------------------
  695|       |
  696|      0|        if (NULL !=
  ------------------
  |  Branch (696:13): [True: 0, False: 0]
  ------------------
  697|      0|            (newhost = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      0|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  698|      0|                                             NETSNMP_DS_LIB_HOSTNAME))) {
  ------------------
  |  |  178|      0|#define NETSNMP_DS_LIB_HOSTNAME          27
  ------------------
  699|      0|            strlcpy(buf, newhost, sizeof(buf));
  700|      0|            str = buf;
  701|      0|        }
  702|       |
  703|      0|        netsnmp_ds_set_string(NETSNMP_DS_LIBRARY_ID,
  ------------------
  |  |   48|      0|#define NETSNMP_DS_LIBRARY_ID     0
  ------------------
  704|      0|                              NETSNMP_DS_LIB_HOSTNAME,
  ------------------
  |  |  178|      0|#define NETSNMP_DS_LIB_HOSTNAME          27
  ------------------
  705|      0|                              prev_hostname);
  706|      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]
  |  |  ------------------
  ------------------
  707|      0|    }
  708|       |
  709|       |    /* First try - assume that there is a domain in str (domain:target) */
  710|       |
  711|     57|    if (str != NULL) {
  ------------------
  |  Branch (711:9): [True: 57, False: 0]
  ------------------
  712|     57|        const char *cp;
  713|     57|        if ((cp = strchr(str, ':')) != NULL) {
  ------------------
  |  Branch (713:13): [True: 57, False: 0]
  ------------------
  714|     57|            char* mystring = (char*)malloc(cp + 1 - str);
  715|     57|            if (mystring == NULL)
  ------------------
  |  Branch (715:17): [True: 0, False: 57]
  ------------------
  716|      0|                return NULL;
  717|     57|            memcpy(mystring, str, cp - str);
  718|     57|            mystring[cp - str] = '\0';
  719|     57|            addr = cp + 1;
  720|       |
  721|     57|            match = find_tdomain(mystring);
  722|     57|            free(mystring);
  723|     57|        }
  724|     57|    }
  725|       |
  726|       |    /*
  727|       |     * Second try, if there is no domain in str (target), then try the
  728|       |     * default domain
  729|       |     */
  730|       |
  731|     57|    if (match == NULL) {
  ------------------
  |  Branch (731:9): [True: 57, False: 0]
  ------------------
  732|     57|        addr = str;
  733|     57|        if (addr && *addr == '/') {
  ------------------
  |  Branch (733:13): [True: 57, False: 0]
  |  Branch (733:21): [True: 0, False: 57]
  ------------------
  734|      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]
  |  |  ------------------
  ------------------
  735|      0|                        "Address starts with '/', so assume \"unix\" "
  736|      0|                        "domain\n"));
  737|      0|            match = find_tdomain("unix");
  738|     57|        } else if (default_domain) {
  ------------------
  |  Branch (738:20): [True: 0, False: 57]
  ------------------
  739|      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]
  |  |  ------------------
  ------------------
  740|      0|                        "Use user specified default domain \"%s\"\n",
  741|      0|                        default_domain));
  742|      0|            if (!strchr(default_domain, ','))
  ------------------
  |  Branch (742:17): [True: 0, False: 0]
  ------------------
  743|      0|                match = find_tdomain(default_domain);
  744|      0|            else {
  745|      0|                int commas = 0;
  746|      0|                const char *cp = default_domain;
  747|      0|                char *ptr = NULL;
  748|      0|                tokenized_domain = strdup(default_domain);
  749|      0|                if (!tokenized_domain)
  ------------------
  |  Branch (749:21): [True: 0, False: 0]
  ------------------
  750|      0|                    return NULL;
  751|       |
  752|      0|                while (*++cp) if (*cp == ',') commas++;
  ------------------
  |  Branch (752:24): [True: 0, False: 0]
  |  Branch (752:35): [True: 0, False: 0]
  ------------------
  753|      0|                lspec = calloc(commas+2, sizeof(char *));
  754|      0|                if (!lspec) {
  ------------------
  |  Branch (754:21): [True: 0, False: 0]
  ------------------
  755|      0|                    free(tokenized_domain);
  756|      0|                    return NULL;
  757|      0|                }
  758|      0|                commas = 1;
  759|      0|                lspec[0] = strtok_r(tokenized_domain, ",", &ptr);
  760|      0|                while ((lspec[commas++] = strtok_r(NULL, ",", &ptr)))
  ------------------
  |  Branch (760:24): [True: 0, False: 0]
  ------------------
  761|      0|                    ;
  762|      0|                spec = lspec;
  763|      0|            }
  764|     57|        } else {
  765|     57|            spec = netsnmp_lookup_default_domains(application);
  766|     57|            if (spec == NULL) {
  ------------------
  |  Branch (766:17): [True: 57, False: 0]
  ------------------
  767|     57|                DEBUGMSGTL(("tdomain",
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
  768|     57|                            "No default domain found, assume \"udp\"\n"));
  769|     57|                match = find_tdomain("udp");
  770|     57|            } else {
  771|      0|                const char * const * r = spec;
  772|      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]
  |  |  ------------------
  ------------------
  773|      0|                            "Use application default domains"));
  774|      0|                while(*r) {
  ------------------
  |  Branch (774:23): [True: 0, False: 0]
  ------------------
  775|      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]
  |  |  ------------------
  ------------------
  776|      0|                    ++r;
  777|      0|                }
  778|      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]
  |  |  ------------------
  ------------------
  779|      0|            }
  780|     57|        }
  781|     57|    }
  782|       |
  783|     57|    for(;;) {
  784|     57|        if (match) {
  ------------------
  |  Branch (784:13): [True: 57, False: 0]
  ------------------
  785|     57|            netsnmp_transport *t = NULL;
  786|     57|            const char* addr2;
  787|       |
  788|     57|            any_found = 1;
  789|       |            /*
  790|       |             * Ok, we know what domain to try, lets see what default data
  791|       |             * should be used with it
  792|       |             */
  793|     57|            if (default_target != NULL)
  ------------------
  |  Branch (793:17): [True: 0, False: 57]
  ------------------
  794|      0|                addr2 = default_target;
  795|     57|            else
  796|     57|                addr2 = netsnmp_lookup_default_target(application,
  797|     57|                                                      match->prefix[0]);
  798|     57|            DEBUGMSGTL(("tdomain",
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
  799|     57|                        "trying domain \"%s\" address \"%s\" "
  800|     57|                        "default address \"%s\"\n",
  801|     57|                        match->prefix[0], addr ? addr : "[NIL]",
  802|     57|                        addr2 ? addr2 : "[NIL]"));
  803|     57|            if (match->f_create_from_tspec) {
  ------------------
  |  Branch (803:17): [True: 57, False: 0]
  ------------------
  804|     57|                netsnmp_tdomain_spec tspec_tmp;
  805|     57|                memcpy(&tspec_tmp, tspec, sizeof(tspec_tmp));
  806|       |                /** if we didn't have a default target but looked one up,
  807|       |                 *  copy the spec and use the found default. */
  808|     57|                if ((default_target == NULL) && (addr2 != NULL))
  ------------------
  |  Branch (808:21): [True: 57, False: 0]
  |  Branch (808:49): [True: 0, False: 57]
  ------------------
  809|      0|                    tspec_tmp.default_target = addr2;
  810|     57|                if (addr != tspec_tmp.target)
  ------------------
  |  Branch (810:21): [True: 0, False: 57]
  ------------------
  811|      0|                    tspec_tmp.target = addr;
  812|     57|                t = match->f_create_from_tspec(&tspec_tmp);
  813|     57|            }
  814|      0|            else {
  815|       |#if 0 /** remove warning until all transports implement tspec */
  816|       |                NETSNMP_LOGONCE((LOG_WARNING,
  817|       |                                 "transport domain %s uses deprecated f_create function\n",
  818|       |                                 match->prefix[0]));
  819|       |#endif
  820|      0|                if (match->f_create_from_tstring) {
  ------------------
  |  Branch (820:21): [True: 0, False: 0]
  ------------------
  821|      0|                    t = match->f_create_from_tstring(addr, local);
  822|      0|                }
  823|      0|                else
  824|      0|                    t = match->f_create_from_tstring_new(addr, local, addr2);
  825|      0|            }
  826|     57|            if (t) {
  ------------------
  |  Branch (826:17): [True: 57, False: 0]
  ------------------
  827|     57|                if (lspec) {
  ------------------
  |  Branch (827:21): [True: 0, False: 57]
  ------------------
  828|      0|                    free(tokenized_domain);
  829|      0|                    free(lspec);
  830|      0|                }
  831|     57|                return t;
  832|     57|            }
  833|     57|        }
  834|      0|        addr = str;
  835|      0|        if (spec && *spec)
  ------------------
  |  Branch (835:13): [True: 0, False: 0]
  |  Branch (835:21): [True: 0, False: 0]
  ------------------
  836|      0|            match = find_tdomain(*spec++);
  837|      0|        else
  838|      0|            break;
  839|      0|    }
  840|      0|    if (!any_found)
  ------------------
  |  Branch (840:9): [True: 0, False: 0]
  ------------------
  841|      0|        snmp_log(LOG_ERR, "No support for any checked transport domain\n");
  842|      0|    if (lspec) {
  ------------------
  |  Branch (842:9): [True: 0, False: 0]
  ------------------
  843|      0|        free(tokenized_domain);
  844|      0|        free(lspec);
  845|      0|    }
  846|       |    return NULL;
  847|     57|}
netsnmp_tdomain_transport_full:
  854|     57|{
  855|     57|    netsnmp_tdomain_spec tspec;
  856|     57|    memset(&tspec, 0x0, sizeof(tspec));
  857|     57|    tspec.application = application;
  858|     57|    tspec.target = str;
  859|     57|    if (local)
  ------------------
  |  Branch (859:9): [True: 57, False: 0]
  ------------------
  860|     57|        tspec.flags |= NETSNMP_TSPEC_LOCAL;
  ------------------
  |  |  117|     57|#define NETSNMP_TSPEC_LOCAL                     0x01 /* 1=server, 0=client */
  ------------------
  861|     57|    tspec.default_domain = default_domain;
  862|     57|    tspec.default_target = default_target;
  863|     57|    tspec.source = NULL;
  864|       |    tspec.transport_config = NULL;
  865|     57|    return netsnmp_tdomain_transport_tspec(&tspec);
  866|     57|}
netsnmp_transport_open_server:
  925|     57|{
  926|     57|    return netsnmp_tdomain_transport_full(application, str, 1, NULL, NULL);
  927|     57|}
_tc_find_transport:
 1229|     57|{
 1230|       |    /*
 1231|       |     * we shouldn't really have that many transports, so instead of
 1232|       |     * using an additional key, just iterate over the whole container.
 1233|       |     */
 1234|     57|    netsnmp_iterator  *itr;
 1235|     57|    trans_cache *tc;
 1236|       |
 1237|     57|    DEBUGMSGTL(("transport:cache:find_transport", "%p\n", t));
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 1238|       |
 1239|     57|    if (NULL == _container)
  ------------------
  |  Branch (1239:9): [True: 57, False: 0]
  ------------------
 1240|     57|        return NULL;
 1241|       |
 1242|      0|    itr = CONTAINER_ITERATOR(_container);
  ------------------
  |  |  404|      0|#define CONTAINER_ITERATOR(x)       (x)->get_iterator(x)
  ------------------
 1243|      0|    if (NULL == itr) {
  ------------------
  |  Branch (1243:9): [True: 0, False: 0]
  ------------------
 1244|      0|        snmp_log(LOG_ERR, "could not get iterator for transport cache\n");
 1245|      0|        return NULL;
 1246|      0|    }
 1247|       |
 1248|      0|    tc = ITERATOR_FIRST(itr);
  ------------------
  |  |  546|      0|#define ITERATOR_FIRST(x)  x->first(x)
  ------------------
 1249|      0|    for( ; tc; tc = ITERATOR_NEXT(itr))
  ------------------
  |  |  547|      0|#define ITERATOR_NEXT(x)   x->next(x)
  ------------------
  |  Branch (1249:12): [True: 0, False: 0]
  ------------------
 1250|      0|        if (tc->t == t)
  ------------------
  |  Branch (1250:13): [True: 0, False: 0]
  ------------------
 1251|      0|            break;
 1252|      0|    ITERATOR_RELEASE(itr);
  ------------------
  |  |  550|      0|#define ITERATOR_RELEASE(x) do { x->release(x); x = NULL; } while(0)
  |  |  ------------------
  |  |  |  Branch (550:67): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1253|       |
 1254|      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]
  |  |  ------------------
  ------------------
 1255|       |
 1256|      0|    return tc;
 1257|      0|}
netsnmp_transport_cache_remove:
 1261|     57|{
 1262|     57|    trans_cache *tc;
 1263|       |
 1264|     57|    DEBUGMSGTL(("transport:cache:close", "%p\n", t));
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 1265|       |
 1266|     57|    if (NULL == t)
  ------------------
  |  Branch (1266:9): [True: 0, False: 57]
  ------------------
 1267|      0|        return 0;
 1268|       |
 1269|       |    /** transport in cache? */
 1270|     57|    tc = _tc_find_transport(t);
 1271|     57|    if (NULL == tc) {
  ------------------
  |  Branch (1271:9): [True: 57, False: 0]
  ------------------
 1272|     57|        DEBUGMSGTL(("transport:cache:close", "%p not found in cache\n", t));
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 1273|     57|        return 0;
 1274|     57|    }
 1275|       |
 1276|      0|    --tc->count;
 1277|       |
 1278|       |    /** still in use? */
 1279|      0|    if (tc->count > 0) {
  ------------------
  |  Branch (1279:9): [True: 0, False: 0]
  ------------------
 1280|      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]
  |  |  ------------------
  ------------------
 1281|      0|                    tc->count, t));
 1282|      0|        return 1;
 1283|      0|    }
 1284|       |
 1285|       |    /** unbalanced get/close? */
 1286|      0|    if (tc->count < 0)
  ------------------
  |  Branch (1286:9): [True: 0, False: 0]
  ------------------
 1287|      0|        snmp_log(LOG_WARNING, "transport cache get/close mismatch\n");
 1288|       |
 1289|      0|    _tc_remove(tc);
 1290|      0|    _tc_free(tc); /* also does close */
 1291|       |
 1292|      0|    return 0;
 1293|      0|}
snmp_transport.c:netsnmp_tdomain_dump:
  521|     57|{
  522|     57|    netsnmp_tdomain *d;
  523|     57|    int i = 0;
  524|       |
  525|     57|    DEBUGMSGTL(("tdomain", "domain_list -> "));
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
  526|    685|    for (d = domain_list; d != NULL; d = d->next) {
  ------------------
  |  Branch (526:27): [True: 628, False: 57]
  ------------------
  527|    628|        DEBUGMSG(("tdomain", "{ "));
  ------------------
  |  |   61|    628|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  144|    628|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 628]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (61:67): [Folded, False: 628]
  |  |  ------------------
  ------------------
  528|    628|        DEBUGMSGOID(("tdomain", d->name, d->name_length));
  ------------------
  |  |   67|    628|#define DEBUGMSGOID(x)     do {if (_DBG_IF_) {__DBGMSGOID(x);} }while(0)
  |  |  ------------------
  |  |  |  |  144|    628|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 628]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define DEBUGMSGOID(x)     do {if (_DBG_IF_) {__DBGMSGOID(x);} }while(0)
  |  |  ------------------
  |  |  |  |  165|      0|#define __DBGMSGOID(x)     debugmsg_oid x
  |  |  ------------------
  |  |  |  Branch (67:71): [Folded, False: 628]
  |  |  ------------------
  ------------------
  529|    628|        DEBUGMSG(("tdomain", ", \""));
  ------------------
  |  |   61|    628|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  144|    628|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 628]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (61:67): [Folded, False: 628]
  |  |  ------------------
  ------------------
  530|  1.82k|        for (i = 0; d->prefix[i] != NULL; i++) {
  ------------------
  |  Branch (530:21): [True: 1.19k, False: 628]
  ------------------
  531|  1.19k|            DEBUGMSG(("tdomain", "%s%s", d->prefix[i],
  ------------------
  |  |   61|  1.19k|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  144|  1.19k|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 1.19k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (61:56): [True: 0, False: 0]
  |  |  |  Branch (61:67): [Folded, False: 1.19k]
  |  |  ------------------
  ------------------
  532|  1.19k|		      (d->prefix[i + 1]) ? "/" : ""));
  533|  1.19k|        }
  534|    628|        DEBUGMSG(("tdomain", "\" } -> "));
  ------------------
  |  |   61|    628|#define DEBUGMSG(x)        do {if (_DBG_IF_) {debugmsg x;} }while(0)
  |  |  ------------------
  |  |  |  |  144|    628|#define _DBG_IF_            snmp_get_do_debugging()
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (144:29): [True: 0, False: 628]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (61:67): [Folded, False: 628]
  |  |  ------------------
  ------------------
  535|    628|    }
  536|     57|    DEBUGMSG(("tdomain", "[NIL]\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]
  |  |  ------------------
  ------------------
  537|     57|}
snmp_transport.c:netsnmp_is_fqdn:
  612|     57|{
  613|     57|    if (!thename)
  ------------------
  |  Branch (613:9): [True: 0, False: 57]
  ------------------
  614|      0|        return 0;
  615|    570|    while(*thename) {
  ------------------
  |  Branch (615:11): [True: 570, False: 0]
  ------------------
  616|    570|        if (*thename != '.' && !isupper((unsigned char)*thename) &&
  ------------------
  |  Branch (616:13): [True: 399, False: 171]
  |  Branch (616:32): [True: 399, False: 0]
  ------------------
  617|    399|            !islower((unsigned char)*thename) &&
  ------------------
  |  Branch (617:13): [True: 399, False: 0]
  ------------------
  618|    399|            !isdigit((unsigned char)*thename) && *thename != '-') {
  ------------------
  |  Branch (618:13): [True: 57, False: 342]
  |  Branch (618:50): [True: 57, False: 0]
  ------------------
  619|     57|            return 0;
  620|     57|        }
  621|    513|        thename++;
  622|    513|    }
  623|      0|    return 1;
  624|     57|}
snmp_transport.c:find_tdomain:
  594|    114|{
  595|    114|    netsnmp_tdomain *d;
  596|  1.14k|    for (d = domain_list; d != NULL; d = d->next) {
  ------------------
  |  Branch (596:27): [True: 1.08k, False: 57]
  ------------------
  597|  1.08k|        int i;
  598|  3.25k|        for (i = 0; d->prefix[i] != NULL; i++)
  ------------------
  |  Branch (598:21): [True: 2.22k, False: 1.02k]
  ------------------
  599|  2.22k|            if (strcasecmp(d->prefix[i], spec) == 0) {
  ------------------
  |  Branch (599:17): [True: 57, False: 2.16k]
  ------------------
  600|     57|                DEBUGMSGTL(("tdomain",
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
  601|     57|                            "Found domain \"%s\" from specifier \"%s\"\n",
  602|     57|                            d->prefix[0], spec));
  603|     57|                return d;
  604|     57|            }
  605|  1.08k|    }
  606|     57|    DEBUGMSGTL(("tdomain", "Found no domain from specifier \"%s\"\n", spec));
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
  607|       |    return NULL;
  608|    114|}

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

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

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

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

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

netsnmp_gethostbyname_v4:
  773|     57|{
  774|     57|#ifdef HAVE_GETADDRINFO
  775|     57|    struct addrinfo *addrs = NULL;
  776|     57|    struct addrinfo hint;
  777|     57|    int             err;
  778|       |
  779|     57|    memset(&hint, 0, sizeof hint);
  780|     57|    hint.ai_flags = 0;
  781|     57|    hint.ai_family = PF_INET;
  782|     57|    hint.ai_socktype = SOCK_DGRAM;
  783|     57|    hint.ai_protocol = 0;
  784|       |
  785|     57|    err = netsnmp_getaddrinfo(name, NULL, &hint, &addrs);
  786|     57|    if (err != 0) {
  ------------------
  |  Branch (786:9): [True: 0, False: 57]
  ------------------
  787|      0|        return -1;
  788|      0|    }
  789|       |
  790|     57|    if (addrs != NULL) {
  ------------------
  |  Branch (790:9): [True: 57, False: 0]
  ------------------
  791|     57|        memcpy(addr_out,
  792|     57|               &((struct sockaddr_in *) addrs->ai_addr)->sin_addr,
  793|     57|               sizeof(in_addr_t));
  794|     57|        freeaddrinfo(addrs);
  795|     57|    } 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|    }
  799|     57|    return 0;
  800|       |
  801|       |#elif defined(HAVE_GETHOSTBYNAME)
  802|       |    struct hostent *hp = NULL;
  803|       |
  804|       |    hp = netsnmp_gethostbyname(name);
  805|       |    if (hp == NULL) {
  806|       |        DEBUGMSGTL(("get_thisaddr",
  807|       |                    "hostname (couldn't resolve)\n"));
  808|       |        return -1;
  809|       |    } else if (hp->h_addrtype != AF_INET) {
  810|       |        DEBUGMSGTL(("get_thisaddr",
  811|       |                    "hostname (not AF_INET!)\n"));
  812|       |        return -1;
  813|       |    } else {
  814|       |        DEBUGMSGTL(("get_thisaddr",
  815|       |                    "hostname (resolved okay)\n"));
  816|       |        memcpy(addr_out, hp->h_addr, sizeof(in_addr_t));
  817|       |    }
  818|       |    return 0;
  819|       |
  820|       |#elif defined(HAVE_GETIPNODEBYNAME)
  821|       |    struct hostent *hp = NULL;
  822|       |    int             err;
  823|       |
  824|       |    hp = getipnodebyname(peername, AF_INET, 0, &err);
  825|       |    if (hp == NULL) {
  826|       |        DEBUGMSGTL(("get_thisaddr",
  827|       |                    "hostname (couldn't resolve = %d)\n", err));
  828|       |        return -1;
  829|       |    }
  830|       |    DEBUGMSGTL(("get_thisaddr",
  831|       |                "hostname (resolved okay)\n"));
  832|       |    memcpy(addr_out, hp->h_addr, sizeof(in_addr_t));
  833|       |    return 0;
  834|       |
  835|       |#else /* HAVE_GETIPNODEBYNAME */
  836|       |    return -1;
  837|       |#endif
  838|     57|}
netsnmp_getaddrinfo:
  843|     57|{
  844|     57|#ifdef HAVE_GETADDRINFO
  845|     57|    struct addrinfo *addrs = NULL;
  846|     57|    struct addrinfo hint;
  847|     57|    int             err;
  848|       |#ifdef DNSSEC_LOCAL_VALIDATION
  849|       |    val_status_t    val_status;
  850|       |#endif
  851|       |
  852|     57|    DEBUGMSGTL(("dns:getaddrinfo", "looking up "));
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
  853|     57|    if (name)
  ------------------
  |  Branch (853:9): [True: 57, False: 0]
  ------------------
  854|     57|        DEBUGMSG(("dns:getaddrinfo", "\"%s\"", name));
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
  855|      0|    else
  856|      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]
  |  |  ------------------
  ------------------
  857|       |
  858|     57|    if (service)
  ------------------
  |  Branch (858:9): [True: 0, False: 57]
  ------------------
  859|      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]
  |  |  ------------------
  ------------------
  860|       |
  861|     57|    if (hints)
  ------------------
  |  Branch (861:9): [True: 57, False: 0]
  ------------------
  862|     57|	DEBUGMSG(("dns:getaddrinfo",
  ------------------
  |  |   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:56): [True: 0, False: 0]
  |  |  |  Branch (61:56): [True: 0, False: 0]
  |  |  |  Branch (61:56): [True: 0, False: 0]
  |  |  |  Branch (61:67): [Folded, False: 57]
  |  |  ------------------
  ------------------
  863|     57|                  " with hints ({.ai_flags = %#x, .ai_family = %s})",
  864|     57|                  hints->ai_flags, hints->ai_family == 0 ? "0" :
  865|     57|                  hints->ai_family == AF_INET ? "AF_INET" :
  866|     57|                  hints->ai_family == AF_INET6 ? "AF_INET6" : "?"));
  867|      0|    else
  868|      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]
  |  |  ------------------
  ------------------
  869|       |
  870|     57|    DEBUGMSG(("dns:getaddrinfo", "\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]
  |  |  ------------------
  ------------------
  871|       |
  872|     57|    if (NULL == hints) {
  ------------------
  |  Branch (872:9): [True: 0, False: 57]
  ------------------
  873|      0|        memset(&hint, 0, sizeof hint);
  874|      0|        hint.ai_flags = 0;
  875|      0|        hint.ai_family = PF_INET;
  876|      0|        hint.ai_socktype = SOCK_DGRAM;
  877|      0|        hint.ai_protocol = 0;
  878|      0|        hints = &hint;
  879|     57|    } else {
  880|     57|        memcpy(&hint, hints, sizeof hint);
  881|     57|    }
  882|       |
  883|     57|#ifndef DNSSEC_LOCAL_VALIDATION
  884|     57|    err = getaddrinfo(name, NULL, &hint, &addrs);
  885|       |#else /* DNSSEC_LOCAL_VALIDATION */
  886|       |    err = val_getaddrinfo(netsnmp_validator_context(), name, NULL, &hint,
  887|       |                          &addrs, &val_status);
  888|       |    DEBUGMSGTL(("dns:sec:val", "err %d, val_status %d / %s; trusted: %d\n",
  889|       |                err, val_status, p_val_status(val_status),
  890|       |                val_istrusted(val_status)));
  891|       |    if (! val_istrusted(val_status)) {
  892|       |        int rc;
  893|       |        if ((err != 0) && VAL_GETADDRINFO_HAS_STATUS(err)) {
  894|       |            snmp_log(LOG_WARNING,
  895|       |                     "WARNING: UNTRUSTED error in DNS resolution for %s!\n",
  896|       |                     name);
  897|       |            rc = EAI_FAIL;
  898|       |        } else {
  899|       |            snmp_log(LOG_WARNING,
  900|       |                     "The authenticity of DNS response is not trusted (%s)\n",
  901|       |                     p_val_status(val_status));
  902|       |            rc = EAI_NONAME;
  903|       |        }
  904|       |        /** continue anyways if DNSSEC_WARN_ONLY is set */
  905|       |        if (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, 
  906|       |                                    NETSNMP_DS_LIB_DNSSEC_WARN_ONLY))
  907|       |            return rc;
  908|       |    }
  909|       |
  910|       |
  911|       |#endif /* DNSSEC_LOCAL_VALIDATION */
  912|     57|    *res = addrs;
  913|     57|    DEBUGIF("dns:getaddrinfo") {
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  914|      0|        if (err == 0 && addrs && addrs->ai_addr) {
  ------------------
  |  Branch (914:13): [True: 0, False: 0]
  |  Branch (914:25): [True: 0, False: 0]
  |  Branch (914:34): [True: 0, False: 0]
  ------------------
  915|      0|            const char *fam = "?";
  916|      0|            char dst[64] = "?";
  917|      0|            uint16_t port = 0;
  918|       |
  919|      0|            switch (addrs->ai_addr->sa_family) {
  ------------------
  |  Branch (919:21): [True: 0, False: 0]
  ------------------
  920|      0|            case AF_INET: {
  ------------------
  |  Branch (920:13): [True: 0, False: 0]
  ------------------
  921|      0|                struct sockaddr_in *sin = (struct sockaddr_in *)addrs->ai_addr;
  922|       |
  923|      0|                fam = "AF_INET";
  924|      0|                inet_ntop(AF_INET, &sin->sin_addr, dst, sizeof(dst));
  925|      0|                port = ntohs(sin->sin_port);
  926|      0|                break;
  927|      0|            }
  928|      0|            case AF_INET6: {
  ------------------
  |  Branch (928:13): [True: 0, False: 0]
  ------------------
  929|      0|                struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)
  930|      0|                    addrs->ai_addr;
  931|       |
  932|      0|                fam = "AF_INET6";
  933|      0|                inet_ntop(AF_INET6, &sin6->sin6_addr, dst, sizeof(dst));
  934|      0|                port = ntohs(sin6->sin6_port);
  935|      0|                break;
  936|      0|            }
  937|      0|            }
  938|      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]
  |  |  ------------------
  ------------------
  939|      0|                        port));
  940|      0|        }
  941|      0|    }
  942|     57|    return err;
  943|       |#else
  944|       |    NETSNMP_LOGONCE((LOG_ERR, "getaddrinfo not available"));
  945|       |    return EAI_FAIL;
  946|       |#endif /* getaddrinfo */
  947|     57|}
calculate_sectime_diff:
 1176|    114|{
 1177|    114|    struct timeval  diff;
 1178|       |
 1179|    114|    NETSNMP_TIMERSUB(now, then, &diff);
  ------------------
  |  |  173|    114|#define NETSNMP_TIMERSUB(a, b, res) do {                        \
  |  |  174|    114|    (res)->tv_sec  = (a)->tv_sec  - (b)->tv_sec - 1;            \
  |  |  175|    114|    (res)->tv_usec = (a)->tv_usec - (b)->tv_usec + 1000000L;    \
  |  |  176|    114|    if ((res)->tv_usec >= 1000000L) {                           \
  |  |  ------------------
  |  |  |  Branch (176:9): [True: 114, False: 0]
  |  |  ------------------
  |  |  177|    114|        (res)->tv_usec -= 1000000L;                             \
  |  |  178|    114|        (res)->tv_sec++;                                        \
  |  |  179|    114|    }                                                           \
  |  |  180|    114|} while (0)
  |  |  ------------------
  |  |  |  Branch (180:10): [Folded, False: 114]
  |  |  ------------------
  ------------------
 1180|    114|    return (u_int)(diff.tv_sec + (diff.tv_usec >= 500000L));
 1181|    114|}
mkdirhier:
 1241|      1|{
 1242|      1|    struct stat     sbuf;
 1243|      1|    char           *ourcopy = strdup(pathname);
 1244|      1|    char           *entry;
 1245|      1|    char           *buf = NULL;
 1246|      1|    char           *st = NULL;
 1247|      1|    int             res;
 1248|       |
 1249|      1|    res = SNMPERR_GENERR;
  ------------------
  |  |  185|      1|#define SNMPERR_GENERR			(-1)
  ------------------
 1250|      1|    if (!ourcopy)
  ------------------
  |  Branch (1250:9): [True: 0, False: 1]
  ------------------
 1251|      0|        goto out;
 1252|       |
 1253|      1|    buf = malloc(strlen(pathname) + 2);
 1254|      1|    if (!buf)
  ------------------
  |  Branch (1254:9): [True: 0, False: 1]
  ------------------
 1255|      0|        goto out;
 1256|       |
 1257|       |#if defined (WIN32) || defined (cygwin)
 1258|       |    /* convert backslash to forward slash */
 1259|       |    for (entry = ourcopy; *entry; entry++)
 1260|       |        if (*entry == '\\')
 1261|       |            *entry = '/';
 1262|       |#endif
 1263|       |
 1264|      1|    entry = strtok_r(ourcopy, "/", &st);
 1265|       |
 1266|      1|    buf[0] = '\0';
 1267|       |
 1268|       |#if defined (WIN32) || defined (cygwin)
 1269|       |    /*
 1270|       |     * Check if first entry contains a drive-letter
 1271|       |     *   e.g  "c:/path"
 1272|       |     */
 1273|       |    if ((entry) && (':' == entry[1]) &&
 1274|       |        (('\0' == entry[2]) || ('/' == entry[2]))) {
 1275|       |        strcat(buf, entry);
 1276|       |        entry = strtok_r(NULL, "/", &st);
 1277|       |    }
 1278|       |#endif
 1279|       |
 1280|       |    /*
 1281|       |     * check to see if filename is a directory 
 1282|       |     */
 1283|      3|    while (entry) {
  ------------------
  |  Branch (1283:12): [True: 2, False: 1]
  ------------------
 1284|      2|        strcat(buf, "/");
 1285|      2|        strcat(buf, entry);
 1286|      2|        entry = strtok_r(NULL, "/", &st);
 1287|      2|        if (entry == NULL && skiplast)
  ------------------
  |  Branch (1287:13): [True: 1, False: 1]
  |  Branch (1287:30): [True: 0, False: 1]
  ------------------
 1288|      0|            break;
 1289|      2|        if (stat(buf, &sbuf) < 0) {
  ------------------
  |  Branch (1289:13): [True: 1, False: 1]
  ------------------
 1290|       |            /*
 1291|       |             * DNE, make it 
 1292|       |             */
 1293|       |#ifdef WIN32
 1294|       |            if (CreateDirectory(buf, NULL) == 0)
 1295|       |#else
 1296|      1|            if (mkdir(buf, mode) == -1)
  ------------------
  |  Branch (1296:17): [True: 0, False: 1]
  ------------------
 1297|      0|#endif
 1298|      0|                goto out;
 1299|      1|            else
 1300|      1|                snmp_log(LOG_INFO, "Created directory: %s\n", buf);
 1301|      1|        } else {
 1302|       |            /*
 1303|       |             * exists, is it a file? 
 1304|       |             */
 1305|      1|            if ((sbuf.st_mode & S_IFDIR) == 0) {
  ------------------
  |  Branch (1305:17): [True: 0, False: 1]
  ------------------
 1306|       |                /*
 1307|       |                 * ack! can't make a directory on top of a file 
 1308|       |                 */
 1309|      0|                goto out;
 1310|      0|            }
 1311|      1|        }
 1312|      2|    }
 1313|      1|    res = SNMPERR_SUCCESS;
  ------------------
  |  |  184|      1|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
 1314|      1|out:
 1315|      1|    free(buf);
 1316|      1|    free(ourcopy);
 1317|      1|    return res;
 1318|      1|}
netsnmp_os_prematch:
 1384|     57|{
 1385|     57|#ifdef HAVE_SYS_UTSNAME_H
 1386|     57|  static int printOSonce = 1;
 1387|     57|  struct utsname utsbuf;
 1388|     57|  if ( 0 > uname(&utsbuf))
  ------------------
  |  Branch (1388:8): [True: 0, False: 57]
  ------------------
 1389|      0|    return -1;
 1390|       |
 1391|     57|  if (printOSonce) {
  ------------------
  |  Branch (1391:7): [True: 1, False: 56]
  ------------------
 1392|      1|    printOSonce = 0;
 1393|       |    /* show the four elements that the kernel can be sure of */
 1394|      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]
  |  |  ------------------
  ------------------
 1395|      1|      utsbuf.sysname, utsbuf.release, utsbuf.version, utsbuf.machine));
 1396|      1|  }
 1397|     57|  if (0 != strcasecmp(utsbuf.sysname, ospmname)) return -1;
  ------------------
  |  Branch (1397:7): [True: 0, False: 57]
  ------------------
 1398|       |
 1399|       |  /* Required to match only the leading characters */
 1400|     57|  return strncasecmp(utsbuf.release, ospmrelprefix, strlen(ospmrelprefix));
 1401|       |
 1402|       |#else
 1403|       |
 1404|       |  return -1;
 1405|       |
 1406|       |#endif /* HAVE_SYS_UTSNAME_H */
 1407|     57|}

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

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

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

netsnmp_dtlsudp_ctor:
 1704|     57|{
 1705|     57|    static const char indexname[] = "_netsnmp_addr_info";
 1706|     57|    static const char *prefixes[] = { "dtlsudp", "dtls"
 1707|     57|#ifdef NETSNMP_TRANSPORT_UDPIPV6_DOMAIN
 1708|     57|                                      , "dtlsudp6", "dtls6"
 1709|     57|#endif
 1710|     57|    };
 1711|     57|    int i, num_prefixes = sizeof(prefixes) / sizeof(char *);
 1712|     57|#ifdef NETSNMP_TRANSPORT_UDPIPV6_DOMAIN
 1713|     57|    static const char indexname6[] = "_netsnmp_addr_info6";
 1714|     57|#endif
 1715|       |
 1716|     57|    DEBUGMSGTL(("dtlsudp", "registering DTLS constructor\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]
  |  |  ------------------
  ------------------
 1717|       |
 1718|       |    /* config settings */
 1719|       |
 1720|     57|#ifdef NETSNMP_TRANSPORT_UDPIPV6_DOMAIN
 1721|     57|    if (!openssl_addr_index6)
  ------------------
  |  Branch (1721:9): [True: 1, False: 56]
  ------------------
 1722|      1|        openssl_addr_index6 =
 1723|      1|            SSL_get_ex_new_index(0, NETSNMP_REMOVE_CONST(void *, indexname6),
 1724|     57|                                 NULL, NULL, NULL);
 1725|     57|#endif
 1726|       |
 1727|     57|    dtlsudpDomain.name = netsnmpDTLSUDPDomain;
 1728|     57|    dtlsudpDomain.name_length = netsnmpDTLSUDPDomain_len;
 1729|     57|    dtlsudpDomain.prefix = calloc(num_prefixes + 1, sizeof(char *));
 1730|     57|    if (!dtlsudpDomain.prefix) {
  ------------------
  |  Branch (1730:9): [True: 0, False: 57]
  ------------------
 1731|      0|        snmp_log(LOG_ERR, "calloc() failed - out of memory\n");
 1732|      0|        return;
 1733|      0|    }
 1734|    285|    for (i = 0; i < num_prefixes; ++ i)
  ------------------
  |  Branch (1734:17): [True: 228, False: 57]
  ------------------
 1735|    228|        dtlsudpDomain.prefix[i] = prefixes[i];
 1736|       |
 1737|     57|    dtlsudpDomain.f_create_from_tstring_new = netsnmp_dtlsudp_create_tstring;
 1738|     57|    dtlsudpDomain.f_create_from_ostring     = netsnmp_dtlsudp_create_ostring;
 1739|       |
 1740|     57|    if (!openssl_addr_index)
  ------------------
  |  Branch (1740:9): [True: 1, False: 56]
  ------------------
 1741|      1|        openssl_addr_index =
 1742|      1|            SSL_get_ex_new_index(0, NETSNMP_REMOVE_CONST(void *, indexname),
 1743|     57|                                 NULL, NULL, NULL);
 1744|       |
 1745|     57|    netsnmp_tdomain_register(&dtlsudpDomain);
 1746|     57|}

netsnmp_parse_ep_str:
   31|     57|{
   32|     57|    char *dup, *cp, *addrstr = NULL, *iface = NULL, *portstr = NULL;
   33|     57|    unsigned port;
   34|       |
   35|     57|    if (!endpoint)
  ------------------
  |  Branch (35:9): [True: 0, False: 57]
  ------------------
   36|      0|        return 0;
   37|       |
   38|     57|    dup = strdup(endpoint);
   39|     57|    if (!dup)
  ------------------
  |  Branch (39:9): [True: 0, False: 57]
  ------------------
   40|      0|        return 0;
   41|       |
   42|     57|    cp = dup;
   43|     57|    if (netsnmp_isnumber(cp)) {
  ------------------
  |  Branch (43:9): [True: 0, False: 57]
  ------------------
   44|      0|        portstr = cp;
   45|     57|    } else {
   46|     57|        if (*cp == '[') {
  ------------------
  |  Branch (46:13): [True: 0, False: 57]
  ------------------
   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|     57|        } else if (*cp != '@' && (*cp != ':' || cp[1] == ':')) {
  ------------------
  |  Branch (55:20): [True: 57, False: 0]
  |  Branch (55:35): [True: 57, False: 0]
  |  Branch (55:49): [True: 0, False: 0]
  ------------------
   56|     57|            addrstr = cp;
   57|     57|            cp = strchr(addrstr, '@');
   58|     57|            if (!cp) {
  ------------------
  |  Branch (58:17): [True: 57, False: 0]
  ------------------
   59|     57|                cp = strrchr(addrstr, ':');
   60|     57|                if (cp && strchr(dup, ':') < cp)
  ------------------
  |  Branch (60:21): [True: 57, False: 0]
  |  Branch (60:27): [True: 0, False: 57]
  ------------------
   61|      0|                    cp = NULL;
   62|     57|            }
   63|     57|        }
   64|     57|        if (cp && *cp == '@') {
  ------------------
  |  Branch (64:13): [True: 57, False: 0]
  |  Branch (64:19): [True: 0, False: 57]
  ------------------
   65|      0|            *cp = '\0';
   66|      0|            iface = cp + 1;
   67|      0|            cp = strchr(cp + 1, ':');
   68|      0|        }
   69|     57|        if (cp && *cp == ':') {
  ------------------
  |  Branch (69:13): [True: 57, False: 0]
  |  Branch (69:19): [True: 57, False: 0]
  ------------------
   70|     57|            *cp++ = '\0';
   71|     57|            portstr = cp;
   72|     57|            if (!netsnmp_isnumber(cp))
  ------------------
  |  Branch (72:17): [True: 0, False: 57]
  ------------------
   73|      0|                goto err;
   74|     57|        } 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|     57|    }
   78|       |
   79|     57|    if (addrstr) {
  ------------------
  |  Branch (79:9): [True: 57, False: 0]
  ------------------
   80|     57|        ep_str->addr = strdup(addrstr);
   81|     57|        if (!ep_str->addr)
  ------------------
  |  Branch (81:13): [True: 0, False: 57]
  ------------------
   82|      0|            goto err;
   83|     57|    }
   84|     57|    if (iface)
  ------------------
  |  Branch (84:9): [True: 0, False: 57]
  ------------------
   85|      0|        strlcpy(ep_str->iface, iface, sizeof(ep_str->iface));
   86|     57|    if (portstr) {
  ------------------
  |  Branch (86:9): [True: 57, False: 0]
  ------------------
   87|     57|        port = atoi(portstr);
   88|     57|        if (port <= 0xffff)
  ------------------
  |  Branch (88:13): [True: 57, False: 0]
  ------------------
   89|     57|            strlcpy(ep_str->port, portstr, sizeof(ep_str->port));
   90|      0|        else
   91|      0|            goto err;
   92|     57|    }
   93|       |
   94|     57|    free(dup);
   95|     57|    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|     57|}
netsnmp_bindtodevice:
  105|     57|{
  106|       |    /* If no interface name has been specified, report success. */
  107|     57|    if (!iface || iface[0] == '\0')
  ------------------
  |  Branch (107:9): [True: 0, False: 57]
  |  Branch (107:19): [True: 57, False: 0]
  ------------------
  108|     57|        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(fd, 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|     57|    }
  125|       |#else
  126|       |    errno = EINVAL;
  127|       |    return -1;
  128|       |#endif
  129|     57|}
netsnmp_ipbase_session_init:
  132|     57|                            struct snmp_session *sess) {
  133|     57|    union {
  134|     57|        struct sockaddr     sa;
  135|     57|        struct sockaddr_in  sin;
  136|     57|        struct sockaddr_in6 sin6;
  137|     57|    } ss;
  138|     57|    socklen_t len = sizeof(ss);
  139|       |
  140|     57|    if (!sess) {
  ------------------
  |  Branch (140:9): [True: 0, False: 57]
  ------------------
  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|     57|    if (getsockname(transport->sock, (struct sockaddr *)&ss, &len) == -1) {
  ------------------
  |  Branch (145:9): [True: 0, False: 57]
  ------------------
  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|     57|    switch (ss.sa.sa_family) {
  150|     57|    case AF_INET:
  ------------------
  |  Branch (150:5): [True: 57, False: 0]
  ------------------
  151|     57|        sess->local_port = ntohs(ss.sin.sin_port);
  152|     57|        break;
  153|      0|    case AF_INET6:
  ------------------
  |  Branch (153:5): [True: 0, False: 57]
  ------------------
  154|      0|        sess->local_port = ntohs(ss.sin6.sin6_port);
  155|      0|        break;
  156|      0|    default:
  ------------------
  |  Branch (156:5): [True: 0, False: 57]
  ------------------
  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|     57|    }
  161|       |
  162|     57|    DEBUGMSGTL(("netsnmp_ipbase", "local port number %d\n", sess->local_port));
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
  163|       |
  164|     57|    return SNMPERR_SUCCESS;
  ------------------
  |  |  184|     57|#define SNMPERR_SUCCESS			(0)     /* XXX  Non-PDU "success" code. */
  ------------------
  165|     57|}
snmpIPBaseDomain.c:netsnmp_isnumber:
   12|    114|{
   13|    114|    if (!*cp)
  ------------------
  |  Branch (13:9): [True: 0, False: 114]
  ------------------
   14|      0|        return 0;
   15|       |
   16|    114|    while (isdigit((unsigned char)*cp))
  ------------------
  |  Branch (16:12): [True: 399, False: 114]
  ------------------
   17|    399|        cp++;
   18|    114|    return *cp == '\0';
   19|    114|}

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

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

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

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

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

netsnmp_tcpipv6_ctor:
  375|     57|{
  376|     57|    tcp6Domain.name = netsnmp_TCPIPv6Domain;
  377|     57|    tcp6Domain.name_length = OID_LENGTH(netsnmp_TCPIPv6Domain);
  ------------------
  |  |   64|     57|    (sizeof(x) / sizeof((x)[0]) +                                       \
  |  |   65|     57|     sizeof(int[-__builtin_types_compatible_p(typeof(x), typeof(&(x)[0]))]))
  ------------------
  378|     57|    tcp6Domain.f_create_from_tstring_new = netsnmp_tcp6_create_tstring;
  379|     57|    tcp6Domain.f_create_from_ostring     = netsnmp_tcp6_create_ostring;
  380|     57|    tcp6Domain.prefix = calloc(4, sizeof(char *));
  381|     57|    if (!tcp6Domain.prefix) {
  ------------------
  |  Branch (381:9): [True: 0, False: 57]
  ------------------
  382|      0|        snmp_log(LOG_ERR, "calloc() failed - out of memory\n");
  383|      0|        return;
  384|      0|    }
  385|     57|    tcp6Domain.prefix[0] = "tcp6";
  386|     57|    tcp6Domain.prefix[1] = "tcpv6";
  387|     57|    tcp6Domain.prefix[2] = "tcpipv6";
  388|       |
  389|     57|    netsnmp_tdomain_register(&tcp6Domain);
  390|     57|}

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

netsnmp_tlstcp_ctor:
 1105|     57|{
 1106|     57|    DEBUGMSGTL(("tlstcp", "registering TLS constructor\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]
  |  |  ------------------
  ------------------
 1107|       |
 1108|       |    /* config settings */
 1109|       |
 1110|     57|    tlstcpDomain.name = netsnmpTLSTCPDomain;
 1111|     57|    tlstcpDomain.name_length = netsnmpTLSTCPDomain_len;
 1112|     57|    tlstcpDomain.prefix = calloc(3, sizeof(char *));
 1113|     57|    if (!tlstcpDomain.prefix) {
  ------------------
  |  Branch (1113:9): [True: 0, False: 57]
  ------------------
 1114|      0|        snmp_log(LOG_ERR, "calloc() failed - out of memory\n");
 1115|      0|        return;
 1116|      0|    }
 1117|     57|    tlstcpDomain.prefix[0] = "tlstcp";
 1118|     57|    tlstcpDomain.prefix[1] = "tls";
 1119|       |
 1120|     57|    tlstcpDomain.f_create_from_tstring_new = netsnmp_tlstcp_create_tstring;
 1121|     57|    tlstcpDomain.f_create_from_ostring     = netsnmp_tlstcp_create_ostring;
 1122|       |
 1123|     57|    netsnmp_tdomain_register(&tlstcpDomain);
 1124|     57|}

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

netsnmp_udp_recvfrom:
  156|     56|{
  157|       |    /** udpipv4 just calls udpbase. should we skip directly to there? */
  158|     56|    return netsnmp_udpipv4_recvfrom(s, buf, len, from, fromlen, dstip, dstlen,
  159|     56|                                    if_index);
  160|     56|}
netsnmp_udp_create_tspec:
  683|     57|{
  684|     57|    netsnmp_transport *t = netsnmp_udpipv4base_tspec_transport(tspec);
  685|     57|    if (NULL != t) {
  ------------------
  |  Branch (685:9): [True: 57, False: 0]
  ------------------
  686|     57|        netsnmp_udp_transport_base(t);
  687|     57|    }
  688|     57|    return t;
  689|       |
  690|     57|}
netsnmp_udp_ctor:
  706|     57|{
  707|     57|    udpDomain.name = netsnmpUDPDomain;
  708|     57|    udpDomain.name_length = netsnmpUDPDomain_len;
  709|     57|    udpDomain.prefix = calloc(2, sizeof(char *));
  710|     57|    if (!udpDomain.prefix) {
  ------------------
  |  Branch (710:9): [True: 0, False: 57]
  ------------------
  711|      0|        snmp_log(LOG_ERR, "calloc() failed - out of memory\n");
  712|      0|        return;
  713|      0|    }
  714|     57|    udpDomain.prefix[0] = "udp";
  715|       |
  716|     57|    udpDomain.f_create_from_tstring_new = netsnmp_udp_create_tstring;
  717|     57|    udpDomain.f_create_from_tspec       = netsnmp_udp_create_tspec;
  718|     57|    udpDomain.f_create_from_ostring     = netsnmp_udp_create_ostring;
  719|       |
  720|     57|    netsnmp_tdomain_register(&udpDomain);
  721|     57|}
snmpUDPDomain.c:netsnmp_udp_transport_base:
  176|     57|{
  177|     57|    if (NULL == t) {
  ------------------
  |  Branch (177:9): [True: 0, False: 57]
  ------------------
  178|      0|        return NULL;
  179|      0|    }
  180|       |
  181|       |    /*
  182|       |     * Set Domain
  183|       |     */
  184|       |
  185|     57|    t->domain = netsnmpUDPDomain;
  186|     57|    t->domain_length = netsnmpUDPDomain_len;
  187|       |
  188|       |    /*
  189|       |     * 16-bit length field, 8 byte UDP header, 20 byte IPv4 header  
  190|       |     */
  191|       |
  192|     57|    t->msgMaxSize = 0xffff - 8 - 20;
  193|     57|    t->f_recv     = netsnmp_udpbase_recv;
  194|     57|    t->f_send     = netsnmp_udpbase_send;
  195|     57|    t->f_close    = netsnmp_socketbase_close;
  196|     57|    t->f_accept   = NULL;
  197|     57|    t->f_setup_session = netsnmp_ipbase_session_init;
  198|     57|    t->f_fmtaddr  = netsnmp_udp_fmtaddr;
  199|     57|    t->f_get_taddr = netsnmp_ipv4_get_taddr;
  200|       |
  201|     57|    return t;
  202|     57|}

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

netsnmp_udpipv6_ctor:
 1239|     57|{
 1240|     57|    udp6Domain.name = netsnmp_UDPIPv6Domain;
 1241|     57|    udp6Domain.name_length = OID_LENGTH(netsnmp_UDPIPv6Domain);
  ------------------
  |  |   64|     57|    (sizeof(x) / sizeof((x)[0]) +                                       \
  |  |   65|     57|     sizeof(int[-__builtin_types_compatible_p(typeof(x), typeof(&(x)[0]))]))
  ------------------
 1242|     57|    udp6Domain.f_create_from_tstring_new = netsnmp_udp6_create_tstring;
 1243|     57|    udp6Domain.f_create_from_tspec       = netsnmp_udp6_create_tspec;
 1244|     57|    udp6Domain.f_create_from_ostring     = netsnmp_udp6_create_ostring;
 1245|     57|    udp6Domain.prefix = calloc(5, sizeof(char *));
 1246|     57|    if (!udp6Domain.prefix) {
  ------------------
  |  Branch (1246:9): [True: 0, False: 57]
  ------------------
 1247|      0|        snmp_log(LOG_ERR, "calloc() failed - out of memory\n");
 1248|      0|        return;
 1249|      0|    }
 1250|     57|    udp6Domain.prefix[0] = "udp6";
 1251|     57|    udp6Domain.prefix[1] = "ipv6";
 1252|     57|    udp6Domain.prefix[2] = "udpv6";
 1253|     57|    udp6Domain.prefix[3] = "udpipv6";
 1254|       |
 1255|     57|    netsnmp_tdomain_register(&udp6Domain);
 1256|     57|}

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

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

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

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

